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
最后我记得需要关闭bitcode,记不太清了,不记得是不是银联支付需要的,如果之后出错可以试一下