Overview of Paytm checkout process
- At the click of the pay button by the customer, order-related payload is passed to your server by the app
- This order payload is used to generate checksumhash by our server side utility and merchant key on your server. Paytm use Checksumhash signature to ensure that request has not been tampered. Utility to generate checksumhash is available here
- Your server passes the payload and checksumhash back to the app which hands over these details to Paytm SDK
- SDK verifies payload and displays payment Paytm checkout page
- Customer fills the payment details and completes the payment authentication. you will get payment status with the callback, after payment complete
- Verify checksumhash received in response on your server side.
- Lastly, verify transaction status with Transaction Status API via server to server call.
Step to implement payment gateway through sdk.
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
Initialized the payment checkout process
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) } } |
Conclusion –
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!