API Implementation

 

Overview
How to use the API Implementation
Parameters description
Checking the status of a payment
IPN
IPN Parameters description

 


Overview

Our API implementation offers a high level of customization, allowing you to implement an advanced white label payments solution directly on your platform in a fast and easy way.

This implementation is based in POST/GET requests to web-services which will return an XML or plain text response, according to your preference. The response will contain a URL you can redirect your customer to in order to start the payment process.

How to use the API implementation

To create a new payment you must make a request to the following URL:

https://www.paygol.com/pay

Parameters description

The following POST/GET parameters are required:

 

Codes for available payment methods:

Name Code Description

Example:

https://www.paygol.com/pay?pg_serviceid=123&pg_price=5.00&pg_currency=EUR&pg_custom=player123&pg_return_url=http://www.mysite.com/return.php
&pg_cancel_url=http://www.mysite.com/cancel.php&pg_mode=api&pg_country=ES&pg_language=es&pg_method=creditcard&pg_format=txt
&pg_ip=123.123.123.123&[email protected]&pg_first_name=john&pg_last_name=smith&pg_personalid=12345678-6

Reply (plain text)

OK|service|payment_method|payment_methods|id|price|currency|price_consumer|currency_consumer|locale|payment_method_url|custom|return_url|cancel_url

Example:

OK|123456|webpay|webpay,servipag,multicaja|XXXX-YYYY-ZZZZ-1234|10.00|EUR|10.00|EUR|es-CL|https://www.paygol.com/api/pay-direct/XXXX-YYYY-ZZZZ-1234
|player123|http://www.mysite.com/return.php|http://www.mysite.com/cancel.php

Reply in case of an error:

NOK|error_message

Example:

NOK|Wrong country

Reply (XML)

<transaction>
  <response>OK</response>
  <service>123456</service>
  <payment_method>webpay</payment_method>
  <payment_methods>webpay,servipag,multicaja</payment_methods>
  <id>XXXX-YYYY-ZZZZ-1234</id>
  <price>10.00</price>
  <currency>EUR</currency>
  <price_consumer>10.00</price_consumer>
  <currency_consumer>EUR</currency_consumer>
  <locale>es-CL</locale>
  <payment_method_url>https://www.paygol.com/api/pay-direct/XXXX-YYYY-ZZZZ-1234</payment_method_url>
  <custom>player123</custom>
  <return_url>http://www.mysite.com/return.php</return_url>
  <cancel_url>http://www.mysite.com/cancel.php</cancel_url>
</transaction>

 

Reply in case of an error (example):

<transaction>
  <response>NOK</response>
  <error_message>Wrong country</error_message>
</transaction>

 

The reply parameters are the same regardless of the format used.

Checking the status of a payment

To check the status of a payment you must make a request to the following URL:

https://www.paygol.com/api/check-payment

The following POST/GET parameters are required:

Example:

https://www.paygol.com/api/check-payment?service=123&id=XXXX-YYYY-ZZZZ-1234&format=txt

Reply (plain text)
Transaction ID was found, regardless of its current status:

OK|status

Example:

OK|completed

Reply in case of an error:

NOK|error_message

Example:

NOK|Transaction ID not found

Reply (XML)
Transaction ID was found, regardless of its current status (example):

<transaction>
  <response>OK</response>
  <status>completed</status>
</transaction>

Reply in case of an error (example):

<transaction>
  <response>NOK</response>
  <error_message>Transaction ID not found</error_message>
</transaction>

The reply parameters are the same regardless of the format used.

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:

<?php 

$secret_key = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeee";  // Enter secret key for your service. 

// Secret key validation 
if ($secret_key != $_GET['key']) {
    echo "Validation error"; 
    exit;
}

// get the variables from Paygol system
$transaction_id	   = $_GET['transaction_id'];
$service_id	       = $_GET['service_id'];
$country	          = $_GET['country'];
$custom	           = $_GET['custom'];
$price	            = $_GET['price'];
$currency  	       = $_GET['currency'];

// Here you can do whatever you want with the variables, for instance inserting or updating data into your Database 

?>

IPN Parameters description