Payment verification signature payment failed? -- WeChat payment app payment

Source: Internet
Author: User
This is IOS: situation description: 1. you have obtained the prepay_id equivalent by calling the same order interface! 2. I have signed a secondary signature before submitting data to the app! Please check whether the code I wrote is correct. why is this problem? 4. beg the Lord...

This is for IOS:

Description:

1. you have obtained the prepay_id equivalent by calling the same order interface!

2. I have signed a secondary signature before submitting data to the app! // Check whether the code I wrote is correct.

3. Why is this problem?

4. beg for your guidance!

Here is my second signature code:

............ // Set parameters and so on $ wx_result = $ wechatAppPay-> unifiedOrder ($ params); // call the same order interface, the result is returned. // The second signature is generated. $ sign_array = array (); // parameters required for the second signature $ 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); // call the signature generation function

The following is the signature generation function code:

/*** Generate the signature ** @ return signature */public function MakeSign ($ params) {// signature Step 1: sort the array parameter ksort ($ params) in lexicographically ); $ string = $ this-> ToUrlParams ($ params); // call the concatenation function // signature Step 2: Add KEY $ string = $ string after the string. "& key = ". $ this-> key; // signature Step 3: MD5 encryption $ string = md5 ($ string); // signature Step 4: convert all characters into uppercase $ result = strtoupper ($ string); return $ result;}/*** concatenate the parameters into URLs: key = value & key = value * @ param $ params * @ return string */public function T OUrlParams ($ params) {$ string = ''; if (! Empty ($ params) {$ array = array (); foreach ($ params as $ key => $ value) {$ array [] = $ key. '= '. $ value ;}$ string = implode ("&", $ array) ;}return $ string ;}

This problem has been solved because the parameter name of the second signature is incorrect.

/// // Update ////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// ///////////////////
But I don't know how to write the callback !!

However, I do not know what is going on if I fail to receive the value (general notification of the payment result sent to me cannot be received ).

Callback address for receiving asynchronous notifications:
$notify_url        = 'http://www.XXXXXX.com/index.php/apps/cart/wxResult';

// Payment callback function

Public function wxResult () {$ data = array (); $ data = $ this-> wechatAppPay-> getpolicydata (); // call the function to obtain data // *********** logical processing ********//////// // $ data2 = $ this-> wechatAppPay-> replypolicy (); // respond to the output XML data after receiving the notification successfully $ this-> jsonmsg ($ data );}

Function for obtaining notification data:

/***** Get the notification data of the payment result * return array */public function getpolicydata () {// get the notification data $ 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 ;}

After receiving the notification, the XML data function is returned:

/*** Response to the output XML data after receiving the notification successfully * @ param string $ xml */public function replyy Y () {$ data ['return _ Code'] = 'success '; $ data ['return _ msg '] =' OK '; $ xml = $ this-> data_to_xml ($ data); echo $ xml; die ();}

** Resolved
////// Update ///////// // The merchant system verifies the signature of the content of the notification of the payment result //// ///////////////////////////**

The merchant system is performing signature verification on the content of the payment result notification. how can this verification be performed?
What is it? What is the logic?

Reply content:

This is for IOS:

Description:

1. you have obtained the prepay_id equivalent by calling the same order interface!

2. I have signed a secondary signature before submitting data to the app! // Check whether the code I wrote is correct.

3. Why is this problem?

4. beg for your guidance!

Here is my second signature code:

............ // Set parameters and so on $ wx_result = $ wechatAppPay-> unifiedOrder ($ params); // call the same order interface, the result is returned. // The second signature is generated. $ sign_array = array (); // parameters required for the second signature $ 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); // call the signature generation function

The following is the signature generation function code:

/*** Generate the signature ** @ return signature */public function MakeSign ($ params) {// signature Step 1: sort the array parameter ksort ($ params) in lexicographically ); $ string = $ this-> ToUrlParams ($ params); // call the concatenation function // signature Step 2: Add KEY $ string = $ string after the string. "& key = ". $ this-> key; // signature Step 3: MD5 encryption $ string = md5 ($ string); // signature Step 4: convert all characters into uppercase $ result = strtoupper ($ string); return $ result;}/*** concatenate the parameters into URLs: key = value & key = value * @ param $ params * @ return string */public function T OUrlParams ($ params) {$ string = ''; if (! Empty ($ params) {$ array = array (); foreach ($ params as $ key => $ value) {$ array [] = $ key. '= '. $ value ;}$ string = implode ("&", $ array) ;}return $ string ;}

This problem has been solved because the parameter name of the second signature is incorrect.

/// // Update ////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// ///////////////////
But I don't know how to write the callback !!

However, I do not know what is going on if I fail to receive the value (general notification of the payment result sent to me cannot be received ).

Callback address for receiving asynchronous notifications:
$notify_url        = 'http://www.XXXXXX.com/index.php/apps/cart/wxResult';

// Payment callback function

Public function wxResult () {$ data = array (); $ data = $ this-> wechatAppPay-> getpolicydata (); // call the function to obtain data // *********** logical processing ********//////// // $ data2 = $ this-> wechatAppPay-> replypolicy (); // respond to the output XML data after receiving the notification successfully $ this-> jsonmsg ($ data );}

Function for obtaining notification data:

/***** Get the notification data of the payment result * return array */public function getpolicydata () {// get the notification data $ 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 ;}

After receiving the notification, the XML data function is returned:

/*** Response to the output XML data after receiving the notification successfully * @ param string $ xml */public function replyy Y () {$ data ['return _ Code'] = 'success '; $ data ['return _ msg '] =' OK '; $ xml = $ this-> data_to_xml ($ data); echo $ xml; die ();}

** Resolved
////// Update ///////// // The merchant system verifies the signature of the content of the notification of the payment result //// ///////////////////////////**

The merchant system is performing signature verification on the content of the payment result notification. how can this verification be performed?
What is it? What is the logic?

Payment Interface Document

Fields specified in this document

  • Appid

  • Partnerid

  • Prepayid

  • Package

  • Noncestr

  • Timestamp

  • Sign
    PleaseNoChange the parameter name case.NoUnderline or something. This problem has been solved before.

Hi, I also encountered the same problem. I don't know if you have solved it.

Does the parameter name participate in md5 calculation?

The timestamp of the secondary signature is the timestamp when the pre_payid is generated.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.