支付宝、微信支付

1.集成什么的就不说了。。。。
2.流程:向后台提交订单信息 >> 后台生成订单及签名之类的 >> 返回 签名字段 orderStr;
orderStr 如下:

"partner=\"2088121304456321\"&seller_id=\"[email protected]\"&out_trade_no=\"1484098174272\"&subject=\"\U6c34\U3001\U7535\U7f34\U8d39\"&body=\"1\"&total_fee=\"0.01\"¬ify_url=\"http://120.24.152.228:8180/zhxc/alipay/receiveInfoFromAlipay.action\"&service=\"mobile.securitypay.pay\"&payment_type=\"1\"&_input_charset=\"UTF-8\"&it_b_pay=\"30m\"&return_url=\"m.alipay.com\"&sign=\"y%2BwxPVvw2HJq%2FI0QYY5LJKP05XfNapX4c3z5NFwOaWexya65Rm7qz6kicj7TKEd72Yxv4BY2fgEUR%2FoKf5cH7GqkmopE1dAFR%2FZat%2BegMF%2F5aHws%2FsR4oRQ307yLJUe2hosrMIMuQQpeNE8tdpuC3MLK01AyrVzk7As%3D\"&sign_type=\"RSA\"";

再调用如下方法:

#pragma mark - 支付宝
- (void)AliPayWithOrderStr:(NSString *)orderStr{

    NSString *appScheme = @"xincheng";
    [[AlipaySDK defaultService] payOrder:orderStr fromScheme:appScheme callback:^(NSDictionary *resultDic) {

        NSString *message = @"";
        switch([[resultDic objectForKey:@"resultStatus"] integerValue])
        {
            case 9000:message = @"订单支付成功"; [self paySu:message];break;
            case 8000:message = @"正在处理中";   [self payFa:message];break;
            case 4000:message = @"订单支付失败"; [self payFa:message];break;
            case 6001:message = @"用户中途取消"; [self payFa:message];break;
            case 6002:message = @"网络连接错误"; [self payFa:message];break;
            default:message = @"未知错误";
        }

    }];
}
- (void)paySu:(NSString*)message{
    [MBProgressHUD showSuccessWithText:message];
    [self.requstState sendNext:@"payEnd"];//RAC 请忽略 
}
- (void)payFa:(NSString*)message{
    [MBProgressHUD showErrorWithText:message];
}

微信支付,后台会返回一个json对象,传入以下方法:

#pragma mark - 微信支付
- (void)WeChatPayWithInfo:(NSDictionary *)dic{

    NSMutableString *stamp  = [dic objectForKey:@"timeStamp"];
    PayReq *req = [[PayReq alloc]init];
    req.partnerId = dic[@"partnerid"];
    req.prepayId =  dic[@"prepayId"];
    req.package =   dic[@"package"];
    req.nonceStr =  dic[@"nonceStr"];
    req.timeStamp = stamp.intValue;
    req.sign = dic[@"paysign"];
    [WXApi sendReq:req];
}

朋友们可能认为这么简单也来发,额。。。。其实 我是用来 复制粘贴的,以后就不用再一次次敲了0.0。。。。。。。

你可能感兴趣的:(支付宝、微信支付)