1
votes

I want to charge a customer using a connected account. Here's my flow I get customer: null in charge response and the customer is not charged however the transaction goes through.

I'm creating token on the server-side using Customer ID. https://stripe.com/docs/connect/shared-customers

app.post('/custToken', (req, res) => {
  stripe.tokens
    .create(
      {
        customer: 'cus_CLpvRC6cGQRjpZ'
      },
      {
        stripe_account: 'acct_1BxTzKEVtlEQzJtB'
      }
    )
    .then(function(token) {
      stripe.charges
        .create(
          {
            amount: 1000,
            currency: 'usd',
            source: token.id
          },
          {
            stripe_account: 'acct_1BxTzKEVtlEQzJtB'
          }
        )
        .then(function(charge) {

        });
    });
1

1 Answers

1
votes

This is the expected result here, charges made with a token from "shared customers" aren't reflected on the Customer on the Platform and won't contain a reference to this customer.

In the code above you are,

  1. Creating a token tok_xxyyyzzz from an existing customer, cus_CLpvRC6cGQRjpZ, on acct_1BxTzKEVtlEQzJtB
  2. Creating a charge on acct_1BxTzKEVtlEQzJtB with this one-off token tok_xxyyyzzz, you've generated.

If you want the Charge on acct_1BxTzKEVtlEQzJtB with a Customer, you need to create a token on acct_1BxTzKEVtlEQzJtB from cus_CLpvRC6cGQRjpZ, create a customer on acct_1BxTzKEVtlEQzJtB with that token, and then create a charge using that customer (Note that the customer created on acct_1BxTzKEVtlEQzJtB and the customer on your platform are two distinct records).