#ashishchicmic
1 messages · Page 1 of 1 (latest)
You can try yes, but there is always a chance the bank will request 3DS/auth again. We do optimise to reduce chances of that though
const data = {
customer,
items: [
{ price },
],
default_payment_method: cardId,
collection_method: 'charge_automatically',
transfer_data: {
destination: config.STRIPE.ADMIN_CONNECT_ACCOUNT_ID,
amount_percent: referralPercentages,
},
payment_behavior: 'default_incomplete',
payment_settings: { save_default_payment_method: 'on_subscription' },
expand: ['latest_invoice.payment_intent'],
};
Above is the data which is used to create a asubscription, do I need to modify something?
Seems mostly fine. Is there a specific error?
Can you share the sub_xxx ID that is generated?
sub_1NffjCKKfDNzQrclO9vdPgw7
It's because you're passing payment_behavior: 'default_incomplete'
The Subscription will always start in an incomplete status with that param, until you manually confirm the associated Payment Intent
You can omit that, and it'll default to allow_incomplete which will automatically attempt payment
Just did that, but now i'm getting invoice.payment_failed. Below is the request data while creating subscription:
{
customer: 'cus_OSZ13YqsMKT0FF',
items: [ { price: 'price_1N5mAtKKfDNzQrclMr6knebz' } ],
default_payment_method: 'card_1NfdtAKKfDNzQrclc4xBy9Yh',
collection_method: 'charge_automatically',
transfer_data: { destination: 'acct_1NR9UZQKJsJv3hQy', amount_percent: 86.8 },
payment_settings: { save_default_payment_method: 'on_subscription' },
expand: [ 'latest_invoice.payment_intent' ]
}
Again, the ID is more helpful
sub_1Nfft1KKfDNzQrclpQXAoEVq
I suspect that 3DS is requested. Any reason why you're using card_xxx objects?
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
So you'd need to bring your user on-session and confirm the Payment Intent
According to my frontend dev, to confirm payment intent, we need a card element. But in this case while creating another subscription we don't have card element. is there another way?
Well as I explained, you're using card_xxx objects which don't support being correctly setup/saved for future 3DS re-use like this
You should be using Payment Method objects that are generated via an initial Subscription or a Setup Intent
So you are suggesting I should pass payment method id in default_payment_method?
Well, yes. But the more pertinent question is whether the pm_xxx ID you have is correctly setup for off-session usage
To confirm, these are scenarios where your users are off-session yes?
Because if they are you should be passing off_session: true: https://stripe.com/docs/api/subscriptions/create#create_subscription-off_session
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
We can request 3DS exemptions in those scenarios
When I create inital subscription for the user then we follow the confirmation part from the user. is this what you mean by setup?
Yes, that should generate a pm_xxx ID. Use that
Also, as I stated, if for these subsequent Subscriptions the user is offline (i.e. not present), then you need to pass off_session: true on creation
We can request exemptions which may reduce the likelihood of 3DS being requested
ok. let me check it and get back
I guess there is some issue with my initial subscription also. because I checked when i get invoice.paid during initial subscription, the default payment method id null
I dont know what i'm doing wrong
what i'm doing is:
- create stripe customer
- create a card for that customer using stripe customer id and the card token i receive from frontend.
await stripe.customers.createSource(
customerId,
{ source: token },
);
- create a subscription
I'm seeing that you are using sources, which doesn't support 3DS:
https://stripe.com/docs/sources
You shoul dbe using new PaymentIntent/Methods API following this guide:
https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements
now we are following same approach, using payment intents client secret to confirm payment on frontend. Also i'm getting invoice.create and invoice.paid event, but still i'm seeing default payment as null in invoice.paid event
sub_1NfgTNKKfDNzQrcljsLTAK5u , its the subsciption id
if you are getting invoice.paid event that means the invoice was paid.
What are you looking for exactly ?
If you want to set default payment method for the customer you can update the customer object after collecting the payment method via this API:
https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method
i'm looking for payment method id. where do I get it? because in inovice.paid event its null
You need to refer to the invoice's payment_intent's payment method in order to get the PaymentMethod Id.
this is my invoice.paid event id evt_1NfglOKKfDNzQrclY6GhdSUP. When i'm fetching payment intent details from this, i still get default payment method as null