【发布时间】:2021-10-12 03:23:15
【问题描述】:
我正在尝试在条带付款方式中存在的计费详细信息对象中添加电话号码。到目前为止,我能够通过电子邮件和类型获取付款方式的数据,现在我正在尝试以单独的方法发送更新模型,该方法将更新计费详细信息中的电话号码。但是我收到了这个错误
"message":"No such PaymentMethod: 'cus_JztknPBEnl5h8x'","stack":"Error: No such PaymentMethod: 'cus_JztknPBEnl5h8x'\n at Function.generate (/Users/mac/Desktop/Batch-Skip/batch -skip-tracing/server/node_modules/stripe/lib/Error.js:40:16)\n 在 IncomingMessage. (/Users/mac/Desktop/Batch-Skip/batch-skip-tracing/server/node_modules/stripe/ lib/StripeResource.js:203:33)\n 在 Object.onceWrapper (events.js:481:28)\n 在 IncomingMessage.emit (events.js:387:35)\n 在 IncomingMessage.emit (domain.js :470:12)\n 在 endReadableNT (internal/streams/readable.js:1317:12)\n 在 processTicksAndRejections (internal/process/task_queues.js:82:21)","context":"payment-controller" ,"method":"addNewCard","level":"error","timestamp":"2021-08-07 23:08:18 +0500"}
这是我的 getPaymentDetails 方法
public async getAllStripePayments(id: string): Promise<Stripe.Response<Stripe.ApiList<Stripe.PaymentMethod>>> {
const paymentMethods = await this.stripeClient.paymentMethods.list({customer: id, type: 'card'});
return paymentMethods;
}
这里是更新方法
public async updateStripePaymentMethods(id: string, updateModel: Stripe.PaymentMethodUpdateParams): Promise<Stripe.Response<Stripe.PaymentMethod>> {
const paymentMethods = await this.stripeClient.paymentMethods.update(id, updateModel);
return paymentMethods;
}
这样调用更新方法
const paymentMethod = await this.stripeApi.getAllStripePayments(stripeCustomer.id);
console.log(JSON.stringify(paymentMethod));
const updateModel = {
billing_details: {
phone: customerMeta.phoneNumber,
},
};
const updatePaymentMethod = await this.stripeApi.updateStripePaymentMethods(stripeCustomer.id, updateModel);
console.log(updatePaymentMethod);
getPaymentDetails 方法返回的数据如下所示
{
"object": "list",
"data": [
{
"id": "card_xxxxxxxxxxxx",
"object": "payment_method",
"billing_details": {
"address": {
"city": null,
"country": null,
"line1": null,
"line2": null,
"postal_code": "xxxxx",
"state": null
},
"email": null,
"name": null,
"phone": null
},
"card": {
"brand": "visa",
"checks": {
"address_line1_check": null,
"address_postal_code_check": "pass",
"cvc_check": "pass"
},
"country": "US",
"exp_month": 7,
"exp_year": 2026,
"fingerprint": "rxyg7B0k7Wp2Komf",
"funding": "credit",
"generated_from": null,
"last4": "4242",
"networks": {
"available": [
"visa"
],
"preferred": null
},
"three_d_secure_usage": {
"supported": true
},
"wallet": null
},
"created": 1628359699,
"customer": "cus_JztknPBEnl5h8x",
"livemode": false,
"metadata": {},
"type": "card"
}
],
"has_more": false,
"url": "/v1/payment_methods"
}
【问题讨论】:
标签: node.js express stripe-payments