


Payment verification signature payment failed? —— WeChat Pay app payment
Situation description:
1. Call the same order interface and get the prepay_id equivalent value!
2. Before submitting data to the app, there is a secondary signature. I signed it according to the rules! //Please check if the code I wrote is correct
3. Why does this problem occur?
4. I beg God for guidance!
This is my secondary signature code:
............ //Set parameters, etc.
$wx_result = $wechatAppPay->unifiedOrder( $params );//调用同一下单接口,并成功返回结果 //开始生成二次签名 $sign_array = array();//第二次签名需要的参数 $sign_array['appid'] = $wx_result['appid']; $sign_array['mch_id'] = $wx_result['mch_id']; $sign_array['prepay_id'] = $wx_result['prepay_id']; $sign_array['nonce_str'] = $wx_result['nonce_str']; $sign_array['timeStamp'] = time(); $sign_array['package'] = $wx_result['Sign=WXPay']; $sign_two = $wechatAppPay->MakeSign($sign_array);//调用签名生成函数
The following is my function code to generate signatures:
/** * 生成签名 * @return 签名 */ public function MakeSign( $params ){ //签名步骤一:按字典序排序数组参数 ksort($params); $string = $this->ToUrlParams($params);//调用拼接函数 //签名步骤二:在string后加入KEY $string = $string . "&key=".$this->key; //签名步骤三:MD5加密 $string = md5($string); //签名步骤四:所有字符转为大写 $result = strtoupper($string); return $result; } /** * 将参数拼接为url: key=value&key=value * @param $params * @return string */ public function ToUrlParams( $params ){ $string = ''; if( !empty($params) ){ $array = array(); foreach( $params as $key => $value ){ $array[] = $key.'='.$value; } $string = implode("&",$array); } return $string; }
This question has been resolved Solved, the reason is that the parameter name in the second signature is wrong.
//////////////////////////////Update/////////////////// ///////////////////////////////////////////////////// ///////////////////////////////////////////////////// /////////////////////////////////
But I don’t know how to write the callback! !
But I can’t receive the value (I can’t receive the general notification of payment results from WeChat), and I don’t know what’s going on
Receive WeChat payment asynchronous notification callback address:
$notify_url = 'http://www.XXXXXX.com/index.php/apps/cart/wxResult';
//微信支付回调函数 public function wxResult() { $data = array(); $data = $this->wechatAppPay->getNotifyData();//调用获取数据函数 ////////********逻辑处理********////////// $data2 = $this->wechatAppPay->replyNotify();//接收通知成功后应答输出XML数据 $this->jsonmsg($data); }
Function to get notification data:
/** * * 获取支付结果通知数据 * return array */ public function getNotifyData(){ //获取通知的数据 $xml = $GLOBALS['HTTP_RAW_POST_DATA']; $data = array(); if( empty($xml) ){ return false; } $data = $this->xml_to_data( $xml ); if( !empty($data['return_code']) ){ if( $data['return_code'] == 'FAIL' ){ return false; } } return $data; }
Response output XML data function after successfully receiving notification:
/** * 接收通知成功后应答输出XML数据 * @param string $xml */ public function replyNotify(){ $data['return_code'] = 'SUCCESS'; $data['return_msg'] = 'OK'; $xml = $this->data_to_xml( $data ); echo $xml; die(); }
** Solved
///////Updated/////////////////Merchant system for payment result notification Signature verification of the content /////////////////////////////////**
is working on the content of the payment result notification from the merchant system How to do signature verification?
What is it? What is the logical idea?
Reply content:
Payment interface document
Fields specified in the document
appid
partnerid
prepayid
package
noncestr
timestamp
sign
Please do not change the case of parameter names, also Don't add Underline or something. I have encountered this problem before and it has been solved.
Hello, I also encountered the same problem. I wonder if you have solved it?
Is the parameter name involved in the md5 calculation?
The timestamp of the secondary signature is the timestamp when pre_payid was generated

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











PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

In PHP8, match expressions are a new control structure that returns different results based on the value of the expression. 1) It is similar to a switch statement, but returns a value instead of an execution statement block. 2) The match expression is strictly compared (===), which improves security. 3) It avoids possible break omissions in switch statements and enhances the simplicity and readability of the code.

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.
