#arya_

1 messages · Page 1 of 1 (latest)

obsidian glacierBOT
zenith breach
#

It's safe to share Ids here

#

PaymentIntent Id or request id req_xxx

#

That error mostly mean you are trying to confirm a PaymentIntent not in your account

silver otter
#

Oh okay

zenith breach
#

common case is you created it as a Direct Charge on a Connected Account and calling API as a Platform now, or vice versa

zenith breach
silver otter
#

req_TF7P0DZ0DUqVmc

zenith breach
#

This is request to create Subscription and I see it succeeded. Where is the error you saw?

silver otter
#

Yes the subscription is created successfully i think. The issue is that the dashboard shows an "incomplete" payment. Also, no redirection to the success page happened.
I was looking into the console in the browser where I saw that the payment intent wasn't being confirmed. I am getting a 404 for the link i shared earlier.
The frontend code is like the following

let confirmed_payment_result = await stripe.confirmPayment({
        elements: elements ? elements : undefined,
        clientSecret,
        confirmParams: {
          return_url: `${FRONTEND_DOMAIN}${generalRoutes.success.slice(1)}`,
        },
      });
#

I also console logged the clientSecret before the above confirmPayment function was called and got the following:
pi_3NvOc7IJY9GdUtED11lgKUt9_secret_swRwO7xvXNjzkz1WT8pJT1p0C

zenith breach
#

I am getting a 404 for the link i shared earlier.
Which link exactly? your return_url?

silver otter
zenith breach
#

The browser's js code, which account it is using Publishable Key of?

silver otter
#

The publishable key in frontend: pk_test_TYooMQauvdEDq54NiTphI7jx

zenith breach
#

Ok you created Subscription on acct_1NC95TIJY9GdUtED, but that Publishable Key is acct_1032D82eZvKYlo2C

#

Which ... aren't related to each other

#

Make sure your client and server using keys from exactly same Stripe Account

silver otter
#

Where did you find these keys?

#

Are the publishable keys in the frontend code and server code supposed to be the same? The publishable key i found was here https://dashboard.stripe.com/test/apikeys: pk_test_51NC95TIJY9GdUtED0vOxEtPffy1RF22w4p0XL0sbenEkFEhHvq1keVx7AJvWkaLuDMZ4EFVtgYrjDA6L6QfrAB3m00pKr0A472

zenith breach
#

Above is acct_1NC95TIJY9GdUtED

#

pk_test_TYooMQauvdEDq54NiTphI7jx is different

#

I can see the account via our internal tool

silver otter
zenith breach
silver otter
#

So should I try the frontend code with "pk_test_51NC95TIJY9GdUtED0vOxEtPffy1RF22w4p0XL0sbenEkFEhHvq1keVx7AJvWkaLuDMZ4EFVtgYrjDA6L6QfrAB3m00pKr0A472"

#

I meant to ask why is the pk_test key shorter ?

zenith breach
#

Correct

silver otter
#

1 sec, trying

#

Sweet, it's working! Thanks Orakaro

#

I had another question

#

I wanted to create and handle promo codes (discount) with expiry i.e. the code will be invalid after being used 50 times or after December 31 (whichever of the two comes first)

zenith breach
#

There are parameters to limit promo code or discount, on the Doc, I believe limit by times is possible. Not sure about date

silver otter
#

Also, to switch from test to live version in stripe, I only need to change the api keys, right?

zenith breach
#

Yep

silver otter
#

Im actually getting the same error now

obsidian glacierBOT
silver otter
#

Im confused why that's happening now

viral lichen
#

I see you passed in a value of undefinedsuccess but that parameter needs a full address like https://example.com

silver otter
#

Huh, let me try again

#

Sweet it's working - i had misspelt the env variable name

#

THanks!

#

I wanted to create and handle promo codes (discount) with expiry i.e. the code will be invalid after being used 50 times or after December 31 (whichever of the two comes first)

#

How can I achieve this?

viral lichen
silver otter
#

I'm confused between promotion code and coupon lol

viral lichen
#

A promotion code is how a coupon is applied

#

A coupon says. "X% off" and the promotion code say "PUPPIES = the X% off coupon"

silver otter
#

Oh okay

#

Is there a code example that I look at where a promotion code is being used?
For instance, a user enters a code "FALL2023" is there a code i can look at that tells me to how to read this in the server, etc

viral lichen
#

So with Stripe only Checkout takes these promo codes, otherwise I think you would need to have your own custom code that checks if a promo code is valid and applies the proper coupon if so

silver otter
#

I saw that subscription.create can take both parameters promotion_code and coupon
Which one should i use?

viral lichen
#

You can use either, if the user is giving you a promo code, the promo code param will likely be easier to use

silver otter
#

Got it, thanks!

#

What happens if the promotion_code passed is invalid? i.e. if the user attempts a payment with some randomly guessed incoreect promotion_code

viral lichen
#

You get an error No such promotion code: 'RUBBISH50' on your backend

silver otter
#

What is the API ID of a promotion code?

#

Can stripe not map a promotion code like "FALL2023" to whatever ID it is going to use

viral lichen
#

My apologies, it looks like the API is expecting the ID promo_1234 which your dashboard will show after you create the promotion code.

#

So it looks like Checkout is the only place that takes the actual promo code "FALL2023" and translates it in to that ID.

#

So I think you would still need the logic to check that the promo code that the customer input is valid and then pass the promo_ ID that matches it

#

You would still be able to take advantage of the expiration and max redemptions functionality

silver otter
#

Got it

#

THanks