2017 © Pedro Peláez
 

yii2-extension yii2-payment

Library to handle payments with Estonian banks

image

dlds/yii2-payment

Library to handle payments with Estonian banks

  • Monday, April 6, 2015
  • by dlds
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1,828 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 10 Forks
  • 0 Open issues
  • 9 Versions
  • 4 % Grown

The README.md

PaymentHandler extension for Yii2

Library to handle payments with Estonian banks. Main features includes: - Payment service implemented with the following handlers: IPizza (Swedbank, SEB, LHV, Danske, Krediidipank), Estcard, Nordea - Object oriented and extensible code, you can easily add custom adapters - Generates payment forms from transaction objects - Handles bank post-back requests, (*1)

This is a very basic "low-level" component for implementing payments. If you also need functionality for shopping baskets and orders, you might want to look at opus-online/yii2-ecom extension., (*2)

Installation

Just define the required package in your composer.json., (*3)

{
    "require": {
        "opus-online/yii2-payment": "*",
    }
}

Usage

Overwrite PaymentHandlerBase class and at least the method getConfiguration. Complement the two configuration files with your account details and locations of key and certificate files. You can just copy the files from under examples/config., (*4)

class MyPaymentHandler extends \dlds\payment\PaymentHandlerBase
{

    /**
     * Returns the configuration array
     */
    public function getConfiguration()
    {
        return [
            // common parameters for all adapters
            'common' => array(
                'returnRoute' => 'bankController/return',
            ),
            // adapter-specific parameters
            'adapters' => \yii\helpers\ArrayHelper::merge(require 'banks-default.php', require 'banks-local.php')
        ];
    }
}

Render all payment forms

// create the payment service
$service = MyPaymentHandler::createPaymentService();

// create a transaction object
$transaction = $service->createTransaction(1234, 234, ['comment' => 'Comment']);

// render the widget
echo \dlds\payment\widgets\PaymentWidget::widget([
    'forms' => $service->generateForms($transaction),
]);

Customize the payment form

The default implementation uses the widget dlds\payment\widgets\PaymentWidget. You can override and use this to use custom forms or elements., (*5)

class MyPaymentWidget extends PaymentWidget
{
    protected function generateSubmit(Form $form) {
        return Html::submitButton('MyCustomLabel');
    }
}

And then just render your customized widget instead of the default one (see the widget example above)., (*6)

Receive return requests from the bank

$service = PaymentHandler::createPaymentService();
$response = $service->handleResponse($_REQUEST);

// re-generate the transaction object from the response
$transaction = $response->getTransaction();

if ($response->isSuccessful()) {
    // see the Transaction object for more details
    echo $transaction->getTransactionId();
}

Added cancelRoute and getCancelUrl() to AdapterAbstract to allow different redirecting after cancelling a payment, (*7)

The Versions

06/04 2015

dev-master

9999999-dev

Library to handle payments with Estonian banks

  Sources   Download

proprietary

The Requires

 

by Ivo Kund

06/04 2015

1.1.1

1.1.1.0

Library to handle payments with Estonian banks

  Sources   Download

proprietary

The Requires

 

by Ivo Kund

06/04 2015

1.1

1.1.0.0

Library to handle payments with Estonian banks

  Sources   Download

proprietary

The Requires

 

by Ivo Kund

13/02 2015

1.0.3

1.0.3.0

Library to handle payments with Estonian banks

  Sources   Download

proprietary

The Requires

 

by Ivo Kund

15/10 2014

1.0.2

1.0.2.0

Library to handle payments with Estonian banks

  Sources   Download

proprietary

The Requires

 

by Ivo Kund

15/10 2014

1.0.1

1.0.1.0

Library to handle payments with Estonian banks

  Sources   Download

proprietary

The Requires

 

by Ivo Kund

07/10 2014

1.0.0

1.0.0.0

Library to handle payments with Estonian banks

  Sources   Download

proprietary

The Requires

 

by Ivo Kund

14/05 2014

1.0-alpha2

1.0.0.0-alpha2

Library to handle payments with Estonian banks

  Sources   Download

proprietary

The Requires

 

by Ivo Kund

28/01 2014

1.0-alpha

1.0.0.0-alpha

Library to handle payments with Estonian banks

  Sources   Download

proprietary

The Requires

 

by Ivo Kund