PHP code example of saulmoralespa / pstpagofacil

1. Go to this page and download the library: Download saulmoralespa/pstpagofacil library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

saulmoralespa / pstpagofacil example snippets


// ... please, add composer autoloader first
PagoFacil;

// create token in panel  menu "API Tokens" 
$token_user = 'YOUR_TOKEN_USER';

// instantiate the class
$pagoFacil = new PSTPagoFacil($token_user);
$pagoFacil->sandbox_mode(true); // sandbox true o production false

$transaction = array(
       'x_url_callback' => 'http://127.0.0.1/notify',
       'x_url_cancel' => 'http://127.0.0.1/cancel',
       'x_url_complete' => 'http://127.0.0.1/complete',
       'x_customer_email' => '[email protected]',
       'x_reference' => time(),
       'x_account_id' => '262', // Id service
       'x_amount' => 500,
       'x_currency' => 'CLP',
       'x_shop_country' => 'CL'
       );
//return object       
$data = $pagoFacil->createPayTransaction($transaction);

$idOrder = '34524'; //id order
//return object
$statusOrder = $pagoFacil->statusOrder($idOrder);