12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- /**
- * 聚合正扫接口 - 示例
- *
- * @author sdk-generator
- * @Description
- */
- namespace BsPayClassify;
- use BsPaySdk\core\BsPayClient;
- use BsPaySdk\request\V2TradeHostingPaymentPreorderWxRequest;
- class V2TradeHostingPaymentPreorder extends BaseInfo{
- public function pay($huifu_id, $pre_order_type = 3, $trans_amt, $goods_desc=''){
- // 2.组装请求参数
- $request = new V2TradeHostingPaymentPreorderWxRequest();
- // 预下单类型
- $request->setPreOrderType($pre_order_type);
- // 请求日期
- $request->setReqDate(date("Ymd"));
- // 请求流水号
- $request->setReqSeqId(date("YmdHis").mt_rand());
- // 商户号
- $request->setHuifuId($huifu_id);
- // 交易金额
- $request->setTransAmt($trans_amt);
- // 商品描述
- $request->setGoodsDesc($goods_desc);
- // 微信小程序扩展参数集合
- $request->setMiniappData($this->getMiniappDataRucan());
- // 设置非必填字段
- $extendInfoMap = $this->getExtendInfos();
- $request->setExtendInfo($extendInfoMap);
- // 3. 发起API调用
- $client = new BsPayClient();
- $result = $client->postRequest($request);
- return $result;
- }
- /**
- * 非必填字段
- *
- */
- function getExtendInfos() {
- // 设置非必填字段
- $extendInfoMap = array();
- // 收银台ID
- $extendInfoMap["checkout_id"]= "";
- // 是否延迟交易
- $extendInfoMap["delay_acct_flag"]= "N";
- // 分账对象
- $extendInfoMap["acct_split_bunch"]= $this->getAcctSplitBunchRucan();
- // 异步通知地址
- $extendInfoMap["notify_url"]= "https://callback.service.com/xx";
- // 交易失效时间
- // $extendInfoMap["time_expire"]= "";
- return $extendInfoMap;
- }
- function getAcctInfosRucan() {
- $dto = array();
- // 分账金额
- $dto["div_amt"] = "0.08";
- // 被分账方ID
- $dto["huifu_id"] = "6666000111546360";
- $dtoList = array();
- array_push($dtoList, $dto);
- return $dtoList;
- }
- function getAcctSplitBunchRucan() {
- $dto = array();
- // 分账明细
- $dto["acct_infos"] = $this->getAcctInfosRucan();
- return json_encode($dto,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
- }
- function getMiniappDataRucan() {
- $dto = array();
- // 应用ID
- $dto["seq_id"] = "系统应用ID";
- // 私有信息
- // $dto["private_info"] = "";
- return json_encode($dto,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
- }
- }
|