/*
* 支付宝支付
*/
- (void)alipayOrderWithOrderNum:(NSString *)orderNum
productName:(NSString *)productName
productDescription:(NSString *)productDescription
amount:(double)amount
{
Order *order = [[Order alloc] init];
order.partner = KAliPartner;
order.seller = KAliSeller;
order.tradeNO = orderNum; //订单号
order.productName = productName; //商品标题
order.productDescription = productDescription; //商品描述
order.amount = [NSString stringWithFormat:@"%.2f", amount]; //支付总价
order.notifyURL = KAliNotifyURL; //回调URL
order.service = @"mobile.securitypay.pay";
order.paymentType = @"1";
order.inputCharset = @"utf-8";
order.itBPay = @"30m";
order.showUrl = @"m.alipay.com";
//应用注册scheme,在AlixPayDemo-Info.plist定义URL types
NSString *appScheme = @"BunldId";
//将商品信息拼接成字符串
NSString *orderSpec = [order description];
//获取私钥并将商户信息签名,外部商户可以根据情况存放私钥和签名,只需要遵循RSA签名规范,并将签名字符串base64编码和UrlEncode
id<DataSigner> signer = CreateRSADataSigner(KAliPrivateKey);
NSString *signedString = [signer signString:orderSpec];
//将签名成功字符串格式化为订单字符串,请严格按照该格式
NSString *orderString = nil;
if (signedString != nil)
{
orderString = [NSString stringWithFormat:@"%@&sign=\"%@\"&sign_type=\"%@\"",
orderSpec, signedString, @"RSA"];
[[AlipaySDK defaultService] payOrder:orderString fromScheme:appScheme callback:^(NSDictionary *resultDic) {
[MBProgressHUD hideMessage];
NSLog(@"reslut = %@",resultDic);
}];
}
}