SlideShare a Scribd company logo
Razorpay Payment Gateway Integration In iOS Swift
Introduction
Razorpay is the fastest growing Payment Solution. Most of the developers prefer Razorpay as the
Payment solution 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 using Xcode 10.1. 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.
Prequisite
1.xcode 10.1
2.Swift 4
3.A Razorpay account (you can signup from here https://dashboard.Razorpay.com/#/access/signup)
4.your Razorpay key id (you can get from here https://dashboard.Razorpay.com/#/app/keys)
Let’s start the development :-
Step 1: Install pod for Razorpay
•Add pod ‘Razorpay-pod’ in the pod file.
•Run ‘pod install’ from terminal.
•Now open the xcworkspace
Step 2: Develop a basic UI as given below.
Step 3: Import Razorpay to your view Controller.
import Razorpay
step 4 :
1.Create action outlet of pay now button in your view controller.
1
2
@IBAction func payNowClicked(_ sender: Any) {
}
2. Create instance reference variable of type Razorpay.
1 private var razorpay:Razorpay?
3. Initialise that reference variable in viewDidLoad method of view controller by calling init method with
public key and delegate.
1
2
3
4
override func viewDidLoad() {
super.viewDidLoad()
razorpay =
Razorpay.initWithKey("rzp_test
_FYCQAsmKTFF8FR",
andDelegate: self)
}
4. Create extension of view controller and confirm RazorpayPaymentCompletionProtocol as given
below :-
a) onPaymentSuccess(_ payment_id: String)
b) onPaymentError(_ code: Int32, description str: String)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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)
alert.addAction(action)
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)
alert.addAction(action)
self.present(alert, animated: true, completion: nil)
}
}
As you can see in above code we have two methods onPaymentSuccess and onPaymentError the
success method will be called if payment transaction is completed successfully where the
onPaymentError will be called if the transaction is not completed successfully. it provides some error
codes as given below :-
Possible values for a failure code are:
•0: Network error
•1: Initialization failure / Unexpected behavior
•2: Payment cancelled by user
Now inside action outlet of pay button create parameter for razor pay like.
1
2
3
4
5
6
7
8
9
10
11
12
13
let options: [String:Any] = [
"amount" : "100"
//mandatory in paise like:-
1000 paise == 10 rs
"description":
"purchase description"
"image": "https://url-
to-image.png",
"name": "business or
product name"
"prefill": [
"contact":
"9797979797",
"email":
"foo@bar.com"
],
"theme": [
"color": "#F37254"
]
]
Progress Bar:
To support theme color in the progress bar, pass HEX color values only.
after setting all parameters call the open method of Razorpay
1 razorpay?.open(options)
Complete Demo Project you can download here :- https://github.com/swiftserieschannel/RazorPayTest

More Related Content

What's hot (20)

Abandoned carts
Abandoned cartsAbandoned carts
Abandoned carts
Netmera
 
Is authorization always needed for sms messages in ringcentral-api
Is authorization always needed for sms messages in ringcentral-apiIs authorization always needed for sms messages in ringcentral-api
Is authorization always needed for sms messages in ringcentral-api
Anirban Sen Chowdhary
 
Payeezy Integration
Payeezy Integration Payeezy Integration
Payeezy Integration
O2b Technologies
 
DealChaser
DealChaserDealChaser
DealChaser
NetSet Software (P) Ltd.
 
SelfConnection
SelfConnectionSelfConnection
SelfConnection
NetSet Software (P) Ltd.
 
Adaptive payments-talk
Adaptive payments-talkAdaptive payments-talk
Adaptive payments-talk
davehawes
 
WAC Network APIs @ OverTheAir 2011
WAC Network APIs @ OverTheAir 2011WAC Network APIs @ OverTheAir 2011
WAC Network APIs @ OverTheAir 2011
Ricardo Varela
 
