Webcheckout
Below you will find a sample code for your payment button. Just replace the sample values as required and you are ready to start receiving payments.
POST /pay
Parameters
pg_serviceid
Required
|
string |
Paygol merchant ID |
pg_price
Required
|
string |
Payment amount: ex. 1000.00 /^[0-9]+\.[0-9]{2}$/ |
pg_currency
Required
|
string |
Currency type specified in ISO 4217 alphabetic code |
pg_country
Optional
|
string |
ISO 3166-2 country code |
pg_method
Optional
|
string |
Payment method code |
pg_email
Optional
|
string |
Payer's email |
pg_first_name
Optional
|
string |
Payer name |
pg_last_name
Optional
|
string |
Payer surname |
pg_personalid
Optional
|
string |
Payer's document number |
pg_phone
Optional
|
string |
Payer's phone number |
pg_sub_merchant_id
Optional
|
string |
Code used to distinguish between different merchants that use our service through their platform |
pg_sub_merchant_url
Optional
|
string |
Website of the merchant where the payment originates from |
pg_return_url
Optional
|
string |
Redirect url for completed payments |
pg_cancel_url
Optional
|
string |
Redirect url for when the payment is failed or canceled by the payer |
pg_language
Optional
|
string |
ISO 639-1 language |
pg_name
Optional
|
string |
Description of your product / service, which will be shown in the payment screen (Max: 255) |
pg_custom
Optional
|
string |
Flexible field, can be used to track user, inventory, etc. (Max. 255) |
API
Our API implementation offers a high level of customization, allowing you to implement a white label payment solution directly on your platform in a fast and easy way.
This implementation is based on POST calls to web services, which will deliver a response in JSON format. The response will contain the URL to which you will have to redirect your customers to start the payment process.
Signature
All requests to the payment API must be signed using the merchant's secret key with the HMAC SHA256 algorithm. The signature should be calculated using the request payload, sorted in ascending order, and adding this result in a request header named X-Pg-Sig.
Get token
Headers
X-Pg-Sig
Required
|
string |
HMAC-SHA256 request signature |
Parameters
pg_serviceid
Required
|
string |
Paygol merchant ID |
POST /api/v2/auth/token
Response 200 OK - Content-Type: application/json
{
"token": "dce5b070ba65626dccd4ad700fdf3c1d219105a1"
}
Create payment
Headers
X-Pg-Sig
Required
|
string |
HMAC-SHA256 request signature |
Parameters
pg_serviceid
Required
|
string |
Paygol merchant ID |
pg_ip
Required
|
string |
IP address of the payer. |
pg_price
Required
|
string |
Payment amount: ex. 1000.00 /^[0-9]+\.[0-9]{2}$/ |
pg_currency
Required
|
string |
Currency type specified in ISO 4217 alphabetic code |
pg_country
Required
|
string |
ISO 3166-2 country code |
pg_method
Required
|
string |
Payment method code |
pg_email
Required
|
string |
Payer's email |
pg_first_name
Required
|
string |
Payer name |
pg_last_name
Required
|
string |
Payer surname |
pg_personalid
Optional
|
string |
Payer's document number |
pg_phone
Optional
|
string |
Payer's phone number |
pg_sub_merchant_id
Optional
|
string |
Code used to distinguish between different merchants that use our service through their platform |
pg_sub_merchant_url
Optional
|
string |
Website of the merchant where the payment originates from |
pg_return_url
Required
|
string |
Redirect url for completed payments |
pg_cancel_url
Required
|
string |
Redirect url for when the payment is failed or canceled by the payer |
pg_custom
Optional
|
string |
Flexible field, can be used to track user, inventory, etc. (Max. 255) |
pg_address
Optional
|
string |
Payer's Address (Max 256) |
pg_city
Optional
|
string |
Payer's City (Max 64) |
Note
Some countries have special requirements for certain payment methods.
POST /api/v2/payment/create
Response 200 OK - Content-Type: application/json
{
"data": {
"service_id": "PAYGOL_SERVICE_ID",
"transaction_id": "OO3Q-73HT-ALEB-Y0G2",
"status": "created",
"payment_method": "webpay",
"amount": "3500.00",
"currency": "CLP",
"payment_method_url": "https://www.paygol.com/api/pay-direct/OO3Q-73HT-ALEB-Y0G2",
"custom": "Pago cuenta VIP",
"customer": {
"first_name": "Roberto",
"last_name": "Fernandez",
"email": "[email protected]",
"phone": "",
"personal_id": "",
"country": "CL"
},
"redirect_urls": {
"success_url": "http://www.mi-sitio.com/pago-ok",
"cancel_url": "http://www.mi-sitio.com/pago-cancelado"
}
}
}
Get payment status
Headers
X-Pg-Sig
Required
|
string |
HMAC-SHA256 request signature |
Parameters
pg_serviceid
Required
|
string |
Paygol merchant ID |
pg_token
Required
|
string |
Auth token |
transaction_id
Required
|
string |
Paygol transaction ID |
POST /api/v2/payment/status
Response 200 OK - Content-Type: application/json
{
"payment": {
"service_id": "PAYGOL_SERVICE_ID",
"transaction_id": "OO3Q-73HT-ALEB-Y0G2",
"status": "completed",
"payment_method": "webpay",
"amount": "3500.00",
"currency": "CLP",
"created_at": "2021-01-02 23:11:00",
"completed": "2021-01-02 23:13:00",
"custom": "Pago cuenta VIP",
"customer": {
"first_name": "Roberto",
"last_name": "Fernandez",
"email": "[email protected]",
"phone": "",
"personal_id": "",
"country": "CL"
}
}
}
Notifications
IPN (Instant Payment Notification) is a notification that is sent from one server to another through a HTTP POST call in relation to your transactions.
To receive notifications of events in your system, you must have previously configured a notification url to which Paygol has access.
To guarantee the security of the exchanges, the data will be signed using the merchant secret_key .
Note
The notification URL and the secret_key can be found in the Merchant panel, Notifications section.
Confirmation
If your notification script executes very complex logic or makes calls to the network, it is possible that the waiting time will expire before Paygol receives the reception confirmation. Ideally, your code that handles receiving notifications (acknowledging with 2xx status code) is independent of any other logic.
Handling duplicate notifications
Notification endpoints can sometimes receive the same notification more than once. This is why we recommend that you avoid duplicate notification receipts by making your event processing idempotent.
Notifications
{
"country": "CL",
"completed_at": "2020-11-26T16:22:32-03:00",
"currency": "CLP",
"created_at": "2020-11-26T16:19:27-03:00",
"custom": "Pago cuenta VIP",
"method": "webpay",
"price": "7500.00",
"service_id": "PAYGOL_SERVICE_ID",
"status": "completed",
"transaction_id": "ZISS-A7Q8-RE2Z-S73W",
}
Retrieve notification information