#mlk-checkout-demo-php

1 messages · Page 1 of 1 (latest)

past burrow
#

Hi 👋 can you tell me a bit more about what is happening? Are you encountering any sort of error?

wind topaz
#

thanks for your answer

#

i have my function

#

public function createe(Request $request)
{

        // This is your test secret API key.
        \Stripe\Stripe::setApiKey('sk_test_51KLqvvA8d9dPx3rrzBl3boKsiQypuH2n8KdzaUaDiZoXdKdCjoV97Ymd0P6hKxWKSZameYqZEu2Mhc1bL7HgDDCe00XISE7Ml1');
        
        
        
        $YOUR_DOMAIN = 'http://localhost:4242/public';
        
        $checkout_session = \Stripe\Checkout\Session::create([
          'line_items' => [[
            # Provide the exact Price ID (e.g. pr_1234) of the product you want to sell
            'price' => 'price_1KMGB6A8d9dPx3rrQ4pcS2rt',
            'quantity' => 1,
          ]],
          'mode' => 'payment',
            'success_url' => 'https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Array',
            'cancel_url' => 'https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Arrayl',
        ]);
        
        header("HTTP/1.1 303 See Other");
        header("Location: " . $checkout_session->url);

}

#

im redirect to the link of my function but my page is white

past burrow
#

It is a test key, but I'd suggest rolling that secret key now that it's been made public.

#

I can see the sessions are being created, what do your browser logs say is happening when the redirect tries to occur?

wind topaz
#

i dont have any message

past burrow
#

If you watch the network tab, does it show the redirect happening?

wind topaz
past burrow
#

Hm, I'm not seeing the redirect to the checkout session being triggered. Can you walk me through what you've set up so far and what steps you're taking?

wind topaz
#

im using the laravel framework

#

i have my html form

#

<form action="{{route('createe')}}" method="POST">
@csrf
<button type="submit" id="checkout-button">Checkout</button>
</form>

#

.

#

.

#

Route::post('/createe', [pagecontroller::class, 'createe'])->name('createe');

#

.

#

.

#

and my function

#

public function createe(Request $request)
{

        // This is your test secret API key.
        \Stripe\Stripe::setApiKey('sk_test_51KLqvvA8d9dPx3rrzBl3boKsiQypuH2n8KdzaUaDiZoXdKdCjoV97Ymd0P6hKxWKSZameYqZEu2Mhc1bL7HgDDCe00XISE7Ml1');
        
        
        
        $YOUR_DOMAIN = 'http://localhost:4242/public';
        
        $checkout_session = \Stripe\Checkout\Session::create([
          'line_items' => [[
            # Provide the exact Price ID (e.g. pr_1234) of the product you want to sell
            'price' => 'price_1KMGB6A8d9dPx3rrQ4pcS2rt',
            'quantity' => 1,
          ]],
          'mode' => 'payment',
            'success_url' => 'https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Array',
            'cancel_url' => 'https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Arrayl',
        ]);
        
        header("HTTP/1.1 303 See Other");
        header("Location: " . $checkout_session->url);

}

past burrow
#

Hm, I'm not terribly familiar with the Laravel framework, but based on your screenshots it looks like your request to your createe endpoint is returning a 200 rather than the 303 to redirect.

wind topaz
#

and do you know how i can solve the problem?

past burrow
#

No I don't, because I believe it involves how the Laravel framework operates. I'd suggest looking at how to build a route within the framework and determine the proper way to return a non-200 status within it.

lyric stream
#

Alternatively you can have your server endpoint return the checkout session url and then redirect the browser from the client side using JS (eg with window.location)

#

But yes generally we aren't able to help with Laravel details as this is not create or maintained by Stripe -- you've need to ask the Laravel vendor or community for help with how to take certain actions using that framework