我已经检查了所有教程,并且在网关集成方面也做了很多研发。
但是没有找到整合Paytm付款网关的方法。
func paymentConfiguration()
{
var orderDict = [AnyHashable: Any]()
orderDict["MID"] = "WorldP64425807474247"
orderDict["CHANNEL_ID"] = "WAP"
orderDict["INDUSTRY_TYPE_ID"] = "Retail"
orderDict["WEBSITE"] = "worldpressplg"
orderDict["TXN_AMOUNT"] = "1"
orderDict["ORDER_ID"] = ViewController.generateOrderID(withPrefix: "")
orderDict["CALLBACK_URL"] = "https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=<ORDER_ID>"
orderDict["CHECKSUMHASH"] = "w2QDRMgp1/BNdEnJEAPCIOmNgQvsi+BhpqijfM9KvFfRiPmGSt3Ddzw+oTaGCLneJwxFFq5mqTMwJXdQE2EzK4px2xruDqKZjHupz9yXev4="
orderDict["REQUEST_TYPE"] = "DEFAULT"
orderDict["CUST_ID"] = "1234567890"
var order = PGOrder(params: orderDict)
}
func openPaytmController()
{
PGServerEnvironment.selectServerDialog(view, completionHandler: {(_ type: ServerType) -> Void in
var txnController = PGTransactionViewController.initTransaction(forOrder: order)
if type != eServerTypeNone {
txnController.serverType = type
txnController.merchant = mc
txnController.delegate = self
self.show(txnController)
}
})
}
任何帮助将不胜感激。
提前致谢
最佳答案
**
PayTM整合快速细节
**
##下载paytm sdk ##
https://github.com/Paytm-Payments/Paytm_iOS_App_Kit
确保在“链接的二进制文件和框架”中添加了动态库和systemConfiguration.framwork。
将桥接头文件添加到项目中
#import "PaymentsSDK.h"
您必须生成CheckSumHash密钥-PayTm唯一密钥以进行交易
传递以下参数以生成checkSumHash
let params:[String: Any] = [
"CUST_ID”:<Your Customer ID>, // you have to generate unique customer ID (Generate random string - less than 50 length count )
"TXN_AMOUNT":"10.00", // sample amount
“MID": <Your merchant ID>,
"ORDER_ID”:<Your Order ID>, // you have to generate unique order ID (Generate random string - less than 50 length count )
"INDUSTRY_TYPE_ID":"Retail", //Staging Environment
"CHANNEL_ID":"WAP", //Staging Environment
"WEBSITE":"APPSTAGING", //Staging Environment - Mobile
"CALLBACK_URL":"https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=\(<Your Order ID>)” // This should be important one and make sure the correct order ID.
]
在您的服务器中,您必须设置文件,该文件应根据给定的参数和商家密钥(该文件存储在其中;请勿在您的应用内部使用)生成CheckSumHash密钥。那应该是您的CHECKSUM URL以及上述参数。最后,我们在响应中获得CheckSumHash
您必须提供上述参数以及checkSumHash(您已获得响应-请参阅:步骤3)以模仿PGTransactionViewCOntroller
let params:[String: Any] = [
"CUST_ID”:<Your Customer ID>, // you have to generate unique customer ID (Generate random string - less than 50 length count )
"TXN_AMOUNT":"10.00", // sample amount
“MID": <Your merchant ID>,
"ORDER_ID”:<Your Order ID>, // you have to generate unique order ID (Generate random string - less than 50 length count )
"INDUSTRY_TYPE_ID":"Retail", //Staging Environment
"CHANNEL_ID":"WAP", //Staging Environment
"WEBSITE":"APPSTAGING", //Staging Environment - Mobile
"CALLBACK_URL":"https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=\(<Your Order ID>)” // This should be important one and make sure the correct order ID. ,“CHECKSUMHASH”:<your geenrated CheckSumHash key> // which you got the response of generate CheckSumHash
]
let order = PGOrder(params: params)
let txnController = PGTransactionViewController(transactionFor: order)
txnController?.serverType = eServerTypeStaging
txnController?.merchant = PGMerchantConfiguration.default()
txnController?.merchant.checksumGenerationURL = CheckSumGenerationURL
txnController?.merchant.merchantID = "FlotaS90100524961231"
txnController?.merchant.checksumValidationURL = CheckSumVerifyURL + orderID
txnController?.loggingEnabled = true
txnController?.merchant.website = "APPSTAGING"
txnController?.merchant.industryID = "Retail"
txnController?.serverType = eServerTypeStaging
txnController?.delegate = self
self.navigationController?.pushViewController(txnController!, animated: true)
PayTM代表处理回应
func didSucceedTransaction(controller: PGTransactionViewController, response: [NSObject : AnyObject]) {
print(response)
}
func didFinishedResponse(_ controller: PGTransactionViewController!, response responseString: String!) {
print(responseString) // Response will be in string
let data = responseString.data(using: .utf8)!
let obj = JSON(data: data)
if obj["STATUS"].stringValue != "TXN_SUCCESS" {
//handle what you want
}
}
}
func didFailTransaction(_ controller: PGTransactionViewController!, error: Error!, response: [AnyHashable : Any]!) {
print(error)
}
func didCancelTrasaction(_ controller: PGTransactionViewController!) {
print("User camcelled the trasaction")
controller.navigationController?.popViewController(animated: true)
}
func errorMisssingParameter(_ controller: PGTransactionViewController!, error: Error!) {
print(error.localizedDescription)
controller.navigationController?.popViewController(animated: true)
}
关于ios - 如何在Swift中集成Paytm付款网关,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49147837/