Mule esb stripe
Mule esb stripeMule esb stripe
Mule esb stripe
D.Rajesh Kumar
 
Droidcon Paris: The new Android SDK
Droidcon Paris: The new Android SDKDroidcon Paris: The new Android SDK
Droidcon Paris: The new Android SDK
PayPal
 
Securing Single-Page Applications with OAuth 2.0
Securing Single-Page Applications with OAuth 2.0Securing Single-Page Applications with OAuth 2.0
Securing Single-Page Applications with OAuth 2.0
Prabath Siriwardena
 
Rest security in mule
Rest security in muleRest security in mule
Rest security in mule
Son Nguyen
 
Introducing safexpay smart NBFC solution
Introducing safexpay smart NBFC solutionIntroducing safexpay smart NBFC solution
Introducing safexpay smart NBFC solution
Neha Sahay
 
Setting up organization with api access
Setting up organization with api accessSetting up organization with api access
Setting up organization with api access
sivachandra mandalapu
 
Deep Dive into OAuth for Connected Apps
Deep Dive into OAuth for Connected AppsDeep Dive into OAuth for Connected Apps
Deep Dive into OAuth for Connected Apps
Salesforce Developers
 
Droidcon DE 2013
Droidcon DE 2013Droidcon DE 2013
Droidcon DE 2013
PayPal
 
Password Replacement Technology : Removing Limitations of Current Passwords
Password Replacement Technology : Removing Limitations of Current PasswordsPassword Replacement Technology : Removing Limitations of Current Passwords
Password Replacement Technology : Removing Limitations of Current Passwords
David Kim
 
What is iam
What is iamWhat is iam
What is iam
Cecile Oracion-Crisologo
 
Securing Insecure
Securing InsecureSecuring Insecure
Securing Insecure
Prabath Siriwardena
 
Applying OAuth on RingCentral API (part 3)
Applying OAuth on RingCentral API (part 3)Applying OAuth on RingCentral API (part 3)
Applying OAuth on RingCentral API (part 3)
Anirban Sen Chowdhary
 
Recharge api by_saurabh_sharma
Recharge api by_saurabh_sharmaRecharge api by_saurabh_sharma
Recharge api by_saurabh_sharma
Saurabh Sharma
 
Abandoned carts
Abandoned cartsAbandoned carts
Abandoned carts
Netmera
 
Is authorization always needed for sms messages in ringcentral-api
Is authorization always needed for sms messages in ringcentral-apiIs authorization always needed for sms messages in ringcentral-api
Is authorization always needed for sms messages in ringcentral-api
Anirban Sen Chowdhary
 
Adaptive payments-talk
Adaptive payments-talkAdaptive payments-talk
Adaptive payments-talk
davehawes
 
WAC Network APIs @ OverTheAir 2011
WAC Network APIs @ OverTheAir 2011WAC Network APIs @ OverTheAir 2011
WAC Network APIs @ OverTheAir 2011
Ricardo Varela
 
Droidcon Paris: The new Android SDK
Droidcon Paris: The new Android SDKDroidcon Paris: The new Android SDK
Droidcon Paris: The new Android SDK
PayPal
 
Securing Single-Page Applications with OAuth 2.0
Securing Single-Page Applications with OAuth 2.0Securing Single-Page Applications with OAuth 2.0
Securing Single-Page Applications with OAuth 2.0
Prabath Siriwardena
 
Rest security in mule
Rest security in muleRest security in mule
Rest security in mule
Son Nguyen
 
Introducing safexpay smart NBFC solution
Introducing safexpay smart NBFC solutionIntroducing safexpay smart NBFC solution
Introducing safexpay smart NBFC solution
Neha Sahay
 
Setting up organization with api access
Setting up organization with api accessSetting up organization with api access
Setting up organization with api access
sivachandra mandalapu
 
Deep Dive into OAuth for Connected Apps
Deep Dive into OAuth for Connected AppsDeep Dive into OAuth for Connected Apps
Deep Dive into OAuth for Connected Apps
Salesforce Developers
 
