PHP code example of payum-tw / ecpay

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

    

payum-tw / ecpay example snippets




use Payum\Core\PayumBuilder;
use Payum\Core\GatewayFactoryInterface;

$defaultConfig = [];

$payum = (new PayumBuilder)
    ->addGatewayFactory('ecpay', function(array $config, GatewayFactoryInterface $coreGatewayFactory) {
        return new \PayumTW\Ecpay\EcpayGatewayFactory($config, $coreGatewayFactory);
    })

    ->addGateway('ecpay', [
        'factory'     => 'ecpay',
        'MerchantID'  => '2000132',
        'HashKey'     => '5294y06JbISpM5x9',
        'HashIV'      => 'v77hoKGq4kWxNNIS',
        'sandbox'     => true,
    ])

    ->getPayum();



use Payum\Core\Request\Capture;

$ecpay = $payum->getGateway('ecpay');

$model = new \ArrayObject([
  // ...
]);

$ecpay->execute(new Capture($model));