#Pablo Alagón
1 messages · Page 1 of 1 (latest)
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.
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
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.
I'm using the Stripe's Node SDK to capture payments
and accepting them afterwards
If you need to store any extra information on the PaymentIntents, you can use the metadata field: https://stripe.com/docs/api/payment_intents/create#create_payment_intent-metadata
but, is it possible to then filter those payments, and proceed with the transferring of the founds?
does that have any cost?
Sorry, I think I don't understand how you imagine this to work currently.
Do you use Stripe Connect? https://stripe.com/en-de/connect
no
How are you accepting payments currently?
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
That's an ideal use case for Stripe Connect, I recommend you look into it: https://stripe.com/docs/connect
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
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
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,...
Alright, what are you hoping I'll understand from your code? Is there something you're trying to show?