Git Product home page Git Product logo

wxpay_jsapi's Introduction

wxpay_jsapi

Java实现JsApi方式的微信支付。进行JsApi支付,需要先通过https://api.mch.weixin.qq.com/pay/unifiedorder 获得一个prepay_id

UnifiedOrderReqData reqData = new UnifiedOrderReqData.UnifiedOrderReqDataBuilder("appid", "mch_id",
                "body", "out_trade_no", 1, 
                "spbill_create_ip", "notify_url", "JSAPI")
                .setOpenid("openid").build();
Map<String, Object> resultMap = WxPayApi.UnifiedOrder(reqData);

return_code 和result_code都为SUCCESS的时候,可以得到我们需要的prepay_id,然后通过微信中内置的jsapi进行支付即可;

支付成功之后,微信会对指定的notify_url进行调用我们从request中获得传回来的xml之后,可以调用

String responseXml = new PayNotifyTemplate(requestXml).execute(new PaySuccessCallBack() {
    @Override
    public void onSuccess(PayNotifyData payNotifyData) {
      //进行业务处理

      //如果处理失败,抛出异常
    }
});

然后把responseXml 写到response中。

wxpay_jsapi's People

Contributors

hupengcool avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.