我当前正在使用Stripe(测试模式),但是无法进行传输。 我可以毫无问题地进行付款,但是当我不得不将部分付款发送到另一个帐户时,我总是遇到问题。
我遵循以下规则:https://stripe.com/docs/recipes/elements-react#setup
在我的server.js中:
app.post("/charge", async (req, res) => {
try {
let {status} = await stripe.charges.create({
amount: 200000,
currency: "usd",
source: "tok_visa",
transfer_group: "tr_test",
source: req.body
});
res.json({status});
} catch (err) {
res.status(500).end();
}
})
app.post("/transfer", async (req, res) => {
try {
let {status} = await stripe.transfers.create({
amount: 100000,
currency: "usd",
destination: "acct_1DUAayISchW15mGi",
transfer_group: "tr_test"
});
res.json({status});
} catch (err) {
res.status(500).end();
}
})
在我的checkoutForm.js上:
async submit(ev) {
let {token} = await this.props.stripe.createToken({name: "Name"});
let response = await fetch("/charge", {
method: "POST",
headers: {"Content-Type": "text/plain"},
body: token.id
});
if (response.ok) console.log("Purchase Complete!")
let response2 = await fetch("/transfer", {
method: "POST",
headers: {"Content-Type": "text/plain"},
body: token.id
});
if (response2.ok) console.log("Transfers Complete!")
}
收费可以,不能转让...
如果有人可以帮助我或给我教程,我会很高兴的!