#savage_direct-charge-multiple-accounts

1 messages ยท Page 1 of 1 (latest)

grizzled viperBOT
#

๐Ÿ‘‹ 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.

severe wyvern
#

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.

real pike
grizzled viperBOT
severe wyvern
#

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'),
      },
    );
  }
final sage
#

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.

severe wyvern
#

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

final sage
#

There isn't any Customer associated with it in the response though

#

customer: null,

severe wyvern
#

attaching it with the paymentMethods.attach() function worked

#

I was just a simple step away last night. Thank you!!!

final sage
#

Great! I'm glad it's working for you