Stripe payments 多次装药

Stripe payments 多次装药,stripe-payments,Stripe Payments,使用Stripe.js,我可以获得一个卡令牌,然后我可以使用该令牌通过以下方式进行收费: Stripe::Charge.create( :amount => 400, :currency => "usd", :card => "tok_103rC02eZvKYlo2C2RD5docg", # obtained with Stripe.js, :metadata => {'order_id' => '6735'} ) 我可以多次使用相同的卡代币向客户

使用
Stripe.js
,我可以获得一个
卡令牌
,然后我可以使用该令牌通过以下方式进行收费:

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

我可以多次使用相同的
卡代币向客户收费吗?或者是1代币/代币和任何后续收费,我将必须获取一个新代币?

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

希望有帮助。 拉里


PS我在Stripe从事支持工作。

有两件事。一个是令牌,一个是卡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
));