File "create-checkout-session.php"
Full path: /home/meharicl/www/stripe/create-checkout-session.php
File size: 2.28 KiB (2331 bytes)
MIME-type: text/x-php
Charset: utf-8
<?php
require_once( 'init.php');
//require 'vendor/autoload.php';
// This is your test secret API key.
//\Stripe\Stripe::setApiKey('sk_test_51LEbcLLqWcRLwQnHxyMdpdYFHrujkd41Dp7n3AvYZkikTSBYZltb5V6zAQPQ2QAMBraCJdsCMnYpxIMfHx8ohOtD00Ryt1RO6F');
\Stripe\Stripe::setApiKey('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');
//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
header('Content-Type: application/json');
$YOUR_DOMAIN = 'https://www.mehariclubdefrance.com/stripe/public';
/*$checkout_session = \Stripe\Checkout\Session::create([
'payment_method_types' => ['card'],
'line_items' => [
[
'name' => 'T-shirt',
'description' => 'Cotisation 2023',
//'images' => ['https://example.com/t-shirt.png'],
'amount' => 110,
'currency' => 'eur',
//'price' => $price->id,
'quantity' => 1,
],
[
'name' => 'T-shirt',
'description' => 'Cotisation 2023',
//'images' => ['https://example.com/t-shirt.png'],
'amount' => 51,
'currency' => 'eur',
//'price' => $price->id,
'quantity' => 2,
],
],
'mode' => 'payment',
'success_url' => $YOUR_DOMAIN . '/success.html?session_id=12345',
'cancel_url' => $YOUR_DOMAIN . '/cancel.html',
]);
*/
$origine=[
'payment_method_types' => ['card'],
'line_items' => [
[
'name' => 'T-shirt',
'amount' => 110,
'currency' => 'eur',
'quantity' => 3,
],
[
'name' => 'T-shirt',
'amount' => 51,
'currency' => 'eur',
'quantity' => 2,
],
[
'name' => 'Chemise',
'amount' => 101,
'currency' => 'eur',
'quantity' => 2,
],
],
'mode' => 'payment',
'success_url' => $YOUR_DOMAIN . '/success.html?session_id=12345',
'cancel_url' => $YOUR_DOMAIN . '/cancel.html',
];
unset($origine['line_items'][1]);
unset($origine['line_items'][2]);
$checkout_session = \Stripe\Checkout\Session::create($origine);
//echo('**************************************<br>');
//var_dump($origine);
//var_dump($origine['line_items'][1]["quantity"]);
//var_dump($origine);
/*
//var_dump($checkout_session );
$ligne= $origine['line_items'] ;
$ligne=$ligne[1];
$q=$ligne['quantity'];
var_dump($q); */
header("HTTP/1.1 303 See Other");
header("Location: " . $checkout_session->url);