#mhanzla80 - subscriptions
1 messages · Page 1 of 1 (latest)
Could you please share the customer id?
Thanks for sharing it
So you should update your customer and set a invoice_settings.default_payment_method
you can refer to this link for further details
https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_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.
i do not have the payment method id. I am initializing the payment sheet which automatically generator the payment method on stripe and process the payment.
How do i get the payment method Id ?
invoice_settings.default_payment_method needs the payment method Id but i do not have it.
How can i get it ?
You can use the API that List a customer's payment methods
https://stripe.com/docs/api/payment_methods/customer_list
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
how do we know that user select and user which payment method in the payment sheet ?
Do you have a screenshot on your paymentsheet please?
ok makes sense
so no, you don't need to set a default_payment_mehtod
instead you should create the subscription and pass payment_behavior:default_incomplete like we mention in the docs
https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements#create-subscription
customer: customerId,
items: [{
price: priceId,
}],
payment_behavior: 'default_incomplete', // <----
payment_settings: { save_default_payment_method: 'on_subscription' }, // <---
expand: ['latest_invoice.payment_intent'],
});
cool cool
but yep, the idea is the same as in that doc ( https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements), we just don't cover mobile apps specifically.
but the idea is you create the subscription in the 'incomplete' status, then you pass the PaymentIntent from that Subscription to the frontend app; the app confirms the PaymentIntent using the PaymentSheet, and that saves the card the customer used and sets it as a default.
okay so you mean we have to call the subscription api before open payment sheet ?
Hi! I'm taking over this thread.
k;
Yes, you first create the subscription on the backend, and then use the subscription.latest_invoice.payment_intent for the PaymentSheet.
where do i have to pass these parameters ?
Which parameters? You need the payment_intent.client_secret to initialize the PaymentSheet: https://stripe.com/docs/payments/accept-a-payment?platform=android&ui=payment-sheet#android-collect-payment-details
subscription.latest_invoice.payment_intent
these parameters.
where do i have to pass them ?
When you create the subscription, you get subscription.latest_invoice.payment_intent.client_secret. Then you pass them to the PaymentSheet as shown here: https://stripe.com/docs/payments/accept-a-payment?platform=android&ui=payment-sheet#android-collect-payment-details
👋 taking over for my colleague. Let me know if there's any follow-up Qs I can answer!
i have implemented the flow that you have told me but it processing the incomplete subscription payment
how can i solve this ?
what webhook events are you listening to?
there is no any webhook
i am using it on phone
i am creating a subscription with incomplete payment and then passing the payment intent secret to the payment sheet but still payment status for subscription is incompete
what's the subscription ID sub_xxx?
sub_1LQWpCR1SG2Iic1Y7o96LArd
doesn't look like you confirmed the PaymentIntent.
and then passing the payment intent secret to the payment sheet
yep, and then you should be entering a card in the payment sheet and submitting the payment. Are you not doing that?
yes i am retrieving customer's saved card and select and pay for it
here you can see this
and what happens when you hit the Pay button in that UI?
success
you're confirming the wrong PaymentIntent
if you check what you're doing, you create a PaymentIntent(which you don't need to do), and you create a Subscription. Then on the frontend you are confirming that PaymentIntent you created, instead of the latest_invoice.payment_intent, which is what you should be doing instead.
you mean i do not have to create the payment intent
on subscription object i receive a payment intent secret id which i have to pass to the payment sheet
right ?
correct
correct
that's what we've been saying and the docs describe
for example ^^ this message explicitly mentioned it