精华内容
下载资源
问答
  • 易宝支付sdk

    2018-11-07 10:58:41
    易宝支付sdk demo,有需要开发易宝支付的小伙伴都可以来看看
  • 易宝支付

    2021-04-11 10:38:46
    添加php的mcrypt扩展 openssl ###########目录结构描述 | ├── lib // 函数库 │ ├── YopClient.php // 对称秘钥请求处理函数集 │ ├── YopClient3.php // 非对称秘钥请求处理函数集 │ ├── YopConfig....

    当前版本:V1.0.0 生成时间:2017-09-02 12:47:10

    ===========================

    ###########环境依赖

    php v5.5+

    安装php的mcrypt扩展 openssl

    ###########部署步骤

    1. 添加php的mcrypt扩展 openssl

    ###########目录结构描述

    |

    ├── lib // 函数库

    │ ├── YopClient.php // 对称秘钥请求处理函数集

    │ ├── YopClient3.php // 非对称秘钥请求处理函数集

    │ ├── YopConfig.php // YOP配置信息函数集

    │ ├── YopRequest.php // YOP请求处理函数集

    │ ├── YopResponse.php // YOP返回处理函数集

    │ ├── Util

    │ ├── AESEncrypter.php // AES函数集

    │ ├── Base64Url.php // Base64Url函数集

    │ ├── BlowfishEncrypter.php // 加解密处理

    │ ├── HttpRequest.php // Http请求函数集

    │ ├── HttpUtils.php // Http处理共通函数集

    │ ├── StringBuilder.php // 字符串创建函数集

    │ ├── StringUtils // 字符串处理函数集

    │ └── YopSignUtils.php // YOP签名共通函数集

    ├── conf.php // 商户商编、密钥对配置文件

    ├── Readme.txt // help

    ├── index.html // demo样例首页

    ├── 其他php页面 // demo测试页,仅供参考

    ###########V1.0.0 版本内容更新

    1. 待更新

    POST /yop-center/rest/v1.0/paperorder/api/pay/query HTTP/1.1

    Accept: text/plain, application/json, application/*+json, */*

    Content-Type: application/x-www-form-urlencoded

    User-Agent: Java/1.8.0_91

    Host: 10.151.30.88:8064

    Connection: keep-alive

    Content-Length: 233

    0e65894ea9f91213f6991a5c81fa23b4ed1345e13f31d0fb43d0a1831760a3f7

    0owN80Vs39386sSSi7B76wa7497P41gZ3G4b8971V8R8sc6lS7ns4FA2846TcustomerNo10040020578formatjsonlocalezh_CNmerchantno10040020578method/rest/v1.0/paperorder/api/pay/queryrequestnoYOP-SDK-1471601751370signRettruets1471601751342v1.00owN80Vs39386sSSi7B76wa7497P41gZ3G4b8971V8R8sc6lS7ns4FA2846T

    format=json

    locale=zh_CN

    ts=1471601751342

    signRet=true

    customerNo=10040020578

    sign=0e65894ea9f91213f6991a5c81fa23b4ed1345e13f31d0fb43d0a1831760a3f7

    encrypt=C%252FG0UURN6jufCiZP0aeDgcSkdpQHXn8JqlIrxxBsrW1LOLTTmWpXSUHOpcDoBWda2WBzJYEBH

    0owN80Vs39386sSSi7B76wa7497P41gZ3G4b8971V8R8sc6lS7ns4FA2846TcustomerNo10040020578formatjsonlocalezh_CNmerchantno10040020578method/rest/v1.0/paperorder/api/pay/queryrequestnoYOP-SDK-1471601751370signRettruets1471601751342v1.00owN80Vs39386sSSi7B76wa7497P41gZ3G4b8971V8R8sc6lS7ns4FA2846T

    0004b49b668fba3e3c8d88bce978419227468281646b9c03ea174b2158c7ad18

    appKey=

    format=json

    locale=zh_CN

    ts=1471599539977

    signRet=true

    customerNo=10040020578

    sign=0004b49b668fba3e3c8d88bce978419227468281646b9c03ea174b2158c7ad18

    encrypt=jqIh5ikW6033NV6jQ9o5XJaOJ5czDmd2MiOUkTtoBeyOaI7lglVF58bh1LEuRqoxMpWKooEUYRnDD6jOe28TvQ%253D%253D

    {

    "state" : "SUCCESS",

    "result" : "HTg9s/K7xqECF5KspdG6wvLiEICimhmB3hOn78tWbUsmSYQ5pBeQB9Z3AazmXb/3RcHeEAacaQyd4RnlPNNV8K+9oBUjPR+Ux47H34M46UBkb9Y8VcIK8Dhr2WVMIOp/sjG8vXuiqzoybqq7RZUExcCYK0k8DqWLqkGOC90TU8a+4DiQGuLG0mkx3XhRg60zD9AvJsZO3n+Dclk7EsXvE5uJ96gPIM8NsmiI0PKYndfM70sEUYgjZNsj7LEcCTfn7FXB+hXVL7FzuvSUnRHlGQjH8btkp7tV2TCMjKImcBvU1WIQp2pqqwR864aaDQ2wZfEAWVdb2NnNoycHbw==",

    "ts" : 1471599541473,

    "sign" : "ab7f48bcc3b91d06b1108ac3458caac460c3f3d4918202e04b59ea13d3127035"

    }

    0

    展开全文
  • 关于易宝支付的回调和跨域请求

    千次阅读 2018-05-25 18:06:01
    此次开发是基于小京东商城的开发(ecshop)1.在支付的SDK里面有个call_...易宝支付的服务器会发送一个response参数还有另外一个参数,忽略,response参数里面有所有的订单信息附上代码 <?phpdefine('IN_ECS', ...
    此次开发是基于小京东商城的开发(ecshop)
    
    1.在支付的SDK里面有个call_back文件,支付的文档里面有个notify参数,里面的地址就写成能访问到call_back.php文件就行,切记,一定要是能访问到此地址
    2.易宝支付的服务器会发送一个response参数还有另外一个参数,忽略,response参数里面有所有的订单信息附上代码


        <?php
    define('IN_ECS', true);
    include (dirname(__FILE__)."/includes/modules/payment/conf.php");
    require_once (dirname(__FILE__)."/includes/modules/payment/yibao/YopClient.php");
    require_once (dirname(__FILE__)."/includes/modules/payment/yibao/YopClient3.php");
    require_once (dirname(__FILE__)."/includes/modules/payment/yibao/Util/YopSignUtils.php");
    require (dirname(__FILE__) . '/includes/init.php');
    //结果通知返回原文数据
    function callback($source){
     
           global $merchantno;
       global $private_key;
       global $yop_public_key;
        //返回的密文
        //还原出原文
        return YopSignUtils::decrypt($source,$private_key, $yop_public_key);


    }
    //$aa = '{"unionID":null,"bankTrxId":"18042210246307468","orderId":"2018041915771","openID":null,"paySuccessDate":"2018-04-22 10:15:52","platformType":"NCPAY","bankPaySuccessDate":"2018-04-22 10:15:52","customerFee":"0.00","uniqueOrderNo":"1001201804220000000102775930","fundProcessType":"REAL_TIME","payAmount":"0.01","orderAmount":"0.01","requestDate":"2018-04-22 10:13:59","parentMerchantNo":"10018335019","paymentProduct":"NCPAY","status":"SUCCESS","merchantNo":"10020290087"}';
    //$a = json_decode($aa,true);
    //$key='oiwersoiasfqwe762323';
    //$sign = MD5($a['orderId'].$a['orderAmount'].$key);




    //$url = "http://域名/api/notify/NotifyShopPay".'?orderId='.$a['orderId'].'&uniqueOrderNo='.$a['uniqueOrderNo'].'&status='.$a['status'].'&orderAmount='.$a['orderAmount'].'&payAmount='.$a['payAmount'].'&sign='.$sign;
    //var_dump($url);exit;
    //$code = "code={"unionID":null,"bankTrxId":"18042210246307468","orderId":"2018042286301","openID":null,"paySuccessDate":"2018-04-22 10:15:52","platformType":"NCPAY","bankPaySuccessDate":"2018-04-22 10:15:52","customerFee":"0.00","uniqueOrderNo":"1001201804220000000102775930","fundProcessType":"REAL_TIME","payAmount":"0.01","orderAmount":"0.01","requestDate":"2018-04-22 10:13:59","parentMerchantNo":"10018335019","paymentProduct":"NCPAY","status":"SUCCESS","merchantNo":"10020290087"}";
    $data = $_REQUEST["response"];
    $call_pay = callback($data);
    $a = json_decode($call_pay,true);
    $key='oiwersoiasfqwe762323';
    $sign = MD5($a['orderId'].$a['orderAmount'].$key);
    $url = "http://域名/api/notify/NotifyShopPay".'?orderId='.$a['orderId'].'&uniqueOrderNo='.$a['uniqueOrderNo'].'&status='.$a['status'].'&orderAmount='.$a['orderAmount'].'&payAmount='.$a['payAmount'].'&sign='.$sign;


    //初始化


          $curl = curl_init();
         
         //设置抓取的url
          curl_setopt($curl, CURLOPT_URL, $url);


         //设置头文件的信息作为数据流输出
          curl_setopt($curl, CURLOPT_HEADER, 1);
          //设置获取的信息以文件流的形式返回,而不是直接输出。
          curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
          //执行命令
         // curl_setopt($curlp, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
          $data = curl_exec($curl);
          // var_dump( curl_error($curl));exit;
         //关闭URL请求
         curl_close($curl);
         //显示获得的数据
         var_dump($data);




    file_put_contents("pay_log.txt",$url);


    echo "SUCCESS"; 
    中间的curl操作是将其返回的地址和参数拼接成url对另外一个平台进行请求。(curl进行跨域的请求操作函数)
    展开全文
  • 易宝支付[钱麦](附代码)

    千次阅读 2018-07-05 15:27:07
    1:准备工作导入易宝支付SDK.jar到自己公司私服(公司使用的nexus搭建私服操作如下)查看/存储库:库(Repositories)----在对应的库路径中添加选择库路径--artifact upload上传:1:GAV定义2:配置组...

    想到支付首先要知道,就是调用以及回调接口。

    1:准备工作导入易宝支付SDK.jar到自己公司私服(公司使用的nexus搭建私服操作如下)

    查看/存储库:库(Repositories)----在对应的库路径中添加
    选择库路径--artifact upload上传:
        1:GAV定义
        2:配置组com.yeepay
        3:Artifact:c
        4:version:

    **注意**:单存在多个jar(jdk/sources/sdk)的时候需要全部添加:add Artifact多次添加jar,加入完成后发布,可以在搜索中搜索添加的名字确认。

    发布,并复制以来pom
    结果:
    <dependency>
    <groupId>com.yeepay</groupId>
    <artifactId>yop-java-sdk</artifactId>
    <version>2.2.7</version>

    </dependency>

    一:易宝支付调用

    枚举类PayTool.java:

    package com.*.constants;
    
    /**
     * 钱麦支付方式
     */
    public enum PayTool {
        BALANCE("BALANCE","账户余额支付"),
        BINDCARD("BINDCARD","账户绑卡支付"),
        YEEPAYCASHIER("YEEPAYCASHIER","易宝支付键支付"),
        SALESB2C("SALESB2C","网银个人支付"),
        SALESB2B("SALESB2B","网银企业支付"),
        WECHATSCAN("WECHATSCAN","微信用户扫码支付"),
        WECHATAPP("WECHATAPP","微信H5支付仅移动端"),
        WECHATOFFICIAL("WECHATOFFICIAL","微信公众号支付仅限制微信浏览器"),
        WECHAT_MICROPAY("WECHAT_MICROPAY","微信刷卡"),
        WECHATSDK("WECHATSDK","微信APP支付"),
        ALIPAYSCAN("ALIPAYSCAN","支付宝用户扫码支付"),
        ALIPAYAPP("ALIPAYAPP","支付宝H5支付仅移动端"),
        ALIPAYSDK("ALIPAYSDK","支付宝APP支付"),
        ALIPAYTIMELY("ALIPAYTIMELY","支付宝即时到账仅PC端"),
        ALIPAY_MICROPAY("ALIPAY_MICROPAY","支付宝被扫支付");
    
        private String code;
        private String desc;
    
        public String getCode() {
            return code;
        }
    
        public void setCode(String code) {
            this.code = code;
        }
    
        public String getDesc() {
            return desc;
        }
    
        public void setDesc(String desc) {
            this.desc = desc;
        }
    
        PayTool(String code, String desc){
            this.code = code;
            this.desc = desc;
        }
    
        public static String getPayToolName(String code){
            for(PayTool type : PayTool.values()){
                if(code.equals(type.getCode())){
                    return type.getDesc();
                }
            }
            return "";
        }
    }
    
     
    

    支付工具类YeepayUtil.java:

    package com.*.utils;
    
    import com.*.constants.PayTool;
    import com.yeepay.g3.sdk.yop.client.YopClient;
    import com.yeepay.g3.sdk.yop.client.YopRequest;
    import com.yeepay.g3.sdk.yop.client.YopResponse;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import java.io.IOException;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.Map;
    
    /**
     * 钱麦支付SDK调用工具类
     */
    public class YeepayUtil {
    
        private static Logger logger = LoggerFactory.getLogger(YeepayUtil.class);
        //读取系统配置文件
        private static final String appKey=SysConfig.getStringConfig("yeepay.appkey");//公司在钱麦的账号:BM123456789
        private static final String secretKey=SysConfig.getStringConfig("yeepay.secretKey");//公司在钱麦方的秘钥:Hhu9qik0ZQfGzWgR1Wc==
        private static final String secretRoot=SysConfig.getStringConfig("yeepay.secretRoot");//接口请求地址,钱麦方提供(固定https://open.yeepay.com/yop-center)
    
        /**
         *
         * @param orderAmount
         * @param shouldPayAmount
         * @param payTool
         * @param productName
         * @param productDesc
         * @param returUrl
         * @param notifyUrl
         * @param requestNo  商户请求号格式(最大长度32)://三位随机码:交易号或订单号-----(因为同一单可能请求多次所以必须加入随机区分,并且订单号借口没有返回必须和请求号一起带回解析,也可以在回调接口中传入订单号,这样回调的时候又回带入)
         * @return
         * @throws IOException
         */
        public static String yeePayCall(double orderAmount,double shouldPayAmount,PayTool payTool,String productName,String productDesc,String returUrl,String notifyUrl,String requestNo) throws IOException {
            String orderAmountDb = MathUtil.formatDouble(orderAmount);
            String shouldPayAmountDb = MathUtil.formatDouble(shouldPayAmount);
            YopRequest request = new YopRequest(appKey,secretKey,secretRoot);
            request.setEncrypt(true);//加密请求模式
            request.setSignRet(true);//是否需要验签
            request.setSignAlg("sha-256");//签名算法
            //添加请求参数
            request.addParam("requestNo", requestNo);
           request.addParam("merchantNo", appKey);
            request.addParam("orderAmount", orderAmountDb);//订单金额(保留2位小数大于等于0.01)
            request.addParam("fundAmount", shouldPayAmountDb);//需支付金额(保留2位小数大于等于0.01)
    //        request.addParam("payTool", payTool.getCode());//支付方式(不传默认支付所有支付)
            request.addParam("merchantExpireTime", "");//订单有效期
            request.addParam("bankCode", "");//银行编码(payTool=SALESB2C或SALESB2B时)
            Date date = new Date();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            request.addParam("merchantOrderDate", sdf.format(date));//支付下单时间
            request.addParam("webCallbackUrl", returUrl);//前端通知页面
            request.addParam("serverCallbackUrl", notifyUrl);//后台异步通知
            request.addParam("productName", productName);
            request.addParam("productDesc", productDesc);
            request.addParam("mcc", "3101");//行业类型(电商:3101)
            request.addParam("productCatalog", "3101");//产品类别码同mcc
            request.addParam("templateType", "WAP");//WAP:显示页面title、APP:不显示
            YopResponse response = YopClient.post("/rest/v1.0/payplus/order/consume",request);
            String redirectUrl = "";
            String state = response.getState();//SUCCESS、FAILURE
            if("SUCCESS".equals(state)){
                Object result = response.getResult();
                if(null != result){
                    Map map = (Map) response.getResult();
                    String code = (String) map.get("code");
                    redirectUrl = (String) map.get("redirectUrl");//支付链接
                    String status = (String) map.get("status");//支付状态(UNPAY-未支付 SUCCESS-支付成功)
                    if("1".equals(code)){//成功
                        if("UNPAY".equals(status)){//未支付
                            logger.info(">>>>>>>>>>>>>>>>未支付!!");
                        }else if("SUCCESS".equals(status)){
                            logger.info(">>>>>>>>>>>>>>>>支付成功!!");
                        }else{
                            logger.info("系统服务异常,请稍后再试!!!");
                        }
                        logger.info(">>>>>>>>>>>>>>>>成功跳转钱麦支付收银台:"+redirectUrl);
                        return redirectUrl;
                        /*byte[] b = hex2byte(redirectUrl);//转成image
                        ByteArrayInputStream in = new ByteArrayInputStream(b);
                        BufferedImage image = ImageIO.read(in);
                        ImageIO.write(image, "jpg", new File("/Users/bin.guo/Desktop/IMG_5168.jpg"));
                        exec("open /Users/bin.guo/Desktop/IMG_5168.jpg");*/
                    }else{
                        logger.info(">>>>>>>>>>>ErrorCode:"+code);
                        logger.info(">>>>>>>>>>>ErrorMessage:"+response.getError());
                        redirectUrl = "ERROR";
                        return redirectUrl;
                    }
                }else{
                    logger.info("系统服务异常,请稍后再试!!!");
                    redirectUrl = "ERROR";
                    return redirectUrl;
                }
            }else if("FAILURE".equals(state)){
                logger.info(">>>>>>>>>>>ErrorCode:"+response.getError().getCode());
                logger.info(">>>>>>>>>>>ErrorMessage:"+response.getError().getMessage());
                redirectUrl = "FAILURE";
                return redirectUrl;
            }else{
                logger.info("系统服务异常,请稍后再试!!!");
                redirectUrl = "ERROR";
                return redirectUrl;
            }
        }
    
        public static void exec(String cmd) {
            try {
                String[] cmdA = {"/bin/sh", "-c", cmd};
                Runtime.getRuntime().exec(cmdA);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    
        /**
            转字节方法
        */
        public static byte[] hex2byte(String s) {
            byte[] src = s.toLowerCase().getBytes();
            byte[] ret = new byte[src.length / 2];
            for (int i = 0; i < src.length; i += 2) {
                byte hi = src[i];
                byte low = src[i + 1];
                hi = (byte) ((hi >= 'a' && hi <= 'f') ? 0x0a + (hi - 'a') : hi - '0');
                low = (byte) ((low >= 'a' && low <= 'f') ? 0x0a + (low - 'a'): low - '0');
                ret[i / 2] = (byte) (hi << 4 | low);
            }
            return ret;
        }
    
    
        /**
            测试方法
        */
        public static void main(String[] s) throws IOException {
            YeepayUtil.yeePayCall(0.01,0.01,PayTool.SALESB2C,"测试商品名称","测试商品描述","","", String.valueOf(System.currentTimeMillis()));
        }
    }
    在Action中调用以上工具类拿到返回支付链接开始进入支付,调用上面工具类YeepayUtil.yeePayCall()执行;
    
    String returUrl="支付成功还是失败都需要跳转的系统通知页面".replace("orderID", 订单对象.getId().toString());//进入对应的订单action处理返回页面通知
    String notifyUrl = "异步回调接口http://www.baidu.com/notify/yeePayNotify.do";
    String invokeUrl = "";//易宝支付返回的支付页面链接(提供前端location.href=invokeUrl)
    String transactionNo = cmFinanceReceipts.getOrderNo();//商户订单号
    String random= RandomCodeGenerator.generateCodeString(3);
    String requestNo = random + ":" + transactionNo;//商户请求号格式:3位随机码:订单号
    try {
       invokeUrl = YeepayUtil.yeePayCall(cmFinanceReceipts.getShouldPayAmount().doubleValue(),cmFinanceReceipts.getShouldPayAmount().doubleValue(),PayTool.SALESB2C,"大宗采购商品","大宗采购商品",returUrl,notifyUrl,requestNo);
    } catch (Exception e) {
       logger.error("交易单号"+transactionNo+"进行易宝createInvokeURL时出错");
       e.printStackTrace();
    }
    return invokeUrl;

    二、支付异步回调(只要是修改订单交易等 )

    回调类中添加如下回调接口以及方法。

    @RequestMapping(value = "yeePayNotify")
    public String yeePayNotify(@Param("response") String response){
        logger.info("易宝支付回调start....");
        String result = "FAILURE";//回调返回易宝支付成功还是失败,以便易宝不会总是请求回调
        try {
            String reString = YopClient.acceptNotificationAsJson(secretKey, response);//通过秘钥解析回调数据
            System.out.println(reString);
            Map<String, Object> paramsMap = json2map(reString);
            logger.info(">>>>>>>>>>>回调参数:"+paramsMap);
            if (null != paramsMap) {
                String code = "";
                String status = "";
                String requestNo = "";
                String paidAmount = "";
                if(null != paramsMap.get("merchantUserId")){
                    String merchantUserId = (String) paramsMap.get("merchantUserId");//商户用户唯一编号
                }
                if(null != paramsMap.get("orderAmount")){
                    String orderAmount = (String) paramsMap.get("orderAmount");//商户订单总金额
                }
                if(null != paramsMap.get("fundAmount")){
                    String fundAmount = (String) paramsMap.get("fundAmount");//实际需支付金额
                }
                if(null != paramsMap.get("cardLast")){
                    String cardLast = (String) paramsMap.get("cardLast");//用户支付银行卡卡号后四位
                }
                if(null != paramsMap.get("cardType")){
                    String cardType = (String) paramsMap.get("cardType");//用户支付银行卡的类别
                }
                if(null != paramsMap.get("bankCode")){
                    String bankCode = (String) paramsMap.get("bankCode");//用户支付银行卡的银行编码
                }
                if(null != paramsMap.get("requestNo")){
                    requestNo = (String) paramsMap.get("requestNo");//原商户请求号
                }
                if(null != paramsMap.get("paidAmount")){
                    paidAmount = (String) paramsMap.get("paidAmount");//已支付金额
                }
                if(null != paramsMap.get("status")){
                    status = (String) paramsMap.get("status");//订单状态(UNPAY:未支付、SUCCESS:支付成功、PROCESS:处理中)
                }
                if(null != paramsMap.get("code")){
                    code = (String) paramsMap.get("code");//返回码
                }
                if(null != paramsMap.get("message")){
                    String message = (String) paramsMap.get("message");//返回码的详细说明
                }
                logger.info(">>>>>>>>>>>返回码code:"+code + "状态status:"+status+"应付金额paidAmount:"+paidAmount+"商户请求号requestNo:"+requestNo);
                if(null != code && "1".equals(code)){//成功
                    if (StringUtils.isBlank(requestNo)) {
                        throw new BusinessException("requestNo is null");
                    }
                    if (StringUtils.isBlank(paidAmount)) {
                        throw new BusinessException("paidAmount is null");
                    }
                    if (StringUtils.isBlank(status)) {
                        throw new BusinessException("status is null");
                    }
                    String[] split = requestNo.split(":");//字符串:交易号或订单号
                    if(split.length !=2){
                        throw new BusinessException("参数校验失败");
                    }
                    String transactionNo = String.valueOf(split[1]);
                    if (status.equals("SUCCESS")) {
                            if (StringUtils.isBlank(transactionNo)) {
                                throw new BusinessException("参数校验失败");
                            }
                            //todo  一切正常情况下更新业务订单信息。变更订单状态等。
                        }
             } else {
                 result = "FAILURE";
                    }
           } else {
                 result = "FAILURE";
           }
     } catch (Exception e) {
                logger.error("易宝支付回调错误" + e.toString(), e);
                result = "FAILURE";
            }
            printOut(result);
            logger.info("易宝支付回调end....");
            return result;
    }
    
    /**
        打印输出结果
    */
    public void printOut(String content) {
        ServletActionContext.getResponse().setContentType("application/json;charset=utf-8");
        PrintWriter out = null;
        try {
            out = ServletActionContext.getResponse().getWriter();
            out.print(content);
            out.flush();
        } catch (Exception ex) {
            out.println(ex.toString());
        } finally {
            if (out != null) {
                try {
                    out.close();
                } catch (Exception e) {
                    logger.error(e.toString(), e);
                }
            }
        }
    }
    
    

    展开全文
  • php易宝对接

    2021-01-07 15:58:08
    } //申请分账,支付成功结果 5 秒后调用,在异步通知里调用 public function amount_apply($trade_no='',$divideRequestId='',$yibao_trade_no='',$fenrun_group=''){ // $divideDetail=[ // ['ledgerNo'=>'...

     下单 ,分账,完结,进件,退款,

    <?php 
    namespace app\admin\controller;
    use think\Controller;
    class Yibao extends Controller
    {
        static $privatekey="MIIE**********WyF/Jk5tPObHJWMg==";
    
      static $yopPublicKey ="MIIB*********QAB";
        
        
        
        
        public function  _initialize(){
            
            vendor('yibao.lib.YopClient3');
            
        }
        
        
        
           public function callback($response){
               vendor('yibao.lib.Util.YopSignUtils');
               vendor('yibao.lib.YopClient');
               $data=\YopSignUtils::decrypt($response,self::$privatekey,self::$yopPublicKey);  
                return $data; 
             
             
         }
        
        
        
        
         //获取token
         public  function  get_token($trade_no='',$merchantNo=''){
                  $order=db('order')->where('trade_no',$trade_no)->find();
                   
              
                  //判断是否需要分账
                  $fenrun_group=db('yibao_fenrun_group')->where('uid',$order['owner'])->select();
                  if(!$fenrun_group){
                      return '';
                  }
                   
                   
                //  $yibao=db('yibao_merchants')->where('uid',$order['owner'])->find();
                  $request = new \YopRequest($appKey='app_100*****', self::$privatekey);
                  $notify_url=config('questurl')."/index/yibao/pay_notify";
                  $request->addParam("parentMerchantNo",'10085795002');
                  $request->addParam("merchantNo",'10085795002');
                  $request->addParam("orderId",$trade_no);
                   if($fenrun_group){
                      
                       $request->addParam("fundProcessType",'DELAY_SETTLE');
                  }
                  $request->addParam("orderAmount",$order['unit_price']);
                  $request->addParam("goodsName",$order['goods_name']);
                  $request->addParam("notifyUrl",$notify_url);
               
                  $response = \YopClient3::post("/rest/v1.0/trade/order", $request);
                  $data=object_array($response);
                  if($order['pay_type']=='微信'){
                      $pay_tool='WECHAT_OPENID';
                  }else{
                      $pay_tool='ZFB_SHH';
                  }
                  if($data["result"]['code']=='OPR00000'){
                      db('order')->where('trade_no',$trade_no)->update(['uniqueOrderNo'=>$data["result"]['uniqueOrderNo'],'merchantNo'=>$merchantNo]);
                      $pay_data=$this->pay($pay_tool,$data["result"]['token'],$order['openid']);
                  }
                  if($pay_data['result']['code']=='CAS00000'){
                       $data=json_decode($pay_data['result']['resultData'],true);
                       $asort_data=[
                             'appId'=>$data['appId'],
                             'timeStamp'=>$data['timeStamp'],
                             'nonceStr'=>$data['nonceStr'],
                             'package'=>$data['package'],
                             'signType'=>'RSA',
                             'paySign'=>$data['paySign'],
                            ];
                      return $asort_data;
                  }else{
                      return '';
                      
                  }
                  
                 // dump($pay_data);
                  //return $data["result"]['token'];
         }
            
         //下单,聚合支付api
         
         public  function  pay($pay_tool='WECHAT_OPENID',$token="",$openId=''){
                
                  if($pay_tool=='WECHAT_OPENID'){
                     $pay_type="WECHAT";
                  }elseif($pay_tool=='ZFB_SHH'){
                     $pay_type="ALIPAY";
                  }elseif($pay_tool=='JSPAY'){
                     $pay_type='UPOP';
                  }
                  $extparamMap=['reportFee'=>'XIANXIA'];
                  $request = new \YopRequest($appKey='app_100*****', self::$privatekey);
                  $notify_url=config('questurl')."/api/index/pay_notify";
                  $request->addParam("payTool", $pay_tool);
                  $request->addParam("payType",$pay_type);
                  $request->addParam("token",$token);
                  $request->addParam("appId",config('appid'));
                  $request->addParam("openId",$openId);
                  $request->addParam("version",'1.0');
                  $request->addParam("userIp",'127.0.0.1');
                  $request->addParam("extParamMap",json_encode($extparamMap));
                  $response = \YopClient3::post("/rest/v1.0/nccashierapi/api/pay", $request);
                  $data=object_array($response);
                  return $data;
         }
         
         
         //申请分账,支付成功结果 5 秒后调用,在异步通知里调用
         public  function amount_apply($trade_no='',$divideRequestId='',$yibao_trade_no='',$fenrun_group=''){
                 
                 
                //   $divideDetail=[
                //           ['ledgerNo'=>'10085742333','amount'=>'0.01','divideDetailDesc'=>'测试结算'],
                //         ];
                 $order=db('order')->where('trade_no',$trade_no)->find(); 
                 
                 
                 $yibao_trade_no=$order['uniqueOrderNo'];
                 $fenrun_group=db('admin_order_profit')->where('order_id',$order['id'])->select();
                 $divideRequestId=$fenrun_group[0]['divideRequestId'];
                  $divideDetail=[];
                  foreach($fenrun_group as $v){
                      $arr=[];
                      $arr['ledgerNo']=$v['ledgerNo'];
                      $arr['amount']=$v['amount'];
                      $arr['divideDetailDesc']='分成结算';
                      $divideDetail[]=$arr;
                  }
                  $order=db('order')->where('trade_no',$trade_no)->find();
                  $yibao=db('yibao_merchants')->where('uid',$order['owner'])->find();
                  $request = new \YopRequest($appKey='app_10085795002', self::$privatekey);
                  $request->addParam("parentMerchantNo", '10085795002');
                  $request->addParam("merchantNo",'10085795002');
                  $request->addParam("orderId",$trade_no);
                  $request->addParam("uniqueOrderNo",$yibao_trade_no);
                  $request->addParam("divideRequestId",$divideRequestId);
                  $request->addParam("divideDetail",json_encode($divideDetail));
                  $response = \YopClient3::post("/rest/v1.0/divide/apply", $request);
                  $data=object_array($response);
                  if($data['result']['status']=='SUCCESS'){
                       $detail=json_decode($data['result']['divideDetail'],true);
                       foreach($detail as $v){
                           db('admin_order_profit')->where('order_id',$order['id'])->where('ledgerNo',$v['ledgerNo'])->update(['divideDetailNo'=>$v['divideDetailNo']]);
                       }
                       $this->amount_complete($trade_no,$yibao_trade_no,$divideRequestId);
                  }
                  
                 
                 // echo(json_encode($data));
                  //return $data;
         }
         //完结分单
         public function amount_complete($trade_no,$yibao_trade_no,$divideRequestId){
                  $order=db('order')->where('trade_no',$trade_no)->find(); 
                 $request = new \YopRequest($appKey='app_10085795002', self::$privatekey);
                  $request->addParam("parentMerchantNo", '10085795002');
                  $request->addParam("merchantNo",'10085795002');
                  $request->addParam("orderId",$trade_no);
                  $request->addParam("uniqueOrderNo",$yibao_trade_no);
                  $request->addParam("divideRequestId",$divideRequestId);
                  $response = \YopClient3::post("/rest/v1.0/divide/complete", $request);
                  $data=object_array($response);
                  if($data['result']['divideStatus']=='SUCCESS'){
                      db('admin_order_profit')->where('divideRequestId',$divideRequestId)->update(['status'=>'1']);
                  }
                  
               //  echo(json_encode($data));
               //  echo '..........';
             
             
             
         }
         //分账查询
         public  function amount_query($trade_no='',$yibao_trade_no='',$divideRequestId=''){
                //  $trade_no='2012081023012802';
                // $divideRequestId='1607394194166';
                // $yibao_trade_no='1013202012080000001934058224';
                 $order=db('order')->where('trade_no',$trade_no)->find(); 
                  $request = new \YopRequest($appKey='app_10085795002', self::$privatekey);
                  $request->addParam("parentMerchantNo", '10085795002');
                  $request->addParam("merchantNo",'10085795002');
                  $request->addParam("orderId",$trade_no);
                  $request->addParam("uniqueOrderNo",$yibao_trade_no);
                  $request->addParam("divideRequestId",$divideRequestId);
                  $response = \YopClient3::get("/rest/v1.0/divide/query", $request);
                  $data=object_array($response);
                   echo(json_encode($data));
             
             
         }
         
         //分账资金退还,先申请资金退还,再退款
         public function amount_back($trade_no){
                 $order=db('order')->where('trade_no',$trade_no)->find();
    
                 $divideBackRequestId=time().mt_rand(1111,9999);
                 $refundRequestId=time().mt_rand(1111,9999);
                 if($order['owner']==1){
                      db('order')->where('trade_no',$trade_no)->update(['refundRequestId'=>$refundRequestId]);  
                      $data=$this->refund($trade_no,$order['uniqueOrderNo'],$refundRequestId,$order['unit_price']);
                      return $data;
                 }else{
                     $fenrun_group=db('admin_order_profit')->where('order_id',$order['id'])->select();
                     $divideBackDetail=[];
                     foreach($fenrun_group as $v){
                         $arr=[];
                         $arr=[
                             'amount'=>$v['amount'],
                             'divideBackReason'=>'用户退款',
                             'divideDetailNo'=>$v['divideDetailNo']
                             ]; 
                        $divideBackDetail[]=$arr; 
                     }
                 
             
                  $request = new \YopRequest($appKey='app_10085795***', self::$privatekey);
                  $request->addParam("parentMerchantNo", '10085795****');
                  $request->addParam("merchantNo",'10085795002');
                  $request->addParam("divideBackRequestId",$divideBackRequestId);
                  $request->addParam("divideRequestId",$fenrun_group[0]['divideRequestId']);
                  $request->addParam("orderId",$trade_no);
                  $request->addParam("uniqueOrderNo",$order['uniqueOrderNo']);
                  
                  $request->addParam("divideBackDetail",json_encode($divideBackDetail));
                  $response = \YopClient3::post("/rest/v1.0/divide/back", $request);
                  $data=object_array($response);
                  file_put_contents('./fenzhangback.txt',json_encode($data).PHP_EOL,FILE_APPEND);
                  if($data['result']['status']=='SUCCESS'){
                      db('order')->where('trade_no',$trade_no)->update(['refundRequestId'=>$refundRequestId,'uniqueDivideBackNo'=>$data['result']['uniqueDivideBackNo']]);  
                      $data=$this->refund($trade_no,$order['uniqueOrderNo'],$refundRequestId,$order['unit_price']);
                      return $data;
      
                      
                  }else{
                    return $data;
                  }
                 }              
      
         }
         
         //用户退款,先调用申请分账金额退还,再调用此接口
         public  function refund($trade_no='',$yibao_trade_no='',$refundRequestId='',$refundAmount=''){
                 // $trade_no='2012081427496710';
                 // $yibao_trade_no='1013202012080000001934544161';
                  $refundRequestId='20201234033322';
                //  $refundAmount='1';
                  $refund_noitfy=config('questurl').'/admin/Yibao/refund_notify';
                  $request = new \YopRequest($appKey='app_10085795002', self::$privatekey);
                  $request->addParam("parentMerchantNo", '10085795002');
                  $request->addParam("merchantNo",'10085795002');
                  $request->addParam("orderId",$trade_no);
                  $request->addParam("refundRequestId",$refundRequestId);
                  $request->addParam("uniqueOrderNo",$yibao_trade_no);
                  $request->addParam("refundAmount",$refundAmount);
                  $request->addParam("description",'用户申请退款');
                  $request->addParam("notifyUrl",$refund_noitfy);
                  $response = \YopClient3::post("/rest/v1.0/trade/refund", $request);
                  $data=object_array($response);
                //  echo json_encode($data);
                  //dump($data);
                   return $data;
         }
         
         public function refund_notify(){
             
                $data=input('');
                $res=$this->callback($data['response']);
                 file_put_contents('./pay_frund.txt',$res.PHP_EOL,FILE_APPEND);
    
                $res=json_decode($res,true);
                // var_dump($res);exit;
                 if($res['status']=='SUCCESS'){
                      db('order')->where('trade_no',$res['orderId'])->update(['trade_status'=>3]);
                  }
                  echo 'SUCCESS';
         }
         
         
         //设置授权目录
         public function set_pay_url($mmo){
             
                  $tradeAuthDirList=[
                        "http://www.baidu.com/"
                     ];
                  $appIdList=[
                               [
                                 "appId"=>config('appid'),
                                 "appIdType"=>"OFFICIAL_ACCOUNT",
                                 "subscribeAppId"=>config('appid')
                               ]
                            ];
                  $request = new \YopRequest($appKey='app_10085795**', self::$privatekey);
                  $request->addParam("parentMerchantNo", '10085795***');
                  $request->addParam("merchantNo",'10085795002');
                  $request->addParam("tradeAuthDirList",json_encode($tradeAuthDirList));
                  $request->addParam("appIdList",json_encode($appIdList));
                  $response = \YopClient3::post("/rest/v1.0/divide/apply", $request);
                  $data=object_array($response);
                  dump($data);
         }
         
         
         //支付结果通知
         public  function  pay_notify(){
             
                file_put_contents('./pay_notify.txt',json_encode(input('')).PHP_EOL,FILE_APPEND);
                
                $data=input('');
                $res=$this->callback($data['response']);
                $res=json_decode($res,true);
                if($res['status']=='SUCCESS'){
                      $trade_no=$res['orderId'];
                      //查询回调的次数
                      $callback_time=db('order')->where('trade_no',$trade_no)->value('callback_time');
                      if($callback_time<1){
                          db('order')->where('trade_no',$trade_no)->update(['trade_status'=>'1']);
                          db('order')->where('trade_no',$trade_no)->setInc('callback_time',1);
                           //进行出货
                          
                          
                          
                       }else{
                           //如果不需要分账
                           $order=db('order')->where('trade_no',$trade_no)->find();
                           //判断是否需要分账
                           $fenrun_group=db('yibao_fenrun_group')->where('uid',$order['owner'])->select();
                           $fen=[];
                           if($fenrun_group){
                               $map['order_id']=$order['id'];
                               $map['divideRequestId']=time().mt_rand(111,999);
                               foreach ($fenrun_group as $k=>$v){
                                   $map['admin_id']=$v['fenrun_admin_id'];
                                   $merchantNo=db('yibao_merchants')->where('uid',$v['fenrun_admin_id'])->value('merchantNo');
                                   $map['ledgerNo']=$merchantNo;
                                   $map['amount']=$v['fenrun']*$order['unit_price']*0.01;
                                   db('admin_order_profit')->insert($map);
                                   $fen[$k][]=$map;
                               }
                               
                              $this->amount_apply($trade_no,$map['divideRequestId'],$order['uniqueOrderNo'],$fen);
                           }
                           echo 'SUCCESS'; 
                       }
                }
             
         }
         
         public  function  in_notify(){
             
               file_put_contents('./yibao_micro_notify.txt',date('Y-m-d H:i:s',time()).'<>'.json_encode(input('')).PHP_EOL,FILE_APPEND);
                $data=input('');
                $res=$this->callback($data['response']);
                $res=$this->callback($data['response']);
                $res=json_decode($res,true);
                if($res['applicationStatus']=='COMPLETED'){
                    db('yibao_merchants')->where('requestNo',$res['requestNo'])->update(['merchantNo'=>$res['merchantNo']]);
                }else{
                     db('yibao_merchants')->where('requestNo',$res['requestNo'])->update(['agreementSignUrl'=>$res['agreementSignUrl'],'auditOpinion'=>$res['auditOpinion']]);
                }
         }
         
         
         public function callback($response){
               vendor('yibao.lib.Util.YopSignUtils');
               vendor('yibao.lib.YopClient');
               $data=\YopSignUtils::decrypt($response,self::$privatekey,self::$yopPublicKey);  
                return $data; 
             
             
         }
         
         public function hui_no(){
             
             
             
             
             
                $data=json_decode($data,true);
                $res=$this->callback($data['response']);
                $res=$this->callback($data['response']);
                $res=json_decode($res,true);
                
                dump($res);exit;
               
                 if($res['applicationStatus']=='COMPLETED'){
                    db('yibao_merchants')->where('requestNo',$res['requestNo'])->update(['merchantNo'=>$res['merchantNo']]);
                }else{
                    
                     db('yibao_merchants')->where('requestNo',$res['requestNo'])->update(['agreementSignUrl'=>$res['agreementSignUrl'],'auditOpinion'=>$res['auditOpinion']]);
                    
                }
              
             
             
             
         }
         
         
         
          public function amount_back_test($trade_no){
                 $order=db('order')->where('trade_no',$trade_no)->find();
    
                 $divideBackRequestId=time().mt_rand(1111,9999);
                 $refundRequestId=time().mt_rand(1111,9999);
             
                     $fenrun_group=db('admin_order_profit')->where('order_id',$order['id'])->select();
                     $divideBackDetail=[];
                     foreach($fenrun_group as $v){
                         $arr=[];
                         $arr=[
                             'amount'=>$v['amount'],
                             'divideBackReason'=>'用户退款',
                             'divideDetailNo'=>$v['divideDetailNo']
                             ]; 
                        $divideBackDetail[]=$arr; 
                     }
                 
             
                  $request = new \YopRequest($appKey='app_1008579****', self::$privatekey);
                  $request->addParam("parentMerchantNo", '10085795****');
                  $request->addParam("merchantNo",'10085795****');
                  $request->addParam("divideBackRequestId",$divideBackRequestId);
                  $request->addParam("divideRequestId",$fenrun_group[0]['divideRequestId']);
                  $request->addParam("orderId",$trade_no);
                  $request->addParam("uniqueOrderNo",$order['uniqueOrderNo']);
                  
                  $request->addParam("divideBackDetail",json_encode($divideBackDetail));
                  $response = \YopClient3::post("/rest/v1.0/divide/back", $request);
                  $data=object_array($response);
                  echo json_encode($data);
                     
      
         }
         
         
          //商户激活
         public  function merchant_active(){
            if(request()->isAjax() && request()->isPost()){
                   
               
                 $id=input('id');
                 $data=db('yibao_merchants')->where('id',$id)->find();
                 //判断是小微还是平台  1:小微  2:平台
                 if($data['type']=='1'){
                 
                    $data=$this->mirco_active($data);
    
                 }else{
                     $data=$this->platm_active($data);
                 
                 }
                 if($data['request']['returnCode']=='NIG00000'){
                     
                     $arr=['status'=>'1','msg'=>'申请成功'];
                 }else{
                     
                     $arr=['status'=>'0','msg'=>$data['result']['returnMsg']];
                 }
                 echo json_encode($arr);
                 exit;
                     
            }
         }
      
       //小微商户激活
       public  function mirco_active($data){
             vendor('yibao.lib.YopClient3');
             $arr=[
                     'requestNo'=>$data['requestNo'],
                     'parentMerchantNo'=>$data['parentMerchantNo'],
                     'merchantSubjectInfo'=>[
                                              'signName'=>$data['signName'],
                                              'shortName'=>$data['shortName']
                      ],
                     'merchantCorporationInfo'=>[
                                              'legalLicenceType'=>'ID_CARD',
                                              'legalLicenceNo'=>$data['legalLicenceNo'],
                                              'legalLicenceFrontUrl'=>$data['legalLicenceFrontUrl'],
                                              'legalLicenceBackUrl'=>$data['legalLicenceBackUrl'],
                                              'mobile'=>$data['mobile'] 
                        ],   
                      'businessAddressInfo'=>[
                                             'province'=>$data['province'],
                                             'city'=>$data['city'],
                                             'district'=>$data['district'],
                                             'address'=>$data['address'],
                                           
                       ],
                       'accountInfo'=>[
                                          'bankAccountType'=>'DEBIT_CARD',
                                          'bankCardNo'=>$data['bankCardNo'],
                                           'bankCode'=>$data['bankCode'],
                        ],
                       'productInfo'=>[
                               
                                ["productCode"=>"T1","rateType"=>"SINGLE_FIXED","fixedRate"=>"0"]
                               
                        ],
                       'notifyUrl'=>"/index/yibao/in_notify"      
                   ];
             
         
                  $request = new \YopRequest($appKey='app_100857**', self::$privatekey);
                  $request->addParam("requestNo", $data['requestNo']);
                  $request->addParam("parentMerchantNo",'10085795***');
                  $request->addParam("merchantSubjectInfo", json_encode($arr['merchantSubjectInfo']));
                  $request->addParam("merchantCorporationInfo",json_encode($arr['merchantCorporationInfo']));
                  $request->addParam("businessAddressInfo",json_encode($arr['businessAddressInfo']));
                  $request->addParam("accountInfo",json_encode($arr['accountInfo']));
                  $request->addParam("productInfo",json_encode($arr['productInfo']));
                  $request->addParam("notifyUrl",$arr['notifyUrl']);
                  
                  $response = \YopClient3::post("/rest/v2.0/mer/register/saas/micro", $request);
                  $data=object_array($response);
                 
                  db('yibao_merchants')->where('requestNo',$map['requestNo'])->update(['applicationNo'=>$data['result']['applicationNo']]);
                  return $data;
                 //echo json_encode($response);      
       }
      
      
      
       //平台商激活
       public  function platm_active($data){
                 
               vendor('yibao.lib.YopClient3');
               $map=[
                        'requestNo'=>$data['requestNo'],  
                        'parentMerchantNo'=>$data['parentMerchantNo'],
                        'businessRole'=>$data['type']==2?'PLATFORM_MERCHANT':'SETTLED_MERCHANT', 
                        'merchantSubjectInfo'=>[
                                            'signType'=>$data['signType']=='1'?'INDIVIDUAL':'ENTERPRISE',
                                            'licenceNo'=>$data['licenceNo'],
                                            'licenceUrl'=>$data['licenceUrl'],
                                            'signName'=>$data['signName'],
                                            'shortName'=>$data['shortName'],
                                            'handLicenceUrl'=>$data['handLicenceUrl'],
                                          'openAccountLicenceNo'=>$data['openAccountLicenceNo'],
                                      'openAccountLicenceUrl'=>$data['openAccountLicenceUrl']
                        ],
                        'merchantCorporationInfo'=>[
                                             'legalName'=>$data['legalName'],
                                             'legalLicenceType'=>'ID_CARD',
                                             'legalLicenceNo'=>$data['legalLicenceNo'],
                                             'legalLicenceFrontUrl'=>$data['legalLicenceFrontUrl'],
                                             'legalLicenceBackUrl'=>$data['legalLicenceBackUrl'],
                        ],
                        'merchantContactInfo'=>[
                                              'contactName'=>$data['contactName'],
                                              'contactMobile'=>$data['contactMobile'],
                                              'contactEmail'=>$data['contactEmail']
                        ],
                        'businessAddressInfo'=>[
                                             'province'=>$data['province'],
                                             'city'=>$data['city'],
                                             'district'=>$data['district'],
                                             'address'=>$data['address'],
                         ],
                        'settlementAccountInfo'=>[
                                            'settlementDirection'=>'BANKCARD',
                                            'bankAccountType'=>$data['bankAccountType'],
                                            'bankCardNo'=>$data['bankCardNo'],
                                            'bankCode'=>$data['bankCode'],
                         ],
                       'productInfo'=>[
                          /**
                           * 
                           *   平台商需要此结算
                                ["productCode"=>"MERCHANT_SCAN_ALIPAY_OFFLINE","rateType"=>"SINGLE_PERCENT","percentRate"=>"0.3"],
                                ["productCode"=>"WECHAT_OFFIACCOUNT_WECHAT_OFFLINE","rateType"=>"SINGLE_PERCENT","percentRate"=>"0.3"],
                                **/
                                
                                ["productCode"=>"T1","rateType"=>"SINGLE_FIXED","fixedRate"=>"0"]
                             
                        ],
                     //  'notifyUrl'=>"/api/index/notify"   
                       'notifyUrl'=>"/index/yibao/in_notify" 
                    ];
        
                                 
         
                  $request = new \YopRequest($appKey='app_100857***', self::$privatekey);
    
                  $request->addParam("requestNo", $map['requestNo']);
                  $request->addParam("parentMerchantNo", '10085795002');
                  $request->addParam("businessRole", $map['businessRole']);
                  $request->addParam("merchantSubjectInfo", json_encode($map['merchantSubjectInfo']));
                  $request->addParam("merchantCorporationInfo", json_encode($map['merchantCorporationInfo']));
                  $request->addParam("merchantContactInfo", json_encode($map['merchantContactInfo']));
                  $request->addParam("businessAddressInfo",json_encode($map['businessAddressInfo']));
                  $request->addParam("settlementAccountInfo",json_encode($map['settlementAccountInfo']));
                  $request->addParam("productInfo",json_encode($map['productInfo']));
                  $request->addParam("notifyUrl",$map['notifyUrl']);
                                       
                 $response = \YopClient3::post("/rest/v2.0/mer/register/saas/merchant", $request);
                 $data=object_array($response);
                 
                 db('yibao_merchants')->where('requestNo',$map['requestNo'])->update(['applicationNo'=>$data['result']['applicationNo']]);
                 return $data;
                  //echo json_encode($response);  
        
       
       
     
       
       
       
         }
      
        
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
        //上传文件
       public  function  upload_licence(){
             $params['file']=input('file');
             vendor('yibao.lib.YopClient3');
    		           
             $request = new \YopRequest($appKey='app_1008574***, self::$privatekey);
             // $data=file_get_contents('./'.$params['file']);
           //  dump($params['file']);
             
             $request->addFile("merQual",'/www/wwwroot/m_apl1986_com/public/'.$params['file']);
             $response = \YopRsaClient::upload("/yos/v1.0/sys/merchant/qual/upload", $request);
             
          //   $request->addFile("merQual",$params['file']);
          //   $response = \YopRsaClient::upload("/yos/v1.0/sys/merchant/qual/upload", $request);
              $data=object_array($response);
             //dump($data);
         
             if($data['state']=='SUCCESS'){
                $arr=[
                    'status'=>'1',
                    'info'=>$data['result']['merQualUrl']
                  ];
             
             }else{
                  $arr=[
                    'status'=>'0',
                    'info'=>''
                  ];
             }
             echo json_encode($arr);
             exit; 
       }
      
         
         
         
         
    
    
    }

     

    展开全文
  • sendMultiOrderQuery.php

    2021-05-08 05:09:35
    require_once ("./lib/YopClient3.php");function object_array($array) {if(is_object($array)) {$array = (array)$array;} if(is_array($array)) {foreach($array as $key=>$value) {$array...

空空如也

空空如也

1
收藏数 7
精华内容 2
关键字:

易宝支付yopclient