编程知识 cdmana.com

For the Java wechat payment V3 development package, I found at least six errors in wechat payment documents

1. Preface

I've been busy recently , It's rare to have a chance to breathe today. I'd like to share some of the achievements in the development . I shared a wechat payment I wrote a few days ago V3 Development package for payment-spring-boot-starter, Just taking time off from work has perfected a wave of .

Project address : github.com/NotFound403/payment-spring-boot

Don't forget to give it Star ah , Ask questions ISSUE.

So what have been improved ? Let me introduce .

2. Maven The central warehouse

Yes , You don't have to compile and deploy yourself , I have submitted to Maven Central warehouse . The latest coordinates are :

<dependency>
    <groupId>cn.felord</groupId>
    <artifactId>payment-spring-boot-starter</artifactId>
    <version>1.0.1.RELEASE</version>
</dependency>

This is a bit of a serious open source project .

3. More functions

In the last sharing, we only realized the voucher ability of wechat payment , More wechat payment capabilities have been added this time :

  • Wechat payment V3 The basic payment of - Direct mode optimization .
  • Realize wechat payment V3 Payment by contract .

At the same time, we have realized the multi merchant by ourselves 、 many APPID Of Multi tenant model . The follow-up wechat payment grading function will also be accessed .

4. Perfect the example

Most students still like to use it as soon as possible , So I wrote another DEMO project , For example, the controller code of wechat payment callback :

    /**
     *  Wechat payment callback succeeded .
     * <p>
     *  There's no need for developers to judge , Only if the deduction is successful, wechat will call back this interface 
     *
     * @param wechatpaySerial    the wechatpay serial
     * @param wechatpaySignature the wechatpay signature
     * @param wechatpayTimestamp the wechatpay timestamp
     * @param wechatpayNonce     the wechatpay nonce
     * @param request            the request
     * @return the map
     */
    @SneakyThrows
    @PostMapping("/transaction")
    public Map transactionCallback(
            @RequestHeader("Wechatpay-Serial") String wechatpaySerial,
            @RequestHeader("Wechatpay-Signature") String wechatpaySignature,
            @RequestHeader("Wechatpay-Timestamp") String wechatpayTimestamp,
            @RequestHeader("Wechatpay-Nonce") String wechatpayNonce,
            HttpServletRequest request) {
        String body = request.getReader().lines().collect(Collectors.joining());
        //  Check the signature of the request header   To ensure that it is the call of wechat server 
        ResponseSignVerifyParams params = new ResponseSignVerifyParams();
        params.setWechatpaySerial(wechatpaySerial);
        params.setWechatpaySignature(wechatpaySignature);
        params.setWechatpayTimestamp(wechatpayTimestamp);
        params.setWechatpayNonce(wechatpayNonce);
        params.setBody(body);
        return wechatApiProvider.callback(TENANT_ID).transactionCallback(params, data -&gt; {
            //TODO  Consume the result of callback resolution 
        });
    }
 

Basically, it can be copied and used . For more, see payment-spring-boot-samples project :

Address :github.com/NotFound403/payment-spring-boot-samples

Please pay attention to protect the security of sensitive parameters , Don't let it out .

5. file

Writing documents is really a boring thing , Reference to other open source projects, made a decent document :

The address is :notfound403.github.io/payment-spring-boot

 Document cover

Quick access guide 、JavaDoc、 Step on the pit to share all in the document . If there is anything that needs to be improved, you can submit it ISSUE.

Today's sharing is here , If you have any problems in wechat payment, you can leave a message and ask questions , I'm willing to help as much as I can , Sharing makes me happy .

Click to see more

版权声明
本文为[osc_ 1i3ltp99]所创,转载请带上原文链接,感谢
https://cdmana.com/2020/12/20201225083918602b.html

Scroll to Top