#j-_api

1 messages ยท Page 1 of 1 (latest)

craggy marlinBOT
#

๐Ÿ‘‹ 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.

ocean lintel
#

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,
      },
    })
fleet cliff
#

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.

Learn how to add the right information to your API calls so you can make calls for your connected accounts.

Learn how to use metadata to save additional information.

ocean lintel
#

ok let me see

#

im suing webhooks

#
  } else if (event.type === 'charge.succeeded') {
    const charge = event.data.object as Stripe.Charge
fleet cliff
ocean lintel
#

so i need to make aditional requests to pass the customer?

fleet cliff
#

You'd need to make two additional requests:

  1. Retrieve the payment ID in the connected account
  2. Update metadata accordingly
#

The metadata will show in the payment object on the connected account

ocean lintel
#

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?

fleet cliff
#

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?

ocean lintel
#

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

fleet cliff
#

I shared the steps above. Let me try explain again.

The steps will be:

  1. After customer makes the payment successfully, you will listen to payment_intent.succeeded or charge.succeeded event (we generally recommend using payment_intent.* if you're using Payment Intent integration
  2. Make a request to Charge API to expand transfer property on the charge object to get the Payment ID using destination_payment field. Refer to this guide on how to expand an object: https://docs.stripe.com/api/expanding_objects
  3. Upon getting the Payment ID from Step (2), make another Charge API to update the metadata on the payment on the connected account with Stripe-Account header: https://docs.stripe.com/connect/authentication#stripe-account-header

Learn how to add the right information to your API calls so you can make calls for your connected accounts.

ocean lintel
#

sec

#

ok i retrieved the charge:
using const retrieveCharges = await stripe.charges.retrieve(charge.id, {
expand: ['customer'],
})

fleet cliff
#

You should expand the transfer object, not customer

#

The doc link is to just an example how a property can be expanded

ocean lintel
#

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

fleet cliff
#

destination_payment (py_xxx) for this Payment Intent will be found under transfer field

ocean lintel
#

destination_payment: 'py_1QN4K4BAuNoVK1pM9fVGEEvh',

#

yes here it is

#

i grab that and then

fleet cliff
ocean lintel
#

ok let me see

#

so first i charge retrieve and then charge.update

fleet cliff
#

Yup! For the Charge Update step, remember to include Stripe-Account header as py_xxx is on the connected account

ocean lintel
#

so annoying

#

getting a typescript error

fleet cliff
#

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;
ocean lintel
#

like this right?

fleet cliff
#

It should look something like this:

ocean lintel
#

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?

fleet cliff
#

What do you mean by assigning to the customer? Could you share what you're trying to achieve?

ocean lintel
#

here

fleet cliff
#

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

ocean lintel
#

sorry

#

i send bad pic

#

sorry ๐Ÿ˜›

fleet cliff
#

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

ocean lintel
#

well on my main account i receive the customer

#

on payments on the connected account i wish there is a customer also

fleet cliff
#

I'm afraid this is not supported

ocean lintel
#

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

fleet cliff
#

One alternative I can think of is to update the description to include the customer informaiton on the destination payments

ocean lintel
#

yes ive done that

#

thank you for your patience river

#

thats all

fleet cliff
#

No problem! Happy to help ๐Ÿ˜„