iOS 银联支付集成

SDK下载地址

pod 'GreedUPPayPlugin'

下面只说使用cocoapods集成之后需要做的配置

AppDelegate

#import 

- (BOOL) application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{
    NSLog(@"%@",url.host);
    //这里最好测试一下
    if ([url.host isEqualToString:@"uppayresult"]) {
        [[UPPaymentControl defaultControl] handlePaymentResult:url completeBlock:^(NSString *code, NSDictionary *data) {
            NSLog(@"银联:%@",code);
            if([code isEqualToString:@"success"]) {
               //成功
            }else if ([code isEqualToString:@"fail"]) {
                //交易失败
            } else if ([code isEqualToString:@"cancel"]) {
                //交易取消
            }
        }];
    }
    return YES;
}
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options{
    NSLog(@"%@",url.host);
     //这里最好测试一下
    if ([url.host isEqualToString:@"uppayresult"]) {
        [[UPPaymentControl defaultControl] handlePaymentResult:url completeBlock:^(NSString *code, NSDictionary *data) {
            NSLog(@"银联:%@",code);
            if([code isEqualToString:@"success"]) {
               //成功
            }else if ([code isEqualToString:@"fail"]) {
                //交易失败
            } else if ([code isEqualToString:@"cancel"]) {
                //交易取消
            }
        }];
    }
    return YES;
}

支付

#import "UPPaymentControl.h"

[[UPPaymentControl defaultControl] startPay:tn  fromScheme:@"appscheme" mode:@"00" viewController:self];

Info.plist

iOS 银联支付集成_第1张图片
ED312406-1A5F-4AB8-A27A-B1D86EC71336.png
iOS 银联支付集成_第2张图片
设置白名单
http设置

最后我记得需要关闭bitcode,记不太清了,不记得是不是银联支付需要的,如果之后出错可以试一下

iOS 银联支付集成_第3张图片
关闭bitcode

你可能感兴趣的:(iOS 银联支付集成)