Skip to content

Instantly share code, notes, and snippets.

@maythiwat
Last active July 10, 2025 17:35
Show Gist options
  • Select an option

  • Save maythiwat/b6a591caad60c657a1c0c3295516d0d2 to your computer and use it in GitHub Desktop.

Select an option

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;
}
?>
<?php
$clientId = '';
$clientSecret = '';
?>
<h4>Slip Verify Image Upload API Example</h4>
<form method="POST" action="" enctype="multipart/form-data">
<label for="slip_image">Slip Image: </label>
<input type="file" accept="image/*" name="slip_image" id="slip_image" required />
<button type="submit">Verify</button>
</form>
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$ch = curl_init('https://suba.rdcw.co.th/v2/inquiry');
curl_setopt($ch, CURLOPT_USERPWD, "{$clientId}:{$clientSecret}");
curl_setopt($ch, CURLOPT_POSTFIELDS, [
'file' => new CURLFile(
$_FILES['slip_image']['tmp_name'],
$_FILES['slip_image']['type']
)
]);
curl_setopt($ch, CURLOPT_ENCODING, '');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = @json_decode(curl_exec($ch));
curl_close($ch);
if ($response && $response->valid) {
echo '<p style="color: green;">This slip is valid!!</p>';
}
echo '<pre>';
print_r($response);
echo '</pre>';
// TODO: Do something with this data.
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment