Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

marcoCarcangiu's avatar

exeption: You cannot use a Stripe token more than once....

I am using https://github.com/amsgames/laravel-shop with omypay/stripe extension. When I get to the checkout I always get the following erro: "You cannot use a Stripe token more than once:....................."

My code is as following:

  if (!Cart::current()->count) {
        throw new Exception('Cannot checkout, no items in cart.');
    }

    //Set gateway
    
    Shop::setGateway('omnipay');

    //Indicate service to use
    Shop::gateway()->create('Stripe');

    //Initialize service 
    Shop::gateway()->omnipay->initialize([
        'apiKey'   => env('STRIPE_SECRET_KEY'),
    ]);

    Shop::gateway()->addOption('source', $request->get('stripeToken'));

    //Call checkout
    if (Shop::checkout())
    {
        //Create order
        $order = Shop::placeOrder();
        //Review payment
        if($order->hasFailed)
        {
            return Shop::exception()->getMessage();
        }
        else
        {
            Cart::current()->clear();
            return "order placed successfully";
        }
    }

    return Shop::exception()->getMessage();
0 likes
0 replies

Please or to participate in this conversation.