


Detailed explanation of TP access to WeChat public account payment
WeChat plays an increasingly important role in life. Places with a large flow of people and a large amount of information are battlegrounds for merchant marketing. There are more and more scenarios where WeChat payment is used in WeChat public accounts. Below, PHP programmer Lei Xuesong explains in detail how ThinkPHP can access WeChat public account payment.
1. Download the official demo and place it under ThinkPHP/Library/Vendor/. It is recommended to create a Wxpay folder. If you want to access Alipay in the future, create another Alipay. This way the catalog may be clearer in the case of multiple payments.
2. Modify WeChat payment-related parameters in the WxPay.Config.php file. And put the certificate downloaded from the WeChat Payment Merchant Platform in the ThinkPHP/Library/Vendor/Wxpay/cert/ folder.
const APPID = '';//开户邮件中可查看或者微信支付后商户平台 const MCHID = '';//开户邮件中可查看或者微信支付商户平台 const KEY = '';//微信支付商户平台自行设置 const APPSECRET = '';//微信公众号secert // 证书路径,注意应该填写绝对路径(仅退款、撤销订单时需要),可登录商户平台下载,API证书下载地址:https://pay.weixin.qq.com/index.php/account/api_cert,下载之前需要安装商户操作证书) const SSLCERT_PATH = 'cert/apiclient_cert.pem'; const SSLKEY_PATH = 'cert/apiclient_key.pem';
3. Set up the payment directory in the WeChat official account. The specific steps are: WeChat Payment->Development Configuration-> Enter the WeChat payment address, which must be detailed to Second-level directories, ending with a left slash "/". For example: the link for WeChat payment is: domain name/wxpay/Cart/weixinpay/o_no/20170622164600. The order number after o_no is a random order number. Then the payment directory in the WeChat official account is: domain name/wxpay/Cart/weixinpay/o_no/.
#4. Set the JS interface security domain name setting and web page authorization domain name in the WeChat public account . Specific steps: Official account settings->Function settings.
Note: When paying on WeChat, openID will be obtained first. The process of obtaining openID is to first request WeChat, and WeChat will return the code to the current request link. A simple understanding is that the WeChat payment link will be requested twice. The first time is when we request to call WeChat payment, and the second time is when WeChat callback gets the openID. Is it possible to run the WeChat payment link for the second time? The subsequent parameters will be lost. For the specific code, you can view the GetOpenid method in WeChat WxPay.JsApiPay.php.
If you understand these key points of WeChat payment, the specific code should be easier to write. For payments and notifications, you can refer to the files in the exmaple folder in WeChat Pay.
The above is the detailed content of Detailed explanation of TP access to WeChat public account payment. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Baidu Map APP has now become the preferred travel navigation software for many users, so some of the functions here are comprehensive and can be selected and operated for free to solve some of the problems that you may encounter in daily travel. You can all check some of your own travel routes and plan some of your own travel plans. After checking the corresponding routes, you can choose appropriate travel methods according to your own needs. So whether you choose some public transportation, Cycling, walking or taking a taxi can all satisfy your needs. There are corresponding navigation routes that can successfully lead you to a certain place. Then everyone will feel more convenient if they choose to take a taxi. There are many drivers They are all able to take orders online, and taxi-hailing has become super

Detailed explanation of the mode function in C++ In statistics, the mode refers to the value that appears most frequently in a set of data. In C++ language, we can find the mode in any set of data by writing a mode function. The mode function can be implemented in many different ways, two of the commonly used methods will be introduced in detail below. The first method is to use a hash table to count the number of occurrences of each number. First, we need to define a hash table with each number as the key and the number of occurrences as the value. Then, for a given data set, we run

Windows operating system is one of the most popular operating systems in the world, and its new version Win11 has attracted much attention. In the Win11 system, obtaining administrator rights is an important operation. Administrator rights allow users to perform more operations and settings on the system. This article will introduce in detail how to obtain administrator permissions in Win11 system and how to effectively manage permissions. In the Win11 system, administrator rights are divided into two types: local administrator and domain administrator. A local administrator has full administrative rights to the local computer

uniapp is a cross-platform application development framework that can develop small programs, Apps and H5 at the same time. In uniapp applications, payment and order management are very common needs. This article will introduce how to implement payment functions and order management in the uniapp application, and give specific code examples. 1. Implementing the payment function The payment function is the key to realizing online transactions, and it usually requires integrating the SDK of a third-party payment platform. The following are the specific steps to implement the payment function in uniapp: Register and obtain a third-party payment platform

Detailed explanation of division operation in OracleSQL In OracleSQL, division operation is a common and important mathematical operation, used to calculate the result of dividing two numbers. Division is often used in database queries, so understanding the division operation and its usage in OracleSQL is one of the essential skills for database developers. This article will discuss the relevant knowledge of division operations in OracleSQL in detail and provide specific code examples for readers' reference. 1. Division operation in OracleSQL

Detailed explanation of the remainder function in C++ In C++, the remainder operator (%) is used to calculate the remainder of the division of two numbers. It is a binary operator whose operands can be any integer type (including char, short, int, long, etc.) or a floating-point number type (such as float, double). The remainder operator returns a result with the same sign as the dividend. For example, for the remainder operation of integers, we can use the following code to implement: inta=10;intb=3;

Detailed explanation of Linux system call system() function System call is a very important part of the Linux operating system. It provides a way to interact with the system kernel. Among them, the system() function is one of the commonly used system call functions. This article will introduce the use of the system() function in detail and provide corresponding code examples. Basic Concepts of System Calls System calls are a way for user programs to interact with the operating system kernel. User programs request the operating system by calling system call functions

The modulo operator (%) in PHP is used to obtain the remainder of the division of two numbers. In this article, we will discuss the role and usage of the modulo operator in detail, and provide specific code examples to help readers better understand. 1. The role of the modulo operator In mathematics, when we divide an integer by another integer, we get a quotient and a remainder. For example, when we divide 10 by 3, the quotient is 3 and the remainder is 1. The modulo operator is used to obtain this remainder. 2. Usage of the modulo operator In PHP, use the % symbol to represent the modulus
