条纹付款:获取错误,因为客户cus _ *****没有带ID ID的链接卡_ *****

在测试模式下,当我创建新客户并尝试付款时,我收到此错误。

客户cus_7Zz2BCnybIZLGw没有ID为tok_17Kp8GAwLkQPB7OqrrM73VVI的链接卡

我使用卡号:4242424242424242 exp_month:12 exp_year 2016

回复是,

Array ( [charge_status] => [error_info] => Array ( [type] => invalid_request_error [message] => Customer cus_7Zz2BCnybIZLGw does not have a linked card with ID tok_17Kp8GAwLkQPB7OqrrM73VVI. [param] => card [code] => missing ) [message] => Customer cus_7Zz2BCnybIZLGw does not have a linked card with ID tok_17Kp8GAwLkQPB7OqrrM73VVI. ) 

输入费用数据是,

  $customer = Stripe_Customer::create(array( 'account_balance' => 100, 'source' => $token, 'email' => strip_tags(trim($email)) ) ); $customer_id = $customer->id; $charge = array( 'card' => 4242424242424242, 'amount' => 100, 'currency' => 'cad', 'receipt_email' => test@test.com, 'description' => 'my payment', 'customer' => $customer_id ); 

创建费用有三种不同的方式:

  • 仅使用source参数。 在这种情况下, source需要是令牌或源 ID(由Checkout或Stripe.js创建),即以tok_src_开头的字符串。

  • 仅限customer参数。 在这种情况下, customer需要是客户 ID,即以cus_开头的字符串。 将收取客户的默认付款来源。

  • 同时包含customersource参数。 在这种情况下, customer需要是前一种情况下的客户ID,但source应该是已连接到客户的付款来源的ID。 付款来源可以是卡 (ID以card_ ), 银行帐户 (ID以ba_ )或来源 (ID以src_ )。

在您的情况下,您将在source参数中传递令牌ID以及在customer参数中传递客户ID。

如果这是新卡,您应首先使用令牌在客户上创建卡 ,然后使用卡ID创建费用。 如果已经为该客户保存了该卡,则您不需要再次收集卡信息(因此根本不需要创建令牌)。

我在StripeCustomerCreateOptions设置了“SourceToken”,在StripeChargeCreateOptions (SourceToken)中为我的StripeCustomer设置了“SourceTokenOrExistingSourceId”。

删除SourceTokenOrExistingSourceId的分配解决了我的StripeCharge问题,因为令牌创建了冲突的ID。