Instant Payment Notification V2 (IPN)

What is IPN?
Instant Payment Notification (IPN) is a service that notifies you of events related to Paygol transactions. You can use it to automate back-office and administrative functions, such as fulfilling orders, inserting points or coins, upgrading membership, tracking customers, and providing status and other information related to a transaction.

Information about the payment
Paygol will make a GET request to your IPN file when your customer completes a transaction. You can use this notification to kick-off order fulfillment, enable digital media downloads, store information in a customer relationship management (CRM) or accounting system, and so on.

How to receive the IPN information in my web page?
Paygol provides samples of Instant Payment Notification (IPN) code for popular development environments. For custom IPN files, you can use the following sample code as a starting point.

Example of implementation

<?php 

require_once 'lib/php-apiv2/Notification.php';

/*
 * Merchant service ID
 */
$service_id = "123";
/*
 * Merchant secret
 */
$shared_secret = "7c1a6a24-7943-102d-92f8-29573711ad31";

try {
    $ipn = new Notification($service_id, $shared_secret);

    $ipn->validate();

    $params = $ipn->getParams();

    var_dump($params);

    // do something

    // Confirm reception
    $ipn->sendResponse(['OK'], 200);
} catch (\Exception $e) {
    $ipn->sendResponse(['error' => 'Validation error'], 400);
}

The above command returns JSON structured like this:

{
  "country": "CL",
  "currency": "USD",
  "custom": "Producto 1 - Producto 2 - Producto 3",
  "method": "bitcoin",
  "price": "10.00",
  "service_id": "123",
  "status": "created",
  "transaction_id": "ABCD-ZZZZ-BIKE-1234"
}