Webhook payment response

Webhook payment response

1. Description

If the merchant requires receiving the payments responses or card tokenization response in a backend, either to update orders, information or only store the response in the database as a backup, then they have to enable a webhook.
A webhook is a series of web API services that the merchant have to enable to receive responses from the payment gateway, card tokenization, subscription payments, or bulk payments.

2. Webhook configuration

2.1 Webhook routes

The different routes that must be configured to receive the different responses are described below. All routes must be enabled to receive POST requests.
Not all routes should be implemented, only the ones that are required.
For example, if you have a domain at webhook.micomercio.com that you want to set as webhook, then the routes are:
  1. /: To receive the answers sent by the checkout service 
    1. http://webhook.yourcommerce.com/
  2. /newCard: To receive the response sent by the tokenization service.
    1. http://webhookyourcommerce.com/newCard
  3. /subscription/payment/results: To receive the response sent by the subscription service.
    1. http://webhookyourcommerce.com/subscription/payment/results
  4. /bulkResume: To receive the responses sent by the bulk payment service
    1. htttp://webhook.yourcommerce.cin/bulkResume

2.2  Webhook headers and body

The webhook must allow to receive the following headers:
  • 'Accept': 'application/json'

  • 'Content-Type': 'application/json'


Also, the body that Greenpay will send to each service will be a json object, like the following:

  1. {

  2.     "status": 200,

  3.     "orderId": "xwr-123455",

  4.     "authorization": "533793",

  5.     "last4": "7777",

  6.     "brand": "Visa",

  7.     "result": {

  8.       "time_local_tran": "165407",

  9.       "systems_trace_audit_number": "000283",

  10.       "success": true,

  11.       "retrieval_ref_num": "701016540713",

  12.       "resp_code": "00",

  13.       "reserved_private4": null,

  14.       "proc_code": "000000",

  15.       "network_international_id": "0003",

  16.       "mti": "0210",

  17.       "merchant_id": 485,

  18.       "date_local_tran": "0110",

  19.       "card_acceptor_terminal_id": "00112478",

  20.       "authorization_id_resp": "533793"

  21.     },

  22.     "errors": [],

  23.     "callback": "http://yourcallback.url/getcheckoutform/response",

  24.     "_signature": "2e9d23b19490531456....47aa7ce262c9c4d4589a26bc8aad046bce4"

  25.   }

The following code is an javascript example of the request that Greenpay services will send to the configured webhook:

var unirest = require("unirest")
var body = {
"status": 200,
"orderId": "xwr-123455",
"authorization": "533793",
"last4": "7777",
"brand": "Visa",
"result":
{
"time_local_tran": "165407",
"systems_trace_audit_number": "000283",
"success": true,
"retrieval_ref_num": "701016540713",
"resp_code": "00",
"reserved_private4": null,
"proc_code": "000000",
"network_international_id": "0003",
"mti": "0210",
"merchant_id": 485,
"date_local_tran": "0110",
"card_acceptor_terminal_id": "00112478",
"authorization_id_resp": "533793" },
"errors": [],
"_signature": "2e9d23bb5e554...ab114d717ec6"
}
req.headers({"cache-control": "no-cache", "Accept": "application/json", "Content-Type": "application/json" })
req.type("json")
req.send(body)
req.end(
function (res) {
if (res.error) throw new Error(res.error)
console.log(res.body) }
)

3. Set the webhook

To set the webhook in GreenPay, the following steps must be followed:
  1. Go to the Greenpay portal (Dashboard) at https://dashboard.greenpay.me/login.
  2. Go to the Settings tab.
  3. Click on the Add new button.
  4. Add the webhook URL, for example, webhook.micomercio.com
  5. Save the configuration.
  6. Once the webhook is set , you will receive notifications to the server with the services responses.
In the following image, you can see the instructions to set the webhook.


    • Related Articles

    • Receive Webhook response

      1. Description If the merchant requires receiving the payments responses or card tokenization response in a backend, either to update orders, information or only store the response in the database as a backup, then they have to enable a webhook. ...
    • Send bulk payment request

      To create a bulk payment request, a POST request must be made to the batch payment endpoint, with the structure of the JSON shown below: 1.{ "merchantId": "your_merchant_id", "secret": "your_secret", "terminal": "your_terminal", "currency": "USD || ...
    • Widget payment process

      To consider Para utilizar el widget de pago de Greenpay, se debe considerar los siguiente: You must have a sandbox or production account, to obtain a sandbox account visit About sandbox or test account. The payment widget is a web element that can be ...
    • Webform payment process

      To consider To use the card payment form, the following aspects should be considered: The form is available at: Sandbox: https://sandbox-checkoutform.greenpay.me/ Producción: https://checkout-form.greenpay.me/ Get a session and token of a valid ...
    • Get responses on a webhook

      1. Description If the merchant requires receiving the payments responses or card tokenization response in a backend, either to update orders, information or only store the response in the database as a backup, then they have to enable a webhook. A ...