Search
 
SCRIPT & CODE EXAMPLE
 

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>
Comment

PREVIOUS NEXT
Code Example
Php :: set session expire time in php 
Php :: query builder laravel getmedia undefined method 
Php :: laravel view not created using foreign keys 
Php :: how to create header in csv file inphp 
Php :: trim string in php codeigniter 
Php :: get session token in wp_login hook 
Php :: wordpress give query a unique identity 
Php :: Replace default WP search and dropdown placeholder 
Php :: laravel collection load 
Php :: leggere file su piu righe php 
Php :: laravel project in css 
Php :: many to many relationship in laravel example stackoverflow 
Php :: Josn_encode php api encoding issue 
Php :: bar chart in js,php prt 1 
Php :: remove nul value aray php 
Php :: single elimination php code 
Php :: php cors error 
Php :: php sum 2 arrays 
Php :: Laravel To determine if an item is not present in the session 
Php :: check which device is used to open webpage php 
Php :: pcntl_fork php mysql "MySQL server has gone away" 
Php :: Call to undefined method :last() 
Php :: eloquent search from child table column 
Php :: redirect from controller to named route with prams in URL 
Php :: how to set db table type in laravel 
Php :: laravel migration example 
Php :: Dispatch, performance 
Php :: php browser cache clear 
Php :: laravel collection modelKeys 
Php :: provide filter condition in autocomplet field in drupal form using property 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =