【发布时间】:2020-01-24 20:54:19
【问题描述】:
我的代码正在保存客户的卡并稍后在我的条带帐户中向他们收费。但是,当我修改代码以在已连接的条带帐户上对卡进行收费时,它将无法正常工作。
请注意,我在欧盟,所以我必须使用强客户身份验证 - 我不能使用令牌。
相关前端代码为:
const cardElement = this.props.elements.getElement('card');
axios.post(`${process.env.REACT_APP_API}/saveCardDetails`, {stripeAccountID: this.props.stripeAccountID}).then(res => {
this.props.stripe.confirmCardSetup(res.data.client_secret, {
payment_method: {
card: cardElement,
},
},{
stripe_account: this.props.stripeAccountID,
}
).then( confirmCardSetupRes => {..})
相关后端代码为:
//saveCardDetails controller
module.exports = (req, res) => {
stripe.setupIntents.create().then(intent => {
console.log('intent.client_secret', intent.client_secret)
res.send({client_secret: intent.client_secret})
})
}
//code to charge the saved card
const chargeSavedCard = (customerStripeID, price, currency, eventTitle, applicationFee, organiserstripeAccountID) => {
stripe.paymentMethods.list({
customer: customerStripeID,
type: 'card',
}).then(paymentMethods => {
stripe.paymentIntents.create({
amount: Math.round(price * 100),
currency: currency,
customer: customerStripeID,
payment_method: paymentMethods.data[0].id,
off_session: true,
confirm: true,
application_fee_amount: Math.round(applicationFee)
}
,{
stripe_account: organiserstripeAccountID,
}
).then(stripeRes => {.......})
抛出以下错误:
{ Error: No such PaymentMethod: pm_1G4YYVCFzSpFw85fXVcZj0hX; OAuth key or Stripe-Account header was used but API request was provided with a platform-owned payment method ID. Please ensure that the provided payment method matches the specified account.
我不明白为什么我的代码没有在连接的帐户上设置付款方式。我哪里错了?
【问题讨论】:
标签: node.js reactjs stripe-payments