条纹充电多次

时间:2014-04-15 23:47:53

标签: stripe-payments

使用Stripe.js,我得到一个card token然后我可以通过以下方式收费:

Stripe::Charge.create(
  :amount => 400,
  :currency => "usd",
  :card => "tok_103rC02eZvKYlo2C2RD5docg", # obtained with Stripe.js,
  :metadata => {'order_id' => '6735'}
)

我可以多次使用相同的card token向客户收费,或者是1令牌/费用以及任何后续费用,我将不得不获取新令牌吗?

2 个答案:

答案 0 :(得分:29)

好问题!当您以这种方式使用令牌时,它会被立即使用,因此无法再次使用。但是,您可以在Stripe中创建Customer对象时将该标记提供为card参数。然后,您可以对该客户执行多项费用。

希望有所帮助。 拉里

PS我在Stripe的支持工作。

答案 1 :(得分:0)

有两件事。一个是令牌,一个是卡ID。令牌可以使用一次。它也有一些时间限制。我们在将卡保存到云后获得的卡ID。我们可以多次使用卡ID。 令牌通过公钥生成。这不能再使用了。 因此,您可以使用卡ID进行多次付款

require_once APPPATH . 'libraries/Stripe.php';
Stripe::setApiKey("***********************"); //Put here your secrect key

//Add card and get token id.

$tokenDetail = Stripe_Token::create(array(
"currency" => "USD",
"card" => array(
"number" => '********', //$credit_card_number,
"exp_month" => '**', //$exp_date_month,
"exp_year" => '**', //$exp_date_year,
"cvc" => '***'//$cvv_number
)
));


$token = $tokenDetail->id;
Stripe::setApiKey("*********************"); ////Put here your secrect key

// Get card id by creating a Customer.
$customer = Stripe_Customer::create(array(
"source" => $tokenDetail->id,
"description" => "For testing purpose",
)
);  

$response = Stripe_Charge::create(array(
"amount" => 100,
"currency" => "usd",
"customer" => $customer->id // obtained with Stripe.js
));