#androz_best-practices

1 messages ยท Page 1 of 1 (latest)

kindred pythonBOT
#

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

๐Ÿ“ 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.

shy shore
#

Hello, this is linked to the previous threads

subtle shell
#

๐Ÿ‘‹ Hi there! Let me take a look

#

What you said sounds viable, but just to clarify: what is the user experience that you want to have?

shy shore
#

I would like my user to be able to select their product, then arrive on the payment page (including showing them the card input), and at that time, still be able to add promo codes

subtle shell
shy shore
subtle shell
#

Are you building a custom checkout, i.e. with ui_mode: custom when creating a Checkout Session?

#

From what I understand, you're using Elements with Checkout Sessions (so ui_mode: custom), and so your question is about how to apply a promotion code to the checkout session?

kindred pythonBOT
shy shore
#

Let me try that right now

#

so that is client-side right? nothing is validated using our backend?

deep stratus
shy shore
#

I'm having trouble calling loadActions on a checkout

#

(I'm debugging it)

#
const stripeCheckout = await stripe?.initCheckout({
      fetchClientSecret: () => Promise.resolve(clientSecret),
    })
    if (!stripeCheckout) {
      throw new Error("Stripe checkout not loaded")
    }

    const actionsResult = await (stripeCheckout as any).loadActions()
#

StripeCheckout does not have a loadActions, but a applyPromotionCode directly

#

I'm upgrading from 7.3 to 8.1

#

yes, that was the issue

#

let me try now

#

upgrading to v8 broke quite a lot of things ahah

#

or Uncaught IntegrationError: Invalid initCheckout() parameter: options.clientSecret is not an accepted parameter.

#

I read the v8 migration guide but couldn't figure out anything about confirm

deep stratus
#

Sorry but what Stripe SDK are you using exacty ?

shy shore
deep stratus
deep stratus
shy shore
#

with clientSecret being the one I created on the backend

deep stratus
#

Can you share a complete stacktrace and i'll try to reproduce ?

#

Like one single JS file that illustrate what you are doing with Stripe SDK

shy shore
#

Sure

kindred pythonBOT
shy shore
#

Indeed I don't know how to proceed ahah.. it has to be an error on my side because my code is super simple

const clientSecret = "cs_test_b14RDDGxu7RWeSFaa9gF91UgeZVMg1NIqXkWpiMcpIT2NU1Ieult6HTDnj_secret_fidnandhYHdWcXxpYCc%2FJ2FgY2RwaXEnKSd2cGd2ZndsdXFsamtQa2x0cGBrYHZ2QGtkZ2lgYSc%2FY2RpdmApJ3BsSGphYCc%2FJ2ZwdnFqaCd4JSUl"; 
const stripe = await loadStripe(pubKey)

if (!stripe) {
  throw new Error("Stripe not loaded")
}

console.log(clientSecret)

const stripeCheckout = stripe?.initCheckout({
  clientSecret: clientSecret,
})
#

I'm checking every component one by one

shy shore
deep stratus
#

Sorry I got confused by something else

shy shore
#

No worries
Indeed I get the same error with the cs_test_b1AYulCRzZCvn51Czr46LEqJS2d1cXD6fPZIpT70X977hdfbrm4KVKMIVH_secret_fidnandhYHdWcXxpYCc/J2FgY2RwaXEnKSd2cGd2ZndsdXFsamtQa2x0cGBrYHZ2QGtkZ2lgYSc/Y2RpdmApJ3BsSGphYCc/J2ZwdnFqaCd4JSUl (decodeURIComponent), and I would be surprised that it's the issue because this code worked really well before

deep stratus
#

But the clientSecret seems not valid

#

Here is the clientSecret that you should use:
cs_live_b1P710Os4Jn8ax3v8GnOTjDb43vidDnvCQlhKf4mj3UyowlfnPBo3UhGWQ_secret_fidnandhYHdWcXxpYCc%2FJ2FgY2RwaXEnKSdwbEhqYWAnPydmcHZxamgneCUl

#

There is a change comparing to yours

shy shore
#

live and test?

#

ah okay

#

a %2

deep stratus
shy shore
#

thank you for your continuous help by the way, I'm trying to sort a lot of things out by myself to remove some of the load on you ๐Ÿ˜…

Here is the clientSecret that you should use:

how did you get it?

deep stratus
#

how did you get it?
From the API response of your API call req_cW3xnb2BLx8Sun

shy shore
#

cs_test_b1KVjssMqtwPQmkvlfRZErgP0W6OQsX1HXUXdluZ3C6CoD99AV46CkqalA_secret_fidnandhYHdWcXxpYCc%2FJ2FgY2RwaXEnKSd2cGd2ZndsdXFsamtQa2x0cGBrYHZ2QGtkZ2lgYSc%2FY2RpdmApJ3BsSGphYCc%2FJ2ZwdnFqaCd4JSUl

this is exactly what I get from Stripe from my backend

#

is it correct?

umbral lagoon
#

Hi, taking over as my teammate needs to step away. Let me catch up.

shy shore
#

thank you

umbral lagoon
#

So what my teammate still applies here. The client secret would be cs_test_b1KVjssMqtwPQmkvlfRZErgP0W6OQsX1HXUXdluZ3C6CoD99AV46CkqalA_secret_fidnandhYHdWcXxpYCc%2FJ2FgY2RwaXEnKSd2cGd2ZndsdXFsamtQa2x0cGBrYHZ2QGtkZ2lgYSc in this case

#

Can you try that please?

shy shore
#

I think it still does not work

umbral lagoon
#

Can you try that guide carefully please?

shy shore
#

Yes

kindred pythonBOT
shy shore
#

my main branch (without upgrading to v8) is now encountering the same issue so I'll have a deeper look at it later and come back to you. Thank you very much for your time and your help, you definitely pointed the right direction with the applyPromoCode function. The implementation is still broken but I hope that I can figure out and it's less important than the design choices!

#

thank you again for your help

#

(feel free to close the ticket? I wish I could post the resolution here once I get it but I guess that everything's lock after an idle time?)

iron hull
#

Sounds good, let us know if you run in to anything else we can help with! We do close threads after ~15 mins of inactivity so yes this thread will likely be locked by then but I do appreciate the thought.

shy shore
#

oh, wait

#

I think I figured out where it came from

#

I'll get back to you in a few mins

shy shore
#

So indeed the issue was with react stripe, not from the initCheckout that I thought was being called...

#

and because it's done internally on their end, it didn't show up and I didn't think about it when searching for initCheckout

iron hull
#

Nice, glad you were able to figure it out! Thanks for the followup

shy shore
#

thanks! everything is working now.