123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346 |
- <?php
- /**
- * 聚合反扫接口 - 示例
- *
- * @author sdk-generator
- * @Description
- */
- namespace BsPayDemo;
- // 1. 资源及配置加载
- require_once dirname(__FILE__) . "/loader.php";
- require_once dirname(__FILE__). "/../BsPaySdk/request/V2TradePaymentMicropayRequest.php";
- use BsPaySdk\core\BsPayClient;
- use BsPaySdk\request\V2TradePaymentMicropayRequest;
- // 2.组装请求参数
- $request = new V2TradePaymentMicropayRequest();
- // 请求日期
- $request->setReqDate(date("Ymd"));
- // 请求流水号
- $request->setReqSeqId(date("YmdHis").mt_rand());
- // 商户号
- $request->setHuifuId("6666000018328947");
- // 交易金额
- $request->setTransAmt("0.01");
- // 商品描述
- $request->setGoodsDesc("聚合反扫消费");
- // 支付授权码
- $request->setAuthCode("2884138408701518074");
- // 安全信息
- $request->setRiskCheckData(getRiskCheckData());
- // 设置非必填字段
- $extendInfoMap = getExtendInfos();
- $request->setExtendInfo($extendInfoMap);
- // 3. 发起API调用
- $client = new BsPayClient();
- $result = $client->postRequest($request);
- if (!$result || $result->isError()) { //失败处理
- var_dump($result -> getErrorInfo());
- } else { //成功处理
- var_dump($result);
- }
- /**
- * 非必填字段
- *
- */
- function getExtendInfos() {
- // 设置非必填字段
- $extendInfoMap = array();
- // 交易有效期
- $extendInfoMap["time_expire"]= "20220918150330";
- // 手续费扣款标志
- // $extendInfoMap["fee_flag"]= "";
- // 禁用支付方式
- $extendInfoMap["limit_pay_type"]= "";
- // 是否延迟交易
- $extendInfoMap["delay_acct_flag"]= "Y";
- // 渠道号
- $extendInfoMap["channel_no"]= "";
- // 补贴支付信息
- // $extendInfoMap["combinedpay_data"]= getCombinedpayData();
- // 场景类型
- $extendInfoMap["pay_scene"]= "";
- // 分账对象
- // $extendInfoMap["acct_split_bunch"]= getAcctSplitBunch();
- // 传入分帐遇到优惠的处理规则
- $extendInfoMap["term_div_coupon_type"]= "3";
- // 聚合反扫微信参数集合
- // $extendInfoMap["wx_data"]= getWxData();
- // 支付宝扩展参数集合
- $extendInfoMap["alipay_data"]= getAlipayData();
- // 银联参数集合
- // $extendInfoMap["unionpay_data"]= getUnionpayData();
- // 设备信息
- $extendInfoMap["terminal_device_info"]= getTerminalDeviceInfo();
- // 异步通知地址
- $extendInfoMap["notify_url"]= "http://www.baidu.com";
- // 交易备注
- $extendInfoMap["remark"]= "";
- // 账户号
- // $extendInfoMap["acct_id"]= "";
- return $extendInfoMap;
- }
- 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);
- }
- function getAcctInfosRucan() {
- $dto = array();
- // 分账金额
- // $dto["div_amt"] = "test";
- // 被分账方ID
- // $dto["huifu_id"] = "test";
- // 账户号
- // $dto["acct_id"] = "";
- $dtoList = array();
- array_push($dtoList, $dto);
- return $dtoList;
- }
- function getAcctSplitBunch() {
- $dto = array();
- // 分账明细
- // $dto["acct_infos"] = getAcctInfosRucan();
- return json_encode($dto,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
- }
- function getGoodsDetailWxRucan() {
- $dto = array();
- // 商品编码
- // $dto["goods_id"] = "test";
- // 商品数量
- // $dto["quantity"] = "test";
- // 商品名称
- // $dto["goods_name"] = "";
- // 商品单价
- // $dto["price"] = "";
- // 微信侧商品编码
- // $dto["wxpay_goods_id"] = "";
- $dtoList = array();
- array_push($dtoList, $dto);
- return $dtoList;
- }
- function getDetail() {
- $dto = array();
- // 单品列表
- // $dto["goods_detail"] = getGoodsDetailWxRucan();
- // 订单原价
- // $dto["cost_price"] = "";
- // 商品小票ID
- // $dto["receipt_id"] = "";
- return $dto;
- }
- function getStoreInfo() {
- $dto = array();
- // 门店id
- // $dto["id"] = "";
- // 门店名称
- // $dto["name"] = "";
- // 门店行政区划码
- // $dto["area_code"] = "";
- // 门店详细地址
- // $dto["address"] = "";
- $dtoList = array();
- array_push($dtoList, $dto);
- return $dtoList;
- }
- function getSceneInfo() {
- $dto = array();
- // 门店信息
- // $dto["store_info"] = getStoreInfo();
- return $dto;
- }
- function getWxData() {
- $dto = array();
- // 收款设备IP直联模式必填字段;<font color="green">示例值:192.168.2.2</font>
- // $dto["spbill_create_ip"] = "test";
- // 子商户公众账号id
- // $dto["sub_appid"] = "";
- // 用户标识
- // $dto["openid"] = "";
- // 子商户用户标识
- // $dto["sub_openid"] = "";
- // 设备号
- // $dto["device_info"] = "";
- // 附加数据
- // $dto["attach"] = "";
- // 商品详情
- // $dto["detail"] = getDetail();
- // 场景信息
- // $dto["scene_info"] = getSceneInfo();
- // 单品优惠标识
- // $dto["promotion_flag"] = "";
- // 电子发票入口开放标识
- // $dto["receipt"] = "";
- return json_encode($dto,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
- }
- function getGoodsDetail() {
- $dto = array();
- // 商品的编号
- // $dto["goods_id"] = "test";
- // 商品名称
- // $dto["goods_name"] = "test";
- // 商品数量
- // $dto["quantity"] = "test";
- // 商品单价
- // $dto["price"] = "test";
- // 商品类目树
- // $dto["categories_tree"] = "";
- // 商品类目
- // $dto["goods_category"] = "";
- // 商品描述信息
- // $dto["body"] = "";
- // 商品的展示地址
- // $dto["show_url"] = "";
- $dtoList = array();
- array_push($dtoList, $dto);
- return $dtoList;
- }
- function getExtendParams() {
- $dto = array();
- // 卡类型
- // $dto["card_type"] = "";
- // 支付宝点餐场景类型
- // $dto["food_order_type"] = "";
- // 花呗分期数
- // $dto["hb_fq_num"] = "";
- // 花呗卖家承担的手续费百分比
- // $dto["hb_fq_seller_percent"] = "";
- // 行业数据回流信息
- // $dto["industry_reflux_info"] = "";
- // 停车场id
- // $dto["parking_id"] = "";
- // 系统商编号
- // $dto["sys_service_provider_id"] = "";
- return $dto;
- }
- function getAlipayData() {
- $dto = array();
- // 支付宝的店铺编号
- $dto["alipay_store_id"] = "";
- // 订单包含的商品列表信息
- // $dto["goods_detail"] = getGoodsDetail();
- // 业务扩展参数
- // $dto["extend_params"] = getExtendParams();
- // 商户操作员编号
- // $dto["operator_id"] = "";
- // 商户门店编号
- $dto["store_id"] = "";
- return json_encode($dto,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
- }
- function getUnionpayData() {
- $dto = array();
- // 币种
- // $dto["currency_code"] = "";
- // 支持发票
- // $dto["invoice_st"] = "";
- // 商户类别
- // $dto["mer_cat_code"] = "";
- // 银联参数集合
- // $dto["pnrins_id_cd"] = "";
- // 特殊计费信息
- // $dto["specfeeinfo"] = "";
- // 终端号
- // $dto["term_id"] = "";
- return json_encode($dto,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
- }
- function getRiskCheckData() {
- $dto = array();
- // ip地址
- // $dto["ip_addr"] = "";
- // 基站地址
- $dto["base_station"] = "3";
- // 纬度
- $dto["latitude"] = "2";
- // 经度
- $dto["longitude"] = "1";
- return json_encode($dto,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
- }
- function getTerminalDeviceInfo() {
- $dto = array();
- // 商户设备类型
- // $dto["mer_device_type"] = "test";
- // 汇付机具号
- // $dto["devs_id"] = "test";
- // 设备类型
- $dto["device_type"] = "4";
- // 交易设备IP
- $dto["device_ip"] = "10.10.0.1";
- // 交易设备MAC
- $dto["device_mac"] = "030147441006000182623";
- // 交易设备IMEI
- $dto["device_imei"] = "030147441006000182623";
- // 交易设备IMSI
- $dto["device_imsi"] = "030147441006000182623";
- // 交易设备ICCID
- $dto["device_icc_id"] = "030147441006000182623";
- // 交易设备WIFIMAC
- $dto["device_wifi_mac"] = "030147441006000182623";
- // 交易设备GPS
- $dto["device_gps"] = "111";
- // 商户终端应用程序版
- // $dto["app_version"] = "";
- // 加密随机因子
- // $dto["encrypt_rand_num"] = "";
- // SIM 卡卡号
- // $dto["icc_id"] = "";
- // 商户终端实时经纬度信息
- // $dto["location"] = "";
- // 商户交易设备IP
- // $dto["mer_device_ip"] = "";
- // 移动国家代码
- // $dto["mobile_country_cd"] = "";
- // 移动网络号码
- // $dto["mobile_net_num"] = "";
- // 商户终端入网认证编号
- // $dto["network_license"] = "";
- // 密文数据
- // $dto["secret_text"] = "";
- // 商户终端序列号
- // $dto["serial_num"] = "";
- return json_encode($dto,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
- }
|