#manyds-connect-directcharge
1 messages · Page 1 of 1 (latest)
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
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',
}
);
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
manyds-connect-directcharge
Also that account id is an Express account. You should never use Direct Charges with Express accounts
so really you likely want to change your integration and move to Destination Charges: https://stripe.com/docs/connect/destination-charges instead and have everything in your own platform account
Let me give it a try. Oops on the express account. meant to use acct_1Lnp84B9f5l7msw2 this one
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
okay, so in this sample https://stripe.com/docs/connect/enable-payment-acceptance-guide?platform=ios, it did not mention such association
<?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?
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
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?
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
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',
}
);
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?
yay!
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
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
got it. setting it up now
found a bug when entering webhook endpoint, where an error is raised with a valid HTTP Link such as http://mywebsites.com/v1/webhook. to get over it, I added / add the end http://mywebsites.com/v1/webhook/ and it worked. I then changed it back by editing it after it is setup