Skip to main content

Razorpay Payment Integration In iOS Swift

Gets Easier & Fastest growing Payment Solution, Accepting International Payments with Razorpay

Most of the developers prefer Razorpay as the international payments solution with supported Multi-currency support and reduced chargebacks in India. It is robust and provides developer friendly API & SDK for Android, iOS etc. It provides different modes of payments like :- credit card, debit card, net banking, UPI and other popular wallets. It provide the fast and reliable support.

In this blog we are going to focus on Razor Pay integration with iOS swift 4.2 using Xcode 11. in which we will learn how can we integrate Razorpay with iOS app. We will create a demo app to integrate Razorpay and pay some amount by using Razorpay payment gateway.

  1. xcode 11
  2. Swift 4.2
  3. A Razorpay account (you can signup from here
Razorpay SignUp

  1. your Razorpay key id (you can get from here
customised payment pages

Development in Xcode

1. Open Terminal then go to project base.
2. open podfile
3. edit podfile add -  pod ‘Razorpay-pod’ 

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'WithMe' do
  # Comment the next line if you don't want to use dynamic frameworks

  # Pods for WithMe
  pod 'razorpay-pod'

  target 'WithMeTests' do
    inherit! :search_paths
    # Pods for testing

  target 'WithMeUITests' do
    # Pods for testing


4. Then pod Install
5 Reopen Project in xcode.

Develope a basic UI as given below. 

import Razorpay

class ViewController: UIViewController{
    // Razorpay
    var braintreeClient: BTAPIClient?
    var razoepay: RazorpayCheckout!
    override func viewDidLoad() {
        razoepay = RazorpayCheckout.initWithKey("rzp_test_FtNotNSVCQRKJU", andDelegate: self)
    @IBAction func checkOut(_ sender: Any) {
        let options: [String:Any] = [
            "amount" : "1000", //mandatory in paise like:- 1000 paise ==  10 rs
            "currency": "INR",
            "description": "purchase description",
            "image": "logo",
            "name": "Swift Series",
            "prefill": [
            "contact": "9797979797",
            "email": ""
            "theme": [
                "color": "#528FF0"

extension ViewController: RazorpayPaymentCompletionProtocol {
    func onPaymentSuccess(_ payment_id: String) {
        let alert = UIAlertController(title: "Paid", message: "Payment Success", preferredStyle: .alert)
        let action = UIAlertAction(title: "OK", style: .cancel, handler: nil)
        self.present(alert, animated: true, completion: nil)
    func onPaymentError(_ code: Int32, description str: String) {
        let alert = UIAlertController(title: "Error", message: "\(code)\n\(str)", preferredStyle: .alert)
        let action = UIAlertAction(title: "OK", style: .cancel, handler: nil)
        self.present(alert, animated: true, completion: nil)

Output. Like

Razorpay Payment Integration In iOS Swift


Post a Comment

Popular posts from this blog

Add a Scene Delegate to your existing project with Storyboard in Swift

To add a scene delegate, first, create a new Swift file that you’ll call "SceneDelegate" containing a subclass of UIResponder, just like the AppDelegate, and that conforms to UIWindowSceneDelegate.  As your app might supports other versions than iOS 13, make this class only available for iOS 13. This is what you should have : If you are working a project that is storyboard based, please set storyboard  initial view controller SceneDelegate.swift import UIKit @available ( iOS 13.0 , *) class SceneDelegate : UIResponder , UIWindowSceneDelegate {     var window : UIWindow ?     func scene ( _ scene: UIScene , willConnectTo session: UISceneSession , options connectionOptions: UIScene . ConnectionOptions ) {                  let storyboard = UIStoryboard (name: "Main" , bundle: nil )         let initialViewController = storyboard. instantiateViewController (withIdentifier: "ViewController" )         let mainNavigationController = UINavigationControlle

How Create Animated Circle Progress Bar iOS 11 Swift 4

  Animated Circle Progress Bar iOS 11 Swift 4 With MBCircularProgressBa r - A circular, animatable & highly customizable progress bar from the Interface Builder Swift, Using pod fite MBCircularProgressBar Installation Cocoapods terminal. pod "MBCircularProgressBar" That - A Simple Steps to installed pod file -        Open terminal        Command on terminal go to project folder Cd path        set your project path on terminal.        command : pod init        open pod file - open -e podfile        added in pod file with in : pod "MBCircularProgressBar"        Command : Pod install        Close project of Xcode        open your Project from terminals        Command : open PodDemos.xcworkspace After opern StoryBoard and Now drag a UIView over the viewController in storyboard Or set UIView Constraint width, height or verticle or horzentail space and set a class MBCircul

How to Use Multiple Sections in UITableView iOS Swift !

Multiple sections in UITableView iOS Swift. UITableView is very important part of iOS ecosystem. So we split tableviews in sections. Then its easier to find right information.  1. First let’s create a project as usual. Create a new single view application X code project. Set project name to UIViewController.  2. Go to main storyboard & select view controller & use UITableView 3. Select tableview & make it initial view controller  4 Create a custom Sections Class like Name => TableSections, create register cell static return “ getCellNibs ” method. Then create  4 section enum “TableItems” then after append all sections to an array model. import UIKit struct CellNib {      static func getCellNibs () -> [ String ] {          return [ "Cell1" , "Cell2" , "Cell3" , "Cell4" ]     } } enum TableItems : Int {      case TableSections1      case TableSections2      case TableSections3      case TableSections4 } class TableSec