ThinkPHP5.0 integrates Alipay mobile payment interface class
thinkphp5.0 integrates Alipay payment, thinkphp5.0 integrates WeChat payment, mobile app payment
thinkphp5.0 integrates Alipay mobile payment code function implementation
When the app accesses Alipay payment, if the user’s mobile phone does not have the Alipay client installed, Alipay will be called Mobile payment h5 page.
If Alipay payment is installed, the Alipay client will be awakened for payment, and the best way for users to withdraw money.
Alipay document address:
https://doc.open.alipay.com/docs/doc.htm?spm=a219a.7386797.0.0.Y4jDIe&treeId=59&articleId=103563&docType=1
All the data is there The server performs the combination and finally returns a processed string to the client.
The generated standard string is provided:
partner="2088101568358171"&seller_id="xxx@alipay.com"&out_trade_no="0819145412-6177"&subject="Test"&body="Test Test"&total_fee="0.01"¬ ify_url="http://notify.msp.hk/notify.htm"&service="mobile.securitypay.pay"&payment_type="1"&_input_charset="utf-8"&it_b_pay="30m"&sign="lBBK%2F0w5LOajrMrji7DUgEqNjIhQbidR13GovA5r3TgIbNqv231yC1NksLdw% 2Ba3JnfHXoXuet6XNNHtn7VE%2BeCoRO1O%2BR1KugLrQEZMtG5jmJIe2pbjm%2F3kb%2FuGkpG%2BwYQYI51%2BhA3YBbvZHVQBYveBqK%2Bh8mUyb7GM1HxWs9k4%3D"&sign_type="RSA "
Code part: //Alipay payment<br> function alipay_before(){<br> $mid = $ this- & gt; is_login (); <br> require_once extend_path.'alipay/alipaycore.php '; _ID = Input ("Request.order_id"); <br> IF ($ order_id == 0){<br> ajaxmsg('illegal data', 0); <br> ajaxmsg( ; = 'Order payment '; //Product details <br> $alipay_config = Config::get('alipay_config'); <br> out out over's ‐ ‐ ‐ ‐ ‐ out‐‐‐ through out <br> '], // The collaborator ID<br>' Seller_id '= & GT; $ Alipay_config [' Seller_id '], <br>' OUT_TRADE_NO '= & GT; t '= & gt;' order Payment ', // Commodity name <br>' body '= & gt; $ body, product details <br>' total_fee '= & gt; $ total_fee, <br>' notify_url '= &CONFIG [' NOTIFY _url '], // The server asynchronous The path of the notification page s 'service' = & gt; $ alipay_config ['service'], // interface name <br> 'payment_type' = & gt; $ alipay_config ['payment_type'], // payment type <br> '_Input_charset' = & gt; $ alipay_config ['input_charset'],//Parameter encoding character set <br> );<br> //Concatenate all the elements of the array received by post into a string using the "&" character according to the "parameter = parameter value" pattern. <br> use with use using to be signed. log.txt in the log folder under the project directory. <br> urlencode 'Private_key'])); <br><br> // Sect the signature and signature type sign_type behind the name string to be signed. <br> $data = $data.'&sign='.'"'.$rsa_sign.'"'.'&sign_type='.'"'.$alipay_config['sign_type'].'"';<br><br> On the client side, it is recommended to use the public key corresponding to the private key to perform a signature verification to ensure that it was not transmitted by others. <br> //echo $data;<br> $list['form'] = $data;<br> ajaxmsg('ok',1,$list);<br> }<br>支付后通知接口:<br> //支付宝支付通知<br> public function alipay_notify_url () <br> {a $ alipay_config = config :: get ('alipay_config'); <br> // Calculate the notification verification results
$ alipaynotify = new alipaynotify ($ alipay_config); $ alipaynotify- & gt; getResponse ($ _ post ['notify_id']))//After the judgment is successful, use the getResponse method to judge whether it is an asynchronous notification sent by Alipay. ({ if ($ alipaynotify-& gt; getSignVeryfy ($ _ pos, $ _post ['sign'])) {// Use Alipay Key Examination <br><br> // —— Please write the program based on your business logic (following Code is for reference only) - <br> using to ‐ to get notification return parameter from Alipay. <br> // Alipay Transaction number <br> $trade_no = $_POST['trade_no'];<br><br> If($_POST['trade_status'] == 'TRADE_FINISHED') { <br> having Business procedures <br> using using //After the refund date exceeds the refundable period (e.g., refundable within three months), the Alipay system will send a notification of the transaction status <br> // Please make sure that the total_fee, seller_id at the time of request are consistent with the total_fee, seller_id obtained at the time of notification <br>} s s else if ($ _post ['trade_status'] ==' trade_success') {<br> $ order_info = db :: name ("order")-& gt; where ("order_sn = '{$ OUT_TRA de_no} '")) -> find(); :name("order")->where("id= {$order_info['id']}")->save(<br> "pay_sn"=>$trade_no,<br> "pay_time"=>time(),<br> 'stauts'=>1<br> <br> U Echo "Success"; // Please do not modify or delete}}}} else // Verify the signature failure {<br> echo "sign fail"; "response fail";<br> }<br> }<br> What I wrote is a standard ordering process, mainly <br> To wake up the Alipay client, waking up Alipay is the first step, indicating that the protocol, account number, and key method are all consistent. <br>The second step is to accept the notification from Alipay after the payment is successful and detail the database on your server. <br>Prevent repeated updates of orders and user fund accounts. <br><br>I have pasted the code. Just put the source code package I integrated directly into the extend directory and call it directly in the controller. <br>Be sure to write the configuration file correctly, especially how to generate the public key and private key, and upload it to the Alipay platform center. <br><br>Technical exchange group: <strong>495654168</strong><br>
Alipay.zip ( 140.02 KB Download: 24 times )

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



