Java Payment family bucket: enterprise-class all kinds of payment means one-stop solution

In chapter 1, we will have a preliminary understanding of the Java enterprise-class payment one-stop solution. In chapter two, we will carry out a pre-school preparation, which is divided into four sections. We need to learn and master the differences and differences between wechat, Alipay and UnionPay, learn to create a database and install the development tools we need to use.

Create database, the following SQL code:

“`DROP TABLE IF EXISTS tb_order; CREATE TABLE tb_ORDER (id int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT ‘主键’, Code varchar(200) CHARACTER SET utf8 COLLATE UTf8_general_ci NOT NULL COMMENT ‘ User_id int(10) UNSIGNED NULL DEFAULT NULL COMMENT ‘Member ID’, amount Decimal (10, 2) UNSIGNED NOT NULL COMMENT’ total amount ‘, Payment_type tinyint(3) UNSIGNED NOT NULL COMMENT ‘方 法 : 1 wechat,2 alipay,3 UnionPay ‘, status tinyint(3) UNSIGNED NOT NULL COMMENT’ status: Create_time TIMESTAMP (0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ‘create_time ‘, PRIMARY KEY (id) USING BTREE, UNIQUE INDEX unq_code(code) USING BTREE, INDEX idx_customer_id(user_id) USING BTREE, INDEX idx_status(status) USING BTREE, INDEX idx_create_time(create_time) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = Utf8_general_ci COMMENT = ‘order table’ ROW_FORMAT = Dynamic;

After learning how to create a database, we need to learn how to install and configure the development environment. We need to download HBuilderX, go to the website to download the latest version, and install it is easy to click next, next. Next we need to download the following things. ! [image.png](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/fc1adfb2eae4490ab66103e1ae94f2e1~tplv-k3u1fbpfcp-watermark .image) ! [image.png](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/fbe1e1cde90b43c1a0173938fac5b8c9~tplv-k3u1fbpfcp-watermark The third chapter is to learn the types of wechat payment, register wechat public platform account, Opened small program to pay bills, pay small program interface principle, the back-end project of user management module, first create a small application project, the overhand experience UNI - APP framework, obtain WeChat landing scrip, write the back-end for open_id program, submit WeChat account login request, perform the function of register and login to use part of the code is as follows: 1, demo.zip\demo\ app. vue ' '<script> export default {onLaunch: function() {console.log('App Launch')}, onShow: function() { console.log('App Show') }, onHide: Function () {console.log('App Hide')}} </script> <style>Copy the code

2, demos.zip \ demo \ pages, order, order. Vue

<view class="page"> <view class="order" v-for="one in list" :key="one"> <view class="line-1"> <text> {{one. Code}} < / text > < text > {{one. The status}} < / text > < view > < the view class = "line - 2" > < text > suppose here is brief information commodity < / text > < / view > < the view Class ="line-3"> <text> ${{one. Amount}} < / text > < button class = "pay - BTN" type = "primary" v - if = "one. The status = = 'not paying'" @ tap = "pay (one) id)" > payment < / button > </view> </view> </view> </template> <script> export default { data() { return { list: [], token: "" } }, methods: {pay: function(id) {let that = this if (thate.appenv == 'wechat ') {uni. Request ({url: that.url.wx.microAppPayOrder, method: "POST", header: { "token": uni.getStorageSync("token") }, data: { "orderId": id }, success: function(resp) { // console.log(resp) let timeStamp = resp.data.timeStamp let nonceStr = resp.data.nonceStr let pk = resp.data.package let paySign = resp.data.paySign uni.requestPayment({ "timeStamp": timeStamp, "nonceStr": nonceStr, "package": pk, "signType": "MD5", "paySign": paySign, success: function() { uni.showToast({ title: "Pay for success"}) / / initiate request uni. Request ({url: that url. Wx. UpdateOrderStatus, method: "POST", the header: {" token ": uni.getStorageSync("token") }, data: { "orderId": id }, success: function(resp) { let pages = getCurrentPages() let page = pages[pages.length - 1] page.onShow() }, fail: Function () {console.log(" update order status failed ")}})}, fail: function() {uni.showtoast ({title: "Payment failure"})}}}})} else if (that) appEnv = = 'alipay applet') {uni. Request ({url: that url. ZFB. MicroAppPayOrder, method: "POST", header: { // "token": uni.getStorageSync("token") "token": that.token }, data: { "orderId": id }, success: function(resp) { // console.log(resp) let prepayId = resp.data.prepayId uni.requestPayment({ provider: "alipay", orderInfo: prepayId, success: function(resp) { if (resp.resultCode == 9000) { uni.showToast({ title: "Pay for success"}) uni. Request ({url: that url. ZFB. UpdateOrderStatus, method: "POST", the header: { // "token":uni.getStorageSync("token") "token": that.token }, data: { "orderId": id }, success: function(resp) { let pages = getCurrentPages() let page = pages[pages.length - 1] page.onShow() }, fail: Function () {console.log(" update order status failed ")}})}},})} else if (tha.appenv == 'H5APP') {uni.request({url: that.url.zfb.appPayOrder, method: "POST", header: { "token": uni.getStorageSync("token") }, data: { "orderId": id }, success: function(resp) { let orderString = resp.data.orderString const jyAliPay = uni.requireNativePlugin('JY-ALIPAY') JyAliPay. Show ({// Initiate payment if_sanbox: true, auto_create_ORDER_info: false, appId: that.zfb.app.appId, rsa2_private: that.zfb.app.privateKey, order_info: orderString }, Function (result) {console.log(result) if (result.resultStatus == '9000') {uni.showtoast ({title: "Payment success"}) uni. Request ({url: that url. ZFB. UpdateOrderStatus, method: "POST", the header: {" token ": uni.getStorageSync("token") }, data: { "orderId": id }, success: Function (resp) {that.loadData()}})} else {uni.showtoast ({title: "failed to pay ", icon:" None "})}}); // uni.requestPayment({ // provider:"alipay", // orderInfo:orderString, // success:function(){ // }, // fail:function(){ // } // }) } }) } }, loadData: function() { let that = this uni.request({ url: that.url.searchUserOrderList, method: "POST", header: { "token": uni.getStorageSync("token") //"token":that.token }, data: { "page": 1, "length": 20 }, success: function(resp) { console.log(resp) let list = resp.data.list for (let one of list) { if (one.status == 1) { one.status = "Not paid"} else if (one.status == 2) {one.status = "paid"} else if (one.status == 3) {one.status = "shipped"} else if (one.status == 4) {one.status = "received"} one.code = one.code.substr(0, 16)} that.list = list}})}}, onShow: function() { this.loadData() } } </script> <style> .page { padding: 10px; } .order { padding: 10px; border-bottom: solid 1px #e0e0e0; font-size: 16px; } .line-1 { display: flex; justify-content: space-between; padding-bottom: 5px; } .line-2 { padding-bottom: 5px; } .line-3 { display: flex; justify-content: space-between; align-items: baseline; } .pay-btn { margin: 0; font-size: 14px; min-width: 80px; line-height: 35px; height: 35px; border: none; } </style>Copy the code

3, demos.zip \ demo/pages/login/login. Vue

<template> <view class="page"> <view class="title"> <image SRC =".. /.. /static/logo.png" mode="widthFix" class="logo"></image> <block v-if="appEnv=='H5APP'"> <view class="row"> <input Placeholder ="username" class="input" v-model="username" /> </view> <view class="row"> <input placeholder=" password" password="password" class="input" v-model="password" /> </view> </block> <button @tap="login" open-type="getUserInfo" Type ="primary" class=" BTN "> </button> </view> </template> <script> export default {data() {return {username: }}, methods: {login: function() {let that = this if (th.appenv == '微信 用 生 活 ') {uni. Login ({success: function(resp) { // console.log(resp) let code = resp.code uni.getUserInfo({ success: function(resp) { //console.log(resp) let nickname = resp.userInfo.nickName let avatarUrl = resp.userInfo.avatarUrl uni.request({ url: that.url.wx.login, method: "POST", data: { "code": code, "nickname": nickname, "photo": avatarUrl }, success: function(resp) { console.log(resp) let token = resp.data.token let expire = resp.data.expire uni.setStorageSync("token",  token) uni.setStorageSync("expire", expire) uni.switchTab({ url: ".. /index/index"})}})}})} else if (th.appenv == 'scopes ') {my.getauthCode ({scopes: "auth_user", success: function(resp) { // console.log(resp) let authCode = resp.authCode my.getAuthUserInfo({ success: function(resp) { // console.log(resp) let nickName = resp.nickName let avatar = resp.avatar uni.request({ url: that.url.zfb.login, method: "POST", data: { "authCode": authCode, "nickname": nickName, "photo": avatar }, success: function(resp) { console.log(resp) let token = resp.data.token let expire = resp.data.expire console.log(token) uni.setStorageSync("token", token) uni.setStorageSync("expire", expire) uni.switchTab({ url: ".. /index/index" }) } }) } }) } }) } else if (that.appEnv=="H5APP") { if (! / ^ [A Za - z0-9] {3, 20} $/. The test (that) the username)) {uni. ShowToast ({title: "the user name format error", icon: "none"})} else if (! / ^ [A Za - z0-9] 6, 20} {$/. The test (that) the password)) {uni. ShowToast ({title: "password format error", the icon: "none" }) } else { uni.request({ url: that.url.login, method: "POST", data: { "username": that.username, "password": that.password }, success: function(resp) { if (resp.data.code == 0) { let token = resp.data.token uni.setStorageSync("token", token) uni.switchTab({ url: ".. /index/index"})} else {uni. ShowToast ({title: "login failed ", icon: "none"})}}})}}}}, onReady: function() { } } </script> <style> .page { padding: 0 20%; } .title { font-size: 24px; text-align: center; font-weight: bold; margin-top: 80px; } .logo { width: 100px; margin-left: auto; margin-right: auto; display: block; margin-top: 20px; margin-bottom: 40px; } .row { padding: 5px 0; } .input { border-bottom: solid 1px #e0e0e0; font-size: 16px; padding: 8px 10px; } .btn { margin-top: 25px; } </style>Copy the code

3, demos.zip \ demo \ pages \ index

	<view>
		index
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			
		}
	}
</script>

<style>

</style>
Copy the code

In chapter 4, we will start to learn how to develop wechat mini program payment module. Each section is as follows: Need to create a small program order page, loading order data, rendering order data, small program issue payment requests, create payment orders to the merchants system essential parameters, create a payment order, to complete the payment, merchants system receives the small program results, encapsulating active inquiry order payment and payment request after the query results. After studying this chapter, we want to sum up. demo.zip\demo\pages\cart

	<view>
		cart
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			
		}
	}
</script>

<style>

</style>

Copy the code

We need to learn a lot of content, a total of 17 chapters, I have learned. There are video and courseware codes. For code video or courseware please contact the author. Vx (CML46679910)