汇付SDK
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hfpay-lib/src/factory/object/market/OpenAccountRequest.php

78 lines
3.0 KiB

<?php
namespace Tansilu\HfPayLib\factory\object\market;
use Tansilu\HfPayLib\Constant;
use Tansilu\HfPayLib\exception\ParamsException;
use Tansilu\HfPayLib\factory\object\RequestObj;
use Tansilu\HfPayLib\utils\StrFilterHelper;
/**
* @property string $order_date 订单日期
* @property string $order_id 订单号
* @property string $user_name 用户姓名
* @property string $market_type 应用市场
* @property string $acct_usage_type 账户用途
* @property string $id_card 证件号
* @property string $id_card_type 证件类型
* @property string $user_id 用户ID
* @property string $user_mobile 手机号
* @property string $ret_url 页面回调地址
* @property string $mer_priv 商户私有域
* @property string $extension 扩展域
* @property string $bg_ret_url 商户后台应答地址
* @property string $face_license_key 人脸licenseKey
*/
class OpenAccountRequest
{
use RequestObj;
/**
* @throws ParamsException
*/
public function toParams(): array
{
if(empty($this->data['order_date'])) {
throw new ParamsException('订单日期不能为空', 'order_date');
}
if(empty($this->data['order_id'])) {
throw new ParamsException('订单号不能为空', 'order_id');
}
if(empty($this->data['user_name'])) {
throw new ParamsException('用户姓名不能为空', 'user_name');
}
if(empty($this->data['market_type'])) {
throw new ParamsException('应用市场类型不能为空', 'market_type');
}
if(!in_array($this->data['market_type'], [Constant::MARKET_MASTER, Constant::MARKET_SUB])) {
throw new ParamsException('应用市场类型不正确', 'market_type');
}
if(empty($this->data['acct_usage_type'])) {
throw new ParamsException('账户用途不能为空', 'acct_usage_type');
}
if(!in_array($this->data['acct_usage_type'], [Constant::USE_TO_BUY, Constant::USE_TO_TRANS])) {
throw new ParamsException('账户用途类型不正确', 'acct_usage_type');
}
if(empty($this->data['id_card'])) {
throw new ParamsException('证件号不能为空', 'id_card');
}
if(empty($this->data['id_card_type'])) {
throw new ParamsException('证件类型不能为空', 'id_card_type');
}
if(!in_array($this->data['id_card_type'], [Constant::ID_TYPE_CARD])) {
throw new ParamsException('证件类型不支持', 'id_card_type');
}
if(empty($this->data['user_id'])) {
throw new ParamsException('用户ID不能为空', 'user_id');
}
if(!empty($this->data['ret_url'])) {
StrFilterHelper::fileUrl($this->data['ret_url']);
}
if(!empty($this->data['bg_ret_url'])) {
StrFilterHelper::fileUrl($this->data['bg_ret_url']);
}
return $this->data;
}
}