Some pitfalls of iOS integrated WeChat payment (onResp does not call back, flash back, etc)

Source: Internet
Author: User

Some pitfalls of iOS integrated payment (onResp does not callback or flash back)

IOS integrated payment is relatively easy in general (if there are no pitfalls), all documents are in:

Https://pay.weixin.qq.com/wiki/doc/api/app.php? Chapter = 8_1

 

You only need to read:

Https://pay.weixin.qq.com/wiki/doc/api/app.php? Chapter = 8_3

Https://pay.weixin.qq.com/wiki/doc/api/app.php? Chapter = 8_5

These two parts can be done.

Most of the problems encountered come from another very common third party: umeng sharing

 

About

Umeng sharing has been integrated.

Download the sdk and copy it to the UMSocial_Sdk_Extra_Frameworks/Wechat folder in the UMSocial_Sdk_Extra_Frameworks/Wechat directory to replace the existing file.

 

 

About

Only one OK button is displayed after the payment is initiated

 

In this case, there is no error message, and the UrlSchemes returned by the breakpoint only has one ret =-2. The official documentation is interpreted:

"No action is required. Scenario: if the user does not pay, click Cancel to return to the APP ."

 

In this case, the request parameter is incorrect.

 

PayReq *request = [[[PayReq alloc] init] autorelease];request.partnerId = @"10000100";request.prepayId= @"1101000000140415649af9fc314aa427";request.package = @"Sign=WXPay";request.nonceStr= @"a462b76e7436e98e0ed6e13c64b4fd1c";request.timeStamp= @"1397527777";request.sign= @"582282D72DD2B03AD892830965F428CB16E7A256";[WXApi sendReq:request];

 

 

Check carefully against the document, be sure to pay attention to the case, In addition, sign the parameter name to use smaller (here the official documentation has errors, the document written with the hump that: https://pay.weixin.qq.com/wiki/doc/api/app.php? Chapter = 8_3 Step 3-name of the field involved in the signature. Thank you @ ).

 

About

Flash back

 

After the payment is initiated, open and return to your program immediately.

The reason is that the project is integrated with umeng, and the registration method is written in front of the initialization of umeng sharing. Just change the location.

 

// Register with you. You need to write it to [WXApi registerApp: @ "wx000000000" withDescription: @ "** weixinpay"] next to the initialization shared by umeng; // your appid

 

 

 

About

OnResp does not call back

 

This issue still comes from conflicts with umeng. Although umeng provides

 

+(BOOL)handleOpenURL:(NSURL *)url wxApiDelegate:(id
 
  )wxApiDelegate;
 

 

Method, but the delegate registered through this method is not called back (this may have different effects on different system versions and umeng sdk versions ).

 

 

The solution is to determine whether the callback is paid:

 

// Url Schemes callback-(BOOL) application :( UIApplication *) application handleOpenURL :( NSURL *) url {return [self applicationOpenURL: url];}-(BOOL) application :( UIApplication *) application openURL :( NSURL *) url sourceApplication :( NSString *) sourceApplication annotation :( id) annotation {return [self applicationOpenURL: url];}-(BOOL) application :( UIApplication *) app openURL :( NSURL *) url options :( NSDictionary *) options {return [self applicationOpenURL: url];}-(BOOL) applicationOpenURL :( NSURL *) url {if ([[url absoluteString] rangeOfString: @ "wx000000000000: // pay"]. location = 0) // your developer appid return [WXApi handleOpenURL: url delegate: [WXApiManager sharedManager]; else return [UMSocialSnsService handleOpenURL: url wxApiDelegate: [WXApiManager sharedManager];}

 

 

 

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.