#verox_api
1 messages ¡ Page 1 of 1 (latest)
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- verox_subscription-retries, 29 minutes ago, 9 messages
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1237046698140762185
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
// Set payment method for the payment intent
$request->user()->updateStripeCustomer(['invoice_settings' => ['default_payment_method' => $intent->payment_method]]);
$invoice = Cashier::stripe()->invoices->retrieve($intent->metadata['invoice']);
Cashier::stripe()->paymentIntents->update($invoice->payment_intent, ['payment_method' => $intent->payment_method]);
// Loop through all subscriptions and update the payment method
$request->user()->subscriptions()->active()->notCanceled()->each(function ($subscription) use ($intent) {
Cashier::stripe()->subscriptions->update(
$subscription->stripe_id,
['default_payment_method' => $intent->payment_method]
);
});
I tried that so far, but it only updates the default payment method and the subscriptions payment methods. The only thing that isn't updated is the payment intent.
Why isn't it working?
I only have that one: req_1wG0cdutaWKMAu
Looking at the Sub for that Customer
The request of the paymentIntent payment method being updated doesn't even appear in the logs.
Even though I logged it like that and the subscription payment methods get updated
$request->user()->updateStripeCustomer(['invoice_settings' => ['default_payment_method' => $intent->payment_method]]);
$invoice = Cashier::stripe()->invoices->retrieve($intent->metadata['invoice']);
Log::info('Updating payment method for invoice ' . $invoice->id . ' to ' . $intent->payment_method);
Cashier::stripe()->paymentIntents->update($invoice->payment_intent, ['payment_method' => $intent->payment_method]);
-> [2024-05-06 1431] local.INFO: Updating payment method for invoice in_1PDRvwBxo62JExo2Hx6HVrHL to pm_1PDSVoBxo62JExo2TNbl2I2E
I see that update right here: https://dashboard.stripe.com/test/logs/req_GsHDUWSBBmw6t6
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Why am I not seeing it? Nvm, at least now we can take a look at it.
Really that is a more complicated way to do it. If you want to just attempt to charge again with the updated PaymentMethod you should just confirm the PaymentIntent, not update it.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Yeah, I already do that after the payment method is updated:
if ($invoice->status == 'draft' || $invoice->status == 'uncollectible') {
try {
$invoice->pay();
} catch (\Exception $e) {
// The payment method has been removed or is invalid. Prompt user to set up a new default payment method
// Prompt user to set up a new default payment method if none exists
$setup = $request->user()->createSetupIntent([
'payment_method_types' => config('cashier.charge.' . $invoice->currency),
'metadata' => [
'type' => $metadata['type'],
'invoice' => $invoice->id,
'name' => $metadata['name'],
'price' => $invoice->amount_due,
'period' => $metadata['period'],
'currency' => $invoice->currency
],
'usage' => 'off_session'
]);
return redirect()->route('payment.setup', ['intent' => $setup->id, 'error' => $request->has('intent')]);
}
}
But it keeps charging the old payment method, instead of the new one.
Yeah you are doing $invocie -> pay() which is not confirming the PaymentIntent, it is calling the /pay endpoint. But if you are going to do that then similarly ignore the PaymentIntent update request (there is really no reason to do that) and instead just pass the PaymentMethod ID to the pay() request: https://docs.stripe.com/api/invoices/pay#pay_invoice-payment_method
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Ah, okay. I'll try that. Thanks.
So like this?
$invoice->pay([
'payment_method' => $request->user()->defaultPaymentMethod()->id,
]);
Yep try that
Great, that worked like a charm! Thanks a lot.