ApplePay接口由于支付未完成而关闭,有没有事件可以跟踪支付未完成?
创始人
2024-09-10 19:30:21
0

可以使用PKPaymentAuthorizationViewController的delegate方法来捕捉支付未完成的事件。具体实现如下:

1.在控制器中设置PKPaymentAuthorizationViewControllerDelegate:

class ViewController: UIViewController, PKPaymentAuthorizationViewControllerDelegate { // ... }

2.在启动Apple Pay时,设置自己为PKPaymentAuthorizationViewController的delegate:

let paymentVC = PKPaymentAuthorizationViewController(paymentRequest: paymentRequest) paymentVC.delegate = self self.presentViewController(paymentVC, animated: true, completion: nil)

3.实现delegate中的paymentAuthorizationViewController(_: didAuthorizePayment: handler:)方法来捕捉支付完成事件:

func paymentAuthorizationViewController(controller: PKPaymentAuthorizationViewController, didAuthorizePayment payment: PKPayment, handler completion: (PKPaymentAuthorizationStatus) -> Void) { // Here you can handle the case where payment is complete completion(PKPaymentAuthorizationStatus.Success) }

  1. 实现delegate中的paymentAuthorizationViewControllerDidFinish(_:)方法来处理支付未完成的事件:

func paymentAuthorizationViewControllerDidFinish(controller: PKPaymentAuthorizationViewController) { // Here you can handle the case where payment is not complete controller.dismissViewControllerAnimated(true, completion: nil) }

这样,在用户在Apple Pay界面中主动关闭支付或者支付出现任何问题导致支付未完成时,上述的paymentAuthorizationViewControllerDidFinish函数将被调用,您就可以在其中进行相关处理了。

相关内容

热门资讯

辅助透视!wpk作必弊,wpk... 辅助透视!wpk作必弊,wpk透视插件,模板教程(有挂实锤)-哔哩哔哩1、wpk透视插件免费脚本咨询...
必备透视!哈糖大菠萝开挂!本来... 必备透视!哈糖大菠萝开挂!本来真的是有辅助软件(了解有挂)-哔哩哔哩亲,关键说明,哈糖大菠萝开挂透视...
辅助透视!epoker有透视吗... 辅助透视!epoker有透视吗,wepoker私人局有透视吗,总结教程(有挂技巧)-哔哩哔哩1、we...
揭幕透视!哈糖大菠萝破解器!一... 揭幕透视!哈糖大菠萝破解器!一直有辅助教程(有挂教程)-哔哩哔哩1、游戏颠覆性的策略玩法,独创攻略技...
详细透视!hhpoker脚本,... 详细透视!hhpoker脚本,wepoker透视脚本视频,指引教程(有挂规律)-哔哩哔哩1、点击下载...
详细透视!约局吧如何查看是否有... 详细透视!约局吧如何查看是否有挂!一贯存在有辅助方法(真的有挂)-哔哩哔哩1、玩家可以在约局吧如何查...
详情透视!hh poker辅助... 详情透视!hh poker辅助有用吗,wepoker辅助透视软件,机巧教程(有挂方略)-哔哩哔哩1、...
教你透视!拱趴大菠萝自动计算机... 教你透视!拱趴大菠萝自动计算机器人!好像是有辅助攻略(竟然有挂)-哔哩哔哩1)拱趴大菠萝自动计算机器...
有挂透视!wepoker透视脚... 有挂透视!wepoker透视脚本免费,hhpoker德州挂真的有吗,演示教程(新版有挂)-哔哩哔哩1...
有挂透视!来玩德州破解器!总是... 有挂透视!来玩德州破解器!总是存在有辅助攻略(有挂头条)-哔哩哔哩1、来玩德州破解器透视辅助软件激活...