Droidcon DE 2013
Droidcon DE 2013Droidcon DE 2013
Droidcon DE 2013
PayPal
 
Password Replacement Technology : Removing Limitations of Current Passwords
Password Replacement Technology : Removing Limitations of Current PasswordsPassword Replacement Technology : Removing Limitations of Current Passwords
Password Replacement Technology : Removing Limitations of Current Passwords
David Kim
 
Applying OAuth on RingCentral API (part 3)
Applying OAuth on RingCentral API (part 3)Applying OAuth on RingCentral API (part 3)
Applying OAuth on RingCentral API (part 3)
Anirban Sen Chowdhary
 
Recharge api by_saurabh_sharma
Recharge api by_saurabh_sharmaRecharge api by_saurabh_sharma
Recharge api by_saurabh_sharma
Saurabh Sharma
 

Similar to Razorpay Payment Gateway Integration In iOS Swift (6)

A2Lab - Payment Request API
A2Lab - Payment Request APIA2Lab - Payment Request API
A2Lab - Payment Request API
Juliano Padilha
 
razorpay internship on how they started.ppt
razorpay internship on how they started.pptrazorpay internship on how they started.ppt
razorpay internship on how they started.ppt
RakhulKumaar
 
Paytm integration in swift
Paytm integration in swiftPaytm integration in swift
Paytm integration in swift
InnovationM
 
Braintree and our new v.zero SDK for iOS
Braintree and our new v.zero SDK for iOSBraintree and our new v.zero SDK for iOS
Braintree and our new v.zero SDK for iOS
Alberto López Martín
 
Monetizing with PayPal on Mobile
Monetizing with PayPal on MobileMonetizing with PayPal on Mobile
Monetizing with PayPal on Mobile
PayPalX Developer Network
 
Payment Request API with a React high order component
Payment Request API with a React high order componentPayment Request API with a React high order component
Payment Request API with a React high order component
Marco Lanaro
 
A2Lab - Payment Request API
A2Lab - Payment Request APIA2Lab - Payment Request API
A2Lab - Payment Request API
Juliano Padilha
 
razorpay internship on how they started.ppt
razorpay internship on how they started.pptrazorpay internship on how they started.ppt
razorpay internship on how they started.ppt
RakhulKumaar
 
Paytm integration in swift
Paytm integration in swiftPaytm integration in swift
Paytm integration in swift
InnovationM
 
Braintree and our new v.zero SDK for iOS
Braintree and our new v.zero SDK for iOSBraintree and our new v.zero SDK for iOS
Braintree and our new v.zero SDK for iOS
Alberto López Martín
 
Payment Request API with a React high order component
Payment Request API with a React high order componentPayment Request API with a React high order component
Payment Request API with a React high order component
Marco Lanaro
 

More from InnovationM (20)

How to use data binding in android
How to use data binding in androidHow to use data binding in android
How to use data binding in android
InnovationM
 
Capture image on eye blink
Capture image on eye blinkCapture image on eye blink
Capture image on eye blink
InnovationM
 
Mob x in react
Mob x in reactMob x in react
Mob x in react
InnovationM
 
How to use geolocation in react native apps
How to use geolocation in react native appsHow to use geolocation in react native apps
How to use geolocation in react native apps
InnovationM
 
Android 8 behavior changes
Android 8 behavior changesAndroid 8 behavior changes
Android 8 behavior changes
InnovationM
 
Understanding of react fiber architecture
Understanding of react fiber architectureUnderstanding of react fiber architecture
Understanding of react fiber architecture
InnovationM
 
Automatic reference counting (arc) and memory management in swift
Automatic reference counting (arc) and memory management in swiftAutomatic reference counting (arc) and memory management in swift
Automatic reference counting (arc) and memory management in swift
InnovationM
 
