iOS

支付整合

对招行网页支付接口和银联支付sdk进行封装。

tips:根据安排整合支付模块

  • 结构说明

99042A97-1C41-4F22-A736-4EE199A32C6D.png

LCPayManager 提供了支付方法和一个回掉查看支付结果

1
- (void)orderPayMode:(PayWay)payway orderInfo:(LCPayBaseVo *)vo;

其中PayWay是支付方式

1
2
3
4
5
6
7
typedef NS_ENUM(NSInteger, PayWay)
{
PayWayByAlipay = 1,
PayWayByCMB = 2,
PayWayByCash = 3,
PayWayByUnionPay = 4,
};

vo 是一个存储支付相关信息的类,里面包含基本的商品信息

暂时直邮银联和招商两种支付方式,所以就提供了两种模式

1
2
LCCMBPayMode
LCUnionPayMode

  • 使用
    银联
    1
    2
    3
    4
    5
     LCPayUnionVo *vo = [[LCPayUnionVo alloc]init];
    vo.orderid = backHead.tn;
    vo.viewController = self;
    [LCPayManager sharedInstance].delegate = self;
    [[LCPayManager sharedInstance] orderPayMode:PayWayByUnionPay orderInfo:vo];

招商

1
2
3
4
5
6
7
8
9
10
11
LCPayManager *ma = [LCPayManager sharedInstance];
ma.delegate = self;
LCPayCMBVo *vo = [[LCPayCMBVo alloc]init];
vo.branchId = backHead.branchId;
vo.coNo = backHead.coNo;
vo.orderid = backHead.billNo;
vo.amount = backHead.amount;
vo.date = backHead.date;
vo.merchantUrl = backHead.merchantUrl;
vo.merchantPara = backHead.merchantPara;
[ma orderPayMode:PayWayByCMB orderInfo:vo];

所有的支付结果在中反回

1
2
3
4
 - (void)didFinishPayWithResult:(NSString *)result
{
NSLog(@"didFinishPayWithResult is %@",result);
}

因为CMB是跳外部浏览器的,所以在AppDelegate中也要做相应处理
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
添加[LCPayManager sharedInstance].mresult的赋值