Processing the Payment

A secure, signed JSON Web Token (JWT) is generated when the cardholder selects the Submit button on your payment form.

To receive a secure and signed JWT and complete the payment on your backend:

1

Call the ClearentSDK.getPaymentToken method.

ClearentSDK.getPaymentToken();
2

Add Promises to receive the success or error message from the ClearentSDK.getPaymentToken() function.

ClearentSDK.getPaymentToken().then(
    (result) => {
        // this function is called if getting a payment token was successful
        console.log("ClearentTokenSuccess");
        console.log(result);
    },
    (error) => {
        // this function is called if getting a payment token failed
        console.log("ClearentTokenError");
        console.log(error);
    }
);
3

Call the JWT service using the ClearentTokenSuccess function to receive the secure, signed, and unencrypted JSON Web Token in the JWT field shown below.

{
   "code":"200",
   "status":"success",
   "exchange-id":"ID-clearent-mobile-jwt-1-c32bfe39-d454-4e34-8b4f-94d850643e48",
   "payload":{
      "mobile-jwt":{
         "jwt":"eyJhbGciOi23UzIh4iJ9.eyJsYXN0LWZvdXIiOiIxMrkP8iwid
                HlwZSI6Ik1BTlVBTCIsImV4cCI6MTU0NzY0NjU2MSwidG9rZW4iOiIxMTAwMDAw
                MDAwMDEzNTkyIn0.eT8c_5yUzxCxL2MEtmbG444eTFRW7OxzRF7x4uRIo-U",
         "last-four":"1111"
      },
      "payloadType":"mobile-jwt"
   }
}
4

Call to the clearent-mobile-gateway from your backend using the mobilejwt field and api-key.

POST /rest/v2/mobile/transactions/sale
Accept:application/json
Content-Type:application/json
api-key:YOUR_API_KEY_GOES_HERE
mobilejwt:eyJhbGciOi23UzIh4iJ9.eyJsYXN0LWZvdXIiOiIxMrkP8iwid
 HlwZSI6Ik1BTlVBTCIsImV4cCI6MTU0NzY0NjU2MSwidG9rZW4iOiIxMTAw
 MDAwMDAwMDEzNTkyIn0.eT8c_5yUzxCxL2MEtmbG444eTFRW7OxzRF7x4uRIo-U
Body
{
    "type": "SALE",
    "amount": "15.55",
    "software-type": "AwesomePOSSoftware",
    "software-type-version":"1"
}

You will receive the below response after successful transaction or an error response if the transaction fails.

{
    "code": "200",
    "status": "success",
    "exchange-id": "ID-clearent-mobile-gateway-1-2a6b56d3-c660-4810-95ea-9fb9a21c6634",
    "payload": {
        "transaction": {
            "amount": "15.55",
            "id": "2586119",
            "type": "SALE",
            "result": "APPROVED",
            "card": "XXXXXXXXXXXX1111",
            "csc": "999",
            "authorization-code": "TAS022",
            "batch-string-id": "938",
            "display-message": "Transaction approved",
            "result-code": "000",
            "exp-date": "1220",
            "software-type": "AwesomePOSSoftware",
            "card-type": "VISA",
            "last-four": "1111"
        },
        "payloadType": "transaction"
    }
}

Example: Decoded, unencrypted, signed JWT

Example: Decoded, unencrypted, signed JWT

Last updated

Was this helpful?