#nikosalewski

1 messages · Page 1 of 1 (latest)

deep timberBOT
round swift
#

Hi there!

#

Which code is throwing that error? Also do you have a request ID (req_xxx)?

#

If you don't find the request, can you share your platform account ID and the connected account ID?

lament ice
#

The error is coming from my createCheckoutSession function. Here's a snippet:

exports.createCheckoutSession = functions
.region("europe-west1")
.https.onRequest((request, response) => {
corsHandler(request, response, async () => {
const {
accountId,
priceId,
userDisplayName,
userEmail,
childName,
childAge,
} = request.body;

    if (!priceId) {
      response.status(400).send({error: "No priceId provided"});
      return;
    }

    try {
      const priceData = await stripe.prices.retrieve(priceId, {
        stripeAccount: accountId,
      });

      const unitAmount = priceData.unit_amount || 0;
      const applicationFee = Math.round(unitAmount * 0.1);

      const session = await stripe.checkout.sessions.create(
          {
            payment_method_types: ["card"],
            line_items: [
              {
                price: priceId,
                quantity: 1,
              },
            ],
            payment_intent_data: {
              application_fee_amount: applicationFee,
            },
            mode: "payment",
            success_url: "...",
            cancel_url: "...",
            metadata: {
              userDisplayName,
              userEmail,
              childName,
              childAge,
            },
          },
          {
            stripeAccount: accountId,
          },
      );
#

I thought that I can add the accountId via the stripeAccount: accountId dynamically to the Stripe header

round swift
lament ice
#

I can't see it there

round swift
#

If you don't find the request, can you share your platform account ID and the connected account ID?

lament ice
#

platform account id: acct_1HkrOVDtsBuOl1Lo

connected account id: acct_1NuWf9AoBEriQhEK

round swift
#

Thanks! Give me a few minutes to look into this.

lament ice
#

Thank you!

round swift
#

Are you using your live API key to make the request?

lament ice
#

Yes. I use the live secret key in my backend and the public key like this:

const stripePromise = loadStripe(
"...7"
);

round swift
#

Error processing request: The provided key '...' does not have access to account '...' (or that account does not exist). Application access may have been revoked.
Can you share the full error message, without replacing the ids with "..." ?

lament ice
#

Error processing request: The provided key 'sk_live_*********************************************************************************************H5Sni6' does not have access to account 'acct_1NuWf9AoBEriQhEK' (or that account does not exist). Application access may have been revoked.

lament ice
#

The two ids should be correct

round swift
#

Sorry for the delay, Discord is busy.

#

Having another look...

lament ice
#

No worries. Thank you!

round swift
#

I just checked your platform account acct_1HkrOVDtsBuOl1Lo, and the secret key you are using sk_live_***H5Sni6' doesn't match the one I see in your dashboard.

#

So you are using the wrong secret key.

#

Your live secret key should end with z7.

lament ice
#

Maybe that's the secret key of the connected account? I only have one platform account and even wrote the secret key down the one time I saw it.

round swift
#

If you are using the Stripe-Account header (stripeAccount in your code), then you have to use the API key of the platform account.
And if you login in your Stripe dashboard, you can see here your API key: https://dashboard.stripe.com/apikeys, which ends with z7. In your error message it ends with i6.

lament ice
#

Hm, don't know how I did that but thank you a lot for your help. Now it works!