集成:
不详说,cocopod集成下SDK。
流程:
向后台提交订单信息 >> 后台生成已签名的支付订单信息 >> >> 调起第三方支付 >> 支付完成或取消回调;
这是后台返回的orderStr :
"partner=\"2088121304456321\"&seller_id=\"875635687@qq.com\"&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。。。。。。。
2020-05-11 :
iOS唤起第三方app都是使用的url来交互,那么就可以不用集成SDK,只要在后端处理好订单字符串,我直接用来调用,就可以避免审核的尴尬了。具体的已经有人实现了,自行百度,我还没有实践。