Stripe Payment: Getting Error as Customer cus_***** does not have a linked card with ID tok_*****

前端 未结 3 746
滥情空心
滥情空心 2020-12-02 15:43

In testing mode when I create a new customer and tries for payment, i got this error.

Customer cus_7Zz2BCnybIZLGw does not have a linked card with ID

3条回答
  •  甜味超标
    2020-12-02 15:58

    This code helped me. It might also help you.

    Stripe\Stripe::setApiKey(env('STRIPE_SECRET'));
    
    $customer = \Stripe\Customer::create([
        'name' => 'Jenny Rosen',
        'email' => 'jenyy@hotmail.co.us',
        'address' => [
            'line1' => '510 Townsend St',
            'postal_code' => '98140',
            'city' => 'San Francisco',
            'state' => 'CA',
            'country' => 'US',
        ],
    ]);
    
    \Stripe\Customer::createSource(
        $customer->id,
        ['source' => $request->stripeToken]
    );
    
    Stripe\Charge::create ([
        "customer" => $customer->id,
        "amount" => 100 * 100,
        "currency" => "usd",
        "description" => "Test payment from stripe.test." , 
    ]);
    

提交回复
热议问题