#musacoli - stripe.js connect init

1 messages · Page 1 of 1 (latest)

humble jewelBOT
rocky mountain
#

Hi there

#
subscription = stripe.Subscription.create(
            metadata=metadata,
            api_key={{our_stripe_api_key}} if live_mode else {{OUR_STRIPE_TEST_APIKEY}},
            currency=product.currency,
            customer=user.stripe_uid,
            items=line_items,
            stripe_account={{customer_connect_account_id}},
            application_fee_percent=app_fee_perc,
            trial_end=trial_end,
            payment_behavior='default_incomplete',
            payment_settings={
                'save_default_payment_method': 'on_subscription',
                'payment_method_types': ['card'],
            },
            expand=['latest_invoice.payment_intent'],
        )```
#

Let's use this thread

high frigate
#

Thanks

rocky mountain
high frigate
#

Yes, we have this running on both FE and BE

#

FE

  stripeAccount: {{customer_stripe_account}}
});
rocky mountain
#

Hmm and you are still seeing the error?

#

Can you share a request ID for that error?

high frigate
#

Sure thing, where can I get it from

#

Also, we're getting 2 errors.

rocky mountain
#

Ah nvm

#

Forgot it is in the logs you shared above

#

One sec

high frigate
#

All good

Here is the one for the client_secret_error

message
: 
"The client_secret provided does not match any associated PaymentIntent on this account."
param
: 
"client_secret"
request_log_url
: 
"https://dashboard.stripe.com/test/logs/req_dzJCnyZZg68785?t=1671478289"
type
: 
"invalid_request_error"
rocky mountain
#

Okay yeah that PaymentIntent confirmation request looks to have been performed on your platform whereas the Sub was created on your Connected Account

#

So yeah can you try again but using the const stripePromise = loadStripe(process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY || '', { stripeAccount: {{customer_stripe_account}} }); code?

#

Also have you logged customer_stripe_account there?

high frigate
#

I am actually hard coding it in, just for extra measure 🤣

#

So still got the same error

rocky mountain
#

Can you do a full reboot of your app?

high frigate
#

Sure thing

rocky mountain
#

It seems cached in that case where Stripe.JS isn't getting initialized for your Connected Account

high frigate
#

Cleared Cache
Rebooted the application
Cleared Cache again

Still the same error sadly

rocky mountain
#

Okay in that case can you share your relevant client-side code?

high frigate
#

Sure thing.

Like a repo, or snippets

rocky mountain
#

snippets are fine

#

Also have you logged out the client secret in your frontend?

#

That your server is passing?

high frigate
#

Sure "pi_3MGp3VGhfEtWv55W1KmVytmm_secret_l9FN8ohoRMeISuN5xwSHQEMX3"

rocky mountain
#

Okay yeah that is the correct client-secret for a Sub on your Connected Account. So really the issue is with the Stripe intialization

#

Have you tried hard coding your publishable key as well?

high frigate
#

Nope, let me try that

#

Yahp, I just did

#

Same error

#

Is the payload for the stripe.js requests meant to include the stripe account id, because it currently doesn't

foggy kiln
#

Yes if i recall that should be includes as the stripe-account header

#

It looks like your initialization includes the correct stripeAccount option & value

foggy kiln
#

Can you share an example request ID happening from the client?

high frigate
#

Here is one

{
  "error": {
    "message": "The client_secret provided does not match any associated PaymentIntent on this account.",
    "param": "client_secret",
    "request_log_url": "https://dashboard.stripe.com/test/logs/req_tvZvJRcIooCzaf?t=1671480069",
    "type": "invalid_request_error"
  }
}
foggy kiln
#

Hmm yes there is no connected account set there

#

in teh snippet you shared the connected account was hard-coded

#

is that the case in prod or is the value dynamic?

high frigate
#

That's the case

#

This is still something in development, so what I have is what's on my branch and being tested with to get the shared error

foggy kiln
#

hmmm can that is weird, you definitely have a value there

#

Can you try removing the || ''?

high frigate
#

I think I've figure it out

#

Let me test and let you know

#

I found two instances of the loadStripe

foggy kiln
#

It's a wild guess but wondering if the || is smooshing the options object

#

ahhh

#

Yea, that would do it, guessing the other doesnt have the connected account set?

high frigate
#

Exactly

#

And we're good to go

#

Thanks a bunch both of you

#

Much appreciate the assistance

foggy kiln
#

NP! glad its working now!

foggy kiln
#

musacoli - stripe.js connect init