5

after payment success Paytm redirects user to the callback-url on mysite. How to redirect user back into the app from the view returned by callback url into the App.

dev21
  • 520
  • 2
  • 8
  • 22

2 Answers2

0

Add these functionalities

    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)

}

And in Paytm functionalities call these functions accordingly. I'll give you an example how I have done it.

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")
}
Chetan Rajagiri
  • 1,009
  • 11
  • 13
0

For Payment success / Failure :-

In REACT NATIVE, If all the parameters are correct and call back URL also correct means, every success or failure transactions paytm itself redirect the order page. Based on the paytm results, you can redirect the page (success page / Failure page). Check the paytm response (TXN_FAILURE / PENDING / TXN_SUCCESS /NO_RECORD_FOUND).

Gprakash
  • 30
  • 7