mirror of
https://github.com/itflow-org/itflow
synced 2026-02-28 02:44:53 +00:00
Added selectable num of records on each listing page, fixed up Pagination Records UI, added new stripe library, further worked on stripe integration, fixed mispelling in client details
This commit is contained in:
42
create.php
Normal file
42
create.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
include("config.php");
|
||||
include("check_login.php");
|
||||
include("functions.php");
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
||||
require 'vendor/stripe-php-7.72.0/init.php';
|
||||
|
||||
// This is your real test secret API key.
|
||||
\Stripe\Stripe::setApiKey("$config_stripe_secret");
|
||||
|
||||
|
||||
function calculateOrderAmount(array $items): int {
|
||||
// Replace this constant with a calculation of the order's amount
|
||||
// Calculate the order total on the server to prevent
|
||||
// customers from directly manipulating the amount on the client
|
||||
return 1400;
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
try {
|
||||
// retrieve JSON from POST body
|
||||
$json_str = file_get_contents('php://input');
|
||||
$json_obj = json_decode($json_str);
|
||||
|
||||
$paymentIntent = \Stripe\PaymentIntent::create([
|
||||
'amount' => calculateOrderAmount($json_obj->items),
|
||||
'currency' => 'usd',
|
||||
]);
|
||||
|
||||
$output = [
|
||||
'clientSecret' => $paymentIntent->client_secret,
|
||||
];
|
||||
|
||||
echo json_encode($output);
|
||||
} catch (Error $e) {
|
||||
http_response_code(500);
|
||||
echo json_encode(['error' => $e->getMessage()]);
|
||||
}
|
||||
Reference in New Issue
Block a user