Sid Gifari From Gifari Industries - BD Cyber Security Team
Home
/
home
/
airmobeuag
/
2020
/
commande_v2
/
✏️
Editing: stripe.php
<?php require 'vendor/autoload.php'; // CODE:STRIPE //\Stripe\Stripe::setApiKey('sk_test_wtOLZRJRmrRm5va5cDWUKeNl'); \Stripe\Stripe::setApiKey('sk_live_jmMEEsrBrru0qcmySOPhViz1'); 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); $customer = \Stripe\Customer::create(['description'=>$Arr['items']['0']['nobdc']]); $paymentIntent = \Stripe\PaymentIntent::create([ 'amount' => ($Arr['items']['0']['montant']), 'currency' => 'eur', 'description'=>$Arr['items']['0']['nobdc'], 'customer' => $customer->id, 'setup_future_usage' => 'off_session', 'metadata' => ['NoBDC' => $Arr['items']['0']['nobdc'],'code_promo'=>'C0001'], ]); $output = [ 'clientSecret' => $paymentIntent->client_secret, 'idc'=>$customer->id, ]; echo json_encode($output); } catch (Error $e) { http_response_code(500); echo json_encode(['error' => $e->getMessage()]); }
💾 Save
❌ Cancel