Stripe - Where to get source_transaction id when making transfer?

Viewed 595

I would like to make a direct transfer from a user card to connected accounts. For that I have to indicate the source_transaction field.

await stripe.transfers.create({
          amount: amount,
          currency: "eur",
          destination: "{connected_account1}",
          transfer_group: "{ORDER1}",
          source_transaction: // How to get this information ?
        });

Here is the information I get from my app (PaymentMethod):

PaymentMethod Object

What do I have to do to get the source_transaction with the informations I get on the PaymentMethod Object ?

1 Answers

A PaymentMethod object represents the payment instrument used to pay. For example if you collect card details you will get a card PaymentMethod (pm_123) but it could also be for SEPA Debit or Alipay. This is unrelated to source_transaction.

To make a Transfer to a connected account you need to have funds in your platform account's balance on Stripe. In the flow you describe, you wouldn't use your own balance and instead you tie the Transfer to the release of funds associated with a payment already made.

This flow is called Separate Charges and Transfers and is documented here. In this flow, you charge a customer for $10 via the PaymentIntent API. Then you separately create a Transfer to the connected account for say $8. The source_transaction here should be the id of the Charge (ch_123) created as a result of the payment.

The Charge id would be in the charges collection on the PaymentIntent once it has succeeded and it's always the first charge in the array (most recent). So if you already have a PaymentIntent in memory in a variable called payment_intent you would need payment_intent.charges.data[0].id and that would map to ch_123 to pass inside source_transaction.

Related