<?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); ?>