SlideShare une entreprise Scribd logo
1  sur  4
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

Recharge api by_saurabh_sharma
Recharge api by_saurabh_sharmaRecharge api by_saurabh_sharma
Recharge api by_saurabh_sharma
Saurabh Sharma
 

Tendances (20)

Abandoned carts
Abandoned cartsAbandoned carts
Abandoned carts
 
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
 
Payeezy Integration
Payeezy Integration Payeezy Integration
Payeezy Integration
 
DealChaser
DealChaserDealChaser
DealChaser
 
SelfConnection
SelfConnectionSelfConnection
SelfConnection
 
Adaptive payments-talk
Adaptive payments-talkAdaptive payments-talk
Adaptive payments-talk
 
WAC Network APIs @ OverTheAir 2011
WAC Network APIs @ OverTheAir 2011WAC Network APIs @ OverTheAir 2011
WAC Network APIs @ OverTheAir 2011
 
Mule esb stripe
Mule esb stripeMule esb stripe
Mule esb stripe
 
Droidcon Paris: The new Android SDK
Droidcon Paris: The new Android SDKDroidcon Paris: The new Android SDK
Droidcon Paris: The new Android SDK
 
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
 
Rest security in mule
Rest security in muleRest security in mule
Rest security in mule
 
Introducing safexpay smart NBFC solution
Introducing safexpay smart NBFC solutionIntroducing safexpay smart NBFC solution
Introducing safexpay smart NBFC solution
 
Setting up organization with api access
Setting up organization with api accessSetting up organization with api access
Setting up organization with api access
 
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
 
Droidcon DE 2013
Droidcon DE 2013Droidcon DE 2013
Droidcon DE 2013
 
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
 
What is iam
What is iamWhat is iam
What is iam
 
Securing Insecure
Securing InsecureSecuring Insecure
Securing Insecure
 
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)
 
Recharge api by_saurabh_sharma
Recharge api by_saurabh_sharmaRecharge api by_saurabh_sharma
Recharge api by_saurabh_sharma
 

Similaire à Razorpay Payment Gateway Integration In iOS Swift

java and javascript api dev guide
java and javascript api dev guidejava and javascript api dev guide
java and javascript api dev guide
Zenita Smythe
 

Similaire à Razorpay Payment Gateway Integration In iOS Swift (20)

Learn how to use API with 2 API examples.pdf
Learn how to use API with 2 API examples.pdfLearn how to use API with 2 API examples.pdf
Learn how to use API with 2 API examples.pdf
 
java and javascript api dev guide
java and javascript api dev guidejava and javascript api dev guide
java and javascript api dev guide
 
Advanced iOS Debbuging (Reloaded)
Advanced iOS Debbuging (Reloaded)Advanced iOS Debbuging (Reloaded)
Advanced iOS Debbuging (Reloaded)
 
End to end todo list app with NestJs - Angular - Redux & Redux Saga
End to end todo list app with NestJs - Angular - Redux & Redux SagaEnd to end todo list app with NestJs - Angular - Redux & Redux Saga
End to end todo list app with NestJs - Angular - Redux & Redux Saga
 
Chaincode Use Cases
Chaincode Use Cases Chaincode Use Cases
Chaincode Use Cases
 
Integrating WordPress With Web APIs
Integrating WordPress With Web APIsIntegrating WordPress With Web APIs
Integrating WordPress With Web APIs
 
Building Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in RailsBuilding Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in Rails
 
Telerik AppBuilder Presentation for TelerikNEXT Conference
Telerik AppBuilder Presentation for TelerikNEXT ConferenceTelerik AppBuilder Presentation for TelerikNEXT Conference
Telerik AppBuilder Presentation for TelerikNEXT Conference
 
android level 3
android level 3android level 3
android level 3
 
Paytm integration in swift
Paytm integration in swiftPaytm integration in swift
Paytm integration in swift
 
How to build twitter bot using golang from scratch
How to build twitter bot using golang from scratchHow to build twitter bot using golang from scratch
How to build twitter bot using golang from scratch
 
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
 
Introduction to aop
Introduction to aopIntroduction to aop
Introduction to aop
 
Micro services from scratch - Part 1
Micro services from scratch - Part 1Micro services from scratch - Part 1
Micro services from scratch - Part 1
 
How to integrate paytm payment gateway using react js in seven easy steps
How to integrate paytm payment gateway using react js in seven easy stepsHow to integrate paytm payment gateway using react js in seven easy steps
How to integrate paytm payment gateway using react js in seven easy steps
 
Demystifying Apple 'Pie' & TouchID
Demystifying Apple 'Pie' & TouchIDDemystifying Apple 'Pie' & TouchID
Demystifying Apple 'Pie' & TouchID
 
Mobile Open Day: React Native: Crossplatform fast dive
Mobile Open Day: React Native: Crossplatform fast diveMobile Open Day: React Native: Crossplatform fast dive
Mobile Open Day: React Native: Crossplatform fast dive
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
 
Building a dashboard using AngularJS
Building a dashboard using AngularJSBuilding a dashboard using AngularJS
Building a dashboard using AngularJS
 
Android Workshop
Android WorkshopAndroid Workshop
Android Workshop
 

Plus de InnovationM

Plus de 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
 
Capture image on eye blink
Capture image on eye blinkCapture image on eye blink
Capture image on eye blink
 
Mob x in react
Mob x in reactMob x in react
Mob x in react
 
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
 
Android 8 behavior changes
Android 8 behavior changesAndroid 8 behavior changes
Android 8 behavior changes
 
Understanding of react fiber architecture
Understanding of react fiber architectureUnderstanding of react fiber architecture
Understanding of react fiber architecture
 
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
 
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...
 
How prototype works in java script?
How prototype works in java script?How prototype works in java script?
How prototype works in java script?
 
React – Let’s “Hook” up
React – Let’s “Hook” upReact – Let’s “Hook” up
React – Let’s “Hook” up
 
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
 
Basic fundamental of ReactJS
Basic fundamental of ReactJSBasic fundamental of ReactJS
Basic fundamental of ReactJS
 
Basic Fundamental of Redux
Basic Fundamental of ReduxBasic Fundamental of Redux
Basic Fundamental of Redux
 
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 )
 
Serialization & De-serialization in Java
Serialization & De-serialization in JavaSerialization & De-serialization in Java
Serialization & De-serialization in Java
 
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
 
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?
 
Model View Presenter For Android
Model View Presenter For AndroidModel View Presenter For Android
Model View Presenter For Android
 
Retrofit Library In Android
Retrofit Library In AndroidRetrofit Library In Android
Retrofit Library In Android
 
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?
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

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": "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