Add payments to your iOS app with Paytm SDK

Paytm iOS SDK is a secure, PCI-compliant way to accept Debit/Credit card, Net-Banking, UPI and Paytm wallet payments from your customers in your iOS app.

Demo of Paytm checkout flow in your app -

Overview of payment processing via Paytm checkout

  1. At click of the pay button by customer, order related payload is passed to your server by the app
  2. This order payload is used to generate checksumhash by our server side utility and merchant key on your server. Checksumhash is a signature used by Paytm to ensure that request has not been tampered. Utility to generate checksumhash is available here
  3. Your server passes the payload and checksumhash back to the app which hands over these details to Paytm SDK
  4. SDK verifies payload and displays payment Paytm checkout page
  5. Customer fills the payment details and completes the payment authentication. Once the payment is complete, response is posted back to your app via callback
  6. Verify checksumhash received in response on your server side. Utility to verify checksumhash is available here
  7. Lastly, verify transaction status with Transaction Status API via server to server call. This protects you from scenarios where your account credentials are compromised or request/response has been tampered

Find the detailed interaction of each system component in the flow chart below

Steps to start accepting payments via iOS SDK

Step 1: Importing the library

Follow these steps to download and import the library in your project

For Swift

  • Download the sdk from here. You have an option to download bitcode enabled and disabled SDK
  • Open your project in XCode and from File menu, select Add files to "yourproject"
  • Select Paytm.framework in the directory you just unzipped
  • Make sure 'Copy items if needed' is checked and Click 'Add'
  • Under "Link Binary With Libraries" in the "Build Phases" tab of your project settings, add SystemConfiguration.framework
  • Check if PaytmSDK.framework is added in both “Link Binary With Libraries” and “Embedded Binaries”. If not, add by clicking on the plus icon

For Objective C

  • Download the sdk from here. You have an option to download bitcode enabled and disabled SDK
  • Open your project in XCode
  • Go to the Build Phases tab, expand the Link Binary With Libraries section, click the "+" button
  • In the newly appeared “Choose items to add” window, click the “Add Other..” button, and specify the path to libPaymentsSDK.a library file and click the Open button
  • In the Link Frameworks and Libraries section, click the "+" button again, find the SystemConfiguration.framework in the list, and click the Add button.

Step 2: Initiate Payment

Start a payment transaction by following these steps -

  1. Choose the Paytm server based on your environment -
    For staging - Create an instance of the PGServerEnvironment and set the serverType to eServerTypeStaging
    For Production - Create an instance of the PGServerEnvironment and set the serverType to eServerTypeProduction

  2. Create a PGOrder instance with the mandatory parameters as given below in the code snippet. In addition to this, you may add other optional parameters as needed. Parameters with their detailed meaning is provided after the code snippet

  3. Create an instance of PGTransactionViewController by calling initTransactionForOrder and pass the PGOrder instance as parameter.

  4. Push the PGTransactionViewController as given below in the code snippet.

