#matteo-grolla_code

1 messages ยท Page 1 of 1 (latest)

limber vaultBOT
trim vaporBOT
#

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.

limber vaultBOT
#

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

rich pumice
mild silo
rich pumice
mild silo
#

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

rich pumice
#

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.

mild silo
#

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>
)

}

rich pumice
#

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.

mild silo
#

const stripePromise = loadStripe('pk_test_51LF...', {stripeAccount: 'acct_1P86PIFtGWHXwYgK'});

rich pumice
#

Yeah, that's the spot. And that publishable key belongs to your platform account?

mild silo
#

yes

rich pumice
#

If you change const options = {fetchClientSecret, stripe_account: 'acct_1P86PIFtGWHXwYgK'}; to const options = {fetchClientSecret}; what happens?

mild silo
#

already done it
and still have the problem

#

last request_id for it is: req_WLRRZUfi4j4RHG

rich pumice
#

You should see a Stripe-Account header in the request.

mild silo
#

mmm not present

rich pumice
#

It seems like your const stripePromise = loadStripe('pk_test_51LF...', {stripeAccount: 'acct_1P86PIFtGWHXwYgK'}); code isn't being used somehow?

mild silo
#

some kind of caching problem
not i see the checkout form

#

And it WORKS!!!

Thank you soooo much Rubeus

rich pumice
#

Ah, good!

mild silo
#

can I ask you one more question?

rich pumice
#

Sure.

mild silo
#

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?

rich pumice
#

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.

mild silo
#

ok, thanks a lot
you were extraordinarily helpfull

rich pumice
#

Happy to help!

trim vaporBOT
mild silo
#

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

  1. check if user exists
  2. 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?

queen copper
#

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

mild silo
#

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

queen copper
#

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.

mild silo
#

Thank you very much
I have the ideas much clearer now

you're probably the best support team I've ever encountered