首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在paytm支付成功后,跳转回app (ios和android)

在paytm支付成功后,跳转回app (ios和android)
EN

Stack Overflow用户
提问于 2017-08-01 15:23:28
回答 1查看 2K关注 0票数 5

支付成功后,Paytm会将用户重定向到mysite上的回调url。如何将用户从回调url返回的视图重定向到应用程序。

EN

回答 1

Stack Overflow用户

发布于 2018-03-22 23:59:46

添加这些功能

代码语言:javascript
复制
    func showController(controller: PGTransactionViewController) {

    if self.navigationController != nil {
        self.navigationController!.pushViewController(controller, animated: true)

    }
    else {
        self.present(controller, animated: true, completion: {() -> Void in
        })
    }
}

func removeController(controller: PGTransactionViewController) {
    if self.navigationController != nil {
        self.navigationController!.popViewController(animated: true)
    }
    else {
        controller.dismiss(animated: true, completion: {() -> Void in
        })
    }
}
     func showError(title:String, message:String, controller: PGTransactionViewController) {
    let alertController = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert);

    let ok = UIAlertAction(title: "No", style: UIAlertActionStyle.default) { (alert) in

        alertController.dismiss(animated: true, completion: nil);
    };

    let goBack = UIAlertAction(title: attributedYesString.string, style: UIAlertActionStyle.default) { (alert) in
        self.removeController(controller: controller)
    };

    alertController.addAction(ok);
    alertController.addAction(goBack)
    self.parent?.present(alertController, animated: true, completion: nil)

}

并且在Paytm中,功能相应地调用这些函数。我将给你一个例子,我是如何做到的。

代码语言:javascript
复制
func didFinishedResponse(_ controller: PGTransactionViewController!, response responseString: String!) {
    print(responseString)
    print("didfinish")
    self.removeController(controller: controller)
}

func didCancelTrasaction(_ controller: PGTransactionViewController!) {
    print("cancelled", "didcancel")
    self.showError(title: "Your transaction will be cancelled", message: "Are you sure?", controller: controller)

}

func errorMisssingParameter(_ controller: PGTransactionViewController!, error: Error!) {
    print(error, "missing")
}

func didSucceedTransaction(_ controller: PGTransactionViewController!, response: [AnyHashable : Any]!) {
    print(response,"Transaction Successfull")
    self.removeController(controller: controller)

}


func didFailTransaction(_ controller: PGTransactionViewController!, error: Error!, response: [AnyHashable : Any]!) {

    self.removeController(controller: controller)
}
func didCancelTransaction(_ controller: PGTransactionViewController!, error: Error!, response: [AnyHashable : Any]!) {
    print(error, response , "Transaction Cancelled")
    self.removeController(controller: controller)

}

func didFinishCASTransaction(_ controller: PGTransactionViewController!, response: [AnyHashable : Any]!) {
    print(response , "Transaction")
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45431419

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档