-(void)aliPaySubmit:(NSDictionary *)orderDict
{
/*============================================================================*/
/*=======================需要填写商户app申请的===================================*/
/*============================================================================*/
//合作者身份(PID)
// NSString *partner = @"2088121752520025";
// //支付宝账号
// NSString *seller = @"jiahetianlang@qq.com";
// //私钥
// NSString *privateKey = @"MIICeQIBADANBgkqhkiG9w0BAQEFAASCAmMwggJfAgEAAoGBAMYzAbenxxOJjn82ELjTb/dE4nGtOWveY7+iZD6TN4LbJV25VTBiCtFYvSN2HGvDEaPqpZdMN7bY8X4s5VK+Pxd8NReUI+ogDR/pQSskNYH/vMaMqKwYs2Nw0u/yoZm6r4QYAEXlFUqasjdwFWfzgKARnd73fUj5Qe59riQEbd3bAgMBAAECgYEAuo5SRIM5ACvPI/BI5x+l2TJOjr+FOAJZE40QHFJHwvTxg/mptOPj2M9VIGbRM6GmHgsEmJfWLVagYKpzpGGMUay9UwJUgHjYvAIjh07f/y/7coYp+pxK5sUt+iZD4NowCCX/+80Lr+AKjWVs88ha/OjxQfwsW7TkzBM6Fo0JBYkCQQD9rTjxVCqrAHbEnGrutI2ICzf+QuLTgfWHmwZHMRw5WuATdyXJA0qD+M1Mm3jNA0SH6COTR0+BXgle7BerLTp/AkEAyAO12fRRf3G+EWCKMw7hRRLXwmhBoqC5K61ijbRlXD4iSgOc7baFySapPTm6myvqzc5naR1chwGqx5MRNB/WpQJBAPxOcMdenj2MbZRputWGkQpRljR3FCGoLavdXaYrS1Ykc6AIrnU6p7+RE6hxLfpCmMPP+KpAj+wsuodFrNjdWEMCQQC+8OvV2itDIu5z4FmOTJI5Qre+25BtFEoxrB/9b02kNZy+U5yoQiqN0N6XmFjQcaiCOJz3+BOwvqKuS3OM8ygRAkEAvwzOfQwqe2gbeCk1KzjAAJwcro4ORFov0Gyw+EvC7izjD4GbOsJmUNTC4IW6Uw+BqonTgZkTeCsWalS0R99npw==";
NSArray *payArray = orderDict[@"pay_config"];
NSDictionary *payDict = [payArray objectAtIndex:0];
NSString *partner = [ZBFactoryisAvailabileString:payDict[@"alipay_partner_id"]];
NSString *seller = [ZBFactoryisAvailabileString:payDict[@"alipay_seller_email"]];
NSString *privateKey = [ZBFactoryisAvailabileString:payDict[@"pcks8_private_key"]];
/*============================================================================*/
/*============================================================================*/
/*============================================================================*/
//partner和seller获取失败,提示
if ([partner length] ==0 ||
[seller length] == 0 ||
[privateKey length] == 0)
{
UIAlertView *alert = [[UIAlertViewalloc] initWithTitle:@"提示"
message:@"缺少partner或者seller或者私钥。"
delegate:self
cancelButtonTitle:@"确定"
otherButtonTitles:nil];
[alert show];
return;
}
//订单标题,展示给用户
// NSString *order_name = [ZBFactory isAvailabileString:orderDict[@"product_name"]];
//订单金额,单位(分)
// NSString *moneyStr = [ZBFactory isAvailabileString:orderDict[@"totalMoney"]];
// NSInteger moneyValue = [moneyStr floatValue]*100;
// NSString *order_price = [NSString stringWithFormat:@"%li",(long)moneyValue];
//订单编号
NSString *orderIDStr = [ZBFactoryisAvailabileString:orderDict[@"order_sn"]];
NSString *logStr = [ZBFactoryisAvailabileString:orderDict[@"log_id"]];
NSString*oderId=[ZBFactoryisAvailabileString:orderDict[@"shop_id"]];
NSString*order_type=[ZBFactoryisAvailabileString:orderDict[@"order_type"]];
//拼接id
NSString *final_ID = [NSStringstringWithFormat:@"%@O%@O%@O%@",orderIDStr,oderId, logStr,order_type];
//支付回调地址
NSString *notify_idStr = [NSStringstringWithFormat:@"%@%@",MainHostName,WZ_ZhiPay];
/*
*生成订单信息及签名
*/
//将商品信息赋予AlixPayOrder的成员变量
Order *order = [[Orderalloc] init];
order.partner = partner;
order.seller = seller;
// order.tradeNO = [self generateTradeNO]; //订单ID(由商家自行制定)
order.tradeNO = final_ID; //订单ID(由商家自行制定)
order.productName = @"亲来了商品";//商品标题
order.productDescription =@"亲来了商品";//商品描述
order.amount =totalMoneyStr; //商品价格
order.notifyURL = notify_idStr; //回调URL
//order.notifyURL = @"http://qll.zjzitai.com/App/notify/alipay.html"; //回调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 = @"qllalipay";
//将商品信息拼接成字符串
NSString *orderSpec = [order description];
NSLog(@"orderSpec = %@",orderSpec);
//获取私钥并将商户信息签名,外部商户可以根据情况存放私钥和签名,只需要遵循RSA签名规范,并将签名字符串base64编码和UrlEncode
id<DataSigner> signer =CreateRSADataSigner(privateKey);
NSString *signedString = [signer signString:orderSpec];
//将签名成功字符串格式化为订单字符串,请严格按照该格式
NSString *orderString = nil;
if (signedString != nil) {
orderString = [NSStringstringWithFormat:@"%@&sign=\"%@\"&sign_type=\"%@\"",
orderSpec, signedString, @"RSA"];
[[AlipaySDK defaultService] payOrder:orderString fromScheme:appScheme callback:^(NSDictionary *resultDic) {
NSInteger resultStatus = [[ZBFactoryisAvailabileString:resultDic[@"resultStatus"]]integerValue];
NSString *resultStr = [ZBFactoryisAvailabileString:resultDic[@"memo"]];
//支付成功
if (resultStatus==9000)
{
resultStr = @"支付成功";
[[NSNotificationCenterdefaultCenter] postNotificationName:@"refreshOrderList"object:nil];
[self performSelector:@selector(actionOfBack)withObject:nilafterDelay:1.0f];
}
if (![ZBFactoryisBlankString:resultStr])
{
UIAlertView *alert = [[UIAlertViewalloc] initWithTitle:@"支付结果"message:resultStr delegate:selfcancelButtonTitle:@"OK"otherButtonTitles:nil,nil];
[alert show];
}
NSLog(@"reslut = %@",resultDic);
}];
}
}