#savage_direct-charge-multiple-accounts
1 messages ยท Page 1 of 1 (latest)
๐ 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/1288908104150548604
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
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.
- savage_api, 1 hour ago, 11 messages
I am trying to set up our api for a specific use case that I can't seem to find a good answer for.
Scenario: We have a company with many stores that are distinct business entities, we want a platform account for the parent company and many connected accounts for the individual stores. The connected accounts need to handle invoicing and payment processing. The customer data and associated payment methods needs to be stored centrally on the platform account so the users do not need to re-register at each store the visit (many in our metro area).
I am using direct charges to manage that but the invoice issue is what I'm trying to solve.
Hello! In that scenario you would essentially use the approach outlined here: https://docs.stripe.com/connect/direct-charges-multiple-accounts
However, instead of creating Payment Intents, you would create Invoices instead. The Invoices will create their own Payment Intents.
Docs on Invoices are here: https://docs.stripe.com/invoicing
And, in particular for this use case, see here for using Invoices with Connect: https://docs.stripe.com/invoicing/connect
I get this when trying to create the invoice with the payment method
StripeInvalidRequestError: The customer does not have a payment method with the ID pm_1Q3LZHHs0qUibMpTBJYgRWMf. The payment method must be attached to the customer.
const clonedPaymentMethod = await this.stripe.paymentMethods.create(
{
customer: platformCustomer.id,
payment_method: customerPaymentMethod,
},
{
stripeAccount: this.configService.get('STRIPE_ACCOUNT_ID'),
},
);
return await this.stripe.invoices.create(
{
auto_advance: true,
collection_method: 'charge_automatically',
default_tax_rates: [taxRateId],
customer: clonedCustomer.id,
description: `Invoice for auction ${auctionTitle} for ${winner}`,
default_payment_method: clonedPaymentMethod.id,
metadata: {
auctionId,
},
},
{
stripeAccount: this.configService.get('STRIPE_ACCOUNT_ID'),
},
);
}
Hi ๐
I'm stepping in as my colleague needs to go.
The error message is pretty self explanatory. The payment method needs to be attached to the customer before you attempt to use it to pay an Invoice.
Is that not what
const clonedPaymentMethod = await this.stripe.paymentMethods.create(
{
customer: platformCustomer.id,
payment_method: customerPaymentMethod,
},
{
stripeAccount: this.configService.get('STRIPE_ACCOUNT_ID'),
},
);
does?
Oh I see there's an attach function too
That function should attach the PM. I'm taking a look at the creation request here: https://dashboard.stripe.com/test/logs/req_PIDXqK4sYNY3Ba
There isn't any Customer associated with it in the response though
customer: null,
attaching it with the paymentMethods.attach() function worked
I was just a simple step away last night. Thank you!!!
Great! I'm glad it's working for you