【发布时间】:2020-01-06 19:17:47
【问题描述】:
最终目的是将支付页面重定向到成功页面,但这发生在服务器上,我从 Stripe api 获得了一个对象响应,我想有条件地将它发送到前端(React),以便我可以重定向页面或直接从后端执行谢谢
条纹按钮
<div className={styles.buttonsection}>
<StripeCheckout
amount={total*100}
label="Credit Card"
name="Boston Maids"
email=""
token={ (token) =>{axios.post('/api/stripe', token)}}
stripeKey={"*********************"}
/>
server.js
app.post('/api/stripe', async (req, res) => {
const charge = await stripe.charges.create({
amount: 5000,
currency: 'usd',
description: 'Cleaning Services',
source: req.body.id
}).catch(console.error).then(charge =>{if (charge) {
console.log(charge);
} ```
【问题讨论】:
标签: javascript node.js reactjs routing stripe-payments