paytm 成功后无法导航回我的应用程序
cannot navigate back to my App after paytm success
我正在使用 Patym SDK 做一个 IOS 应用程序,事务正在成功发生,但它没有导航回应用程序。它显示带有“重定向回应用程序”的网络视图。以前有人遇到过这个问题吗?
这是我的代码:
extension ShippingViewController : PGTransactionDelegate {
func didCancelTrasaction(_ controller: PGTransactionViewController!) {
let vc = UIStoryboard(name: "account", bundle: nil).instantiateViewController(withIdentifier: "confirmViewController") as! confirmViewController
self.present(vc, animated: true, completion: nil)
}
func didFinishedResponse(_ controller: PGTransactionViewController!, response responseString: String!) {
let vc = UIStoryboard(name: "account", bundle: nil).instantiateViewController(withIdentifier: "confirmViewController") as! confirmViewController
self.present(vc, animated: true, completion: nil)
}
func errorMisssingParameter(_ controller: PGTransactionViewController!, error: Error!) {
print(error)
showAlert(title: "didCancelTrasaction", message: error.localizedDescription)
let vc = UIStoryboard(name: "account", bundle: nil).instantiateViewController(withIdentifier: "CSWhoopsView") as! CSAlertViewController
self.present(vc, animated: true, completion: nil)
}
func didFailTransaction(_ controller: PGTransactionViewController!, error: Error!, response: [AnyHashable : Any]!) {
print(error)
showAlert(title: "Transaction Failed", message: error.localizedDescription)
let vc = UIStoryboard(name: "account", bundle: nil).instantiateViewController(withIdentifier: "CSWhoopsView") as! CSAlertViewController
self.present(vc, animated: true, completion: nil)
}
func didCancelTransaction(_ controller: PGTransactionViewController!, error: Error!, response: [AnyHashable : Any]!) {
showAlert(title: "Transaction Cancelled", message: error.localizedDescription)
let vc = UIStoryboard(name: "account", bundle: nil).instantiateViewController(withIdentifier: "CSWhoopsView") as! CSAlertViewController
self.present(vc, animated: true, completion: nil)
}
func didFinishCASTransaction(_ controller: PGTransactionViewController!, response: [AnyHashable : Any]!) {
print("my response isis :" )
print(response)
showAlert(title: "cas", message: "")
}
func didSucceedTransaction(_ controller: PGTransactionViewController!, response: [AnyHashable : Any]!) {
print("my response is :" )
print(response)
showAlert(title: "Transaction Successfull", message: NSString.localizedStringWithFormat("Response- %@", response) as String)
let vc = UIStoryboard(name: "account", bundle: nil).instantiateViewController(withIdentifier: "confirmViewController") as! confirmViewController
self.present(vc, animated: true, completion: nil)
}
}
根据此文档:PayTM iOS SDK Integration Step,PGTransactionDelegate
提供以下方法来处理回调。
// On Successful Payment
func didSucceedTransaction(controller: PGTransactionViewController, response: [NSObject : AnyObject]) {
print(response)
print("Response - \(response)")
//removeController - Close PayTM Controller here using dismiss or pop controller methods
}
// On Failure
func didFailTransaction(controller: PGTransactionViewController, error: NSError, response: [NSObject : AnyObject]) {
print(response)
if response.count == 0 {
print(response.description)
}
else if error != 0 {
print(error.localizedDescription)
}
//removeController - Close PayTM Controller here using dismiss or pop controller methods
}
//On Cancellation
func didCancelTransaction(controller: PGTransactionViewController, error: NSError, response: [NSObject : AnyObject]) {
print("Transaction has been Cancelled")
//removeController - Close PayTM Controller here using dismiss or pop controller methods
}
func didFinishCASTransaction(controller: PGTransactionViewController, response: [NSObject : AnyObject]) {
print(response);
}
还有一点很重要:Paytm CALLBACK_URL
- 这个url是由Paytm提供的,所以应用程序可以从paytm和return读取数据。
注意:由于此处 SDK 的最新更新是 PGTransactionDelegate 方法(在 Objective-C 中)
@protocol PGTransactionDelegate <NSObject>
@required
//Called when a transaction has completed. response dictionary will be having details about Transaction.
-(void)didFinishedResponse:(PGTransactionViewController *)controller response:(NSString *)responseString;
//Called when a user has been cancelled the transaction.
-(void)didCancelTrasaction:(PGTransactionViewController *)controller;
//Called when a required parameter is missing.
-(void)errorMisssingParameter:(PGTransactionViewController *)controller error:(NSError *) error;
@end
编辑:
在您的代码中替换以下委托实现。
func didSucceedTransaction(_ controller: PGTransactionViewController!, response: [AnyHashable : Any]!) {
print("my response is :" )
print(response)
showAlert(title: "Transaction Successfull", message: NSString.localizedStringWithFormat("Response- %@", response) as String)
controller.dismiss(animated: true) {
let vc = UIStoryboard(name: "account", bundle: nil).instantiateViewController(withIdentifier: "confirmViewController") as! confirmViewController
self.present(vc, animated: true, completion: nil)
}
}
扩展 ShippingViewController : PGTransactionDelegate {
func didCancelTrasaction(_ controller: PGTransactionViewController!) {
let vc = UIStoryboard(name: "account", bundle: nil).instantiateViewController(withIdentifier: "confirmViewController") as! confirmViewController
self.present(vc, animated: true, completion: nil)
}
func didFinishedResponse(_ controller: PGTransactionViewController!, response responseString: String!) {
let vc = UIStoryboard(name: "account", bundle: nil).instantiateViewController(withIdentifier: "confirmViewController") as! confirmViewController
self.present(vc, animated: true, completion: nil)
}
func errorMisssingParameter(_ controller: PGTransactionViewController!, error: Error!) {
print(error)
showAlert(title: "didCancelTrasaction", message: error.localizedDescription)
let vc = UIStoryboard(name: "account", bundle: nil).instantiateViewController(withIdentifier: "CSWhoopsView") as! CSAlertViewController
self.present(vc, animated: true, completion: nil)
}
func didFailTransaction(_ controller: PGTransactionViewController!, error: Error!, response: [AnyHashable : Any]!) {
print(error)
showAlert(title: "Transaction Failed", message: error.localizedDescription)
let vc = UIStoryboard(name: "account", bundle: nil).instantiateViewController(withIdentifier: "CSWhoopsView") as! CSAlertViewController
self.present(vc, animated: true, completion: nil)
}
func didCancelTransaction(_ controller: PGTransactionViewController!, error: Error!, response: [AnyHashable : Any]!) {
showAlert(title: "Transaction Cancelled", message: error.localizedDescription)
let vc = UIStoryboard(name: "account", bundle: nil).instantiateViewController(withIdentifier: "CSWhoopsView") as! CSAlertViewController
self.present(vc, animated: true, completion: nil)
}
func didFinishCASTransaction(_ controller: PGTransactionViewController!, response: [AnyHashable : Any]!) {
print("my response isis :" )
print(response)
showAlert(title: "cas", message: "")
}
func didSucceedTransaction(_ controller: PGTransactionViewController!, response: [AnyHashable : Any]!) {
print("my response is :" )
print(response)
showAlert(title: "Transaction Successfull", message: NSString.localizedStringWithFormat("Response- %@", response) as String)
let vc = UIStoryboard(name: "account", bundle: nil).instantiateViewController(withIdentifier: "confirmViewController") as! confirmViewController
self.present(vc, animated: true, completion: nil)
}
}
我正在使用 Patym SDK 做一个 IOS 应用程序,事务正在成功发生,但它没有导航回应用程序。它显示带有“重定向回应用程序”的网络视图。以前有人遇到过这个问题吗?
这是我的代码:
extension ShippingViewController : PGTransactionDelegate {
func didCancelTrasaction(_ controller: PGTransactionViewController!) {
let vc = UIStoryboard(name: "account", bundle: nil).instantiateViewController(withIdentifier: "confirmViewController") as! confirmViewController
self.present(vc, animated: true, completion: nil)
}
func didFinishedResponse(_ controller: PGTransactionViewController!, response responseString: String!) {
let vc = UIStoryboard(name: "account", bundle: nil).instantiateViewController(withIdentifier: "confirmViewController") as! confirmViewController
self.present(vc, animated: true, completion: nil)
}
func errorMisssingParameter(_ controller: PGTransactionViewController!, error: Error!) {
print(error)
showAlert(title: "didCancelTrasaction", message: error.localizedDescription)
let vc = UIStoryboard(name: "account", bundle: nil).instantiateViewController(withIdentifier: "CSWhoopsView") as! CSAlertViewController
self.present(vc, animated: true, completion: nil)
}
func didFailTransaction(_ controller: PGTransactionViewController!, error: Error!, response: [AnyHashable : Any]!) {
print(error)
showAlert(title: "Transaction Failed", message: error.localizedDescription)
let vc = UIStoryboard(name: "account", bundle: nil).instantiateViewController(withIdentifier: "CSWhoopsView") as! CSAlertViewController
self.present(vc, animated: true, completion: nil)
}
func didCancelTransaction(_ controller: PGTransactionViewController!, error: Error!, response: [AnyHashable : Any]!) {
showAlert(title: "Transaction Cancelled", message: error.localizedDescription)
let vc = UIStoryboard(name: "account", bundle: nil).instantiateViewController(withIdentifier: "CSWhoopsView") as! CSAlertViewController
self.present(vc, animated: true, completion: nil)
}
func didFinishCASTransaction(_ controller: PGTransactionViewController!, response: [AnyHashable : Any]!) {
print("my response isis :" )
print(response)
showAlert(title: "cas", message: "")
}
func didSucceedTransaction(_ controller: PGTransactionViewController!, response: [AnyHashable : Any]!) {
print("my response is :" )
print(response)
showAlert(title: "Transaction Successfull", message: NSString.localizedStringWithFormat("Response- %@", response) as String)
let vc = UIStoryboard(name: "account", bundle: nil).instantiateViewController(withIdentifier: "confirmViewController") as! confirmViewController
self.present(vc, animated: true, completion: nil)
}
}
根据此文档:PayTM iOS SDK Integration Step,PGTransactionDelegate
提供以下方法来处理回调。
// On Successful Payment
func didSucceedTransaction(controller: PGTransactionViewController, response: [NSObject : AnyObject]) {
print(response)
print("Response - \(response)")
//removeController - Close PayTM Controller here using dismiss or pop controller methods
}
// On Failure
func didFailTransaction(controller: PGTransactionViewController, error: NSError, response: [NSObject : AnyObject]) {
print(response)
if response.count == 0 {
print(response.description)
}
else if error != 0 {
print(error.localizedDescription)
}
//removeController - Close PayTM Controller here using dismiss or pop controller methods
}
//On Cancellation
func didCancelTransaction(controller: PGTransactionViewController, error: NSError, response: [NSObject : AnyObject]) {
print("Transaction has been Cancelled")
//removeController - Close PayTM Controller here using dismiss or pop controller methods
}
func didFinishCASTransaction(controller: PGTransactionViewController, response: [NSObject : AnyObject]) {
print(response);
}
还有一点很重要:Paytm CALLBACK_URL
- 这个url是由Paytm提供的,所以应用程序可以从paytm和return读取数据。
注意:由于此处 SDK 的最新更新是 PGTransactionDelegate 方法(在 Objective-C 中)
@protocol PGTransactionDelegate <NSObject>
@required
//Called when a transaction has completed. response dictionary will be having details about Transaction.
-(void)didFinishedResponse:(PGTransactionViewController *)controller response:(NSString *)responseString;
//Called when a user has been cancelled the transaction.
-(void)didCancelTrasaction:(PGTransactionViewController *)controller;
//Called when a required parameter is missing.
-(void)errorMisssingParameter:(PGTransactionViewController *)controller error:(NSError *) error;
@end
编辑:
在您的代码中替换以下委托实现。
func didSucceedTransaction(_ controller: PGTransactionViewController!, response: [AnyHashable : Any]!) {
print("my response is :" )
print(response)
showAlert(title: "Transaction Successfull", message: NSString.localizedStringWithFormat("Response- %@", response) as String)
controller.dismiss(animated: true) {
let vc = UIStoryboard(name: "account", bundle: nil).instantiateViewController(withIdentifier: "confirmViewController") as! confirmViewController
self.present(vc, animated: true, completion: nil)
}
}
扩展 ShippingViewController : PGTransactionDelegate {
func didCancelTrasaction(_ controller: PGTransactionViewController!) {
let vc = UIStoryboard(name: "account", bundle: nil).instantiateViewController(withIdentifier: "confirmViewController") as! confirmViewController
self.present(vc, animated: true, completion: nil)
}
func didFinishedResponse(_ controller: PGTransactionViewController!, response responseString: String!) {
let vc = UIStoryboard(name: "account", bundle: nil).instantiateViewController(withIdentifier: "confirmViewController") as! confirmViewController
self.present(vc, animated: true, completion: nil)
}
func errorMisssingParameter(_ controller: PGTransactionViewController!, error: Error!) {
print(error)
showAlert(title: "didCancelTrasaction", message: error.localizedDescription)
let vc = UIStoryboard(name: "account", bundle: nil).instantiateViewController(withIdentifier: "CSWhoopsView") as! CSAlertViewController
self.present(vc, animated: true, completion: nil)
}
func didFailTransaction(_ controller: PGTransactionViewController!, error: Error!, response: [AnyHashable : Any]!) {
print(error)
showAlert(title: "Transaction Failed", message: error.localizedDescription)
let vc = UIStoryboard(name: "account", bundle: nil).instantiateViewController(withIdentifier: "CSWhoopsView") as! CSAlertViewController
self.present(vc, animated: true, completion: nil)
}
func didCancelTransaction(_ controller: PGTransactionViewController!, error: Error!, response: [AnyHashable : Any]!) {
showAlert(title: "Transaction Cancelled", message: error.localizedDescription)
let vc = UIStoryboard(name: "account", bundle: nil).instantiateViewController(withIdentifier: "CSWhoopsView") as! CSAlertViewController
self.present(vc, animated: true, completion: nil)
}
func didFinishCASTransaction(_ controller: PGTransactionViewController!, response: [AnyHashable : Any]!) {
print("my response isis :" )
print(response)
showAlert(title: "cas", message: "")
}
func didSucceedTransaction(_ controller: PGTransactionViewController!, response: [AnyHashable : Any]!) {
print("my response is :" )
print(response)
showAlert(title: "Transaction Successfull", message: NSString.localizedStringWithFormat("Response- %@", response) as String)
let vc = UIStoryboard(name: "account", bundle: nil).instantiateViewController(withIdentifier: "confirmViewController") as! confirmViewController
self.present(vc, animated: true, completion: nil)
}
}