Learn about Python programming with introductory code examples Python is an easy-to-learn, yet powerful programming language. For beginners, it is very important to understand the introductory code examples of Python programming. This article will provide you with some concrete code examples to help you get started quickly. Print HelloWorldprint("HelloWorld") This is the simplest code example in Python. The print() function is used to output the specified content

"Go Language Programming Examples: Code Examples in Web Development" With the rapid development of the Internet, Web development has become an indispensable part of various industries. As a programming language with powerful functions and superior performance, Go language is increasingly favored by developers in web development. This article will introduce how to use Go language for Web development through specific code examples, so that readers can better understand and use Go language to build their own Web applications. 1. Simple HTTP Server First, let’s start with a

PHP variables store values during program runtime and are crucial for building dynamic and interactive WEB applications. This article takes an in-depth look at PHP variables and shows them in action with 10 real-life examples. 1. Store user input $username=$_POST["username"];$passWord=$_POST["password"]; This example extracts the username and password from the form submission and stores them in variables for further processing. 2. Set the configuration value $database_host="localhost";$database_username="username";$database_pa

The simplest code example of Java bubble sort Bubble sort is a common sorting algorithm. Its basic idea is to gradually adjust the sequence to be sorted into an ordered sequence through the comparison and exchange of adjacent elements. Here is a simple Java code example that demonstrates how to implement bubble sort: publicclassBubbleSort{publicstaticvoidbubbleSort(int[]arr){int

Title: From Beginner to Mastery: Code Implementation of Commonly Used Data Structures in Go Language Data structures play a vital role in programming and are the basis of programming. In the Go language, there are many commonly used data structures, and mastering the implementation of these data structures is crucial to becoming a good programmer. This article will introduce the commonly used data structures in the Go language and give corresponding code examples to help readers from getting started to becoming proficient in these data structures. 1. Array Array is a basic data structure, a group of the same type

Huawei Cloud Edge Computing Interconnection Guide: Java Code Samples to Quickly Implement Interfaces With the rapid development of IoT technology and the rise of edge computing, more and more enterprises are beginning to pay attention to the application of edge computing. Huawei Cloud provides edge computing services, providing enterprises with highly reliable computing resources and a convenient development environment, making edge computing applications easier to implement. This article will introduce how to quickly implement the Huawei Cloud edge computing interface through Java code. First, we need to prepare the development environment. Make sure you have the Java Development Kit installed (

How to use PHP to write the inventory management function code in the inventory management system. Inventory management is an indispensable part of many enterprises. For companies with multiple warehouses, the inventory management function is particularly important. By properly managing and tracking inventory, companies can allocate inventory between different warehouses, optimize operating costs, and improve collaboration efficiency. This article will introduce how to use PHP to write code for inventory warehouse management functions, and provide you with relevant code examples. 1. Establish the database before starting to write the code for the inventory warehouse management function.

Java Selection Sorting Method Code Writing Guide and Examples Selection sorting is a simple and intuitive sorting algorithm. The idea is to select the smallest (or largest) element from the unsorted elements each time and exchange it until all elements are sorted. This article will provide a code writing guide for selection sorting, and attach specific Java sample code. Algorithm Principle The basic principle of selection sort is to divide the array to be sorted into two parts, sorted and unsorted. Each time, the smallest (or largest) element is selected from the unsorted part and placed at the end of the sorted part. Repeat the above
