I want to get transaction status from this endpoint
https://api.sandbox.midtrans.com/v2/[orderid]/status
but it needs a basic auth, when i post it on the URL the result I am getting is:
{
"status_code": "401",
"status_message": "Operation is not allowed due to unauthorized payload.",
"id": "e722750a-a400-4826-986c-ebe679e5fd94"
}
and i have a website ayokngaji.com then i want to send basic auth to get status with my url. Example:
ayokngaji.com/v2/[orderid]/status = (BASIC AUTH INCLUDED)
How do i make this?
i also tried using postman, and using basic auth it work, and show the right result
when i search it online it show me like CURL, BASIC AUTH, but i don't understand any of these tutorial because my limit on english and small knowledge on php
SOLVED:
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sandbox.midtrans.com/v2/order-101c-1581491105/status",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Accept: application/json",
"Content-Type: application/json",
"Authorization: Basic U0ItTWlkLXNl"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;