7/9/2021                                             Ejemplo en PHP de integración APP Checkout
Centro de Soporte
     Ejemplo en PHP de integración APP
     Checkout
     Ejemplo de clase para invocar al servicio de generar token para PHP.
     El ejemplo esta para realizar la prueba de integración en ambiente SANDBOX, si deseamos
     integrar a transacciones en vivo debemos de utilizar las url de producción.
     //Creación de productos:
                       $products[] = Array('Producto 1', '100', '', '1', '10.00', '10.00');
                       $products[] = Array('Producto 2', '102', '', '2', '5.00', '10.00');
     // Configuración de campos personalizados
     $customFields = Array('idSistema'=>'1009','idCliente'=>'2025','numerodeorden'=>'2585');
     //URL de sandbox para prueba                        
                       $base_api = "https://sandbox.qpaypro.com/payment/register_transaction_store";
                       $http_origin = "https://sandbox.qpaypro.com/";
     //Estructura de parámetros al servicio                          
                       $requestSend =
                       [
                                         "x_login" =>  'visanetgt_qpay',
                                         "x_api_key" => '88888888888',
                                         "x_amount" => '24.00',
                                         "x_currency_code" => 'GTQ',
                                         "x_first_name" => 'Usuario',
                                                                                                       1/4
7/9/2021                                                  Ejemplo en PHP de integración APP Checkout
                                         "x_last_name" => 'Prueba',
                                         "x_phone" => '24963214',
                                         "x_ship_to_address" => 'Ship address',
                                         "x_ship_to_city" => 'Ship City',
                                         "x_ship_to_country" => 'Guatemala',
                                         "x_ship_to_state" => '0',
                                         "x_ship_to_zip" => '1010',
                                         "x_ship_to_phone" =>'11223344',
                                         "x_description" => "Order number: 123",
                                         "x_url_success" => '',
                                         "x_url_error" => '',
                                         "x_url_cancel" =>'URL_de_procedencia',
                                         "http_origin" =>"tuempresa.com",
                                         "x_company" =>  '',
                                         "x_address" => 'Address',
                                         "x_city" => 'City',
                                         "x_country" => 'Guatemala',
                                         "x_state" => '0',
                                         "x_zip" => '1201',
                                         "products" => json_encode($products),
                                         "x_freight" => '3.00',
                                         "taxes" => '1.00',
                                         "x_email" => 'usuarioprueba@gmail.com',
                                         "x_type" => "AUTH_ONLY",
                                                                                                       2/4
7/9/2021                                               Ejemplo en PHP de integración APP Checkout
                                         "x_method" => "CC",
                                         "x_invoice_num" => '123',
                                         "custom_fields" => json_encode($customFields),
                                         "x_visacuotas" => 'si',
                                         "x_relay_url" =>
     'RUTA_A_DONDE_DEBE_VOLVER_AL_FINALIZAR_PAGO',
                                         "origen"=>"PLUGIN",
                                         "store_type" => "LOCAL"
                       ];
     //Llamada al servicio                             
                       $headerArray = array(
                                         'Content-Type: application/json;charset=UTF-8'
                       );
                                          
                       $ch = curl_init();
                       curl_setopt($ch, CURLOPT_URL, $base_api);
                       curl_setopt($ch, CURLOPT_POST, 1);
                       curl_setopt($ch, CURLOPT_POSTFIELDS, $requestSend);
                       curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                       curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
                       curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
                                        
                       $resp = curl_exec($ch);
                       $info = curl_getinfo($ch);
     //Resultado 'TOKEN GENERADO'
                                                                                                    3/4
7/9/2021                                      Ejemplo en PHP de integración APP Checkout
                       var_dump($resp);
                       die;
                            
     //Ingresar o redireccionar al siguiente URL
     https://sandbox.qpaypro.com/payment/store?token=TOKEN_GENERADO
           https://desk.zoho.com/portal/qpaypro/es/kb/articles/ejemplo-en-php-de-integraci%C3%B3n-app-
                                                      checkout
                                                                                                         4/4