59 lines
1.4 KiB
PHP
59 lines
1.4 KiB
PHP
<?php
|
|
$incoming=file_get_contents("php://input");
|
|
$details=json_decode($incoming,true);
|
|
|
|
$invoiceNumber=$details['invoiceNumber'];
|
|
$token=$details['token'];
|
|
|
|
|
|
$baseURL="https://devpayouts.tnmmpamba.co.mw/api";
|
|
|
|
//$res=authenticate($baseURL, $wallet, $password);
|
|
$bearerToken="102164|newoEd6QOFaTptUiGAp232jULtUmgMtaX1x2CRww4Ka2270dc49";
|
|
|
|
|
|
|
|
|
|
$res=checkInvoiceStatus($invoiceNumber, $bearerToken, $baseURL);
|
|
echo (print_r($res,true));
|
|
|
|
function checkInvoiceStatus($invoiceNumber, $bearerToken, $baseURL) {
|
|
// Build request URL
|
|
$url = rtrim($baseURL, '/') . "/invoices/" . urlencode($invoiceNumber);
|
|
|
|
// Initialize cURL
|
|
$ch = curl_init();
|
|
|
|
curl_setopt_array($ch, [
|
|
CURLOPT_URL => $url,
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_HTTPHEADER => [
|
|
"Authorization: Bearer " . $bearerToken,
|
|
"Accept: application/json"
|
|
]
|
|
]);
|
|
|
|
// Execute the request
|
|
$response = curl_exec($ch);
|
|
|
|
// Handle errors
|
|
if (curl_errno($ch)) {
|
|
echo "cURL Error: " . curl_error($ch);
|
|
curl_close($ch);
|
|
return null;
|
|
}
|
|
|
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
curl_close($ch);
|
|
|
|
// Check for successful response
|
|
if ($httpCode === 200 && $response) {
|
|
return json_decode($response, true);
|
|
} else {
|
|
echo "Request failed. HTTP Code: " . $httpCode . "\nResponse: " . $response;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
?>
|