pavlinter/yii2-adm-oplata

Yii2: Adm Oplata

Installs: 41

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 1

Open Issues: 0

Type:yii2-extension

v1.0.0-beta 2015-01-20 10:30 UTC

This package is not auto-updated.

Last update: 2024-11-05 03:42:33 UTC


README

https://www.oplata.com

Установка

Удобнее всего установить это расширение через composer.

   "pavlinter/yii2-adm-oplata": "*",

Настройка

'modules' => [
    ...
    'adm' => [
        ...
        'modules' => [
            'admoplata'
        ],
        ...
    ],
    'admoplata' => [
       'class' => 'pavlinter\admoplata\Module',
       'modules' => [],
    ],
    ...
],
'components' => [
    ...
    'oplata' => [
        'class' => 'pavlinter\admoplata\components\Oplata',
        'merchantId' => 'xxxx', //own merchant id
        'password' => 'xxxx', //own password
        'invoiceLayout' => '/main';
        'layout' => '@vendor/pavlinter/yii2-adm/adm/views/layouts/main';
        'userSelect' => [
            'viewCallback' => null, //function ($row) {return Adm::t('oplata','{email}:select2 template', $row);}
            'querySearch' => null, // function ($query, $userTable, $search) {/* @var \yii\db\Query $query */return $query->from($userTable)->where(['like', 'email', $search])->limit(20)->all();}
            'queryLoad' => null, //function ($query, $userTable, $id) {/* @var \yii\db\Query $query */return $query->from($userTable)->where(['id' => $id])->one();}
        ];
        'sendFunc' => null; //function ($model, $module, $user, $username) {}
        'sendFrom' => null; // default Yii::$app->params['adminEmail']
        'mailTemplate' => '@vendor/pavlinter/yii2-adm-oplata/admoplata/views/transaction/email-template';
        'remindTemplate' => '@vendor/pavlinter/yii2-adm-oplata/admoplata/views/transaction/remind-template',
        'remindDays' => 1, //Высылать напоминание о платиже за 1 день до окончания счета /en/admoplata/transaction/cron
        'pdf' => [
            'image' => [ //logo htmlOptions
                //'src' => '',
            ],
            'imageLink' => [ //logo link htmlOptions
                //'href' => '',
            ],
        ];
    ],
    'response' => [
        'formatters' => [
            'adm-pdf' => [
                'class' => 'pavlinter\admoplata\PdfResponseFormatter',
            ],
        ]
    ],
    ...
],

Ссылка для крона

/en/admoplata/transaction/cron

Запустить миграцию

yii migrate --migrationPath=@vendor/pavlinter/yii2-adm-oplata/admoplata/migrations

Как использовать

echo Html::a('My-Page',['/admoplata/default/invoice', 'alias' => 'My-hash']);

Контроллер

public function actionOrder() {
    $item1 = new OplataItem();
    $item1->title = 'Item 1';
    $item1->description = 'Item 1Item 1Item 1Item 1Item 1';
    $item1->price = '20';
    $item1->amount = 1;

    $item2 = new OplataItem();
    $item2->title = 'Item 2';
    $item2->description = 'Item 2Item 2Item 2Item 2Item 2';
    $item2->price = '0.9';
    $item2->amount = 2;

    Yii::$app->oplata->clearItems();
    Yii::$app->oplata->addItem($item1);
    Yii::$app->oplata->addItem($item2);
    $order = Yii::$app->oplata->createOrder([
        'user_id' => null,
        'language_id' => Yii::$app->getI18n()->getId(),
        'email' => 'bob@bob.com',
        'title' => 'Тестовый заказ',
        'currency' => OplataTransaction::CURRENCY_USD,
        'shipping' => '0.89',
        'data' => [], //or string or object
    ]);
    if ($order !== false) {
        return $this->redirect(['invoice', 'alias' => $order->alias]);
    }
    echo '<pre>';
    echo print_r(Yii::$app->oplata->getErrors());
    echo '</pre>';
}