I'm implementing stripe subscription using stripe-php library, following this doc https://stripe.com/docs/billing/subscriptions/fixed-price
Simulating customer subscription with failed payment method, stripe subscription object generated successfully with invoice status open.
The issue is when implementing retry-invoice on my backend, my code as below:
// retrieve new payment method (valid one)
$payment_method = \Stripe\PaymentMethod::retrieve (
$request->paymentMethodId
);
// attach customer to payment method
$payment_method->attach([
'customer' => $request->customerId,
]);
// update customer default payment method
\Stripe\Customer::update($request->customerId, [
'invoice_settings' => [
'default_payment_method' => $request->paymentMethodId
]
]);
// retrieve invoice object
$invoice = \Stripe\Invoice::retrieve($invoiceId, [
'expand' => ['payment_intent']
]);
On stripe dashboard, customer default payment method has successfully updated with latest one (valid card), but the subscription invoice remain as open.
Please help, anyone also facing this issue? i'm afraid that i have missed some steps to follow from stripe docs.