func genrateOTPValu(getRandomMerchant:String,getName:String,getTotal:String,getProductType:String){
createSignatureForGenrateOTP =
"sportEyeByAbouElgoukhaccess_code=hRRVGXrIpHSYoH19Ebwtamount=\(getTotal)currency=EGPlanguage=enmerchant_identifier=e54638ebmerchant_order_id=\(getRandomMerchant)merchant_reference=\(getRandomMerchant)payment_option=VALUphone_number=01008606003products=[{product_name=\(getName.replacingOccurrences(of: " ", with: "")), product_price=\(getTotal), product_category=\(getProductType)}]service_command=OTP_GENERATEsportEyeByAbouElgoukh"
base64Str = createSignatureForGenrateOTP!.sha256()
let params =
[
"merchant_reference":getRandomMerchant,
"merchant_identifier":"e54638eb",
"access_code":"hRRVGXrIpHSYoH19Ebwt",
"signature": base64Str!,
"service_command":"OTP_GENERATE",
"language":"en",
"payment_option":"VALU",
"phone_number":"01008606003",
"merchant_order_id":getRandomMerchant,
"amount":getTotal,
"currency":"EGP",
"products":[
[
"product_name": getName,
"product_price": getTotal,
"product_category":getProductType,
]
]
] as [String : Any]
Alamofire.request(URLAPi.URL_Payment_Api , method : .post , parameters : params , encoding: JSONEncoding.default ).responseJSON { (response) in
debugPrint(response)
if response.result.isSuccess {
//
let jsonpayfortrequest : JSON = JSON(response.result.value!)
let passobjectforrootclasspayfort = OTPGenrateModel(fromJson: jsonpayfortrequest)
print(passobjectforrootclasspayfort.transaction_id!)
if !passobjectforrootclasspayfort.transaction_id!.isEmpty {
self.verifyOTP(getTotal: getTotal, getRandom: getRandomMerchant, getTransaction: passobjectforrootclasspayfort.transaction_id!)
}
SVProgressHUD.dismiss()
} else {
print("error connection")
SVProgressHUD.dismiss()
}
}
}
产品列表中的问题,因为必须这样显示产品列表才能成功创建签名[“ product:name”:值,“ product_price”:值,“ product_category”:值]