--
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 ● P:1-855-263-3852 ● www.liki.com ● 408 Saint-Sulpice,#2, Montréal, QC, Canada H2Y 2V5 |
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();
})
})
})
}