PHP code example of dshovchko / php_easypay

1. Go to this page and download the library: Download dshovchko/php_easypay 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/ */

    

dshovchko / php_easypay example snippets


composer 

interface Callback
{
        public function check($account);
        public function payment($account, $orderid, $amount);
        public function confirm($paymentid);
        public function cancel($paymentid);
}

use EasyPay\Provider31\AccountInfo as AccountInfo;

class My_EasyPay_Callback implements EasyPay\Callback
{
        ....
        
        public function check($account)
        {
                $cl = $this->find_account($account);
                
                return new AccountInfo(array(
                        'Account' => $account,
                        'Fio' => $cl['fio'],
                        'Address' => $cl['adress'],
                ));
        }
        
        public function payment($account, $orderid, $amount)
        {
                $paymentid = $this->insert_payment($account, $orderid, $amount);
                
                return $paymentid;
        }
        
        public function confirm($paymentid)
        {
                $orderdate = $this->confirm_payment($paymentid)
                
                return $orderdate;
        }
        
        public function cancel($paymentid)
        {
                $canceldate = $this->cancel_payment($paymentid)
                
                return $canceldate;
        }

        ...
}



$options = include('../etc/config.php');

;

$log = new EasyPay\Logger(
    realpath('../log').DIRECTORY_SEPARATOR,     // log path
    $options['log_prefix'],                     // prefix for log files (default 'my')
    $options['log_debug']                       // enable/disable debug (default false)
);

$cb = new My_EasyPay_Callback($options);

$p = new EasyPay\Provider31($options['easypay'], $cb, $log);
$p->process();


return array(

    // logger setings
    'log_prefix' => 'easypay',
    'log_debug' => true,

    // EasyPay settings
    'easypay' => array(
        'ServiceId' => 'myserviceid',                                           // service id
        'UseSign' => true,                                                      // use sign? (true/false)
        'EasySoftPKey' => '/your_path/etc/EasyPay/EasySoftPublicKey2.pem',      // path for EasyPay public key
        'ProviderPKey' => '/your_path/etc/EasyPay/My.ppk',                      // path for yours private key
    ),
);