Payment Integrations

How To Make Charge In Clearent Using JWT Card Token And How To Use Existing Card

Introduction

In this article, we will learn how to implement a clearent payment gateway with a JWT Credit card token using jquery. You can use this token as a card in your Sale refund and other APIs.

And also we learn how to use existing cards for sale and other APIs Integrators may use the JavaScript SDK to incorporate payments into their websites smoothly. Iframes are used by Clearent’s JavaScript SDK to include PCI security compliance best practices for e-commerce sites.

You can learn how to use Clearent Javascript SDK and how to generate JWT Card Token from Here

we are going to learn how to use this token and use the existing cards in the future without generating tokens again.

Let’s begin.

Here we use postman for API calls

Step 1: Get Your Card JWT Token From  Javascript SDK

Step 2: Now open Your postman

  • Set Type POST
  • Enter your clearent mobile sale API : https://gateway-sb.clearent.net/rest/v2/mobile/transactions/sale
  • Now click on “Header” and new key :
  •        
  • Now click on body and add your JSON data for payment and add body type JSON
    • Data :
      {
          "type": "SALE",
          "amount": "99",
          "software-type": "AwesomePOSSoftware",
          "software-type-version":"1",
          "create-token":"true"
      }

Now Click on Send 

And you get responses that look like this :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<response>
    <code>402</code>
    <status>fail</status>
    <exchange-id>ID-clearent-mobile-jwt-1-c166602b-2347-47c5-bc7a-779f0dc7681c</exchange-id>
    <links>
        <rel>transaction</rel>
        <href>/rest/v2/transactions?id=114974209</href>
        <id>114974209</id>
    </links>
    <links>
        <rel>token</rel>
        <href>/rest/v2/tokens/{Here is your card Token}</href>
        <id>{Here is your card Token}</id>
    </links>
    <payload type="errorTransaction">
        <transaction>
            <amount>0.01</amount>
            <id>114974209</id>
            <type>SALE</type>
            <result>DECLINED_BY_ISSUER_REFERRED_PLEASE_CALL_CARD_ISSUER</result>
            <display-message>Declined by Issuer -Referred - Please call Card Issuer</display-message>
            <result-code>007</result-code>
            <card>XXXXXXXXXXXX1111</card>
            <exp-date>0226</exp-date>
            <csc>999</csc>
            <software-type>AwesomePOSSoftware</software-type>
            <card-type>VISA</card-type>
            <last-four>1111</last-four>
            <merchant-id>{here is your merchant-id}</merchant-id>
            <terminal-id>10011113</terminal-id>
        </transaction>
        <error>
            <error-message>DECLINED_BY_ISSUER_REFERRED_PLEASE_CALL_CARD_ISSUER , DECLINED_BY_ISSUER_REFERRED_PLEASE_CALL_CARD_ISSUER</error-message>
            <result-code>007</result-code>
        </error>
    </payload>
</response>

Here you can find your following key and tokens:

  1. Transaction Key
  2. New Card Token
  3. Your Card details

That’s it you can make payment with your JWT token without giving your card details

But there is one problem JWT token is not valid for the second time you can not use this JWt token for future payment. Token will be invalid in some time.

So you can use the token that you get from the response save this token in your database and you can use that token in future payment

But using this token you can not use this API : https://gateway-sb.clearent.net/rest/v2/mobile/transactions/sale

To use the existing  card(Token) you need to use this API : https://gateway-sb.clearent.net/rest/v2/transactions/sale

Use Existing Token for Payment

Open Postman and add AIP : https://gateway-sb.clearent.net/rest/v2/transactions/sale

for this time add Your API key in the header and in this API you can not pass your Any JWT token

Now Add Body 

  • In body set type: SALE
  • Set Amount
  • set software-Type: Any Name
  • set software-type-virsion:1
  • here we already have a card token so make “create-token”: false
  • And in header set “accept”: application/JSON

Like This :


Now Click on send and you got a response that look like this :

{
    "code": "200",
    "status": "success",
    "exchange-id": "ID-clearent-cgw-2-1643310635949-0-16898478",
    "links": [
        {
            "rel": "transaction",
            "href": "/rest/v2/transactions?id=114974234",
            "id": "114974234"
        }
    ],
    "payload": {
        "transaction": {
            "amount": "25.55",
            "id": "114974234",
            "type": "SALE",
            "result": "APPROVED",
            "card": "XXXXXXXXXXXX1111",
            "authorization-code": "TAS393",
            "batch-string-id": "38",
            "display-message": "Transaction approved",
            "result-code": "000",
            "exp-date": "0226",
            "software-type": "AwesomePOSSoftware",
            "card-type": "VISA",
            "last-four": "1111",
            "merchant-id": "943250857867",
            "terminal-id": "10011113"
        },
        "payloadType": "transactionToken",
        "tokenResponse": {
            "token-id": "{Card Token}",
            "times-used": "1",
            "status": "Active",
            "created": "2022-02-12T06:28:30.946Z",
            "updated": "2022-02-12T06:28:30.968Z",
            "exp-date": "0226",
            "last-four-digits": "1111",
            "card-type": "VISA",
            "merchant-id": "943250857867",
            "token-status": "Open"
        }
    }
}

That’s it.

Here we learn how to use JWT Card tokens and make payments and generate cards is for future payment

You cannot use the JWT token in the future because this token is valid for some time and you can not use it after that

So we generate a card ID with the use of JWTmobile sale API and in response and we can store this token in DB, also you can use this token any time in the future for payment.

In short, you can use this token as an existing card for customers and make Transactions.

Umang Ramani

Recent Posts

Testing hk

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Operation

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

TETS NEW

test

2 years ago