【发布时间】:2018-11-25 02:35:06
【问题描述】:
也发布在https://github.com/tipsi/tipsi-stripe/issues/312
包
"firebase": "^4.12.0",
"react": "^16.2.0",
"react-native": "^0.53.3",
"react-native-firebase": "^3.2.7",
"react-stripe-elements": "^1.6.0",
"tipsi-stripe": "^5.2.1"
问题
我使用不正确的到期日期调用 createTokenWithCard,它似乎没有返回错误,而是返回了一个令牌。 然后,当我尝试将此令牌写入 Firebase 时,我看到一个错误:“您的卡已被拒绝。” tipsi-stripe 是否返回错误而我没有正确检查?
代码如下:
addCard = async ({
number, expMonth, expYear, cvc,
}) => {
this.setState({ addingCardInProcess: true });
try {
const tokenObject = await stripe.createTokenWithCard({
number, expMonth, expYear, cvc
});
firebase
.database()
.ref(`/stripe_customers/${uid()}/sources`)
.push({ token: tokenObject.tokenId })
.then(() => {
this.setState({ addingCardInProcess: false });
this.cardAlert(true);
})
.catch((err) => {
this.setState({ addingCardInProcess: false });
this.cardAlert(false, err.message);
});
} catch(err) {
this.cardAlert(false, err.message);
this.setState({ addingCardInProcess: false })
}
};
【问题讨论】:
标签: react-native stripe-payments