Detailed explanation of the payment function code of the Vue project

Detailed explanation of the payment function code of the Vue project

1. Alipay method:

Alipay method: Click Alipay to pay, call the backend interface (with the order number), and the backend returns a form (HTML string structure).

Submit the form to call Alipay payment

Code:

// alipayWap: form fragment returned by the background interface <div v-html="alipayWap" ref="alipayWap"></div>
methods: {
	toAlipay() {
		this.$axios.get('xxx').then(res = > {
			this.alipayWap = res;
             // Wait for DOM to update, and then the form will appear on the page this.$nextTick(() => {
            	this.$refs.alipayWap.children[0].submit()
          	})
		})
	}
}

2. WeChat Pay

Most of the workload is done by the backend. The order generation is done by the backend and connected to Tencent. The frontend is only responsible for displaying the payment QR code returned by the backend (generated by the backend. In some cases, the frontend can also connect to the order generation and then generate the QR code by itself, but this situation is relatively rare) on the terminal for users to scan.

You need to generate a QR code page based on the URL returned by the background, as shown in the figure

QR code display code:

Request the payment QR code interface of the backend

Finally, scan the QR code and pay.

This is the end of this article about the payment function of the vue project. For more relevant vue payment function content, please search 123WORDPRESS.COM’s previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Payment function implementation in vue project (WeChat payment and Alipay payment)
  • springboot+vue+docking Alipay interface+QR code scanning payment function (sandbox environment)
  • Pitfalls encountered in implementing WeChat payment function in Vue
  • Vue's H5 page invokes the Alipay payment function
  • Vue imitates Alipay payment function

<<:  The difference between GB2312, GBK and UTF-8 in web page encoding

>>:  Solution to the ineffective margin of div nested in HTML

Recommend

How to migrate the data directory in mysql8.0.20

The default storage directory of mysql is /var/li...

Summary of the dockerfile-maven-plugin usage guide

Table of contents pom configuration Setting.xml c...

Detailed explanation of linux crm deployment code

Linux basic configuration Compile and install pyt...

Detailed explanation of monitoring NVIDIA GPU usage under Linux

When using TensorFlow for deep learning, insuffic...

How to implement page screenshot function in JS

"Page screenshot" is a requirement ofte...

Detailed explanation of object literals in JS

Table of contents Preface 1. Set the prototype on...

CSS isolation issue in Blazor

1. Environment VS 2019 16.9.0 Preview 1.0 .NET SD...

Example of how to create and run multiple MySQL containers in Docker

1. Use the mysql/mysql-server:latest image to qui...

Use of Linux watch command

1. Command Introduction The watch command execute...

Sample code for realizing book page turning effect using css3

Key Takeaways: 1. Mastering CSS3 3D animation 2. ...

Tutorial on installing Pycharm and Ipython on Ubuntu 16.04/18.04

Under Ubuntu 18.04 1. sudo apt install python ins...