I've downloaded the PayUMoney iOS SDK from the PayUMoney website. I'm now unable to integrate the SDK with my swift project.
-
can you please share the download link where you got only sdk without integration instructions ? – vaibhav Dec 21 '16 at 06:29
-
https://www.payumoney.com/payment-gateway-integration-guide.html This is where i got it – Mahil Arasu Dec 21 '16 at 06:30
-
this PayU SDK doesn't seem to be reliable, go for PayPal SDK, it's very simple to use and the PayPal developer website offers an extensive documentation that helps you implement its SDK in your app. – Frank Eno Dec 21 '16 at 06:31
1 Answers
This answer is taken from PayU documentation itself, i am answering here just because it took me hours to implement with their documentation.
Hi i can guide you with NON seamless integration. https://github.com/payu-intrepos/Documentations/wiki/8.-iOS-SDK-integration#nonseamless
In non seamless integration PayU is already providing UI and will handle the card type and all payment process and at the end you will be notified for the status of your transaction with reason if failed and all details.
Download the SDK from Here:https://github.com/payu-intrepos/iOS-SDK-Sample-App/archive/3.8.1.zip
From Sample code copy file from "BusinessLayer" folder.
So i hope you have all required files now we can go further with integration.
You are integrating PayU with swift, as there is no swift SDK is not present from PayU team we have to proceed with Briding to Objective-C . You can find about this here:How to call Objective-C code from Swift
Once header file is created and configured in build setting, import the following Headers of SDK
#import "PayU_iOS_CoreSDK.h"
#import <CommonCrypto/CommonHMAC.h>
#import "PUUIPaymentOptionVC.h"
#import "PUSAWSManager.h"
#import "PUSAWSManager.h"
#import "PUSAHelperClass.h"
Now we are ready to use PayU SDK into our environment/project.
Create new instance of 3 main object used for payment 1)Payment parameters 2)Hash Values 2)Helperclass// to calculate hash value
paste this above your viewDidLoad()
let paymentParam: PayUModelPaymentParams = PayUModelPaymentParams()
var hashes :PayUModelHashes = PayUModelHashes()
let PUSAhelper:PUSAHelperClass = PUSAHelperClass()
Here is function i have created for further processing
func continueWithCardPayment() {
paymentParam.key = "gtKFFx"
paymentParam.transactionID = "umangtxn123"
paymentParam.amount = "100.0"
paymentParam.productInfo = "Nokia"
paymentParam.SURL = "https://google.com/"
paymentParam.FURL = "https://facebook.com/"
paymentParam.firstName = "Umang"
paymentParam.email = "umangarya336@gmail.com"
paymentParam.environment = ENVIRONMENT_MOBILETEST
paymentParam.udf1 = "udf1"
paymentParam.udf2 = "udf2"
paymentParam.udf3 = "udf3"
paymentParam.udf4 = "udf4"
paymentParam.udf5 = "udf5"
paymentParam.offerKey = "" // Set this property if you want to give offer:
paymentParam.userCredentials = ""
PUSAhelper.generateHashFromServer(self.paymentParam) { (hashes, errorString) in
self.hashes = hashes
self.paymentParam.hashes = hashes
self.callPaymentGateway()
}
}
func callPaymentGateway() {
let webServiceResponse :PayUWebServiceResponse = PayUWebServiceResponse()
webServiceResponse.getPayUPaymentRelatedDetailForMobileSDK(paymentParam) { (paymentDetail, errString, extraParam) in
if errString == nil {
let payOptionVC: PUUIPaymentOptionVC = loadVC("PUUIMainStoryBoard", strVCId: VC_IDENTIFIER_PAYMENT_OPTION) as! PUUIPaymentOptionVC
payOptionVC.paymentParam = self.paymentParam
payOptionVC.paymentRelatedDetail = paymentDetail
runOnMainThread({
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(self.paymentResponseReceived(_:)), name: kPUUINotiPaymentResponse, object: nil)
self.navigationController?.pushViewController(payOptionVC, animated: true)
})
}
else{
print("Failed to proceed for payment : \(errString)")
}
}
}
There are some My custom function that will through error at your side you copy paste, i am mentioning them here. Do take care of them
1)loadVC("PUUIMainStoryBoard", strVCId: VC_IDENTIFIER_PAYMENT_OPTION) //Loadvc function i have created to load view controller, you have to change it as you call your view controller
2)runOnMainThread({ // This function is for running code on main thread.
I have used all test credentials provided by PayU team you can find more in their doc :https://www.payumoney.com/pdf/PayUMoney-Technical-Integration-Document.pdf
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(self.paymentResponseReceived(_:)), name: kPUUINotiPaymentResponse, object: nil)
//With this line we are adding notification sent by payment gateway to notify us regarding the status of the payment process, lets cash the notification.
func paymentResponseReceived(notify:NSNotification) {
print(notify)
}
You will get the response in notify.object. You can find more sophisticated language and way at their document:https://github.com/payu-intrepos/Documentations/wiki/8.-iOS-SDK-integration.
Hope this answer may help you.

- 1
- 1

- 2,988
- 1
- 21
- 43
-
i did try this. I'm getting an error from the bridging header, saying that "file not found" – Mahil Arasu Dec 21 '16 at 06:41
-
it says, "PayU_iOS_CoreSDK.h" file not found in the bridging header – Mahil Arasu Dec 21 '16 at 07:17
-
-
If there is no such file in sdk then download sample project and get file from thr. In terms of payment integration PayU sucks' – Devang Tandel Dec 21 '16 at 07:59
-
I did add all the libraries needed. But then the libraries are not linked. – Mahil Arasu Dec 21 '16 at 14:39
-
-
PUSAhelper.generateHashFromServer giving error: unresolved method name generateHashFromServer in PUSAHelperClass – Krishna Kumar Thakur May 31 '17 at 07:23
-
got the solution Used PUSAhelper.generateHashFromServer() now its working. – Krishna Kumar Thakur May 31 '17 at 07:36
-
1generateHasFromServer , we should not use this method instead ask your backend developer to create one. – Devang Tandel Jun 15 '17 at 06:04
-
-
@Mamta - Payu have now provided SDK for swift. Try that instead. Let me know if you are still facing issue. – Devang Tandel Apr 19 '18 at 10:10
-
@Dev_Tandel thanks for informing! Please could you provide the link here – Mamta Apr 22 '18 at 07:17
-
https://github.com/payu-intrepos/Documentations/wiki/New-Swift-SDK---Seamless – Devang Tandel Apr 24 '18 at 04:20