Introduction
This sample project is one of the many integrations I designed and developed. It allows customer that uses Dynamics NAV and LS Retail POS System to receive credit card payments and send payment information to Global Payments API in order to process the transactions. If you don’t know what Global Payments API is, check out this link.
Setup
1) First we have a setup table for each Pos Terminal. Here we specify API Endpoints and other settings:
Notice that the web service required to send a token with all requests, into the Request Headers. The token we create expires in 24 hours. Therefore, before making each request, we check the Expiration Date of the Token in the Setup Line table and if is expired, we generate a new token and update the Setup Line table. If token is not expired, we use the existing one. Generating the token required also to encrypt some data using SHA512 algorithm, so this was interesting to develop.
API Log
2) We have also an API Log, which means that we log all Requests and Responses sent/received from/to the web service.
3) Example of sent Request. Notice that, based on a setup, the Track data / Card No. are redacted as this represents sensitive information about the used card.
4) Example of received Response:
The Response is *.zip archived for performance reasons, so I had to unzip it in order to use the information received and then store it into the Log table. This was also interesting to develop (see code samples at the end).
5) Based on another setup, we can either use an MSR Reader that reads the Track data from the card or manually enter the Card No. and Expiration Date. In previous examples you saw data retrieved using an MSR Card Reader. Below is an example of transaction created by manual input of Card No. and Expiration Date:
How the Global Payments API Integration works
6) Now let’s see how it works at the POS. It is very simple, just add items to sell and press a button. Then system asks to Swipe the Card (in case of using an MSR Card Reader) or to enter Card No and Expiration date. See below how it asks for Card Swipe:
7) If the Card Track was read successfully the payment is sent to web service. If response from web service is transaction APPROVED, payment is registered into ERP system. Otherwise, error message (with details about the cause of error) is shown and payment is not registered. Example error invalid card:
8) If the Card Track could not be read using the MSR Card Reader (because card is damaged for example), a confirm message appears and user has possibility to enter manually card information:
9) If user selects ‘Yes’, system asks first for Card No.:
10) And then for Expiration date in ‘mm/yy’ format:
11) If card is expired or the entered data is invalid, errors are shown. Example:
12) If card information is correct, Request is sent to web service. Based on the response received (APPROVED or DECLINED), the payment is registered into ERP system or the error received from web service is displayed.
Other Information and Code Samples
The Global Payments API Integration supports also Payment Reversals and Refunds.
Code samples on GitHub (only core codeunits, not complete solution!) :
https://github.com/andreilungu/Utilities/tree/master/NAV/Global%20Payments%20API%20Integration
Important Note:
All Sample Projects posts are examples of apps created by me from beginning to end(of course, using public information and resources when needed). All customer private data is hidden, the aim being to present briefly the app’s features, ideas, methods used etc