-
Notifications
You must be signed in to change notification settings - Fork 0
/
Module.php
73 lines (61 loc) · 1.83 KB
/
Module.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
namespace sibds\payment\yookassa;
use Yii;
use dicr\yookassa\YooKassa;
class Module extends \yii\base\Module
{
public $testServer = false;
public $adminRoles = ['admin', 'superadmin'];
public $thanksUrl = '/main/spasibo-za-zakaz';
public $failUrl = '/main/problema-s-oplatoy';
public $currency = 'RUB';
public $shopId = '';
public $secretKey = '';
public $orderModel = 'dvizh\order\models\Order';
public $getId = null;
public $getModel = null;
public $getDescription = null;
public $sessionTimeout = null; // in seconds
public $refundRate = 100; // percentage of refund
public $logCategory = false;
public $taxSystem = 1;
public $vatCode = 1;
public $supportCart = false;
public $defaulProductName = null;
public $paymentMode = 'full_payment';
public $paymentSubject = 'commodity';
public function init()
{
parent::init();
// custom initialization code goes here
//init component for work with yookassa
$config = null;
if ($this->testServer) {
$config = [
'testServer' => $this->testServer,
'debug' => true,
'httpClient' => [
'verify' => false,
],
];
}
\Yii::$app->setComponents([
'yookassa' => [
'class' => YooKassa::class,
'shopId' => $this->shopId,
'secretKey' => $this->secretKey,
'config' => $config ?? null,
],
]);
}
/**
* @return dicr\yookassa\Client
*/
public function getClient()
{
/** @var dicr\yookassa\YooKassa $yookassa */
$yooKassa = Yii::$app->get('yookassa');
/** @var dicr\yookassa\Client $client */
return $yooKassa->client;
}
}