Java WeChat payment official account payment, scan code payment example

Wechat payment has become more and more popular, and then there are many products that can quickly access wechat payment as a gimmick. However, in addition to convenience, it also makes us slowly rely on a third party and lose the ability to think independently. This time, I intend to share the wechat payment I developed before.

I. payment of H5 official account

Key points: correctly obtain openid and unified order interface, correctly handle payment result notification, and correctly configure payment authorization directory

H5 payment method is widely used. This payment method is mainly used for web pages with customized menus in wechat. Depending on the wechat client installed on the mobile phone, the higher version of wechat supports wechat payment. Please note the following according to my process

1 write a page for payment. It's a little easier to write because it's for testing

2 write a servlet to get the code through OAuth

3. After obtaining the code, obtain the openid through redirecturi and call the unified ordering interface

When calling wechat unified order interface, you need to pay attention to the signature algorithm. Only when the signature calculation is correct can the payment be made smoothly

4. Write the final payment interface and call up wechat H5 payment

5. Processing wechat payment result notification

For the above code, there are many references http://blog.csdn.net/u011160656/article/details/41759195 Therefore, this part of the code will not be posted. If necessary, just read this blog.

II. Wechat code scanning payment (mode 1)

Important: you must call the long link to short link interface and correctly configure the code scanning payment callback URL

1. Generate wechat payment QR code according to the order number

Here are several methods to generate QR codes:

This is a tool class. Another method is to display the QR code on the interface. Createqrcode mainly uses code blocks:

2. Convert long link to short link to generate QR code, write code scanning payment callback method and call unified order interface

Finally, look at the WeChat configuration of official account payment and scan code payment.

I hope that through this article, we can understand that even if we use WeChat to do WeChat official account and WeChat payment without Java, we can develop WeChat applications which are satisfied with ourselves and customers. Although the demos given by wechat are all PHP, these are floating clouds, and the development language is the second. Understanding the bottom layer required for interface calls is only a required course for programmers.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>