Last active
October 15, 2023 15:11
-
-
Save maythiwat/b6a591caad60c657a1c0c3295516d0d2 to your computer and use it in GitHub Desktop.
RDCW Slip Verify - PHP cURL Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Inquire Transfer Slip validity and details | |
* | |
* @param string $clientId Application Client ID | |
* @param string $clientSecret Application Client Secret | |
* @param string $payload Payload String from QR Code | |
* | |
* @return object|null Returns validity and details on successful, or null on failure | |
*/ | |
function suba_inquiry($clientId, $clientSecret, $payload) { | |
$ch = curl_init('https://suba.rdcw.co.th/v1/inquiry'); | |
curl_setopt($ch, CURLOPT_USERPWD, "{$clientId}:{$clientSecret}"); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['payload' => $payload])); | |
curl_setopt($ch, CURLOPT_ENCODING, ''); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$response = @json_decode(curl_exec($ch)); | |
curl_close($ch); | |
if ($response && isset($response->valid)) { | |
return $response; | |
} | |
return null; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment