alpha_full/pages/panier/lyra/modePaie.formLyra.appel.php
2026-04-06 22:58:51 +02:00

83 lines
3.1 KiB
PHP
Executable File

<?php
$nomFicAppelant = basename(__FILE__);
require_once 'vendor/autoload.php';
$token='Basic Njk4NzYzNTc6dGVzdHBhc3N3b3JkX0RFTU9QUklWQVRFS0VZMjNHNDQ3NXpYWlEyVUE1eDdN';
/* Username, password and endpoint used for server to server web-service calls */
// Lyra\Client::setDefaultUsername($customer_id);
Lyra\Client::setDefaultUsername("69876357");
Lyra\Client::setDefaultPassword("testpassword_DEMOPRIVATEKEY23G4475zXZQ2UA5x7M");
Lyra\Client::setDefaultEndpoint("https://api.lyra.com");
/* publicKey and used by the javascript client */
Lyra\Client::setDefaultPublicKey("69876357:testpublickey_DEMOPUBLICKEY95me92597fd28tGD4r5");
/* SHA256 key */
Lyra\Client::setDefaultSHA256Key("38453613e7f44dc58732bad3dca2bca3");
// // ---------------------------------------------------
// // Flag edt : ajouter le code language dans la table pour pouvoir boucler dessus
// // ---------------------------------------------------
// if ($lg=="ENG") {$language="en";}
// else {$language="fr";}
// $postdata = array(
// 'amount' => $amount,
// 'currency' => "EUR",
// 'paymentForms' => array(
// "paymentMethodType" => "CARD",
// "pan" => "4970100000000055",
// "expiryMonth" => "11",
// "expiryYear" => "21",
// "securityCode" => "123"
// )
// );
// $ch = curl_init();
// curl_setopt($ch, CURLOPT_URL, "https://api.lyra.com/api-payment/V4/Charge/CreatePayment");
// curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
// curl_setopt($ch, CURLOPT_POST, 1);
// curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postdata));
// curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json', 'Authorization: Bearer ' . $token));
// $response = curl_exec($ch);
// if (isset($debug[1]) && $debug[1] == '1' ) $debugMsg .=$response;
// curl_close($ch);
// ---------------------------------------------------
// I initialize the PHP SDK
// ---------------------------------------------------
// require_once 'vendor/autoload.php';
// require_once __DIR__ . '/keys.php';
// require_once __DIR__ . '/helpers.php';
// ---------------------------------------------------
// Initialize the SDK
// see keys.php
$client = new Lyra\Client();
// ---------------------------------------------------
// I create a formToken
// ---------------------------------------------------
$store = array("amount" => 250,
"currency" => "EUR",
// "orderId" => uniqid("MyOrderId"),
"customer" => array(
"email" => $idMail
));
$response = $client->post("V4/Charge/CreatePayment", $store);
/* I check if there are some errors */
if ($response['status'] != 'SUCCESS') {
/* an error occurs, I throw an exception */
display_error($response);
$error = $response['answer'];
throw new Exception("error " . $error['errorCode'] . ": " . $error['errorMessage'] );
}
if (isset($debug[1]) && $debug[1] == '1' ) $debugMsg .='response = <br>' .$response;
/* everything is fine, I extract the formToken */
$formToken = $response["answer"]["formToken"];
// $client = $response["answer"]["customer"];
if (isset($debug[1]) && $debug[1] == '1' ) $debugMsg .='FormToken = <br>' .$formToken;
?>