Connect, Charge, Transfer and Metadata

865 views
Skip to first unread message

Antoine Aflalo

unread,
Mar 23, 2016, 1:03:47 PM3/23/16
to Stripe API Discussion
Hello,

When using Connect we're doing a charge with a destination. On the charge, we set some metadata and description related to our platform. After testing, we discovered those data aren't copied into the automatic transfer done from the platform account to the managed account.

Is there a way to make them be copied on the automatic transfer?

Also, is it possible that this transfer could fail ?

Remi J.

unread,
Mar 23, 2016, 1:04:36 PM3/23/16
to api-d...@lists.stripe.com
Hey Antoine,

This is definitely possible to do but is going to require some custom development on your end. The idea here would be to update the payment on the connected account to set the wanted description as we don't currently propagate it ourselves.

First off, to get the corresponding payment id you'd need to do two steps. The first step is to get the id of the transfer associated with the charge which is in the `transfer` property on the charge object [1]. Then, you would retrieve that transfer [2] and in the transfer object [3] you'd see the `destination_payment` property corresponding to the payment on the connected account (py_XXX).

You can get all of this in one API call by using the `expand` feature [4] and passing `transfer` to get the transfer property expanded in the response. This gives you access to the payment id (py_XXX) directly in that API call.

Then, once you get this, you'd call the Update Charge API [5] using the `Stripe-Account` header [6] so that you can set the description you want on that payment.

Let me know if that doesn't help!
Remi


--
You received this message because you are subscribed to the Google Groups "Stripe API Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to api-discuss...@lists.stripe.com.
To post to this group, send email to api-d...@lists.stripe.com.
Visit this group at https://groups.google.com/a/lists.stripe.com/group/api-discuss/.

Antoine Aflalo

unread,
Mar 23, 2016, 1:17:40 PM3/23/16
to api-d...@lists.stripe.com
Thank you again for the great and fast answer.

Just a clarification about the last step; I would have to set the description and metadata on the payment using the Update Charge API.

Does that mean I can retrieve and update payments with the Charge API ?
--

Antoine AFLALO
Dévélopeur Web

● P:1-855-263-3852  www.liki.com  408 Saint-Sulpice,#2, Montréal, QC, Canada H2Y 2V5

Remi J.

unread,
Mar 23, 2016, 1:20:20 PM3/23/16
to api-d...@lists.stripe.com
That's correct. We call it payment because it doesn't come from a card. It would be the same for an ACH charge or a Bitcoin or Alipay one. But you can treat it as a charge and use the Charge APIs to retrieve and update it.

Emmy

unread,
Dec 19, 2017, 3:18:08 PM12/19/17
to Stripe API Discussion, antoine...@liki.com
In case it's useful, here is the method we run after creating a new charge w/ a transfer. We use the stripe-node client.

const addMetadataToTransfer = (charge_id) => {
 
return new Promise((resolve, reject) => {
    stripe
.charges.retrieve(charge_id, {
      expand
: ['transfer']
   
}, (err, charge) => {
     
if (err) {
        console
.log('ERROR retrieving charge with transfer!');
        console
.error(err);
       
return resolve();
     
}


     
if (!charge) {
        console
.error('No charge found!')
       
return resolve();
     
}


     
if (!charge.transfer) {
        console
.warn('Transfer not updated; no transfer on charge');
       
return resolve();
     
}


      stripe
.charges.update(charge.transfer.destination_payment, {
        description
: charge.description,
        metadata
: charge.metadata,
     
}, {
        stripe_account
: charge.transfer.destination
     
},
     
(err, transferPayment) => {
       
if (err) {
          console
.log('ERROR adding metadata to transfer payment!');
          console
.error(err);
         
return resolve();
       
}


       
if (!transferPayment) {
          console
.error('No transfer payment found!')
         
return resolve();
       
}


        console
.log('Added metadata to transfer payment :)');
       
return resolve();
     
})
   
})
 
})
}

Reply all
Reply to author
Forward
0 new messages