【问题标题】:Stripe charge multiple times多次分条充电
【发布时间】:2014-04-15 23:47:52
【问题描述】:

使用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 个令牌和任何后续收费,我都必须获取一个新令牌?

【问题讨论】:

    标签: stripe-payments


    【解决方案1】:

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

    希望对您有所帮助。 拉里

    PS 我在 Stripe 从事支持工作。

    【讨论】:

    • 官方文档中怎么会说令牌会过期?你说的话毫无意义。基本上你是说如果我创建一个客户,然后创建卡,然后获取卡令牌,然后添加到客户(updateCustomer),那么我可以永远只使用客户 ID 向这个用户收费吗?我不相信文档是这么说的。没有公司这样做。这就像永远的空白支票。
    【解决方案2】:

    有两件事。一个是token,一个是card id。令牌可以使用一次。它也有一定的使用时间限制。将卡片保存到云端后得到的卡片 ID。我们可以多次使用card 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
    ));
    

    【讨论】:

      猜你喜欢
      • 2021-09-01
      • 1970-01-01
      • 2023-03-05
      • 2021-11-28
      • 2011-06-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-27
      相关资源
      最近更新 更多