集成mustPay第四方支付
至于为什么使用第四方支付,原因是因为app为博彩等敏感性质的时候,支付宝和微信可能审核通不过,这个时候我们就可以用第四方的支付了,不过第四方的收费比较高,需要4.0%!它里面集成了支付宝 微信 银联支付 百度钱包 京东钱包等支付方式,基本满足app的需求.
首先我们要去官网下载mustPaySDK:https://www.mustpay.com.cn/mustpay/download/index
然后将mustPaySDK导入到项目中
图片 1.png
第二步:往info.plist添加东西 (就是把需要调用的支付APP加入白名单)如下图
图片 1.png找到LSApplicationQueriesSchemes 这个数组
<string>weibo.cn</string>
<string>wechat</string>
<string>weixin</string>
<string>sinaweibohd</string>
<string>sinaweibo</string>
<string>sinaweibosso</string>
<string>weibosdk</string>
<string>weibosdk2.5</string>
<string>mqqapi</string>
<string>mqq</string>
<string>mqqOpensdkSSoLogin</string>
<string>mqqconnect</string>
<string>mqqopensdkdataline</string>
<string>mqqopensdkgrouptribeshare</string>
<string>mqqopensdkfriend</string>
<string>mqqopensdkapi</string>
<string>mqqopensdkapiV2</string>
<string>mqqopensdkapiV3</string>
<string>mqzoneopensdk</string>
<string>wtloginmqq</string>
<string>wtloginmqq2</string>
<string>mqqwpa</string>
<string>mqzone</string>
<string>mqzonev2</string>
<string>mqzoneshare</string>
<string>wtloginqzone</string>
<string>mqzonewx</string>
<string>mqzoneopensdkapiV2</string>
<string>mqzoneopensdkapi19</string>
<string>mqzoneopensdkapi</string>
<string>mqzoneopensdk</string>
<string>alipay</string>
<string>alipayshare</string>
<string>uppaywallet</string>
<string>uppaysdk</string>
把上面的需要用的粘贴进去比如支付宝就是<string>alipay</string>
第三步:配置Build Settings 里的other link 如下图:
图片 1.png第四步:用到的系统库如下图
图片 1.png第五步
在AppDelegate里面的
-(void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
//当微信 支付宝不能调起你们的应用时 用户打开你们的应用 发个验证订单的通知
[[NSNotificationCenter defaultCenter] postNotificationName:@"check" object:nil userInfo:nil];
}
在需要调起支付的界面导入#import "MustPayHeader.h"
声明#import "MustPayHeader.h"
打开代理
[MustPaySDK sharedSingleton].delegate = self;
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(nispectOrder) name:@"check" object:nil];
}
-(void)nispectOrder
{
NSLog(@" 什么啊");
}
-(void)mustPayResult:(NSString*)code{
if ([code isEqualToString:@"success"]) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"支付成功"
delegate:self cancelButtonTitle:nil otherButtonTitles:@"知道啦", nil];
[alert show];
}else if ([code isEqualToString:@"faile"]){
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"支付失败"
delegate:self cancelButtonTitle:nil otherButtonTitles:@"知道啦", nil];
[alert show];
}
}
/**
@param appid MustPay平台分配的唯一应用ID
@param prepayid 服务端通过统一下单接口获取的prepayid
@param goodsName 商品名字
@param goodsPrice 商品价格
@param scheme 支付宝用到 ,用于支付宝返回本应用
/
- (void)mustPayInitViewAppid:(NSString)appid
prepayid:(NSString)prepayid
goodsName:(NSString)goodsName
goodsPrice:(NSString)goodsPrice
scheme:(NSString)scheme
{
}
//验证订单状态
-(void)erifyOrderStatus
{
}
但是集成以后有个比较坑的地方是SDK没有和模拟器版的合成,导致程序只能用真机跑,真的是让人受不了,后期维护很麻烦