-
集成mustPay第四方支付
2025-05-24 06:13:55
至于为什么使用第四方支付,原因是因为app为博彩等敏感性质的时候,支付宝和微信可能审核通不过,这个时候我们就可以用第四方的支付了,不过第四方的收费比较高,需要4.0%!它里面集成了支付宝 微信 银联支付 百度钱包 京东钱包等支付方式,基本满足app的需求.
首先我们要去官网下载mustPaySDK:https://www.mustpay.com.cn/mustpay/download/index
然后将mustPaySDK导入到项目中
图片 1.png
第二步:往info.plist添加东西 (就是把需要调用的支付APP加入白名单)如下图
图片 1.png
找到LSApplicationQueriesSchemes 这个数组
weibo.cn wechat weixin sinaweibohd sinaweibo sinaweibosso weibosdk weibosdk2.5 mqqapi mqq mqqOpensdkSSoLogin mqqconnect mqqopensdkdataline mqqopensdkgrouptribeshare mqqopensdkfriend mqqopensdkapi mqqopensdkapiV2 mqqopensdkapiV3 mqzoneopensdk wtloginmqq wtloginmqq2 mqqwpa mqzone mqzonev2 mqzoneshare wtloginqzone mqzonewx mqzoneopensdkapiV2 mqzoneopensdkapi19 mqzoneopensdkapi mqzoneopensdk alipay alipayshare uppaywallet uppaysdk 把上面的需要用的粘贴进去比如支付宝就是
alipay 第三步:配置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没有和模拟器版的合成,导致程序只能用真机跑,真的是让人受不了,后期维护很麻烦