In this project you'll see an example e-commerce that will pay through Gestpay Starter solution.
## Prerequisites
- NodeJS (4+)
- ngrok, if you want to launch this example locally on your development machine.
- install the dependencies:
npm install - open file
properties.jsonand set yourshopLogin - launch ngrok with
./ngrok http 3000, where3000is the port configured inproperties.json.It will return an address likehttp://44bda365.ngrok.io - Go in Merchant Back Office and, in Configuration, configure your server address: for example
http://44bda365.ngrok.io/responsein URL for positive response, URL for negative response. - launch the app with
npm start
This example tries to be as simple as possible. Here is a list of npm packages used:
- Express, a web framework.
- Handlebars, to render html templates
- Soap, a node package to interact with SOAP endpoints.
npm run watch: will run the app but for every modification it will reload instantly. Useful during development;npm test: will run all the testsnpm run test-watch: if you change something, tests will re-runnpm run jsdoc: you might like to have some documentation about the two modules used in this project, check itout.
server.js: contains all the express logic and configuration.gestpay_service/GestpayService.js: used for communicating between server.js and wscryptdecrypt.jswscryptdecrypt/wscryptdectypt.js: the low level file that will perform the soap calls to Gestpay.properties.json: a file with some global properties.
- The main entry point is
/, where the user can choose a product to pay. - After clicking on buy button, the server will ask Gestpay for an
encryptionStringand the user will redirect to/pay. - When the user clicks on pay, he will be redirected to Gestpay website to complete the payment.
- When the payment is completed, Gestpay will call
/response, our server will decrypt theencryptionStringreceived, and the transaction status is showed to the user.