ASPaypalManager.m 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //
  2. // ASPaypalManager.m
  3. // Asteria
  4. //
  5. // Created by xingyu on 2024/5/14.
  6. //
  7. #import "ASPaypalManager.h"
  8. @implementation ASPaypalManager
  9. static ASPaypalManager *_instance = nil;
  10. + (instancetype)sharedInstance {
  11. static dispatch_once_t onceToken;
  12. dispatch_once(&onceToken, ^{
  13. _instance = [[ASPaypalManager alloc] init];
  14. });
  15. return _instance;
  16. }
  17. - (void)checkoutPayWithMethodType:(NSString *)payType completion:(void (^ __nullable)(NSUInteger isSucess , id payData))completion {
  18. UIViewController *topVC = topViewController();
  19. if ([payType isEqualToString:@"paypal_express"]) {//paypal
  20. K_WEAK_SELF;
  21. [ASNetTools.shared getWithPath:Chectout_Pay_Paypal_Url param:@{} success:^(id _Nonnull json) {
  22. K_STRONG_SELF;
  23. NSDictionary *dataDic = (NSDictionary *)json;
  24. NSString *urlStr = AS_String_NotNull(dataDic[@"url"]);
  25. dispatch_async(dispatch_get_main_queue(), ^{
  26. [self tool_gotoWebPay:urlStr withVC:topVC completion:completion];
  27. });
  28. NSLog(@"=====%@", json);
  29. } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
  30. }];
  31. } else if ([payType isEqualToString:@"stripe_payments"]) {//visa
  32. } else if ([payType isEqualToString:@"afterpay_payment"]) {//afterpay
  33. } else if ([payType isEqualToString:@"klarna_kco"]) {//klarna
  34. } else {
  35. }
  36. }
  37. - (void)tool_gotoWebPay:(NSString *)urlStr withVC:(UIViewController *)tmpvc completion:(void (^ __nullable)(NSUInteger isSucess , id payData))completion{
  38. XXX_BaseWebC *vc = [[XXX_BaseWebC alloc] init];
  39. vc.isPayType = YES;
  40. vc.WebViewBlock = ^(NSUInteger status, id _Nonnull webData) {
  41. if(status == 1){
  42. if(completion){
  43. completion(1, webData);
  44. }
  45. }else{
  46. if(completion){
  47. completion(0, webData);
  48. }
  49. }
  50. };
  51. [vc xxx_dsWebLoadUrl:urlStr];
  52. vc.modalPresentationStyle = UIModalPresentationFullScreen;
  53. [tmpvc presentViewController:vc animated:YES completion:nil];
  54. }
  55. @end