Create Fiat Checkout Order
3 min
This API creates a payin order to enable users to make checkout transactions. It accepts amount and currency details. On creating an order a dynamic token is returned from this api which is required to be passed to Pay3 SDK
This api requires access token that can be generated using Access TokenAccess Token API.
Create Checkout Order
Create an order with payin details from application's backend
POST
https://your-hostname.pay3.app/v1/client/checkout/create-order
curl --location 'https://api.prod.pay3.app/v1/client/checkout/create-order' \
--header 'signature: {{signature}}' \
--header 'access-token: eyJraWQiOiIxYmI5NjA1YzM2ZVRCWkJMOHllMDRmcjBkcEo2OTM4NjgzMDIwMmIyZCIsInR5cCI6IkpXVCIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiIxY2VjOGM3YS1kNjMzLTQzMDUtYmJkZi00N2M3ZWJlYWU1YmEiLCJpc3MiOiJodHRwczovL3M4ZXFtbWE5ZDguZXhlY3V0ZS1hcGkudXMtZWFzdC0xLmFtYXpvbmF3cy5jb20vcHJvZC92MS91c2VyLW1hbmFnZW1lbnQvLndlbGwta25vd24vandrcy5qc29uIiwiaWF0IjoxNzU2NDU2MTgxLCJleHAiOjE3NTY0NTc5ODF9.mzRmTnht4TsGUQpV5P_QfNdlODyq12ootG_hmb5NelsfpOjIiPMk2xz9rrIqtvQG3uVxvZXdRl5VjKsi9HbIkcaj543fUBjTEsumFnYGaVbbRXCVki_TUanWYZPi4GCJs7JD7VA35AfWbiEC0spYGn9quxhyiEHu9n5u0_05kf11GeDa99HNCHGSxKxYY0aOFGWcdoietZIGHIZjQqERzMnmR8ehuSzzt7_ulD2Vrpj8oowRvDbHLboKICKalNQUzgROTWUQRPFmRRb5yREpiCFfjEyuJzjtEwuNqh5M2oEGZwuTBzaXOSdZda7uhMp7hFh5lm5WhVMz6HR_k8GNdw' \
--header 'Content-Type: application/json' \
--data-raw '{
"currencyId": "usd_usa",
"fiatAmount": "10.00",
"paymentMethodId": "all",
"email": "[email protected]",
"clientId": "4894a422-1209-4371-9961-7e60008ec3e1",
"requestId": "889938983",
"mode": "returnUrl",
"callbackUrl": "https://www.google.com"
}'
Signature Generation
The request for creating checkout order requires a header signature. This can be generated using following code snippet.
const crypto = require('crypto');
// Required Parameters
const secretKey="Api-Secret-Provided-By-Pay3";
const fiatAmount = "0.02";
const requestId = "Order-Id-Generated-By-Application";
const clientId = "your-client-id";
const accessToken = "dynamic-access-token";
const getSignature = (secretKey, fiatAmount, requestId) => {
// Prepare the string to sign in same format.
// fiatAmount followed by requestId
const stringToSign = 'fiatAmount=' + fiatAmount + '&requestId=' + requestId;
// Generating signature using SHA256 and provided secret and
// base64 encode the result
const mac = crypto.createHmac('sha256', secretKey);
return mac.update(stringToSign).digest('base64');
}
// Generate Signature
const signature = getSignature(secretKey, fiatAmount, requestId);import javax.crypto.Mac
import javax.crypto.spec.SecretKeySpec
class Signature {
fun getPay3Signature(secretKey: String, requestId: String, fiatAmount: String, currencyId: String): String {
return try {
val stringToSign = "currencyId=$currencyId&fiatAmount=$fiatAmount&requestId=$requestId"
val mac = Mac.getInstance("HmacSHA256")
val secretKeySpec = SecretKeySpec(secretKey.toByteArray(), "HmacSHA256")
mac.init(secretKeySpec)
val hash = mac.doFinal(stringToSign.toByteArray(Charsets.UTF_8))
Base64.getEncoder().encodeToString(hash)
} catch (e: Exception) {
throw RuntimeException("Error generating signature", e)
}
}
}const crypto = require('crypto');
// Required Parameters
const secretKey="Api-Secret-Provided-By-Pay3";
const fiatAmount = "0.02";
const requestId = "Order-Id-Generated-By-Application";
const clientId = "your-client-id";
const accessToken = "dynamic-access-token";
const getSignature = (secretKey, fiatAmount, requestId) => {
// Prepare the string to sign in same format.
// fiatAmount followed by requestId
const stringToSign = 'fiatAmount=' + fiatAmount + '&requestId=' + requestId;
// Generating signature using SHA256 and provided secret and
// base64 encode the result
const mac = crypto.createHmac('sha256', secretKey);
return mac.update(stringToSign).digest('base64');
}
// Generate Signature
const signature = getSignature(secretKey, fiatAmount, requestId);