PHP code example of hakito / cakephp-stuzza-eps-banktransfer-plugin

1. Go to this page and download the library: Download hakito/cakephp-stuzza-eps-banktransfer-plugin 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/ */

    

hakito / cakephp-stuzza-eps-banktransfer-plugin example snippets


public function bootstrap()
{
    // Call parent to load bootstrap from files.
    parent::bootstrap();

    $this->addPlugin(\EpsBankTransfer\Plugin::class, ['routes' => true]);
}

[
    'EpsBankTransfer',
    [
        //     // Eps "Händler" id
        'secret' => 'topSecret',             // Secret for authentication
        'iban' => 'AT611904300234573201',    // IBAN code of bank account where money will be sent to
        'bic' => 'GAWIATW1XXX',              // BIC code of bank account where money will be sent to
        'account_owner' => 'John Q. Public', // Name of the account owner where money will be sent to

        // Encryption key for sending encrypted remittance identifier as encrypted string
        'encryptionKey' => 'A_SECRET_KEY_MUST_BE_32_BYTES_LONG',

        //// optional parameters
        //'ObscuritySuffixLength' => 8,             // Number of hash chars appended to remittance identifier
        //'ObscuritySeed'  => 'SOME RANDOM STRING', // Seed for the random remittance identifier suffix. REQUIRED when ObscuritySuffixLength > 0 provided
        //'TestMode' => true                        // Use EPS test mode URL endpoint
    ]
];

    'Log' =>
    [
        'eps' =>
        [
            'className' => FileLog::class,
            'path' => LOGS,
            'file' => 'eps',
            'scopes' => ['EpsBankTransfer'],
            'levels' => ['warning', 'error', 'critical', 'alert', 'emergency', 'info', 'debug'],
        ],
    ]

    // Load the component
    public function initialize(): void
    {
        parent::initialize();
        $this->loadComponent('EpsBankTransfer.Eps');
    }

    // Sample checkout
    private function _checkoutEPS($orderId)
    {
        // Add all articles
        $this->Eps->AddArticle('Magic dragon', $quantity, $priceInCents);

        // You might also want to add shipping agio as article
        $this->Eps->AddArticle('Shipping agio', 1, $shippingAgioInCents);

        // remittanceIdentifier could be your shopping card id
        // okUrl is the return url if payment is successful
        // nOkUrl is the return url if payment failed / canceled
        // BIC of the bank from GetBanksArray
        $this->Eps->PaymentRedirect($remittanceIdentifier, $okUrl, $nOkUrl, $bic);
    }

\Cake\Event\EventManager::instance()->on('EpsBankTransfer.VitalityCheck',
function ($event, $args)
{
  // $args =
  // [
  //   'raw' => {string},                  // Raw XML content
  //   'vitalityCheckDetails' => {object}, // Instance of at\externet\eps_bank_transfer\VitalityCheckDetails
  // ]

  return ['handled' => true]; // You have to set this otherwise the EPS call is not successful
});

\Cake\Event\EventManager::instance()->on('EpsBankTransfer.Confirmation',
function ($event, $args)
{
  // $args =
  // [
  //   'raw' => {string},                     // Raw XML content
  //   'bankConfirmationDetails' => {object}, // Instance of at\externet\eps_bank_transfer\BankConfirmationDetails
  // ]

  return ['handled' => true]; // You have to set this otherwise the EPS call is not successful
});