自己封装的微信支付与支付宝支付(服务端)

自己封装的微信支付与支付宝支付(服务端)。返回结果请自行处理


功能包括:1、微信调起App端支付、统一下单、支付订单查询、退款

                     2、支付宝调起App端支付、wap端调起支付、支付订单查询、退款

                     3、无需添加阿里外部jar包



用法:

          //初始化

          WxPay pay = WxPay.newInstance().init("app_id", "mch_id", "key");

        // 微信统一下单
        WxCreateOrderModel model = new WxCreateOrderModel();
        model.setNotify_url("url");
        model.setTotal_fee("1");
        model.setSpbill_create_ip("192.168.1.153");
        model.setBody("我在测试");
        model.setTrade_type("APP");//如果是微信公众号,请传JSAPI , 并赋值model.setOpenid(your openid);
        model.setOut_trade_no("T123456789d");
        String response = pay.createPayOrder(model);
 

        

        // APP端调起微信支付
        String payStr = pay.startAppPay(new WxPayModel("支付单号"));
      

        // 微信查询订单
        WxQueryOrderModel queryModel = new WxQueryOrderModel("W20171102094432010");
        String query = pay.query(queryModel);


         // 微信退款
        WxFefundModel fefundModel = new WxFefundModel("W20171102093907008", "4200000010201711021869587164", "2", "2");
        String fefund = pay.refund(fefundModel, new P12CerModel("c:/apiclient_cert.p12"));

       

        ************************** 支付宝 *********************************

        //初始化

        AliPay aliPay = AliPay.newInstance().init("app_id", "partner", "seller",PRIVATEKEY, PUBLICKEY);
        

         //调起支付

         AliPayModel aliCreateOrderModel = new AliPayModel();
        aliCreateOrderModel.setBody("testBody");
        aliCreateOrderModel.setNotify_url("http://192.168.1.153/notify");
        aliCreateOrderModel.setOut_trade_no("Z20171101ce");
        aliCreateOrderModel.setSubject("test");
        aliCreateOrderModel.setTotal_fee("0.01");
        String createPayOrder = aliPay.startAppPay(aliCreateOrderModel);


         //支付宝wap支付
         AliWapPayModel wap = new AliWapPayModel();
         wap.setNotify_url("http://192.168.1.153/notify");
         wap.setReturn_url("http://192.168.1.153/notify");
         wap.setTotal_amount("1");
         wap.setSubject("测试");
         wap.setOut_trade_no("Z123456789");
         String startWapPay = aliPay.startWapPay(wap);


          // 订单查询
        QueryResponse queryResponse = aliPay.query("out_trade_no");


         //退款

         // 支付宝退款
        AliRefundModel model = new AliRefundModel();
        model.setOut_request_no("R123456");
        model.setOut_trade_no("A123456");
        model.setRefund_amount("12");
        model.setRefund_reason("正常退款");
        RefundResponse refundResponse = aliPay.refund(model);



下载地址:点击打开链接

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值