#satujamsaja_api

1 messages ยท Page 1 of 1 (latest)

warm stratusBOT
#

๐Ÿ‘‹ 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/1445165086736908288

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

grand pond
#

Hi there ๐Ÿ‘‹ did you set the Payment Method that was created from the Setup Intent as the customer's default payment method?

#

You can do that by updating invoice_settings.default_payment_method. Alternatively, you can provide the payment method as the default_payment_method when creating the Subscription, to only use that Payment Method as the default for that Subscription.

warm stratusBOT
scarlet kayak
#

Is it when creating subscription? But payment_method was used for creating payment intent?

grand pond
#

The Payment Intens for Subscriptions are created automatically. How do you think you passed the Payment Method to that? Can you share your code?

scarlet kayak
#

// Payment intent data.
$payment_intent_data = [
'amount' => $webform_data[$amount_charged] * 100,
'currency' => 'nzd',
'payment_method' => $payment_methods->data[0]->id,
'customer' => $customer->id,
'confirm' => true,
'off_session' => true,
'description' => $product_name,
];

grand pond
#

Gotcha, thank you. You don't need to create your own Payment Intents for Subscriptions.

scarlet kayak
#

So whats the code for the subscription ?

grand pond
#

Where do you want to set the default payment method. At the Customer object level, so it will be used for all Subscriptions, or at the Subscription level (which overrides the Customer level one)?

scarlet kayak
#

Where the payment should work with 3d secure

#

Hang on let me do quick test

stuck marlin
#

๐Ÿ‘‹ Toby needs to run, I'll be taking over the thread, let me know if you have any questions after testing.

scarlet kayak
#

Thanks @stuck marlin

#

That's my curret setup when testing with 3d secure card number 4000 0000 0000 3220

#

My current flow

#

setupintent created ->
retrieve setupinent ->
creatr customer with payment method attached and invoice settings->
create payment_intent with customer data and payment methode ->
create subscription with customer data and price_id

stuck marlin
#

As Toby mentioned there isn't any need to manually create the Payment Intent.
When you create the Subscription it's going to generate an Invoice, and depending on the collection method you specified during Subscription creation it's either going to send an invoice, or charge the user automatically (using either the PM saved on the customer, or the PM set on the Subscription during creation) In either case there is no need to manually create a Payment Intent.
https://docs.stripe.com/api/subscriptions/create#create_subscription-collection_method

scarlet kayak
#

I see so creating payment intent wasn't necessary? Attaching customer id to subscription will automatically charge customer with attached payment method?

stuck marlin
#

Correct, so long as you set charge_automatically as the collection_method it will charge the default_payment_method on the customer

scarlet kayak
#

Got it, so it's not related to the use of 3d secure?

stuck marlin
#

Typically, 3DS comes into play during the setup intent when, we request an exemption from the issuer for future payments. Those 3DS test cards are generally for use when the customer is on-session and available to handle the redirect the 3DS modal. (Ie when testing payment forms)