Postman

Using Postman to test the API

Using ICEPAY’s Postman collection you can start testing the ICEPAY API in minutes! We have created a set of API calls that automate calculation of the necessary checksums. With the help of Postman you can investigate how our API works and use that knowledge in building your own integration.


Prerequisites:


There are basically three steps to start running:

  1. Get credentials on the ICEPAY Test environment
  2. Download the ICEPAY Postman collection
  3. Enter the proper variables in the Postman environment

Getting credentials for Test environment

To get credentials for the ICEPAY Test environment you can visit the self signup page. After completing the form, and then activating your account by clicking the link in the confirmation email, you can login to the portal.

On the Contract Profiles page you can click on “Create Contract Profile”. A new Contract Profile will be created for you (you may need to refresh the page to see it). Take note of the Contract Profile Id (click on the # in the list of Contract Profiles) and the Secret (click on Get Secret).


Downloading the ICEPAY Postman collection

You can download the collection here. Click on “Run in Postman” in the top right corner and select “Postman for Windows” (or Mac/Linux). Unfortunately our Postman collection will not work in Postman for Web.

In Postman you will notice a new collection named “ICEPAY Contracts”. Also note that a new environment has been added: “Test Environment”.


Setting up Postman

It is now time to set the proper values in the Postman environment. Start by selecting the “Test Environment” in the top right corner of Postman and clicking on the Quick Look button.

Setup values for:

  • UserId – use the value for Contract Profile Id retrieved from the Contract Profiles list in the Test Portal
  • UserSecret – use the secret retrieved from the Contract Profiles list in the Test Portal
  • Postback_CompletedUrl – use any URL that can receive redirects, like beeceptor or webhook.site
  • Postback_ErrorUrl- use any URL that can receive redirects, like beeceptor or webhook.site
  • Postback_NotificationUrl – use any URL that can receive postbacks and is reachable on the internet, like beeceptor or webhook.site

Start running

You can now start running requests. Just ensure the environment “Test Environment” is selected. Also note that for some requests there is a necessary order, for example in the folder Transactions\iDeal\Refund you must first execute the request for Transaction and then execute the request for Refund. To ensure an iDeal transaction is successful, you should manually visit the acquirerRequestUri from the response in a browser.

If you use a site like beeceptor or webhook.site ,you can observe the postbacks and redirects on that site.


How does it work?

The requests in our Postman collection work through scripting in the Pre-request Script. The main challenge is to calculate the Checksum. We use the following lines of script.

eval(pm.environment.get("common_functions"));

This loads the common_functions, which is a number javascript functions in the environment variables. It also ensures new values are generated for “reference” and “requestTimeStamp” for each request.

var requestBody = replaceVariables(request.data);

Here, the body is loaded into a variable and all the replacements are made (replacing {{UserId}}, {{reference}}, {{Postback_CompletedUrl}} etc.)

var hmacText = replaceVariables(request.url) + request.method + pm.environment.get("UserId") + requestBody;

Now we concatenate the data necessary for the checksum calculation as described here.

var checksum = hash(userSecret, hmacText);
pm.environment.set("checksum", checksum);

We calculate the checksum by calling the function that we loaded from common_functions. The result is stored in the environment variable “checksum”, which is referenced on the Headers tab.

Note that in our script we also log intermediate values to the console. By selecting “Show Postman Console” you can observe these values, helping you better understand the process.