码迷,mamicode.com
首页 > 其他好文 > 详细

支付宝支付

时间:2015-07-14 15:21:07      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!