#Felix Cao
1 messages · Page 1 of 1 (latest)
Can you elaborate more what you're trying to achieve?
- our platform is
Xoda Xodahas lots of merchant, we named gym- gym has lots of member
- member buy the gym's service
So I want to know when the member create a transaction,
How to know the transaction come from our platform?
👋 taking over here. Thanks for the explanation but it comes down to how you are using Stripe API
What API are you using? which integration?
So that's SetupIntent and PaymentElement
I think Xoda is a Platform, and each gym is a Connected Account?
From Set up future payments
Step1. Our server side return client_secret by api
const stripe = require('stripe')('sk_test_26PHem9AhJZvU623DfE1x4sd');
const customer = await stripe.customers.create();
const intent = stripe.setupIntents.create({
customer: customer.id,
automatic_payment_methods: {enabled: true},
});
return res.status(200).json({ client_secret: intent.client_secret });
Step2. Our Front end will use the client_secret to render the payment method page with Stripe Elements
and confirmSetup
and submit the payment method to strip
then get the payment_method_id
then submit the payment_method_id to our server side
Through step1 and step2, will collect the payment method for customer
Please redact your secret key (sk_xxx)
Okie sure. And when the transaction completed, you should receive a setup_intent.succeeded webhook event
it should contains the customer_id
on which you can call Retrieve Customer API to find out information about the member (customer) who bought the service
I mean the stripe how to know the transaction come from our platform
Sorry I don't follow the context. On where do you want to verify the traction comes from your platform?
Yes
Need to attach the connected_account_id ?
The stripe can know the transaction from our platform by connected_account_id ?
You may mixed things up. You are using SetupIntent flow, why are you creating PaymentIntent?
SetupIntent != PaymentIntent
My understand is :
SetupIntent give the collect the payment method for future paymentIntent
Right?
Ah yes that's correct. Those are 2 separated steps tho
When you create the future paymentintent, then you would want confirm: true instead of false
So the above step1 and step2 is right ?
Then
Step3, transaction:
const stripe = stripeWithSK(member.gym.stripe_secret_key);
try {
let paymentIntent = await stripe.paymentIntents.create(
{
amount,
currency: member.gym.currency_code,
automatic_payment_methods: { enabled: true },
customer: member.stripe_customer_id,
payment_method: member.stripe_payment_method_id,
confirm: false,
metadata: {
reference_number
}
},
{
stripeAccount: 'acct_*****',
}
);
paymentIntent = await confirm(paymentIntent.id, member.stripe_payment_method_id, stripe);
console.log('paymentIntent----', paymentIntent) // todo, will del
return paymentIntent;
} catch (err) {
console.log('Stripe Error code is: ', err.code);
const paymentIntentRetrieved = await stripe.paymentIntents.retrieve(err.raw.payment_intent.id);
console.log('PI retrieved: ', paymentIntentRetrieved.id);
}
Sorry, this is still the same as above (PaymentIntent) and that was step 2
Could you put it clear what exactly is your step 1, step 2 and step 3?
Ah okie I see, thanks!
In step 3, on the line confirm: false you should change it to confirm: true
I don't want to change confirm: true
handle the charge by server side
and the merchant's member has a schedule payment, such as weekly, fortnightly, monthly...
All the transaction will handle by server side, and will send a email or SMS to customer
For the schedule payment, we have a cron job to run
Is it right for step1 - step3 ?
Thans very much !
Step 3 is already server side, what prevent you by setting confirm: true? If you don't confirm it, it still need to be confirmed sometimes later
I have to have a rest
It's time to noon break in china
And will ask for your advice again in the after noon
Can i still ask for you advice again ?
Sure