Sre*_*ree 41 javascript php payment jquery stripe-payments
在测试模式下,当我创建新客户并尝试付款时,我收到此错误.
客户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.
)
Run Code Online (Sandbox Code Playgroud)
输入费用数据是,
$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
);
Run Code Online (Sandbox Code Playgroud)
Ywa*_*ain 87
创建费用有三种不同的方式:
source仅使用参数.在这种情况下,source需要是令牌或源 ID(由Checkout或Stripe.js创建),即以tok_或开头的字符串src_.
customer仅使用参数.在这种情况下,customer需要是客户 ID,即以字母开头的字符串cus_.将收取客户的默认付款来源.
同时与customer和source参数.在这种情况下,customer需要像上一种情况一样是客户ID,但source应该是已经附加到客户的支付来源的ID.付款来源可以是卡(ID开头card_),银行帐户(ID开头ba_)或来源(ID开头src_).
在您的情况下,您将在source参数中传递令牌ID以及参数中的客户ID customer.
如果这是新卡,您应首先使用令牌在客户上创建卡,然后使用卡ID创建费用.如果该卡已经为该客户保存,则您不需要再次收集卡信息(因此根本不需要创建令牌).
小智 7
这段代码对我有帮助。它也可能对你有帮助。
Stripe\Stripe::setApiKey(env('STRIPE_SECRET'));
$customer = \Stripe\Customer::create([
'name' => 'Jenny Rosen',
'email' => 'jenyy@hotmail.co.us',
'address' => [
'line1' => '510 Townsend St',
'postal_code' => '98140',
'city' => 'San Francisco',
'state' => 'CA',
'country' => 'US',
],
]);
\Stripe\Customer::createSource(
$customer->id,
['source' => $request->stripeToken]
);
Stripe\Charge::create ([
"customer" => $customer->id,
"amount" => 100 * 100,
"currency" => "usd",
"description" => "Test payment from stripe.test." ,
]);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14231 次 |
| 最近记录: |