标签:
1.SDK下载地址
https://b.alipay.com/order/productDetail.htm?productId=2013080604609654&tabId=4#ps-tabinfo-hash
2.按照Demo和文档一步一步接入即可
3.从服务端获取参数发起支付
//支付宝支付 - (void)requestOrderAlipay:(NSString *)orderId{ AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager shareManager]; NSMutableDictionary *parameters = [[NSMutableDictionary alloc] initWithDictionary:[CommonParameters getCommonParameters]]; [parameters setObject:orderId forKey:@"orderId"]; [parameters addSignatureKey]; [manager POST:ALIPAY_ORDER_INFO_URL parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) { if ([NetWorkReturnHelper NetCompatibleErrorCode:responseObject]) { Order *order=[[Order alloc]init]; order.partner = PartnerID; order.seller = SellerID; order.tradeNO=[responseObject objectForKey:@"orderSn"]; order.productName=[responseObject objectForKey:@"subject"]; order.productDescription=[responseObject objectForKey:@"body"]; order.amount=[responseObject objectForKey:@"payFee"]; order.notifyURL=[responseObject objectForKey:@"notifyUrl"]; order.service = @"mobile.securitypay.pay"; order.paymentType = @"1"; order.inputCharset = @"utf-8"; order.itBPay = @"30m"; order.showUrl = @"m.alipay.com"; NSString *alipayScheme = @"XQB"; NSString* orderSpec = [order description]; //获取私钥并将商户信息签名,外部商户可以根据情况存放私钥和签名,只需要遵循RSA签名规范,并将签名字符串base64编码和UrlEncode id<DataSigner> signer = CreateRSADataSigner(PartnerPrivKey); 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:alipayScheme callback:^(NSDictionary *resultDic) { NSLog(@"reslut = %@",resultDic); }]; } } else { NSLog(@"获取支付宝订单信息失败"); } } failure:^(AFHTTPRequestOperation *operation, NSError *error) { XQBLog(@"银联签名网络异常"); }]; }
4.返回支付状态
标签:
原文地址:http://www.cnblogs.com/cuiyw/p/4645200.html