Integration Guidelines:

The Frontpay API is organized around REST. Our API has predictable resource-oriented URLs, accepts "form-encoded" request bodies, returns "JSON-encoded" responses, and uses standard HTTP response codes,authentication, and verbs.

To integrate API you must have a secret Key whether in test mode or live mode, that can be acquired from above field.

The following GET request will generate a json web token(JWT) that will be used in authorization header for subsequent requests. e.g. replace "phone" with your actual phone.

  • curl -XGET -H "Content-type: application/json"
  • "https://dev.frontpay.pk/generateJwt?phone=+923001234567"

The response of the above API will be as follows:

{

  • "success":true,
  • "token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InBob25lIjoiMDMwMDEyMzQ1NjEifSwiaWF0IjoxNjEyOTM4OTg2LCJleHAiOjE2MTM1NDM3ODZ9. YYtQ7ZQtSV7By-3WynprRe0S_a56jmJjUnzkiGfSZeY",
  • "createdAt":"2021-02-10T06:36:26.122Z",
  • "expiresAt":"2021-02-17T06:36:26.122Z"

}

The json web token will valid for 7 days after that you have to get new token by this API.

Card validation

The following POST request will validate a customer card from our payment gateway.Replace "secretKey" with your actual secret Key.

pass jWT token in authorization header.Mode can be test or live.

  • curl -XPOST -H 'Authorization: Bearer your token'
  • -H "Content-type: application/json"
  • -d '{ "cardNumber" : "4242424242424242","expiryYear" : "2022","expiryMonth" : "2","cvc" : "314","secretKey" : "CMZFW7UmmU8rnYuISTSgyZ7I1612779810088","mode" : "test" }'
  • 'https://dev.frontpay.pk/merchant/validateCard'

The response of the above API will be as follows:

{

  • "success":false,
  • "message":"card validation successful",
  • "data":"tok_1IJHCIKpmTOdJunwR274dzYd"

}

After successful card validation the API will return a token which will be used in payment API to charge a customer.

Charge a customer

The following POST request will charge a customer by pass the token get from validate card API in source param.Replace "secretKey" with your actual secret Key.

  • curl -XPOST -H 'Authorization: Bearer your token'
  • -H "Content-type: application/json"
  • -d '{ "amount" : "420","currency" : "pkr","source" : "tok_1IIotxKpmTOdJunwBoNTVlXM","description" : "payment description","secretKey" : "CMZFW7UmmU8rnYuISTSgyZ7I1612779810088","mode" : "test" }'
  • 'https://dev.frontpay.pk/merchant/createCharge'

The response of the above API will be as follows:

{

  • "success":true,
  • "message":"payment successful"

}

Integration Guidelines:

The Frontpay API is organized around REST. Our API has predictable resource-oriented URLs, accepts "form-encoded" request bodies, returns "JSON-encoded" responses, and uses standard HTTP response codes,authentication, and verbs.

To integrate API you must have a secret Key whether in test mode or live mode, that can be acquired from above field.

The following GET request will generate a json web token(JWT) that will be used in authorization header for subsequent requests. e.g. replace "phone" with your actual phone.

  • curl -XGET -H "Content-type: application/json"
  • "https://dev.frontpay.pk/generateJwt?phone=+923001234567"

The response of the above API will be as follows:

{

  • "success":true,
  • "token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InBob25lIjoiMDMwMDEyMzQ1NjEifSwiaWF0IjoxNjEyOTM4OTg2LCJleHAiOjE2MTM1NDM3ODZ9. YYtQ7ZQtSV7By-3WynprRe0S_a56jmJjUnzkiGfSZeY",
  • "createdAt":"2021-02-10T06:36:26.122Z",
  • "expiresAt":"2021-02-17T06:36:26.122Z"

}

The json web token will valid for 7 days after that you have to get new token by this API.

Card validation

The following POST request will validate a customer card from our payment gateway.Replace "secretKey" with your actual secret Key.

pass jWT token in authorization header.Mode can be test or live.

  • curl -XPOST -H 'Authorization: Bearer your token'
  • -H "Content-type: application/json"
  • -d '{ "cardNumber" : "4242424242424242","expiryYear" : "2022","expiryMonth" : "2","cvc" : "314","secretKey" : "CMZFW7UmmU8rnYuISTSgyZ7I1612779810088","mode" : "live" }'
  • 'https://dev.frontpay.pk/merchant/validateCard'

The response of the above API will be as follows:

{

  • "success":false,
  • "message":"card validation successful",
  • "data":"tok_1IJHCIKpmTOdJunwR274dzYd"

}

After successful card validation the API will return a token which will be used in payment API to charge a customer.

Charge a customer

The following POST request will charge a customer by pass the token get from validate card API in source param.Replace "secretKey" with your actual secret Key.

  • curl -XPOST -H 'Authorization: Bearer your token'
  • -H "Content-type: application/json"
  • -d '{ "amount" : "420","currency" : "pkr","source" : "tok_1IIotxKpmTOdJunwBoNTVlXM","description" : "payment description","secretKey" : "CMZFW7UmmU8rnYuISTSgyZ7I1612779810088","mode" : "live" }'
  • 'https://dev.frontpay.pk/merchant/createCharge'

The response of the above API will be as follows:

{

  • "success":true,
  • "message":"payment successful"

}

Your account is not live yet click below to submit requirements to make your account live.

Go Live