PHP code example of nordsoftware / yii-paymentmanager

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

    

nordsoftware / yii-paymentmanager example snippets


.....
'components' => array(
    .....
    'payment' => array(
        'class' => 'PaymentManager',
        'contexts' => array(
            'context1' => array(
                'successUrl' => array('/context1/done'),
                'failureUrl' => array('/context1/failure'),
            ),
        ),
        'gateways' => array(
            .....
        ),
    ),
),
.....

.....
'import' => array(
    .....
    'webroot.vendor.nordsoftware.yii-paymentmanager.components.*',
    'webroot.vendor.nordsoftware.yii-paymentmanager.models.*',
    'webroot.vendor.nordsoftware.yii-paymentmanager.migrations.*',
    'webroot.vendor.nordsoftware.yii-audit.behaviors.*',
    'webroot.vendor.nordsoftware.yii-audit.models.*',
    'webroot.vendor.crisu83.yii-arbehaviors.behaviors.*',
    .....
),
.....

$transaction = PaymentTransaction::create(
    array(
        'context' => 'context1', // the context name from the configuration
        'gateway' => 'paytrail', // ansaction->addShippingContact(
    array(
        'firstName' => 'Foo',
        'lastName' => 'Bar',
        'email' => '[email protected]',
        'phoneNumber' => '1234567890',
        'mobileNumber' => '0400123123',
        'companyName' => 'Test company',
        'streetAddress' => 'Test street 1',
        'postalCode' => '12345',
        'postOffice' => 'Helsinki',
        'countryCode' => 'FIN',
    )
);

$transaction->addItem(
    array(
        'description' => 'Test product',
        'code' => '01234',
        'quantity' => 5,
        'price' => 19.90,
        'vat' => 23.00,
        'discount' => 10.00,
    )
);

$transaction->addItem(
    array(
        'description' => 'Another test product',
        'code' => '43210',
        'quantity' => 1,
        'price' => 49.90,
        'vat' => 23.00,
        'discount' => 50.00,
    )
);

Yii::app()->payment->process($transaction);
bash
php composer.phar update