先定义一个Order的数据模型(也就是NSObject)
func AliplayFunc(){
var Orders = Order()
Orders.partner = partner
Orders.seller = seller
Orders.productName = "商品名称"
Orders.productDescription = "商品描述"
Orders.amount = NSString(format: "%.2f",TicketTotalprice) as String (价格必须小数点两位)
Orders.tradeNO = "订单号,不能有特殊字符"
Orders.notifyURL = "支付宝支付成功的请求地址(也就是你站点接收支付宝的请求信号的地址)"
Orders.service = "mobile.securitypay.pay";
Orders.paymentType = "1";
Orders.inputCharset = "utf-8";
Orders.itBPay = "30m";
Orders.showUrl = "m.alipay.com";
var appScheme = "manzhanmiao"
var orderSpec = Orders.description
var signer = CreateRSADataSigner(privateKey)
var signedString = signer.signString(orderSpec)
var orderString = "\(orderSpec)&sign=\"\(signedString)\"&sign_type=\"RSA\""
AlipaySDK.defaultService().payOrder(orderString, fromScheme: appScheme, callback: { (resultDic) -> Void in
println("reslut = \(resultDic)")
if let Alipayjson = resultDic as? NSDictionary{
let resultStatus = Alipayjson.valueForKey("resultStatus") as! String
if resultStatus == "9000"{
self.AlipayinfoFunc("\(self.tradeNo)", trade_no: "\(self.tradeNo)", trade_status: resultStatus)
}else if resultStatus == "8000" {
self.infoNotice("正在处理中")
self.navigationController?.popViewControllerAnimated(true)
}else if resultStatus == "4000" {
self.infoNotice("订单支付失败")
self.navigationController?.popViewControllerAnimated(true)
}else if resultStatus == "6001" {
self.infoNotice("用户中途取消")
self.navigationController?.popViewControllerAnimated(true)
}else if resultStatus == "6002" {
self.infoNotice("网络连接出错")
self.navigationController?.popViewControllerAnimated(true)
}
}
})
}
网友评论
可以的么?