Skip to main content

Increasing Authorization Amount

When you authorize a payment instead of capturing it immediately, you might discover that you need to charge more than the original order total before capturing the funds. Perhaps you need to add rush shipping, include additional items the customer requested, or apply fees that weren't calculated at checkout. However, Stripe prevents you from capturing more than the originally authorized amount for security reasons.

This code sample shows how to increase the authorization amount by a percentage above the order total, giving you flexibility to modify orders after authorization without running into capture limitations.

When would you use this?

Increasing authorization amounts is particularly useful for businesses that frequently modify orders after initial payment authorization. Instead of having to process additional payments or re-authorize cards, you can build in a buffer that accommodates common order changes.

Common use cases include allowing for potential shipping upgrades that customers might request after placing their order, accommodating custom orders where final pricing might increase during production, building in room for additional fees or taxes that might apply during fulfillment, or providing flexibility for B2B orders where quantities or specifications often change before shipping.

The Code

This example increases the authorization amount by 25% above the order total, giving you room to capture additional funds if needed while still processing the customer's original order amount.

/**
* Increase payment authorization amount to allow for order modifications
* @param array $args Payment intent arguments
* @param WC_Order $order The order object
* @return array Modified payment intent arguments with increased amount
*/
add_filter('wc_stripe_payment_intent_args', function($args, $order){
$amount = $args['amount'];
$args['amount'] = $amount + ($amount * 0.25); // 25% increase
return $args;
}, 10, 2);

How the Code Works

The code uses the wc_stripe_payment_intent_args filter, which runs when Stripe payment intents are being created. This filter allows you to modify the arguments that will be sent to Stripe before the payment intent is actually created.

The function retrieves the original order amount from $args['amount'], which is stored in Stripe's smallest currency unit (cents for USD). It then calculates a 25% increase by multiplying the amount by 0.25 and adding that to the original amount. The modified amount is then stored back in the arguments array that gets sent to Stripe.

When the payment is authorized, Stripe will hold the increased amount on the customer's payment method, even though your WooCommerce order reflects only the original total. This gives you the flexibility to capture up to the higher authorized amount if order modifications are needed.

Customizing the Authorization Increase

You can easily adjust the increase percentage or implement more sophisticated logic based on your business needs:

Different percentage increase:

// 15% increase instead of 25%
$args['amount'] = $amount + ($amount * 0.15);

Fixed dollar amount increase:

// Add $50 buffer (5000 cents for USD)
$args['amount'] = $amount + 5000;

Conditional increases based on order total:

if($amount >= 10000){ // Orders over $100
$args['amount'] = $amount + ($amount * 0.15); // 15% increase
} else {
$args['amount'] = $amount + ($amount * 0.30); // 30% increase for smaller orders
}

Different increases by product category:

$needs_large_buffer = false;
foreach($order->get_items() as $item){
$product = $item->get_product();
if($product && in_array(15, $product->get_category_ids())){ // Custom products category
$needs_large_buffer = true;
break;
}
}

$increase = $needs_large_buffer ? 0.40 : 0.25; // 40% vs 25%
$args['amount'] = $amount + ($amount * $increase);

Important Considerations

When you increase the authorization amount, customers will see the higher amount as a pending charge on their payment method, even though your WooCommerce order shows the lower original total. This can cause confusion and customer service inquiries, so it's important to communicate your payment process clearly to customers.

Consider adding order notes or email notifications that explain why the pending amount might be higher than the order total. You might also want to include this information in your checkout terms or payment policies.

Remember that you can only capture up to the authorized amount. If you need to charge more than your increased authorization, you'll need to create a separate payment or ask the customer to authorize additional funds.

Testing Your Implementation

To verify the increased authorization is working correctly, place a test order in your Stripe test environment and check your Stripe dashboard. The payment intent should show the increased amount as authorized, while your WooCommerce order displays the original total.

You can also add logging to track when authorization amounts are increased:

add_filter('wc_stripe_payment_intent_args', function($args, $order){
$original_amount = $args['amount'];
$args['amount'] = $original_amount + ($original_amount * 0.25);

wc_stripe_log_info("Order {$order->get_id()}: Original amount {$original_amount}, Authorized amount {$args['amount']}");

return $args;
}, 10, 2);

Remember to adjust the increase percentage to match your specific business needs and communicate the authorization process clearly to your customers to avoid confusion about pending charges.