Home  >  Article  >  Backend Development  >  PHP WeChat access payment related

PHP WeChat access payment related

高洛峰
高洛峰Original
2016-11-18 13:30:33990browse

Recently, a bug was adjusted for the company, involving the relevant interface of WeChat payment. So I have a few questions recorded here, hoping to help others.

Merchant ID

In the WeChat public account management panel, there is a WeChat payment menu bar. After entering, there may be two serial numbers in the first tab, one of which is the serial number when our company is an ordinary merchant. There is also a serial number that will be marked with the word service provider. This is the serial number used by our company as a service provider. Ordinary merchants are WeChat users who transfer money directly to you; service providers are agents of a group of ordinary merchants. You can manage a group of merchants selling goods in your H5 application. At this time, WeChat users transfer money to the merchants. You act as agent.

Since the functions here are not developed by me, some code details are not very sure. When calling the unified ordering interface in this document, if the company's ordinary merchant number is passed in, it is considered to be a transfer to an ordinary merchant. If you need to transfer it to a merchant represented by our company, you need to enter our company's service merchant number and sub-merchant number at the same time. If you mistakenly use the company's service merchant account as an ordinary merchant account without passing in the sub-merchant number, an error will be reported that requires the sub_mch_id to be passed in.

The payment url is not authorized

WeChat payment will involve a callback url. This URL is passed in when calling the WeChat interface. However, if this incoming URL needs to have parameters, be sure not to use question marks and & connectors, otherwise the URL will be misidentified, such as: index.php?g=mobile&m=payment, it is best to convert it to one that is also commonly used in thinkphp. '/' method, such as /mobile/payment/order_id/111.

In the WeChat payment access menu, there is a development settings tab, which configures the callback url. URLs not set here will not have callback permissions, and an error will be reported that the payment URL is not authorized. There are two steps to configure the permissions of the callback URL:

You need to download a txt authorization code file and place it in the root directory of the web server, www.foobar.com/xxxxx.txt. If you can access your authorization in this way under your own domain name code file, there will be no problem.

When setting the url, if you need to pass in the id of a payment order number, such as /mobile/payment/order_id/111, then the callback url must be set to www.foobar.com/mobile/payment/order_id/ as the authorization url , which means that the URL only supports at most one level of delimiters.


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn