1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Yii2 extension for payment processing with Omnipay, Payum and more later. |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/hiqdev/yii2-merchant |
6
|
|
|
* @package yii2-merchant |
7
|
|
|
* @license BSD-3-Clause |
8
|
|
|
* @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/) |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace hiqdev\yii2\merchant\models; |
12
|
|
|
|
13
|
|
|
use Yii; |
14
|
|
|
use yii\base\Model; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Class Deposit. |
18
|
|
|
*/ |
19
|
|
|
class DepositForm extends Model |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var float the amount of money to be deposited |
23
|
|
|
*/ |
24
|
|
|
public $amount; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var string desired currency |
28
|
|
|
*/ |
29
|
|
|
public $currency; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var string the route that will be passed to merchant |
33
|
|
|
* in order to redirect user to a custom page |
34
|
|
|
*/ |
35
|
|
|
public $finishUrl; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* {@inheritdoc} |
39
|
|
|
*/ |
40
|
|
|
public function rules() |
41
|
|
|
{ |
42
|
|
|
return [ |
43
|
|
|
[['amount'], 'number', 'max' => 9999999999999, 'whenClient' => 'function (attribute, value) { |
44
|
|
|
if (value.includes(",")) { |
45
|
|
|
var form = attribute.$form; |
46
|
|
|
$("#" + attribute.id).val(value.replace(/[,]/g, ".")); |
47
|
|
|
form.yiiActiveForm("validate"); |
48
|
|
|
} |
49
|
|
|
return true; |
50
|
|
|
}'], |
51
|
|
|
[['currency'], 'default', 'value' => 'usd'], |
52
|
|
|
[['amount', 'currency'], 'required'], |
53
|
|
|
[['amount'], 'compare', 'operator' => '>', 'compareValue' => 0], |
54
|
|
|
]; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function attributes() |
58
|
|
|
{ |
59
|
|
|
return ['amount', 'currency']; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* {@inheritdoc} |
64
|
|
|
*/ |
65
|
|
|
public function attributeLabels() |
66
|
|
|
{ |
67
|
|
|
return [ |
68
|
|
|
'amount' => Yii::t('merchant', 'Amount'), |
69
|
|
|
'currency' => Yii::t('merchant', 'Currency'), |
70
|
|
|
]; |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|