-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckout.php
35 lines (28 loc) · 905 Bytes
/
checkout.php
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
<?php
$transaction = file_get_contents('php://input');
// Change "app.sandbox.midtrans.com" to "app.midtrans.com" when you are deploying to production environment
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://app.sandbox.midtrans.com/snap/v1/transactions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $transaction,
CURLOPT_HTTPHEADER => array(
"accept: application/json",
"Authorization: Basic U0ItTWlkLXNlcnZlci1HWEJUQUg3Szc3SnAwa0tuUVZxYXZMckI6",
"cache-control: no-cache",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}