380 lines
14 KiB
PHP
380 lines
14 KiB
PHP
|
|
<?
|
||
|
|
namespace common\payment\structure;
|
||
|
|
use common\Payment;
|
||
|
|
use core\lang\structure\LangVariable as V;
|
||
|
|
use ms\MS;
|
||
|
|
use ms\ms\structure\msLang;
|
||
|
|
use ui\Form;
|
||
|
|
use ui\form\structure\eInputType;
|
||
|
|
use ui\input\Input;
|
||
|
|
|
||
|
|
class ePaymentForm {
|
||
|
|
|
||
|
|
|
||
|
|
static function getForm($payment,$options=[]){
|
||
|
|
$values = $options['values'];
|
||
|
|
$type = intval($payment[Payment::$TYPE]);
|
||
|
|
$payment_id = intval($payment[Payment::$ID]);
|
||
|
|
$type_info = ePaymentType::getArray()[$payment[Payment::$TYPE]];
|
||
|
|
$structure = $type_info['data'];
|
||
|
|
$res = [];
|
||
|
|
switch ($type) {
|
||
|
|
case ePaymentType::UCSCard:
|
||
|
|
$res = self::UCSCard($structure);
|
||
|
|
break;
|
||
|
|
case ePaymentType::ROBOKASSA:
|
||
|
|
$res = self::Robokassa($structure,$values);
|
||
|
|
break;
|
||
|
|
case ePaymentType::KASPI:
|
||
|
|
$res = self::Kaspi($structure,$values);
|
||
|
|
break;
|
||
|
|
case ePaymentType::CLOUDPAYMENTS:
|
||
|
|
$res = self::CloudPayments($structure,$values);
|
||
|
|
break;
|
||
|
|
case ePaymentType::YOOKASSA:
|
||
|
|
$res = self::YooKassa($structure,$values);
|
||
|
|
break;
|
||
|
|
case ePaymentType::DOLYAMI:
|
||
|
|
$res = self::Dolyami($structure,$values);
|
||
|
|
break;
|
||
|
|
case ePaymentType::TINKOFF:
|
||
|
|
$res = self::Tinkoff($structure,$values);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
$res[] = [
|
||
|
|
Form::VIEW => Form::ROW,
|
||
|
|
Form::COLS => [
|
||
|
|
[
|
||
|
|
Form::VIEW => Form::INPUT,
|
||
|
|
Form::TYPE => eInputType::HIDDEN,
|
||
|
|
Form::INPUT_OPT => [
|
||
|
|
Input::NAME=>'controller',
|
||
|
|
Input::VALUE=> Payment::$controller,
|
||
|
|
]
|
||
|
|
],
|
||
|
|
[
|
||
|
|
Form::VIEW => Form::INPUT,
|
||
|
|
Form::TYPE => eInputType::HIDDEN,
|
||
|
|
Form::KEY_VALUE => Payment::$ID,
|
||
|
|
Form::INPUT_OPT => [Input::VALUE=>$payment_id],
|
||
|
|
],
|
||
|
|
[
|
||
|
|
Form::VIEW => Form::INPUT,
|
||
|
|
Form::TYPE => eInputType::HIDDEN,
|
||
|
|
Form::KEY_VALUE => 'save_just_data',
|
||
|
|
Form::INPUT_OPT => [Input::VALUE=>1],
|
||
|
|
],
|
||
|
|
]
|
||
|
|
];
|
||
|
|
$res[] = [
|
||
|
|
Form::VIEW => Form::ROW,
|
||
|
|
Form::COLS => [
|
||
|
|
[
|
||
|
|
Form::VIEW =>Form::INPUT,
|
||
|
|
Form::COL_CLASSES =>'',
|
||
|
|
Form::TYPE =>eInputType::SUBMIT,
|
||
|
|
Form::INPUT_OPT => [
|
||
|
|
Input::CSS_CLASS => MS::CSS_BTN_SAVE,
|
||
|
|
Input::LABEL => $c = V::get(msLang::$BUTTON_SUBMIT),
|
||
|
|
],
|
||
|
|
],
|
||
|
|
],
|
||
|
|
];
|
||
|
|
return $res;
|
||
|
|
}
|
||
|
|
static function Robokassa($structure,$values)
|
||
|
|
{
|
||
|
|
$is_test = boolval($values['is_test']);
|
||
|
|
return [
|
||
|
|
[
|
||
|
|
Form::VIEW => Form::ROW,
|
||
|
|
Form::COLS => [
|
||
|
|
[
|
||
|
|
Form::VIEW => Form::INPUT,
|
||
|
|
Form::COL_CLASSES => 'c-1-3',
|
||
|
|
Form::TYPE => eInputType::TEXT,
|
||
|
|
Form::KEY_VALUE => 'shop_id',
|
||
|
|
Form::INPUT_OPT => [
|
||
|
|
Input::LABEL => $c = $structure['shop_id'],
|
||
|
|
Input::PLACEHOLDER => $c,
|
||
|
|
],
|
||
|
|
],
|
||
|
|
[
|
||
|
|
Form::VIEW => Form::INPUT,
|
||
|
|
Form::COL_CLASSES => 'c-1-3',
|
||
|
|
Form::TYPE => eInputType::SWITCH_IOS,
|
||
|
|
Form::KEY_VALUE => 'is_test',
|
||
|
|
Form::INPUT_OPT => [
|
||
|
|
Input::LABEL => $c = $structure['is_test'],
|
||
|
|
Input::PLACEHOLDER => $c,
|
||
|
|
Input::CHECKED => $is_test,
|
||
|
|
],
|
||
|
|
],
|
||
|
|
],
|
||
|
|
],
|
||
|
|
[
|
||
|
|
Form::VIEW => Form::ROW,
|
||
|
|
Form::COLS => [
|
||
|
|
[
|
||
|
|
Form::VIEW => Form::INPUT,
|
||
|
|
Form::COL_CLASSES => 'c-1-3',
|
||
|
|
Form::TYPE => eInputType::TEXT,
|
||
|
|
Form::KEY_VALUE => 'pass1',
|
||
|
|
Form::INPUT_OPT => [
|
||
|
|
Input::LABEL => $c = $structure['pass1'],
|
||
|
|
Input::PLACEHOLDER => $c,
|
||
|
|
],
|
||
|
|
],
|
||
|
|
[
|
||
|
|
Form::VIEW => Form::INPUT,
|
||
|
|
Form::COL_CLASSES => 'c-1-3',
|
||
|
|
Form::TYPE => eInputType::TEXT,
|
||
|
|
Form::KEY_VALUE => 'pass2',
|
||
|
|
Form::INPUT_OPT => [
|
||
|
|
Input::LABEL => $c = $structure['pass2'],
|
||
|
|
Input::PLACEHOLDER => $c,
|
||
|
|
],
|
||
|
|
],
|
||
|
|
],
|
||
|
|
],
|
||
|
|
[
|
||
|
|
Form::VIEW => Form::ROW,
|
||
|
|
Form::COLS => [
|
||
|
|
[
|
||
|
|
Form::VIEW => Form::INPUT,
|
||
|
|
Form::COL_CLASSES => 'c-1-3',
|
||
|
|
Form::TYPE => eInputType::TEXT,
|
||
|
|
Form::KEY_VALUE => 'test_pass1',
|
||
|
|
Form::INPUT_OPT => [
|
||
|
|
Input::LABEL => $c = $structure['test_pass1'],
|
||
|
|
Input::PLACEHOLDER => $c,
|
||
|
|
],
|
||
|
|
],
|
||
|
|
[
|
||
|
|
Form::VIEW => Form::INPUT,
|
||
|
|
Form::COL_CLASSES => 'c-1-3',
|
||
|
|
Form::TYPE => eInputType::TEXT,
|
||
|
|
Form::KEY_VALUE => 'test_pass2',
|
||
|
|
Form::INPUT_OPT => [
|
||
|
|
Input::LABEL => $c = $structure['test_pass2'],
|
||
|
|
Input::PLACEHOLDER => $c,
|
||
|
|
],
|
||
|
|
],
|
||
|
|
],
|
||
|
|
],
|
||
|
|
];
|
||
|
|
}
|
||
|
|
static function UCSCard($structure){
|
||
|
|
return [
|
||
|
|
$res[] = [
|
||
|
|
Form::VIEW => Form::ROW,
|
||
|
|
Form::COLS => [
|
||
|
|
[
|
||
|
|
Form::VIEW =>Form::INPUT,
|
||
|
|
Form::COL_CLASSES =>'c-1-3',
|
||
|
|
Form::TYPE =>eInputType::TEXT,
|
||
|
|
Form::KEY_VALUE =>'shop_id',
|
||
|
|
Form::INPUT_OPT => [
|
||
|
|
Input::LABEL =>$c = $structure['shop_id'],
|
||
|
|
Input::PLACEHOLDER =>$c ,
|
||
|
|
],
|
||
|
|
],
|
||
|
|
[
|
||
|
|
Form::VIEW =>Form::INPUT,
|
||
|
|
Form::COL_CLASSES =>'c-1-3',
|
||
|
|
Form::TYPE =>eInputType::TEXT,
|
||
|
|
Form::KEY_VALUE =>'shop_login',
|
||
|
|
Form::INPUT_OPT => [
|
||
|
|
Input::LABEL =>$c = $structure['shop_login'],
|
||
|
|
Input::PLACEHOLDER =>$c,
|
||
|
|
],
|
||
|
|
],
|
||
|
|
[
|
||
|
|
Form::VIEW =>Form::INPUT,
|
||
|
|
Form::COL_CLASSES =>'c-1-3',
|
||
|
|
Form::TYPE =>eInputType::TEXT,
|
||
|
|
Form::KEY_VALUE =>'shop_password',
|
||
|
|
Form::INPUT_OPT => [
|
||
|
|
Input::LABEL =>$c = $structure['shop_password'],
|
||
|
|
Input::PLACEHOLDER =>$c ,
|
||
|
|
],
|
||
|
|
],
|
||
|
|
],
|
||
|
|
]
|
||
|
|
];
|
||
|
|
}
|
||
|
|
static function Kaspi($structure,$values){
|
||
|
|
return [
|
||
|
|
$res[] = [
|
||
|
|
Form::VIEW => Form::ROW,
|
||
|
|
Form::COLS => [
|
||
|
|
[
|
||
|
|
Form::VIEW =>Form::INPUT,
|
||
|
|
Form::COL_CLASSES =>'c-1-3',
|
||
|
|
Form::TYPE =>eInputType::TEXT,
|
||
|
|
Form::KEY_VALUE =>'shop_id',
|
||
|
|
Form::INPUT_OPT => [
|
||
|
|
Input::LABEL =>$c = $structure['shop_id'],
|
||
|
|
Input::PLACEHOLDER =>$c ,
|
||
|
|
],
|
||
|
|
],
|
||
|
|
],
|
||
|
|
]
|
||
|
|
];
|
||
|
|
}
|
||
|
|
static function CloudPayments($structure,$values){
|
||
|
|
return [
|
||
|
|
$res[] = [
|
||
|
|
Form::VIEW => Form::ROW,
|
||
|
|
Form::COLS => [
|
||
|
|
[
|
||
|
|
Form::VIEW =>Form::INPUT,
|
||
|
|
Form::COL_CLASSES =>'c-1-3',
|
||
|
|
Form::TYPE =>eInputType::TEXT,
|
||
|
|
Form::KEY_VALUE =>'token',
|
||
|
|
Form::INPUT_OPT => [
|
||
|
|
Input::LABEL =>$c = $structure['token'],
|
||
|
|
Input::PLACEHOLDER =>$c ,
|
||
|
|
],
|
||
|
|
],
|
||
|
|
],
|
||
|
|
]
|
||
|
|
];
|
||
|
|
}
|
||
|
|
static function YooKassa($structure,$values){
|
||
|
|
return [
|
||
|
|
$res[] = [
|
||
|
|
Form::VIEW => Form::ROW,
|
||
|
|
Form::COLS => [
|
||
|
|
[
|
||
|
|
Form::VIEW =>Form::INPUT,
|
||
|
|
Form::COL_CLASSES =>'c-1-3',
|
||
|
|
Form::TYPE =>eInputType::TEXT,
|
||
|
|
Form::KEY_VALUE =>'shop_id',
|
||
|
|
Form::INPUT_OPT => [
|
||
|
|
Input::LABEL =>$c = $structure['shop_id'],
|
||
|
|
Input::PLACEHOLDER =>$c ,
|
||
|
|
],
|
||
|
|
],
|
||
|
|
[
|
||
|
|
Form::VIEW =>Form::INPUT,
|
||
|
|
Form::COL_CLASSES =>'c-1-3',
|
||
|
|
Form::TYPE =>eInputType::TEXT,
|
||
|
|
Form::KEY_VALUE =>'token',
|
||
|
|
Form::INPUT_OPT => [
|
||
|
|
Input::LABEL =>$c = $structure['token'],
|
||
|
|
Input::PLACEHOLDER =>$c ,
|
||
|
|
],
|
||
|
|
],
|
||
|
|
],
|
||
|
|
]
|
||
|
|
];
|
||
|
|
}
|
||
|
|
static function Dolyami($structure,$values){
|
||
|
|
return [
|
||
|
|
$res[] = [
|
||
|
|
Form::VIEW => Form::ROW,
|
||
|
|
Form::COLS => [
|
||
|
|
[
|
||
|
|
Form::VIEW =>Form::INPUT,
|
||
|
|
Form::COL_CLASSES =>'c-1-3',
|
||
|
|
Form::TYPE =>eInputType::TEXT,
|
||
|
|
Form::KEY_VALUE =>'login',
|
||
|
|
Form::INPUT_OPT => [
|
||
|
|
Input::LABEL =>$c = $structure['shop_id'],
|
||
|
|
Input::PLACEHOLDER =>$c ,
|
||
|
|
],
|
||
|
|
],
|
||
|
|
[
|
||
|
|
Form::VIEW =>Form::INPUT,
|
||
|
|
Form::COL_CLASSES =>'c-1-3',
|
||
|
|
Form::TYPE =>eInputType::TEXT,
|
||
|
|
Form::KEY_VALUE =>'pass',
|
||
|
|
Form::INPUT_OPT => [
|
||
|
|
Input::LABEL =>$c = $structure['token'],
|
||
|
|
Input::PLACEHOLDER =>$c ,
|
||
|
|
],
|
||
|
|
],
|
||
|
|
],
|
||
|
|
]
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
static function Tinkoff($structure,$values)
|
||
|
|
{
|
||
|
|
$is_test = boolval($values['is_test']);
|
||
|
|
return [
|
||
|
|
[
|
||
|
|
Form::VIEW => Form::ROW,
|
||
|
|
Form::COLS => [
|
||
|
|
[
|
||
|
|
Form::VIEW => Form::INPUT,
|
||
|
|
Form::COL_CLASSES => 'c-1-3',
|
||
|
|
Form::TYPE => eInputType::SWITCH_IOS,
|
||
|
|
Form::KEY_VALUE => 'is_test',
|
||
|
|
Form::INPUT_OPT => [
|
||
|
|
Input::LABEL => $c = $structure['is_test'],
|
||
|
|
Input::PLACEHOLDER => $c,
|
||
|
|
Input::CHECKED => $is_test,
|
||
|
|
],
|
||
|
|
],
|
||
|
|
],
|
||
|
|
],
|
||
|
|
[
|
||
|
|
Form::VIEW => Form::ROW,
|
||
|
|
Form::COLS => [
|
||
|
|
[
|
||
|
|
Form::VIEW => Form::INPUT,
|
||
|
|
Form::COL_CLASSES => 'c-1-3',
|
||
|
|
Form::TYPE => eInputType::TEXT,
|
||
|
|
Form::KEY_VALUE => 'terminal',
|
||
|
|
Form::INPUT_OPT => [
|
||
|
|
Input::LABEL => $c = $structure['terminal'],
|
||
|
|
Input::PLACEHOLDER => $c,
|
||
|
|
],
|
||
|
|
],
|
||
|
|
[
|
||
|
|
Form::VIEW => Form::INPUT,
|
||
|
|
Form::COL_CLASSES => 'c-1-3',
|
||
|
|
Form::TYPE => eInputType::TEXT,
|
||
|
|
Form::KEY_VALUE => 'pass',
|
||
|
|
Form::INPUT_OPT => [
|
||
|
|
Input::LABEL => $c = $structure['pass'],
|
||
|
|
Input::PLACEHOLDER => $c,
|
||
|
|
],
|
||
|
|
],
|
||
|
|
],
|
||
|
|
],
|
||
|
|
[
|
||
|
|
Form::VIEW => Form::ROW,
|
||
|
|
Form::COLS => [
|
||
|
|
[
|
||
|
|
Form::VIEW => Form::INPUT,
|
||
|
|
Form::COL_CLASSES => 'c-1-3',
|
||
|
|
Form::TYPE => eInputType::TEXT,
|
||
|
|
Form::KEY_VALUE => 'test_terminal',
|
||
|
|
Form::INPUT_OPT => [
|
||
|
|
Input::LABEL => $c = $structure['test_terminal'],
|
||
|
|
Input::PLACEHOLDER => $c,
|
||
|
|
],
|
||
|
|
],
|
||
|
|
[
|
||
|
|
Form::VIEW => Form::INPUT,
|
||
|
|
Form::COL_CLASSES => 'c-1-3',
|
||
|
|
Form::TYPE => eInputType::TEXT,
|
||
|
|
Form::KEY_VALUE => 'test_pass',
|
||
|
|
Form::INPUT_OPT => [
|
||
|
|
Input::LABEL => $c = $structure['test_pass'],
|
||
|
|
Input::PLACEHOLDER => $c,
|
||
|
|
],
|
||
|
|
],
|
||
|
|
],
|
||
|
|
],
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
}
|