Sid Gifari From Gifari Industries - BD Cyber Security Team
Home
/
home
/
airmobeuag
/
2020
/
lpf
/
✏️
Editing: stripe.php
<?php require 'vendor/autoload.php'; // This is a sample test API key. Sign in to see examples pre-filled with your key. \Stripe\Stripe::setApiKey('sk_test_wtOLZRJRmrRm5va5cDWUKeNl'); 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 $items[0]['montant']; } header('Content-Type: application/json'); try { // retrieve JSON from POST body $json_str = file_get_contents('php://input'); $json_obj = json_decode($json_str); $Arr = json_decode($json_str,TRUE); $paymentIntent = \Stripe\PaymentIntent::create([ 'amount' => ($Arr['items']['0']['montant']), 'currency' => 'eur', 'metadata' => ['NoBDC' => $Arr['items']['0']['nobdc'],'code_promo'=>'C0001'], ]); $output = [ 'clientSecret' => $paymentIntent->client_secret, ]; echo json_encode($output); } catch (Error $e) { http_response_code(500); echo json_encode(['error' => $e->getMessage()]); }
💾 Save
❌ Cancel