我正在将 stripe.js 与 php 一起使用,并且在为现有/保存的卡和新卡创建令牌时遇到问题,一切正常。是否有任何函数可以根据 cardId 和 customerId 生成令牌
问问题
1177 次
1 回答
2
从现有的客户或卡对象创建新令牌既没有必要也不可能。将卡存储在客户对象上后,您可以仅使用您的密钥和客户 ID 完成收费。从文档:
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
\Stripe\Stripe::setApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
// Token is created using Stripe.js or Checkout!
// Get the payment token ID submitted by the form:
$token = $_POST['stripeToken'];
// Create a Customer:
$customer = \Stripe\Customer::create(array(
"email" => "paying.user@example.com",
"source" => $token,
));
// Charge the Customer instead of the card:
$charge = \Stripe\Charge::create(array(
"amount" => 1000,
"currency" => "usd",
"customer" => $customer->id
));
// YOUR CODE: Save the customer ID and other info in a database for later.
// YOUR CODE (LATER): When it's time to charge the customer again, retrieve the customer ID.
$charge = \Stripe\Charge::create(array(
"amount" => 1500, // $15.00 this time
"currency" => "usd",
"customer" => $customer_id
));
如果您对如何在 Stripe 上实施特定支付流程有任何其他问题,我建议您联系Stripe 支持。
于 2017-08-11T19:17:57.957 回答