#kun_incomplete-subscription
1 messages ยท Page 1 of 1 (latest)
๐ 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/1271161627009618034
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
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.
- kun_setupintent-3ds, 39 minutes ago, 9 messages
- kun_api, 2 days ago, 23 messages
- kun_api, 6 days ago, 12 messages
Well I have issues creating subscription with status = "incomplete" abd need help please
any helpo please
Are you setting the Payment Method as default for that Customer?
https://stripe.com/docs/api/customers/update#update_customer-invoice_settings
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
can you eplain it please
You have to set a Payment Method as default in order for the Subscription to use it for payment
Ok thanks let me try it
is there any problem with this code
const createSubscription: any = await this.stripe.subscriptions.create({
customer: paymentInfo.customerId,
items: [{ price: 'price_1JejcNFrwl37tCGijYmb0GU8' }], // Replace 'priceId' with your actual Stripe price ID
default_payment_method: paymentInfo.paymentMethodId,
expand: ['latest_invoice.payment_intent'],
});
That will set the Payment Method as the default on the Subscription object, which should work. Keep in mind, you can also set it on the Customer object so that it's used for all invoices and subscriptions. As it stands now, it will only be used as default for that one subscription
you mean when I creating the customer?
this is where I am creating the customer
'''
const newCustomer = await this.stripe.customers.create(
{
email: userEmail,
payment_method: paymentMethodId,
invoice_settings: {
default_payment_method: paymentMethodId,
},
}
);
No, when you create the Payment Method you would update the customer: https://docs.stripe.com/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 went through this before
Serioulsy I dont understand it
please can you explain so I can fix it
I don't really know how to explain it any better. Once you create the Payment Method and attach it to the Customer, you can set it as the defualt on either the Customer or the Subscription.
ok let me tell you the flow I am following
1 create paymentMethodId from ngx stripe
2 Send this paymentMethodId at backend and creat customer
3 Then I create the SetupIntnt
4 Then I create the subscription for recurring payments
now where I need to attach this paymentMethodId to the customer?
when I am creatiung the customer or some where else?
Where are you attaching the Payment Method to the customer? These steps seem very out of order and some are missing
well our application needs this
add card anc validate it
then after 7 days the subscription started and then recurring payment started
well I checked once the paymentMethodId
from ngx stripe
I sttached the same paymentMethodId
while creating Customer
then Setup Intent
and then for subsctription
This is really difficult to understand when it's short 3 word sentences stacked on top of each other. Please take some time and reword your explanation
ok let me explain it
Step 1: using ngx stripe library for angular I use stripe elements to get card Details securley and then
I use this piece of code
this.stripeService
.createPaymentMethod({
type: "card",
card: this.card.element,
billing_details: {
name: nameOnCard,
},
})
to create paymentMethodId
Step2: Once I have paymentMethodId on frontend I sent it back to my server to create new customer using stripe.js library Here is the code
this.stripe.customers.create(
{
email: userEmail,
payment_method: paymentMethodId,
invoice_settings: {
default_payment_method: paymentMethodId,
},
}
);
and here I make sure I am attaching the same paymentMethodId what I get in step 1
is it clear with these two steps then I ll epxlain the other steps
Are those steps working as expected?
Hi there ๐ jumping in as my teammate needs to step away soon. Those Subscriptions are showing up as incomplete due to the payment_behavior being used:
https://docs.stripe.com/api/subscriptions/create#create_subscription-payment_behavior
You aren't specifying a payment_behavior to use, so the default behavior is used which is allow_incomplete. When using that behavior, the Subscription ends up in an incomplete status when the first payment cannot be completed. In the Subscription you shared, that's because 3DS is being required for the first payment, and your customer must complete that authentication challenge in order for that payment to complete.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Can you tell me more about your Setup Intent step that you've mentioned?
kun_incomplete-subscription
ok I get your Point
when I do steupIntent some of card I get status ="succeeded" and some of the "required_actions" how can I do 3DS for succeeded?
Is this the main problem I am getting
You don't do it for succeeded intents, it's the ones that end up in requires_action that you need to take action for. I'm guessing you're creating/confirming those intents server-side?
yes
And for succeeded items
I then use the same paymentMethodId
and try to create subscription
const createSubscription: any = await this.stripe.subscriptions.create({
customer: paymentInfo.customerId,
items: [{ price: 'price_1JejcNFrwl37tCGijYmb0GU8' }], // Replace 'priceId' with your actual Stripe price ID
default_payment_method: paymentInfo.paymentMethodId,
expand: ['latest_invoice.payment_intent'],
collection_method: 'charge_automatically'
});
and I get status incomplete
Can you share the ID of a Setup Intent that succeeded successfully where you saw that behavior?
It is worth noting that your flow should always be prepared to handle the scenario where a customer has to complete a 3DS challenge. It's up to the issuer of their card to decide whether 3DS is required for each transaction, so it's possible for a challenge to need to be completed for an already set up card.
let me send you the id of setup intent
sending please allow me 2 minutes
{
id: "seti_1PlbjCFrwl37tCGiqKZ4pDWj",
object: "setup_intent",
application: null,
automatic_payment_methods: {
allow_redirects: "never",
enabled: true,
},
cancellation_reason: null,
client_secret: "seti_1PlbjCFrwl37tCGiqKZ4pDWj_secret_QcrSRqKufFSIpKifqK62U2fLFE7JK25",
created: 1723144226,
customer: "cus_QcrREVy3EcFwUf",
description: null,
flow_directions: null,
last_setup_error: null,
latest_attempt: "setatt_1PlbjCFrwl37tCGipR5r0hHM",
livemode: true,
mandate: null,
metadata: {
},
next_action: null,
on_behalf_of: null,
payment_method: "pm_1Plbj0Frwl37tCGi8H1Hisv6",
payment_method_configuration_details: {
id: "pmc_1LSodjFrwl37tCGiiS9ShhOg",
parent: null,
},
payment_method_options: {
card: {
mandate_options: null,
network: null,
request_three_d_secure: "automatic",
},
},
payment_method_types: [
"card",
"link",
],
single_use_mandate: null,
status: "succeeded",
usage: "off_session",
}
this is the response of my setup intent
Gotcha. Was this working as expected in testmode when you used our 3DS test cards to step through this flow? And do you have flexibility to adjust your flow?
I think the problem here is that you're creating and attaching the Payment Method to the Customer first. Both of those are actions that are part of a Setup Intents lifecycle, so it's typically easier and smoother to let the Setup Intent do those parts for you.
ohhhh
I get it now
Well let me share my customer creation method
const newCustomer = await this.stripe.customers.create(
{
email: userEmail,
payment_method: paymentMethodId,
invoice_settings: {
default_payment_method: paymentMethodId,
},
}
);
this is the method
can you reconfirm it
well Let me share another thing
I just used another card which status is "required_action" and used 3DS
and after I reconfirm the 3DS
the create subscription still showing me incomplete status
What I would typically recommend here is the following:
- Create a Customer object
- Create a Setup Intent for that Customer
- Use the Setup Intent + either the Payment Element to collect payment details and handle 3DS (https://docs.stripe.com/payments/save-and-reuse?platform=web&ui=elements)
- Use the resulting Payment Method to create the Subscription object
But that's only if you want to collect payment method details before creating the Subscription object.
Well I double check it my paymentMethodId is same for customer and for the setup intent
The Setup Intent will create a Payment Method using the approach I described, and attach it to the Customer, so you don't have to do any validation there if you use the approach I suggest.
However, going back to the point I raised earlier, your Subscription flow should always be prepared to handle the case where an issuer requires 3DS. Since neither you nor us at Stripe have control over when that is required.
so what shoud I do with paymentMethodid I am geeting from ngx stripe elements?
Don't do that, don't create a Payment Method directly.
I am handling this
However, going back to the point I raised earlier, your Subscription flow should always be prepared to handle the case where an issuer requires 3DS. Since neither you nor us at Stripe have control over when that is required.
toby can you explain my flow to you
may be you can help me better
Okay, so you already have a way to recover the Subscriptions ending up in an incomplete state, you're just looking to minimize how often that happens?
Sorry what?
I mean should I explain my whole flow maybe I am doing something wrong?
I have 4 steps can I explain it in details?
You're welcome to, but I think I already understand, and am suggesting a better path.
can you please explain the path in steps
because I am getting the paymentMethodId from stripe elements
then use this id to create the customer
then use customer id and same paymentMethodId to create setupintent
Were you following one of our guides when you built this flow? If so, can you share a link to that?
no I took different examples from different articles of medium, chatpgpt and stack overflow
Gotcha, unfortunately it's a sub-par flow that you've ended up with.
I'd recommend not doing this step:
because I am getting the paymentMethodId from stripe elements
And instead use the flow I outlined earlier:
- Create a Customer object
- Create a Setup Intent for that Customer
- Use the Setup Intent + either the Payment Element to collect payment details and handle 3DS (https://docs.stripe.com/payments/save-and-reuse?platform=web&ui=elements)
- Use the resulting Payment Method to create the Subscription object
But, even that may not be necessary, the first Payment Intent of the Subscription can be used to setup the resulting Payment Method for future usage. You want to use Elements as part of your flow, right?
I have a quick question here?
I cant directly use the details of card from frontend
What's the question?
I cant directly use the details of card from frontend
Correct
But, even that may not be necessary, the first Payment Intent of the Subscription can be used to setup the resulting Payment Method for future usage. You want to use Elements as part of your flow, right?
yes I want to use the stripe elements
so How can I create the customer directly
This is the flow I'd recommend using then:
https://docs.stripe.com/billing/subscriptions/build-subscriptions?platform=web&ui=elements
That guide walks through every piece of the flow.
You don't need payment method details to create a Customer.
another quick question
my flow is to validate the card and save it to our databse and then use this card for the future subscription payments
Then I'd recommend the flow I laid out in this message.
this one?
Yup
ok let me try it and then I want to ask more question from here can i resume my chat from here?
Yup, I'll leave the thread open for as long as I'm here. (about another hour)
ok let me try
so the flow you have suggested
1 create the customer and get the customer ID
2 create the setupIntent using the customer id
3 setupIntent sends a client secret which should be used along side with customer card detils geeting from the stripe card element
4 and then create the PaymentIntent for later
but I have a question
I want do the subscription in the end instead of one time payment
4 would be create the Subscription, but otherwise yes
As I suggested:
Use the resulting Payment Method to create the Subscription object
ohhh so I should follow the first 3 steps
and then in the end create subscription
Oh, yeah, the guide shows creating a Payment Intent. Sorry, I forgot about that!
One final question
if I need some help like tomorrow how can I resume my chat?
so In the end instead of creating Payment Intent I should create Subscription?
Yes, you'd create a Subscription instead. The chat will be closed by then, but if you summarize what is giving you troubles tomorrow in a new question whoever is staffing the server at that time will be happy to help.
will he can see my previous msgs so I can help him understand the problems
If you still have questions now, I'm happy to help with them. This is a long thread though, and the server tends to get quite busy, so my teammates staffing the server later likely won't have time to review everything. If you're running into problems tomorrow, you should explain what those problems are so the team member helping you can understand what problem you're encountering and provide advice for that.
got it brother
and thanks for the help
a quick thing the last two link you have sent me
"Setup future payments for later"
"Subscription"
I have my solution in these articles?
I think so, mostly the Setup Future Payments one. You already have code to create Subscriptions, so that will mostly be the same since the Setup Intent will give you a Payment Method to work with.
The issuer of the card being used decides whether 3DS must be completed. It'll likely be triggered during the Setup Intent confirmation. It may also be required when you create the Subscription though.
the Setup Intent is in server side how can I do the 3DS
You confirm it client-side with the information that the Payment Element collected. Step 6 in the guide shows that confirmation process.