forked from stripe-samples/accept-a-payment
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-checkout-session.php
More file actions
24 lines (21 loc) · 877 Bytes
/
Copy pathcreate-checkout-session.php
File metadata and controls
24 lines (21 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
require_once 'shared.php';
// This is the root of the URL and includes the scheme. It usually looks like
// `http://localhost:4242`. This is used when constructing the fully qualified
// URL where the user will be redirected to after going through the payment
// flow.
$domain_url = $_ENV['DOMAIN'];
// Create new Checkout Session for the order
// ?session_id={CHECKOUT_SESSION_ID} means the redirect will have the session ID set as a query param
$checkout_session = $stripe->checkout->sessions->create([
'success_url' => $domain_url . '/success.php?session_id={CHECKOUT_SESSION_ID}',
'cancel_url' => $domain_url . '/canceled.html',
'mode' => 'payment',
// 'automatic_tax' => ['enabled' => true],
'line_items' => [[
'price' => $_ENV['PRICE'],
'quantity' => 1,
]]
]);
header("HTTP/1.1 303 See Other");
header("Location: " . $checkout_session->url);