|
@@ -21,6 +21,8 @@
|
|
@property (nonatomic, strong) KlarnaPaymentView *klarna_payV;
|
|
@property (nonatomic, strong) KlarnaPaymentView *klarna_payV;
|
|
@property (nonatomic, strong) NSString *client_token;
|
|
@property (nonatomic, strong) NSString *client_token;
|
|
|
|
|
|
|
|
+@property (nonatomic, strong) UIViewController *topVC;
|
|
|
|
+
|
|
@end
|
|
@end
|
|
|
|
|
|
|
|
|
|
@@ -40,24 +42,27 @@ static ASCheckoutPayManager *_instance = nil;
|
|
|
|
|
|
self.payType = payType;
|
|
self.payType = payType;
|
|
|
|
|
|
- UIViewController *topVC = topViewController();
|
|
|
|
|
|
+ self.topVC = topViewController();
|
|
|
|
|
|
if ([payType isEqualToString:@"paypal_express"]) {//paypal
|
|
if ([payType isEqualToString:@"paypal_express"]) {//paypal
|
|
K_WEAK_SELF;
|
|
K_WEAK_SELF;
|
|
- [MBProgressHUD showHUDAddedTo:topVC.view animated:YES];
|
|
|
|
|
|
+ [MBProgressHUD showHUDAddedTo:self.topVC.view animated:YES];
|
|
[ASNetTools.shared getWithPath:Chectout_Pay_Paypal_Url param:@{} success:^(id _Nonnull json) {
|
|
[ASNetTools.shared getWithPath:Chectout_Pay_Paypal_Url param:@{} success:^(id _Nonnull json) {
|
|
K_STRONG_SELF;
|
|
K_STRONG_SELF;
|
|
- [MBProgressHUD hideHUDForView:topVC.view animated:YES];
|
|
|
|
|
|
+ [MBProgressHUD hideHUDForView:self.topVC.view animated:YES];
|
|
|
|
|
|
NSDictionary *dataDic = (NSDictionary *)json;
|
|
NSDictionary *dataDic = (NSDictionary *)json;
|
|
NSString *urlStr = AS_String_NotNull(dataDic[@"url"]);
|
|
NSString *urlStr = AS_String_NotNull(dataDic[@"url"]);
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
- [self tool_gotoWebPay:urlStr withVC:topVC];
|
|
|
|
|
|
+ [self tool_gotoWebPay:urlStr withVC:self.topVC];
|
|
});
|
|
});
|
|
} faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
|
|
} faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
|
|
// K_STRONG_SELF;
|
|
// K_STRONG_SELF;
|
|
- [MBProgressHUD hideHUDForView:topVC.view animated:YES];
|
|
|
|
- [topVC.view makeToast:msg duration:2 position:CSToastPositionCenter];
|
|
|
|
|
|
+ [MBProgressHUD hideHUDForView:self.topVC.view animated:YES];
|
|
|
|
+ [self.topVC.view makeToast:msg duration:2 position:CSToastPositionCenter];
|
|
|
|
+ if (self.payFinishBlock) {
|
|
|
|
+ self.payFinishBlock(self.payType, 0, @{@"msg":@""});
|
|
|
|
+ }
|
|
}];
|
|
}];
|
|
|
|
|
|
} else if ([payType isEqualToString:@"stripe_payments"]) {//visa
|
|
} else if ([payType isEqualToString:@"stripe_payments"]) {//visa
|
|
@@ -97,10 +102,10 @@ static ASCheckoutPayManager *_instance = nil;
|
|
} else if ([payType isEqualToString:@"klarna_kco"]) {//klarna
|
|
} else if ([payType isEqualToString:@"klarna_kco"]) {//klarna
|
|
|
|
|
|
K_WEAK_SELF;
|
|
K_WEAK_SELF;
|
|
- [MBProgressHUD showHUDAddedTo:topVC.view animated:YES];
|
|
|
|
|
|
+ [MBProgressHUD showHUDAddedTo:self.topVC.view animated:YES];
|
|
[ASNetTools.shared getWithPath:Chectout_Pay_Klarna_Url param:@{} success:^(id _Nonnull json) {
|
|
[ASNetTools.shared getWithPath:Chectout_Pay_Klarna_Url param:@{} success:^(id _Nonnull json) {
|
|
K_STRONG_SELF;
|
|
K_STRONG_SELF;
|
|
- [MBProgressHUD hideHUDForView:topVC.view animated:YES];
|
|
|
|
|
|
+ [MBProgressHUD hideHUDForView:self.topVC.view animated:YES];
|
|
|
|
|
|
NSDictionary *dataDic = (NSDictionary *)json;
|
|
NSDictionary *dataDic = (NSDictionary *)json;
|
|
self.client_token = AS_String_NotNull(dataDic[@"client_token"]);
|
|
self.client_token = AS_String_NotNull(dataDic[@"client_token"]);
|
|
@@ -110,8 +115,12 @@ static ASCheckoutPayManager *_instance = nil;
|
|
NSLog(@"=====%@", json);
|
|
NSLog(@"=====%@", json);
|
|
} faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
|
|
} faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
|
|
/*K_STRONG_SELF*/;
|
|
/*K_STRONG_SELF*/;
|
|
- [MBProgressHUD hideHUDForView:topVC.view animated:YES];
|
|
|
|
|
|
+ [MBProgressHUD hideHUDForView:self.topVC.view animated:YES];
|
|
|
|
+ [self.topVC.view makeToast:msg duration:2 position:CSToastPositionCenter];
|
|
|
|
|
|
|
|
+ if (self.payFinishBlock) {
|
|
|
|
+ self.payFinishBlock(self.payType, 0, @{@"msg":@""});
|
|
|
|
+ }
|
|
}];
|
|
}];
|
|
} else {
|
|
} else {
|
|
//货到付款
|
|
//货到付款
|
|
@@ -122,7 +131,6 @@ static ASCheckoutPayManager *_instance = nil;
|
|
#pragma mark ----- stripe支付 、 货到付款方式-----
|
|
#pragma mark ----- stripe支付 、 货到付款方式-----
|
|
//stripe支付(二次校验后生成订单)
|
|
//stripe支付(二次校验后生成订单)
|
|
- (void)stripePayCreateOrderid:(NSString *)payid {
|
|
- (void)stripePayCreateOrderid:(NSString *)payid {
|
|
- UIViewController *topVC = topViewController();
|
|
|
|
|
|
|
|
NSDictionary *requestParams = nil;
|
|
NSDictionary *requestParams = nil;
|
|
if ([payid isEqualToString:@""]) {//货到付款方式
|
|
if ([payid isEqualToString:@""]) {//货到付款方式
|
|
@@ -135,11 +143,11 @@ static ASCheckoutPayManager *_instance = nil;
|
|
requestParams = @{@"paymentMethod":param};
|
|
requestParams = @{@"paymentMethod":param};
|
|
}
|
|
}
|
|
|
|
|
|
- [MBProgressHUD showHUDAddedTo:topVC.view animated:YES];
|
|
|
|
|
|
+ [MBProgressHUD showHUDAddedTo:self.topVC.view animated:YES];
|
|
K_WEAK_SELF;
|
|
K_WEAK_SELF;
|
|
[ASNetTools.shared putWithPath:Chectout_PUT_sureOrder param:requestParams success:^(id _Nonnull json) {
|
|
[ASNetTools.shared putWithPath:Chectout_PUT_sureOrder param:requestParams success:^(id _Nonnull json) {
|
|
K_STRONG_SELF;
|
|
K_STRONG_SELF;
|
|
- [MBProgressHUD hideHUDForView:topVC.view animated:YES];
|
|
|
|
|
|
+ [MBProgressHUD hideHUDForView:self.topVC.view animated:YES];
|
|
|
|
|
|
NSString *orderid = (NSString *)json;
|
|
NSString *orderid = (NSString *)json;
|
|
if (self.payFinishBlock) {
|
|
if (self.payFinishBlock) {
|
|
@@ -148,9 +156,10 @@ static ASCheckoutPayManager *_instance = nil;
|
|
|
|
|
|
} faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
|
|
} faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
|
|
K_STRONG_SELF;
|
|
K_STRONG_SELF;
|
|
- [MBProgressHUD hideHUDForView:topVC.view animated:YES];
|
|
|
|
|
|
+ [MBProgressHUD hideHUDForView:self.topVC.view animated:YES];
|
|
|
|
+ [self.topVC.view makeToast:msg duration:2 position:CSToastPositionCenter];
|
|
if (self.payFinishBlock) {
|
|
if (self.payFinishBlock) {
|
|
- self.payFinishBlock(self.payType, 0, @{@"msg":msg});
|
|
|
|
|
|
+ self.payFinishBlock(self.payType, 0, @{@"msg":@""});
|
|
}
|
|
}
|
|
}];
|
|
}];
|
|
}
|
|
}
|
|
@@ -167,6 +176,9 @@ static ASCheckoutPayManager *_instance = nil;
|
|
[self requestVerifyPaypalToken:webData];
|
|
[self requestVerifyPaypalToken:webData];
|
|
} else {
|
|
} else {
|
|
[tmpvc.view makeToast:[(NSDictionary *)webData objectForKey:@"title"] duration:2 position:CSToastPositionCenter];
|
|
[tmpvc.view makeToast:[(NSDictionary *)webData objectForKey:@"title"] duration:2 position:CSToastPositionCenter];
|
|
|
|
+ if (self.payFinishBlock) {
|
|
|
|
+ self.payFinishBlock(self.payType, 0, @{@"msg":@""});
|
|
|
|
+ }
|
|
}
|
|
}
|
|
};
|
|
};
|
|
[vc xxx_dsWebLoadUrl:urlStr];
|
|
[vc xxx_dsWebLoadUrl:urlStr];
|
|
@@ -176,39 +188,57 @@ static ASCheckoutPayManager *_instance = nil;
|
|
|
|
|
|
//paypal支付 Token验证
|
|
//paypal支付 Token验证
|
|
- (void)requestVerifyPaypalToken:(NSDictionary *)dic {
|
|
- (void)requestVerifyPaypalToken:(NSDictionary *)dic {
|
|
- UIViewController *topVC = topViewController();
|
|
|
|
|
|
|
|
NSDictionary *params = @{@"token":[dic objectForKey:@"token"]};
|
|
NSDictionary *params = @{@"token":[dic objectForKey:@"token"]};
|
|
- [MBProgressHUD showHUDAddedTo:topVC.view animated:YES];
|
|
|
|
|
|
+ [MBProgressHUD showHUDAddedTo:self.topVC.view animated:YES];
|
|
K_WEAK_SELF;
|
|
K_WEAK_SELF;
|
|
- [ASNetTools.shared postWithPath:Chectout_Verify_PayToken param:params success:^(id _Nonnull json) {
|
|
|
|
|
|
+ [ASNetTools.shared getWithPath:Chectout_Verify_PayToken param:params success:^(id _Nonnull json) {
|
|
K_STRONG_SELF;
|
|
K_STRONG_SELF;
|
|
- [MBProgressHUD hideHUDForView:topVC.view animated:YES];
|
|
|
|
|
|
+ [MBProgressHUD hideHUDForView:self.topVC.view animated:YES];
|
|
|
|
+
|
|
|
|
|
|
NSDictionary *payReturnDic = (NSDictionary *)json;
|
|
NSDictionary *payReturnDic = (NSDictionary *)json;
|
|
- NSString *orderid = [payReturnDic objectForKey:@"id"];
|
|
|
|
|
|
+
|
|
|
|
+ NSString *orderid = [payReturnDic objectForKey:@"incrementId"];
|
|
if (self.payFinishBlock) {
|
|
if (self.payFinishBlock) {
|
|
self.payFinishBlock(self.payType, 1, @{@"orderid":orderid});
|
|
self.payFinishBlock(self.payType, 1, @{@"orderid":orderid});
|
|
}
|
|
}
|
|
-
|
|
|
|
} faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
|
|
} faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
|
|
K_STRONG_SELF;
|
|
K_STRONG_SELF;
|
|
- [MBProgressHUD hideHUDForView:topVC.view animated:YES];
|
|
|
|
|
|
+ [MBProgressHUD hideHUDForView:self.topVC.view animated:YES];
|
|
if (self.payFinishBlock) {
|
|
if (self.payFinishBlock) {
|
|
self.payFinishBlock(self.payType, 0, @{@"msg":msg});
|
|
self.payFinishBlock(self.payType, 0, @{@"msg":msg});
|
|
}
|
|
}
|
|
}];
|
|
}];
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// [ASNetTools.shared postWithPath:Chectout_Verify_PayToken param:params success:^(id _Nonnull json) {
|
|
|
|
+// K_STRONG_SELF;
|
|
|
|
+// [MBProgressHUD hideHUDForView:topVC.view animated:YES];
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+// NSDictionary *payReturnDic = (NSDictionary *)json;
|
|
|
|
+// NSString *orderid = [payReturnDic objectForKey:@"id"];
|
|
|
|
+// if (self.payFinishBlock) {
|
|
|
|
+// self.payFinishBlock(self.payType, 1, @{@"orderid":orderid});
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
|
|
|
|
+// K_STRONG_SELF;
|
|
|
|
+// [MBProgressHUD hideHUDForView:topVC.view animated:YES];
|
|
|
|
+// if (self.payFinishBlock) {
|
|
|
|
+// self.payFinishBlock(self.payType, 0, @{@"msg":msg});
|
|
|
|
+// }
|
|
|
|
+// }];
|
|
}
|
|
}
|
|
|
|
|
|
#pragma mark ----- klarna支付验证 -----
|
|
#pragma mark ----- klarna支付验证 -----
|
|
//klarna支付验证
|
|
//klarna支付验证
|
|
-(void)tool_verifyOrderAutoken:(NSString *)authToken{
|
|
-(void)tool_verifyOrderAutoken:(NSString *)authToken{
|
|
-
|
|
|
|
- UIViewController *topVC = topViewController();
|
|
|
|
-
|
|
|
|
|
|
+
|
|
NSDictionary *params = @{@"authorization_token":authToken};
|
|
NSDictionary *params = @{@"authorization_token":authToken};
|
|
|
|
|
|
- [MBProgressHUD showHUDAddedTo:topVC.view animated:YES];
|
|
|
|
|
|
+ [MBProgressHUD showHUDAddedTo:self.topVC.view animated:YES];
|
|
K_WEAK_SELF;
|
|
K_WEAK_SELF;
|
|
[ASNetTools.shared postWithPath:Chectout_Verify_KlarnaCart param:params success:^(id _Nonnull json) {
|
|
[ASNetTools.shared postWithPath:Chectout_Verify_KlarnaCart param:params success:^(id _Nonnull json) {
|
|
K_STRONG_SELF;
|
|
K_STRONG_SELF;
|
|
@@ -226,7 +256,7 @@ static ASCheckoutPayManager *_instance = nil;
|
|
|
|
|
|
} faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
|
|
} faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
|
|
K_STRONG_SELF;
|
|
K_STRONG_SELF;
|
|
- [MBProgressHUD hideHUDForView:topVC.view animated:YES];
|
|
|
|
|
|
+ [MBProgressHUD hideHUDForView:self.topVC.view animated:YES];
|
|
|
|
|
|
if (self.payFinishBlock) {
|
|
if (self.payFinishBlock) {
|
|
self.payFinishBlock(self.payType, 0, @{@"msg":@"Payment anomaly"});
|
|
self.payFinishBlock(self.payType, 0, @{@"msg":@"Payment anomaly"});
|
|
@@ -236,7 +266,6 @@ static ASCheckoutPayManager *_instance = nil;
|
|
|
|
|
|
//klarna支付
|
|
//klarna支付
|
|
-(void)tool_creatOrderAutoken:(NSString *)authToken{
|
|
-(void)tool_creatOrderAutoken:(NSString *)authToken{
|
|
- UIViewController *topVC = topViewController();
|
|
|
|
|
|
|
|
self.client_token = authToken;
|
|
self.client_token = authToken;
|
|
|
|
|
|
@@ -252,7 +281,7 @@ static ASCheckoutPayManager *_instance = nil;
|
|
K_WEAK_SELF;
|
|
K_WEAK_SELF;
|
|
[ASNetTools.shared postWithPath:Chectout_Verify_KlarnaToken param:params success:^(id _Nonnull json) {
|
|
[ASNetTools.shared postWithPath:Chectout_Verify_KlarnaToken param:params success:^(id _Nonnull json) {
|
|
K_STRONG_SELF;
|
|
K_STRONG_SELF;
|
|
- [MBProgressHUD hideHUDForView:topVC.view animated:YES];
|
|
|
|
|
|
+ [MBProgressHUD hideHUDForView:self.topVC.view animated:YES];
|
|
|
|
|
|
NSString *orderid = (NSString *)json;
|
|
NSString *orderid = (NSString *)json;
|
|
NSLog(@"=======%@", orderid);
|
|
NSLog(@"=======%@", orderid);
|
|
@@ -262,7 +291,7 @@ static ASCheckoutPayManager *_instance = nil;
|
|
|
|
|
|
} faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
|
|
} faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
|
|
K_STRONG_SELF;
|
|
K_STRONG_SELF;
|
|
- [MBProgressHUD hideHUDForView:topVC.view animated:YES];
|
|
|
|
|
|
+ [MBProgressHUD hideHUDForView:self.topVC.view animated:YES];
|
|
|
|
|
|
if (self.payFinishBlock) {
|
|
if (self.payFinishBlock) {
|
|
self.payFinishBlock(self.payType, 0, @{@"msg":msg});
|
|
self.payFinishBlock(self.payType, 0, @{@"msg":msg});
|
|
@@ -291,7 +320,7 @@ static ASCheckoutPayManager *_instance = nil;
|
|
|
|
|
|
} else {
|
|
} else {
|
|
if (self.payFinishBlock) {
|
|
if (self.payFinishBlock) {
|
|
- self.payFinishBlock(self.payType, 0, @{@"msg":@"Payment Failed"});
|
|
|
|
|
|
+ self.payFinishBlock(self.payType, 0, @{@"msg":@"Payment Failed/Cancel"});
|
|
}
|
|
}
|
|
NSLog(@"klarna 授权支付失败");
|
|
NSLog(@"klarna 授权支付失败");
|
|
}
|
|
}
|