[英]No Such Payment Method - Clone Payment Method Stripe Connect
I'm following this example to clone a payment method: https://stripe.com/docs/payments/payment-methods/connect#cloning-payment-methods我正在按照此示例克隆付款方式: 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,
}
);
This returns:这将返回:
{
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'
}
However, when I next try to run:但是,当我下次尝试运行时:
const paymentMethod2 = await stripe.paymentMethods.retrieve(
paymentMethod.id
);
or或者
const paymentMethodAttached = await stripe.paymentMethods.attach(
paymentMethod.id,
{ customer: card.customer }
I get the error:我得到错误:
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
}
);
UPDATE :更新:
I am now running:我现在正在运行:
const paymentMethodAttached = await stripe.paymentMethods.attach(
paymentMethod.id,
{
customer: card.customer,
},
{
stripeAccount: vendorAcc,
}
);
This throws the error:这会引发错误:
No such customer: 'cus_...'没有这样的客户:'cus_...'
When I run当我跑
const paymentMethod2 = await stripe.paymentMethods.retrieve(
paymentMethod.id,
{
stripeAccount: vendorAcc,
}
);
this returns successfully, with:这成功返回,其中:
{
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...” errors are usually caused by either a mismatch in API keys (eg using a mixture of your test plus live keys) or by trying to access objects that exist on a different account (eg trying to perform an operation from your platform account on an object that was created on a connected account). “No such...”错误通常是由于 API 密钥不匹配(例如使用测试和实时密钥的混合)或尝试访问存在于不同帐户上的对象(例如尝试从您在已连接帐户上创建的 object 上的平台帐户)。
In this case it's the second one: your retrieve or attach calls don't include the Stripe-Account header , so they're looking on the wrong Stripe Account.在这种情况下,它是第二个:您的检索或附加调用不包括 Stripe-Account header ,因此他们正在查找错误的 Stripe 帐户。
Update: Also the Customer must exist on the Connected Account, which it likely doesn't given your 'no such Customer' error.更新:客户必须存在于关联帐户中,这可能不会给出您的“没有这样的客户”错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.