#dicbra
1 messages · Page 1 of 1 (latest)
Yes, you can update that object with the Update Charge endpoint https://stripe.com/docs/api/charges/update
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Payment objects are actually charge objects under the hood. I forget the exact reasons behind the naming difference but you can treat them as the same thing in most cases like this
I'm creating Subscription with transfer_data
What I expect is to be able to add metadata while creating subscrip[tion
but metadata for transfer_data
Maybe you know some tricky way to nest that metadata from subscription to transfer_data object?
Are you creating these subscriptions directly or through Checkout? I think you will need to make that call either way but I can definitely look in to if there is an easier way
directly
here is example
items: [
{
price_data: {
unit_amount: monthlyAmount,
currency: 'usd',
recurring: {
interval: 'month',
},
product: this.productLoanInstallments,
},
},
],
transfer_data: {
destination: noteHolder.stripeConnectedAccountId,
amount_percent: this.transferAmount,
},
cancel_at: toUnixTimeStamp(convertInstallmentsToDate(anchorDate, numberOfInstallments).getTime()),
billing_cycle_anchor: toUnixTimeStamp(anchorDate.getTime()),
trial_end: toUnixTimeStamp(anchorDate.getTime()),
metadata: {
promissoryNoteId,
},
customer: homeOwner.stripeCustomerId,
})```
I need that promissoryNoteId in connected account for every transfer.
nothing?
Apologies the server is busy, just getting back here...
Unfortuantely there is not a way to automatically set the metadata on the transfer that you are creating here. At the moment, you will have to listen for events around the payment and set the metadata via the API when you get them.
Are you clear on how to get to that py_ object in the API? I can help you find the best event to listen for for it if you don't already have a solid way of finding it.
payment.created ?
I think I'm going to use transfer.created becouse I have more info in this event.
[1] object: {
[1] id: 'tr_3NnMYTFIZKZQwzZI1AjZkSLz',
[1] object: 'transfer',
[1] amount: 48750,
[1] amount_reversed: 0,
[1] balance_transaction: 'txn_3NnMYTFIZKZQwzZI1DrEN2MX',
[1] created: 1694009886,
[1] currency: 'usd',
[1] description: null,
[1] destination: 'acct_1NnJNCFZlWJ15UL2',
[1] destination_payment: 'py_1NnMYUFZlWJ15UL2IQdxGc4z',
[1] livemode: false,
[1] metadata: {},
[1] reversals: {
[1] object: 'list',
[1] data: [],
[1] has_more: false,
[1] total_count: 0,
[1] url: '/v1/transfers/tr_3NnMYTFIZKZQwzZI1AjZkSLz/reversals'
[1] },
[1] reversed: false,
[1] source_transaction: 'ch_3NnMYTFIZKZQwzZI1iHB1dNV',
[1] source_type: 'card',
[1] transfer_group: 'group_pi_3NnMYTFIZKZQwzZI1EXeZPLp'
[1] }
[1] }
Yeah, transfer.created would be the best way to get that ID, then you can retrieve the source_transaction charge and expand its payment_intent.invoice property which will give you info on the subscription that the charge came from
Happy to help! This can definitely be dificult to implement.
One last details is that the Invoice there will be a subscription_details.metdata property which will have a snapshot of the metadata that you set on the subscription
Snapshot as in a one time copy of the subscription's metadata when the invoice was created. So if you change the metadata on the subscription it will not be updated on that property on the invoice
got it