#matteo-grolla_code
1 messages ยท Page 1 of 1 (latest)
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.
- matteo-grolla_code, 14 minutes ago, 10 messages
- matteo-grolla_code, 4 hours ago, 6 messages
๐ 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/1234925534690148392
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hello! Can you give me the request ID showing that error? Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
I don't see that request in the stripe dashboard logs
in the browser, the request
POST https://api.stripe.com/v1/payment_pages/cs_test_c1EYErbkrwjWsn9SyYd0Nl2vA6oU2wShUjTrQdP3Nx1a7hPppOeUjJSem6/init
returns a 404
and this response header
Original-Request: req_yHU3kUx2zIkoBQ
That's what I needed! So the issue is that you're not initializing Stripe.js with the proper key/account ID: https://docs.stripe.com/js/initializing
the payload of the POST is
key: pk_test_KEY_OF_PLATFORM_ACCOUNT
and if I don't use the stripe_account parameter it works
Let's back up a bit. The code you're using above (the stripe.checkout.sessions.create() code) creates a Checkout Session on a connected account (the one you specified with stripe_account: 'acct_1P86PIFtGWHXwYgK'). You're then attempting to display that Checkout Session on a website using Stripe.js. In order for that to work you need to initialize Stripe.js with your platform's publishable key and also specify the connected account ID using the stripeAccount parameter in the options object: https://docs.stripe.com/js/initializing#init_stripe_js-options-stripeAccount
Initializing Stripe.js that way allows it to access the Checkout Session you created on that connected account.
If you only initialize Stripe.js with your platform's publishable key and don't specify the connected account's ID it's going to look on your platform account for the Checkout Session. The Checkout Session doesn't exist on that account, so you'll get a resource_missing error like the one you're getting now.
Thanks Rubeus
I'm struggling with the documentation because I'm using the EmbeddedCheckoutProvider for nextjs
I'm trying this, but it doesn't work
export default function EPaymentsPanel({customer}: Props) {
const fetchClientSecret = useCallback(() => {
// Create a Checkout Session
return fetch("/api/stripe/checkout", {
method: "POST",
})
.then((res) => res.json())
.then((data) => data.clientSecret);
}, []);
const options = {fetchClientSecret, stripe_account: 'acct_1P86PIFtGWHXwYgK'};
return (
<div>
<h1>E-Payments</h1>
<div id="checkout">
<EmbeddedCheckoutProvider
stripe={stripePromise}
options={options}
>
<EmbeddedCheckout/>
</EmbeddedCheckoutProvider>
</div>
</div>
)
}
Where are you initializing Stripe.js with your publishable key?
The options you have in the code above are for <EmbeddedCheckoutProvider>, but that doesn't take a stripe_account option.
const stripePromise = loadStripe('pk_test_51LF...', {stripeAccount: 'acct_1P86PIFtGWHXwYgK'});
Yeah, that's the spot. And that publishable key belongs to your platform account?
yes
If you change const options = {fetchClientSecret, stripe_account: 'acct_1P86PIFtGWHXwYgK'}; to const options = {fetchClientSecret}; what happens?
already done it
and still have the problem
I'm looking into the request
https://api.stripe.com/v1/payment_pages/cs_test_c14wtROgMhsUlvvK3NpszmkvWZBZkJjd0kU4WNbhxMn47HZ3ZAq8xQA5oY/init
but I don't see any reference to the connected account
in the body, parameters or request headers
last request_id for it is: req_WLRRZUfi4j4RHG
You should see a Stripe-Account header in the request.
mmm not present
It seems like your const stripePromise = loadStripe('pk_test_51LF...', {stripeAccount: 'acct_1P86PIFtGWHXwYgK'}); code isn't being used somehow?
some kind of caching problem
not i see the checkout form
And it WORKS!!!
Thank you soooo much Rubeus
Ah, good!
can I ask you one more question?
Sure.
the purpose of saving the payment method was to use it in the future for payments
currently I'm not creating a user
I create a checkout.session and marked it with the field
"client_reference_id":"matteo"
when I have to create a payment for user "matteo"
I believe I can lookup that checkout.session
and then the setup_intent
and then the payment_method
is it ok or chould I create a user to better lookup the payment_method in the future?
In order to use a Payment Method more than once it must be attached to a Customer.
The correct way to do it is to look it up based on the Customer in question, not the Checkout Session.
ok, thanks a lot
you were extraordinarily helpfull
Happy to help!
a last one...
reading the doc it seemed me that
when creating a checkout session
either you specify an existing customer_id
or you create a new one
so I'll have to make a couple of calls to stripe
- check if user exists
- create checkout
is this the way to go or is there a way to say "create user if it doens't exist" passing a unique id for the user from my business management software?
Hello
Are you purely just storing customer information on Stripe? OR are you maintaining a version of that in your own Database?
Depending on how you're integrated, you may just need to check in your own Database to see if the customer exists or not.
Additionally, you can set customer_creation parameter to if_required if you don't want to create a new customer
Rubeus told me that to use a saved payment more than once (this is my use case) it must be attached to a customer
you are suggesting that i store in my db the customer_id created from stripe, right?
It's probably the best way, I was thinking of storing mine on stripe which may be more convoluted
Rubeus told me that to use a saved payment more than once (this is my use case) it must be attached to a customer. you are suggesting that i store in my db the customer_id created from stripe, right?
Less of a suggestion, more of a question ๐ we don't know much about your integration so was just trying to confirm.
It's probably the best way, I was thinking of storing mine on stripe which may be more convoluted
You can choose either based on what's preferred for your integration
Also going back to the question you asked earlier
is there a way to say "create user if it doens't exist" passing a unique id for the user from my business management software?
No, the API doesn't have any features that support that.
Thank you very much
I have the ideas much clearer now
you're probably the best support team I've ever encountered