iOS之封装集成第三方支付相关

iOS 银联支付集成

2017-07-17  本文已影响30人  梦里风吹过

SDK下载地址

pod 'GreedUPPayPlugin'

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

AppDelegate

#import <GreedUPPayPlugin/UPPaymentControl.h>

- (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<NSString*, id> *)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

ED312406-1A5F-4AB8-A27A-B1D86EC71336.png 设置白名单 http设置

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

关闭bitcode
上一篇下一篇

猜你喜欢

热点阅读