[英]No Such Payment Method - Clone Payment Method Stripe Connect
我正在按照此示例克隆付款方式: https://stripe.com/docs/payments/payment-methods/connect#cloning-payment-methods
const paymentMethod = await stripe.paymentMethods.create(
{
customer: card.customer,
payment_method: card.id,
},
{
stripeAccount: vendorAcc,
}
);
這將返回:
{
id: 'pm_....',
object: 'payment_method',
billing_details: {
address: {
city: null,
country: null,
line1: null,
line2: null,
postal_code: null,
state: null
},
email: '...',
name: '...',
phone: null
},
card: {
brand: 'visa',
checks: {
address_line1_check: null,
address_postal_code_check: null,
cvc_check: 'pass'
},
country: 'US',
exp_month: 3,
exp_year: ...,
fingerprint: 'c...',
funding: 'credit',
generated_from: null,
last4: '4242',
networks: { available: [Array], preferred: null },
three_d_secure_usage: { supported: true },
wallet: null
},
created: 1616118576,
customer: null,
livemode: false,
metadata: {},
type: 'card'
}
但是,當我下次嘗試運行時:
const paymentMethod2 = await stripe.paymentMethods.retrieve(
paymentMethod.id
);
或者
const paymentMethodAttached = await stripe.paymentMethods.attach(
paymentMethod.id,
{ customer: card.customer }
我得到錯誤:
StripeInvalidRequestError: No such PaymentMethod: 'pm_...'
...
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_...'",
param: 'payment_method',
type: 'invalid_request_error',
headers: {
server: 'nginx',
date: 'Fri, 19 Mar 2021 01:49:37 GMT',
'content-type': 'application/json',
'content-length': '262',
connection: 'keep-alive',
'access-control-allow-credentials': 'true',
'access-control-allow-methods': 'GET, POST, HEAD, OPTIONS, DELETE',
'access-control-allow-origin': '*',
'access-control-expose-headers': 'Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required',
'access-control-max-age': '300',
'cache-control': 'no-cache, no-store',
'request-id': 'req_...',
'stripe-version': '2020-03-02',
'x-stripe-c-cost': '12',
'strict-transport-security': 'max-age=31556926; includeSubDomains; preload'
},
statusCode: 404,
requestId: 'req_...'
},
rawType: 'invalid_request_error',
code: 'resource_missing',
doc_url: 'https://stripe.com/docs/error-codes/resource-missing',
param: 'payment_method',
detail: undefined,
headers: {
server: 'nginx',
date: 'Fri, 19 Mar 2021 01:49:37 GMT',
'content-type': 'application/json',
'content-length': '262',
connection: 'keep-alive',
'access-control-allow-credentials': 'true',
'access-control-allow-methods': 'GET, POST, HEAD, OPTIONS, DELETE',
'access-control-allow-origin': '*',
'access-control-expose-headers': 'Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required',
'access-control-max-age': '300',
'cache-control': 'no-cache, no-store',
'request-id': 'req_...',
'stripe-version': '2020-03-02',
'x-stripe-c-cost': '12',
'strict-transport-security': 'max-age=31556926; includeSubDomains; preload'
},
requestId: 'req_...',
statusCode: 404,
charge: undefined,
decline_code: undefined,
payment_intent: undefined,
payment_method: undefined,
payment_method_type: undefined,
setup_intent: undefined,
source: undefined
}
);
更新:
我現在正在運行:
const paymentMethodAttached = await stripe.paymentMethods.attach(
paymentMethod.id,
{
customer: card.customer,
},
{
stripeAccount: vendorAcc,
}
);
這會引發錯誤:
沒有這樣的客戶:'cus_...'
當我跑
const paymentMethod2 = await stripe.paymentMethods.retrieve(
paymentMethod.id,
{
stripeAccount: vendorAcc,
}
);
這成功返回,其中:
{
id: 'pm_...',
object: 'payment_method',
billing_details: {
address: {
city: null,
country: null,
line1: null,
line2: null,
postal_code: null,
state: null
},
email: '...',
name: '...',
phone: null
},
card: {
brand: 'visa',
checks: {
address_line1_check: null,
address_postal_code_check: null,
cvc_check: 'pass'
},
country: 'US',
exp_month: 3,
exp_year: 2024,
fingerprint: '...',
funding: 'credit',
generated_from: null,
last4: '4242',
networks: { available: [Array], preferred: null },
three_d_secure_usage: { supported: true },
wallet: null
},
created: 1616158821,
customer: null,
livemode: false,
metadata: {},
type: 'card'
}
“No such...”錯誤通常是由於 API 密鑰不匹配(例如使用測試和實時密鑰的混合)或嘗試訪問存在於不同帳戶上的對象(例如嘗試從您在已連接帳戶上創建的 object 上的平台帳戶)。
在這種情況下,它是第二個:您的檢索或附加調用不包括 Stripe-Account header ,因此他們正在查找錯誤的 Stripe 帳戶。
更新:客戶必須存在於關聯帳戶中,這可能不會給出您的“沒有這樣的客戶”錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.