| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695 |
- <?php
- namespace addons\HuifuPay\common\service;
- use addons\HuifuPay\common\models\HuifupayPayRequestLog;
- use addons\HuifuPay\common\service\params\HuifuBalancePayParam;
- use addons\HuifuPay\common\service\params\HuifuBalancePayRefundParam;
- use addons\HuifuPay\common\service\params\HuifuFastPayParam;
- use addons\HuifuPay\common\service\params\HuifuBalanceOnlineRefundParam;
- use addons\HuifuPay\common\service\params\HuifuMerchantBusiModifyParam;
- use BsPaySdk\core\BsPay;
- use BsPaySdk\core\BsPayClient;
- use BsPaySdk\core\BsPayTools;
- use BsPaySdk\request\BaseRequest;
- use BsPaySdk\request\V2MerchantBusiOpenRequest;
- use BsPaySdk\request\V2QuickbuckleApplyRequest;
- use BsPaySdk\request\V2QuickbuckleUnbindRequest;
- use BsPaySdk\request\V2TradeAcctpaymentPayRequest;
- use BsPaySdk\request\V2TradeAcctpaymentRefundRequest;
- use BsPaySdk\request\V2TradeHostingPaymentPreorderAliRequest;
- use BsPaySdk\request\V2TradeHostingPaymentPreorderWxRequest;
- use BsPaySdk\request\V2TradeOnlinepaymentTransferAccountRequest;
- use BsPaySdk\request\V2TradePaymentDelaytransConfirmRequest;
- use BsPaySdk\request\V2TradePaymentJspayRequest;
- use BsPaySdk\request\V2TradePaymentScanpayRefundRequest;
- use BsPaySdk\request\V2TradeOnlinepaymentQuickpayApplyRequest;
- use BsPaySdk\request\V2QuickbuckleConfirmRequest;
- use BsPaySdk\request\V2TradeOnlinepaymentQuickpayConfirmRequest;
- use BsPaySdk\request\V2TradeOnlinepaymentRefundRequest;
- use BsPaySdk\request\V2MerchantBusiModifyRequest;
- use BsPaySdk\request\V2UserBasicdataIndvRequest;
- use BsPaySdk\request\V2UserBusiOpenRequest;
- use common\enums\AddonsEnum;
- # 以下配置为开发联调时覆盖SDK的配置项,需在引入SDK的init.php之前配置以覆盖SDK初始配置
- # 设置是否调试模式,不配置默认关闭:false
- define("DEBUG", true);
- # 设置调试日志路径,不配置默认为SDK同级的log目录下
- //define("LOG", dirname(__FILE__) . "/log");
- define("LOG", \Yii::$app->basePath . '/../api/runtime/huifu');
- # 设置生产模式,不配置默认生产模式:true
- //define("PROD_MODE", false);
- # SDK 初始化文件加载
- require_once dirname(__FILE__) . "/../BsPaySdk/init.php";
- require_once dirname(__FILE__) . "/../BsPaySdk/request/V2QuickbuckleApplyRequest.php";
- require_once dirname(__FILE__) . "/../BsPaySdk/request/V2QuickbuckleUnbindRequest.php";
- require_once dirname(__FILE__) . "/../BsPaySdk/request/V2TradePaymentJspayRequest.php";
- require_once dirname(__FILE__) . "/../BsPaySdk/request/V2TradeHostingPaymentPreorderWxRequest.php";
- require_once dirname(__FILE__) . "/../BsPaySdk/request/V2TradePaymentScanpayRefundRequest.php";
- require_once dirname(__FILE__) . "/../BsPaySdk/request/V2TradeOnlinepaymentTransferAccountRequest.php";
- require_once dirname(__FILE__) . "/../BsPaySdk/request/V2TradeHostingPaymentPreorderAliRequest.php";
- require_once dirname(__FILE__) . "/../BsPaySdk/request/V2TradeAcctpaymentPayRequest.php";
- require_once dirname(__FILE__) . "/../BsPaySdk/request/V2TradeAcctpaymentRefundRequest.php";
- require_once dirname(__FILE__) . "/../BsPaySdk/request/V2QuickbuckleConfirmRequest.php";
- require_once dirname(__FILE__) . "/../BsPaySdk/request/V2TradeOnlinepaymentQuickpayApplyRequest.php";
- require_once dirname(__FILE__) . "/../BsPaySdk/request/V2TradeOnlinepaymentQuickpayConfirmRequest.php";
- require_once dirname(__FILE__). "/../BsPaySdk/request/V2TradeOnlinepaymentRefundRequest.php";
- require_once dirname(__FILE__). "/../BsPaySdk/request/V2TradePaymentDelaytransConfirmRequest.php";
- require_once dirname(__FILE__). "/../BsPaySdk/request/V2MerchantBusiModifyRequest.php";
- require_once dirname(__FILE__). "/../BsPaySdk/request/V2MerchantBusiOpenRequest.php";
- require_once dirname(__FILE__). "/../BsPaySdk/request/V2UserBusiOpenRequest.php";
- require_once dirname(__FILE__). "/../BsPaySdk/request/V2UserBasicdataIndvRequest.php";
- use common\traits\ErrorTrait;
- use ReflectionClass;
- use RuntimeException;
- use yii\db\Exception;
- use \Yii;
- class HuifuService
- {
- use ErrorTrait;
- public $public_key = '';
- public $config = [];
- public $mall_id;
- public $requestId;
- public function __construct($mall_id = null)
- {
- if (!empty($mall_id)) {
- $this->config = \Yii::$app->services->setting->addons->get($mall_id, AddonsEnum::ADDONS_NAME_HUIFU_PAY, 'basic');
- # init方法,从 config.json 加载系统参数
- $config = [
- 'sys_id' => $this->config['huifupay_sys_id'],
- 'product_id' => $this->config['huifupay_product_id'],
- 'rsa_merch_private_key' => $this->config['huifupay_private_key'],
- 'rsa_huifu_public_key' => $this->config['huifupay_public_key'],
- ];
- $this->public_key = "-----BEGIN PUBLIC KEY-----\n" . wordwrap($this->config['huifupay_public_key'], 64, "\n", true) . "\n-----END PUBLIC KEY-----";
- BsPay::init($config, true);
- $this->mall_id = $mall_id;
- }
- }
- public function verifySign($signature, $data)
- {
- return BsPayTools::verifySign_sort($signature, $data, $this->config['huifupay_public_key']);
- }
- /**
- * 作者:zengfanhua
- * 创建时间:2024/05/29 12:59:02
- * 大额转账要素切换
- * 01-四要素(卡号,户名,金额,调账标识),05-三要素(金额+姓名+12位纯数字打款标识);示例值:01
- */
- //
- public function merchantBusiBigPayModify($type='05')
- {
- // 2.组装请求参数
- $request = new V2MerchantBusiModifyRequest();
- // 请求流水号
- $request->setReqSeqId(date("YmdHis") . mt_rand());
- // 请求日期
- $request->setReqDate(date("Ymd"));
- // 汇付客户Id
- $request->setHuifuId($this->config['huifupay_huifu_id']);
- // 设置非必填字段
- $param['biz_type']=$type;
- $extendInfoMap = HuifuMerchantBusiModifyParam::getExtendInfosNoInfo($param);
- $request->setExtendInfo($extendInfoMap);
- // 3. 发起API调用
- $result = $this->postRequest($request);
- if (!$result || $result->isError()) { //失败处理
- throw new Exception($result->getErrorInfo());
- } else { //成功处理
- $resData = $result->getRspDatas();
- $resData = $resData['data'];
- if ($resData['resp_code'] == '00000000' || $resData['resp_code'] == '00000100') {
- return $resData;
- }
- throw new Exception($resData['resp_desc']);
- }
- }
- /**
- * 作者:zengfanhua
- * 创建时间:2024/01/08 12:59:02
- * 余额支付(这是一个同步响应操作)
- */
- public function balancePay($data, $splitAccount = [])
- {
- // 2.组装请求参数
- $request = new V2TradeAcctpaymentPayRequest();
- // 请求流水号
- $request->setReqSeqId(date("YmdHis") . mt_rand());
- // 请求日期
- $request->setReqDate(date("Ymd"));
- // 出款方商户号
- $request->setOutHuifuId($data['huifu_id']);
- // 支付金额
- $request->setOrdAmt($data['amount']);
- // 分账对象
- $request->setAcctSplitBunch(HuifuBalancePayParam::getAcctSplitBunch($splitAccount));
- // 安全信息
- $request->setRiskCheckData(HuifuBalancePayParam::getRiskCheckData());
- // 设置非必填字段
- $extendInfoMap = HuifuBalancePayParam::getExtendInfos();
- $request->setExtendInfo($extendInfoMap);
- // 3. 发起API调用
- $result = $this->postRequest($request);
- if (!$result || $result->isError()) { //失败处理
- throw new Exception($result->getErrorInfo());
- } else { //成功处理
- $resData = $result->getRspDatas();
- $resData = $resData['data'];
- if ($resData['resp_code'] == '00000000' || $resData['resp_code'] == '00000100') {
- return $resData;
- }
- throw new Exception($resData['resp_desc']);
- }
- }
- /**
- * 作者:zengfanhua
- * 创建时间:2024/01/08 12:59:02
- * 余额支付退款
- */
- public function balanceReturn($data, $splitAccount)
- {
- // 2.组装请求参数
- $request = new V2TradeAcctpaymentRefundRequest();
- // 请求流水号
- $request->setReqSeqId(date("YmdHis") . mt_rand());
- // 请求日期
- $request->setReqDate(date("Ymd"));
- // 商户号
- $request->setHuifuId($data['huifu_id']);
- // 原余额支付请求日期org_hf_seq_id和(orgReqDate+orgReqSeqId)二选一;<br/>格式:yyyyMMdd;<font color="green">示例值:20221023</font>
- $request->setOrgReqDate($data['old_req_date']);
- // 原余额支付请求流水号org_hf_seq_id和(orgReqDate+orgReqSeqId)二选一;<br/><font color="green">示例值:2021091708126665001</font>
- $request->setOrgReqSeqId($data['org_req_seq_id']);
- // 原余额支付支付全局流水号org_hf_seq_id和(orgReqDate+orgReqSeqId)二选一;<br/><font color="green">示例值:00470topo1A211015160805P090ac132fef00000</font>
- $request->setOrgHfSeqId("");
- // 退款金额
- $request->setOrdAmt($data['amount']);
- // 设置非必填字段
- $extendInfoMap = HuifuBalancePayRefundParam::getExtendInfos($splitAccount);
- if (!empty($data['delay_acct_flag'])) $extendInfoMap['delay_acct_flag'] = $data['delay_acct_flag'];
- $request->setExtendInfo($extendInfoMap);
- // 3. 发起API调用
- $result = $this->postRequest($request);
- if (!$result || $result->isError()) { //失败处理
- throw new Exception($result->getErrorInfo());
- } else { //成功处理
- $resData = $result->getRspDatas();
- $resData = $resData['data'];
- if ($resData['resp_code'] == '00000000' || $resData['resp_code'] == '00000100') {
- return $resData;
- }
- throw new Exception($resData['resp_desc']);
- }
- }
- /**
- * 大额支付
- */
- public function bigPay($notify_url, $data)
- {
- // 2.组装请求参数
- $request = new V2TradeOnlinepaymentTransferAccountRequest();
- // 请求流水号
- $request->setReqSeqId(date("YmdHis") . mt_rand());
- // 请求日期
- $request->setReqDate(date("Ymd"));
- // 收款方商户号
- $request->setHuifuId($data['huifu_id']);
- // 交易金额
- $request->setTransAmt($data['amount']);
- // 商品描述
- $request->setGoodsDesc($data['goods_title']);
- //基本信息
- $extendInfoMap = array();
- // // 收款方用户客户号
- //$extendInfoMap["user_huifu_id"] = $data['huifu_id'];
- // // 收款方账户号
- // $extendInfoMap["acct_id"] = "";
- // 付款方名称
- $extendInfoMap["certificate_name"] = $data['real_name'];
- // 付款方银行卡号
- $extendInfoMap["bank_card_no"] = BsPayTools::encrypt_with_rsa_pubkey($data['bank_card_no'], $this->config['huifupay_public_key']);
- // 订单类型
- // $extendInfoMap["order_type"]= "";
- // 备注
- $extendInfoMap["remark"] = "";
- // 异步通知地址
- $extendInfoMap["notify_url"] = $notify_url;
- if (!empty($data['delay_acct_flag'])) $extendInfoMap['delay_acct_flag'] = $data['delay_acct_flag'];
- // 设置非必填字段
- $request->setExtendInfo($extendInfoMap);
- // 3. 发起API调用
- $result = $this->postRequest($request);
- if (!$result || $result->isError()) { //失败处理
- throw new Exception($result->getErrorInfo());
- } else { //成功处理
- $resData = $result->getRspDatas();
- $resData = $resData['data'];
- if ($resData['resp_code'] == '00000000' || $resData['resp_code'] == '00000100') {
- return $resData;
- }
- throw new Exception($resData['resp_desc']);
- }
- }
- /**
- * 作者:zengfanhua
- * 创建时间:2024/01/03 15:44:57
- * 线上交易退款
- */
- public function onlineRefund($data, $splitAccount = [])
- {
- // 2.组装请求参数
- $request = new V2TradeOnlinepaymentRefundRequest();
- // 请求日期
- $request->setReqDate(date("Ymd"));
- // 请求流水号
- $request->setReqSeqId(date("YmdHis") . mt_rand());
- // 商户号
- $request->setHuifuId($data['huifu_id']);
- // 退款金额
- $request->setOrdAmt($data['amount']);
- // 设备信息
- $request->setTerminalDeviceData(HuifuBalanceOnlineRefundParam::getTerminalDeviceData());
- // 安全信息
- $request->setRiskCheckData(HuifuBalanceOnlineRefundParam::getRiskCheckData());
- // 设置非必填字段
- $extendInfoMap = HuifuBalanceOnlineRefundParam::getExtendInfos($data,$splitAccount);
- $request->setExtendInfo($extendInfoMap);
- // 3. 发起API调用
- $result = $this->postRequest($request);
- if (!$result || $result->isError()) { //失败处理
- throw new Exception($result->getErrorInfo());
- } else { //成功处理
- $resData = $result->getRspDatas();
- $resData = $resData['data'];
- if ($resData['resp_code'] == '00000000' || $resData['resp_code'] == '00000100') {
- return $resData;
- }
- throw new Exception($resData['resp_desc']);
- }
- }
- /**
- * 作者:zengfanhua
- * 创建时间:2024/01/03 15:44:57
- * 扫码交易退款
- */
- public function refund($data, $splitAccount = [])
- {
- // 2.组装请求参数
- $request = new V2TradePaymentScanpayRefundRequest();
- // 请求日期
- $request->setReqDate(date("Ymd"));
- // 请求流水号
- $request->setReqSeqId(date("YmdHis") . mt_rand());
- // 商户号
- $request->setHuifuId($data['huifu_id']);
- // 申请退款金额
- $request->setOrdAmt($data['amount']);
- // 原交易请求日期
- $request->setOrgReqDate($data['old_req_date']);
- // 设置非必填字段
- $extendInfoMap = HuifuRefundParam::getExtendInfos($data['org_req_seq_id'], $splitAccount);
- $request->setExtendInfo($extendInfoMap);
- // 3. 发起API调用
- $result = $this->postRequest($request);
- if (!$result || $result->isError()) { //失败处理
- throw new Exception($result->getErrorInfo());
- } else { //成功处理
- $resData = $result->getRspDatas();
- $resData = $resData['data'];
- if ($resData['resp_code'] == '00000000' || $resData['resp_code'] == '00000100') {
- return $resData;
- }
- throw new Exception($resData['resp_desc']);
- }
- }
- /**
- * 作者:zengfanhua-支付托管
- * 创建时间:2023/12/30 10:27:21
- * 微信小程序预下单接口
- * @data 数据
- * @notify_url 通知地址
- * @expireDate 过期时间
- * @return array
- */
- public function preWxOrder($data, $notify_url, $expireDate, $splitAccount = [])
- {
- // 2.组装请求参数
- $request = new V2TradeHostingPaymentPreorderWxRequest();
- // 预下单类型
- $request->setPreOrderType("3");
- // 请求日期
- $request->setReqDate(date("Ymd"));
- // 请求流水号
- $request->setReqSeqId(date("YmdHis") . mt_rand());
- // 商户号
- $request->setHuifuId($data['huifu_id']);
- // 交易金额
- $request->setTransAmt($data['amount']);
- // 商品描述
- $request->setGoodsDesc($data['goods_title']);
- // 微信小程序扩展参数集合
- $request->setMiniappData(HuifuPreOrderParam::getMiniappDataRucan());
- // 设置非必填字段
- $extendInfoMap = HuifuPreOrderParam::getExtendInfos($expireDate, $notify_url, $splitAccount);
- if (!empty($data['delay_acct_flag'])) $extendInfoMap['delay_acct_flag'] = $data['delay_acct_flag'];
- $request->setExtendInfo($extendInfoMap);
- // 3. 发起API调用
- $result = $this->postRequest($request);
- if (!$result || $result->isError()) { //失败处理
- throw new Exception(is_string($result->getErrorInfo()) ? $result->getErrorInfo() : var_export($result->getErrorInfo(), true));
- } else { //成功处理
- $resData = $result->getRspDatas();
- $resData = $resData['data'];
- if ($resData['resp_code'] == '00000000' || $resData['resp_code'] == '00000100') {
- return $resData;
- }
- throw new Exception($resData['resp_desc']);
- }
- }
- /**
- * 支付产品
- * @param $data
- * @param $notify_url
- * @param $expireDate
- * @param $splitAccount
- * @return mixed
- * @throws Exception
- */
- public function preWxOrder2($data, $notify_url, $expireDate, $splitAccount = [])
- {
- try {
- // 2.组装请求参数
- $request = new V2TradePaymentJspayRequest();
- // 请求流水号
- $request->setReqSeqId(date("YmdHis") . mt_rand());
- // 请求日期
- $request->setReqDate(date("Ymd"));
- // 汇付ID
- $request->setHuifuId($data['huifu_id']);
- // 交易金额
- $request->setTransAmt($data['amount']);
- // 商品描述
- $request->setGoodsDesc($data['goods_title']);
- $request->setTradeType($data['trade_type']);
- // 微信参数集合
- $request->setWxData(HuifuJsPayParam::getWxData($data['mall_id'],$data['open_id']));
- // 设置非必填字段
- $extendInfoMap = HuifuPreOrderParam::getExtendInfos($expireDate, $notify_url, $splitAccount);
- if (!empty($data['delay_acct_flag'])) $extendInfoMap['delay_acct_flag'] = $data['delay_acct_flag'];
- $request->setExtendInfo($extendInfoMap);
- // 3. 发起API调用
- $result = $this->postRequest($request);
- if (!$result || $result->isError()) { //失败处理
- throw new Exception(is_string($result->getErrorInfo()) ? $result->getErrorInfo() : var_export($result->getErrorInfo(), true));
- } else { //成功处理
- $resData = $result->getRspDatas();
- $resData = $resData['data'];
- if ($resData['resp_code'] == '00000000' || $resData['resp_code'] == '00000100') {
- return $resData;
- }
- throw new Exception($resData['resp_code'].$resData['resp_desc']);
- }
- }catch (\Exception $e){
- throw new Exception($e->getMessage());
- }
- }
- /**
- * 作者:zengfanhua
- * 创建时间:2023/12/30 10:27:21
- * 支付宝预下单接口
- * @data 数据
- * @notify_url 通知地址
- * @expireDate 过期时间
- * @return array
- */
- public function preAliOrder($data, $notify_url, $expireDate, $splitAccount = [])
- {
- // 2.组装请求参数
- $request = new V2TradeHostingPaymentPreorderAliRequest();
- // 预下单类型
- $request->setPreOrderType("2");
- // 请求日期
- $request->setReqDate(date("Ymd"));
- // 请求流水号
- $request->setReqSeqId(date("YmdHis") . mt_rand());
- // 商户号
- $request->setHuifuId($data['huifu_id']);
- // 交易金额
- $request->setTransAmt($data['amount']);
- // 商品描述
- $request->setGoodsDesc($data['goods_title']);
- // app扩展参数集合
- $dto = array();
- // 小程序返回码
- $dto["app_schema"] = "app跳转链接";
- // 私有信息
- // $dto["private_info"] = "";
- $request->setAppData(json_encode($dto, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
- // 设置非必填字段
- $extendInfoMap = HuifuPreOrderParam::getExtendInfos($expireDate, $notify_url, $splitAccount);
- if (!empty($data['delay_acct_flag'])) $extendInfoMap['delay_acct_flag'] = $data['delay_acct_flag'];
- $request->setExtendInfo($extendInfoMap);
- // 3. 发起API调用
- $result = $this->postRequest($request);
- if (!$result || $result->isError()) { //失败处理
- throw new Exception(is_string($result->getErrorInfo()) ? $result->getErrorInfo() : var_export($result->getErrorInfo(), true));
- } else { //成功处理
- $resData = $result->getRspDatas();
- $resData = $resData['data'];
- if ($resData['resp_code'] == '00000000' || $resData['resp_code'] == '00000100') {
- return $resData;
- }
- throw new Exception($resData['resp_desc']);
- }
- }
- /**
- * 作者:zengfanhua
- * 创建时间:2023/12/28 13:02:41
- * 聚合正扫接口
- * @data 数据
- * @notify_url 通知地址
- * @expireDate 过期时间
- * @wxData 微信扩展信息
- * @alipayData 支付宝扩展信息
- */
- public function jsPay($data, $notify_url, $expireDate, $splitAccount = [], $wxData = [], $alipayData = [])
- {
- // 2.组装请求参数
- $request = new V2TradePaymentJspayRequest();
- // 请求日期
- $request->setReqDate(date("Ymd"));
- // 请求流水号
- $request->setReqSeqId(date("YmdHis") . mt_rand());
- // 商户号
- $request->setHuifuId($this->config['huifu_id']);
- // 商品描述
- $request->setGoodsDesc($data['goods_title']);
- // 交易类型
- $request->setTradeType($data['trade_type']);
- // 交易金额
- $request->setTransAmt($data['amount']);
- // 设置非必填字段
- $extendInfoMap = HuifuJsPayParam::getExtendInfos($notify_url, $wxData, $alipayData, $expireDate, $splitAccount = []);
- if (!empty($data['delay_acct_flag'])) $extendInfoMap['delay_acct_flag'] = $data['delay_acct_flag'];
- $request->setExtendInfo($extendInfoMap);
- // 3. 发起API调用
- $result = $this->postRequest($request);
- if (!$result || $result->isError()) { //失败处理
- throw new Exception($result->getErrorInfo());
- } else { //成功处理
- $resData = $result->getRspDatas();
- $resData = $resData['data'];
- if ($resData['resp_code'] == '00000000' || $resData['resp_code'] == '00000100') {
- return $resData;
- }
- throw new Exception($resData['resp_desc']);
- }
- }
- /**
- * 作者:zengfanhua
- * 创建时间:2023/12/28 13:05:32
- * 签约银行卡
- * @param array data UserBankCard->id
- * @throws Exception
- * @return bool
- */
- public function signCard($data)
- {
- // 2.组装请求参数
- $request = new V2QuickbuckleApplyRequest;
- // 请求日期
- $request->setReqDate(date("Ymd"));
- // 请求流水号
- $request->setReqSeqId(date("YmdHis") . mt_rand());
- // 汇付客户Id
- $request->setHuifuId($data['huifu_id']);
- // 商户用户id
- $request->setOutCustId($data['user_id']);
- // 订单号
- $request->setOrderId($data['order_no']);
- // 订单日期
- $request->setOrderDate(date("Ymd"));
- // 银行卡号
- $card_id_rsa = BsPayTools::encrypt_with_rsa_pubkey($data['bank_card_no'], $this->config['huifupay_public_key']);
- $request->setCardId($card_id_rsa);
- // 银行卡开户姓名
- $real_name_rsa = BsPayTools::encrypt_with_rsa_pubkey($data['payer_name'], $this->config['huifupay_public_key']);
- $request->setCardName($real_name_rsa);
- // 银行卡绑定证件类型
- $request->setCertType("00");
- // 银行卡绑定身份证
- $user_id_rsa = BsPayTools::encrypt_with_rsa_pubkey($data['id_no'], $this->config['huifupay_public_key']);
- $request->setCertId($user_id_rsa);
- // 个人证件有效期类型
- $request->setCertValidityType($data['is_longer'] ? "1" : '0');
- // 个人证件有效期起始日
- $request->setCertBeginDate(str_replace('-', '', $data['sdate']));
- // 个人证件有效期到期日长期有效不填;<font color="green">示例值:20420905</font>
- $request->setCertEndDate($data['is_longer'] ? '' : str_replace('-', '', $data['edate']));
- // 银行卡绑定手机号
- $mobile_rsa = BsPayTools::encrypt_with_rsa_pubkey($data['mobile_no'], $this->config['huifupay_public_key']);
- $request->setCardMp($mobile_rsa);
- // CVV2信用卡交易专用需要密文传输。<br/>使用汇付RSA公钥加密(加密前3位,加密后最长2048位),[参见参考文档](https://paas.huifu.com/partners/guide/#/api_jiami_jiemi);<br/><font color="green">示例值:Ly+fnExeyPOTzfOtgRRur77nJB9TAe4PGgK9M……fc6XJXZss=</font>
- $request->setVipCode('');
- // 卡有效期信用卡交易专用,格式:MMYY,需要密文传输;<br/>使用汇付RSA公钥加密(加密前4位,加密后最长2048位),[参见参考文档](https://paas.huifu.com/partners/guide/#/api_jiami_jiemi);<br/><font color="green">示例值:Ly+fnExeyPOTzfOtgRRur77nJB9TAe4PGgK9M……fc6XJXZss=JXZss=</font>
- // $request->setExpiration("test");
- // 挂网协议编号授权信息(招行绑卡需要上送);<font color="green">示例值:34463343</font>
- // $request->setProtocolNo("test");
- // 设备信息域
- // $request->setTrxDeviceInf(getTrxDeviceInf());
- // 设置非必填字段
- $extendInfoMap = HuifuSignParam::getExtendInfos();
- $request->setExtendInfo($extendInfoMap);
- // 3. 发起API调用
- $result = $this->postRequest($request);
- if (!$result || $result->isError()) { //失败处理
- throw new Exception($result->getErrorInfo());
- } else { //成功处理
- $resData = $result->getRspDatas();
- $resData = $resData['data'];
- if ($resData['resp_code'] == '00000000' || $resData['resp_code'] == '00000100') {
- return $resData;
- }
- throw new Exception($resData['resp_desc']);
- }
- }
- /**
- * 解绑银行卡
- * @param $data
- * @return true
- */
- public function unbindBankCard($data)
- {
- try {
- $request = new V2QuickbuckleUnbindRequest;
- // 请求日期
- $request->setReqDate(date("Ymd"));
- // 请求流水号
- $request->setReqSeqId(date("YmdHis") . mt_rand());
- // 请求商户Id
- $request->setHuifuId($data['huifu_id']);
- // 商户用户id
- $request->setOutCustId($data['user_id']);
- // 银行卡号卡密
- $request->setTokenNo($data['sign_no']);
- $client = new BsPayClient();
- $result = $client->postRequest($request);
- if (!$result || $result->isError()) { //失败处理
- throw new Exception($result->getErrorInfo());
- } else { //成功处理
- $resData = $result->getRspDatas();
- $resData = $resData['data'];
- if ($resData['resp_code'] == '00000000' || $resData['trans_status'] == 'S') {
- return true;
- }
- throw new Exception($resData['resp_desc']);
- }
- } catch (\Exception $e) {
- Yii::$app->custom->logs('请求错误', $e->getMessage());
- throw new \Exception($e->getMessage());
- }
- }
- /**
- * 作者:zengfanhua
- * 创建时间:2023/12/28 13:05:32
- * 确认绑定
- * @param array data UserBankCard->id
- * @throws Exception
- * @return bool
- */
- public function confirmBindSms($data)
- {
- // 2.组装请求参数
- $request = new V2QuickbuckleConfirmRequest();
- // 请求日期
- $request->setReqDate(date("Ymd"));
- // 请求流水号
- $request->setReqSeqId(date("YmdHis") . mt_rand());
- // 汇付商户Id
- $request->setHuifuId($data['huifu_id']);
- // 用户id
- $request->setOutCustId($data['user_id']);
- // 订单号
- $request->setOrderId($data['order_no']);
- // 订单日期
- $request->setOrderDate(date("Ymd"));
- // 银行卡号
- $card_id_rsa = BsPayTools::encrypt_with_rsa_pubkey($data['bank_card_no'], $this->config['huifupay_public_key']);
- $request->setCardId($card_id_rsa);
- // 银行卡开户姓名
- $real_name_rsa = BsPayTools::encrypt_with_rsa_pubkey($data['payer_name'], $this->config['huifupay_public_key']);
- $request->setCardName($real_name_rsa);
- // 银行卡绑定证件类型
- $request->setCertType("00");
- // 银行卡绑定身份证
- $user_id_rsa = BsPayTools::encrypt_with_rsa_pubkey($data['id_no'], $this->config['huifupay_public_key']);
- $request->setCertId($user_id_rsa);
- // 银行卡绑定手机号
- $mobile_rsa = BsPayTools::encrypt_with_rsa_pubkey($data['mobile_no'], $this->config['huifupay_public_key']);
- $request->setCardMp($mobile_rsa);
- // 验证码
- $request->setVerifyCode($data['code']);
- // CVV2信用卡代扣专用需要密文传输,使用汇付RSA公钥加密(加密前3位,加密后最长2048位),[参见参考文档](https://paas.huifu.com/partners/guide/#/api_jiami_jiemi);<br/><font color="green">示例值:Ly+fnExeyPOTzf……rGq0l0NTebfc6XJXZss=</font>
- //$request->setVipCode("BndOZvPCXIMcRJi1uCkw4DiNHht+KkARa+sbKbiLh4cXhjywxYM8GMl7g1a5cc1aD2PD6rVvnGzhhgpJ8mzeb/gbzNcYbU5hEXJZm5HShghGucQJB/SoqCIlyaWlz3hnclaGzznWJa5qNa50mCxVqX4zbpuGPWXv+8AnYTu8/Vk=");
- // 卡有效期信用卡代扣专用,格式:MMYY,需要密文传输。<br/>使用汇付RSA公钥加密(加密前4位,加密后最长2048位),[参见参考文档](https://paas.huifu.com/partners/guide/#/api_jiami_jiemi);<br/><font color="green">示例值:Ly+fnExeyPO……ebfc6XJXZss=</font>
- // $request->setExpiration("test");
- // 设备信息域
- // $request->setTrxDeviceInf(getTrxDeviceInf());
- // 设置非必填字段
- $extendInfoMap = array();
- // 商户名称
- //$extendInfoMap["merch_name"] = "测试";
- // 验卡流水号
- $extendInfoMap["trans_id"] = $data['trans_id'];
- // 卡的借贷类型
- // $extendInfoMap["dc_type"]= "";
- // 风控信息
- // $extendInfoMap["risk_info"]= getRiskInfo();
- $request->setExtendInfo($extendInfoMap);
- // 3. 发起API调用
- $result = $this->postRequest($request);
- if (!$result || $result->isError()) { //失败处理
- throw new Exception($result->getErrorInfo());
- } else { //成功处理
- $resData = $result->getRspDatas();
- $resData = $resData['data'];
- if ($resData['resp_code'] == '00000000' || $resData['resp_code'] == '00000100') {
- return $resData;
- }
- throw new Exception($resData['resp_desc']);
- }
- }
- /**
- * 作者:zengfanhua
- * 创建时间:2023/12/28 13:05:32
- * 发送快捷支付短信
- * @param array data UserBankCard->id
- * @throws Exception
- * @return bool
- */
- public function sendPaySms($data, $notify_url, $expireDate, $splitAccount = [])
- {
- // 2.组装请求参数
- $request = new V2TradeOnlinepaymentQuickpayApplyRequest();
- // 请求日期
- $request->setReqDate(date("Ymd"));
- // 请求流水号
- $request->setReqSeqId(date("YmdHis") . mt_rand());
- // 汇付商户Id
- $request->setHuifuId($data['huifu_id']);
- // 用户客户号
- $request->setUserHuifuId($data['cust_id']);
- // 绑卡id
- $request->setCardBindId($data['sign_no']);
- // 订单金额
- $request->setTransAmt($data['amount']);
- // 银行扩展字段
- $request->setExtendPayData(HuifuFastPayParam::getExtendPayData());
- // 安全信息
- $request->setRiskCheckData(HuifuFastPayParam::getRiskCheckData());
- // 设备数据
- $request->setTerminalDeviceData(HuifuFastPayParam::getTerminalDeviceData());
- // 异步通知地址
- $request->setNotifyUrl($notify_url);
- // 设置非必填字段
- $extendInfoMap = HuifuFastPayParam::getExtendInfos($splitAccount, $expireDate);
- if (!empty($data['delay_acct_flag'])) $extendInfoMap['delay_acct_flag'] = $data['delay_acct_flag'];
- $request->setExtendInfo($extendInfoMap);
- // 3. 发起API调用
- $result = $this->postRequest($request);
- if (!$result || $result->isError()) { //失败处理
- throw new Exception($result->getErrorInfo());
- } else { //成功处理
- $resData = $result->getRspDatas();
- $resData = $resData['data'];
- if ($resData['resp_code'] == '00000000' || $resData['resp_code'] == '00000100') {
- return $resData;
- }
- throw new Exception($resData['resp_desc']);
- }
- }
- /**
- * 作者:zengfanhua
- * 创建时间:2023/12/28 13:05:32
- * 发送快捷支付短信确认
- * @param array data UserBankCard->id
- * @throws Exception
- * @return bool
- */
- public function sendPaySmsConfirm($data, $notify_url)
- {
- // 2.组装请求参数
- $request = new V2TradeOnlinepaymentQuickpayConfirmRequest();
- // 请求日期
- $request->setReqDate(date("Ymd"));
- // 请求流水号
- $request->setReqSeqId($data['order_id']);
- // 商户号
- $request->setHuifuId($data['huifu_id']);
- // 短信验证码
- $request->setSmsCode($data['sms_code']);
- // 商品描述
- $request->setGoodsDesc($data['goods_title']);
- // 外部地址
- $request->setNotifyUrl($notify_url);
- $extendInfoMap = [];
- if (!empty($data['delay_acct_flag'])) $extendInfoMap['delay_acct_flag'] = $data['delay_acct_flag'];
- // 设置非必填字段
- $request->setExtendInfo($extendInfoMap);
- // 3. 发起API调用
- $result = $this->postRequest($request);
- if (!$result || $result->isError()) { //失败处理
- throw new Exception($result->getErrorInfo());
- } else { //成功处理
- $resData = $result->getRspDatas();
- $resData = $resData['data'];
- if ($resData['resp_code'] == '00000000' || $resData['resp_code'] == '00000100') {
- return $resData;
- }
- throw new Exception($resData['resp_desc']);
- }
- }
- // 单独分账
- public function shareCommission($data, $splitAccount)
- {
- $request = new V2TradePaymentDelaytransConfirmRequest();
- // 请求日期
- $request->setReqDate(date("Ymd"));
- // 请求流水号
- $request->setReqSeqId($data['order_id']);
- // 商户号
- $request->setHuifuId($data['huifu_id']);
- // 订单编号
- $request->setOrgMerOrdId($data['trade_no']);
- $extendInfoMap["acct_split_bunch"] = HuifuPreOrderParam::getAcctSplitBunchRucan($splitAccount);
- // 原交易为快捷支付必填:QUICK_PAY,
- // 原交易为余额支付必填:ACCT_PAYMENT;
- if (!empty($data['pay_type'])) $extendInfoMap["pay_type"] = $data['pay_type'];
- // $extendInfoMap['org_mer_ord_id'] = $data['trade_no'];
- $extendInfoMap['org_req_date'] = $data['org_req_date'];
- $extendInfoMap['org_req_seq_id'] = $data['org_req_seq_id'];
- $request->setExtendInfo($extendInfoMap);
- // 3. 发起API调用
- $result = $this->postRequest($request);
- if (!$result || $result->isError()) { //失败处理
- // throw new \Exception(is_string($result->getErrorInfo()) ? $result->getErrorInfo() : var_export($result->getErrorInfo(), true));
- self::$static_error = !empty($result) ? (is_string($result->getErrorInfo()) ? $result->getErrorInfo() :
- var_export($result->getErrorInfo(), true)) : '未获取到响应数据';
- return false;
- } else { //成功处理
- $resData = $result->getRspDatas();
- $resData = $resData['data'];
- if ($resData['resp_code'] == '00000000' || $resData['resp_code'] == '00000100') {
- return $resData;
- }
- self::$static_error = $resData;
- return false;
- // throw new \Exception($resData['resp_desc']);
- }
- }
- /**
- * @param $data
- * @return false|mixed
- * @throws Exception
- * @author 史晨
- * @date 2025/9/25 11:22
- * 个人用户开户
- */
- public function userIndv($data)
- {
- $request = new V2UserBasicdataIndvRequest();
- // 请求流水号
- $request->setReqSeqId(date("YmdHis") . mt_rand());
- // 请求日期
- $request->setReqDate(date("Ymd"));
- // 个人姓名
- $request->setName($data['card_name']);
- // 个人证件类型
- $request->setCertType('00');
- // 个人证件号码
- $request->setCertNo($data['cert_no']);
- // 个人证件有效期类型
- $request->setCertValidityType($data['cert_validity_type']);
- // 个人证件有效期开始日期
- $request->setCertBeginDate($data['cert_begin_date']);
- // 个人证件有效期截止日期
- $request->setCertEndDate($data['cert_end_date']);
- // 手机号
- $request->setMobileNo($data['mp']);
- // 发送请求
- $result = $this->postRequest($request);
- if (!$result || $result->isError()) { //失败处理
- throw new Exception($result->getErrorInfo());
- } else { //成功处理
- $resData = $result->getRspDatas();
- $resData = $resData['data'];
- if ($resData['resp_code'] == '00000000' || $resData['resp_code'] == '00000100') {
- return $resData;
- }
- return $resData['resp_desc'];
- }
- }
- /**
- * @param $data
- * @param $huifuId
- * @return mixed
- * @throws Exception
- * @author 史晨
- * @date 2025/9/25 15:18
- * 用户业务入驻
- */
- public function userBusiOpen($data,$huifuId)
- {
- $request = new V2UserBusiOpenRequest();
- // 汇付ID
- $request->setHuifuId($huifuId);
- // 请求流水号
- $request->setReqSeqId(date("YmdHis") . mt_rand());
- // 请求日期
- $request->setReqDate(date("Ymd"));
- // 渠道商/商户汇付Id
- $request->setUpperHuifuId($this->config['huifupay_huifu_id']);
- // 结算卡信息
- $request->setCardInfo(json_encode($data));
- $result = $this->postRequest($request);
- if (!$result || $result->isError()) { //失败处理
- throw new Exception($result->getErrorInfo());
- } else { //成功处理
- $resData = $result->getRspDatas();
- $resData = $resData['data'];
- if ($resData['resp_code'] == '00000000' || $resData['resp_code'] == '00000100') {
- return $resData;
- }
- return $resData['resp_desc'];
- }
- }
- /**
- * 发起post请求,并记录请求日志
- *
- * @param BaseRequest $request
- *
- * @return BsPay
- */
- public function postRequest($request)
- {
- $client = new BsPayClient();
- /** @var $result BsPay */
- $result = $client->postRequest($request);
- // 写入接口请求日志
- try {
- if (is_object($result)) {
- $logRes = HuifupayPayRequestLog::setData(
- $this->mall_id,
- [
- 'mall_id' => $this->mall_id,
- 'url' => $result->getUrl() ?: '',
- 'path' => (new ReflectionClass($request))->getShortName(),
- 'method' => 'post',
- 'request_data' => $result->getReqDatas() ?: [],
- 'response_data' => $result->getRspDatas() ?: '',
- 'http_state_code' => $result->getHttpStateCode() ?: 0,
- 'headers' => $result->getHttpHeaders() ?: [],
- 'err_msg' => $result->getErrorInfo() ?: '',
- ]
- );
- if (!$logRes) {
- throw new RuntimeException(HuifupayPayRequestLog::getStaticError());
- }
- $this->requestId = $logRes['id'];
- }
- }catch (\Exception $e) {
- Yii::$app->custom->logs('【汇付】记录请求日志失败', compact('result', 'request'));
- }
- return $result;
- }
- }
- class HuifuJsPayParam
- {
- /**
- * 作者:zengfanhua
- * 创建时间:2023/12/28 13:45:00
- * @return array
- */
- public static function getExtendInfos($notify_url, $wxData = [], $alipayData = [], $expireDate, $splitAccount = [])
- {
- $extendInfoMap = [];
- // 交易有效期
- $extendInfoMap["time_expire"] = date('YmdHis', $expireDate);
- // 聚合正扫微信拓展参数集合
- $extendInfoMap["wx_data"] = $wxData;
- // 支付宝扩展参数集合
- $extendInfoMap["alipay_data"] = $alipayData;
- // 银联参数集合
- // $extendInfoMap["unionpay_data"]= getUnionpayData();
- // 数字人民币参数集合
- // $extendInfoMap["dc_data"]= getDcData();
- // 分账对象
- $extendInfoMap["acct_split_bunch"] = self::getAcctSplitBunch($splitAccount);
- // 传入分帐遇到优惠的处理规则
- $extendInfoMap["term_div_coupon_type"] = "0";
- // 补贴支付信息
- // $extendInfoMap["combinedpay_data"]= getCombinedpayData();
- // 账户号
- // $extendInfoMap["acct_id"]= "";
- // 手续费扣款标志
- // $extendInfoMap["fee_flag"]= "";
- // 禁用信用卡标记
- $extendInfoMap["limit_pay_type"] = "NO_CREDIT";
- // 是否延迟交易
- $extendInfoMap["delay_acct_flag"] = "N";
- // 商户贴息标记
- $extendInfoMap["fq_mer_discount_flag"] = "N";
- // 渠道号
- $extendInfoMap["channel_no"] = "";
- // 场景类型
- $extendInfoMap["pay_scene"] = "02";
- // 安全信息
- $extendInfoMap["risk_check_data"] = self::getRiskCheckData();
- // 设备信息
- $extendInfoMap["terminal_device_data"] = self::getTerminalDeviceData();
- // 备注
- $extendInfoMap["remark"] = "String";
- // 异步通知地址
- $extendInfoMap["notify_url"] = $notify_url;
- return $extendInfoMap;
- }
- public static function getGoodsDetailWxRucan()
- {
- $dto = array();
- // 商品编码
- // $dto["goods_id"] = "";
- // 商品名称
- // $dto["goods_name"] = "";
- // 商品单价(元)
- // $dto["price"] = "";
- // 商品数量
- // $dto["quantity"] = "";
- // 微信侧商品编码
- // $dto["wxpay_goods_id"] = "";
- $dtoList = array();
- array_push($dtoList, $dto);
- return $dtoList;
- }
- public static function getDetail()
- {
- $dto = array();
- // 单品列表
- // $dto["goods_detail"] = getGoodsDetailWxRucan();
- // 订单原价(元)
- // $dto["cost_price"] = "";
- // 商品小票ID
- // $dto["receipt_id"] = "";
- return $dto;
- }
- public static function getStoreInfo()
- {
- $dto = array();
- // 门店id
- // $dto["id"] = "";
- // 门店名称
- // $dto["name"] = "";
- // 门店行政区划码
- // $dto["area_code"] = "";
- // 门店详细地址
- // $dto["ass"] = "";
- $dtoList = array();
- array_push($dtoList, $dto);
- return $dtoList;
- }
- public static function getSceneInfo()
- {
- $dto = array();
- // 门店信息
- // $dto["store_info"] = getStoreInfo();
- return $dto;
- }
- public static function getWxData($mall_id,$open_id,$extra = [])
- {
- $wechat_config = \Yii::$app->services->pay->getWechatConfig($mall_id);
- $dto = array();
- // 子商户公众账号id
- $dto["sub_appid"] = $wechat_config['mini_program_app_id']??'';
- // 用户标识
- // $dto["openid"] = "";
- // 子商户用户标识
- $dto["sub_openid"] = $open_id;
- // 附加数据
- // $dto["attach"] = "";
- // // 商品描述
- // $dto["body"] = "";
- // // 商品详情
- // $dto["detail"] = getDetail();
- // // 设备号
- // $dto["device_info"] = "";
- // // 订单优惠标记
- // $dto["goods_tag"] = "";
- // // 实名支付
- // $dto["identity"] = "";
- // // 开发票入口开放标识
- // $dto["receipt"] = "";
- // // 场景信息
- // $dto["scene_info"] = getSceneInfo();
- // // 终端ip
- // $dto["spbill_create_ip"] = "";
- // // 单品优惠标识
- // $dto["promotion_flag"] = "";
- // // 新增商品ID
- // $dto["product_id"] = "";
- // // 指定支付者
- // $dto["limit_payer"] = "";
- return json_encode($dto, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
- }
- public static function getExtendParams()
- {
- $dto = array();
- // 卡类型
- // $dto["card_type"] = "";
- // // 支付宝点餐场景类型
- // $dto["food_order_type"] = "qr_order";
- // // 花呗分期数
- // $dto["hb_fq_num"] = "";
- // // 花呗卖家承担的手续费百分比
- // $dto["hb_fq_seller_percent"] = "";
- // // 行业数据回流信息
- // $dto["industry_reflux_info"] = "String";
- // // 停车场id
- // $dto["parking_id"] = "123wsx";
- // // 系统商编号
- // $dto["sys_service_provider_id"] = "1111111";
- // 信用卡分期资产方式
- // $dto["fq_channels"] = "";
- return $dto;
- }
- public static function getGoodsDetail()
- {
- $dto = array();
- // 商品的编号
- // $dto["goods_id"] = "12312321";
- // // 商品名称(元)
- // $dto["goods_name"] = "阿里";
- // // 商品单价
- // $dto["price"] = "0.01";
- // // 商品数量
- // $dto["quantity"] = "20";
- // // 商品描述信息
- // $dto["body"] = "";
- // // 商品类目树
- // $dto["categories_tree"] = "String";
- // // 商品类目
- // $dto["goods_category"] = "";
- // // 商品的展示地址
- // $dto["show_url"] = "";
- // $dtoList = array();
- // array_push($dtoList, $dto);
- return $dto;
- }
- public static function getExtUserInfo()
- {
- $dto = array();
- // 姓名
- // $dto["name"] = "";
- // 手机号
- // $dto["mobile"] = "";
- // 证件类型
- // $dto["cert_type"] = "";
- // 证件号
- // $dto["cert_no"] = "";
- // 允许的最小买家年龄
- // $dto["min_age"] = "";
- // 是否强制校验付款人身份信息
- // $dto["fix_buyer"] = "";
- // 是否强制校验身份信息
- // $dto["need_check_info"] = "";
- return $dto;
- }
- public static function getAlipayData()
- {
- $dto = array();
- // 买家的支付宝唯一用户号
- $dto["buyer_id"] = "20880414938706770000";
- // 支付宝的店铺编号
- $dto["alipay_store_id"] = "";
- // 买家支付宝账号
- $dto["buyer_logon_id"] = "String";
- // 业务扩展参数
- $dto["extend_params"] = self::getExtendParams();
- // 订单包含的商品列表信息
- $dto["goods_detail"] = self::getGoodsDetail();
- // 商户原始订单号
- $dto["merchant_order_no"] = "String";
- // 商户操作员编号
- $dto["operator_id"] = "123213213";
- // 销售产品码
- $dto["product_code"] = "String";
- // 卖家支付宝用户号
- $dto["seller_id"] = "String";
- // 商户门店编号
- $dto["store_id"] = "";
- // 外部指定买家
- // $dto["ext_user_info"] = getExtUserInfo();
- // 订单标题
- // $dto["subject"] = "";
- // 商家门店名称
- // $dto["store_name"] = "";
- return json_encode($dto, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
- }
- public static function getPayeeInfo()
- {
- $dto = array();
- // 商户类别
- // $dto["mer_cat_code"] = "";
- // 二级商户代码
- // $dto["sub_id"] = "";
- // 二级商户名称
- // $dto["sub_name"] = "";
- // 终端号
- // $dto["term_id"] = "";
- return $dto;
- }
- public static function getUnionpayData()
- {
- $dto = array();
- // 收款方附加数据
- // $dto["acq_addn_data"] = "";
- // 地区信息
- // $dto["area_info"] = "";
- // 持卡人ip
- // $dto["customer_ip"] = "";
- // 前台通知地址
- // $dto["front_url"] = "";
- // 订单描述
- // $dto["order_desc"] = "";
- // 收款方附言
- // $dto["payee_comments"] = "";
- // 收款方信息
- // $dto["payee_info"] = getPayeeInfo();
- // 银联分配的服务商机构标识码
- // $dto["pnr_ins_id_cd"] = "";
- // 请求方自定义域
- // $dto["req_reserved"] = "";
- // 终端信息
- // $dto["term_info"] = "";
- // 云闪付用户标识
- // $dto["user_id"] = "";
- return json_encode($dto, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
- }
- public static function getDcData()
- {
- $dto = array();
- // 数字货币银行编号
- // $dto["digital_bank_no"] = "";
- return json_encode($dto, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
- }
- public static function getAcctInfosRucan($splitAccount)
- {
- $dtoList = array();
- foreach ($splitAccount as $key => $value) {
- $dto = array();
- // 分账金额
- $dto["div_amt"] = $value['num'];
- // 被分账方ID
- $dto["huifu_id"] = $value['id'];
- // 账户号
- $dto["acct_id"] = "";
- array_push($dtoList, $dto);
- }
- return $dtoList;
- }
- public static function getAcctSplitBunch($splitAccount)
- {
- $dto = array();
- if (empty($splitAccount)) {
- return $dto;
- }
- // 分账明细
- $dto["acct_infos"] = self::getAcctInfosRucan($splitAccount);
- return json_encode($dto, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
- }
- public static function getCombinedpayData()
- {
- $dto = array();
- // 补贴方汇付编号
- // $dto["huifu_id"] = "test";
- // 补贴方类型
- // $dto["user_type"] = "test";
- // 补贴方账户号
- // $dto["acct_id"] = "test";
- // 补贴金额
- // $dto["amount"] = "test";
- $dtoList = array();
- array_push($dtoList, $dto);
- return json_encode($dtoList, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
- }
- public static function getRiskCheckData()
- {
- $dto = array();
- // ip地址
- $dto["ip_addr"] = "180.167.105.130";
- // 基站地址
- $dto["base_station"] = "192.168.1.1";
- // 纬度
- $dto["latitude"] = "33.3";
- // 经度
- $dto["longitude"] = "33.3";
- return json_encode($dto, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
- }
- public static function getTerminalDeviceData()
- {
- $dto = array();
- // 商户设备类型
- // $dto["mer_device_type"] = "test";
- // 汇付机具号
- $dto["devs_id"] = "SPINTP357338300264411";
- // 设备类型
- $dto["device_type"] = "1";
- // 交易设备IP
- $dto["device_ip"] = "10.10.0.1";
- // 交易设备MAC
- $dto["device_mac"] = "";
- // 交易设备IMEI
- $dto["device_imei"] = "";
- // 交易设备IMSI
- $dto["device_imsi"] = "";
- // 交易设备ICCID
- $dto["device_icc_id"] = "";
- // 交易设备WIFIMAC
- $dto["device_wifi_mac"] = "";
- // 交易设备GPS
- $dto["device_gps"] = "192.168.0.0";
- // 商户终端应用程序版本
- // $dto["app_version"] = "";
- // SIM 卡卡号
- // $dto["icc_id"] = "";
- // 商户终端实时经纬度信息
- // $dto["location"] = "";
- // 商户交易设备IP
- // $dto["mer_device_ip"] = "";
- // 移动国家代码
- // $dto["mobile_country_cd"] = "";
- // 移动网络号码
- // $dto["mobile_net_num"] = "";
- // 商户终端入网认证编号
- // $dto["network_license"] = "";
- // 商户终端序列号
- // $dto["serial_num"] = "";
- return json_encode($dto, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
- }
- }
- class HuifuSignParam
- {
- /**
- * 非必填字段
- *
- */
- public static function getExtendInfos()
- {
- // 设置非必填字段
- $extendInfoMap = array();
- // 商户名称
- //$extendInfoMap["merch_name"] = "全球鹰(浙江)网络科技有限公司";
- // 电子邮箱
- //$extendInfoMap["email"] = "290475886@qq.com";
- // 卡的借贷类型
- // $extendInfoMap["dc_type"]= "";
- // 风控信息
- // $extendInfoMap["risk_info"]= getRiskInfo();
- return $extendInfoMap;
- }
- }
- class HuifuPreOrderParam
- {
- /**
- * 非必填字段
- *
- */
- public static function getExtendInfos($expireDate, $notify_url, $splitAccount)
- {
- // 设置非必填字段
- $extendInfoMap = array();
- // 收银台ID
- $extendInfoMap["checkout_id"] = "";
- // 是否延迟交易
- $extendInfoMap["delay_acct_flag"] = "N";
- // 分账对象
- $extendInfoMap["acct_split_bunch"] = self::getAcctSplitBunchRucan($splitAccount);
- // 交易失效时间
- $extendInfoMap["time_expire"] = date('YmdHis', $expireDate);
- // 业务信息
- // $extendInfoMap["biz_info"]= getBizInfo();
- // 交易异步通知地址
- $extendInfoMap["notify_url"] = $notify_url;
- return $extendInfoMap;
- }
- public static function getAcctInfosRucan($accountList)
- {
- $dtoList = array();
- foreach ($accountList as $key => $value) {
- $dto = array();
- //分账金额
- $dto["div_amt"] = $value['num'];
- // 被分账方ID
- $dto["huifu_id"] = $value['id'];
- array_push($dtoList, $dto);
- }
- return $dtoList;
- }
- public static function getAcctSplitBunchRucan($accountList)
- {
- $dto = array();
- if (empty($accountList)) {
- return $dto;
- }
- // 分账明细
- $dto["acct_infos"] = self::getAcctInfosRucan($accountList);
- return json_encode($dto, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
- }
- public static function getMiniappDataRucan()
- {
- $dto = array();
- // 是否生成scheme_code
- $dto["need_scheme"] = "N"; // 之前是Y
- // 应用ID
- $dto["seq_id"] = "";
- // 私有信息
- $dto["private_info"] = "oppsHosting://";
- return $dto;
- //return json_encode($dto, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
- }
- public static function getPayCheckWx()
- {
- $dto = array();
- // 指定支付者
- // $dto["limit_payer"] = "";
- // 微信实名验证
- // $dto["real_name_flag"] = "";
- return $dto;
- }
- public static function getPersonPayer()
- {
- $dto = array();
- // 姓名
- // $dto["name"] = "";
- // 证件类型
- // $dto["cert_type"] = "";
- // 证件号
- // $dto["cert_no"] = "";
- return $dto;
- }
- public function getBizInfo()
- {
- $dto = array();
- // 付款人验证(微信)
- // $dto["payer_check_wx"] = getPayCheckWx();
- // 个人付款人信息
- // $dto["person_payer"] = getPersonPayer();
- return json_encode($dto, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
- }
- }
- class HuifuRefundParam
- {
- /**
- * 非必填字段
- *
- */
- public static function getExtendInfos($org_req_seq_id, $splitAccount = [])
- {
- // 设置非必填字段
- $extendInfoMap = array();
- // 原交易全局流水号
- //$extendInfoMap["org_hf_seq_id"] = '';
- // 原交易微信支付宝的商户单号
- // $extendInfoMap["org_party_order_id"]= "";
- // 原交易请求流水号
- $extendInfoMap["org_req_seq_id"]= $org_req_seq_id;
- // 分账对象
- $extendInfoMap["acct_split_bunch"] = self::getAcctSplitBunchRucan($splitAccount);
- // 聚合正扫微信拓展参数集合
- // $extendInfoMap["wx_data"]= self::getWxData();
- // 数字货币扩展参数集合
- // $extendInfoMap["digital_currency_data"]= self::getDigitalCurrencyData();
- // 补贴支付信息
- // $extendInfoMap["combinedpay_data"]= self::getCombinedpayData();
- // 备注
- // $extendInfoMap["remark"]= "";
- // 是否垫资退款
- // $extendInfoMap["loan_flag"]= "";
- // 垫资承担者
- // $extendInfoMap["loan_undertaker"]= "";
- // 垫资账户类型
- // $extendInfoMap["loan_acct_type"]= "";
- // 安全信息
- // $extendInfoMap["risk_check_data"]= self::getRiskCheckData();
- // 设备信息
- // $extendInfoMap["terminal_device_data"]= self::getTerminalDeviceData();
- // 异步通知地址
- // $extendInfoMap["notify_url"]= "";
- return $extendInfoMap;
- }
- public static function getAcctInfosRucan($splitAccount)
- {
- $dtoList = array();
- foreach ($splitAccount as $key => $value) {
- $dto = array();
- // 分账金额
- $dto["div_amt"] = $value['num'];
- // 被分账方ID
- $dto["huifu_id"] = $value['id'];
- // 账户号
- $dto["acct_id"] = "";
- array_push($dtoList, $dto);
- }
- return $dtoList;
- }
- public static function getAcctSplitBunchRucan($splitAccount)
- {
- $dto = array();
- if (empty($splitAccount)) {
- return $dto;
- }
- // 分账信息列表
- $dto["acct_infos"] = self::getAcctInfosRucan($splitAccount);
- return json_encode($dto, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
- }
- public static function getGoodsDetail()
- {
- $dto = array();
- // 商品编码
- // $dto["goods_id"] = "test";
- // 优惠退款金额
- // $dto["refund_amount"] = "test";
- // 商品退货数量
- // $dto["refund_quantity"] = "test";
- // 商品单价
- // $dto["price"] = "test";
- $dtoList = array();
- array_push($dtoList, $dto);
- return $dtoList;
- }
- public static function getDetail()
- {
- $dto = array();
- // 商品详情列表
- // $dto["goods_detail"] = getGoodsDetail();
- return $dto;
- }
- public static function getWxData()
- {
- $dto = array();
- // 退款商品详情
- // $dto["detail"] = getDetail();
- return $dto;
- }
- public static function getDigitalCurrencyData()
- {
- $dto = array();
- // 退款原因
- // $dto["refund_desc"] = "";
- return json_encode($dto, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
- }
- public static function getCombinedpayData()
- {
- $dto = array();
- // 补贴方汇付编号
- // $dto["huifu_id"] = "test";
- // 补贴方类型
- // $dto["user_type"] = "test";
- // 补贴方账户号
- // $dto["acct_id"] = "test";
- // 补贴金额
- // $dto["amount"] = "test";
- $dtoList = array();
- array_push($dtoList, $dto);
- return json_encode($dtoList, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
- }
- public static function getRiskCheckData()
- {
- $dto = array();
- // ip地址
- // $dto["ip_addr"] = "";
- // 基站地址
- // $dto["base_station"] = "";
- // 纬度
- // $dto["latitude"] = "";
- // 经度
- // $dto["longitude"] = "";
- return json_encode($dto, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
- }
- public static function getTerminalDeviceData()
- {
- $dto = array();
- // 设备类型
- // $dto["device_type"] = "";
- // 交易设备IP
- // $dto["device_ip"] = "";
- // 交易设备MAC
- // $dto["device_mac"] = "";
- // 交易设备IMEI
- // $dto["device_imei"] = "";
- // 交易设备IMSI
- // $dto["device_imsi"] = "";
- // 交易设备ICCID
- // $dto["device_icc_id"] = "";
- // 交易设备WIFIMAC
- // $dto["device_wifi_mac"] = "";
- // 交易设备GPS
- // $dto["device_gps"] = "";
- return json_encode($dto, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
- }
- }
|