刚接触 stripe,但文档看起来很不错,但现在库存的东西非常基本,我可以看到在 stripe 控制台中创建的客户,与产品和价格相同,但当我尝试附加从 cardElement 检索的付款方式并将其发送时到服务器我收到付款方法无效的消息。我正在关注此页面中的 stripe 文档 https://stripe.com/docs/billing/subscriptions/fixed-price#create-customer
在 JavaScript 中我有:
const payload = await stripe.createPaymentMethod({
type: 'card',
card: elements.getElement(CardElement),
billing_details: billingDetails,
});
Run Code Online (Sandbox Code Playgroud)
返回带有 id 的 paymentMethod 对象
paymentMethod.id be like pm_1GoHU32eZvKYloXXXXXXX
Run Code Online (Sandbox Code Playgroud)
在服务器端:
await stripe.paymentMethods.attach(paymentMethodId, {
customer: customerId,
});
Run Code Online (Sandbox Code Playgroud)
但我收到如下异常
StripeInvalidRequestError: No such PaymentMethod: pm_1GoHU32eZvKYloXXXXXXX
at Function.generate (/root/coco/node_modules/stripe/lib/Error.js:39:16)
at IncomingMessage.<anonymous>
(/root/coco/node_modules/stripe/lib/StripeResource.js:175:33)
at Object.onceWrapper (events.js:421:28)
at IncomingMessage.emit (events.js:327:22)
at IncomingMessage.EventEmitter.emit (domain.js:485:12)
at endReadableNT (_stream_readable.js:1225:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
type: 'StripeInvalidRequestError',
raw: {
code: 'resource_missing',
doc_url: 'https://stripe.com/docs/error-codes/resource-missing',
message: 'No such PaymentMethod: pm_1GoHU32eZvKYlo2CYLA3SCaX',
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14981 次 |
| 最近记录: |