search

Home  >  Q&A  >  body text

objective-c - The mobile website payment integrated with Alipay on the ios side is transferred to the APP payment, and H5 cannot be activated.

I recently connected with Alipay SDK to implement mobile payment function. After downloading the latest DEMO from the official website and configuring the parameters, it runs normally. Then follow the tutorial step by step to integrate it into your own project. Pay attention to everything that should be paid attention to, and compile OK. Since the Alipay client has been installed on the mobile phone, the synchronization result needs to be obtained in Appdelegate. The code is as follows (Swift):

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {

if (url.host! as String) == "safepay" {
    // 支付跳转支付宝钱包进行支付,处理支付结果
    AlipaySDK.defaultService().processOrderWithPaymentResult(url, standbyCallback: { (resultDic) in
        print("result = \(resultDic)")
    })
}
return true

}

// NOTE: New API interface will be used after 9.0
func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {

if (url.host! as String) == "safepay" {
    // 支付跳转支付宝钱包进行支付,处理支付结果
    AlipaySDK.defaultService().processOrderWithPaymentResult(url, standbyCallback: { (resultDic: [NSObject : AnyObject]!) in
        print("result = \(resultDic)")
    })
}
return true

}
After running on the real machine, jumping to Alipay for successful payment, and then jumping back to your own App, the console can print out the synchronization result (the status is 9000, payment successful), but the program directly crashes and stops. In the AlipaySDK.defaultService().processOrderWithPaymentResult method, the console displays (lldb).

Then I tried to block the AlipaySDK.defaultService().processOrderWithPaymentResult method, and it ran normally without crashing. I tested it on another real machine. Since this real machine does not have the Alipay client installed, after completing the payment in H5, it will appear at:

AlipaySDK.defaultService().payUrlOrder(orderString as String, fromScheme: appScheme, callback: { (resultDic) in

        print(resultDic)
    })

The synchronization result is obtained in the method, but this time the console does not print the synchronization result and crashes directly.
This means that as soon as I call the method to obtain the synchronization result, it will crash. Reluctantly, I created a new Swift project for testing, integrated the Alipay SDK in the same way, and used the same code. It turned out that it ran normally and there was no crash at all! I wonder if there is a conflict with other third-party libraries, but I have encountered conflicts between two third-party libraries before. It is usually a redefinition problem and the compilation will not pass.

I really can’t figure out what the problem is. I’d like to ask if anyone here has encountered this problem before. Thank you!

迷茫迷茫2792 days ago780

reply all(0)I'll reply

No reply
  • Cancelreply