{"id":1663,"date":"2019-05-07T13:24:08","date_gmt":"2019-05-07T07:54:08","guid":{"rendered":"http:\/\/blog.openwebsolutions.in\/?p=1663"},"modified":"2019-05-07T13:25:45","modified_gmt":"2019-05-07T07:55:45","slug":"paytm-payment-integration-ios-swift-language","status":"publish","type":"post","link":"https:\/\/openwebsolutions.in\/blog\/paytm-payment-integration-ios-swift-language\/","title":{"rendered":"Paytm Payment Integration in iOS using Swift Language"},"content":{"rendered":"<p class=\"p1\">When you start working with PayTm Payment Integration, first of all, you have to know the basic idea of installing framework file manually. I recently worked on this process and faced some problem while installing the PodFile. That&#8217;s why I recommended you to install PaymentsSDK file <a href=\"https:\/\/github.com\/Paytm-Payments\/Paytm_iOS_App_Kit\/blob\/master\/Swift\/BitCodeEnabled\/PaymentSDK.framework\/PaymentSDK\"><strong>from this link<\/strong><\/a>. Then follow\u00a0<span class=\"s2\">these steps one by one.<\/span><\/p>\n<p class=\"p1\"><span class=\"s2\"><strong>Step 1:<span class=\"Apple-converted-space\">\u00a0<\/span><\/strong>After successfully downloading, just drag and drop the .framework file into your swift project.<br \/>\n<\/span><\/p>\n<p class=\"p1\"><span class=\"s2\"><strong>Step 2:<\/strong> After completing step 1, you need to add the framework into your target file that you can find here- <em>YourProject(TARGET) &gt;BuildPhrase &gt;Link Binary<\/em> With Libraries, after that check if it add into &#8211; <em>YourProject(TARGET) &gt;General &gt;Linked Frameworks With Libraries<\/em>, this directory or not. If not added then you can also do the same by clicking the \u201c+\u201d button. You can\u00a0<\/span>now\u00a0<span class=\"s2\">use PaymentsSDK easily into your project\u2019s each and every View Controller by using \u201cimport PaymentSDK\u201d<\/span> in header section in your swift file.<\/p>\n<p class=\"p1\"><strong>Step 3:<\/strong> If you find some error in step 2 then step 3 is for you otherwise you can proceed with the next step. When I have done this two-step, I found an error Like \u201cPaymentSDK framework not found\u201d after compiling. I suggest you simply two things to do to remove that error. First, enable your bit code by simply <span class=\"s2\">going to <em>YourProject(TARGET) &gt;Build Setting &gt;Build Option &gt;Enable Bitcode<\/em><\/span><\/p>\n<p><img loading=\"lazy\" class=\"alignnone wp-image-1666 size-full\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2019\/04\/Screenshot-2019-04-25-at-12.49.45-PM.png\" alt=\"\" width=\"774\" height=\"89\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2019\/04\/Screenshot-2019-04-25-at-12.49.45-PM.png 774w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2019\/04\/Screenshot-2019-04-25-at-12.49.45-PM-300x34.png 300w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2019\/04\/Screenshot-2019-04-25-at-12.49.45-PM-768x89.png 768w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2019\/04\/Screenshot-2019-04-25-at-12.49.45-PM-600x69.png 600w\" sizes=\"(max-width: 774px) 100vw, 774px\" \/><\/p>\n<p class=\"p1\"><span class=\"s2\"> and set it to Yes because here we are using that framework which is bitcode enabled. Forgot it if already set Yes and now add paymentSDK framework to the Other Linker Framework by going to <em>YourProject(TARGET) &gt;Build Setting &gt;Linking &gt;Other Liker Flags<\/em> <\/span><\/p>\n<p><img loading=\"lazy\" class=\"alignnone wp-image-1667 size-full\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2019\/04\/Screenshot-2019-04-25-at-12.50.28-PM.png\" alt=\"\" width=\"759\" height=\"150\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2019\/04\/Screenshot-2019-04-25-at-12.50.28-PM.png 759w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2019\/04\/Screenshot-2019-04-25-at-12.50.28-PM-300x59.png 300w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2019\/04\/Screenshot-2019-04-25-at-12.50.28-PM-600x119.png 600w\" sizes=\"(max-width: 759px) 100vw, 759px\" \/><\/p>\n<p>add PaymentSDK framework file just like this,<\/p>\n<p><img loading=\"lazy\" class=\"alignnone wp-image-1668 \" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2019\/04\/Screenshot-2019-04-25-at-12.53.20-PM.png\" alt=\"\" width=\"353\" height=\"182\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2019\/04\/Screenshot-2019-04-25-at-12.53.20-PM.png 322w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2019\/04\/Screenshot-2019-04-25-at-12.53.20-PM-300x155.png 300w\" sizes=\"(max-width: 353px) 100vw, 353px\" \/><\/p>\n<p class=\"p1\"><span class=\"s2\">now clean your project by simply using\u00a0<em>Cmd + Option + Shift + K<\/em> and build it. I hope this gonna work perfectly.<\/span><\/p>\n<p class=\"p1\"><span class=\"s2\"><strong>Step 4:<\/strong> Now it&#8217;s time to dive into your code in your ViewController.swift file. Import PaymentSDK and create a delegate method of Payment\u00a0<em>\u201cPGTransactionDelegate\u201d<\/em> because we are now using this delegate method to work with the payment procedure and in it two variable just like this,<\/span><\/p>\n<blockquote>\n<p class=\"p1\">var server = PGServerEnvironment()<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">\u00a0 \u00a0 \u00a0 \u00a0 <\/span>var txnController = PGTransactionViewController()<\/p>\n<\/blockquote>\n<p class=\"p1\">After this, you need to write some code to navigate to transaction controller for payment procedure.<\/p>\n<blockquote>\n<p class=\"p1\">func beginPayment() {<\/p>\n<p class=\"p1\">server = server.createProductionEnvironment()<\/p>\n<p class=\"p1\">let type :ServerType = .eServerTypeProduction<\/p>\n<p class=\"p1\">let order = PGOrder(orderID: &#8220;&#8221;, customerID: &#8220;&#8221;, amount: &#8220;&#8221;, eMail: &#8220;&#8221;, mobile: &#8220;&#8221;)<\/p>\n<p class=\"p1\">order.params = [&#8220;MID&#8221;: &#8220;rxazcv89315285244163&#8221;,<\/p>\n<p class=\"p1\">&#8220;ORDER_ID&#8221;: &#8220;order1&#8221;,<\/p>\n<p class=\"p1\">&#8220;CUST_ID&#8221;: &#8220;cust123&#8221;,<\/p>\n<p class=\"p1\">&#8220;MOBILE_NO&#8221;: &#8220;7777777777&#8221;,<\/p>\n<p class=\"p1\">&#8220;EMAIL&#8221;: &#8220;username@emailprovider.com&#8221;,<\/p>\n<p class=\"p1\">&#8220;CHANNEL_ID&#8221;: &#8220;WAP&#8221;,<\/p>\n<p class=\"p1\">&#8220;WEBSITE&#8221;: &#8220;WEBSTAGING&#8221;,<\/p>\n<p class=\"p1\">&#8220;TXN_AMOUNT&#8221;: &#8220;100.12&#8221;,<\/p>\n<p class=\"p1\">&#8220;INDUSTRY_TYPE_ID&#8221;: &#8220;Retail&#8221;,<\/p>\n<p class=\"p1\">&#8220;CHECKSUMHASH&#8221;: &#8220;oCDBVF+hvVb68JvzbKI40TOtcxlNjMdixi9FnRSh80Ub7XfjvgNr9NrfrOCPLmt65UhStCkrDnlYkclz1qE0uBMOrmuKLGlybuErulbLYSQ=&#8221;,<\/p>\n<p class=\"p1\">&#8220;CALLBACK_URL&#8221;: &#8220;https:\/\/securegw-stage.paytm.in\/theia\/paytmCallback?ORDER_ID=order1&#8221;]<\/p>\n<p class=\"p1\">self.txnController =<span class=\"Apple-converted-space\">\u00a0 <\/span>self.txnController.initTransaction(for: order) as?PGTransactionViewController<\/p>\n<p class=\"p1\">self.txnController.title = &#8220;Paytm Payments&#8221;<\/p>\n<p class=\"p1\">self.txnController.setLoggingEnabled(true)<\/p>\n<p class=\"p1\">if(type != ServerType.eServerTypeNone) {<\/p>\n<p class=\"p1\">self.txnController.serverType = type;<\/p>\n<p class=\"p1\">} else {<\/p>\n<p class=\"p1\">return<\/p>\n<p class=\"p1\">}<\/p>\n<p class=\"p1\">self.txnController.merchant = PGMerchantConfiguration.defaultConfiguration()<\/p>\n<p class=\"p1\">self.txnController.delegate = self<\/p>\n<p class=\"p1\">self.navigationController?.pushViewController(self.txnController, animated: true)<\/p>\n<p class=\"p1\">}<\/p>\n<\/blockquote>\n<p class=\"p1\">I assume that all merchant config and all params for this method are created from the backend side. The suggestion is to talk with your backend programmer and get understood that merchant configuration.<\/p>\n<p class=\"p1\">** Here you need to know something if you are working Stagging Environment then just change the<\/p>\n<blockquote><p><em>server = server.createStagingEnvironment()<\/em><\/p><\/blockquote>\n<p class=\"p1\">** And if you do not use navigation controller don\u2019t worry, you can present that payment page as a popup by creating an instance of navigationController, because Paytm not allow presenting that txnController. You need to modify that just like this :<\/p>\n<blockquote>\n<p class=\"p1\">let storyBoard: UIStoryboard = UIStoryboard(name: &#8220;Main&#8221;, bundle: nil)<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">\u00a0 \u00a0 \u00a0 \u00a0 <\/span>let navigationController = storyBoard.instantiateViewController(withIdentifier: ReuseIdentifiers.identifierForNavigationVC) as! UINavigationController<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">\u00a0 \u00a0 \u00a0 \u00a0 <\/span>navigationController.pushViewController(txnController, animated: true)<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">\u00a0 \u00a0 \u00a0 \u00a0 <\/span>navigationController.modalTransitionStyle = .crossDissolve<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">\u00a0 \u00a0 \u00a0 \u00a0 <\/span>txnController.delegate = self<\/p>\n<p class=\"p1\"><span class=\"Apple-converted-space\">\u00a0 \u00a0 \u00a0 \u00a0 <\/span>self.present(navigationController, animated: true, completion: nil)<\/p>\n<\/blockquote>\n<p class=\"p1\"><strong>Step 5:<\/strong> After doing the previous step your last work remains to check whether the payment\u00a0is successful or cancel or failed. If you want to check it then you need to perform some method from <em>PGTransactionDelegate<\/em> method those are :<\/p>\n<blockquote>\n<p class=\"p1\">\/\/this function triggers when transaction gets finished<\/p>\n<p class=\"p1\">func didFinishedResponse(_ controller: PGTransactionViewController, response responseString: String) {<\/p>\n<p class=\"p1\">let msg : String = responseString<\/p>\n<p class=\"p1\">var titlemsg : String = &#8220;&#8221;<\/p>\n<p class=\"p1\">if let data = responseString.data(using: String.Encoding.utf8) {<\/p>\n<p class=\"p1\">do {<\/p>\n<p class=\"p1\">if let jsonresponse = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as? [String:Any] , jsonresponse.count &gt; 0{<\/p>\n<p class=\"p1\">titlemsg = jsonresponse[&#8220;STATUS&#8221;] as? String ?? &#8220;&#8221;<\/p>\n<p class=\"p1\">}<\/p>\n<p class=\"p1\">} catch {<\/p>\n<p class=\"p1\">print(&#8220;Something went wrong&#8221;)<\/p>\n<p class=\"p1\">}<\/p>\n<p class=\"p1\">}<\/p>\n<p class=\"p1\">let actionSheetController: UIAlertController = UIAlertController(title: titlemsg , message: msg, preferredStyle: .alert)<\/p>\n<p class=\"p1\">let cancelAction : UIAlertAction = UIAlertAction(title: &#8220;OK&#8221;, style: .cancel) {<\/p>\n<p class=\"p1\">action -&gt; Void in<\/p>\n<p class=\"p1\">controller.navigationController?.popViewController(animated: true)<\/p>\n<p class=\"p1\">}<\/p>\n<p class=\"p1\">actionSheetController.addAction(cancelAction)<\/p>\n<p class=\"p1\">self.present(actionSheetController, animated: true, completion: nil)<\/p>\n<p class=\"p1\">}<\/p>\n<p class=\"p1\">\/\/this function triggers when transaction gets cancelled<\/p>\n<p class=\"p1\">func didCancelTrasaction(_ controller : PGTransactionViewController) {<\/p>\n<p class=\"p1\">controller.navigationController?.popViewController(animated: true)<\/p>\n<p class=\"p1\">}<\/p>\n<p class=\"p1\">\/\/Called when a required parameter is missing.<\/p>\n<p class=\"p1\">func errorMisssingParameter(_ controller : PGTransactionViewController, error : NSError?) {<\/p>\n<p class=\"p1\">controller.navigationController?.popViewController(animated: true)<\/p>\n<p class=\"p1\">}<\/p>\n<\/blockquote>\n<p class=\"p1\">Now you can do whatever you want into those function. I hope that this tutorial helps you a lot. Thanks for visiting our blog.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When you start working with PayTm Payment Integration, first of all, you have to know the basic idea of installing framework file manually. I recently worked on this process and faced some problem while installing the PodFile. That&#8217;s why I recommended you to install PaymentsSDK file from this link. Then follow\u00a0these steps one by one. [&hellip;]<\/p>\n","protected":false},"author":40,"featured_media":1669,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[54,128,5],"tags":[55,129],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v14.8.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Paytm Payment Integration In iOS Using Swift Language<\/title>\n<meta name=\"robots\" content=\"index, follow\" \/>\n<meta name=\"googlebot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta name=\"bingbot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/openwebsolutions.in\/blog\/paytm-payment-integration-ios-swift-language\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Paytm Payment Integration In iOS Using Swift Language\" \/>\n<meta property=\"og:description\" content=\"When you start working with PayTm Payment Integration, first of all, you have to know the basic idea of installing framework file manually. I recently worked on this process and faced some problem while installing the PodFile. That&#8217;s why I recommended you to install PaymentsSDK file from this link. Then follow\u00a0these steps one by one. [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/openwebsolutions.in\/blog\/paytm-payment-integration-ios-swift-language\/\" \/>\n<meta property=\"og:site_name\" content=\"Openweb Solutions Blog\" \/>\n<meta property=\"article:published_time\" content=\"2019-05-07T07:54:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-05-07T07:55:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2019\/04\/Paytm-Payment-Intregration-In-iOS-Swift.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n<meta name=\"twitter:card\" content=\"summary\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#website\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/\",\"name\":\"Openweb Solutions Blog\",\"description\":\"Transforming ideas into reality\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/openwebsolutions.in\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/paytm-payment-integration-ios-swift-language\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2019\/04\/Paytm-Payment-Intregration-In-iOS-Swift.png\",\"width\":1280,\"height\":720},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/paytm-payment-integration-ios-swift-language\/#webpage\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/paytm-payment-integration-ios-swift-language\/\",\"name\":\"Paytm Payment Integration In iOS Using Swift Language\",\"isPartOf\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/paytm-payment-integration-ios-swift-language\/#primaryimage\"},\"datePublished\":\"2019-05-07T07:54:08+00:00\",\"dateModified\":\"2019-05-07T07:55:45+00:00\",\"author\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#\/schema\/person\/bae16b1f4580e553c4f951e15e53991d\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/openwebsolutions.in\/blog\/paytm-payment-integration-ios-swift-language\/\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#\/schema\/person\/bae16b1f4580e553c4f951e15e53991d\",\"name\":\"Avijit Mondal\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/54e392690891b158499cb52642f6cfad?s=96&r=g\",\"caption\":\"Avijit Mondal\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/1663"}],"collection":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/users\/40"}],"replies":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/comments?post=1663"}],"version-history":[{"count":6,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/1663\/revisions"}],"predecessor-version":[{"id":1692,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/1663\/revisions\/1692"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/media\/1669"}],"wp:attachment":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/media?parent=1663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/categories?post=1663"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/tags?post=1663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}