代码之家  ›  专栏  ›  技术社区  ›  Wesley Schravendijk

Laravel Stripe在测试模式下工作,但不在Live中,没有这样的令牌

  •  0
  • Wesley Schravendijk  · 技术社区  · 7 年前

    我现在不知所措。

    我刚开始穿条纹衣服。 看起来是个很棒的服务。

    这里是问题发生的地方。

    Stripe::setApiKey('[our live token]'); 
    
    /*
    * create new customer
    */
    $results = \Stripe\Charge::create([
       "amount"            =>          '10',
       "currency"          =>          "jpy",
       "source"            =>          $getCommission->unique_id,
       "description"       =>          "test charge"
    ]);
    

    它一直在说

    No such token: cus_EuguGZgeDoCxBj
    

    我非常感激你的帮助。

    1 回复  |  直到 7 年前
        1
  •  1
  •   Surender Singh Rawat    7 年前

    您提供的是客户id而不是源令牌。

    源令牌是用于引用您的卡的令牌。生成自条纹.js

    \Stripe\Stripe::setApiKey("sk_test_4eC39HqLyjWDarjtT1zdp7dc");
    
    \Stripe\Charge::create([
          "amount" => 2000,
          "currency" => "usd",
          "source" => "tok_amex", // obtained with Stripe.js
          "description" => "Charge for jenny.rosen@example.com"
     ]);
    

    如何获取默认源:

    1. 代表该客户获取默认源

        \Stripe\Stripe::setApiKey("sk_test_4eC39HqLyjWDarjtT1zdp7dc");
      
        $customer = \Stripe\Customer::retrieve('cus_EkSwM3JX7f0ueA');
        $customer->default_source; // use this as source token
      

      使用默认源作为源令牌