#kun_incomplete-subscription

1 messages ยท Page 1 of 1 (latest)

spring capeBOT
#

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

crystal ploverBOT
#

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.

noble needle
#

Well I have issues creating subscription with status = "incomplete" abd need help please

#

any helpo please

swift cloak
noble needle
#

can you eplain it please

swift cloak
#

You have to set a Payment Method as default in order for the Subscription to use it for payment

noble needle
#

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'],
});

swift cloak
#

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

noble needle
#

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,
},
}
);

swift cloak
noble needle
#

I went through this before
Serioulsy I dont understand it
please can you explain so I can fix it

swift cloak
#

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.

noble needle
#

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?

swift cloak
#

Where are you attaching the Payment Method to the customer? These steps seem very out of order and some are missing

noble needle
#

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

swift cloak
#

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

noble needle
#

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

spring capeBOT
swift cloak
#

Are those steps working as expected?

noble needle
#

yes

#

should I explain the other last 2 steps?

toxic lynx
#

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.

#

Can you tell me more about your Setup Intent step that you've mentioned?

spring capeBOT
#

kun_incomplete-subscription

noble needle
#

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

toxic lynx
#

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?

noble needle
#

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

toxic lynx
#

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.

noble needle
#

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

toxic lynx
#

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.

noble needle
#

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

toxic lynx
#

What I would typically recommend here is the following:

But that's only if you want to collect payment method details before creating the Subscription object.

Learn how to save payment details and charge your customers later.

noble needle
#

Well I double check it my paymentMethodId is same for customer and for the setup intent

toxic lynx
#

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.

noble needle
#

so what shoud I do with paymentMethodid I am geeting from ngx stripe elements?

toxic lynx
#

Don't do that, don't create a Payment Method directly.

noble needle
#

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

toxic lynx
#

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?

noble needle
#

I mean should I explain my whole flow maybe I am doing something wrong?

#

I have 4 steps can I explain it in details?

toxic lynx
#

You're welcome to, but I think I already understand, and am suggesting a better path.

noble needle
#

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

toxic lynx
#

Were you following one of our guides when you built this flow? If so, can you share a link to that?

noble needle
#

no I took different examples from different articles of medium, chatpgpt and stack overflow

toxic lynx
#

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:

Learn how to save payment details and charge your customers later.

#

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?

noble needle
#

I have a quick question here?
I cant directly use the details of card from frontend

toxic lynx
#

What's the question?

noble needle
#

I cant directly use the details of card from frontend

toxic lynx
#

Correct

noble needle
#

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

toxic lynx
noble needle
#

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

toxic lynx
toxic lynx
#

Yup

noble needle
#

ok let me try it and then I want to ask more question from here can i resume my chat from here?

toxic lynx
#

Yup, I'll leave the thread open for as long as I'm here. (about another hour)

noble needle
#

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

toxic lynx
#

4 would be create the Subscription, but otherwise yes

#

As I suggested:

Use the resulting Payment Method to create the Subscription object

noble needle
#

ohhh so I should follow the first 3 steps
and then in the end create subscription

toxic lynx
#

Oh, yeah, the guide shows creating a Payment Intent. Sorry, I forgot about that!

noble needle
#

One final question
if I need some help like tomorrow how can I resume my chat?

noble needle
toxic lynx
#

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.

noble needle
#

will he can see my previous msgs so I can help him understand the problems

toxic lynx
#

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.

noble needle
#

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?

toxic lynx
#

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.

noble needle
#

one last thing

#

in this flow do we need 3DS

toxic lynx
#

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.

noble needle
#

the Setup Intent is in server side how can I do the 3DS

toxic lynx
#

You confirm it client-side with the information that the Payment Element collected. Step 6 in the guide shows that confirmation process.

noble needle
#

got it

#

let me try this GOD WILLING it will work

#

Thanks brother for this information and help

#

Have a nice day