#vlad-ko_subscription-intent-mismatch

1 messages ยท Page 1 of 1 (latest)

tiny sundialBOT
#

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

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

abstract glade
#

so basically it is failing on mobile side like that

queen trout
#

What exactly is the error you are seeing, what steps are you taking, and when does the error occur?

abstract glade
#

on backend i rewrite the logic - initially i was looking for latestInvoiceObject?.paymentIntentObject?.clientSecret

#

i want to collect the payment details in advance and give the users free period for N days

#

i change the logic to

#

hasTrialOption -> stripeSubscription.pendingSetupIntentObject.clientSecret

#

hasNoTrialOption -> stripeSubscription.latestInvoiceObject.paymentIntentObject.clientSecret

#

subscription setup is like that

queen trout
#

And it sounds like one of those options is not returning a valid client secret, right?

abstract glade
#

SubscriptionCreateParams.TrialSettings.EndBehavior.builder()
.setMissingPaymentMethod( -> MissingPaymentMethod.CANCEL

#

.setPaymentBehavior(SubscriptionCreateParams.PaymentBehavior.DEFAULT_INCOMPLETE)

#
  • .addExpand("latest_invoice.payment_intent")
    .addExpand("pending_setup_intent")
#

I will try now with SubscriptionCreateParams.TrialSettings.EndBehavior.builder()
.setMissingPaymentMethod( -> MissingPaymentMethod.CREATE_INVOICE

#

do you need subscription id

queen trout
#

Sorry but that makes no sense to me

abstract glade
#

you can check this one sub_1SCiJMCOtHrcpcR8FrGfukuA (old code)

queen trout
#

All I'm asking is which option is resulting in the client secret error?

abstract glade
#

if i add this .setTrialPeriodDays(createRequest.trialPeriodInDays) the payment on ios is failing with the error above

#

if i don't have trial -> all good (sub_1SCiHgCOtHrcpcR8sYMfEQPz)

queen trout
#

Okay so let's focus on the subscription with the trial period days

#

Can you log the client secret?

abstract glade
#

will need some time add deploy the logging

queen trout
#

Wait a sec. Looking at the code screenshot, it looks like what is failing is a check to validate the client secret matches for a Payment Intent

#

But you are returning a client secret for a Setup Intent

#

So that's expected

abstract glade
#

pendingSetupIntentObject.clientSecret: seti_1SCjvXCOtHrcp...._secret_T91zE3T4T2n2mO2....

#

latestInvoiceObject.paymentIntentObject.clientSecret: null

#

Wait a sec. Looking at the code screenshot, it looks like what is failing is a check to validate the client secret matches for a Payment Intent
but this is wrong setup on client (ios) side

#

?

queen trout
#

Sorry but none of that makes any sense to me

#

Why would this be a wrong setup on client side? what do you mean by that?

abstract glade
#

sorry i am backend dev and ios development is done by someone else

queen trout
#

And that is where the error is being thrown, correct?

abstract glade
#

yes, on ios payment sheet or what is used by the dev guy

queen trout
#
STPPaymentIntentParams.isClientSecretValid(secret)
#

Yeah so the problem here is this like of code is checking for a Payment Intent client secret

#

When you include a free trial, you are returning a Setup Intent client secret

#

The iOS code is not handling that properly

abstract glade
#

so he needs to know if we have a trial option or to tell him what kind of secret i will send

#

and based on that he needs to validate different client secrets

queen trout
#

The iOS code needs to check whether or not the Subscription includes a trial and route the code execution properly

abstract glade
#

can sdk do the check or should i provide him the details in the payload from our backend (if you know, we will check it any way)

#

i think it is clear to me now

#

thanks

queen trout
#

Great, happy to help

abstract glade
#

i was thinking that it is something like that

#

but I was not sure when I have SetupIntent and PaymentIntent

queen trout
#

When Subscriptions have free trials, we send a Setup Intent so you can collect payment method details

#

But when there are no free trials, there is a Payment Intent so you can collect payment

abstract glade
#

thanks, mate and have a great day

queen trout
#

You too ๐Ÿ‘‹