QR

Generate Purchase QR

After scanning MonPay user QR using QR scanner equipment, merchant’s sales system should call “Generate purchase QR” function while providing user’s QR value with other parameters such as transaction amount. After this request has been called, MonPay application will display an invoice to the user automatically so that users can pay.

                
$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://wallet.monpay.mn/rest/branch/qrpurchase/generate');
$request->setRequestMethod('POST');

$body = new http\Message\Body;
$body->append('{
  "amount": 1000,
  "displayName": "MobiCom",
  "generateUuid": true,
  "userPresentedQr": "qr"
}');

$request->setBody($body);
$request->setOptions(array());
$request->setHeaders(array(
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' => 'Basic {Basic auth combination of Your branch username and MonPay account id}'
));

$client->enqueue($request)->send();

$response = $client->getResponse();
echo $response->getBody();
                
            
                
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");

RequestBody body = RequestBody.create(mediaType, "{
    "amount": 1000,
    "displayName": "MobiCom",
    "generateUuid": true,
    "userPresentedQr": "qr"
}");

Request request = new Request.Builder()
  .url("https://wallet.monpay.mn/rest/branch/qrpurchase/generate")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Accept", "application/json")
  .addHeader("Authorization", "Basic {Basic auth combination of Your branch username and MonPay account id}")
  .build();

Response response = client.newCall(request).execute();
                
            
Header
Method POST
URL https://wallet.monpay.mn/rest/branch/qrpurchase/generate
Authorization User: {branchusername}
 Password: {account id}
branchusername – Your unique username to enter merchant website which is provided from Mobifinance. AccountId – Your MonPay merchant account ID. Ask Mobifinance
Content-Type application/json
Accept application/json
Request
Parameters Type Required Description
amount double No Amount to charge user. Can be either fixed amount or varying (by not providing amount parameter)
generateUuid boolean No If set to true then api will return unique “uuid”. QR codes with uuid can be used only once & there’s also expire time. Client application can check whether this QR code is scanned or not by providing “uuid” back by calling check api. If it’s not set then generated QR code can be used multiple times & there’s no expire time. But client applications can’t check sale status.
userPresentedQr string Yes User QR
displayName string No Display name to show (if not provided then merchant username will be used)
Response
Parameters Type Description
code integer Code determines if request was successful or not
info string Description
result qrcode string Generated QR code
uuid string Check uuid
Response type
Http Status Code Description
200 0 Successful
400 5 Bad request
401 1 Unauthorized
500 999 Internal error