#manyds-connect-directcharge

1 messages · Page 1 of 1 (latest)

undone jayBOT
rancid vector
#

Can you share the request id?

#

Usually those errors occur when the object you're referencing exists on the platform but you make the request on the connect account

undone jayBOT
dire fjord
#

Here is the code that caused the error, if we remove the stripeAccount, then it goes through fine

#

const customer = await stripe.customers.create();

customerId = customer.id;

const ephemeralKey = await stripe.ephemeralKeys.create(

  { customer: customerId },

  { apiVersion: '2022-11-15' }

);

const paymentIntent = await stripe.paymentIntents.create(

  {

    amount: amount * 100,

    currency: 'cad',

    customer: customerId,

    automatic_payment_methods: {

      enabled: true,

    },

    application_fee_amount: 123,

  },

  {

    stripeAccount: 'acct_1LnnYSQ6fRy5pIt8',

  }

);
rancid vector
#

It's because you're creating the customer on your platform account

#

You can't create a payment intent on the connect account and reference a customer that only exists on the platform account

#

So, you'll need to pass the stripeAccount header when creating the customer as well

crude latch
#

manyds-connect-directcharge

#

Also that account id is an Express account. You should never use Direct Charges with Express accounts

dire fjord
#

Let me give it a try. Oops on the express account. meant to use acct_1Lnp84B9f5l7msw2 this one

crude latch
#

ah yeah that one is a Standard account so for those you would use Direct Charges and the advice from my colleague holds

#

you need to make sure all the object are created on that one account

dire fjord
#

<?php
require 'vendor/autoload.php';
$stripe = new \Stripe\StripeClient(''''');

// Use an existing Customer ID if this is a returning customer.
$customer = $stripe->customers->create();
$ephemeralKey = $stripe->ephemeralKeys->create([
'customer' => $customer->id,
], [
'stripe_version' => '2022-08-01',
]);
$paymentIntent = $stripe->paymentIntents->create([
'amount' => 1099,
'currency' => 'eur',
'customer' => $customer->id,
'automatic_payment_methods' => [
'enabled' => 'true',
],
'application_fee_amount' => 123,
], ['stripe_account' => '{{CONNECTED_ACCOUNT_ID}}'
]);

#

where do I add the stripeAccount header when creating a customer?

crude latch
#

Please don't share real API keys like that. Also your code can be formatted using 3 ` around it

#

that header is used to say "I am making the request on a connected account". Right now you create the Customer on your platform account and then you create the PaymentIntent on the connected account which would never work

#

You have to create the Customer on that connected account, same for the ephemeral key

dire fjord
#

oops about the key, let me look into it now

#

The customer is okay now. Running into issue creating ephemeral key. how to I create the ephemeral key on the connected account?

crude latch
#

same as the other two calls really, pass the stripe_account option

#

really you need to "get" that since it will apply to all the API requests you make on a connected account

dire fjord
#

running an issue creating the ephemeral keys

crude latch
#

it's just a picture

#

Please share exact code, wrapped in three ` before and after

dire fjord
#
const customer = await stripe.customers.create(
      {
        email: email,
        name: `${firstName} ${lastName}`,
        description: `${eventName}`,
      },
      {
        stripeAccount: 'acct_1Lnp84B9f5l7msw2',
      }
    );

    const customerId = customer.id;

    const ephemeralKey = await stripe.ephemeralKeys.create(
      { customer: customerId },
      { apiVersion: '2022-11-15' },
      {
        stripeAccount: 'acct_1Lnp84B9f5l7msw2',
      }
    );
    const paymentIntent = await stripe.paymentIntents.create(
      {
        amount: amount * 100,
        currency: 'cad',
        customer: customerId,
        automatic_payment_methods: {
          enabled: true,
        },
        application_fee_amount: 123,
      },
      {
        stripeAccount: 'acct_1Lnp84B9f5l7msw2',
      }
    );
crude latch
#

Just so that we make this easy to iterate on, please only share relevant code

#

right now the real issue is the second call so we should only look at that one

#

the problem is that you have to pass apiVersion and stripeAccount together because they are both options of the request

#
const ephemeralKey = await stripe.ephemeralKeys.create(
  {
    // Parameters go here
    customer: customerId,
  },
  {
    // Request options go heder
    apiVersion: '2022-11-15',
    stripeAccount: 'acct_1Lnp84B9f5l7msw2',
  }
);```
#

does that make sense?

dire fjord
#

yes, let me try

#

that worked. thanks

crude latch
#

yay!

dire fjord
#

payment intent pm_1NYFxOB9f5l7msw2riovZ81w was created and paid, but we did not receive the webhook notification. We only receive the notification about the application fee created

We made the payment to acct_1Lnp84B9f5l7msw2, with customer cus_OKvogA3UHZ6gBk but did not receive the webhook notification forit

undone jayBOT
crude latch
#

there are two types of WebhookEndpoints and you are likely not aware yet. You need both if you want to catch Events on your own account and on your connected accounts

dire fjord
#

got it. setting it up now