Modify the WeChat payment example code into the example code used directly in tp, and simply make scan code payment and callback functions
Modify the WeChat payment sample code into the sample code used directly in tp, and simply make scan code payment and callback functions
Mode 2 is used. If necessary, you can directly execute the code in mode 1.
Class import Take a look at my import and you will understand how to import it. You don’t have to worry about this stuff anymore.
The code reference is as follows
Example code for generating payment QR code: public function index() {<br>
Import ( "@.Controller.WxPay.WxPayNativePay" );<br>
$notify = new WxPayNativePay ();<br>
$url1 = $notify->GetPrePayUrl ( "123456789" );<br>
//Mode 2<br>
/**<br>
* Process: <br>
* 1. Call unified ordering, get code_url, and generate QR code<br>
* 2. Users scan the QR code to make payment<br>
* 3. After the payment is completed, the WeChat server will notify you that the payment was successful<br>
* 4. In the payment success notification, you need to check the order to confirm whether the payment is actually successful (see: notify.php) <br>
*/<br>
// $price = $_POST ['price'];<br>
// $prodect_id = $_POST ['prodect_id'];<br>
// $premission_name = $_POST ['premission_name'];<br>
$price = 0.01;<br>
$product_id = $ product
$premission_name = $prodect_id;<br>
//Start processing<br>
$input = new WxPayUnifiedOrder ();<br>
$input->SetBody ( "xxxx---" . $premission_name );<br>
$input->SetAttach ( "xxxxx-Attach" );<br>
$input->SetOut_trade_no ( WxPayConfig::MCHID . date ( "YmdHis" ) );<br>
$input->SetTotal_fee ( $price * 100 );<br>
$input->SetTime_start ( date ( "YmdHis" ) );<br>
$input->SetTime_expire ( date ( "YmdHis", time () + 600 ) );<br>
$input->SetGoods_tag ( "xxx-tag" );<br>
$input->SetNotify_url ( "http://xxxx.com/wxtest/index.php/home/Index/notify" );<br>
$input->SetTrade_type ( "NATIVE" );<br>
$input->SetProduct_id ( rand ( 4, 8 ) );<br>
$result = $notify->GetPayUrl ( $input );<br>
$url2 = $result ["code_url"];<br>
// Generate QR code<br>
error_reporting (E_ERROR);<br>
Import ( "@.Controller.WxPay.PHPQRCODE" );<br>
$url = urldecode ($url2);<br>
QRcode::png ( $url );<br>} }
Example code for WeChat payment callback processing: /**<br>
* @Function description: WeChat payment callback processing<br>
*
* * @Time 2016-9-22 3:41:59 pm<br>
*/<br>
Public function notify() {<br>
//Get WeChat callback data<br>
$notifiedData = $GLOBALS ['HTTP_RAW_POST_DATA'];<br>
//Load related classes<br>
Import ( "@.Controller.WxPay.WxPayNativePay" );<br>
Import ( "@.Controller.WxPay.WxPayData" );<br>
Import ( "@.Controller.WxPay.WxPayNotify" );<br>
Import ( "@.Controller.WxPay.PayNotifyCallBack" );<br>
$xml_to_arr = WxPayDataBase::FromXml_4_babbage ( $notifiedData );<br>
//Convert to array and write to cache<br>
F ("wx_notified_data", $xml_to_arr);<br>
// Let’s also write the xml prototype into xml<br>
F ("wx_notified_data_xml", $notifiedData);<br>
<br>
//Return payment status value to WeChat<br>
$notify = new PayNotifyCallBack ();<br>
// Return status <br>
$notify->Handle ( false );<br>
}<br>Hope this can be helpful to colleagues with weak skills like me
wxpay4tp.zip
( 1.25 MB Download: 8 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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version
Visual web development tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.