- 26 Jan 2024
- 1 Minuto para leer
- Colaboradores
- Impresión
- OscuroLigero
Payment Gateway Integration
- Actualizado en 26 Jan 2024
- 1 Minuto para leer
- Colaboradores
- Impresión
- OscuroLigero
Payment Gateway HTTP POST to VisualVault
Payment gateway providers commonly have a feature where the results of a payment transaction can be sent back to the originating web application via HTTP POST (Web hook). VisualVault support this functionality by leveraging the integrated Microservices feature and the Scripts API endpoint.
Process Overview
Using a VisualVault Microservice to receive Web hook event notifications
Microservice Configuration in VisualVault Control Panel
- Create a Microservice in the VisualVault Control Panel.
- Configure the microservice to be a Node.js Script service
- Configure the microservice to allow anonymous access
- Copy the Script Id (for use in VisualVault API endpoint URL)
- Paste your Node.Js code into the code window and save
Example URLs for invoking the payment outcome microservice:
URL using Script Id (recommended):
https://vv5dev.visualvault.com/api/v1/{customer}/{database}/scripts/{id}?transform=false
URL using Script Name:
Name parameter is the name of your microservice used for processing the payment outcome.
Transform parameter tells VisualVault not to modify the content of the HTTP POST JSON body.
Example Code for the payment outcome microservice:
Important! your script must validate the HTTP request and confirm its coming from the payment gateway. If request is not valid (incorrect payment gateway payload) then return http 401 (unauthorized).
Your Node.js microservice script will receive the payment gateway payload in the field named "json". Use JSON.parse to get the JSON object sent from the Payment Gateway Web hook.
Follow the Payment Gateway's specific documentation on how to validate their Web hook request and how to use their payload to get payment information (payment confirmation or error code information).
Most Payment Gateway vendors will re-submit the request many times until you return an http 200 response code to indicate the request was processed successfully.
module.exports.getCredentials = function () {
var options = {}
options.baseUrl = "https://sandbox3.visualvault.com";
options.customerAlias = "CUSTOMER ALIAS";
options.databaseAlias = "DATBASE ALIAS";
options.userId = "USER ID";
options.password = "PASSWORD";
options.clientId = "CLIENT ID";
options.clientSecret = "CLIENT SECRET";
return options;
};
module.exports.main = function (ffCollection, vvClient, response) {
var jsonField = ffCollection.getFormFieldByName("json");
var json = JSON.parse(jsonField.value);
response.json(200, json);
}