#Pablo Alagón

1 messages · Page 1 of 1 (latest)

queen basinBOT
strange otter
#

Hi! Let me help you with this.

#

I'm sure you can build custom logic in your app to use different API keys for each region.

#

What do you mean by "tag" payments? A payment can live only on one account.

errant solstice
#

by tag i mean whenever a payment enters from a specific location, let Stripe know that that payment comes from that specific place, and somehow, and the end of the month, forward the corresponding payments to the other Stripe accounts

strange otter
#

How are you creating payments?

#

A payment must be created in a specific Stripe account. So when you see it comes from a particular country you can use the Stripe API keys from the correspoding account.

errant solstice
#

I'm using the Stripe's Node SDK to capture payments

#

and accepting them afterwards

strange otter
errant solstice
#

but, is it possible to then filter those payments, and proceed with the transferring of the founds?

#

does that have any cost?

strange otter
#

Sorry, I think I don't understand how you imagine this to work currently.

strange otter
#

How are you accepting payments currently?

errant solstice
#

i just wanna have like a "main account" for a client, and if that client has multiple locations with their corresponding stripe account, and the end of the month send the gathered founds in that main account to their other accoutns

strange otter
errant solstice
#

all the examples there are using checkout method for the payments

#

is it possible to do it with stripe.createPaymentMethod

#

and using a capture of the payment instead

drifting hamlet
#

Hi 👋 jumping in as my teammate needs to step away. Yes, Connect allows you to process Payment Intents directly rather than needing to rely on Checkout Sessions.

#

When building a Connect integration, the first choices you need to make are what type of Accounts and what charge structure will be the best fit for your use case.

This talks about the types of Connected Accounts that are available:
https://stripe.com/docs/connect/accounts

And this discusses the charge structures:
https://stripe.com/docs/connect/charges

Learn more about the different types of Stripe accounts you can use with Connect.

Learn how to create a charge and split payments between your platform and your sellers or service providers when you accept payments.

errant solstice
#

this our actual code:

const paymentMethodReq = await stripe.createPaymentMethod({
  type: 'card',
  card: cardElement,
  // billing_details: billingDetails
})

if (paymentMethodReq.error) {
  setLoading(false)
  //console.log(paymentMethodReq.error)
  setError(paymentMethodReq.error.message)
  setOpenMessage(true)
  return
}

const stripeData = await fetch(`${import.meta.env.VITE_API_BASE}/stripe-api/create-payment-intent`, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    quantity: parseInt(props.quantity * 100),
    payment_method: paymentMethodReq.paymentMethod.id,
    pedido: new URLSearchParams(window.location.search).get('pedido'),
  }),
})
  .then((res) => res.json())
  .then((res) => {
    return res
  })
  .catch((e) => {
    console.error(e)
    setLoading(false)
  })

This is the /create-payment-intent endpoint:

router.post('/create-payment-intent', (req, res) => {
  // quantity comes in cents
  const { quantity, pedido, payment_method } = req.body

  pool.query('SELECT * FROM tokens WHERE token=$1', [pedido], async (error, results) => {
    if (error) res.status(500).send()
    else if (results.rows.length > 0) {
      if (quantity && payment_method && pedido) {
        const paymentIntent = await stripe.paymentIntents.create({
          amount: quantity,
          currency: 'eur',
          payment_method_types: ['card'],
          capture_method: 'manual',
          payment_method: payment_method,
        })

        pool
          .query('UPDATE pedidos SET pintent=$1 WHERE id=$2', [paymentIntent.id, results.rows[0].idpedido])
          .then(() => res.json({ client_secret: paymentIntent.client_secret }))
          .catch(() => res.status(500).send())
      } else {
        res.status(500).send()
      }
    } else res.status(500).send()
  })
})

And the at the checkout when the user hits pay, this happens:
await stripe.confirmCardPayment(stripeData.client_secret,...

drifting hamlet
#

Alright, what are you hoping I'll understand from your code? Is there something you're trying to show?