-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathcreateSilentPay.php
More file actions
54 lines (45 loc) · 1.37 KB
/
createSilentPay.php
File metadata and controls
54 lines (45 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
/**
* I initialize the PHP SDK
*/
require_once __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/keys.php';
require_once __DIR__ . '/helpers.php';
/**
* Initialize the SDK
* see keys.php
*/
$client = new Lyra\Client();
$total = number_format($total_final, 2, '', '');
$token = $payToken;
//$total = $total . 0000;
if (isset($_GET['requestObject'])) {
$store = json_decode($_GET['requestObject']);
} else {
$store = array( "amount" => $total,
"currency" => "ARS",
"paymentMethodToken"=> $token,
"formAction" => "SILENT",
"transactionOptions"=> array(
"cardOptions"=> array("installmentNumber"=> $silent_cuotas)
)
);
}
//print_r($store);
/**
* I create a formToken
*/
$responseSlient = $client->post("V4/Charge/CreatePayment", $store);
//* I check if there are some errors */
if ($responseSlient['status'] != 'SUCCESS') {
/* an error occurs */
$error = $responseSlient['answer'];
header("Content-Type", "application/json");
header('HTTP/1.1 500 Internal Server Error');
echo '{"error": "' . $error['errorCode'] . '", "_type": "DemoError" }';
die();
}
/* everything is fine, I extract the formToken */
$Token = $responseSlient["answer"]["paymentMethodToken"];
//header("Content-Type", "application/json");
//echo '{"formToken": "' . $formToken . '"", "_type": "DemoFormToken" }';