#user1352-question
1 messages ยท Page 1 of 1 (latest)
Hi thank for your repl
Reply
I have value total in card.js
And Iโm trying to send the total server to make test recharge
Okay so that's not really a Stripe question in that case. You'd do this the same way you send any value to your server really
usually you do a POST request to your server to get the amount and create a PI
What type of post , xhttp request or app.get(Pos)
that's really up to you. That's your own code in the sense that you send the value the same way you do a login form or any kind of submission in your app
Look to this code
I try to use app get inside the server
To get the value total
I running the server is said to defined
I'm sorry I don't understand, it's just a picture of code with no context
that's your server-side code getting a total? But it's really just your own code, there's no Stripe code there
I see
what's blocking you exactly?
app.post('/create-payment-intent', async (req, res) => {
const {paymentMethodType, currency} = req.body;
// Each payment method type has support for different currencies. In order to
// support many payment method types and several currencies, this server
// endpoint accepts both the payment method type and the currency as
// parameters.
//
// Some example payment method types include card, ideal, and alipay.
const params = {
payment_method_types: [paymentMethodType],
amount: 1999,
currency: currency,
}
// If this is for an ACSS payment, we add payment_method_options to create
// the Mandate.
if(paymentMethodType === 'acss_debit') {
params.payment_method_options = {
acss_debit: {
mandate_options: {
payment_schedule: 'sporadic',
transaction_type: 'personal',
},
},
}
}
// Create a PaymentIntent with the amount, currency, and a payment method type.
//
// See the documentation [0] for the full list of supported parameters.
//
// [0] https://stripe.com/docs/api/payment_intents/create
try {
const paymentIntent = await stripe.paymentIntents.create(params);
// Send publishable key and PaymentIntent details to client
res.send({
clientSecret: paymentIntent.client_secret,
});
} catch (e) {
return res.status(400).send({
error: {
message: e.message,
},
});
}
});
you're just copy-pasting code at this point unfortunately and mixing ACSS and stuff
just ignore all of Stripe for a few hours since you are working on how to handle basic form/post submission in JS
`
app.post('/create-payment-intent', async (req, res) => {
const {paymentMethodType, currency} = req.body;
// Each payment method type has support for different currencies. In order to
// support many payment method types and several currencies, this server
// endpoint accepts both the payment method type and the currency as
// parameters.
//
// Some example payment method types include card, ideal, and alipay.
const params = {
payment_method_types: [paymentMethodType],
amount: 1999,
currency: currency,
}
// If this is for an ACSS payment, we add payment_method_options to create
// the Mandate.
if(paymentMethodType === 'acss_debit') {
params.payment_method_options = {
acss_debit: {
mandate_options: {
payment_schedule: 'sporadic',
transaction_type: 'personal',
},
},
}
}
// Create a PaymentIntent with the amount, currency, and a payment method type.
//
// See the documentation [0] for the full list of supported parameters.
//
// [0] https://stripe.com/docs/api/payment_intents/create
try {
const paymentIntent = await stripe.paymentIntents.create(params);
// Send publishable key and PaymentIntent details to client
res.send({
clientSecret: paymentIntent.client_secret,
});
} catch (e) {
return res.status(400).send({
error: {
message: e.message,
},
});
}
});
`
you just did the same and reposted the whole code again ๐
But I see you're trying to send the amount from your client-side JS to your server-side code to create the PI
but you still haven't said what's blocking you
and really ignoring Stripe for a few hours and learning to do this in basic/vanilla JS is the best next step
it's not Stripe specific, it's the same as any input text you'd have in your website anywhere
This it been send to client card .js
then what's the problem? I'm sorry I keep repeating this but you really need to explain the code and error in a lot more words, right now you just say it doesn't work