如何快速整合PayU Money

我是新的迅速任何人都可以帮助我整合PayU钱在迅速….我使用这个SDK: https : //github.com/payu-intrepos/Documentations/wiki/8.1-NEW-iOS-Seamless -SDK整合

这个答案是从PayU文档本身取得的,我在这里回答是因为花了我几个小时来实现他们的文档。

嗨,我可以指导你与非无缝集成。 https://github.com/payu-intrepos/Documentations/wiki/8.-iOS-SDK-integration#nonseamless

在非无缝整合PayU已经提供用户界面,并将处理卡的types和所有支付过程,最后你将被通知你的交易状态,如果失败的原因和所有细节。

从这里下载SDK: https : //github.com/payu-intrepos/iOS-SDK-Sample-App/archive/3.8.1.zip

从“BusinessLayer”文件夹中的示例代码复制文件。

所以我希望你现在有了所有需要的文件,我们可以进一步整合。

您正在将PayU与Swift集成,因为PayU团队中没有快速的SDK,所以我们必须继续对Objective-C进行Briding。 你可以在这里find这个: 如何从Swift中调用Objective-C代码

一旦在构build设置中创build并configuration了头文件,请导入SDK的以下头文件

#import "PayU_iOS_CoreSDK.h" #import <CommonCrypto/CommonHMAC.h> #import "PUUIPaymentOptionVC.h" #import "PUSAWSManager.h" #import "PUSAWSManager.h" #import "PUSAHelperClass.h" 

现在我们准备使用PayU SDK进入我们的环境/项目。

创build用于支付的3主要对象的新实例1)支付参数2)哈希值2)帮助类//计算哈希值

粘贴在你的viewDidLoad()上面

 let paymentParam: PayUModelPaymentParams = PayUModelPaymentParams() var hashes :PayUModelHashes = PayUModelHashes() let PUSAhelper:PUSAHelperClass = PUSAHelperClass() 

这是我为进一步处理创build的function

 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)") } } } 

有一些我的自定义function,将通过错误在你身边复制粘贴,我在这里提到他们。 请照顾他们

1)loadVC(“PUUIMainStoryBoard”,strVCId:VC_IDENTIFIER_PAYMENT_OPTION)// Loadvc函数我已经创build加载视图控制器,你必须改变它,你调用你的视图控制器

2)runOnMainThread({//此函数用于在主线程上运行代码。

我已经使用了PayU团队提供的所有testing凭据,您可以在他们的文档中find更多信息: https ://www.payumoney.com/pdf/PayUMoney-Technical-Integration-Document.pdf

 NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(self.paymentResponseReceived(_:)), name: kPUUINotiPaymentResponse, object: nil) 

//通过这一行,我们添加了支付网关发送的通知,通知我们有关付款过程的状态,让我们兑现通知。

 func paymentResponseReceived(notify:NSNotification) { print(notify) } 

你会在notify.object中得到响应。 您可以在他们的文档中find更复杂的语言和方式: https : //github.com/payu-intrepos/Documentations/wiki/8.-iOS-SDK-integration 。

希望这个答案可以帮助你。