Saltar al contenido

Dynamic link

Dynamic link of the Payment Button for Developers
Button Payments allows you to connect via APIREST language to the functionality of the button. For integration, the following processes are described:

  1. The following data must be sent through APIREST:
Type: POST
Submit URL: https://portal.botonpagos.com/api/datafast/linksApi
1.1 Mandatory Parameters:
1.1.1 Establishment Code code => text (30) (It is sent as the header of the request and this code is provided by Button Payments)
1.1.2 Products (Send in Json format) products => array ( 0 => array ( id => int, quantity => double (10,2), price => double (10,2), subtotal => double (10,2), tax => double (10,2), total => double (10,2) ) )
1.2 Optional Parameters:
1.2.1 Customer Data (Send in Json format) customer => array ( name => text(50) (optional), last_name => text(50) (optional), document => text(20) (optional), email => text (optional), phone => text(20) (optional), address => text (optional), aditional_data => text (optional) )
1.2.2 URL response url_response => text (Optional) Type POST
1.2.3 Description description => text (Optional)
Ejemplo de uso con PHP

<?php
//I assemble the products of my order
//Store Product ID
$products[0]['id'] = 01;
//Product quantity
$products[0]['quantity'] = 2;
//Product price
$products[0]['price'] = 5.00;
//Value without TAX of the product
$products[0]['subtotal'] = 10.00;
// Product tax
$products[0]['tax'] = 1.20;
//Total product value
$products[0]['total'] = 11.20;

//I assemble the customer data
//Customer name (Optional)
$customer['name'] = 'Pedro Andres';
//Customer Last Name (Optional)
$customer['last_name'] = 'Ramirez Cando';
//Customer Identity Document (Optional)
$customer['document'] = '1785698847';
//Customer email (Optional)
$customer['email'] = '[email protected]';
//Customer phone (Optional)
$customer['phone'] = '0984571241';
//Customer address (Optional)
$customer['address'] = 'Av. Amazonas y Patria';
//Transaction Reason / Additional Notes (Optional)
$customer['aditional_data'] = 'Venta de Suministro';

//I assemble the array to send
$datos = array(
        'products' => json_encode($products),
        'customer' => json_encode($customer) // (Optional) Send only if you want to send customer data,
        'url_response' => 'https://url_response.com', // (Optional)  Type: POST
        'description' => 'Descripción de link' // (Optional)
);

//Address to Payment link
$url = 'https://portal.botonpagos.com/api/datafast/linksApi';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'code: ID del comercio'//ID provided by ButtonPagos
));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $datos);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$responseData = curl_exec($ch);
//If there is a connection error
if (curl_error($ch)) {
    echo curl_error($ch);
}
curl_close($ch);
//Step to array the data obtained in Json
$responseData = json_decode($responseData, true);
?>
2. Payment Link
As a result of the previous step, a json object is obtained with an error code in case the sent data could not be processed. (Remember that to process like the example it is necessary to convert the json object into an array).

The variable $responseData[‘error_code’] will be equal to 1 if there is an error and the description of the error will be contained in the variable $responseData[‘error_description’]

In case there is no error you will get a payment link.

The result should be the following:

https://portal.botonpagos.com/datafast/pagos/checkout/[code]

That completes the payment link process.