【发布时间】:2018-11-24 17:07:59
【问题描述】:
我在我的 React 应用程序中使用 Stripe Checkout。不知何故,我没有正确地将属性传递给我的 onToken 函数,因为我得到了未定义的错误。
我最终需要发送一堆道具,但现在只是想让它正常工作。
import axios from 'axios'
import React from 'react'
import StripeCheckout from 'react-stripe-checkout';
const PAYMENT_SERVER_URL = '3RD_PARTY_SERVER';
const CURRENCY = 'USD';
export default class Stripe25 extends React.Component {
onToken = (token) => {
axios.post(PAYMENT_SERVER_URL,
{
description,
source: token.id,
currency: CURRENCY,
amount: amount
})
.then(successPayment)
.catch(errorPayment);
}
render() {
return (
<StripeCheckout
token={this.onToken}
stripeKey="STRIPE_PUBLIC_KEY"
name=""
description=""
image=""
panelLabel="Donate"
amount={2500} // cents
currency="USD"
locale="auto"
zipCode={false}
billingAddress={true}
>
<button className="btn btn-primary">
$25
</button>
</StripeCheckout>
)
}
}
【问题讨论】:
-
描述在哪里定义?我在任何地方都没有看到它,并且它没有传递到 onToken 方法中。
标签: javascript reactjs stripe.js