Skip to content

Instantly share code, notes, and snippets.

@maythiwat
Last active October 15, 2023 15:11
Show Gist options
  • Save maythiwat/b6a591caad60c657a1c0c3295516d0d2 to your computer and use it in GitHub Desktop.
Save maythiwat/b6a591caad60c657a1c0c3295516d0d2 to your computer and use it in GitHub Desktop.
RDCW Slip Verify - PHP cURL Example
<?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