Hi @mycommunication,
I understand you’ve built a custom PHP script to add a “Late Fee” product to a WooCommerce subscription and charge the customer using an existing Stripe token. However, despite successful auto-renewals via WooCommerce, this manual charge attempt fails when using the same token. That definitely sounds frustrating, and I’ll do my best to point you in the right direction.
From what you’ve shared, here are a few key considerations that might explain why the custom purchase attempt is being declined:
- Stripe Customer Tokens vs. Payment Intents WooCommerce Subscriptions (with Stripe) uses payment method tokens tied to a Stripe customer object. When Stripe processes automatic renewals, it uses saved payment methods attached to that customer—typically through the setup_intent flow. If your custom script doesn’t correctly associate the saved payment method with the customer and fails to create a PaymentIntent with proper authentication context, Stripe may reject it due to missing authorization or SCA requirements.
- SCA (Strong Customer Authentication) If the card requires SCA (common with European cards), Stripe will require 3D Secure or another challenge even for saved cards. The built-in WooCommerce Stripe Gateway handles this automatically using setup_intent and off_session flags. For your script to work similarly, you must:
- Create a PaymentIntent with off_session set to true
- Attach the correct payment_method and customer ID
- Set confirm to true
- Handle the requires_action or authentication_required response gracefully
- Script Setup Steps At a minimum, your custom script should:
- Retrieve the WooCommerce Stripe customer ID (usually saved in wc_stripe_customer_id user meta)
- Retrieve the correct payment_method ID (Stripe token saved)
- Create a PaymentIntent via the Stripe API:
\Stripe\Stripe::setApiKey('sk_test_...');
$intent = \Stripe\PaymentIntent::create([
'amount' => 5000, // e.g., 50.00 EUR
'currency' => 'eur',
'customer' => $stripe_customer_id,
'payment_method' => $payment_method_id,
'off_session' => true,
'confirm' => true,
'description' => 'Late Fee for Subscription Order #1234',
'metadata' => [
'order_id' => 1234,
],
]);
– Catch and handle Stripe\Exception\CardException to capture SCA issues or declines
4. Check the Logs Enable logging in WooCommerce > Settings > Payments > Stripe, and check the logs under WooCommerce > Status > Logs > stripe-YYYY-MM-DD to see if the failure reveals a decline reason like insufficient_funds, authentication_required, or do_not_honor.
5. Test Mode vs. Live Mode Make sure your script uses the correct API key (test vs live) and tokens corresponding to the correct Stripe environment.
Let us know how that goes.
Hi there,
We haven’t heard back in a bit, so I’ll go ahead and mark this as resolved for now. If you’d like to pick things back up later, we’re just a message away!
Apart from this, if you have a moment, we’d really appreciate a review: https://ww.wp.xz.cn/support/plugin/woocommerce-gateway-stripe/reviews/#new-post