I'm currently doing one app for that app I need to integrate payment gate way but don't know how to implement payu money in my app, from two days i'm just reading tutorials but still didn't get any solution I'm new to swift if any help it would be Awesome.
Asked
Active
Viewed 6,130 times
-3
-
Which payment gateway you want to integrate mention you some code and explanation – Bhupat Bheda May 03 '17 at 07:16
-
http://stackoverflow.com/questions/33908484/payu-money-gateway-ios-swift – Bista May 03 '17 at 07:20
-
Refer this answer to integrate PayU in iOS with Swift. https://stackoverflow.com/a/47234959/4201458 – Chaudhary Ankit Deshwal Nov 11 '17 at 06:19
3 Answers
2
https://www.payumoney.com/payment-gateway-integration-guide.html check this one, they added iOS sdk for Swift and objective c in payU money I hope its helpful for u.

santoshi
- 380
- 2
- 13
1
There is SDK and Example provided by PayU for swift at https://codeload.github.com/payu-intrepos/PayUMoney-IOS-SDK/zip/master
If you want to integrate payU then you have to make bridge to use the SDK.
Here is my answer for Swift 2.3, : https://stackoverflow.com/a/41256507/3548469
You will easily able to convert in swift 3.0.

Community
- 1
- 1

Devang Tandel
- 2,988
- 1
- 21
- 43
-
Hi dev My friend said use Stripe framework its better to integrate is this better way to implement – sam May 03 '17 at 07:34
-
Hi Sam, You can use stripe , stripe is way easy and convenient to use when comparing to integration. If you payu is not compulsory then you should opt for stripe. – Devang Tandel May 03 '17 at 07:52
-
if pay u is not compulsory then you may go for stripe it totally upto you. – Devang Tandel May 03 '17 at 07:53
-
you asked you tried to integrate pay u money so answered solution for it. – Devang Tandel May 03 '17 at 07:54
-
-
https://comparisons.financesonline.com/stripe-vs-payu here is the comparison between both – Devang Tandel May 03 '17 at 08:58
-
-
https://www.payumoney.com/payment-gateway-integration-guide.html I seen here some iOS sdk for swift at the down – sam May 03 '17 at 09:07
-
1
This is helped me
import UIKit
var merchantKey = "your live merchant key"
var salt = "your live merchant salt"
var PayUBaseUrl = "https://secure.payu.in"
class PaymentScreen: UIViewController,UIWebViewDelegate {
@IBOutlet weak var myWebView: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
self.payPayment()
}
func payPayment() {
var i = arc4random()
let amount = "1"
let productInfo = "product"
let firstName = "SampleName"
let email = "xxx@gmail.com"
let phone = "9876543210"
let sUrl = "https://www.google.com"
let fUrl = "https://www.bing.com"
let service_provider = "payu_paisa"
let strHash:String = self.sha1(String.localizedStringWithFormat("%d%@", i, NSDate()))
let rangeOfHello = Range(start: strHash.startIndex,
end: strHash.startIndex.advancedBy(20))
let txnid1 = strHash.substringWithRange(rangeOfHello)
let hashValue = String.localizedStringWithFormat("%@|%@|%@|%@|%@|%@|||||||||||%@",merchantKey,txnid1,amount,productInfo,firstName,email,salt)
let hash=self.sha1(hashValue)
let postStr = "txnid="+txnid1+"&key="+merchantKey+"&amount="+amount+"&productinfo="+productInfo+"&firstname="+firstName+"&email="+email+"&phone="+phone+"&surl="+sUrl+"&furl="+fUrl+"&hash="+hash+"&service_provider="+service_provider
let url = NSURL(string: String.localizedStringWithFormat("%@/_payment", PayUBaseUrl))
print("check my url", url, postStr)
let request = NSMutableURLRequest(URL: url!)
do {
let postLength = String.localizedStringWithFormat("%lu",postStr.characters.count)
request.HTTPMethod = "POST"
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Current-Type")
request.setValue(postLength, forHTTPHeaderField: "Content-Length")
request.HTTPBody = postStr.dataUsingEncoding(NSUTF8StringEncoding)
myWebView.loadRequest(request)
} catch {
}
}
func webViewDidStartLoad(webView: UIWebView) {
}
func webViewDidFinishLoad(webView: UIWebView) {
let requestURL = self.myWebView.request?.URL
let requestString:String = (requestURL?.absoluteString)!
if requestString.containsString("https://www.google.com") {
print("success payment done")
}
else if requestString.containsString("https://www.bing.com") {
print("payment failure")
}
}
func webView(webView: UIWebView, didFailLoadWithError error: NSError?) {
print("double failure")
}
func sha1(toEncrypt:String) -> String {
let data = toEncrypt.dataUsingEncoding(NSUTF8StringEncoding)!
var digest = [UInt8](count:Int(CC_SHA512_DIGEST_LENGTH), repeatedValue: 0)
CC_SHA512(data.bytes, CC_LONG(data.length), &digest)
let hexBytes = digest.map { String(format: "%02x", $0) }
return hexBytes.joinWithSeparator("")
}
}

Anurag Mishra
- 109
- 1
- 9