#arya_
1 messages · Page 1 of 1 (latest)
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
Oh okay
common case is you created it as a Direct Charge on a Connected Account and calling API as a Platform now, or vice versa
sure, what is the request Id (req_xxx) of this? Find it on https://dashboard.stripe.com/test/logs
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
req_TF7P0DZ0DUqVmc
This is request to create Subscription and I see it succeeded. Where is the error you saw?
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
I am getting a 404 for the link i shared earlier.
Which link exactly? your return_url?
No. I believe the stripe.confirmPayment function is making a POST call to https://api.stripe.com/v1/payment_intents/pi_3NvOc7IJY9GdUtED11lgKUt9/confirm which is giving me a 404
The console log in the browser shows that a 404 is received and the message is "No such payment_intent: 'pi_3NvOc7IJY9GdUtED11lgKUt9'"
The browser's js code, which account it is using Publishable Key of?
The publishable key in frontend: pk_test_TYooMQauvdEDq54NiTphI7jx
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
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
Above is acct_1NC95TIJY9GdUtED
pk_test_TYooMQauvdEDq54NiTphI7jx is different
I can see the account via our internal tool
What exactly is this? I don't know how it got there. But why is this shorter and im confused now
You provided it here
So should I try the frontend code with "pk_test_51NC95TIJY9GdUtED0vOxEtPffy1RF22w4p0XL0sbenEkFEhHvq1keVx7AJvWkaLuDMZ4EFVtgYrjDA6L6QfrAB3m00pKr0A472"
I meant to ask why is the pk_test key shorter ?
Correct
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)
There are parameters to limit promo code or discount, on the Doc, I believe limit by times is possible. Not sure about date
Also, to switch from test to live version in stripe, I only need to change the api keys, right?
Yep
Im confused why that's happening now
The only confirm error that I am seeing on that intent has a message about how your return URL needs to be a valid URL https://dashboard.stripe.com/test/logs/req_LLzJYbehzgIy9S
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
I see you passed in a value of undefinedsuccess but that parameter needs a full address like https://example.com
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?
When creating the promotion code, we have parameters for an expiration date and for max redemptions https://stripe.com/docs/api/promotion_codes/create
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'm confused between promotion code and coupon lol
A promotion code is how a coupon is applied
A coupon says. "X% off" and the promotion code say "PUPPIES = the X% off coupon"
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
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
I saw that subscription.create can take both parameters promotion_code and coupon
Which one should i use?
My apologies, it looks like you can provide a promo code when creating or updatign a subscription https://stripe.com/docs/api/subscriptions/create#create_subscription-promotion_code
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
You can use either, if the user is giving you a promo code, the promo code param will likely be easier to use
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
You get an error No such promotion code: 'RUBBISH50' on your backend
What is the API ID of a promotion code?
Where can I find the API ID: https://stripe.com/docs/api/subscriptions/create#create_subscription-promotion_code
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 stripe not map a promotion code like "FALL2023" to whatever ID it is going to use
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