Updated 2 December 2020
1. Download sdk from here
2. Add this sdk to your project
3. Import in the class where you want to accept payment through SDK
Start implementing with the code
Import the paytm library
1 |
import AppInvokeSDK |
1 |
private let handler = AIHandler() |
1 2 3 4 5 6 |
let mid = "merchant Id" let orderId = "order Id" let txnToken = "tax" let amount = "product amount" let callback = "where you want to reace after payment" let environment: AIEnvironment = () ? .production : .staging |
Present the payment controller
1 |
self.handler.openPaytm(merchantId: mid, orderId: orderId, txnToken: txnToken, amount: amount, callbackUrl: callback, delegate: self, environment: environment) |
Add paytm delegate in your project which will use handle the payment status (failer or seccess)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
extension ViewController: AIDelegate { func didFinish(with status: AIPaymentStatus, response: [String : Any]) { print("Paytm Callback Response: ", response) self.showAlert(title: "\(status)", message: String(describing: response)) } func openPaymentWebVC(_ controller: UIViewController?) { if let vc = controller { DispatchQueue.main.async {[weak self] in self?.present(vc, animated: true, completion: nil) } } } } |
Show the payment status through the alert
1 2 3 4 5 6 7 |
func showAlert(title: String?, message: String?) { let alert = UIAlertController(title: title, message: message, preferredStyle: .alert) alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil)) DispatchQueue.main.async { self.present(alert, animated: true, completion: nil) } } |
In this blog we have discussed about how do we checkout through paytm
I hope this blog will help you in getting some basic knowledge about the paytm checkout
For more technical blog please click here
Thanks for reading!
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
func didFinish(with status: AIPaymentStatus, response: [String : Any]) {
print(“Paytm Callback Response: “, response)
self.showAlert(title: “\(status)”, message: String(describing: response))
}