Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Stripe Test - Laravel

@php

require_once __DIR__. '/../../../vendor/autoload.php';

StripeStripe::setApiKey('"STRIPE_SECRET_TOKEN"');

$session = StripeCheckoutSession::create([
'line_items' => [[
  'price_data' => [
    'currency' => 'mxn',
    'product_data' => [
      'name' => 'T-shirt',
      'name' => 'Pantalon',
    ],
    'unit_amount' => 2000,
    'unit_amount' => 3000,
  ],
  'quantity' => 1,
]],
'mode' => 'payment',
'success_url' => 'https://example.com/success',
'cancel_url' => 'https://example.com/cancel',
]);

@endphp

<html>
<head>
<title>Test</title>
</head>
<body>
<button id="checkout-button" type="button">Pagar</button>

<script src="https://js.stripe.com/v3/"></script>
<script>

    const stripe = Stripe("'STRIPE_PUBLIC_TOKEN'"); //Your Publishable key.
    const btn = document.getElementById('checkout-button');

    btn.addEventListener("click", function()
    {
        console.log('access');
        stripe.redirectToCheckout({ sessionId: "{{ $session->id }}" });
        console.log('exit');
    });

</script>
</body>
</html>
 
PREVIOUS NEXT
Tagged: #Stripe #Test #Laravel
ADD COMMENT
Topic
Name
1+9 =