#j-_api
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1308616719333457920
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi river
I am attempting to send information to a connected account of who paid, on my original account im getting the customer id and the metadata, but i also want to send the information to my connected id account
const paymentIntent = await stripe.paymentIntents.create({
customer: customerId,
amount: amounts.total,
currency: currency,
payment_method: paymentMethodId,
setup_future_usage: setupFutureUsage,
description: params.venueId, // Ensure description is populated
application_fee_amount: avoFee,
transfer_data: {
destination: stripeAccountId,
},
metadata: {
venueId: params.venueId,
userId: userId,
persistAnonymousUser,
billId: params.billId,
tipPercentage: amounts.tipPercentage,
avoFee: avoFee,
userFee: amounts.userFee,
total: amounts.total,
amount: amounts.amount,
selectedProductsIds: JSON.stringify(selectedProductsIds),
splitType,
partySize,
payingFor,
isFromProductOrdering,
},
})
Metadata is not copied from one object to another automatically: https://docs.stripe.com/metadata#copy-metadata
For destination charge, you'd need to get the destination payment after receiving payment_intent.succeeded event, and update it with Stripe-Account header as connected account to update its metadata directly.
- Find out the destination payment on the connected account - Upon receipt of that event, make a request to retrieve the
latest_chargeand expand the response to includetransfer.destination_payment: https://docs.stripe.com/api/expanding_objects - Update the destination payment with
Stripe-Accountheader: https://docs.stripe.com/connect/authentication#stripe-account-header
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Learn how to add the right information to your API calls so you can make calls for your connected accounts.
ok let me see
im suing webhooks
} else if (event.type === 'charge.succeeded') {
const charge = event.data.object as Stripe.Charge
This would work too, but you still need to make additional request to expand the transfer to get the destination_payment: https://docs.stripe.com/api/transfers/object#transfer_object-destination_payment
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
so i need to make aditional requests to pass the customer?
You'd need to make two additional requests:
- Retrieve the payment ID in the connected account
- Update metadata accordingly
The metadata will show in the payment object on the connected account
after the opayment?
on the webhook i need to retrieve and update the metadata?
i want to understand the steps i need to make
first i create the payment intent, then on the webhook i receive the metadata and apply to my database
on the webhook i need to retrieve and update?
first i create the payment intent, then on the webhook i receive the metadata and apply to my database
Sorry, I don't quite understand here
Your initial ask is to have the payment on connected account having the same metadata
How does it relate to your database?
Could you explain what you're trying to achieve with an example, so that I can provide the solution accordingly?
Well
Ignore about my database
Im just explaining the steps im doing
Creating the payment intent, and then, getting the payment Intent, and then i receive via webhook the charge status
if what step should i make the additional requests of retrieving payment Id and update hte metadata
I shared the steps above. Let me try explain again.
The steps will be:
- After customer makes the payment successfully, you will listen to
payment_intent.succeededorcharge.succeededevent (we generally recommend usingpayment_intent.*if you're using Payment Intent integration - Make a request to Charge API to expand
transferproperty on the charge object to get the Payment ID usingdestination_paymentfield. Refer to this guide on how to expand an object: https://docs.stripe.com/api/expanding_objects - Upon getting the Payment ID from Step (2), make another Charge API to update the
metadataon the payment on the connected account withStripe-Accountheader: https://docs.stripe.com/connect/authentication#stripe-account-header
sec
ok i retrieved the charge:
using const retrieveCharges = await stripe.charges.retrieve(charge.id, {
expand: ['customer'],
})
You should expand the transfer object, not customer
The doc link is to just an example how a property can be expanded
ok
OG: retrieveCharges {
id: 'ch_3QN4K3BHBjfFQF5Y10VYqKXy',
object: 'charge',
amount: 1380,
amount_captured: 1380,
amount_refunded: 0,
application: null,
application_fee: 'fee_1QN4K4BAuNoVK1pMfVb2HztD',
application_fee_amount: 522,
balance_transaction: 'txn_3QN4K3BHBjfFQF5Y1uRL0God',
billing_details: {
address: {
city: null,
country: null,
line1: null,
line2: null,
postal_code: null,
state: null
},
email: null,
name: null,
phone: null
},
calculated_statement_descriptor: 'AVOQADO.IO',
captured: true,
created: 1732072279,
currency: 'mxn',
customer: 'cus_QtmkFD43l5BuO1',
description: 'madre_cafecito',
destination: 'acct_1NuRFGBAuNoVK1pM',
dispute: null,
disputed: false,
failure_balance_transaction: null,
failure_code: null,
failure_message: null,
fraud_details: {},
invoice: null,
livemode: false,
metadata: {
amount: '1200',
avoFee: '522',
billId: 'cm3pb0dff000d2u7wkswyjnb1',
persistAnonymousUser: 'd4d1c548-bbbb-4327-953e-92b510107ae8',
splitType: 'CUSTOMAMOUNT',
tipPercentage: '0.15',
total: '1380',
userFee: '0',
userId: 'cm18gy14e000d1122j4g19ja8',
venueId: 'madre_cafecito'
},
on_behalf_of: null,
order: null,
outcome: {
network_advice_code: null,
network_decline_code: null,
network_status: 'approved_by_network',
reason: null,
risk_level: 'normal',
risk_score: 13,
seller_message: 'Payment complete.',
type: 'authorized'
},
paid: true,
payment_intent: 'pi_3QN4K3BHBjfFQF5Y1RCvU3zm',
payment_method: 'pm_1QN4K3BHBjfFQF5YJ489p331',
payment_method_details: {
card: {
amount_authorized: 1380,
authorization_code: null,
using the transfer
destination: 'acct_1NuRFGBAuNoVK1pM',
const charge = await stripe.charges.update(
'ch_3MmlLrLkdIwHu7ix0snN0B15',
{
metadata: {
bla bla bla bla?
},
}
);
im so lost im sorry
destination_payment (py_xxx) for this Payment Intent will be found under transfer field
destination_payment: 'py_1QN4K4BAuNoVK1pM9fVGEEvh',
yes here it is
i grab that and then
This py_1QN4K4BAuNoVK1pM9fVGEEvh will be in the connected account. To update this, you will need to use Charge API with Stripe-Account header as connected account ID: https://docs.stripe.com/api/connected-accounts?lang=node
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Yup! For the Charge Update step, remember to include Stripe-Account header as py_xxx is on the connected account
You will need to manually map the type
For example:
const destinationPaymentId = (expandedCharge.transfer as Stripe.Transfer)?.destination_payment;
I'd recommend doing something like this:
const transfer = expandedCharge.transfer as Stripe.Transfer;
const destinationPaymentId = transfer?.destination_payment;
const connectedAccount = transfer?.destination;
like this right?
thanks
i think i take a lot of your time
im sorru
ill investigare further
i did it nice!
and how i assign the customer
before metadata rigjt?
What do you mean by assigning to the customer? Could you share what you're trying to achieve?
This is not Stripe code. If this your own internal business logic, we can't really help here as I don't have enough context of your business requirement
You can't assign the customer for destination payment like this
This is not supported
Hmm.. oh wait
Have you created any customer object on this connected account?
The customer on the platform will not be present in the connected account
well on my main account i receive the customer
on payments on the connected account i wish there is a customer also
I'm afraid this is not supported
ok what i want to do is that my connected acocunt knows where that payment comes from
for example river pays for item, i want to show on the payments of the connected account some data so the owner of the connected account can see where it comes from fast
i dont know if something comes to your mind but thats why i need to give some insights
One alternative I can think of is to update the description to include the customer informaiton on the destination payments
No problem! Happy to help ๐