javascript - Tipsi-Stripe:无法从令牌创建源
问题描述
完全不知道这里可能是什么问题,我不知道这个错误意味着什么。尝试从我的令牌创建源时,出现此错误:
Unhandled Promise Rejection (id: 40):
Error: The payment method `card` requires the parameter: card[number].
Error: The payment method `card` requires the parameter: card[number].
at Object.promiseMethodWrapper [as createSourceWithParams] (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:2275:36)
at Stripe.createSourceWithParams (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:190106:29)
at payWithCard$ (http://localhost:8081/src/CheckoutForm.bundle?platform=ios&dev=true&minify=false&modulesOnly=true&runModule=false&shallow=true:383:72)
at tryCatch (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:28564:19)
at Generator.invoke [as _invoke] (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:28740:24)
at Generator.prototype.<computed> [as next] (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:28607:23)
at tryCatch (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:28564:19)
at invoke (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:28640:22)
at http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:28650:15
at tryCallOne (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:3475:14)
这是我的代码。我已经尝试过任何组合,但我不确定 card[number] 是什么意思。我的令牌绝对有效,并且我在每个文档中传递了正确的值:https ://tipsi.github.io/tipsi-stripe/docs/createsourcewithparamsparams.html
const options = {
requiredBillingAddressFields: 'full',
theme: {
primaryBackgroundColor: '#f1f1f1',
},
};
const token = await stripe.paymentRequestWithCardForm(options);
const params = {
type: 'card',
amount: 50,
// currency: 'USD',
// returnURL: 'example://stripe-redirect',
card: token.card.cardId,
// card: token.card,
// card123: token.card.cardId,
token: token.tokenId,
};
console.log(token);
const source = await stripe.createSourceWithParams(params);
alert(source);
console.log(source);
任何建议将不胜感激。这是一个大图书馆,我认为这个问题很普遍?谢谢。
解决方案
API 已更改,文档未更新。这是新格式:
const source = await stripe.createSourceWithParams({
type: 'card',
number: '5555555555554444',
expMonth: 11,
expYear: 29,
cvc: '789',
})
推荐阅读
- android - 如何获取 Android AAB 文件的 versionCode 和 versionName(标记)?
- android - 在 Kotlin 中构建自己的缓存
- r - 使用现有列表中的名称来创建新列表,但也使用该名称作为新列表的名称
- jquery - 如何计算隐藏元素的顶部偏移量?
- swift5 - 创建亮度和暗淡的进度条?
- python - OPENCV_ENABLE_NONFREE CMake 选项并在函数“create”中重建库
- php - 按父母 slug 或 ID 在单页上显示 Woocommerce 子类别
- sonarqube - 如何抑制 SonarCloud 中的代码块,以防止在 Azure Functions 中必须存在“代码重复”时发出警报?
- html - 带有文本的内联 DIV 转到父级的底部
- php - 当 num1 和 num2 为空时,如何写“pera”而不是“Result is”?我试过了,但每次我得到“结果是”