Firebase crashlytics integration in iOS swift (dSYM File Required Problem Res...
Firebase crashlytics integration in iOS swift (dSYM File Required Problem Res...Firebase crashlytics integration in iOS swift (dSYM File Required Problem Res...
Firebase crashlytics integration in iOS swift (dSYM File Required Problem Res...
InnovationM
 
How prototype works in java script?
How prototype works in java script?How prototype works in java script?
How prototype works in java script?
InnovationM
 
React – Let’s “Hook” up
React – Let’s “Hook” upReact – Let’s “Hook” up
React – Let’s “Hook” up
InnovationM
 
Line Messaging API Integration with Spring-Boot
Line Messaging API Integration with Spring-BootLine Messaging API Integration with Spring-Boot
Line Messaging API Integration with Spring-Boot
InnovationM
 
Basic fundamental of ReactJS
Basic fundamental of ReactJSBasic fundamental of ReactJS
Basic fundamental of ReactJS
InnovationM
 
Basic Fundamental of Redux
Basic Fundamental of ReduxBasic Fundamental of Redux
Basic Fundamental of Redux
InnovationM
 
Integration of Highcharts with React ( JavaScript library )
Integration of Highcharts with React ( JavaScript library )Integration of Highcharts with React ( JavaScript library )
Integration of Highcharts with React ( JavaScript library )
InnovationM
 
Serialization & De-serialization in Java
Serialization & De-serialization in JavaSerialization & De-serialization in Java
Serialization & De-serialization in Java
InnovationM
 
Concept of Stream API Java 1.8
Concept of Stream API Java 1.8Concept of Stream API Java 1.8
Concept of Stream API Java 1.8
InnovationM
 
How to Make Each Round of Testing Count?
How to Make Each Round of Testing Count?How to Make Each Round of Testing Count?
How to Make Each Round of Testing Count?
InnovationM
 
Model View Presenter For Android
Model View Presenter For AndroidModel View Presenter For Android
Model View Presenter For Android
InnovationM
 
Retrofit Library In Android
Retrofit Library In AndroidRetrofit Library In Android
Retrofit Library In Android
InnovationM
 
Eventbus Library and How Does it Work?
Eventbus Library and How Does it Work?Eventbus Library and How Does it Work?
Eventbus Library and How Does it Work?
InnovationM
 
How to use data binding in android
How to use data binding in androidHow to use data binding in android
How to use data binding in android
InnovationM
 
Capture image on eye blink
Capture image on eye blinkCapture image on eye blink
Capture image on eye blink
InnovationM
 
How to use geolocation in react native apps
How to use geolocation in react native appsHow to use geolocation in react native apps
How to use geolocation in react native apps
InnovationM
 
Android 8 behavior changes
Android 8 behavior changesAndroid 8 behavior changes
Android 8 behavior changes
InnovationM
 
Understanding of react fiber architecture
Understanding of react fiber architectureUnderstanding of react fiber architecture
Understanding of react fiber architecture
InnovationM
 
Automatic reference counting (arc) and memory management in swift
Automatic reference counting (arc) and memory management in swiftAutomatic reference counting (arc) and memory management in swift
Automatic reference counting (arc) and memory management in swift
InnovationM
 
Firebase crashlytics integration in iOS swift (dSYM File Required Problem Res...
Firebase crashlytics integration in iOS swift (dSYM File Required Problem Res...Firebase crashlytics integration in iOS swift (dSYM File Required Problem Res...
Firebase crashlytics integration in iOS swift (dSYM File Required Problem Res...
InnovationM
 
How prototype works in java script?
How prototype works in java script?How prototype works in java script?
How prototype works in java script?
InnovationM
 
React – Let’s “Hook” up
React – Let’s “Hook” upReact – Let’s “Hook” up
React – Let’s “Hook” up
InnovationM
 
Line Messaging API Integration with Spring-Boot
Line Messaging API Integration with Spring-BootLine Messaging API Integration with Spring-Boot
Line Messaging API Integration with Spring-Boot
InnovationM
 
Basic fundamental of ReactJS
Basic fundamental of ReactJSBasic fundamental of ReactJS
Basic fundamental of ReactJS
InnovationM
 
Basic Fundamental of Redux
Basic Fundamental of ReduxBasic Fundamental of Redux
Basic Fundamental of Redux
InnovationM
 
Integration of Highcharts with React ( JavaScript library )
Integration of Highcharts with React ( JavaScript library )Integration of Highcharts with React ( JavaScript library )
Integration of Highcharts with React ( JavaScript library )
InnovationM
 
Serialization & De-serialization in Java
Serialization & De-serialization in JavaSerialization & De-serialization in Java
Serialization & De-serialization in Java
InnovationM
 
Concept of Stream API Java 1.8
Concept of Stream API Java 1.8Concept of Stream API Java 1.8
Concept of Stream API Java 1.8
InnovationM
 
How to Make Each Round of Testing Count?
How to Make Each Round of Testing Count?How to Make Each Round of Testing Count?
How to Make Each Round of Testing Count?
InnovationM
 
Model View Presenter For Android
Model View Presenter For AndroidModel View Presenter For Android
Model View Presenter For Android
InnovationM
 
Retrofit Library In Android
Retrofit Library In AndroidRetrofit Library In Android
Retrofit Library In Android
InnovationM
 
Eventbus Library and How Does it Work?
Eventbus Library and How Does it Work?Eventbus Library and How Does it Work?
Eventbus Library and How Does it Work?
InnovationM
 

Recently uploaded (20)

Introducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and ARIntroducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and AR
Safe Software
 
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
Jasper Oosterveld
 
Introducing the OSA 3200 SP and OSA 3250 ePRC
Introducing the OSA 3200 SP and OSA 3250 ePRCIntroducing the OSA 3200 SP and OSA 3250 ePRC
Introducing the OSA 3200 SP and OSA 3250 ePRC
Adtran
 
SDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhereSDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhere
Adtran
 
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 ADr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr. Jimmy Schwarzkopf
 
Data Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any ApplicationData Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any Application
Safe Software
 
Cybersecurity Fundamentals: Apprentice - Palo Alto Certificate
Cybersecurity Fundamentals: Apprentice - Palo Alto CertificateCybersecurity Fundamentals: Apprentice - Palo Alto Certificate
Cybersecurity Fundamentals: Apprentice - Palo Alto Certificate
VICTOR MAESTRE RAMIREZ
 
Co-Constructing Explanations for AI Systems using Provenance
Co-Constructing Explanations for AI Systems using ProvenanceCo-Constructing Explanations for AI Systems using Provenance
Co-Constructing Explanations for AI Systems using Provenance
Paul Groth
 
Agentic AI Explained: The Next Frontier of Autonomous Intelligence & Generati...
Agentic AI Explained: The Next Frontier of Autonomous Intelligence & Generati...Agentic AI Explained: The Next Frontier of Autonomous Intelligence & Generati...
Agentic AI Explained: The Next Frontier of Autonomous Intelligence & Generati...
Aaryan Kansari
 
Microsoft Build 2025 takeaways in one presentation
Microsoft Build 2025 takeaways in one presentationMicrosoft Build 2025 takeaways in one presentation
Microsoft Build 2025 takeaways in one presentation
Digitalmara
 
UiPath Community Zurich: Release Management and Build Pipelines
UiPath Community Zurich: Release Management and Build PipelinesUiPath Community Zurich: Release Management and Build Pipelines
UiPath Community Zurich: Release Management and Build Pipelines
UiPathCommunity
 
The case for on-premises AI
The case for on-premises AIThe case for on-premises AI
The case for on-premises AI
Principled Technologies
 
AI Trends - Mary Meeker
AI Trends - Mary MeekerAI Trends - Mary Meeker
AI Trends - Mary Meeker
Razin Mustafiz
 
Measuring Microsoft 365 Copilot and Gen AI Success
Measuring Microsoft 365 Copilot and Gen AI SuccessMeasuring Microsoft 365 Copilot and Gen AI Success
Measuring Microsoft 365 Copilot and Gen AI Success
Nikki Chapple
 
TrustArc Webinar: Mastering Privacy Contracting
TrustArc Webinar: Mastering Privacy ContractingTrustArc Webinar: Mastering Privacy Contracting
TrustArc Webinar: Mastering Privacy Contracting
TrustArc
 
Jira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : IntroductionJira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : Introduction
Ravi Teja
 
Palo Alto Networks Cybersecurity Foundation
Palo Alto Networks Cybersecurity FoundationPalo Alto Networks Cybersecurity Foundation
Palo Alto Networks Cybersecurity Foundation
VICTOR MAESTRE RAMIREZ
 
Grannie’s Journey to Using Healthcare AI Experiences
Grannie’s Journey to Using Healthcare AI ExperiencesGrannie’s Journey to Using Healthcare AI Experiences
Grannie’s Journey to Using Healthcare AI Experiences
Lauren Parr
 
LSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection FunctionLSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection Function
Takahiro Harada
 
Securiport - A Border Security Company
Securiport  -  A Border Security CompanySecuriport  -  A Border Security Company
Securiport - A Border Security Company
Securiport
 
Introducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and ARIntroducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and AR
Safe Software
 
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
Jasper Oosterveld
 
Introducing the OSA 3200 SP and OSA 3250 ePRC
Introducing the OSA 3200 SP and OSA 3250 ePRCIntroducing the OSA 3200 SP and OSA 3250 ePRC
Introducing the OSA 3200 SP and OSA 3250 ePRC
Adtran
 
SDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhereSDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhere
Adtran
 
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 ADr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr. Jimmy Schwarzkopf
 
Data Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any ApplicationData Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any Application
Safe Software
 
Cybersecurity Fundamentals: Apprentice - Palo Alto Certificate
Cybersecurity Fundamentals: Apprentice - Palo Alto CertificateCybersecurity Fundamentals: Apprentice - Palo Alto Certificate
Cybersecurity Fundamentals: Apprentice - Palo Alto Certificate
VICTOR MAESTRE RAMIREZ
 
Co-Constructing Explanations for AI Systems using Provenance
Co-Constructing Explanations for AI Systems using ProvenanceCo-Constructing Explanations for AI Systems using Provenance
Co-Constructing Explanations for AI Systems using Provenance
Paul Groth
 
Agentic AI Explained: The Next Frontier of Autonomous Intelligence & Generati...
Agentic AI Explained: The Next Frontier of Autonomous Intelligence & Generati...Agentic AI Explained: The Next Frontier of Autonomous Intelligence & Generati...
Agentic AI Explained: The Next Frontier of Autonomous Intelligence & Generati...
Aaryan Kansari
 
Microsoft Build 2025 takeaways in one presentation
Microsoft Build 2025 takeaways in one presentationMicrosoft Build 2025 takeaways in one presentation
Microsoft Build 2025 takeaways in one presentation
Digitalmara
 
UiPath Community Zurich: Release Management and Build Pipelines
UiPath Community Zurich: Release Management and Build PipelinesUiPath Community Zurich: Release Management and Build Pipelines
UiPath Community Zurich: Release Management and Build Pipelines
UiPathCommunity
 
AI Trends - Mary Meeker
AI Trends - Mary MeekerAI Trends - Mary Meeker
AI Trends - Mary Meeker
Razin Mustafiz
 
Measuring Microsoft 365 Copilot and Gen AI Success
Measuring Microsoft 365 Copilot and Gen AI SuccessMeasuring Microsoft 365 Copilot and Gen AI Success
Measuring Microsoft 365 Copilot and Gen AI Success
Nikki Chapple
 
TrustArc Webinar: Mastering Privacy Contracting
TrustArc Webinar: Mastering Privacy ContractingTrustArc Webinar: Mastering Privacy Contracting
TrustArc Webinar: Mastering Privacy Contracting
TrustArc
 
Jira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : IntroductionJira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : Introduction
Ravi Teja
 
Palo Alto Networks Cybersecurity Foundation
Palo Alto Networks Cybersecurity FoundationPalo Alto Networks Cybersecurity Foundation
Palo Alto Networks Cybersecurity Foundation
VICTOR MAESTRE RAMIREZ
 
Grannie’s Journey to Using Healthcare AI Experiences
Grannie’s Journey to Using Healthcare AI ExperiencesGrannie’s Journey to Using Healthcare AI Experiences
Grannie’s Journey to Using Healthcare AI Experiences
Lauren Parr
 
LSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection FunctionLSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection Function
Takahiro Harada
 
Securiport - A Border Security Company
Securiport  -  A Border Security CompanySecuriport  -  A Border Security Company
Securiport - A Border Security Company
Securiport
 

Razorpay Payment Gateway Integration In iOS Swift

  • 1. Razorpay Payment Gateway Integration In iOS Swift Introduction Razorpay is the fastest growing Payment Solution. Most of the developers prefer Razorpay as the Payment solution 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 using Xcode 10.1. 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. Prequisite 1.xcode 10.1 2.Swift 4 3.A Razorpay account (you can signup from here https://dashboard.Razorpay.com/#/access/signup) 4.your Razorpay key id (you can get from here https://dashboard.Razorpay.com/#/app/keys) Let’s start the development :- Step 1: Install pod for Razorpay •Add pod ‘Razorpay-pod’ in the pod file. •Run ‘pod install’ from terminal. •Now open the xcworkspace
  • 2. Step 2: Develop a basic UI as given below. Step 3: Import Razorpay to your view Controller. import Razorpay step 4 : 1.Create action outlet of pay now button in your view controller. 1 2 @IBAction func payNowClicked(_ sender: Any) { } 2. Create instance reference variable of type Razorpay. 1 private var razorpay:Razorpay? 3. Initialise that reference variable in viewDidLoad method of view controller by calling init method with public key and delegate. 1 2 3 4 override func viewDidLoad() { super.viewDidLoad() razorpay = Razorpay.initWithKey("rzp_test _FYCQAsmKTFF8FR", andDelegate: self) } 4. Create extension of view controller and confirm RazorpayPaymentCompletionProtocol as given below :- a) onPaymentSuccess(_ payment_id: String) b) onPaymentError(_ code: Int32, description str: String)
  • 3. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 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) alert.addAction(action) 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) alert.addAction(action) self.present(alert, animated: true, completion: nil) } } As you can see in above code we have two methods onPaymentSuccess and onPaymentError the success method will be called if payment transaction is completed successfully where the onPaymentError will be called if the transaction is not completed successfully. it provides some error codes as given below :- Possible values for a failure code are: •0: Network error •1: Initialization failure / Unexpected behavior •2: Payment cancelled by user Now inside action outlet of pay button create parameter for razor pay like.
  • 4. 1 2 3 4 5 6 7 8 9 10 11 12 13 let options: [String:Any] = [ "amount" : "100" //mandatory in paise like:- 1000 paise == 10 rs "description": "purchase description" "image": "https://url- to-image.png", "name": "business or product name" "prefill": [ "contact": "9797979797", "email": "[email protected]" ], "theme": [ "color": "#F37254" ] ] Progress Bar: To support theme color in the progress bar, pass HEX color values only. after setting all parameters call the open method of Razorpay 1 razorpay?.open(options) Complete Demo Project you can download here :- https://github.com/swiftserieschannel/RazorPayTest