func beginPayment() {
	serv = serv.createProductionEnvironment()
	let type :ServerType = .eServerTypeProduction
	let order = PGOrder(orderID: "", customerID: "", amount: "", eMail: "", mobile: "")
	order.params = ["MID": "rxazcv89315285244163",
		"ORDER_ID": "order1",
		"CUST_ID": "cust123",
		"MOBILE_NO": "7777777777",
		"EMAIL": "",
		"TXN_AMOUNT": "100.12",
		"INDUSTRY_TYPE_ID": "Retail",
		"CHECKSUMHASH": "oCDBVF+hvVb68JvzbKI40TOtcxlNjMdixi9FnRSh80Ub7XfjvgNr9NrfrOCPLmt65UhStCkrDnlYkclz1qE0uBMOrmuKLGlybuErulbLYSQ=",
	self.txnController =  self.txnController.initTransaction(for: order) as?PGTransactionViewController
	self.txnController.title = "Paytm Payments"
	if(type != ServerType.eServerTypeNone) {
		self.txnController.serverType = type;
	} else {
	self.txnController.merchant = PGMerchantConfiguration.defaultConfiguration()
	self.txnController.delegate = self
	self.navigationController?.pushViewController(self.txnController, animated: true)

Description of Parameters:

Parameter NameDescription
MID String(20) MandatoryThis is a unique identifier provided to every merchant by Paytm. MID is part of your account credentials and is different on staging and production environment. Your staging MID is available here and production MID will be available once your activation is complete
ORDER_ID String(50) MandatoryUnique reference ID for a transaction which is generated by merchant Special characters allowed in Order ID are: “@” “-” “_” “.”.
CUST_ID String(64) MandatoryUnique reference ID for every customer which is generated by merchant Special characters allowed in Cust_ID are @, ! ,_ $
TXN_AMOUNT String(10) MandatoryAmount in INR payable by customer. Should contain digits up to two decimal points. The amount should not include any separator like (“,”)
CHANNEL_ID String(3) MandatoryThis parameter is used to control the theme of the payment page. Based on the channel passed, Paytm will render the layout suitable for that specific platform
For App, the value is WAP
WEBSITE String(30) MandatoryFor staging environment: WEBSTAGING
For production environment: Will be available here once your activation is complete
INDUSTRY_TYPE_ID String(20) MandatoryFor staging environment: "Retail"
For production environment: Will be available here once your activation is complete
CHECKSUMHASH String(108) MandatorySecurity parameter to avoid tampering. Generated using server side checksum utility provided by Paytm. Merchant has to ensure that this always gets generated on server. Utilities to generate checksumhash is available here
MOBILE_NO Optional String(15) MandatoryCustomer mobile number. Passing this enables faster login for customer into his/her Paytm account
EMAIL Optional String(50) MandatoryCustomer's email ID. Passing this enables faster login for customer into his/her mobile wallet.
CALLBACK_URL String(255) MandatoryStaging Environment:
Production Environment:

STEP 3: Handle error and success responses

To handle success/errors on completion of payment, implement didFinishedResponse, didCancelTrasaction, errorMisssingParameter methods of the PGTransactionDelegate. Code snippet provided below

//this function triggers when transaction gets finished
func didFinishedResponse(_ controller: PGTransactionViewController, response responseString: String) {
	let msg : String = responseString
	var titlemsg : String = ""
	if let data = String.Encoding.utf8) {
		do {
			if let jsonresponse = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as? [String:Any] , jsonresponse.count > 0{
				titlemsg = jsonresponse["STATUS"] as? String ?? ""
		} catch {
			print("Something went wrong")
	let actionSheetController: UIAlertController = UIAlertController(title: titlemsg , message: msg, preferredStyle: .alert)
	let cancelAction : UIAlertAction = UIAlertAction(title: "OK", style: .cancel) { 
		action -> Void in
		controller.navigationController?.popViewController(animated: true)
	self.present(actionSheetController, animated: true, completion: nil)
//this function triggers when transaction gets cancelled
func didCancelTrasaction(_ controller : PGTransactionViewController) {
	controller.navigationController?.popViewController(animated: true)
//Called when a required parameter is missing.
func errorMisssingParameter(_ controller : PGTransactionViewController, error : NSError?) {
	controller.navigationController?.popViewController(animated: true)

Step 5: Checksum Generation and Verification

Get the sample code for a language of your choice -

On completion of your integration -

Post completion of integration on your staging environment, do a complete transaction from order summary page on your website or mobile app

  1. Attempt a test transaction using test paymodes credentials
  2. Ensure you re-verify transaction response with Transaction Status API via server to server call in payment flow and not separately as a one time activity
  3. See the transaction details in “Test Data” mode on your dashboard

Once the test transaction is complete, move your code to live environment with production account details. Note that production accounts details are available after you have activated your account on the dashboard

Lastly, it's recommended that you read about Managing Refunds and late payment notifications

In case of any issues with integration, please get in touch