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

MySQL query sorting and paging related

Overview It is usually not what we want to presen...

Detailed explanation of Svn one-click installation shell script under linxu

#!/bin/bash #Download SVN yum -y install subversi...

Detailed explanation of CSS3 animation and new features of HTML5

1. CSS3 animation ☺CSS3 animations are much easie...

Analysis of MySQL lock mechanism and usage

This article uses examples to illustrate the MySQ...

vsftpd virtual user based on MySql authentication

Table of contents 1. MySQL installation 1.2 Creat...

JS ES new features template string

Table of contents 1. What is a template string? 2...

MySQL 8.0.13 installation and configuration graphic tutorial

Msyql database installation, for your reference, ...

Detailed explanation of Linux one-line command to process batch files

Preface The best method may not be the one you ca...

An example of refactoring a jigsaw puzzle game using vue3

Preface It took two days to reconstruct a puzzle ...

Summary of MySQL commonly used type conversion functions (recommended)

1. Concat function. Commonly used connection stri...

Detailed explanation of Json format

Table of contents A JSON is built on two structur...

20 Signposts on the Road to Becoming an Excellent UI (User Interface) Designer

Introduction: Interface designer Joshua Porter pub...

MySQL 8.0.12 winx64 detailed installation tutorial

This article shares the installation tutorial of ...