function getSign($url, $method, $nonce, $timestamp, $keyCode, $requestBody, $pem_private_key)
$data = $url.";".$method.";".$nonce.";".$timestamp.";".$keyCode.";".$requestBody;
$p = openssl_pkey_get_private($pem_private_key);
$signSuccess = openssl_sign($data, $signature, $p, OPENSSL_ALGO_SHA256);
$encodedSignature = base64_encode($signature);
return $encodedSignature;
print_r($e->getMessage());
$url = '/merchant-integration/v1/qr/gen-transaction-qr';
$nonce = (string)$timestamp;
'callback_url' => 'http://merchant-site/vinid/result',
'description' => 'test qr code',
'order_amount' => '1000',
'order_currency' => 'VND',
'order_reference_id' => 'merchant-order-id-01',
'pos_code' => 'merchant-pos-code',
'service_type' => 'PURCHASE',
'store_code' => 'merchant-store-code'
$requestBody = json_encode($params);
$apiKey = 'Your api key';
$privateKey = 'Your private key';
$sign = getSign($url, $method, $nonce, $timestamp, $apiKey, $requestBody, $privateKey);
'Accept: application/json',
'Content-Type: application/json',
'X-Timestamp: '.$timestamp,
curl_setopt($ch, CURLOPT_URL, 'https://api-merchant-sandbox.vinid.dev'.$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBody);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);