This article mainly describes the pitfalls encountered during the development of small program access payment, which are divided into two major blocks: Encapsulation of small program end and background interface. The main content of this article is as follows: 1. backend interface encapsulation; 2. integration of small programs; 3. Summary of step-by-step attacks. I. backend interface encapsulation is based on ThinkPHP5 for interface encapsulation. the specific steps are as follows: 1. the official payment documents provide PHP script payment samples and download them; 2. the sample has encapsulated every class. we just need to add a namespace and create a directory wxpay under the extend directory of TP5 to put... this article mainly describes the pitfalls encountered during the development of small program access payment, which are divided into two major blocks: Encapsulation of small program end and background interface. The main content of this article is as follows: 1. backend interface encapsulation; 2. integration of small programs; 3. Summary of step-by-step attacks. 1. the backend interface is encapsulated based on ThinkPHP 5. the specific steps are as follows: 1. the Official Payment documentation provides a PHP script payment sample, which can be downloaded; 2. the sample has encapsulated each class. we only need to add a namespace to create a directory wxpay under the extend directory of TP5 and copy the class in the sample to the directory, add the namespace. The most important class in the transformation result is WxPayApi. php, with the namespace added in the form of the following, the transformation of other classes is similar: 3. introduce the namespace where needed, a new object can be used, unified order interface example: first introduce the required classes: encapsulate the unified order interface for external applications, and directly return the parameters required by the applet to call the payment interface: the re-payment interface is similar, and can be encapsulated by the unified order class. 2. it is easy to integrate the applet with the applet. you only need to return the interface
1. 10 articles about extend are recommended
Introduction: This article mainly introduces the differences between class construct () and _ initialize () in ThinkPHP. This article is very detailed and I believe it will be of reference value to everyone, let's take a look. Preface I believe that phper familiar with THINKPHP is basically familiar with the _ initialize () method. we seem to seldom use _ construct () unless we write the plug-in by ourselves, it is rarely used. Today, when I checked the code, I suddenly saw _ construc...
[Related Q & A recommendations ]:
Cross-origin request in javascript-Fetch
Apache configures rewrite to hide index. php of thinkphp
Thinkphp template assignment
Thinkphp error Failed to load resource 404 (Not Found), error modifying. htaccess
The php program reports that the module cannot be loaded: install. php
The above is a detailed list of 10 Thinkphp course recommendations. For more information, see other related articles in the first PHP community!