gpt4 book ai didi

ios - 如何在 swift 中集成 PayU Money

转载 作者:搜寻专家 更新时间:2023-11-01 07:17:58 26 4
gpt4 key购买 nike

我是 swift 的新手 任何人都可以帮助我在 swift 中集成 PayU Money ....我正在使用这个 sdk:https://github.com/payu-intrepos/Documentations/wiki/8.1-NEW-iOS-Seamless-SDK-integration

最佳答案

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

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

在非无缝集成中,PayU 已经提供了 UI 并将处理卡类型和所有支付流程,最后您将收到有关交易状态的通知,如果失败则说明原因和所有详细信息。

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

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

所以我希望您现在拥有所有必需的文件,我们可以进一步进行集成。

您正在将 PayU 与 swift 集成,因为 PayU 团队不提供 swift SDK,我们必须继续 Briding to Objective-C 。您可以在这里找到相关信息:How to call Objective-C code from Swift

在build设置中创建并配置头文件后,导入以下 SDK 头文件

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

现在我们已准备好在我们的环境/项目中使用 PayU SDK。

创建用于支付的 3 个主要对象的新实例1)支付参数2)哈希值2)Helperclass//计算hash值

将此粘贴​​到您的 viewDidLoad() 上方

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

这是我为进一步处理而创建的函数

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

有一些我的自定义函数会在您复制粘贴时通过错误,我在这里提到它们。照顾好他们

1)loadVC("PUUIMainStoryBoard", strVCId: VC_IDENTIFIER_PAYMENT_OPTION)//我创建的加载 View Controller 的 Loadvc 函数,您必须在调用 View Controller 时更改它

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

我已经使用了 PayU 团队提供的所有测试凭据你可以在他们的文档中找到更多信息: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 中获得响应。您可以在他们的文档中找到更复杂的语言和方式:https://github.com/payu-intrepos/Documentations/wiki/8.-iOS-SDK-integration .

希望这个回答能帮到你。

关于ios - 如何在 swift 中集成 PayU Money,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40885632/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com