From 187b3b6b1efa58549127903e7ed87ca0acefd00f Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Wed, 4 Oct 2023 16:55:46 +0700 Subject: [PATCH 001/204] Refactor OMSSourceTypeValue. Dropped Objc Prefix in Interface Builder class name field --- ExampleApp/ExampleApp-Bridging-Header.h | 7 - .../CustomCreditCardFormViewController.h | 28 -- .../CustomCreditCardFormViewController.m | 143 ----------- .../OMSExampleProductDetailViewController.h | 13 - .../OMSExampleProductDetailViewController.m | 202 --------------- ExampleApp/Resources/Main.storyboard | 9 +- ExampleApp/Shared/OMSBaseViewController.m | 1 - .../PaymentSettingTableViewController.swift | 7 +- ExampleApp/Shared/Tools.swift | 28 +- ExampleApp/Swift/OMSBaseViewController.swift | 189 ++++++++++++++ .../Swift/ProductDetailViewController.swift | 2 - OmiseSDK.xcodeproj/project.pbxproj | 239 +----------------- .../AuthorizingPaymentViewController.swift | 47 +--- OmiseSDK/Capability.swift | 68 ++++- OmiseSDK/Client.swift | 2 +- OmiseSDK/Compatibility/OmiseCapability.swift | 74 ++++-- OmiseSDK/Compatibility/OmiseSource.swift | 36 ++- OmiseSDK/CreditCardFormViewController.swift | 3 +- OmiseSDK/Currency.swift | 145 +++++------ .../DuitNowOBWBankChooserViewController.swift | 2 - ...ontextInformationInputViewController.swift | 2 - OmiseSDK/FPXBankChooserViewController.swift | 2 - OmiseSDK/FPXFormViewController.swift | 2 - OmiseSDK/Globals.swift | 4 +- ...ntBankingSourceChooserViewController.swift | 3 +- ...tsNumberOfTermsChooserViewController.swift | 3 +- ...etBankingSourceChooserViewController.swift | 3 +- ...leBankingSourceChooserViewController.swift | 2 - OmiseSDK/OMSSourceTypeValue.swift | 65 +++++ OmiseSDK/OmiseSDK.h | 7 - OmiseSDK/PaymentChooserViewController.swift | 7 +- OmiseSDK/PaymentCreatorController.swift | 7 +- .../Resources/Base.lproj/OmiseSDK.storyboard | 35 ++- OmiseSDK/TrueMoneyFormViewController.swift | 2 - OmiseSDKObjc/OMSConstants.h | 69 ----- OmiseSDKObjc/OMSConstants.m | 64 ----- 36 files changed, 517 insertions(+), 1005 deletions(-) delete mode 100644 ExampleApp/ExampleApp-Bridging-Header.h delete mode 100644 ExampleApp/Objective-C/CustomCreditCardFormViewController.h delete mode 100644 ExampleApp/Objective-C/CustomCreditCardFormViewController.m delete mode 100644 ExampleApp/Objective-C/OMSExampleProductDetailViewController.h delete mode 100644 ExampleApp/Objective-C/OMSExampleProductDetailViewController.m create mode 100644 ExampleApp/Swift/OMSBaseViewController.swift create mode 100644 OmiseSDK/OMSSourceTypeValue.swift delete mode 100644 OmiseSDK/OmiseSDK.h delete mode 100644 OmiseSDKObjc/OMSConstants.h delete mode 100644 OmiseSDKObjc/OMSConstants.m diff --git a/ExampleApp/ExampleApp-Bridging-Header.h b/ExampleApp/ExampleApp-Bridging-Header.h deleted file mode 100644 index 585ade06..00000000 --- a/ExampleApp/ExampleApp-Bridging-Header.h +++ /dev/null @@ -1,7 +0,0 @@ -// -// Use this file to import your target's public headers that you would like to expose to Swift. -// - - -#import "OMSBaseViewController.h" - diff --git a/ExampleApp/Objective-C/CustomCreditCardFormViewController.h b/ExampleApp/Objective-C/CustomCreditCardFormViewController.h deleted file mode 100644 index 55cc17d8..00000000 --- a/ExampleApp/Objective-C/CustomCreditCardFormViewController.h +++ /dev/null @@ -1,28 +0,0 @@ -// -// OMSCustomCreditCardFormViewController.h -// ExampleApp (Objective-C) -// -// Created by Pitiphong Phongpattranont on 19/4/19. -// Copyright © 2019 Omise. All rights reserved. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -@class CustomCreditCardFormViewController, OMSToken; -@protocol OMSCustomCreditCardFormViewControllerDelegate - -- (void)customCreditCardFormViewController:(CustomCreditCardFormViewController *)controller didSucceedWithToken:(OMSToken *)token; -- (void)customCreditCardFormViewController:(CustomCreditCardFormViewController *)controller didFailWithError:(NSError *)error; - -@end - - -@interface CustomCreditCardFormViewController : UIViewController - -@property (weak, nonatomic) id delegate; - -@end - -NS_ASSUME_NONNULL_END diff --git a/ExampleApp/Objective-C/CustomCreditCardFormViewController.m b/ExampleApp/Objective-C/CustomCreditCardFormViewController.m deleted file mode 100644 index 8e20fc52..00000000 --- a/ExampleApp/Objective-C/CustomCreditCardFormViewController.m +++ /dev/null @@ -1,143 +0,0 @@ -#import "CustomCreditCardFormViewController.h" -#import - -@interface CustomCreditCardFormViewController () - -@property (strong, nonatomic) IBOutlet OMSCardNumberTextField *cardNumberField; -@property (strong, nonatomic) IBOutlet OMSCardNameTextField *cardNameField; -@property (strong, nonatomic) IBOutlet OMSCardExpiryDateTextField *cardExpiryField; -@property (strong, nonatomic) IBOutlet OMSCardCVVTextField *cardCVVField; -@property (strong, nonatomic) IBOutlet UIStackView *billingStackView; - -@property (strong, nonatomic) IBOutlet UIBarButtonItem *doneButton; - -@property (strong) OMSSDKClient *omiseClient; - -@end - -@implementation CustomCreditCardFormViewController - -- (void)loadView { - [super loadView]; - - if (!self.storyboard) { - if (@available(iOS 13, *)) { - self.view.backgroundColor = UIColor.systemBackgroundColor; - } else { - self.view.backgroundColor = UIColor.whiteColor; - } - - self.cardNumberField = [[OMSCardNumberTextField alloc] init]; - self.cardNumberField.translatesAutoresizingMaskIntoConstraints = false; - self.cardNumberField.placeholder = @"1234567812345678"; - self.cardNameField = [[OMSCardNameTextField alloc] init]; - self.cardNameField.translatesAutoresizingMaskIntoConstraints = false; - self.cardNameField.placeholder = @"John Appleseed"; - self.cardExpiryField = [[OMSCardExpiryDateTextField alloc] init]; - self.cardExpiryField.translatesAutoresizingMaskIntoConstraints = false; - self.cardExpiryField.placeholder = @"MM/yy Date Format"; - self.cardCVVField = [[OMSCardCVVTextField alloc] init]; - self.cardCVVField.translatesAutoresizingMaskIntoConstraints = false; - self.cardCVVField.placeholder = @"321"; - - UILabel *cardNumberLabel = [[UILabel alloc] init]; - cardNumberLabel.text = @"Card Number"; - cardNumberLabel.translatesAutoresizingMaskIntoConstraints = false; - UIStackView *cardNumberStackView = [[UIStackView alloc] initWithArrangedSubviews: @[cardNumberLabel, self.cardNumberField] ]; - UILabel *cardNameLabel = [[UILabel alloc] init]; - cardNameLabel.text = @"Card Name"; - cardNameLabel.translatesAutoresizingMaskIntoConstraints = false; - UIStackView *cardNameStackView = [[UIStackView alloc] initWithArrangedSubviews: @[cardNameLabel, self.cardNameField] ]; - UILabel *cardExpiryLabel = [[UILabel alloc] init]; - cardExpiryLabel.text = @"Card Expiry"; - cardExpiryLabel.translatesAutoresizingMaskIntoConstraints = false; - UIStackView *cardExpiryStackView = [[UIStackView alloc] initWithArrangedSubviews: @[cardExpiryLabel, self.cardExpiryField] ]; - UILabel *cardCVVLabel = [[UILabel alloc] init]; - cardCVVLabel.text = @"Card CVV"; - cardCVVLabel.translatesAutoresizingMaskIntoConstraints = false; - UIStackView *cardCVVStackView = [[UIStackView alloc] initWithArrangedSubviews: @[cardCVVLabel, self.cardCVVField] ]; - - UIStackView *lowerRowStackView = [[UIStackView alloc] initWithArrangedSubviews: @[cardExpiryStackView, cardCVVStackView]]; - - cardNumberStackView.axis = UILayoutConstraintAxisVertical; - cardNumberStackView.distribution = UIStackViewDistributionFill; - cardNumberStackView.alignment = UIStackViewAlignmentFill; - cardNumberStackView.spacing = 10; - cardNameStackView.axis = UILayoutConstraintAxisVertical; - cardNameStackView.distribution = UIStackViewDistributionFill; - cardNameStackView.alignment = UIStackViewAlignmentFill; - cardNameStackView.spacing = 10; - cardExpiryStackView.axis = UILayoutConstraintAxisVertical; - cardExpiryStackView.distribution = UIStackViewDistributionFill; - cardExpiryStackView.alignment = UIStackViewAlignmentFill; - cardExpiryStackView.spacing = 10; - cardCVVStackView.axis = UILayoutConstraintAxisVertical; - cardCVVStackView.distribution = UIStackViewDistributionFill; - cardCVVStackView.alignment = UIStackViewAlignmentFill; - cardCVVStackView.spacing = 10; - lowerRowStackView.axis = UILayoutConstraintAxisHorizontal; - lowerRowStackView.distribution = UIStackViewDistributionFillEqually; - lowerRowStackView.alignment = UIStackViewAlignmentFill; - lowerRowStackView.spacing = 10; - - - UIStackView *stackView = [[UIStackView alloc] initWithArrangedSubviews: @[cardNumberStackView, cardNameStackView, lowerRowStackView] ]; - stackView.translatesAutoresizingMaskIntoConstraints = false; - stackView.axis = UILayoutConstraintAxisVertical; - stackView.distribution = UIStackViewDistributionFill; - stackView.alignment = UIStackViewAlignmentFill; - stackView.spacing = 20; - - [self.view addSubview:stackView]; - [NSLayoutConstraint activateConstraints: - @[ - [stackView.leadingAnchor constraintEqualToAnchor:self.view.layoutMarginsGuide.leadingAnchor], - [stackView.trailingAnchor constraintEqualToAnchor:self.view.layoutMarginsGuide.trailingAnchor], - [stackView.topAnchor constraintEqualToAnchor:self.view.layoutMarginsGuide.topAnchor constant: 20], - [stackView.bottomAnchor constraintLessThanOrEqualToAnchor:self.view.layoutMarginsGuide.bottomAnchor], - ] - ]; - } -} - -- (void)viewDidLoad { - [super viewDidLoad]; - - self.omiseClient = [[OMSSDKClient alloc] initWithPublicKey:@"pkey_test_"]; - - if (!self.storyboard) { - UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave - target:self - action:@selector(proceed:)]; - self.navigationItem.rightBarButtonItem = saveButton; - self.doneButton = saveButton; - self.navigationItem.title = @"Custom Credit Card Form"; - } -} - -- (IBAction)proceed:(id)sender { - if (!self.cardNumberField.text.length || - !self.cardNameField.text.length || - !self.cardExpiryField.text.length || - !self.cardCVVField.text.length) { - return; - } - - OMSTokenRequest *tokenRequest = [[OMSTokenRequest alloc] initWithName:self.cardNameField.text - number:self.cardNumberField.text - expirationMonth:self.cardExpiryField.selectedMonth - expirationYear:self.cardExpiryField.selectedYear - securityCode:self.cardCVVField.text - city:nil - postalCode:nil]; - - [self.omiseClient sendTokenRequest:tokenRequest callback:^(OMSToken * _Nullable token, NSError * _Nullable error) { - if (token) { - [self.delegate customCreditCardFormViewController:self didSucceedWithToken:token]; - } else if (error) { - [self.delegate customCreditCardFormViewController:self didFailWithError:error]; - } - }]; -} - -@end diff --git a/ExampleApp/Objective-C/OMSExampleProductDetailViewController.h b/ExampleApp/Objective-C/OMSExampleProductDetailViewController.h deleted file mode 100644 index 97f932c0..00000000 --- a/ExampleApp/Objective-C/OMSExampleProductDetailViewController.h +++ /dev/null @@ -1,13 +0,0 @@ -@import UIKit; -@import OmiseSDK; - -#import "OMSBaseViewController.h" - - -NS_ASSUME_NONNULL_BEGIN - -@interface OMSExampleProductDetailViewController : OMSBaseViewController - -@end - -NS_ASSUME_NONNULL_END diff --git a/ExampleApp/Objective-C/OMSExampleProductDetailViewController.m b/ExampleApp/Objective-C/OMSExampleProductDetailViewController.m deleted file mode 100644 index 5de2843d..00000000 --- a/ExampleApp/Objective-C/OMSExampleProductDetailViewController.m +++ /dev/null @@ -1,202 +0,0 @@ -#import "OMSExampleProductDetailViewController.h" -#import -#import "CustomCreditCardFormViewController.h" -#import - - -NSString * const OMSPublicKey = @"<#Omise Public Key#>"; - - -@interface OMSExampleProductDetailViewController () - -@property (strong, nonatomic, nullable) OMSCapability *capability; - -@end - - -@implementation OMSExampleProductDetailViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - - OMSSDKClient *client = [[OMSSDKClient alloc] initWithPublicKey:OMSPublicKey]; - [client capabilityDataWithCompletionHandler:^(OMSCapability * _Nullable capability, NSError * _Nullable error) { - self.capability = capability; - }]; -} - -- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender { - if ([identifier isEqualToString:@"PresentCreditFormWithModal"] || - [identifier isEqualToString:@"ShowCreditForm"] || - [identifier isEqualToString:@"PresentPaymentCreator"] || - [identifier isEqualToString:@"ShowCreditFormWithCustomFields"]) { - return self.currentCodePathMode == OMSCodePathModeStoryboard; - } - - return YES; -} - -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { - if ([segue.identifier isEqualToString:@"PresentCreditFormWithModal"]) { - OMSCreditCardFormViewController *creditCardFormController = (OMSCreditCardFormViewController *)((UINavigationController *)segue.destinationViewController).topViewController; - creditCardFormController.publicKey = OMSPublicKey; - creditCardFormController.handleErrors = YES; - creditCardFormController.delegate = self; - } else if ([segue.identifier isEqualToString:@"ShowCreditForm"]) { - OMSCreditCardFormViewController *creditCardFormController = (OMSCreditCardFormViewController *)segue.destinationViewController; - creditCardFormController.publicKey = OMSPublicKey; - creditCardFormController.handleErrors = YES; - creditCardFormController.delegate = self; - } else if ([segue.identifier isEqualToString:@"PresentPaymentCreator"]) { - OMSPaymentCreatorController *paymentCreatorController = (OMSPaymentCreatorController *)segue.destinationViewController; - paymentCreatorController.publicKey = OMSPublicKey; - paymentCreatorController.paymentAmount = self.paymentAmount; - paymentCreatorController.paymentCurrencyCode = self.paymentCurrencyCode; - if (self.usesCapabilityDataForPaymentMethods && self.capability) { - [paymentCreatorController applyPaymentMethodsFrom:self.capability]; - } else { - paymentCreatorController.allowedPaymentMethods = self.allowedPaymentMethods; - } - paymentCreatorController.paymentDelegate = self; - } else if ([segue.identifier isEqualToString:@"ShowCreditFormWithCustomFields"]) { - CustomCreditCardFormViewController *customCreditCardFormViewController = (CustomCreditCardFormViewController *)segue.destinationViewController; - customCreditCardFormViewController.delegate = self; - } else { - [super prepareForSegue:segue sender:sender]; - } -} - -- (IBAction)showModalCreditCardForm:(id)sender { - if (self.currentCodePathMode == OMSCodePathModeStoryboard) { - return; - } - OMSCreditCardFormViewController *creditCardFormController = [OMSCreditCardFormViewController creditCardFormViewControllerWithPublicKey:OMSPublicKey]; - creditCardFormController.handleErrors = YES; - creditCardFormController.delegate = self; - UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:creditCardFormController]; - [self presentViewController:navigationController animated:YES completion:NULL]; -} - -- (IBAction)showCreditCardForm:(id)sender { - if (self.currentCodePathMode == OMSCodePathModeStoryboard) { - return; - } - OMSCreditCardFormViewController *creditCardFormController = [OMSCreditCardFormViewController creditCardFormViewControllerWithPublicKey:OMSPublicKey]; - creditCardFormController.handleErrors = YES; - creditCardFormController.delegate = self; - [self showViewController:creditCardFormController sender:self]; -} - -- (IBAction)showModalPaymentCreator:(id)sender { - if (self.currentCodePathMode == OMSCodePathModeStoryboard) { - return; - } - OMSPaymentCreatorController *paymentCreatorController = [OMSPaymentCreatorController - paymentCreatorControllerWithPublicKey:OMSPublicKey amount:self.paymentAmount currency:self.paymentCurrencyCode allowedPaymentMethods:self.allowedPaymentMethods paymentDelegate:self]; - [self presentViewController:paymentCreatorController animated:YES completion:NULL]; -} - -- (IBAction)showCustomCreditCardForm:(UIButton *)sender { - if (self.currentCodePathMode == OMSCodePathModeStoryboard) { - return; - } - - CustomCreditCardFormViewController *customCreditCardFormViewController = [[CustomCreditCardFormViewController alloc] init]; - customCreditCardFormViewController.delegate = self; - [self showViewController:customCreditCardFormViewController sender:sender]; -} - -- (IBAction)authorizingPayment:(UIBarButtonItem *)sender { - UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Authorizing Payment" message:@"Please input your given authorized URL" preferredStyle:UIAlertControllerStyleAlert]; - [alertController addTextFieldWithConfigurationHandler:nil]; - [alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]]; - [alertController addAction:[UIAlertAction actionWithTitle:@"Go" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { - UITextField *textField = alertController.textFields.firstObject; - NSURL *url = [[NSURL alloc] initWithString:textField.text]; - - NSURLComponents *expectedReturnURL = [[NSURLComponents alloc] initWithString:@"http://www.example.com/orders"]; - UINavigationController *authorizingPaymentViewController = [OMSAuthorizingPaymentViewController authorizingPaymentViewControllerNavigationWithAuthorizedURL:url expectedReturnURLPatterns:@[expectedReturnURL] delegate:self]; - [self presentViewController:authorizingPaymentViewController animated:YES completion:nil]; - }]]; - - [self presentViewController:alertController animated:YES completion:nil]; -} - - -#pragma mark - Credit Card Form Controller Delegate methods - -- (void)creditCardFormViewController:(OMSCreditCardFormViewController *)controller didSucceedWithToken:(OMSToken *)token { - [self dismissFormWithCompletion:^{ - NSString *alertMessage = [NSString stringWithFormat:@"The token with id of %@ was successfuly created. Please send this id to server to create a charge.", token.tokenID]; - UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Token created" message:alertMessage preferredStyle:UIAlertControllerStyleAlert]; - [alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:nil]]; - }]; -} - -- (void)creditCardFormViewController:(OMSCreditCardFormViewController *)controller didFailWithError:(NSError *)error { - NSLog(@"%@", error.localizedDescription); - [self dismissForm]; -} - -- (void)creditCardFormViewControllerDidCancel:(OMSCreditCardFormViewController *)controller { - [self dismissForm]; -} - - -#pragma mark - Payment Creator Controller Delegate methods - -- (void)authorizingPaymentViewController:(OMSAuthorizingPaymentViewController *)viewController didCompleteAuthorizingPaymentWithRedirectedURL:(NSURL *)redirectedURL { - NSLog(@"%@", redirectedURL); - [self dismissForm]; -} - -- (void)authorizingPaymentViewControllerDidCancel:(OMSAuthorizingPaymentViewController *)viewController { - [self dismissForm]; -} - - -#pragma mark - Payment Creator Controller Delegate methods - -- (void)paymentCreatorControllerDidCancel:(OMSPaymentCreatorController *)paymentCreatorController { - [self dismissForm]; -} - -- (void)paymentCreatorController:(OMSPaymentCreatorController *)paymentCreatorController didCreateToken:(OMSToken *)token { - [self dismissFormWithCompletion:^{ - NSString *alertMessage = [NSString stringWithFormat:@"The token with id of %@ was successfuly created. Please send this id to server to create a charge.", token.tokenID]; - UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Token created" message:alertMessage preferredStyle:UIAlertControllerStyleAlert]; - [alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:nil]]; - }];} - -- (void)paymentCreatorController:(OMSPaymentCreatorController *)paymentCreatorController didCreateSource:(OMSSource * _Nonnull)source { - [self dismissFormWithCompletion:^{ - NSString *alertMessage = [NSString stringWithFormat:@"The source with id of %@ was successfuly created. Please send this id to server to create a charge.", source.sourcdID]; - UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Source created" message:alertMessage preferredStyle:UIAlertControllerStyleAlert]; - [alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:nil]]; - }];} - -- (void)paymentCreatorController:(OMSPaymentCreatorController *)paymentCreatorController didFailWithError:(NSError *)error { - [self dismissForm]; -} - - -#pragma mark - Custom Credit Card Form Controller Delegate methods - -- (void)customCreditCardFormViewController:(CustomCreditCardFormViewController *)controller didSucceedWithToken:(OMSToken *)token { - [self dismissFormWithCompletion:^{ - NSString *alertMessage = [NSString stringWithFormat:@"The token with id of %@ was successfuly created. Please send this id to server to create a charge.", token.tokenID]; - UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Token created" message:alertMessage preferredStyle:UIAlertControllerStyleAlert]; - [alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:nil]]; - }]; -} - -- (void)customCreditCardFormViewController:(CustomCreditCardFormViewController *)controller didFailWithError:(NSError *)error { - NSLog(@"%@", error.localizedDescription); - [self dismissForm]; -} - - -@end - - diff --git a/ExampleApp/Resources/Main.storyboard b/ExampleApp/Resources/Main.storyboard index 4339475b..b44e504f 100644 --- a/ExampleApp/Resources/Main.storyboard +++ b/ExampleApp/Resources/Main.storyboard @@ -1,8 +1,9 @@ - + - + + @@ -10,7 +11,7 @@ - + @@ -1352,7 +1353,7 @@ You can present via either Storyboard or Code and you can see the code in the Ex - + diff --git a/ExampleApp/Shared/OMSBaseViewController.m b/ExampleApp/Shared/OMSBaseViewController.m index d50f8d40..968baade 100644 --- a/ExampleApp/Shared/OMSBaseViewController.m +++ b/ExampleApp/Shared/OMSBaseViewController.m @@ -1,5 +1,4 @@ #import "OMSBaseViewController.h" -#import @interface OMSBaseViewController () diff --git a/ExampleApp/Shared/PaymentSettingTableViewController.swift b/ExampleApp/Shared/PaymentSettingTableViewController.swift index 69d5521d..2abaac62 100644 --- a/ExampleApp/Shared/PaymentSettingTableViewController.swift +++ b/ExampleApp/Shared/PaymentSettingTableViewController.swift @@ -33,9 +33,8 @@ class PaymentSettingTableViewController: UITableViewController { amountField.text = amountFormatter.string(from: NSNumber(value: currentCurrency.convert(fromSubunit: currentAmount))) } } - @objc(currentCurrencyCode) - // swiftlint:disable:next attributes identifier_name - var __currentCurrencyCode: String { + + var currentCurrencyCode: String { get { return currentCurrency.code } @@ -55,7 +54,7 @@ class PaymentSettingTableViewController: UITableViewController { } } - @objc var allowedPaymentMethods: Set = [] { + var allowedPaymentMethods: Set = [] { willSet { guard isViewLoaded else { return diff --git a/ExampleApp/Shared/Tools.swift b/ExampleApp/Shared/Tools.swift index 426cefe5..3efd9fd0 100644 --- a/ExampleApp/Shared/Tools.swift +++ b/ExampleApp/Shared/Tools.swift @@ -33,30 +33,30 @@ struct PaymentPreset { @objc class Tool: NSObject { - @objc static let thailandPaymentAmount: Int64 = PaymentPreset.thailandPreset.paymentAmount - @objc static let thailandPaymentCurrency: String = PaymentPreset.thailandPreset.paymentCurrency.code - @objc static let thailandAllowedPaymentMethods: [OMSSourceTypeValue] = PaymentPreset.thailandPreset.allowedPaymentMethods + static let thailandPaymentAmount: Int64 = PaymentPreset.thailandPreset.paymentAmount + static let thailandPaymentCurrency: String = PaymentPreset.thailandPreset.paymentCurrency.code + static let thailandAllowedPaymentMethods: [OMSSourceTypeValue] = PaymentPreset.thailandPreset.allowedPaymentMethods - @objc static let japanPaymentAmount: Int64 = PaymentPreset.japanPreset.paymentAmount - @objc static let japanPaymentCurrency: String = PaymentPreset.japanPreset.paymentCurrency.code - @objc static let japanAllowedPaymentMethods: [OMSSourceTypeValue] = PaymentPreset.japanPreset.allowedPaymentMethods + static let japanPaymentAmount: Int64 = PaymentPreset.japanPreset.paymentAmount + static let japanPaymentCurrency: String = PaymentPreset.japanPreset.paymentCurrency.code + static let japanAllowedPaymentMethods: [OMSSourceTypeValue] = PaymentPreset.japanPreset.allowedPaymentMethods - @objc static let singaporePaymentAmount: Int64 = PaymentPreset.singaporePreset.paymentAmount - @objc static let singaporePaymentCurrency: String = PaymentPreset.singaporePreset.paymentCurrency.code - @objc static let singaporeAllowedPaymentMethods: [OMSSourceTypeValue] = PaymentPreset.singaporePreset.allowedPaymentMethods + static let singaporePaymentAmount: Int64 = PaymentPreset.singaporePreset.paymentAmount + static let singaporePaymentCurrency: String = PaymentPreset.singaporePreset.paymentCurrency.code + static let singaporeAllowedPaymentMethods: [OMSSourceTypeValue] = PaymentPreset.singaporePreset.allowedPaymentMethods - @objc static let malaysiaPaymentAmount: Int64 = PaymentPreset.malaysiaPreset.paymentAmount - @objc static let malaysiaPaymentCurrency: String = PaymentPreset.malaysiaPreset.paymentCurrency.code - @objc static let malaysiaAllowedPaymentMethods: [OMSSourceTypeValue] = PaymentPreset.malaysiaPreset.allowedPaymentMethods + static let malaysiaPaymentAmount: Int64 = PaymentPreset.malaysiaPreset.paymentAmount + static let malaysiaPaymentCurrency: String = PaymentPreset.malaysiaPreset.paymentCurrency.code + static let malaysiaAllowedPaymentMethods: [OMSSourceTypeValue] = PaymentPreset.malaysiaPreset.allowedPaymentMethods - @objc static func imageWith(size: CGSize, color: UIColor) -> UIImage? { + static func imageWith(size: CGSize, color: UIColor) -> UIImage? { return Tool.imageWith(size: size) { (context) in context.setFillColor(color.cgColor) context.fill(CGRect(origin: .zero, size: size)) } } - @objc static func imageWith(size: CGSize, actions: (CGContext) -> Void) -> UIImage? { + static func imageWith(size: CGSize, actions: (CGContext) -> Void) -> UIImage? { let renderer = UIGraphicsImageRenderer(size: size) return renderer.image { context in actions(context.cgContext) diff --git a/ExampleApp/Swift/OMSBaseViewController.swift b/ExampleApp/Swift/OMSBaseViewController.swift new file mode 100644 index 00000000..bb3792f4 --- /dev/null +++ b/ExampleApp/Swift/OMSBaseViewController.swift @@ -0,0 +1,189 @@ +// +// OMSBaseViewController.swift +// OmiseSDK +// +// Created by Andrei Solovev on 4/10/23. +// Copyright © 2023 Omise. All rights reserved. +// + +import UIKit +import OmiseSDK + +enum OMSCodePathMode { + case storyboard + case code +} + +class OMSBaseViewController: UIViewController { + + @IBOutlet private var modeChooser: UISegmentedControl! + + var currentCodePathMode: OMSCodePathMode = .storyboard + var paymentAmount: Int64 = 0 + var paymentCurrencyCode: String = "" + var usesCapabilityDataForPaymentMethods = false + var allowedPaymentMethods: [OMSSourceTypeValue] = [] + + required init?(coder: NSCoder) { + self.usesCapabilityDataForPaymentMethods = true + super.init(coder: coder) + } + + override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { + self.usesCapabilityDataForPaymentMethods = true + super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) + } + override func viewDidLoad() { + super.viewDidLoad() + + // Workaround of iOS 12 bug on the tint color + self.view.tintColor = nil + self.navigationController?.navigationBar.tintColor = nil + + updateUIColors() + + let localeCountryCode: String? = { + if #available(iOS 16, *) { + return Locale.current.region?.identifier + } else { + return Locale.current.regionCode + } + }() + + switch localeCountryCode { + case "JP": + self.paymentAmount = Tool.japanPaymentAmount + self.paymentCurrencyCode = Tool.japanPaymentCurrency + self.allowedPaymentMethods = Tool.japanAllowedPaymentMethods + case "SG": + self.paymentAmount = Tool.singaporePaymentAmount + self.paymentCurrencyCode = Tool.singaporePaymentCurrency + self.allowedPaymentMethods = Tool.singaporeAllowedPaymentMethods + case "MY": + self.paymentAmount = Tool.malaysiaPaymentAmount + self.paymentCurrencyCode = Tool.malaysiaPaymentCurrency + self.allowedPaymentMethods = Tool.malaysiaAllowedPaymentMethods + default: + self.paymentAmount = Tool.thailandPaymentAmount + self.paymentCurrencyCode = Tool.thailandPaymentCurrency + self.allowedPaymentMethods = Tool.thailandAllowedPaymentMethods + } + } + + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + super.prepare(for: segue, sender: sender) + if segue.identifier == "PresentPaymentSettingScene", + let settingNavigationController = segue.destination as? UINavigationController, + let settingViewController = settingNavigationController.topViewController as? PaymentSettingTableViewController { + settingViewController.currentAmount = self.paymentAmount + settingViewController.currentCurrencyCode = self.paymentCurrencyCode + settingViewController.usesCapabilityDataForPaymentMethods = self.usesCapabilityDataForPaymentMethods + settingViewController.allowedPaymentMethods = Set(self.allowedPaymentMethods) + } + } + override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { + super.traitCollectionDidChange(previousTraitCollection) + updateUIColors() + } + + // swiftlint:disable:next function_body_length + func updateUIColors() { + var modeChooserDefaultBackgroundColor: UIColor = .white + + if #available(iOS 13.0, *) { + modeChooserDefaultBackgroundColor = .systemBackground + } + + if #available(iOS 15.0, *) { + let navigationBarAppearance = UINavigationBarAppearance() + navigationBarAppearance.configureWithOpaqueBackground() + navigationBarAppearance.titleTextAttributes = [ + NSAttributedString.Key.foregroundColor: UIColor.label + ] + self.navigationItem.scrollEdgeAppearance = navigationBarAppearance + self.navigationItem.standardAppearance = navigationBarAppearance + self.navigationItem.compactAppearance = navigationBarAppearance + + } else { + let emptyImage = Tool.imageWith(size: CGSize(width: 1.0, height: 1.0), + color: modeChooserDefaultBackgroundColor) + self.navigationController?.navigationBar.setBackgroundImage(emptyImage, for: .any, barMetrics: .default) + self.navigationController?.navigationBar.setBackgroundImage(emptyImage, for: .any, barMetrics: .compact) + self.navigationController?.navigationBar.shadowImage = emptyImage + } + + let selectedModeBackgroundImage = Tool.imageWith(size: CGSize(width: 1.0, height: 1.0)) { context in + context.setFillColor(modeChooserDefaultBackgroundColor.cgColor) + context.fill(CGRect(x: 0.0, y: 0.0, width: 1.0, height: 40.0)) + context.setFillColor(self.view.tintColor.cgColor) + context.fill(CGRect(x: 0.0, y: 40.0, width: 1.0, height: 1.0)) + } + + self.modeChooser.setBackgroundImage(selectedModeBackgroundImage, for: .selected, barMetrics: .default) + + let normalModeBackgroundImage = Tool.imageWith(size: CGSize(width: 1.0, height: 41.0), color: modeChooserDefaultBackgroundColor) + + self.modeChooser.setBackgroundImage(normalModeBackgroundImage, for: .normal, barMetrics: .default) + self.modeChooser.setBackgroundImage(normalModeBackgroundImage, for: .highlighted, barMetrics: .default) + + // swiftlint:disable line_length + self.modeChooser.setDividerImage(normalModeBackgroundImage, forLeftSegmentState: .selected, rightSegmentState: .normal, barMetrics: .default) + self.modeChooser.setDividerImage(normalModeBackgroundImage, forLeftSegmentState: .normal, rightSegmentState: .selected, barMetrics: .default) + self.modeChooser.setDividerImage(normalModeBackgroundImage, forLeftSegmentState: .highlighted, rightSegmentState: .normal, barMetrics: .default) + self.modeChooser.setDividerImage(normalModeBackgroundImage, forLeftSegmentState: .normal, rightSegmentState: .highlighted, barMetrics: .default) + self.modeChooser.setDividerImage(normalModeBackgroundImage, forLeftSegmentState: .highlighted, rightSegmentState: .selected, barMetrics: .default) + self.modeChooser.setDividerImage(normalModeBackgroundImage, forLeftSegmentState: .normal, rightSegmentState: .normal, barMetrics: .default) + // swiftlint:enable line_length + + let highlightedTitleAttributes: [NSAttributedString.Key: Any] = [ + NSAttributedString.Key.foregroundColor: self.view.tintColor ?? UIColor.lightGray, + NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .callout) + ] + + var normalTitleAttributes: [NSAttributedString.Key: Any] = [ + NSAttributedString.Key.foregroundColor: UIColor.darkText, + NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .callout) + ] + + if #available(iOS 13.0, *) { + normalTitleAttributes = [ + NSAttributedString.Key.foregroundColor: UIColor.label, + NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .callout) + ] + } + + self.modeChooser.setTitleTextAttributes(normalTitleAttributes, for: .normal) + self.modeChooser.setTitleTextAttributes(normalTitleAttributes, for: .highlighted) + self.modeChooser.setTitleTextAttributes(highlightedTitleAttributes, for: .selected) + } + + func dismissForm(_ completion: (() -> Void)? = nil) { + if self.presentedViewController != nil { + self.dismiss(animated: true, completion: completion) + } else { + self.navigationController?.popToViewController(self, animated: true) + completion?() + } + } + + @IBAction private func updatePaymentInformationFromSetting(_ sender: UIStoryboardSegue) { + + guard let settingViewController = sender.source as? PaymentSettingTableViewController else { + return + } + + self.paymentAmount = settingViewController.currentAmount + self.paymentCurrencyCode = settingViewController.currentCurrencyCode + self.usesCapabilityDataForPaymentMethods = settingViewController.usesCapabilityDataForPaymentMethods + self.allowedPaymentMethods = Array(settingViewController.allowedPaymentMethods) + } + + @IBAction private func codePathModeChangedHandler(_ sender: UISegmentedControl) { + if sender.selectedSegmentIndex == 1 { + self.currentCodePathMode = .code + } else { + self.currentCodePathMode = .storyboard + } + } + +} diff --git a/ExampleApp/Swift/ProductDetailViewController.swift b/ExampleApp/Swift/ProductDetailViewController.swift index 4ca66296..a6b4cddc 100644 --- a/ExampleApp/Swift/ProductDetailViewController.swift +++ b/ExampleApp/Swift/ProductDetailViewController.swift @@ -1,8 +1,6 @@ import UIKit import OmiseSDK -@objc(OMSExampleProductDetailViewController) -// swiftlint:disable:next attributes class ProductDetailViewController: OMSBaseViewController { private let publicKey = LocalConfig.default.publicKey diff --git a/OmiseSDK.xcodeproj/project.pbxproj b/OmiseSDK.xcodeproj/project.pbxproj index 3b381e40..c80676e8 100644 --- a/OmiseSDK.xcodeproj/project.pbxproj +++ b/OmiseSDK.xcodeproj/project.pbxproj @@ -18,7 +18,6 @@ 224460041CF43A1200801D0F /* SDKTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 225931561CE4745200841B86 /* SDKTestCase.swift */; settings = {COMPILER_FLAGS = "-Wnodeprecated-declarations"; }; }; 224460051CF43A1500801D0F /* CardNumberTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 225931541CE4743A00841B86 /* CardNumberTest.swift */; settings = {COMPILER_FLAGS = "-Wnodeprecated-declarations"; }; }; 2244600A1CF441DC00801D0F /* TokenRequestDelegateDummy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 224460091CF441DC00801D0F /* TokenRequestDelegateDummy.swift */; settings = {COMPILER_FLAGS = "-Wnodeprecated-declarations"; }; }; - 2259311C1CE3210700841B86 /* OmiseSDK.h in Headers */ = {isa = PBXBuildFile; fileRef = 2259311B1CE3210700841B86 /* OmiseSDK.h */; settings = {ATTRIBUTES = (Public, ); }; }; 2259314E1CE46E5700841B86 /* CardBrand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2259314D1CE46E5700841B86 /* CardBrand.swift */; }; 225931501CE46F7F00841B86 /* CardNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2259314F1CE46F7F00841B86 /* CardNumber.swift */; }; 229E14581D0EBAB5000511DE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 229E14541D0EBAB5000511DE /* AppDelegate.swift */; }; @@ -28,7 +27,6 @@ 73F9BA4725E50F4700F55CA8 /* AdaptableDynamicTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73F9BA4625E50F4700F55CA8 /* AdaptableDynamicTableViewController.swift */; }; 73F9BA4B25E6053700F55CA8 /* FPXFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73F9BA4A25E6053700F55CA8 /* FPXFormViewController.swift */; }; 7502CA532A3011A900766E7D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7502CA562A3011A900766E7D /* LaunchScreen.storyboard */; }; - 7502CA542A3011A900766E7D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7502CA562A3011A900766E7D /* LaunchScreen.storyboard */; }; 7502CA5F2A31A7D600766E7D /* CountryListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7502CA5E2A31A7D600766E7D /* CountryListViewController.swift */; }; 7502CA602A31A7D600766E7D /* CountryListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7502CA5E2A31A7D600766E7D /* CountryListViewController.swift */; }; 7502CA622A31A7E100766E7D /* CountryListViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7502CA612A31A7E100766E7D /* CountryListViewModelProtocol.swift */; }; @@ -45,6 +43,8 @@ 7509D4EF2A1D1F9F0050AB38 /* OmiseTestSDK in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 7509D4ED2A1D1F9F0050AB38 /* OmiseTestSDK */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 7509D4F42A1D2C3E0050AB38 /* AtomeFormViewModelMockup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7509D4E32A1C89F10050AB38 /* AtomeFormViewModelMockup.swift */; }; 7509D4F52A1D2F550050AB38 /* AtomeFormViewContextMockup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7509D4E12A1C876B0050AB38 /* AtomeFormViewContextMockup.swift */; }; + 752E40C42ACD420C00B62A49 /* OMSSourceTypeValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 752E40C32ACD420C00B62A49 /* OMSSourceTypeValue.swift */; }; + 752E40C72ACD429B00B62A49 /* OMSBaseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 752E40C52ACD426E00B62A49 /* OMSBaseViewController.swift */; }; 753279382A31B40F008048AD /* CountryListViewModelMockup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 753279372A31B40F008048AD /* CountryListViewModelMockup.swift */; }; 75348D4E29C3FCC70008C8A3 /* Bundle+OmiseSDK.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75348D4D29C3FCC70008C8A3 /* Bundle+OmiseSDK.swift */; }; 75405A782A25D327008C21F6 /* String+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75405A772A25D327008C21F6 /* String+Helpers.swift */; }; @@ -79,7 +79,6 @@ 75DAD88E2A0BA5130098AF96 /* OmiseTestSDK in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 75DAD88B2A0BA5130098AF96 /* OmiseTestSDK */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 75DAD8902A0BB8D80098AF96 /* LocalConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75DAD88F2A0BB8D80098AF96 /* LocalConfig.swift */; }; 75F2A0182A0BD0D40038FA54 /* Config.local.plist in Resources */ = {isa = PBXBuildFile; fileRef = 75DAD8922A0BC9540098AF96 /* Config.local.plist */; }; - 75F2A0192A0BD0D40038FA54 /* Config.local.plist in Resources */ = {isa = PBXBuildFile; fileRef = 75DAD8922A0BC9540098AF96 /* Config.local.plist */; }; 75F2A0932A13B0B10038FA54 /* OmiseSDKUITestsApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0922A13B0B10038FA54 /* OmiseSDKUITestsApp.swift */; }; 75F2A0952A13B0B10038FA54 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0942A13B0B10038FA54 /* ContentView.swift */; }; 75F2A09A2A13B0B10038FA54 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 75F2A0992A13B0B10038FA54 /* Preview Assets.xcassets */; }; @@ -114,26 +113,16 @@ 8A3C10582159FCE900BEFD8A /* BadRequestAPIErrorParsingTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A3C10572159FCE900BEFD8A /* BadRequestAPIErrorParsingTestCase.swift */; }; 8A40DA29216B441E00749F45 /* PaymentSettingTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A7A9EBC2166160300F12D86 /* PaymentSettingTableViewController.swift */; }; 8A40DA2B216B53E900749F45 /* Tools.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A40DA2A216B53E900749F45 /* Tools.swift */; }; - 8A40DA2C216B53E900749F45 /* Tools.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A40DA2A216B53E900749F45 /* Tools.swift */; }; 8A43454720DBAE76005C5C94 /* PANModelTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A43454620DBAE76005C5C94 /* PANModelTestCase.swift */; }; - 8A43FEAA2269BD8A002E89EC /* CustomCreditCardFormViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A43FEA92269BD8A002E89EC /* CustomCreditCardFormViewController.m */; }; 8A47173A20AAB0F40022733A /* Token.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A47173920AAB0F40022733A /* Token.swift */; }; 8A47173D20AAB11B0022733A /* Source.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A47173C20AAB11B0022733A /* Source.swift */; }; 8A4F7CB920A9C0FD001C441A /* Object.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A4F7CB820A9C0FD001C441A /* Object.swift */; }; 8A5D59811D5317DD005D3346 /* OmiseSDK.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8A5D59831D5317DD005D3346 /* OmiseSDK.storyboard */; }; 8A60619A20B2A8D400CF90D5 /* PAN.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A60619920B2A8D400CF90D5 /* PAN.swift */; }; - 8A6AA06D216B958100E49E5E /* OMSBaseViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A6AA06B216B957D00E49E5E /* OMSBaseViewController.m */; }; - 8A6AA06E216B9DAE00E49E5E /* OMSBaseViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A6AA06B216B957D00E49E5E /* OMSBaseViewController.m */; }; - 8A723A562164D7B100D902F5 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 229E14541D0EBAB5000511DE /* AppDelegate.swift */; }; - 8A723A5C2164D7B100D902F5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 22E0DBD61D0EBE2E00472C74 /* Assets.xcassets */; }; - 8A723A5F2164D7B100D902F5 /* OmiseSDK.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 225931181CE3210700841B86 /* OmiseSDK.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 8A723A692164D87B00D902F5 /* OMSExampleProductDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AF6A1D920E4FEBE00AC5625 /* OMSExampleProductDetailViewController.m */; }; 8A72CD5E2162358400F14F76 /* PaymentOptionTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A72CD5D2162358400F14F76 /* PaymentOptionTableViewCell.swift */; }; 8A7567652178956800C684C9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8A7567642178956800C684C9 /* Main.storyboard */; }; - 8A7567662178956800C684C9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8A7567642178956800C684C9 /* Main.storyboard */; }; 8A76791F214663560085DE3C /* PaymentUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A76791E214663560085DE3C /* PaymentUI.swift */; }; 8A776647214A5FC60029D166 /* NoticeView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8A776646214A5FC60029D166 /* NoticeView.xib */; }; - 8A7A9EBE2166160300F12D86 /* PaymentSettingTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A7A9EBC2166160300F12D86 /* PaymentSettingTableViewController.swift */; }; 8A7A9EC0216642D100F12D86 /* Swift Version Compatibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A7A9EBF216642D100F12D86 /* Swift Version Compatibility.swift */; }; 8A87DBCB226DA404001596F1 /* OmiseCapability.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A87DBCA226DA404001596F1 /* OmiseCapability.swift */; }; 8AC1D3A32139224D0051F966 /* InternetBankingSourceChooserViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AC1D3A22139224D0051F966 /* InternetBankingSourceChooserViewController.swift */; }; @@ -164,18 +153,9 @@ F3497368254C067000D05C7B /* MobileBankingSourceChooserViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3497367254C066F00D05C7B /* MobileBankingSourceChooserViewController.swift */; }; F615CBF8261565D600E1A2D9 /* CardExpiryDatePickerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F615CBF7261565D600E1A2D9 /* CardExpiryDatePickerTests.swift */; }; F6614CD6243DB8E7005B656E /* TrueMoneyFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F6614CD5243DB8E7005B656E /* TrueMoneyFormViewController.swift */; }; - F6FE862C25E3B02300C7A4DE /* OMSConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = F6FE862A25E3B02300C7A4DE /* OMSConstants.m */; }; - F6FE862D25E3B02300C7A4DE /* OMSConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = F6FE862B25E3B02300C7A4DE /* OMSConstants.h */; settings = {ATTRIBUTES = (Public, ); }; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - 8A723A522164D7B100D902F5 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 2259310F1CE3210700841B86 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 225931171CE3210700841B86; - remoteInfo = OmiseSDK; - }; 8A7F8B0A20C55312008F4D08 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 2259310F1CE3210700841B86 /* Project object */; @@ -226,17 +206,6 @@ name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; }; - 8A723A5E2164D7B100D902F5 /* Embed Frameworks */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 10; - files = ( - 8A723A5F2164D7B100D902F5 /* OmiseSDK.framework in Embed Frameworks */, - ); - name = "Embed Frameworks"; - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ @@ -251,7 +220,6 @@ 22445FFB1CF41DD300801D0F /* Globals.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Globals.swift; sourceTree = ""; }; 224460091CF441DC00801D0F /* TokenRequestDelegateDummy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TokenRequestDelegateDummy.swift; sourceTree = ""; }; 225931181CE3210700841B86 /* OmiseSDK.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OmiseSDK.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 2259311B1CE3210700841B86 /* OmiseSDK.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OmiseSDK.h; sourceTree = ""; }; 2259311D1CE3210700841B86 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 2259314D1CE46E5700841B86 /* CardBrand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardBrand.swift; sourceTree = ""; }; 2259314F1CE46F7F00841B86 /* CardNumber.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardNumber.swift; sourceTree = ""; }; @@ -277,6 +245,8 @@ 7509D4E12A1C876B0050AB38 /* AtomeFormViewContextMockup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtomeFormViewContextMockup.swift; sourceTree = ""; }; 7509D4E32A1C89F10050AB38 /* AtomeFormViewModelMockup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtomeFormViewModelMockup.swift; sourceTree = ""; }; 7509D4E62A1C8E3D0050AB38 /* AtomeFormViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtomeFormViewModelTests.swift; sourceTree = ""; }; + 752E40C32ACD420C00B62A49 /* OMSSourceTypeValue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OMSSourceTypeValue.swift; sourceTree = ""; }; + 752E40C52ACD426E00B62A49 /* OMSBaseViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OMSBaseViewController.swift; sourceTree = ""; }; 753279372A31B40F008048AD /* CountryListViewModelMockup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CountryListViewModelMockup.swift; sourceTree = ""; }; 75348D4D29C3FCC70008C8A3 /* Bundle+OmiseSDK.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Bundle+OmiseSDK.swift"; sourceTree = ""; }; 75405A772A25D327008C21F6 /* String+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Helpers.swift"; sourceTree = ""; }; @@ -335,8 +305,6 @@ 8A40DA2A216B53E900749F45 /* Tools.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tools.swift; sourceTree = ""; }; 8A429E7A2109A3AE007C230F /* PaymentInformationTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentInformationTestCase.swift; sourceTree = ""; }; 8A43454620DBAE76005C5C94 /* PANModelTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PANModelTestCase.swift; sourceTree = ""; }; - 8A43FEA82269BD8A002E89EC /* CustomCreditCardFormViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CustomCreditCardFormViewController.h; sourceTree = ""; }; - 8A43FEA92269BD8A002E89EC /* CustomCreditCardFormViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CustomCreditCardFormViewController.m; sourceTree = ""; }; 8A47173920AAB0F40022733A /* Token.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Token.swift; sourceTree = ""; }; 8A47173C20AAB11B0022733A /* Source.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Source.swift; sourceTree = ""; }; 8A4F7CB820A9C0FD001C441A /* Object.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Object.swift; sourceTree = ""; }; @@ -346,7 +314,6 @@ 8A60619920B2A8D400CF90D5 /* PAN.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PAN.swift; sourceTree = ""; }; 8A6AA06A216B957D00E49E5E /* OMSBaseViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OMSBaseViewController.h; sourceTree = ""; }; 8A6AA06B216B957D00E49E5E /* OMSBaseViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OMSBaseViewController.m; sourceTree = ""; }; - 8A723A632164D7B100D902F5 /* ExampleApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ExampleApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 8A72CD5D2162358400F14F76 /* PaymentOptionTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentOptionTableViewCell.swift; sourceTree = ""; }; 8A7567642178956800C684C9 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; }; 8A76791E214663560085DE3C /* PaymentUI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentUI.swift; sourceTree = ""; }; @@ -368,9 +335,6 @@ 8AF5517B213D4C0100D61C98 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = en; path = en.lproj/Localizable.stringsdict; sourceTree = ""; }; 8AF56E5F2268650D0097CFEE /* OmiseTextFieldCompatability.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OmiseTextFieldCompatability.swift; sourceTree = ""; }; 8AF56E61226878070097CFEE /* CustomCreditCardFormViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomCreditCardFormViewController.swift; sourceTree = ""; }; - 8AF6A1D720E4FEBE00AC5625 /* ExampleApp-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ExampleApp-Bridging-Header.h"; sourceTree = ""; }; - 8AF6A1D820E4FEBE00AC5625 /* OMSExampleProductDetailViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OMSExampleProductDetailViewController.h; sourceTree = ""; }; - 8AF6A1D920E4FEBE00AC5625 /* OMSExampleProductDetailViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OMSExampleProductDetailViewController.m; sourceTree = ""; }; 8AF985742147CC3D007E18ED /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Error.strings; sourceTree = ""; }; 8AF985762147CF3B007E18ED /* th */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = th; path = th.lproj/Error.strings; sourceTree = ""; }; 8AF985772147CF3B007E18ED /* th */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = th; path = th.lproj/Localizable.stringsdict; sourceTree = ""; }; @@ -389,8 +353,6 @@ F3497367254C066F00D05C7B /* MobileBankingSourceChooserViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MobileBankingSourceChooserViewController.swift; sourceTree = ""; }; F615CBF7261565D600E1A2D9 /* CardExpiryDatePickerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardExpiryDatePickerTests.swift; sourceTree = ""; }; F6614CD5243DB8E7005B656E /* TrueMoneyFormViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrueMoneyFormViewController.swift; sourceTree = ""; }; - F6FE862A25E3B02300C7A4DE /* OMSConstants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OMSConstants.m; path = OmiseSDKObjc/OMSConstants.m; sourceTree = SOURCE_ROOT; }; - F6FE862B25E3B02300C7A4DE /* OMSConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OMSConstants.h; path = OmiseSDKObjc/OMSConstants.h; sourceTree = SOURCE_ROOT; }; F6FE863925E3B19A00C7A4DE /* OMSConstants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OMSConstants.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -417,13 +379,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 8A723A592164D7B100D902F5 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; 987A02C61CE35D5E0035417A /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -441,7 +396,6 @@ children = ( 226E16101D2268B400219652 /* QuickStart.playground */, 2259311A1CE3210700841B86 /* OmiseSDK */, - F6FE863425E3B0AE00C7A4DE /* OmiseSDKObjc */, 75DAD87F2A0B9AE50098AF96 /* OmiseTestSDK */, 987A02CA1CE35D5E0035417A /* OmiseSDKTests */, 75F2A0912A13B0B10038FA54 /* OmiseSDKUITests */, @@ -460,7 +414,6 @@ 225931181CE3210700841B86 /* OmiseSDK.framework */, 987A02C91CE35D5E0035417A /* OmiseSDKTests.xctest */, 22D4809D1D0EB29C00544CE1 /* ExampleApp.app */, - 8A723A632164D7B100D902F5 /* ExampleApp.app */, 75F2A0902A13B0B00038FA54 /* OmiseSDKUITests.app */, ); name = Products; @@ -470,7 +423,6 @@ isa = PBXGroup; children = ( 75348D4C29C3FC8F0008C8A3 /* Helpers */, - 2259311B1CE3210700841B86 /* OmiseSDK.h */, 8A00FEC21F1DE88600246078 /* README.md */, 2259311D1CE3210700841B86 /* Info.plist */, 8AD0609520B55E610074894E /* Client.swift */, @@ -483,6 +435,7 @@ 8AD0609120B550B90074894E /* Compatibility */, F6FE863F25E49BC900C7A4DE /* Resources */, 98FF99BA2577789800476487 /* Configuration.swift */, + 752E40C32ACD420C00B62A49 /* OMSSourceTypeValue.swift */, ); path = OmiseSDK; sourceTree = ""; @@ -493,11 +446,9 @@ 75F2A01A2A0BD1CD0038FA54 /* Resources */, 75DAD8922A0BC9540098AF96 /* Config.local.plist */, 22D480AB1D0EB29C00544CE1 /* Info.plist */, - 8AF6A1D720E4FEBE00AC5625 /* ExampleApp-Bridging-Header.h */, 229E14541D0EBAB5000511DE /* AppDelegate.swift */, 8A723A672164D80200D902F5 /* Swift */, 8AB3B85F216DCF5C006497B5 /* Shared */, - 8A723A682164D80C00D902F5 /* Objective-C */, ); path = ExampleApp; sourceTree = ""; @@ -771,23 +722,13 @@ 8A723A672164D80200D902F5 /* Swift */ = { isa = PBXGroup; children = ( + 752E40C52ACD426E00B62A49 /* OMSBaseViewController.swift */, 229E14561D0EBAB5000511DE /* ProductDetailViewController.swift */, 8AF56E61226878070097CFEE /* CustomCreditCardFormViewController.swift */, ); path = Swift; sourceTree = ""; }; - 8A723A682164D80C00D902F5 /* Objective-C */ = { - isa = PBXGroup; - children = ( - 8AF6A1D820E4FEBE00AC5625 /* OMSExampleProductDetailViewController.h */, - 8AF6A1D920E4FEBE00AC5625 /* OMSExampleProductDetailViewController.m */, - 8A43FEA82269BD8A002E89EC /* CustomCreditCardFormViewController.h */, - 8A43FEA92269BD8A002E89EC /* CustomCreditCardFormViewController.m */, - ); - path = "Objective-C"; - sourceTree = ""; - }; 8AB3B85F216DCF5C006497B5 /* Shared */ = { isa = PBXGroup; children = ( @@ -874,15 +815,6 @@ path = Views; sourceTree = ""; }; - F6FE863425E3B0AE00C7A4DE /* OmiseSDKObjc */ = { - isa = PBXGroup; - children = ( - F6FE862B25E3B02300C7A4DE /* OMSConstants.h */, - F6FE862A25E3B02300C7A4DE /* OMSConstants.m */, - ); - path = OmiseSDKObjc; - sourceTree = ""; - }; F6FE863F25E49BC900C7A4DE /* Resources */ = { isa = PBXGroup; children = ( @@ -903,8 +835,6 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 2259311C1CE3210700841B86 /* OmiseSDK.h in Headers */, - F6FE862D25E3B02300C7A4DE /* OMSConstants.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -973,25 +903,6 @@ productReference = 75F2A0902A13B0B00038FA54 /* OmiseSDKUITests.app */; productType = "com.apple.product-type.application"; }; - 8A723A502164D7B100D902F5 /* ExampleApp (Objective-C) */ = { - isa = PBXNativeTarget; - buildConfigurationList = 8A723A602164D7B100D902F5 /* Build configuration list for PBXNativeTarget "ExampleApp (Objective-C)" */; - buildPhases = ( - 8A723A532164D7B100D902F5 /* Sources */, - 8A723A592164D7B100D902F5 /* Frameworks */, - 8A723A5A2164D7B100D902F5 /* Resources */, - 8A723A5E2164D7B100D902F5 /* Embed Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - 8A723A512164D7B100D902F5 /* PBXTargetDependency */, - ); - name = "ExampleApp (Objective-C)"; - productName = ExampleApp; - productReference = 8A723A632164D7B100D902F5 /* ExampleApp.app */; - productType = "com.apple.product-type.application"; - }; 987A02C81CE35D5E0035417A /* OmiseSDKTests */ = { isa = PBXNativeTarget; buildConfigurationList = 987A02D31CE35D5E0035417A /* Build configuration list for PBXNativeTarget "OmiseSDKTests" */; @@ -1038,10 +949,6 @@ 75F2A08F2A13B0B00038FA54 = { CreatedOnToolsVersion = 14.3; }; - 8A723A502164D7B100D902F5 = { - LastSwiftMigration = 1000; - ProvisioningStyle = Automatic; - }; 987A02C81CE35D5E0035417A = { CreatedOnToolsVersion = 7.3.1; LastSwiftMigration = 1000; @@ -1067,7 +974,6 @@ 225931171CE3210700841B86 /* OmiseSDK */, 987A02C81CE35D5E0035417A /* OmiseSDKTests */, 22D4809C1D0EB29C00544CE1 /* ExampleApp (Swift) */, - 8A723A502164D7B100D902F5 /* ExampleApp (Objective-C) */, 75F2A08F2A13B0B00038FA54 /* OmiseSDKUITests */, ); }; @@ -1107,17 +1013,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 8A723A5A2164D7B100D902F5 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 7502CA542A3011A900766E7D /* LaunchScreen.storyboard in Resources */, - 8A7567662178956800C684C9 /* Main.storyboard in Resources */, - 8A723A5C2164D7B100D902F5 /* Assets.xcassets in Resources */, - 75F2A0192A0BD0D40038FA54 /* Config.local.plist in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; 987A02C71CE35D5E0035417A /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -1218,7 +1113,6 @@ 756C8F262A40698600D53059 /* TextFieldView.swift in Sources */, 986406341CFEA7E4004BCF51 /* CardNameTextField.swift in Sources */, 8AF9857121479F38007E18ED /* MoreInformationOnCVVViewController.swift in Sources */, - F6FE862C25E3B02300C7A4DE /* OMSConstants.m in Sources */, 75405A7C2A25EC88008C21F6 /* Array+Helpers.swift in Sources */, 8A188BB01D951E3C00FFF467 /* AuthorizingPaymentViewController.swift in Sources */, 8A01F78B20D90EC5003FC11E /* Client+ObjC.swift in Sources */, @@ -1248,6 +1142,7 @@ 8A01E48D21059EFF00D73FE6 /* PaymentInformation.swift in Sources */, 75F2A0C22A1A87AE0038FA54 /* UIColor+Helpers.swift in Sources */, 7509D4DD2A1A9FD70050AB38 /* MainActionButton.swift in Sources */, + 752E40C42ACD420C00B62A49 /* OMSSourceTypeValue.swift in Sources */, 225931501CE46F7F00841B86 /* CardNumber.swift in Sources */, 7502CA622A31A7E100766E7D /* CountryListViewModelProtocol.swift in Sources */, 8AC1D3A5213922570051F966 /* InstallmentBankingSourceChooserViewController.swift in Sources */, @@ -1263,11 +1158,11 @@ files = ( 8A40DA29216B441E00749F45 /* PaymentSettingTableViewController.swift in Sources */, 229E14581D0EBAB5000511DE /* AppDelegate.swift in Sources */, - 8A6AA06E216B9DAE00E49E5E /* OMSBaseViewController.m in Sources */, 8A40DA2B216B53E900749F45 /* Tools.swift in Sources */, 229E145A1D0EBAB5000511DE /* ProductDetailViewController.swift in Sources */, 8AF56E62226878070097CFEE /* CustomCreditCardFormViewController.swift in Sources */, 75DAD8902A0BB8D80098AF96 /* LocalConfig.swift in Sources */, + 752E40C72ACD429B00B62A49 /* OMSBaseViewController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1304,19 +1199,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 8A723A532164D7B100D902F5 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 8A723A692164D87B00D902F5 /* OMSExampleProductDetailViewController.m in Sources */, - 8A7A9EBE2166160300F12D86 /* PaymentSettingTableViewController.swift in Sources */, - 8A6AA06D216B958100E49E5E /* OMSBaseViewController.m in Sources */, - 8A40DA2C216B53E900749F45 /* Tools.swift in Sources */, - 8A43FEAA2269BD8A002E89EC /* CustomCreditCardFormViewController.m in Sources */, - 8A723A562164D7B100D902F5 /* AppDelegate.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; 987A02C51CE35D5E0035417A /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -1343,11 +1225,6 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ - 8A723A512164D7B100D902F5 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 225931171CE3210700841B86 /* OmiseSDK */; - targetProxy = 8A723A522164D7B100D902F5 /* PBXContainerItemProxy */; - }; 8A7F8B0B20C55312008F4D08 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 225931171CE3210700841B86 /* OmiseSDK */; @@ -1639,7 +1516,6 @@ SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; - SWIFT_OBJC_BRIDGING_HEADER = "ExampleApp/ExampleApp-Bridging-Header.h"; TARGETED_DEVICE_FAMILY = 1; }; name = "Debug (Staging)"; @@ -1671,7 +1547,6 @@ SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; - SWIFT_OBJC_BRIDGING_HEADER = "ExampleApp/ExampleApp-Bridging-Header.h"; TARGETED_DEVICE_FAMILY = 1; }; name = Release; @@ -1791,64 +1666,6 @@ }; name = Release; }; - 8A723A612164D7B100D902F5 /* Debug (Staging) */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - ASSETCATALOG_WARNINGS = NO; - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = ""; - INFOPLIST_FILE = ExampleApp/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - OTHER_LDFLAGS = ( - "-lc++", - "-all_load", - ); - PRODUCT_BUNDLE_IDENTIFIER = co.omise.ExampleApp; - PRODUCT_NAME = ExampleApp; - PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_OBJC_BRIDGING_HEADER = "ExampleApp/ExampleApp-Bridging-Header.h"; - TARGETED_DEVICE_FAMILY = 1; - }; - name = "Debug (Staging)"; - }; - 8A723A622164D7B100D902F5 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - ASSETCATALOG_WARNINGS = NO; - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = ""; - INFOPLIST_FILE = ExampleApp/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - OTHER_LDFLAGS = ( - "-lc++", - "-all_load", - ); - PRODUCT_BUNDLE_IDENTIFIER = co.omise.ExampleApp; - PRODUCT_NAME = ExampleApp; - PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_OBJC_BRIDGING_HEADER = "ExampleApp/ExampleApp-Bridging-Header.h"; - TARGETED_DEVICE_FAMILY = 1; - }; - name = Release; - }; 987A02D11CE35D5E0035417A /* Debug (Staging) */ = { isa = XCBuildConfiguration; buildSettings = { @@ -2044,36 +1861,6 @@ SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; - SWIFT_OBJC_BRIDGING_HEADER = "ExampleApp/ExampleApp-Bridging-Header.h"; - TARGETED_DEVICE_FAMILY = 1; - }; - name = Debug; - }; - 98FF99B7257773EB00476487 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - ASSETCATALOG_WARNINGS = NO; - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = ""; - INFOPLIST_FILE = ExampleApp/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - OTHER_LDFLAGS = ( - "-lc++", - "-all_load", - ); - PRODUCT_BUNDLE_IDENTIFIER = co.omise.ExampleApp; - PRODUCT_NAME = ExampleApp; - PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_OBJC_BRIDGING_HEADER = "ExampleApp/ExampleApp-Bridging-Header.h"; TARGETED_DEVICE_FAMILY = 1; }; name = Debug; @@ -2121,16 +1908,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 8A723A602164D7B100D902F5 /* Build configuration list for PBXNativeTarget "ExampleApp (Objective-C)" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 8A723A612164D7B100D902F5 /* Debug (Staging) */, - 98FF99B7257773EB00476487 /* Debug */, - 8A723A622164D7B100D902F5 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; 987A02D31CE35D5E0035417A /* Build configuration list for PBXNativeTarget "OmiseSDKTests" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/OmiseSDK/AuthorizingPaymentViewController.swift b/OmiseSDK/AuthorizingPaymentViewController.swift index 01c0fa75..3d3a69d6 100644 --- a/OmiseSDK/AuthorizingPaymentViewController.swift +++ b/OmiseSDK/AuthorizingPaymentViewController.swift @@ -3,7 +3,6 @@ import WebKit import os /// Delegate to receive authorizing payment events. -@objc(OMSAuthorizingPaymentViewControllerDelegate) @available(iOSApplicationExtension, unavailable) // swiftlint:disable:next attributes public protocol AuthorizingPaymentViewControllerDelegate: AnyObject { @@ -14,14 +13,6 @@ public protocol AuthorizingPaymentViewControllerDelegate: AnyObject { /// A delegation method called when user cancel the authorizing payment process. func authorizingPaymentViewControllerDidCancel(_ viewController: AuthorizingPaymentViewController) - - @available(*, unavailable, - renamed: "authorizingPaymentViewController(_:didCompleteAuthorizingPaymentWithRedirectedURL:)") - func omiseAuthorizingPaymentViewController(_ viewController: AuthorizingPaymentViewController, didCompleteAuthorizingPaymentWithRedirectedURL redirectedURL: URL) - - @available(*, unavailable, - renamed: "authorizingPaymentViewControllerDidCancel(_:)") - func omiseAuthorizingPaymentViewControllerDidCancel(_ viewController: AuthorizingPaymentViewController) } @available(*, deprecated, renamed: "AuthorizingPaymentViewController") @@ -48,7 +39,6 @@ public typealias OmiseAuthorizingPaymentViewControllerDelegate = AuthorizingPaym - remark: This is still an experimental API. If you encountered with any problem with this API, please feel free to report to Omise. */ -@objc(OMSAuthorizingPaymentViewController) @available(iOSApplicationExtension, unavailable) // swiftlint:disable:next attributes public class AuthorizingPaymentViewController: UIViewController { @@ -84,36 +74,24 @@ public class AuthorizingPaymentViewController: UIViewController { /// - parameter delegate: A delegate object that will recieved authorizing payment events. /// /// - returns: A UINavigationController with `OmiseAuthorizingPaymentViewController` as its root view controller - @objc(authorizingPaymentViewControllerNavigationWithAuthorizedURL:expectedReturnURLPatterns:delegate:) - // swiftlint:disable:next attributes public static func makeAuthorizingPaymentViewControllerNavigationWithAuthorizedURL(_ authorizedURL: URL, expectedReturnURLPatterns: [URLComponents], delegate: AuthorizingPaymentViewControllerDelegate) -> UINavigationController { let storyboard = UIStoryboard(name: "OmiseSDK", bundle: .omiseSDK) let navigationController = storyboard.instantiateViewController( withIdentifier: "DefaultAuthorizingPaymentViewControllerWithNavigation" ) as! UINavigationController // swiftlint:disable:this force_cast + navigationController.navigationBar.isTranslucent = false + navigationController.navigationBar.backgroundColor = .white + // swiftlint:disable:next force_cast let viewController = navigationController.topViewController as! AuthorizingPaymentViewController viewController.authorizedURL = authorizedURL viewController.expectedReturnURLPatterns = expectedReturnURLPatterns viewController.delegate = delegate - + return navigationController } - - @available(*, deprecated, - message: "Please use the new method that confrom to Objective-C convention +[AuthorizingPaymentViewController authorizingPaymentViewControllerNavigationWithAuthorizedURL:expectedReturnURLPatterns:delegate:] as of this method will be removed in the future release.", // swiftlint:disable:this line_length - renamed: "makeAuthorizingPaymentViewControllerNavigationWithAuthorizedURL(_:expectedReturnURLPatterns:delegate:)") - @objc(makeAuthorizingPaymentViewControllerNavigationWithAuthorizedURL:expectedReturnURLPatterns:delegate:) - // swiftlint:disable:next identifier_name attributes - public static func __makeAuthorizingPaymentViewControllerNavigationWithAuthorizedURL(_ authorizedURL: URL, expectedReturnURLPatterns: [URLComponents], delegate: AuthorizingPaymentViewControllerDelegate) -> UINavigationController { - return AuthorizingPaymentViewController.makeAuthorizingPaymentViewControllerNavigationWithAuthorizedURL( - authorizedURL, - expectedReturnURLPatterns: expectedReturnURLPatterns, - delegate: delegate - ) - } - + /// A factory method for creating a authorizing payment view controller comes in UINavigationController stack. /// /// - parameter authorizedURL: The authorized URL given in `Charge` object that will be set to `OmiseAuthorizingPaymentViewController` @@ -121,8 +99,6 @@ public class AuthorizingPaymentViewController: UIViewController { /// - parameter delegate: A delegate object that will recieved authorizing payment events. /// /// - returns: An `OmiseAuthorizingPaymentViewController` with given authorized URL and delegate. - @objc(authorizingPaymentViewControllerWithAuthorizedURL:expectedReturnURLPatterns:delegate:) - // swiftlint:disable:next attributes public static func makeAuthorizingPaymentViewControllerWithAuthorizedURL(_ authorizedURL: URL, expectedReturnURLPatterns: [URLComponents], delegate: AuthorizingPaymentViewControllerDelegate) -> AuthorizingPaymentViewController { let storyboard = UIStoryboard(name: "OmiseSDK", bundle: .omiseSDK) let viewController = storyboard.instantiateViewController( @@ -135,19 +111,6 @@ public class AuthorizingPaymentViewController: UIViewController { return viewController } - @available(*, deprecated, - message: "Please use the new method that confrom to Objective-C convention +[AuthorizingPaymentViewController authorizingPaymentViewControllernWithAuthorizedURL:expectedReturnURLPatterns:delegate:] as of this method will be removed in the future release.", // swiftlint:disable:this line_length - renamed: "makeAuthorizingPaymentViewControllerWithAuthorizedURL(_:expectedReturnURLPatterns:delegate:)") - @objc(makeAuthorizingPaymentViewControllerWithAuthorizedURL:expectedReturnURLPatterns:delegate:) - // swiftlint:disable:next identifier_name attributes - public static func __makeAuthorizingPaymentViewControllerWithAuthorizedURL(_ authorizedURL: URL, expectedReturnURLPatterns: [URLComponents], delegate: AuthorizingPaymentViewControllerDelegate) -> AuthorizingPaymentViewController { - return AuthorizingPaymentViewController.makeAuthorizingPaymentViewControllerWithAuthorizedURL( - authorizedURL, - expectedReturnURLPatterns: expectedReturnURLPatterns, - delegate: delegate - ) - } - // need to refactor loadView, removing super results in crash // swiftlint:disable:next prohibited_super_call public override func loadView() { diff --git a/OmiseSDK/Capability.swift b/OmiseSDK/Capability.swift index fa7c9053..3df07d7b 100644 --- a/OmiseSDK/Capability.swift +++ b/OmiseSDK/Capability.swift @@ -24,8 +24,11 @@ public struct Capability: Object { extension Capability { public static func ~= (lhs: Capability, rhs: CreateSourceParameter) -> Bool { func backend(from capability: Capability, for payment: PaymentInformation) -> Backend? { - let paymentSourceType = OMSSourceTypeValue(payment.sourceType) - return capability[paymentSourceType] + if let paymentSourceType = OMSSourceTypeValue(payment.sourceType) { + return capability[paymentSourceType] + } else { + return nil + } } guard let backend = backend(from: lhs, for: rhs.paymentInformation) else { @@ -198,12 +201,15 @@ extension Capability { var backendsContainer = try container.nestedUnkeyedContainer(forKey: .paymentBackends) var backends: [Capability.Backend] = [] + while !backendsContainer.isAtEnd { - backends.append(try backendsContainer.decode(Capability.Backend.self)) + let backend = try backendsContainer.decode(Capability.Backend.self) + backends.append(backend) } + self.supportedBackends = backends - let backendTypes = backends.map { Capability.Backend.BackendType(payment: $0.payment) } + let backendTypes = backends.compactMap { Capability.Backend.BackendType(payment: $0.payment) } self.backends = Dictionary(uniqueKeysWithValues: zip(backendTypes, backends)) } @@ -233,6 +239,8 @@ extension Capability.Backend { supportedCurrencies = try container.decode(Set.self, forKey: .supportedCurrencies) switch type { + case .unknown(let sourceType): + self.payment = .unknownSource(sourceType, configurations: [:]) case .card: let supportedBrand = try container.decode(Set.self, forKey: .cardBrands) self.payment = .card(supportedBrand) @@ -338,9 +346,13 @@ extension Capability.Backend { private let creditCardBackendTypeValue = "card" extension Capability.Backend { + struct OMSSourceTypeValueError: Error { + } + fileprivate enum BackendType: Codable, Hashable { case card case source(OMSSourceTypeValue) + case unknown(sourceType: String) init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() @@ -348,7 +360,11 @@ extension Capability.Backend { case creditCardBackendTypeValue: self = .card case let value: - self = .source(OMSSourceTypeValue(value)) + if let sourceType = OMSSourceTypeValue(value) { + self = .source(sourceType) + } else { + self = .unknown(sourceType: value) + } } } @@ -356,6 +372,8 @@ extension Capability.Backend { var container = encoder.singleValueContainer() let type: String switch self { + case .unknown(let sourceType): + type = sourceType case .card: type = creditCardBackendTypeValue case .source(let sourceType): @@ -366,7 +384,7 @@ extension Capability.Backend { } // swiftlint:disable:next function_body_length - init(payment: Capability.Backend.Payment) { + init?(payment: Capability.Backend.Payment) { switch payment { case .card: self = .card @@ -389,15 +407,35 @@ extension Capability.Backend { case .touchNGo: self = .source(.touchNGo) case .installment(let brand, availableNumberOfTerms: _): - self = .source(OMSSourceTypeValue(brand.type)) + if let sourceType = OMSSourceTypeValue(brand.type) { + self = .source(sourceType) + } else { + return nil + } case .internetBanking(let banking): - self = .source(OMSSourceTypeValue(banking.type)) + if let sourceType = OMSSourceTypeValue(banking.type) { + self = .source(sourceType) + } else { + return nil + } case .mobileBanking(let banking): - self = .source(OMSSourceTypeValue(banking.type)) + if let sourceType = OMSSourceTypeValue(banking.type) { + self = .source(sourceType) + } else { + return nil + } case .billPayment(let billPayment): - self = .source(OMSSourceTypeValue(billPayment.type)) + if let sourceType = OMSSourceTypeValue(billPayment.type) { + self = .source(sourceType) + } else { + return nil + } case .unknownSource(let sourceType, configurations: _): - self = .source(.init(sourceType)) + if let sourceType = OMSSourceTypeValue(sourceType) { + self = .source(sourceType) + } else { + return nil + } case .promptpay: self = .source(.promptPay) case .paynow: @@ -405,7 +443,11 @@ extension Capability.Backend { case .truemoney: self = .source(.trueMoney) case .points(let points): - self = .source(OMSSourceTypeValue(points.type)) + if let sourceType = OMSSourceTypeValue(points.type) { + self = .source(sourceType) + } else { + return nil + } case .eContext: self = .source(.eContext) case .fpx: @@ -437,6 +479,8 @@ extension Capability.Backend { var type: String { switch self { + case .unknown(let sourceType): + return sourceType case .card: return "card" case .source(let sourceType): diff --git a/OmiseSDK/Client.swift b/OmiseSDK/Client.swift index 3a79c968..275a40e7 100644 --- a/OmiseSDK/Client.swift +++ b/OmiseSDK/Client.swift @@ -398,7 +398,7 @@ extension Client { // MARK: - Constants extension Client { - static let sdkVersion: String = "4.24.3" + static let sdkVersion: String = "5.0.0" static let currentPlatform: String = ProcessInfo.processInfo.operatingSystemVersionString static let currentDevice: String = UIDevice.current.model diff --git a/OmiseSDK/Compatibility/OmiseCapability.swift b/OmiseSDK/Compatibility/OmiseCapability.swift index 39dc9d44..1d892ffe 100644 --- a/OmiseSDK/Compatibility/OmiseCapability.swift +++ b/OmiseSDK/Compatibility/OmiseCapability.swift @@ -1,7 +1,6 @@ import Foundation -@objc(OMSCapability) -// swiftlint:disable:next attributes type_name +// swiftlint:disable:next type_name public class __OmiseCapability: NSObject { let capability: Capability @@ -18,26 +17,23 @@ public class __OmiseCapability: NSObject { } } -@objc(OMSCapabilityBackend) -// swiftlint:disable:next attributes type_name +// swiftlint:disable:next type_name public class __OmiseCapabilityBackend: NSObject { private let backend: Capability.Backend - @objc public lazy var payment: __OmiseCapabilityBackendPayment = + public lazy var payment: __OmiseCapabilityBackendPayment? = __OmiseCapabilityBackendPayment.makeCapabilityBackend(from: backend.payment) - @objc public lazy var supportedCurrencyCodes: Set = Set(backend.supportedCurrencies.map { $0.code }) + public lazy var supportedCurrencyCodes: Set = Set(backend.supportedCurrencies.map { $0.code }) required init(_ backend: Capability.Backend) { self.backend = backend } } -@objc(OMSCapabilityBackendPayment) -// swiftlint:disable:next attributes type_name +// swiftlint:disable:next type_name public class __OmiseCapabilityBackendPayment: NSObject {} -@objc(OMSCapabilityCardBackend) -// swiftlint:disable:next attributes type_name +// swiftlint:disable:next type_name public class __OmiseCapabilityCardBackendPayment: __OmiseCapabilityBackendPayment { @objc public let supportedBrands: Set @@ -46,12 +42,11 @@ public class __OmiseCapabilityCardBackendPayment: __OmiseCapabilityBackendPaymen } } -@objc(OMSCapabilitySourceBackend) -// swiftlint:disable:next attributes type_name +// swiftlint:disable:next type_name public class __OmiseCapabilitySourceBackendPayment: __OmiseCapabilityBackendPayment { - @objc public let type: OMSSourceTypeValue + public let type: OMSSourceTypeValue - init(sourceType: OMSSourceTypeValue) { + init?(sourceType: OMSSourceTypeValue) { self.type = sourceType } @@ -129,14 +124,22 @@ public class __OmiseCapabilitySourceBackendPayment: __OmiseCapabilityBackendPaym static func makeInternetBankingSourceBackendPayment( bank: PaymentInformation.InternetBanking - ) -> __OmiseCapabilitySourceBackendPayment { - return __OmiseCapabilitySourceBackendPayment(sourceType: OMSSourceTypeValue(bank.type)) + ) -> __OmiseCapabilitySourceBackendPayment? { + if let sourceType = OMSSourceTypeValue(bank.type) { + return __OmiseCapabilitySourceBackendPayment(sourceType: sourceType) + } else { + return nil + } } static func makeMobileBankingSourceBackendPayment( bank: PaymentInformation.MobileBanking - ) -> __OmiseCapabilitySourceBackendPayment { - return __OmiseCapabilitySourceBackendPayment(sourceType: OMSSourceTypeValue(bank.type)) + ) -> __OmiseCapabilitySourceBackendPayment? { + if let sourceType = OMSSourceTypeValue(bank.type) { + return __OmiseCapabilitySourceBackendPayment(sourceType: sourceType) + } else { + return nil + } } } @@ -145,7 +148,7 @@ public class __OmiseCapabilitySourceBackendPayment: __OmiseCapabilityBackendPaym public class __OmiseCapabilityInstallmentBackendPayment: __OmiseCapabilitySourceBackendPayment { @objc public let availableNumberOfTerms: IndexSet - init(sourceType: OMSSourceTypeValue, availableNumberOfTerms: IndexSet) { + init?(sourceType: OMSSourceTypeValue, availableNumberOfTerms: IndexSet) { self.availableNumberOfTerms = availableNumberOfTerms super.init(sourceType: sourceType) } @@ -155,28 +158,41 @@ public class __OmiseCapabilityInstallmentBackendPayment: __OmiseCapabilitySource // swiftlint:disable:next attributes type_name public class __OmiseCapabilityUnknownSourceBackendPayment: __OmiseCapabilitySourceBackendPayment { @objc public let parameters: [String: Any] - init(sourceType: String, parameters: [String: Any]) { + init?(sourceType: String, parameters: [String: Any]) { self.parameters = parameters - super.init(sourceType: OMSSourceTypeValue(rawValue: sourceType)) + if let sourceType = OMSSourceTypeValue(sourceType) { + super.init(sourceType: sourceType) + } else { + return nil + } } } extension __OmiseCapabilityBackendPayment { // swiftlint:disable:next function_body_length - static func makeCapabilityBackend(from payment: Capability.Backend.Payment) -> __OmiseCapabilityBackendPayment { + static func makeCapabilityBackend(from payment: Capability.Backend.Payment) -> __OmiseCapabilityBackendPayment? { + switch payment { case .card(let brands): return __OmiseCapabilityCardBackendPayment(supportedBrands: Set(brands.map({ $0.description }))) case .installment(let brand, availableNumberOfTerms: let availableNumberOfTerms): - return __OmiseCapabilityInstallmentBackendPayment( - sourceType: OMSSourceTypeValue(brand.type), availableNumberOfTerms: availableNumberOfTerms - ) + if let sourceType = OMSSourceTypeValue(brand.type) { + return __OmiseCapabilityInstallmentBackendPayment( + sourceType: sourceType, availableNumberOfTerms: availableNumberOfTerms + ) + } else { + return nil + } case .internetBanking(let bank): return __OmiseCapabilitySourceBackendPayment.makeInternetBankingSourceBackendPayment(bank: bank) case .mobileBanking(let bank): return __OmiseCapabilitySourceBackendPayment.makeMobileBankingSourceBackendPayment(bank: bank) case .billPayment(let billPayment): - return __OmiseCapabilitySourceBackendPayment(sourceType: OMSSourceTypeValue(billPayment.type)) + if let sourceType = OMSSourceTypeValue(billPayment.type) { + return __OmiseCapabilitySourceBackendPayment(sourceType: sourceType) + } else { + return nil + } case .alipay: return __OmiseCapabilitySourceBackendPayment.alipaySourceBackendPayment case .alipayCN: @@ -200,7 +216,11 @@ extension __OmiseCapabilityBackendPayment { case .truemoney: return __OmiseCapabilitySourceBackendPayment.truemoneySourceBackendPayment case .points(let points): - return __OmiseCapabilitySourceBackendPayment(sourceType: OMSSourceTypeValue(points.type)) + if let sourceType = OMSSourceTypeValue(points.type) { + return __OmiseCapabilitySourceBackendPayment(sourceType: sourceType) + } else { + return nil + } case .eContext: return __OmiseCapabilitySourceBackendPayment.eContextSourceBackendPayment case .fpx: diff --git a/OmiseSDK/Compatibility/OmiseSource.swift b/OmiseSDK/Compatibility/OmiseSource.swift index dc2d90a6..84b618a7 100644 --- a/OmiseSDK/Compatibility/OmiseSource.swift +++ b/OmiseSDK/Compatibility/OmiseSource.swift @@ -181,9 +181,13 @@ public class __SourceCustomBarcodePayment: __SourceBarcodePayment { /// - Parameters: /// - customType: The type of a source to be created /// - parameters: Parameters of a source to be created - public init(customType: String, parameters: [String: Any]) { + public init?(customType: String, parameters: [String: Any]) { self.parameters = parameters - super.init(type: OMSSourceTypeValue(rawValue: customType))! + if let sourceType = OMSSourceTypeValue(customType) { + super.init(type: sourceType) + } else { + return nil + } } } @@ -433,9 +437,13 @@ public class __CustomSourcePayment: __SourcePaymentInformation { /// - Parameters: /// - customType: The source type of the payment source /// - parameters: The parameter of the payment source - public init(customType: String, parameters: [String: Any]) { + public init?(customType: String, parameters: [String: Any]) { self.parameters = parameters - super.init(type: OMSSourceTypeValue(rawValue: customType))! + if let sourceType = OMSSourceTypeValue(customType) { + super.init(type: sourceType) + } else { + return nil + } } } @@ -535,7 +543,7 @@ extension PaymentInformation { extension __SourcePaymentInformation { // swiftlint:disable:next function_body_length - static func makeSourcePaymentInformation(from paymentInformation: PaymentInformation) -> __SourcePaymentInformation { + static func makeSourcePaymentInformation(from paymentInformation: PaymentInformation) -> __SourcePaymentInformation? { switch paymentInformation { case .alipay: return __SourcePaymentInformation.alipayPayment @@ -565,7 +573,11 @@ extension __SourcePaymentInformation { case .billPayment(PaymentInformation.BillPayment.tescoLotus): return __SourcePaymentInformation.tescoLotusBillPaymentPayment case .billPayment(PaymentInformation.BillPayment.other(let type)): - return __SourcePaymentInformation.init(type: OMSSourceTypeValue(type))! + if let sourceType = OMSSourceTypeValue(type) { + return __SourcePaymentInformation.init(type: sourceType) + } else { + return nil + } case .internetBanking(let bank): switch bank { case .bay: @@ -573,7 +585,11 @@ extension __SourcePaymentInformation { case .bbl: return __SourceInternetBankingPayment.bblInternetBankingPayment case .other(let type) where type.hasPrefix(PaymentInformation.InternetBanking.paymentMethodTypePrefix): - return __SourceInternetBankingPayment.init(type: OMSSourceTypeValue(type))! + if let sourceType = OMSSourceTypeValue(type) { + return __SourceInternetBankingPayment.init(type: sourceType) + } else { + return nil + } case .other(let type): return __CustomSourcePayment(customType: type, parameters: [:]) } @@ -600,7 +616,11 @@ extension __SourcePaymentInformation { case .uob: return __SourceInstallmentsPayment.installmentUOBPayment(withNumberOfTerms: installment.numberOfTerms) case .other(let type) where type.hasPrefix(PaymentInformation.Installment.paymentMethodTypePrefix): - return __SourceInstallmentsPayment.init(type: OMSSourceTypeValue(type), numberOfTerms: installment.numberOfTerms)! + if let sourceType = OMSSourceTypeValue(type) { + return __SourceInstallmentsPayment.init(type: sourceType, numberOfTerms: installment.numberOfTerms) + } else { + return nil + } case .other(let type): return __CustomSourcePayment(customType: type, parameters: [:]) } diff --git a/OmiseSDK/CreditCardFormViewController.swift b/OmiseSDK/CreditCardFormViewController.swift index 45d9610d..963336b1 100644 --- a/OmiseSDK/CreditCardFormViewController.swift +++ b/OmiseSDK/CreditCardFormViewController.swift @@ -76,9 +76,8 @@ public typealias CreditCardFormController = CreditCardFormViewController /// Drop-in credit card input form view controller that automatically tokenizes credit /// card information. -@objc(OMSCreditCardFormViewController) public class CreditCardFormViewController: UIViewController, PaymentChooserUI, PaymentFormUIController { - // swiftlint:disable:previous attributes type_body_length + // swiftlint:disable:previous type_body_length typealias ViewModel = CreditCardFormViewModel typealias ViewContext = CreditCardFormViewContext diff --git a/OmiseSDK/Currency.swift b/OmiseSDK/Currency.swift index ff7c50aa..ac6f4a81 100644 --- a/OmiseSDK/Currency.swift +++ b/OmiseSDK/Currency.swift @@ -4,6 +4,24 @@ public let centBasedCurrencyFactor = 100 public let identicalBasedCurrencyFactor = 1 public enum Currency: Codable, Hashable { + + enum CurrencyCode: String { + case thb = "THB" + case jpy = "JPY" + case idr = "IDR" + case sgd = "SGD" + case usd = "USD" + case gbp = "GBP" + case eur = "EUR" + case myr = "MYR" + case aud = "AUD" + case cad = "CAD" + case chf = "CHF" + case cny = "CNY" + case dkk = "DKK" + case hkd = "HKD" + } + case thb case jpy case idr @@ -12,96 +30,61 @@ public enum Currency: Codable, Hashable { case gbp case eur case myr - case aud case cad case chf case cny case dkk case hkd - + case custom(code: String, factor: Int) + static let `default`: Currency = .thb + public var code: String { switch self { - case .thb: - return OMSSupportedCurrencyCode.THB.rawValue - case .jpy: - return OMSSupportedCurrencyCode.JPY.rawValue - case .idr: - return OMSSupportedCurrencyCode.IDR.rawValue - case .sgd: - return OMSSupportedCurrencyCode.SGD.rawValue - case .usd: - return OMSSupportedCurrencyCode.USD.rawValue - case .gbp: - return OMSSupportedCurrencyCode.GBP.rawValue - case .eur: - return OMSSupportedCurrencyCode.EUR.rawValue - case .myr: - return OMSSupportedCurrencyCode.MYR.rawValue - case .aud: - return OMSSupportedCurrencyCode.AUD.rawValue - case .cad: - return OMSSupportedCurrencyCode.CAD.rawValue - case .chf: - return OMSSupportedCurrencyCode.CHF.rawValue - case .cny: - return OMSSupportedCurrencyCode.CNY.rawValue - case .dkk: - return OMSSupportedCurrencyCode.DKK.rawValue - case .hkd: - return OMSSupportedCurrencyCode.HKD.rawValue - case.custom(code: let code, factor: _): - return code - } - } - - /// A convertion factor represents how much Omise amount equals to 1 unit of this currency. eg. THB's factor is equals to 100. - public var factor: Int { - switch self { - case .thb, .idr, .sgd, .usd, .gbp, .eur, .myr, .aud, .cad, .chf, .cny, .dkk, .hkd: - return centBasedCurrencyFactor - case .jpy: - return identicalBasedCurrencyFactor - case .custom(code: _, factor: let factor): - return factor + case .thb: return CurrencyCode.thb.rawValue + case .jpy: return CurrencyCode.jpy.rawValue + case .idr: return CurrencyCode.idr.rawValue + case .sgd: return CurrencyCode.sgd.rawValue + case .usd: return CurrencyCode.usd.rawValue + case .gbp: return CurrencyCode.gbp.rawValue + case .eur: return CurrencyCode.eur.rawValue + case .myr: return CurrencyCode.myr.rawValue + case .aud: return CurrencyCode.aud.rawValue + case .cad: return CurrencyCode.cad.rawValue + case .chf: return CurrencyCode.chf.rawValue + case .cny: return CurrencyCode.cny.rawValue + case .dkk: return CurrencyCode.dkk.rawValue + case .hkd: return CurrencyCode.hkd.rawValue + case.custom(code: let code, factor: _): return code } } - + /// Create a currency with the given `ISO 4217` currency code /// /// - Parameter code: The ISO 4217 currency code for the creating Currency that will be created - public init(code: String) { + public init(code: String?) { + guard let code = code else { + self = Currency.default + return + } + switch code.uppercased() { - case OMSSupportedCurrencyCode.THB.rawValue: - self = .thb - case OMSSupportedCurrencyCode.JPY.rawValue: - self = .jpy - case OMSSupportedCurrencyCode.IDR.rawValue: - self = .idr - case OMSSupportedCurrencyCode.SGD.rawValue: - self = .sgd - case OMSSupportedCurrencyCode.USD.rawValue: - self = .usd - case OMSSupportedCurrencyCode.GBP.rawValue: - self = .gbp - case OMSSupportedCurrencyCode.EUR.rawValue: - self = .eur - case OMSSupportedCurrencyCode.MYR.rawValue: - self = .myr - case OMSSupportedCurrencyCode.AUD.rawValue: - self = .aud - case OMSSupportedCurrencyCode.CAD.rawValue: - self = .cad - case OMSSupportedCurrencyCode.CHF.rawValue: - self = .chf - case OMSSupportedCurrencyCode.CNY.rawValue: - self = .cny - case OMSSupportedCurrencyCode.DKK.rawValue: - self = .dkk - case OMSSupportedCurrencyCode.HKD.rawValue: - self = .hkd + case CurrencyCode.thb.rawValue: self = .thb + case CurrencyCode.jpy.rawValue: self = .jpy + case CurrencyCode.idr.rawValue: self = .idr + case CurrencyCode.sgd.rawValue: self = .sgd + case CurrencyCode.usd.rawValue: self = .usd + case CurrencyCode.gbp.rawValue: self = .gbp + case CurrencyCode.eur.rawValue: self = .eur + case CurrencyCode.myr.rawValue: self = .myr + case CurrencyCode.aud.rawValue: self = .aud + case CurrencyCode.cad.rawValue: self = .cad + case CurrencyCode.chf.rawValue: self = .chf + case CurrencyCode.cny.rawValue: self = .cny + case CurrencyCode.dkk.rawValue: self = .dkk + case CurrencyCode.hkd.rawValue: self = .hkd case let currencyCode: let numberFormatter = NumberFormatter() numberFormatter.numberStyle = .currency @@ -110,7 +93,19 @@ public enum Currency: Codable, Hashable { self = .custom(code: currencyCode, factor: factor) } } - + + /// A convertion factor represents how much Omise amount equals to 1 unit of this currency. eg. THB's factor is equals to 100. + public var factor: Int { + switch self { + case .thb, .idr, .sgd, .usd, .gbp, .eur, .myr, .aud, .cad, .chf, .cny, .dkk, .hkd: + return centBasedCurrencyFactor + case .jpy: + return identicalBasedCurrencyFactor + case .custom(code: _, factor: let factor): + return factor + } + } + /// Convert the given subunit amount to the unit amount /// /// - Parameter value: Value in subunit (Satang in THB for example) diff --git a/OmiseSDK/DuitNowOBWBankChooserViewController.swift b/OmiseSDK/DuitNowOBWBankChooserViewController.swift index 8d8a65db..80991f6a 100644 --- a/OmiseSDK/DuitNowOBWBankChooserViewController.swift +++ b/OmiseSDK/DuitNowOBWBankChooserViewController.swift @@ -1,8 +1,6 @@ import UIKit import os -@objc(OMSDuitNowOBWBankChooserViewController) -// swiftlint:disable:next attributes class DuitNowOBWBankChooserViewController: AdaptableStaticTableViewController, PaymentSourceChooser, PaymentChooserUI { diff --git a/OmiseSDK/EContextInformationInputViewController.swift b/OmiseSDK/EContextInformationInputViewController.swift index 2e4b46a7..f99c3b60 100644 --- a/OmiseSDK/EContextInformationInputViewController.swift +++ b/OmiseSDK/EContextInformationInputViewController.swift @@ -1,7 +1,5 @@ import UIKit -@objc(OMSEContextInformationInputViewController) -// swiftlint:disable:next attributes class EContextInformationInputViewController: UIViewController, PaymentSourceChooser, PaymentChooserUI, PaymentFormUIController { var flowSession: PaymentCreatorFlowSession? var client: Client? diff --git a/OmiseSDK/FPXBankChooserViewController.swift b/OmiseSDK/FPXBankChooserViewController.swift index 37968287..8a05f274 100644 --- a/OmiseSDK/FPXBankChooserViewController.swift +++ b/OmiseSDK/FPXBankChooserViewController.swift @@ -1,8 +1,6 @@ import UIKit import os -@objc(OMSFPXBankChooserViewController) -// swiftlint:disable:next attributes class FPXBankChooserViewController: AdaptableDynamicTableViewController, PaymentSourceChooser, PaymentChooserUI { var email: String? var flowSession: PaymentCreatorFlowSession? diff --git a/OmiseSDK/FPXFormViewController.swift b/OmiseSDK/FPXFormViewController.swift index 906e408c..4efd21df 100644 --- a/OmiseSDK/FPXFormViewController.swift +++ b/OmiseSDK/FPXFormViewController.swift @@ -1,7 +1,5 @@ import UIKit -@objc(OMSFPXFormViewController) -// swiftlint:disable:next attributes class FPXFormViewController: UIViewController, PaymentSourceChooser, PaymentChooserUI, PaymentFormUIController { private let destinationSegue: String = "GoToFPXBankChooserSegue" diff --git a/OmiseSDK/Globals.swift b/OmiseSDK/Globals.swift index cb89aad3..c724519a 100644 --- a/OmiseSDK/Globals.swift +++ b/OmiseSDK/Globals.swift @@ -114,7 +114,7 @@ extension OMSSourceTypeValue { case .barcodeAlipay: return "barcode" case .installmentBAY, .installmentMBB, .installmentFirstChoice, .installmentBBL, - .installmentKTC, .installmentKBank, .installmentSCB, .installmentCiti, .installmentTTB, .installmentUOB: + .installmentKTC, .installmentKBank, .installmentSCB, .installmentCiti, .installmentTTB, .installmentUOB: return "installment" case .eContext: return "econtext" @@ -160,8 +160,6 @@ extension OMSSourceTypeValue { return "duitnow_obw" case .payPay: return "paypay" - default: - return self.rawValue } } } diff --git a/OmiseSDK/InstallmentBankingSourceChooserViewController.swift b/OmiseSDK/InstallmentBankingSourceChooserViewController.swift index bd46e8ae..3ec73286 100644 --- a/OmiseSDK/InstallmentBankingSourceChooserViewController.swift +++ b/OmiseSDK/InstallmentBankingSourceChooserViewController.swift @@ -1,8 +1,7 @@ import UIKit import os -@objc(OMSInstallmentBankingSourceChooserViewController) -// swiftlint:disable:next type_name attributes +// swiftlint:disable:next type_name class InstallmentBankingSourceChooserViewController: AdaptableStaticTableViewController, PaymentSourceChooser, PaymentChooserUI { diff --git a/OmiseSDK/InstallmentsNumberOfTermsChooserViewController.swift b/OmiseSDK/InstallmentsNumberOfTermsChooserViewController.swift index 68dba6a9..2a328c48 100644 --- a/OmiseSDK/InstallmentsNumberOfTermsChooserViewController.swift +++ b/OmiseSDK/InstallmentsNumberOfTermsChooserViewController.swift @@ -1,7 +1,6 @@ import UIKit -@objc(OMSInstallmentsNumberOfTermsChooserViewController) -// swiftlint:disable:next type_name attributes +// swiftlint:disable:next type_name class InstallmentsNumberOfTermsChooserViewController: UITableViewController, PaymentSourceChooser, PaymentChooserUI { var flowSession: PaymentCreatorFlowSession? diff --git a/OmiseSDK/InternetBankingSourceChooserViewController.swift b/OmiseSDK/InternetBankingSourceChooserViewController.swift index 0e931c39..30ee7386 100644 --- a/OmiseSDK/InternetBankingSourceChooserViewController.swift +++ b/OmiseSDK/InternetBankingSourceChooserViewController.swift @@ -1,8 +1,7 @@ import UIKit import os -@objc(OMSInternetBankingSourceChooserViewController) -// swiftlint:disable:next type_name attributes +// swiftlint:disable:next type_name class InternetBankingSourceChooserViewController: AdaptableStaticTableViewController, PaymentSourceChooser, PaymentChooserUI { diff --git a/OmiseSDK/MobileBankingSourceChooserViewController.swift b/OmiseSDK/MobileBankingSourceChooserViewController.swift index c7384b85..19b0632c 100644 --- a/OmiseSDK/MobileBankingSourceChooserViewController.swift +++ b/OmiseSDK/MobileBankingSourceChooserViewController.swift @@ -1,8 +1,6 @@ import UIKit import os -@objc(OMSMobileBankingSourceChooserViewController) -// swiftlint:disable:next attributes class MobileBankingSourceChooserViewController: AdaptableStaticTableViewController, PaymentSourceChooser, PaymentChooserUI { diff --git a/OmiseSDK/OMSSourceTypeValue.swift b/OmiseSDK/OMSSourceTypeValue.swift new file mode 100644 index 00000000..48fc2ba2 --- /dev/null +++ b/OmiseSDK/OMSSourceTypeValue.swift @@ -0,0 +1,65 @@ +// +// OMSSourceTypeValue.swift +// OmiseSDK +// +// Created by Andrei Solovev on 4/10/23. +// Copyright © 2023 Omise. All rights reserved. +// + +import Foundation + +public enum OMSSourceTypeValue: String { + case internetBankingBAY = "internet_banking_bay" + case internetBankingBBL = "internet_banking_bbl" + case mobileBankingSCB = "mobile_banking_scb" + case mobileBankingOCBCPAO = "mobile_banking_ocbc_pao" + case mobileBankingKBank = "mobile_banking_kbank" + case mobileBankingBAY = "mobile_banking_bay" + case mobileBankingBBL = "mobile_banking_bbl" + case mobileBankingKTB = "mobile_banking_ktb" + case alipay = "alipay" + case alipayCN = "alipay_cn" + case alipayHK = "alipay_hk" + case dana = "dana" + case gcash = "gcash" + case kakaoPay = "kakaopay" + case touchNGo = "touch_n_go" + case touchNGoAlipayPlus = "touch_n_go_alipay_plus" + case billPaymentTescoLotus = "bill_payment_tesco_lotus" + case barcodeAlipay = "barcode_alipay" + case installmentBAY = "installment_bay" + case installmentFirstChoice = "installment_first_choice" + case installmentBBL = "installment_bbl" + case installmentMBB = "installment_mbb" + case installmentKTC = "installment_ktc" + case installmentKBank = "installment_kbank" + case installmentSCB = "installment_scb" + case installmentCiti = "installment_citi" + case installmentTTB = "installment_ttb" + case installmentUOB = "installment_uob" + case eContext = "econtext" + case promptPay = "promptpay" + case payNow = "paynow" + case trueMoney = "truemoney" + case pointsCiti = "points_citi" + case fpx = "fpx" + case rabbitLinepay = "rabbit_linepay" + case grabPay = "grabpay" + case grabPayRms = "grabpay_rms" + case boost = "boost" + case shopeePay = "shopeepay" + case shopeePayJumpApp = "shopeepay_jumpapp" + case maybankQRPay = "maybank_qr" + case duitNowQR = "duitnow_qr" + case duitNowOBW = "duitnow_obw" + case atome = "atome" + case payPay = "paypay" + + public init?(_ rawValue: String) { + if let value = OMSSourceTypeValue(rawValue: rawValue) { + self = value + } else { + return nil + } + } +} diff --git a/OmiseSDK/OmiseSDK.h b/OmiseSDK/OmiseSDK.h deleted file mode 100644 index 02b64531..00000000 --- a/OmiseSDK/OmiseSDK.h +++ /dev/null @@ -1,7 +0,0 @@ -#import - -FOUNDATION_EXPORT double OmiseSDKVersionNumber; -FOUNDATION_EXPORT const unsigned char OmiseSDKVersionString[]; - - -#import diff --git a/OmiseSDK/PaymentChooserViewController.swift b/OmiseSDK/PaymentChooserViewController.swift index b8e9a297..290cd0fb 100644 --- a/OmiseSDK/PaymentChooserViewController.swift +++ b/OmiseSDK/PaymentChooserViewController.swift @@ -214,14 +214,11 @@ extension PaymentChooserOption { return [.duitNowOBW] case .payPay: return [.payPay] - default: - return [] } } } -@objc(OMSPaymentChooserViewController) -// swiftlint:disable:next type_body_length attributes +// swiftlint:disable:next type_body_length class PaymentChooserViewController: AdaptableStaticTableViewController, PaymentSourceChooser, PaymentChooserUI { @@ -234,7 +231,7 @@ class PaymentChooserViewController: AdaptableStaticTableViewController - + @@ -486,7 +486,7 @@ - + @@ -1570,7 +1570,7 @@ - + @@ -1595,7 +1595,7 @@ - + @@ -1768,7 +1768,6 @@ - @@ -1782,7 +1781,7 @@ - + @@ -1961,7 +1960,7 @@ - + @@ -2295,7 +2294,7 @@ - + @@ -2345,7 +2344,7 @@ - + @@ -2609,7 +2608,7 @@ - + @@ -2628,7 +2627,7 @@ - + @@ -2837,7 +2836,7 @@ - + @@ -2894,7 +2893,7 @@ - + @@ -2916,7 +2915,7 @@ - + @@ -2939,13 +2938,13 @@ - + @@ -2968,13 +2968,13 @@ - - + @@ -2438,7 +2438,7 @@ - + @@ -2462,7 +2462,7 @@ - + @@ -2486,7 +2486,7 @@ @@ -2945,7 +2945,7 @@ - + @@ -2968,13 +2968,13 @@ - + @@ -87,7 +87,7 @@ - + @@ -114,7 +114,7 @@ - + @@ -141,7 +141,7 @@ - + @@ -168,13 +168,13 @@ - + - + @@ -2438,7 +2438,7 @@ - + @@ -2462,7 +2462,7 @@ - + @@ -2486,7 +2486,7 @@ @@ -2945,7 +2945,7 @@ - + @@ -2968,13 +2968,13 @@ @@ -1376,7 +1395,7 @@ You can present via either Storyboard or Code and you can see the code in the Ex - + @@ -1400,7 +1419,7 @@ You can present via either Storyboard or Code and you can see the code in the Ex - + diff --git a/ExampleApp/Views/PaymentSettingTableViewController.swift b/ExampleApp/Views/PaymentSettingTableViewController.swift index f64bdfd5..e83991f5 100644 --- a/ExampleApp/Views/PaymentSettingTableViewController.swift +++ b/ExampleApp/Views/PaymentSettingTableViewController.swift @@ -129,6 +129,7 @@ class PaymentSettingTableViewController: UITableViewController { @IBOutlet private var duitNowOBWPaymentCell: UITableViewCell! @IBOutlet private var useCapabilityAPIValuesCell: UITableViewCell! @IBOutlet private var useSpecifiedValuesCell: UITableViewCell! + @IBOutlet private var weChatPaymentCell: UITableViewCell! override func viewDidLoad() { super.viewDidLoad() @@ -353,6 +354,8 @@ extension PaymentSettingTableViewController { return .duitNowQR case duitNowOBWPaymentCell: return .duitNowOBW + case weChatPaymentCell: + return .weChat default: return nil } @@ -447,6 +450,8 @@ extension PaymentSettingTableViewController { return duitNowQRPaymentCell case .duitNowOBW: return duitNowOBWPaymentCell + case .weChat: + return weChatPaymentCell default: return nil } diff --git a/OmiseSDK/Capability.swift b/OmiseSDK/Capability.swift index 32f9a989..b81889e0 100644 --- a/OmiseSDK/Capability.swift +++ b/OmiseSDK/Capability.swift @@ -93,6 +93,7 @@ extension Capability { case duitNowQR case duitNowOBW case payPay + case weChat case unknownSource(String, configurations: [String: Any]) } @@ -186,6 +187,8 @@ extension Capability.Backend.Payment { return true case (.payPay, .payPay): return true + case (.weChat, .weChat): + return true default: return false } @@ -322,6 +325,8 @@ extension Capability.Backend { self.payment = .duitNowOBW case .source(.payPay): self.payment = .payPay + case .source(.weChat): + self.payment = .weChat case .source(let value): let configurations = try container.decodeJSONDictionary() self.payment = .unknownSource(value.rawValue, configurations: configurations) @@ -342,7 +347,7 @@ extension Capability.Backend { case .installment(_, availableNumberOfTerms: let availableNumberOfTerms): try container.encode(Array(availableNumberOfTerms), forKey: .allowedInstallmentTerms) try container.encode(Array(supportedCurrencies), forKey: .supportedCurrencies) - case .internetBanking, .alipay, .alipayCN, .alipayHK, .atome, .dana, .gcash, .kakaoPay, .touchNGoAlipayPlus, .touchNGo, .promptpay, .paynow, .truemoney, .truemoneyJumpApp, .points, .billPayment, .eContext, .mobileBanking, .fpx, .rabbitLinepay, .ocbcPao, .ocbcDigital, .grabPay, .grabPayRms, .boost, .shopeePay, .shopeePayJumpApp, .maybankQRPay, .duitNowQR, .duitNowOBW, .payPay: + case .internetBanking, .alipay, .alipayCN, .alipayHK, .atome, .dana, .gcash, .kakaoPay, .touchNGoAlipayPlus, .touchNGo, .promptpay, .paynow, .truemoney, .truemoneyJumpApp, .points, .billPayment, .eContext, .mobileBanking, .fpx, .rabbitLinepay, .ocbcPao, .ocbcDigital, .grabPay, .grabPayRms, .boost, .shopeePay, .shopeePayJumpApp, .maybankQRPay, .duitNowQR, .duitNowOBW, .payPay, .weChat: // swiftlint:disable:previous line_length try container.encode(Array(supportedCurrencies), forKey: .supportedCurrencies) case .unknownSource(_, configurations: let configurations): @@ -465,6 +470,8 @@ extension Capability.Backend { self = .source(.duitNowOBW) case .payPay: self = .source(.payPay) + case .weChat: + self = .source(.weChat) case .unknownSource(let sourceType, configurations: _): self.init(sourceType: sourceType) } diff --git a/OmiseSDK/Globals.swift b/OmiseSDK/Globals.swift index e9fb5cc6..43df1038 100644 --- a/OmiseSDK/Globals.swift +++ b/OmiseSDK/Globals.swift @@ -162,6 +162,8 @@ extension SourceTypeValue { return "duitnow_obw" case .payPay: return "paypay" + case .weChat: + return "wechat_pay" } } } diff --git a/OmiseSDK/PaymentChooserViewController.swift b/OmiseSDK/PaymentChooserViewController.swift index fe6d5570..64772d4c 100644 --- a/OmiseSDK/PaymentChooserViewController.swift +++ b/OmiseSDK/PaymentChooserViewController.swift @@ -38,6 +38,7 @@ enum PaymentChooserOption: CaseIterable, Equatable, CustomStringConvertible { case touchNGo case grabPayRms case payPay + case weChat var description: String { switch self { @@ -111,6 +112,8 @@ enum PaymentChooserOption: CaseIterable, Equatable, CustomStringConvertible { return "GrabPay" case .payPay: return "PayPay" + case .weChat: + return "WeChat" } } } @@ -186,6 +189,8 @@ extension PaymentChooserOption { return [.duitNowOBW] case .payPay: return [.payPay] + case .weChat: + return [.weChat] } } } @@ -362,6 +367,8 @@ class PaymentChooserViewController: AdaptableStaticTableViewControllerD67rs%1)K(N@sfbS1nvf}zG*L?^#u|)eFbRS*A!%X>(@w>sjJzMHm18 z;?`CKB6!02OGFsl*-=q1!9y_6)Xo$D>e9BqB@6M5epW;~0EpTH0MW4kum-B4rvV@g z1pu=o0Knz}fIPGCsuK=0ccdejga+mFno=rLG8m zObI2!Il=T0HkN}&YzKpO?JOaT_^!fTwCxt`(k|~7!krqf0$+sZ&^-#!vgN0H9{sYFh{3i_T z(Pvu!myAPZegJJY<3o)&eg#-ZDu+V%AW(xTA#9M3vEg^P&C>p1_(ErSMw8T2rIuZ__t6b|_h?bis8e?@H7evNQoQ7Pb? z-pm1(w3%V6Zi_$IVXQfeLJnoHTo??x@z>u14*9jmM=%b_pOh_=^IF(pnW;DRbk_U%iExsUuTID+=v4m;rIeue{TJV)yezRz}>?@RYvB!;GxVr9SjH zm&~=!)X(YL$Vkt!%yh~e*Ywtt4^Ftcuex2`Q*uu8dBKW>S1Lh`LPVVET?u7-W_P7r zD|{U7VsrX6>PG>eqqxIWL>*!7{#eb`>>!(<*4)RsL=1ilO8pap>^f0>R_dol4OZ2N(u859mF^qM-dZTVZDquE;vH_c z0`EXT^KI zw-d<{FjhP#k^t)(h+a$BE`w0jdBd!d)~<}tAFN66*t46}IcJ7Ht@$AH^|~zAoJ`g*Ub*=IQg17`8-=YA_LpX+gH0> z7G{KbmbhS2kaSNbubl0YQyng4tUBsw({6FRwI?=SGa5AqY3^XY-=&?`u-}N%q#=d9 z{GxzY>J;7$3xvQjN2ZPZ-j;hWmE{I=G0&K`oFjUkHG;mKN_niV1viJ^n^nWK+60;} zi2Ojm{F6GRJWK3dT2|4vHw8jt%DBwVP-ty(jj0_Z1SwW+B$R@vUsev&mt3lZj;Yb2 zhu*_xNR>p3d)$rR1ckSsx|wz8RTOko_eWP%X62JT%fRtNzbN-F3XWfFUPNzv-%xXT z?Dlwfuhh)Er4W6mf;}(ATDu{5w%=dqF%j4IdZ`PI$H8%U) zi{&QXTv^?%C?vD3$;pAU6 z#S=w4vX`j@$)_R>DlU|#Ir;O)FU5Fx(4sZ-MoDM;GSkgPmn_PiZM*6zxT)^|rd4K=bd|=+USw6cYSj_>~Qj(qcNY({8BbHZ>?PyoBxm*4O z5_7=um-=U`y+LaT-pNj*Gq5__iNaFt;uf$yB3JXrT2D}&dWI!#$0sBaa*QRjHOhfu1sh@7ksI-}p zd6~7ZgT@85!ga;e9Bzx(>54Xu?HJB&^cSt~v*Fkl#dt$}?l1kF8iSTD>gQrBH8AP6 z&`hbwNV)wfTK@CD@0EHLpfNuGr&;yO3v%zsBL|}1#YlKQ&$FJz2&mCblejs3U2#L| zBM%r?(D>!ECSsI$XYvlzBv77sXlfx!kOBT{gR} zgqy`Z**Q&q36~tH?#ZBfOLN*@Io=D5KjL(XhJEbttmBmEB%n9_q^1gkCp9Kk{Tg=r z+-onv;_L5>;%BWfX#8E(MThnC@*2!m1e2(&5WPKWwce6s+A~+#h$o9A z*IhPYIV*Qh$Q;~Xm+bwA*=yc-28ZnS>Y&_7jL0pl)VUw^n?>*8MN zm)rna5SHbJ6;P6FL+@?N=UCsci#y)JQ%=~WDWFiH(!x-+EPak~yasvG~awZU>u!@bPapeDk*8td pWvckYNX0r0uNJn^zv>XZAqdN5CPpDvU+{kotu5>c=gmkl{{!5_m{kA( literal 0 HcmV?d00001 diff --git a/OmiseSDK/Resources/Assets.xcassets/Method/wechat_pay.imageset/wechat_pay@2x.png b/OmiseSDK/Resources/Assets.xcassets/Method/wechat_pay.imageset/wechat_pay@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..09991182ce60809107bff8e32912e5749d780450 GIT binary patch literal 4896 zcmZu#cRXBM*PbCk^b!%BA)o~@FJY7rUT%HA`@QG<_Fn6({XFa0Ywh#TIT&p%6)JKTasU88rKXD1IkyTIgN)>S zF12&Rog1Ksj*1eXVt{Ss{2|rKP|aFX6Cil*lL0OR=>fzSknBXC0WSTCaXhyd?yZaIFYDvuBVy<5;DIuCwGwf0w>e)U&IkUZkx%qD zUm>6PAO9j#2yxe~7`)TLVM5TbX;hxa+yNILiI|fZ*VNBmUVb{30dH zNXN><#nJ1cA~|sg1P=ax(SI}Ux!YNtcjtG8=%4uij{O^N_&*i?JNhRB4!&sVf3^6J z^ZPw|et>f1=hgi6GRTpCyiLIe0MIO}ArS9#u_pS=a`-73@yThC%fCesDQg6q zMF&$SwRr@PEZW-sxmvv+eKHPi~d?ksc{ zGBPHp?SPEFChW~Qo#Vd+4V=kZP= z)lAnVxwRk~ws_RmfVl3Tj4k}-w$~a5Bc70|^=&%XdhiS{o%!~7DRaNhn`$JcGp?BC zliH#V2l(LZt!b{u1hny2PIrzD0f>T~ydjC^$D z?H`@YY@#tM&bQmhYPzRY49%AQk}gFY^}f9>f{!Og@NH3{*K_TkNrtZF(tYxXpE}E- zA4vHeFKv7yZwenmuRXxwC0r3`!Obg-2JPVhF}8Qy5kEB-FnNv-r&I8}b8YjUPrA@i zw75>6v28{wV^-Jn5evbhY@=WqB*_Q)J3g`**UhiGY7Z+wh%PzLOeFr23K<6Lud$X|1oH&? z+Vt7EB3t)ZQJlcpp}S#Vwf5Jchy`o(dzW-=b;ezmCv*g+Y6K5vEhvcap}t(r#8_gq zXDpk3XCY?I;z)y&EY-Wt#I|UKql$Dfq!!A0IcZT(3%QwB^tLiJ!G^7p zYEn>cVzwQPrqMKJ1_HlnmnZH0A64^r%p}(muY9~o|52J;C$kv0v?EMLTb~Q(Wm%yTO&G>fhNS3!QJYF+XR{K_wqSq)e>BCwxb> zmZnzMYff7(8%+_(2DF#TUO^>d6>H<+oufRnt#|o3AfR^zmA<23{!hNgOC_=tav>*B z>8ErkB?J3A>WfG%u+d(-Y#{1{cs8URW4kMY=Ngtn(f&v<_?{OSerazOpV_p3zmr0` zw(B_qZBQ(mzT#|0!Xu8zBLI^;lTB7?NZue%A!?;}j_}5J@n!rk3}K(2%_0!-$tp*d zzjpK4S1S2c3;E?&2q?R#O99Ed$MW0yE52ENS+HYenJxqi0OV0^Xf9ANCf>wg38=0> z-NUCdIthn(P9ChH1lMUm0UQjy0j-tTbn;zHv7_!BBb$d%Q{)k=-1@}V#rHWFUjl{7 zshjI%5$uFd9j7&kRZl8*X1w}Ca?P1q$0!#){st7 zxBDhn+c%{HVwQB!?-ajrgQpv&SD}6Uy|hfAOqXZD7J}9%T|HGQ;uv@-g9E9SiuKK& zo*X4&SSqowku8>;J$8i?YubCQ3jMPRhQSgkjhFG`Y^*|jHqR#QgKJ`}vL1jxKR*!T zOOXt_cTdU?m`P^k5)85He7-=2+K`F;IfOiVJWB|IuddP-FRpm4*s2^;#}o<$T=S8d z4pmksvHK}w#(~TTbt5VU7fPv^twlU}E#nQ%+_<#A4uKNw*cCO3u~8QDkyOx8sHgYV zX!nW#f?_=AL_x15P0D_n3&ACnENZu+_GPcbtwCNhW1c<(AytHrIM3vnEDVdsGeMt6 z!=`QK(rP@~>0RLHrwF?JNr@a!=-idi!%O+X*Y+bnQJw3RKf`}5h+Bfpb=0B6e_K^i zmEc`!8T*>}=sx7MYdEBRQ2Rx@<~T<%V@L!P$26~ArAFW0A`2pUI8D>@q}x{Y71V!v z%+n_B6Yng5y8vij{aXhE8ES7|BUjZF@Nj1N=1G|W-V|9-U`Hfeov~_2MRH3cYv^?p z{clk!`HA<59_1_~y>16T6sD6lweqlM7dDENr+gx1n8h6j}bGRfD zG4!G;1(a9##2>#G4~^}FdeBur zt|?_Q_yYmAP-a;PP?lIhp!oe6*T>FQ#{lN_`nJ>w(JwT=4!%QZ1i+kZeTt7|B^2IW zInkxZd{>yQX$W9If!hZMxl{170UV0-UU!DC-4|okiyKk+Lf5*6DiiqjWhLTeOJ$Im zchfE|+1pAeK!WF*k7STB%dTXls8rq}+BU-kI}`F=0WOekaGlK$95*=*-&s-f)wlEF z6BLN3O{*!k0K7zR4`ib|s{0)_d&>h(o`D#ugSz?|%{tTQ>RYK@C_^QW{RH8(wyKUi zAgcL;YoBU5pi)*1uWQO{seiywYtR#cnFj zCW!eL)8=A!H;S6q%MvtmqNC%<^m_nB+$_dJ*BxR*x0U6h=ydGiD^5Lu#Ly!#TScaX zz@CZv1g3TylRolt#~FoK4vx-;JBC@2IW^ZG?xFpF?~cJkn;%PzPAybrk%f%AWjSeX zct3q=VuqU`j(stw9|9-)s|H^@%h;ywdtM4Ci6DK(?cj3PNp+eyi~YUs9+h|G&HC!s zOs!6Lmhw}+7%zcTWoYvRa8*5OoFUM?edUe&YUWv@njZ?V|0GTT) zjQ7S7J7Jaj-_vax@^!@INjh3j1M=mAFFm0TDJm_aiu%HW^i4S?jUyRbeQTlxjjS(v zeN@PUn5!^EIVws-z4@@26rOJ_c0;=QIyRA!G8o}E3A^I$#mp8XHNTyG71aIlCTQ)aW^4&+Wt0fxcQibZrh&UnipN zH@0|JWLHYCZ|1D_ZU3AzE`$)4V=>Byc$(a>z2|W+{;PdN+!4!cG)-XK;O3;X!Tkxx z3U`gHPVkm(^YvBSvxGW2X!qsq&7_x=qY4&tD*1W&REJKp*$XE{U&J(SJGJp~DS5sp z+3LL2oq(Br*4$B>Y*1-5HU6WeynG{QiaQ-e-n?A$dS-=+N$mM&>0_!EGSWUP`?8`Z z**+4a%c-KujBg5(D4?0#n{GmKqO#ORJiWhSWmcGmckh?#E^roV(N_Tsq);vkDg@79K8T6reQ3SH< z|LRZy-lvxkxQ?mcOLfN`A9mc~&W#@iJT@5_Pmb(3#j1fAl6UJ~ykit$b4BD~;$YcvUF_jk#tRI;(|4 zWlpUK3*3Nc=wg&L-~!N2z=;{G_X__5DW2{ivIuJIgVom_ewtx#Xu?cKN5w_Q^C>Q| zaQ#y8%Y@aGAxwHV-p4BrNm07_ApNB~?3zgkZOZ)hZD-vi+2xswU5XvKit?6&O0`?J zZaiTuihVsNf)Q}S;OXS&ZKXB8a_Zgk`J{zFb8%X$o_R3S*UZRdDx)CE#J5B2+nWiv zv5F0yEQ#sMz`1J~t}o(g2fntXJbhs!jIj}uGA6Lo&5H#~k2}~jENl9>klc*9yUm#H zs+5HQK9QdkAL5zICX>tfOWNj%D6In{t~ zFfl~ymy4$A_iMdnRm>QC{c)@=pQ8hY_n*Oi;AU8dWJ>wZA_oG~nPVYFSzjdld^)`+ z$L>_sO~)dAI^=&PYYWc~F05DF7k;fb2++H?`3q>dFQlGD89CPefXNiCT)w4vL$;qv z_gzbrua>>@CU<$w6W%BWt+MQ_RQJ6R%dTjmkvelK7U|H$eSzd!8fT||xh24upw|Ig zd}Kn&JJ-?Vsk?U^JkxRQ$xJ{Yij6^#W>7y-N7{|-je3i#u4xXi z2jxI#Qng;!l9_}krh2SGlM?5vHvB`@AbR5&TpDiAAyU!3qZH~zz{Iq3HIRM9#Saoe zRyXc@Ry@y?OT4=Jg0md}_<9CsP9=o2=H`pzcqL+-Ba4Vd~V9 zDE{nGNJF>0q$p=N!g)@S(bsgv==hK|eC|ht7!uyCOmTJ=c_wbz)TLXpwrunL8}ftS zso1v+cu5?PQAngm$^`(kVHS{!udk`!N!5gv`WocLE;NXv;xlB{!9(2+hf~iBRPyg% zjo`Fd0D!JQhgFon0+*w8`@oCE?avUy$ecU6G*v`MO&!ZjhFeZlnj0ZlxSRWQJ}Kh7PG=q!EykQV@_vI;2aaB}74nPGMwd ziHq;|esRBh&-v}W)?WL0*4k^W^Upaa=Apg@2_XX^001D-(o{9PmC!!}ANO`%$@G)H z6+mx8jR%0LF{bU?MYQ^9BHfIQ|Tv|2sur002wa$ru8M=;_MZc(@6{Y(1>)g#6t+|F8h^ z{<62Kn;jg+=I`d}?k(%D!2TCP_E!I67G`Jr3j%jhV29{EWK;3*vSYh1BqAij4klz{ zW0Uu?wU;$iRsWlQyHa3xgu^{$g@ym5<0t+n5n)jo85v;_F<~(=!CQo&cYr$_<}c{( z&G8Q>|Ma73=WXNVY{}bq6*Wc%K^ZZvJckjQmy3J46ALc16 zDkLKO|B>KM_WwTK|6={w`3LQ&7a(TckR$g{29quWQN-~2T0 zzEIw3mTx62kZ$DyC+ygm$-zwA^)5R(#DIa4)u*pJ`LYmH)_qfvz)KuXmgF@dxu8;o zEN5LAX4Hg9?eBXb7Fy~$Fltv4Nv`qfbeo!vc&i2w=*xSYH4)y~n?ucL{-Fbp$EQLM zHb~9{aC02YOnlQ&0g-uk!(YQ`hJ?EM>D0tS0|N5QywsU@Sm{Cjj71DOkQeT+qhq3N zIRZn*!l(~%Bo1lEkG}Z{&DX0a%1xTTG$ToCs_)LIpw*;RQf+SjcnyC%tT?#s1U^k6L_PhNF{wU`*ZbPjJ-fes(K*|mX9J;P0%==nJ z>V=!SV6SSVw8AGaez&^QJlTGQ%i@@Zu|{Xgy^f9Id*UY^@2W-0Xmt82`qsgN!dsOWy4`Wz* z;Ezu2xz-Q|qwg;93LBnmP2bn5noD-UEAfnhPrTxji??x-jW}LtKNbW5(iB zC&tsZCg%4CXz11brFdsu|G8igHt$jxhEH`)X?3PNC zgnjBC!)185Ep5+eensuqg~*ku?0%e10aZ^DNZ6XBamdPhQBG@a*8a>W9{0>GrjzI! zgZW<8iCBpPIVx_u|6Jw60jRq2ZlF7}$7}M#(9Gu+1wg#$x1`VS3xp``R7Pn^H@J~B zeU-${pB<~m&S&A^b%likT~Q)0z)(<8sNQ3n!Bm-o*&fT}SVBYcfPCi95qb%9ZxIKN z3ctVKG#m;aeIfMh$!d><^8dn1-ShF0B&NVs<6k|8>Bbxmej{CY|($oW5C`iF9Max79cHA+5ipx{P4iF z{D&4se)0bI$00A4$~o?zFK&B>^1PF-ZmX@6NnM)ZG=eU<z594QWPnf6rW>!?w7*rdNx1Se7xq=9al&S_@2$7dr^0`xb0_! z5WJz9qu#~*3ev6;+lY1fzWW%;-2KzkWQ|JSDx2tOgp3H0;0@q(+hH0Yh@`bW20F7d zv?$+utZJ|Bf_2ZrwB0zocub3-^K;S4DKpP?CoSv4VH%50 zFKVZ1MqQdm5E#%44JL2c+TFw$+(4i7Wba7*oM$meLMO6kg51@nnftHo5hjFa6LoEx zkX`mywfR@g*P|<^wjN#$$=rLVC-x-Z?sqhWX9}R;eoVIlAr~$ErNRZ$p)z|&a!c42 z0DcE18GKl&ODIB{o_ihCduH=gBird&Lu*u?GDh=R0|KF2^Lvo}iqaHkCVAIA5H@RK zvo_SYiS@nyL6IG}QP>q~V*mAkHe>ki_#9Nfs!s4Uze#ZZ(t?|{aft?<6<~iDtg$Hh zpq2k;8PCVg0!AcUWiR$ua3Hz;{l1wOOIcYnf{Tr^id60`_&cR?aYv?#$qq^n@-T0iZ0}lmH;mB zMcvbRAbnKEw1BJI6E?w9_sn9^mC695DhRu={?l>Tv_B~D1#4J& zp|iC{K}y<(;P7?W4X~2n*KfwDXLCJHH64zjbK5E%GN_}u&_?<#=ncGP>4}}GnRiWD zuN4247)>umb|zTk1X-~#A5Y#R+tx!L=GHxx!mpwb+@XqW)1RvZEFDy%_he#?aE>E*u0g*V(4?`o}LC7l%c@dachBsOW??wO%R>O zwp}~yTtSlS zzZq9mdsUC%NLpFwjwN7B^A>kpW(^@h&&BU}8+LVM=LMk!hoMUp_wGRI>%RbvBBrU zITS~L0Gds=6#c-AG)zQOIkuLCEiAI&ao3-n1zS}wF2omd0!ey+P#sGhyrM(-fQfU$t`>S53bH74kz0`B z+@(I7mE$9q6NRO>Fg_ftDf>`BUcEImCO9{_Z9k%Kys%tm4NPxAuKHc#ahmdx7Y({3V;9p(vF0yLZcn*w-lw2BC!)~}>2yfnxv1(*IkFOkn@N6q6JwKLBAOff z8p9y@0I=0d|3%i!)~89^vJQKYi}IzlA~u-X??(_{-*=>2y0xq}6Ky~Ozp_zJ+>qEi zcPFCb%lkt{;jHy@&$Tpd-bsGB<_uuT6>xG~;RM%B_fb>f60S~slpqOHdn7X^uyupL{XFWD0}K;^MaR)MvA9jL7+ zQLtZo6D&TM&o%z+zTd<8zS%yu3bY^8CY3ZeQ3#y6Y%N>A`ttBGG7hpAl3k$rkTO^( zqpxB*(CLmrx2q*~j33A-+fXqJ#VvxX$%KKh`Z9=^kid=mZH1q~L&pfVs)lGysuRn7&ZVMgvj0%~`c;gLyFCrO# zv+m0AIZ>CUgBRdfg~JuV_2S76E_nef9=`ye9&hJJyLASa;W=Ia9XNUO7)tmmqVIWV zL6fuarNB)X-wcmbt(A;rM$fk1g5`Rwl5e%xXY$$kTuNiRYOkVm3k@Ah)z1o13Z%u& zzRMfs`+840>^f7Tm+J-lG1qWZPl67ZUl8LSFI-2#KAoi=LoFc!33{g?! z+icV#$rC%;kj<|iUGas#QH4}%;0d)m-ziw0NK4HF#^F+M9zVErcN#AGZOVP7Nxs}1 z&w-e!STu-Bdh>`Whvme{GkQ|tWfhJmRUMP^z0q}19sVCOC!Hvc3ovI4$~&J{663iV zV9F&2P(i$-c9u1?so*G<0+j5Mi@a(A?!&AakgE>4Q<{k=xb*L{zPa;zz!CN{LspOF{MZH(62|lSI1^YhHO2}x^loY2Y5}92eD`qpN@F#z@ zL>P22ML9yW)jpMEtoQuGMRl$AGV;QH?^Cf2?#04)^wsVJrF#^nK_nAWG&YbrG3BO({ z9VVmj&1z+}RlEfulFF#M&m}sc&8)AY%e69dyzjQ2IfaC^;$OVM=~<^Lz4{nDNde_) zkSW7F27GZ-N=?xSJ2+J^x)VH0nk!rj@;se9?KPom@f^7aYp+_MB9hzjE9A%_6L)TR zNPrhI5opj|F`m#h2N~?W2U{7)uRDjilAz10>%+)2zqBFR02F7T`M;*3IDki<%xpJl zR_AUJ)xnPgYCg{aoLiI0eCON(v4lGeUD)r5PXiQ`>{W^r^VuR0 z?HnN-@kLs@z-Q(A1`cIjbd%;dtrZx*tl541a8S{BT7~X;_`_x(noTC2W4fxi(LMNz zfB($`+>wd}R$`!zfc#QU`VuN=<3-j^Fmh#0p0N>lMr{cyQ*_)q6IJ&)H5ccYju4|E zQQmo*R1a0Z!AC8PH)!;^Zuwq|`&RTLy41RdJd-O`I4V3z`351&lDYlwz>+qTAG$9r zgY5foX%!=zFy-gzGD0RRt?a%B#xMbB{srIf!9blNWh;So$evfa&q`NKeQ;@Ip4uyZ!kGDf~vArHX_vBmrN@e-bt2lyr zPayGCz|52njh<1hg07Vo(K6ridvL2{A}nbuY9rlDDVn!h*0%#|x;S7=_@6a$g4CZ+#yMj94s)bOc}^jhWdy;%;k#$!(B-+{i0ZvyT3_s(e6yxW z7bPC9vHATLsKMdXsE*=GcuJ6{kH2wDdK1zsE6RwFva5d=uX%~&i~q_#)kT^6oK2y% z-sl4^VJ(mdh*Ta@fb)|i31Tw4xotjR*BL2f9MOwmk<9dNxo=CG@_B042zeic=vGaoUu2WX_9G~(8z0nKffn0wTLak47u!h9 zD^KV%40n2GcnFkuatN_`vM$@*$A| zRrJNjpJzYATz+{KkHaM!6_wCF8Ww!RF!1t2O2Vnm`E~7Dk%$0La}_2D?=o=|rPDE! zguza>;hS0l#<(3j%GvplvmGaKnaY|rKkB9FZE@FSIUZc&lbnbPOV5TpQ?_8K7W1ra zvAASB5mhYwLQmE@>4Z$ec_+bCi)taG&iH`NeM{o(5a5faOPXn4N8+fbJAe)=sot;zQUf0&^!%G(-*<$?#5){&X9l}bZGe*>^7XV*lKGM2F=xi0 zA)XC05(#qjprzm!UCvS*sZ4Lxed`SHuu|-H_q(ghe$I|{>~rugWIt~)uIZAM^$V=s zNqsYQS9$|?BA2S@IYHNfYX3Z^b~ZX=H&B;R5ijDE+ZKC#P*?To_UVSw=&P)<&|(pP z4AlNE-SuIajh)>(fximcRbXC@G$n}GzRZEm%+(iT5B<*Q`DzEb;CV@&fWG@}LqPx; zGRGX>(cry3a8)L8hXASMfb8GMNqd+AR(i#BnFNemX6iebJMUate+KA%w-2~+$Xw{W z+HTeJ5UXMlw6|T;f~HK$YnrUxR}--j4-y}j$WDnR znt|ZaUk{h;zRhAmlp<>c-cI0lY_0H?-c)Ah{OI;?wc!9Lt`Ur?}xF!hSDs0z{Z$INvS}YO<`!}ukoiMyM>O @@ -3127,7 +3157,7 @@ - + @@ -3811,6 +3841,7 @@ + diff --git a/OmiseSDK/SourceTypeValue.swift b/OmiseSDK/SourceTypeValue.swift index b5ead775..36938ead 100644 --- a/OmiseSDK/SourceTypeValue.swift +++ b/OmiseSDK/SourceTypeValue.swift @@ -56,6 +56,7 @@ public enum SourceTypeValue: String { case duitNowOBW = "duitnow_obw" case atome = "atome" case payPay = "paypay" + case weChat = "wechat_pay" public init?(_ rawValue: String) { if let value = SourceTypeValue(rawValue: rawValue) { diff --git a/OmiseSDKTests/PaymentInformationTestCase.swift b/OmiseSDKTests/PaymentInformationTestCase.swift index 95db11e3..069095d4 100644 --- a/OmiseSDKTests/PaymentInformationTestCase.swift +++ b/OmiseSDKTests/PaymentInformationTestCase.swift @@ -1107,5 +1107,30 @@ class PaymentInformationTestCase: XCTestCase { } } + func testEncodeWeChatSourceParameter() throws { + let encoder = PaymentInformationTestCase.makeJSONEncoder() + + do { + let sourceParameter = Source.CreateParameter(paymentInformation: .weChat, + amount: 10_000_00, + currency: .thb) + let encodedJSONString = String(data: try encoder.encode(sourceParameter), encoding: .utf8) + XCTAssertEqual( + """ + { + "amount" : 1000000, + "currency" : "THB", + "email" : null, + "items" : null, + "name" : null, + "phone_number" : null, + "platform_type" : "IOS", + "shipping" : null, + "type" : "wechat_pay" + } + """, encodedJSONString) + } + } + } // swiftlint:enable function_body_length From 918876dbb8ed2b94d32cb362b14aaa0455d4f8bf Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Mon, 22 Jan 2024 13:26:21 +0700 Subject: [PATCH 032/204] Renamed WeChat to WeChat Pay --- ExampleApp/Resources/Main.storyboard | 2 +- OmiseSDK/PaymentChooserViewController.swift | 2 +- OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ExampleApp/Resources/Main.storyboard b/ExampleApp/Resources/Main.storyboard index 1cc62716..eff4426f 100644 --- a/ExampleApp/Resources/Main.storyboard +++ b/ExampleApp/Resources/Main.storyboard @@ -1095,7 +1095,7 @@ You can present via either Storyboard or Code and you can see the code in the Ex - - + @@ -185,7 +184,7 @@ You can present via either Storyboard or Code and you can see the code in the Ex - + @@ -316,8 +315,8 @@ You can present via either Storyboard or Code and you can see the code in the Ex - "Try Capability API" will try to load the allowed payment methods from the Capability API and use it if it's available. -"Use specific payment methods" will ignore the allowed payment methods from the Capability API and always use the payment method specified below + "Try CapabilityOld API" will try to load the allowed payment methods from tCapabilityOld API and use it if it's available. +"Use specific payment methods" will ignore the allowed payment methods from tCapabilityOld API and always use the payment method specified below @@ -326,7 +325,7 @@ You can present via either Storyboard or Code and you can see the code in the Ex - - + @@ -1357,20 +1356,6 @@ You can present via either Storyboard or Code and you can see the code in the Ex - - - - - - - - - - - - - - diff --git a/ExampleApp/Views/CustomCreditCardFormViewController.swift b/ExampleApp/Views/CustomCreditCardFormViewController.swift index c66a567e..ace569d2 100644 --- a/ExampleApp/Views/CustomCreditCardFormViewController.swift +++ b/ExampleApp/Views/CustomCreditCardFormViewController.swift @@ -6,7 +6,7 @@ protocol CustomCreditCardFormViewControllerDelegate: AnyObject { /// Delegate method for receiving token data when card tokenization succeeds. /// - parameter token: `OmiseToken` instance created from supplied credit card data. /// - seealso: [Tokens API](https://www.omise.co/tokens-api) - func creditCardFormViewController(_ controller: CustomCreditCardFormViewController, didSucceedWithToken token: Token) + func creditCardFormViewController(_ controller: CustomCreditCardFormViewController, didSucceedWithToken token: TokenOld) /// Delegate method for receiving error information when card tokenization failed. /// This allows you to have fine-grained control over error handling when setting @@ -161,7 +161,7 @@ class CustomCreditCardFormViewController: UIViewController { let cvv = cardCVVField.text else { return } - let tokenRequest = Request( + let tokenRequest = Request( name: name, pan: cardNumberField.pan, expirationMonth: expiryMonth, diff --git a/ExampleApp/Views/ProductDetailViewController.swift b/ExampleApp/Views/ProductDetailViewController.swift index 996574b4..dedc0648 100644 --- a/ExampleApp/Views/ProductDetailViewController.swift +++ b/ExampleApp/Views/ProductDetailViewController.swift @@ -4,7 +4,7 @@ import OmiseSDK class ProductDetailViewController: BaseViewController { private let publicKey = LocalConfig.default.publicKey - private var capability: Capability? + private var capability: CapabilityOld? override func viewDidLoad() { super.viewDidLoad() @@ -20,7 +20,7 @@ class ProductDetailViewController: BaseViewController { client.capabilityDataWithCompletionHandler { (result) in if case .success(let capability) = result { self.capability = capability - print("Capability Country: \(capability.countryCode)") + print("CapabilityOld Country: \(capability.countryCode)") } } } @@ -145,10 +145,10 @@ extension ProductDetailViewController: CreditCardFormViewControllerDelegate { dismissForm() } - func creditCardFormViewController(_ controller: CreditCardFormViewController, didSucceedWithToken token: Token) { + func creditCardFormViewController(_ controller: CreditCardFormViewController, didSucceedWithToken token: TokenOld) { dismissForm { let alertController = UIAlertController( - title: "Token Created", + title: "TokenOld Created", message: "A token with id of \(token.id) was successfully created. Please send this id to server to create a charge.", preferredStyle: .alert ) @@ -196,10 +196,10 @@ extension ProductDetailViewController: PaymentCreatorControllerDelegate { switch payment { case .token(let token): - title = "Token Created" + title = "TokenOld Created" message = "A token with id of \(token.id) was successfully created. Please send this id to server to create a charge." case .source(let source): - title = "Token Created" + title = "TokenOld Created" message = "A source with id of \(source.id) was successfully created. Please send this id to server to create a charge." } @@ -229,10 +229,10 @@ extension ProductDetailViewController: PaymentCreatorControllerDelegate { // MARK: - Custom Credit Card Form View Controller Delegate extension ProductDetailViewController: CustomCreditCardFormViewControllerDelegate { - func creditCardFormViewController(_ controller: CustomCreditCardFormViewController, didSucceedWithToken token: Token) { + func creditCardFormViewController(_ controller: CustomCreditCardFormViewController, didSucceedWithToken token: TokenOld) { dismissForm { let alertController = UIAlertController( - title: "Token Created", + title: "TokenOld Created", message: "A token with id of \(token.id) was successfully created. Please send this id to server to create a charge.", preferredStyle: .alert ) diff --git a/OmiseSDK/CreditCardFormViewController.swift b/OmiseSDK/CreditCardFormViewController.swift index 05f485b9..34bfef19 100644 --- a/OmiseSDK/CreditCardFormViewController.swift +++ b/OmiseSDK/CreditCardFormViewController.swift @@ -7,7 +7,7 @@ public protocol CreditCardFormViewControllerDelegate: AnyObject { /// Delegate method for receiving token data when card tokenization succeeds. /// - parameter token: `OmiseToken` instance created from supplied credit card data. /// - seealso: [Tokens API](https://www.omise.co/tokens-api) - func creditCardFormViewController(_ controller: CreditCardFormViewController, didSucceedWithToken token: Token) + func creditCardFormViewController(_ controller: CreditCardFormViewController, didSucceedWithToken token: TokenOld) /// Delegate method for receiving error information when card tokenization failed. /// This allows you to have fine-grained control over error handling when setting @@ -415,7 +415,7 @@ public class CreditCardFormViewController: UIViewController, PaymentChooserUI, P token.id) if let delegate = strongSelf.delegate { delegate.creditCardFormViewController(strongSelf, didSucceedWithToken: token) - os_log("Credit Card Form Create Token succeed delegate notified", log: uiLogObject, type: .default) + os_log("Credit Card Form Create TokenOld succeed delegate notified", log: uiLogObject, type: .default) } else { os_log("There is no Credit Card Form's delegate to notify about the created token", log: uiLogObject, type: .default) } diff --git a/OmiseSDK/CreditCardFormViewModel.swift b/OmiseSDK/CreditCardFormViewModel.swift index 60bb0bb7..02288955 100644 --- a/OmiseSDK/CreditCardFormViewModel.swift +++ b/OmiseSDK/CreditCardFormViewModel.swift @@ -42,7 +42,7 @@ class CreditCardFormViewModel: CreditCardFormViewModelProtocol, CountryListViewM return result } - func onSubmitButtonPressed(_ viewContext: ViewContext, publicKey: String?, onComplete: @escaping (RequestResult) -> Void) { + func onSubmitButtonPressed(_ viewContext: ViewContext, publicKey: String?, onComplete: @escaping (RequestResult) -> Void) { guard let publicKey = publicKey else { os_log("Missing or invalid public key information - %{private}@", log: uiLogObject, type: .error, publicKey ?? "") @@ -52,7 +52,7 @@ class CreditCardFormViewModel: CreditCardFormViewModelProtocol, CountryListViewM os_log("Requesting to create token", log: uiLogObject, type: .info) - let request = Request( + let request = Request( name: viewContext.name, pan: viewContext.pan, expirationMonth: viewContext.expirationMonth, diff --git a/OmiseSDK/CreditCardFormViewModelProtocol.swift b/OmiseSDK/CreditCardFormViewModelProtocol.swift index d20a9b5f..92e64225 100644 --- a/OmiseSDK/CreditCardFormViewModelProtocol.swift +++ b/OmiseSDK/CreditCardFormViewModelProtocol.swift @@ -16,7 +16,7 @@ protocol CreditCardFormViewModelProtocol { var countryListViewModel: CountryListViewModelProtocol { get } var isAddressFieldsVisible: Bool { get } - func onSubmitButtonPressed(_ viewContext: ViewContext, publicKey: String?, onComplete: @escaping (RequestResult) -> Void) + func onSubmitButtonPressed(_ viewContext: ViewContext, publicKey: String?, onComplete: @escaping (RequestResult) -> Void) func error(for: AddressField, validate: String?) -> String? func title(for: AddressField) -> String? func placeholder(for: AddressField) -> String? diff --git a/OmiseSDK/Done/Capability.swift b/OmiseSDK/Done/CapabilityOld.swift similarity index 94% rename from OmiseSDK/Done/Capability.swift rename to OmiseSDK/Done/CapabilityOld.swift index 3060387d..a0358fa6 100644 --- a/OmiseSDK/Done/Capability.swift +++ b/OmiseSDK/Done/CapabilityOld.swift @@ -1,7 +1,7 @@ // swiftlint:disable file_length import Foundation -public struct Capability: Object { +public struct CapabilityOld: Object { public let countryCode: String public let location: String public let object: String @@ -10,20 +10,20 @@ public struct Capability: Object { public let supportedBackends: [Backend] - private let backends: [Capability.Backend.BackendType: Backend] + private let backends: [CapabilityOld.Backend.BackendType: Backend] - public var creditCardBackend: Capability.Backend? { + public var creditCardBackend: CapabilityOld.Backend? { return backends[.card] } - public subscript(type: SourceTypeValue) -> Capability.Backend? { + public subscript(type: SourceTypeValue) -> CapabilityOld.Backend? { return backends[.source(type)] } } -extension Capability { - public static func ~= (lhs: Capability, rhs: CreateSourceParameter) -> Bool { - func backend(from capability: Capability, for payment: PaymentInformation) -> Backend? { +extension CapabilityOld { + public static func ~= (lhs: CapabilityOld, rhs: CreateSourceParameter) -> Bool { + func backend(from capability: CapabilityOld, for payment: PaymentInformation) -> Backend? { if let paymentSourceType = SourceTypeValue(payment.sourceType) { return capability[paymentSourceType] } else { @@ -53,7 +53,7 @@ extension Capability { } } -extension Capability { +extension CapabilityOld { public struct Backend: Codable, Equatable { public let payment: Payment public let supportedCurrencies: Set @@ -110,7 +110,7 @@ extension Capability { } } -extension Capability: Codable { +extension CapabilityOld: Codable { private enum CodingKeys: String, CodingKey { case countryCode = "country" case object @@ -120,7 +120,7 @@ extension Capability: Codable { } } -extension Capability.Backend { +extension CapabilityOld.Backend { private enum CodingKeys: String, CodingKey { case object case name @@ -132,9 +132,9 @@ extension Capability.Backend { } } -extension Capability.Backend.Payment { +extension CapabilityOld.Backend.Payment { // swiftlint:disable:next function_body_length - public static func == (lhs: Capability.Backend.Payment, rhs: Capability.Backend.Payment) -> Bool { + public static func == (lhs: CapabilityOld.Backend.Payment, rhs: CapabilityOld.Backend.Payment) -> Bool { switch (lhs, rhs) { case (.card, .card), (.alipay, .alipay), (.alipayCN, .alipayCN), (.alipayHK, .alipayHK): return true @@ -192,7 +192,7 @@ extension Capability.Backend.Payment { } } -extension Capability { +extension CapabilityOld { public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) @@ -204,16 +204,16 @@ extension Capability { var backendsContainer = try container.nestedUnkeyedContainer(forKey: .paymentBackends) - var backends: [Capability.Backend] = [] + var backends: [CapabilityOld.Backend] = [] while !backendsContainer.isAtEnd { - let backend = try backendsContainer.decode(Capability.Backend.self) + let backend = try backendsContainer.decode(CapabilityOld.Backend.self) backends.append(backend) } self.supportedBackends = backends - let backendTypes = backends.compactMap { Capability.Backend.BackendType(payment: $0.payment) } + let backendTypes = backends.compactMap { CapabilityOld.Backend.BackendType(payment: $0.payment) } self.backends = Dictionary(uniqueKeysWithValues: zip(backendTypes, backends)) } @@ -233,7 +233,7 @@ extension Capability { } } -extension Capability.Backend { +extension CapabilityOld.Backend { // swiftlint:disable:next function_body_length public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) @@ -356,7 +356,7 @@ extension Capability.Backend { } private let creditCardBackendTypeValue = "card" -extension Capability.Backend { +extension CapabilityOld.Backend { fileprivate enum BackendType: Codable, Hashable { case card case source(SourceTypeValue) @@ -400,7 +400,7 @@ extension Capability.Backend { } // swiftlint:disable:next function_body_length - init?(payment: Capability.Backend.Payment) { + init?(payment: CapabilityOld.Backend.Payment) { switch payment { case .card: self = .card @@ -494,7 +494,7 @@ extension Capability.Backend { } } -extension Capability.Backend { +extension CapabilityOld.Backend { fileprivate enum Provider: String, Codable, Hashable { case alipayPlus = "Alipay_plus" case rms = "RMS" diff --git a/OmiseSDK/Done/Token.swift b/OmiseSDK/Done/TokenOld.swift similarity index 94% rename from OmiseSDK/Done/Token.swift rename to OmiseSDK/Done/TokenOld.swift index 02f8fee1..b7895171 100644 --- a/OmiseSDK/Done/Token.swift +++ b/OmiseSDK/Done/TokenOld.swift @@ -1,7 +1,7 @@ import Foundation -/// Parameter for creating a new `Token` -/// - seealso: Token +/// Parameter for creating a new `TokenOld` +/// - seealso: TokenOld public struct CreateTokenParameter: Encodable { /// Card holder's full name. public let name: String @@ -138,8 +138,8 @@ public enum ChargeStatus: String, Codable { case successful } -/// Represents an Omise Token object -public struct Token: CreatableObject { +/// Represents an Omise TokenOld object +public struct TokenOld: CreatableObject { public typealias CreateParameter = CreateTokenParameter public static let postURL: URL = Configuration.default.environment.tokenURL @@ -148,19 +148,19 @@ public struct Token: CreatableObject { /// Omise ID of the token public let id: String - /// Boolean indicates that if this Token is in the live mode + /// Boolean indicates that if this TokenOld is in the live mode public let isLiveMode: Bool - /// URL for fetching the Token data + /// URL for fetching the TokenOld data public let location: String /// Boolean indicates that if this token is already used for creating a charge already public var isUsed: Bool - /// Card that is used for creating this Token + /// Card that is used for creating this TokenOld public let card: Card? - /// Date that this Token was created + /// Date that this TokenOld was created public let createdDate: Date /// Status of charge created using this token @@ -234,9 +234,9 @@ public struct Card: Decodable { } } -extension Request where T == Token { +extension Request where T == TokenOld { - /// Initializes a new Token Request with the given information + /// Initializes a new TokenOld Request with the given information public init( name: String, pan: PAN, @@ -267,7 +267,7 @@ extension Request where T == Token { )) } - /// Initializes a new Token Request with the given information + /// Initializes a new TokenOld Request with the given information public init( name: String, number: String, diff --git a/OmiseSDK/FPXBankChooserViewController.swift b/OmiseSDK/FPXBankChooserViewController.swift index 8a05f274..5433fc23 100644 --- a/OmiseSDK/FPXBankChooserViewController.swift +++ b/OmiseSDK/FPXBankChooserViewController.swift @@ -1,7 +1,7 @@ import UIKit import os -class FPXBankChooserViewController: AdaptableDynamicTableViewController, PaymentSourceChooser, PaymentChooserUI { +class FPXBankChooserViewController: AdaptableDynamicTableViewController, PaymentSourceChooser, PaymentChooserUI { var email: String? var flowSession: PaymentCreatorFlowSession? private let defaultImage: String = "FPX/unknown" @@ -12,7 +12,7 @@ class FPXBankChooserViewController: AdaptableDynamicTableViewController, PaymentSourceChooser, PaymentChooserUI { - var capability: Capability? + var capability: CapabilityOld? var flowSession: PaymentCreatorFlowSession? var duitNowOBWBanks: [PaymentInformation.DuitNowOBW.Bank] = PaymentInformation.DuitNowOBW.Bank.allCases @@ -494,7 +494,7 @@ class PaymentChooserViewController: AdaptableStaticTableViewController(api: APIProtocol, completion: @escaping RequestResultClosure) { + let urlRequest = urlRequest(publicKey: publicKey, api: api) + network.send( + urlRequest: urlRequest, + dateFormatter: api.dateFormatter, + completion: completion + ) + } + + /// Observe Token Charge Status until it changes + /// Sends API request every `timeInterval` with number of`maxAttempt`attempts. + /// - Parameters: + /// - tokenId: Token ID + /// - timeInterval: TimeInterval between polling requests + /// - attemp: Current attemp + /// - maxAttempt: Maximum number of attemps + func observeChargeStatusUntilChange( + tokenID: String, + timeInterval: Int, + attemp: Int, + maxAttempt: Int, + _ completion: @escaping RequestResultClosure + ) { + guard maxAttempt > attemp else { + return + } + token(tokenID: tokenID) { [weak self] (result: (Result)) in + switch result { + case .success(let token) where token.chargeStatus.isFinal: + completion(.success(token.chargeStatus)) + case .success(let token): + guard attemp + 1 < maxAttempt else { + completion(.success(token.chargeStatus)) + return + } + + let queue = DispatchQueue.global(qos: .background) + queue.asyncAfter(deadline: .now() + .seconds(timeInterval)) { + self?.observeChargeStatusUntilChange( + tokenID: tokenID, + timeInterval: timeInterval, + attemp: attemp + 1, + maxAttempt: maxAttempt, + completion + ) + } + + case .failure(let error): + completion(.failure(error)) + } + } + } + + /// Perform Token API request with given Token ID + /// - returns Token + func token(tokenID: String, _ completion: @escaping RequestResultClosure) { + apiRequest(api: OmiseAPI.token(tokenID: tokenID), completion: completion) + } +} diff --git a/OmiseSDK/Refactoring/New/Client/ClientNew+URLRequest.swift b/OmiseSDK/Refactoring/New/Client/Client+URLRequest.swift similarity index 97% rename from OmiseSDK/Refactoring/New/Client/ClientNew+URLRequest.swift rename to OmiseSDK/Refactoring/New/Client/Client+URLRequest.swift index 5776adf4..8f186c0f 100644 --- a/OmiseSDK/Refactoring/New/Client/ClientNew+URLRequest.swift +++ b/OmiseSDK/Refactoring/New/Client/Client+URLRequest.swift @@ -2,7 +2,7 @@ import Foundation import UIKit.UIDevice // TODO: Make it private and move test code to another test of public method -extension ClientNew { +extension Client { func customURL(api: APIProtocol) -> URL? { switch api.server { case .api: @@ -38,7 +38,7 @@ extension ClientNew { // MARK: User Agent // TODO: Make it private and move test code to another test of public method -extension ClientNew { +extension Client { func userAgent( sdkVersion: String = OmiseSDK.shared.version, platform: String = ProcessInfo.processInfo.operatingSystemVersionString, @@ -50,7 +50,7 @@ extension ClientNew { // MARK: HTTP Headers // TODO: Make it private and move test code to another test of public method -extension ClientNew { +extension Client { enum HTTPHeaders: String { case authorization = "Authorization" case userAgent = "User-Agent" diff --git a/OmiseSDK/Refactoring/New/Client/Client.swift b/OmiseSDK/Refactoring/New/Client/Client.swift new file mode 100644 index 00000000..841c6125 --- /dev/null +++ b/OmiseSDK/Refactoring/New/Client/Client.swift @@ -0,0 +1,59 @@ +import Foundation +import os + +// TODO: Add Unit Tests +public class Client { + public typealias RequestResultClosure = (Result) -> Void + + private enum Const { + static let observingAttemptsCount = 10 + static let observingTimeInterval = 3 + } + + let publicKey: String + let network: NetworkService + + public convenience init(publicKey: String) { + self.init(publicKey: publicKey, network: NetworkService()) + } + + init(publicKey: String, network: NetworkService) { + self.publicKey = publicKey + self.network = network + } + + /// Perform Capability API Request + /// - returns Capability + public func capability(_ completion: @escaping RequestResultClosure) { + apiRequest(api: OmiseAPI.capability) { (result: Result) in + if let capability = try? result.get() { + OmiseSDK.shared.setCurrentCountry(countryCode: capability.countryCode) + } + completion(result) + } + } + + /// Observe Token Charge Status until it changes + /// Sends API request every `timeInterval` with number of`maxAttempt`attempts. + /// - returns Latest charge status value + public func observeChargeStatusUntilChange(tokenID: String, _ completion: @escaping RequestResultClosure) { + observeChargeStatusUntilChange( + tokenID: tokenID, + timeInterval: Self.Const.observingTimeInterval, + attemp: 0, + maxAttempt: Self.Const.observingAttemptsCount, + completion + ) + } + + /// Send Create a Token API request with given Card Payload + /// - returns Created Token + public func createToken(payload: CardPaymentPayload, _ completion: @escaping RequestResultClosure) { + apiRequest(api: OmiseAPI.createToken(payload: payload), completion: completion) + } + + /// Sends Create a Source API request with given Source Payload + public func createSource(payload: SourcePaymentPayload, _ completion: @escaping RequestResultClosure) { + apiRequest(api: OmiseAPI.createSource(payload: payload), completion: completion) + } +} diff --git a/OmiseSDK/Refactoring/New/Client/ClientNew.swift b/OmiseSDK/Refactoring/New/Client/ClientNew.swift deleted file mode 100644 index 18cd7aaa..00000000 --- a/OmiseSDK/Refactoring/New/Client/ClientNew.swift +++ /dev/null @@ -1,116 +0,0 @@ -import Foundation -import os - -// TODO: (REFACTOR) NETWORK SERVICE -// TODO: (COMMENTS) ADD DESCRIPTIONS TO PUBLIC PROPERTIES AND DATA TYPES - -// TODO: (UNIT TESTS) DEFINE TEST DATA COLLECTION -// TODO: (UNIT TESTS) ADD REMAINING UNIT TESTS -// TODO: (UNIT TESTS) CLEAN UNIT TESTS - - - - -// TODO: Rename to ClientOld -public class ClientNew { - public typealias RequestResultClosure = (Result) -> Void - - private enum Const { - static let observingAttemptsCount = 10 - static let observingTimeInterval = 3 - } - - private let publicKey: String - private let network: NetworkService - - public convenience init(publicKey: String) { - self.init(publicKey: publicKey, network: NetworkService()) - } - - init(publicKey: String, network: NetworkService) { - self.publicKey = publicKey - self.network = network - } - - public func capability(_ completion: @escaping RequestResultClosure) { - apiRequest(api: OmiseAPI.capability) { (result: Result) in - if let capability = try? result.get() { - OmiseSDK.shared.setCurrentCountry(countryCode: capability.countryCode) - } - completion(result) - } - } - - public func observeChargeStatusUntilChange(tokenID: String, _ completion: @escaping RequestResultClosure) { - observeChargeStatusUntilChange( - tokenID: tokenID, - timeInterval: Self.Const.observingTimeInterval, - attemp: 0, - maxAttempt: Self.Const.observingAttemptsCount, - completion - ) - } - - public func createToken(cardPayment: CardPayment, _ completion: @escaping RequestResultClosure) { - apiRequest(api: OmiseAPI.createToken(cardPayment: cardPayment), completion: completion) - } -} - -extension ClientNew { - func createSource(sourcePayment: SourcePayment, _ completion: @escaping RequestResultClosure - ) { - apiRequest(api: OmiseAPI.createSource(sourcePayment: sourcePayment), completion: completion) - } -} - -private extension ClientNew { - func apiRequest(api: APIProtocol, completion: @escaping RequestResultClosure) { - let urlRequest = urlRequest(publicKey: publicKey, api: api) - network.send( - urlRequest: urlRequest, - dateFormatter: api.dateFormatter, - completion: completion - ) - } - - func observeChargeStatusUntilChange( - tokenID: String, - timeInterval: Int, - attemp: Int, - maxAttempt: Int, - _ completion: @escaping RequestResultClosure - ) { - guard maxAttempt > attemp else { - return - } - token(tokenID: tokenID) { [weak self] (result: (Result)) in - switch result { - case .success(let token) where token.chargeStatus.isFinal: - completion(.success(token.chargeStatus)) - case .success(let token): - guard attemp + 1 < maxAttempt else { - completion(.success(token.chargeStatus)) - return - } - - let queue = DispatchQueue.global(qos: .background) - queue.asyncAfter(deadline: .now() + .seconds(timeInterval)) { - self?.observeChargeStatusUntilChange( - tokenID: tokenID, - timeInterval: timeInterval, - attemp: attemp + 1, - maxAttempt: maxAttempt, - completion - ) - } - - case .failure(let error): - completion(.failure(error)) - } - } - } - - func token(tokenID: String, _ completion: @escaping RequestResultClosure) { - apiRequest(api: OmiseAPI.token(tokenID: tokenID), completion: completion) - } -} diff --git a/OmiseSDK/Refactoring/New/Extensions/Calendar+CreditCard.swift b/OmiseSDK/Refactoring/New/Helpers/Extensions/Calendar+CreditCard.swift similarity index 94% rename from OmiseSDK/Refactoring/New/Extensions/Calendar+CreditCard.swift rename to OmiseSDK/Refactoring/New/Helpers/Extensions/Calendar+CreditCard.swift index 33dfcd34..fe30c7f8 100644 --- a/OmiseSDK/Refactoring/New/Extensions/Calendar+CreditCard.swift +++ b/OmiseSDK/Refactoring/New/Helpers/Extensions/Calendar+CreditCard.swift @@ -1,6 +1,6 @@ import Foundation -public extension Calendar { +extension Calendar { /// Calendar used in the Credit Card information which is Gregorian Calendar static let creditCardInformationCalendar = Calendar(identifier: .gregorian) /// Range contains the valid range of the expiration month value diff --git a/OmiseSDK/Refactoring/New/Client/APIProtocol.swift b/OmiseSDK/Refactoring/New/Helpers/Network Service/APIProtocol.swift similarity index 100% rename from OmiseSDK/Refactoring/New/Client/APIProtocol.swift rename to OmiseSDK/Refactoring/New/Helpers/Network Service/APIProtocol.swift diff --git a/OmiseSDK/Refactoring/New/Services/NetworkService.swift b/OmiseSDK/Refactoring/New/Helpers/Network Service/NetworkService.swift similarity index 100% rename from OmiseSDK/Refactoring/New/Services/NetworkService.swift rename to OmiseSDK/Refactoring/New/Helpers/Network Service/NetworkService.swift diff --git a/OmiseSDK/Refactoring/New/Models/Capability/Capability.PaymentMethod.Bank.swift b/OmiseSDK/Refactoring/New/Models/Capability.PaymentMethod.Bank.swift similarity index 90% rename from OmiseSDK/Refactoring/New/Models/Capability/Capability.PaymentMethod.Bank.swift rename to OmiseSDK/Refactoring/New/Models/Capability.PaymentMethod.Bank.swift index 15b2a003..9c7e67cb 100644 --- a/OmiseSDK/Refactoring/New/Models/Capability/Capability.PaymentMethod.Bank.swift +++ b/OmiseSDK/Refactoring/New/Models/Capability.PaymentMethod.Bank.swift @@ -1,6 +1,6 @@ import Foundation -extension CapabilityNew.PaymentMethod { +extension Capability.PaymentMethod { // TODO: Add Unit Tests to Bank // TODO: Add comments to Bank's properties public struct Bank: Codable, Hashable { diff --git a/OmiseSDK/Refactoring/New/Models/Capability/Capability.PaymentMethod.Provider.swift b/OmiseSDK/Refactoring/New/Models/Capability.PaymentMethod.Provider.swift similarity index 91% rename from OmiseSDK/Refactoring/New/Models/Capability/Capability.PaymentMethod.Provider.swift rename to OmiseSDK/Refactoring/New/Models/Capability.PaymentMethod.Provider.swift index 5755e57e..003cd0c1 100644 --- a/OmiseSDK/Refactoring/New/Models/Capability/Capability.PaymentMethod.Provider.swift +++ b/OmiseSDK/Refactoring/New/Models/Capability.PaymentMethod.Provider.swift @@ -1,6 +1,6 @@ import Foundation -extension CapabilityNew.PaymentMethod { +extension Capability.PaymentMethod { // TODO: Add Unit Tests to Provider // TODO: Add comments to Provider's properties enum Provider: String, Codable, Hashable { diff --git a/OmiseSDK/Refactoring/New/Models/Capability/Capability.PaymentMethod.swift b/OmiseSDK/Refactoring/New/Models/Capability.PaymentMethod.swift similarity index 96% rename from OmiseSDK/Refactoring/New/Models/Capability/Capability.PaymentMethod.swift rename to OmiseSDK/Refactoring/New/Models/Capability.PaymentMethod.swift index 81d7f109..ba0256d1 100644 --- a/OmiseSDK/Refactoring/New/Models/Capability/Capability.PaymentMethod.swift +++ b/OmiseSDK/Refactoring/New/Models/Capability.PaymentMethod.swift @@ -1,6 +1,6 @@ import Foundation -extension CapabilityNew { +extension Capability { // TODO: Add Unit Tests to PaymentMethod // TODO: Add comments to PaymentMethod's properties public struct PaymentMethod: Codable { diff --git a/OmiseSDK/Refactoring/New/Models/Capability/CapabilityNew.swift b/OmiseSDK/Refactoring/New/Models/Capability.swift similarity index 63% rename from OmiseSDK/Refactoring/New/Models/Capability/CapabilityNew.swift rename to OmiseSDK/Refactoring/New/Models/Capability.swift index 00559390..11555630 100644 --- a/OmiseSDK/Refactoring/New/Models/Capability/CapabilityNew.swift +++ b/OmiseSDK/Refactoring/New/Models/Capability.swift @@ -1,11 +1,10 @@ import Foundation -// TODO: Rename to Capability -// TODO: Add Unit Tests to CapabilityNew +// TODO: Add Unit Tests to Capability // TODO: Add comments to CapabilityNew's properties -public struct CapabilityNew: Codable { +public struct Capability: Codable { public let countryCode: String - public let paymentMethods: [CapabilityNew.PaymentMethod] + public let paymentMethods: [Capability.PaymentMethod] public let banks: Set private enum CodingKeys: String, CodingKey { diff --git a/OmiseSDK/Refactoring/New/Models/Payments/CardPayment.swift b/OmiseSDK/Refactoring/New/Models/CardPaymentPayload.swift similarity index 94% rename from OmiseSDK/Refactoring/New/Models/Payments/CardPayment.swift rename to OmiseSDK/Refactoring/New/Models/CardPaymentPayload.swift index d85273e8..cca317d7 100644 --- a/OmiseSDK/Refactoring/New/Models/Payments/CardPayment.swift +++ b/OmiseSDK/Refactoring/New/Models/CardPaymentPayload.swift @@ -1,12 +1,10 @@ import Foundation // TODO: Add Unit Tests for CardPayment -// TODO: Add comments to CardPayment's properties - /// Information to create a token /// A token represents a credit or debit card /// https://docs.opn.ooo/tokens-api -public struct CardPayment: Encodable { +public struct CardPaymentPayload: Encodable { /// Card holder's full name public let name: String /// Card number @@ -47,3 +45,5 @@ public struct CardPayment: Encodable { case phoneNumber = "phone_number" } } + + diff --git a/OmiseSDK/Refactoring/New/Models/System/Country.swift b/OmiseSDK/Refactoring/New/Models/Country.swift similarity index 98% rename from OmiseSDK/Refactoring/New/Models/System/Country.swift rename to OmiseSDK/Refactoring/New/Models/Country.swift index 0562ecd0..d3385b25 100644 --- a/OmiseSDK/Refactoring/New/Models/System/Country.swift +++ b/OmiseSDK/Refactoring/New/Models/Country.swift @@ -1,11 +1,3 @@ -// -// Country.swift -// OmiseSDK -// -// Created by Andrei Solovev on 8/6/23. -// Copyright © 2023 Omise. All rights reserved. -// - import Foundation struct Country: Codable, Equatable { diff --git a/OmiseSDK/Refactoring/New/Models/Source/Source.Flow.swift b/OmiseSDK/Refactoring/New/Models/Source.Flow.swift similarity index 100% rename from OmiseSDK/Refactoring/New/Models/Source/Source.Flow.swift rename to OmiseSDK/Refactoring/New/Models/Source.Flow.swift diff --git a/OmiseSDK/Refactoring/New/Models/Source/Source.Payload.Address.swift b/OmiseSDK/Refactoring/New/Models/Source.Payload.Address.swift similarity index 100% rename from OmiseSDK/Refactoring/New/Models/Source/Source.Payload.Address.swift rename to OmiseSDK/Refactoring/New/Models/Source.Payload.Address.swift diff --git a/OmiseSDK/Refactoring/New/Models/Source/Source.Payload.Atome.swift b/OmiseSDK/Refactoring/New/Models/Source.Payload.Atome.swift similarity index 100% rename from OmiseSDK/Refactoring/New/Models/Source/Source.Payload.Atome.swift rename to OmiseSDK/Refactoring/New/Models/Source.Payload.Atome.swift diff --git a/OmiseSDK/Refactoring/New/Models/Source/Source.Payload.BarcodeAlipay.swift b/OmiseSDK/Refactoring/New/Models/Source.Payload.BarcodeAlipay.swift similarity index 100% rename from OmiseSDK/Refactoring/New/Models/Source/Source.Payload.BarcodeAlipay.swift rename to OmiseSDK/Refactoring/New/Models/Source.Payload.BarcodeAlipay.swift diff --git a/OmiseSDK/Refactoring/New/Models/Source/Source.Payload.DuitNowOBW.swift b/OmiseSDK/Refactoring/New/Models/Source.Payload.DuitNowOBW.swift similarity index 100% rename from OmiseSDK/Refactoring/New/Models/Source/Source.Payload.DuitNowOBW.swift rename to OmiseSDK/Refactoring/New/Models/Source.Payload.DuitNowOBW.swift diff --git a/OmiseSDK/Refactoring/New/Models/Source/Source.Payload.EContext.swift b/OmiseSDK/Refactoring/New/Models/Source.Payload.EContext.swift similarity index 100% rename from OmiseSDK/Refactoring/New/Models/Source/Source.Payload.EContext.swift rename to OmiseSDK/Refactoring/New/Models/Source.Payload.EContext.swift diff --git a/OmiseSDK/Refactoring/New/Models/Source/Source.Payload.FPX.swift b/OmiseSDK/Refactoring/New/Models/Source.Payload.FPX.swift similarity index 100% rename from OmiseSDK/Refactoring/New/Models/Source/Source.Payload.FPX.swift rename to OmiseSDK/Refactoring/New/Models/Source.Payload.FPX.swift diff --git a/OmiseSDK/Refactoring/New/Models/Source/Source.Payload.Installment.swift b/OmiseSDK/Refactoring/New/Models/Source.Payload.Installment.swift similarity index 100% rename from OmiseSDK/Refactoring/New/Models/Source/Source.Payload.Installment.swift rename to OmiseSDK/Refactoring/New/Models/Source.Payload.Installment.swift diff --git a/OmiseSDK/Refactoring/New/Models/Source/Source.Payload.Item.swift b/OmiseSDK/Refactoring/New/Models/Source.Payload.Item.swift similarity index 100% rename from OmiseSDK/Refactoring/New/Models/Source/Source.Payload.Item.swift rename to OmiseSDK/Refactoring/New/Models/Source.Payload.Item.swift diff --git a/OmiseSDK/Refactoring/New/Models/Source/Source.Payload.TrueMoney.swift b/OmiseSDK/Refactoring/New/Models/Source.Payload.TrueMoney.swift similarity index 100% rename from OmiseSDK/Refactoring/New/Models/Source/Source.Payload.TrueMoney.swift rename to OmiseSDK/Refactoring/New/Models/Source.Payload.TrueMoney.swift diff --git a/OmiseSDK/Refactoring/New/Models/Source/Source.Payload.swift b/OmiseSDK/Refactoring/New/Models/Source.Payload.swift similarity index 100% rename from OmiseSDK/Refactoring/New/Models/Source/Source.Payload.swift rename to OmiseSDK/Refactoring/New/Models/Source.Payload.swift diff --git a/OmiseSDK/Refactoring/New/Models/Source/Source.swift b/OmiseSDK/Refactoring/New/Models/Source.swift similarity index 100% rename from OmiseSDK/Refactoring/New/Models/Source/Source.swift rename to OmiseSDK/Refactoring/New/Models/Source.swift diff --git a/OmiseSDK/Refactoring/New/Models/Payments/SourcePayment.swift b/OmiseSDK/Refactoring/New/Models/SourcePaymentPayload.swift similarity index 78% rename from OmiseSDK/Refactoring/New/Models/Payments/SourcePayment.swift rename to OmiseSDK/Refactoring/New/Models/SourcePaymentPayload.swift index 0c42855f..cbe59187 100644 --- a/OmiseSDK/Refactoring/New/Models/Payments/SourcePayment.swift +++ b/OmiseSDK/Refactoring/New/Models/SourcePaymentPayload.swift @@ -1,17 +1,15 @@ import Foundation -// TODO: Add Unit Tests for SourcePayment -// TODO: Add comments to SourcePayment's properties - -/// Information to create payment Source +/// Information to create payment source /// Sources are methods for accepting payments through non-credit-card channels -public struct SourcePayment: Encodable { +public struct SourcePaymentPayload: Encodable { /// Source amount in smallest unit of source currency let amount: Int64 /// Currency for source as three-letter ISO 4217 code let currency: String + /// The payment details of this source describes how the payment is processed let details: Source.Payload - + /// Current SDK platform type let platform = "IOS" init(amount: Int64, currency: String, details: Source.Payload) { @@ -26,6 +24,7 @@ public struct SourcePayment: Encodable { case platform = "platform_type" } + /// Encode information to create payment source to JSON string public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(platform, forKey: .platform) @@ -34,3 +33,4 @@ public struct SourcePayment: Encodable { try details.encode(to: encoder) } } + diff --git a/OmiseSDK/Refactoring/New/Models/Source/SourceType.swift b/OmiseSDK/Refactoring/New/Models/SourceType.swift similarity index 100% rename from OmiseSDK/Refactoring/New/Models/Source/SourceType.swift rename to OmiseSDK/Refactoring/New/Models/SourceType.swift diff --git a/OmiseSDK/Refactoring/New/Models/Token/Token.Card.swift b/OmiseSDK/Refactoring/New/Models/Token.Card.swift similarity index 99% rename from OmiseSDK/Refactoring/New/Models/Token/Token.Card.swift rename to OmiseSDK/Refactoring/New/Models/Token.Card.swift index ed906cea..571eb64e 100644 --- a/OmiseSDK/Refactoring/New/Models/Token/Token.Card.swift +++ b/OmiseSDK/Refactoring/New/Models/Token.Card.swift @@ -1,6 +1,6 @@ import Foundation -extension TokenNew { +extension Token { // TODO: Add Unit Tests to Card public struct Card: Decodable { /// Card's ID. diff --git a/OmiseSDK/Refactoring/New/Models/Token/Token.ChargeStatus.swift b/OmiseSDK/Refactoring/New/Models/Token.ChargeStatus.swift similarity index 91% rename from OmiseSDK/Refactoring/New/Models/Token/Token.ChargeStatus.swift rename to OmiseSDK/Refactoring/New/Models/Token.ChargeStatus.swift index ebe32297..245b1d31 100644 --- a/OmiseSDK/Refactoring/New/Models/Token/Token.ChargeStatus.swift +++ b/OmiseSDK/Refactoring/New/Models/Token.ChargeStatus.swift @@ -1,6 +1,6 @@ import Foundation -extension TokenNew { +extension Token { // TODO: Add Unit Tests to ChargeStatus // TODO: Add comments to ChargeStatus's properties public enum ChargeStatus: String, Decodable { @@ -17,7 +17,7 @@ extension TokenNew { } } -extension TokenNew.ChargeStatus { +extension Token.ChargeStatus { static let finalStates: [Self] = [.successful, .failed, .expired, .reversed] var isFinal: Bool { diff --git a/OmiseSDK/Refactoring/New/Models/Token/TokenNew.swift b/OmiseSDK/Refactoring/New/Models/Token.swift similarity index 70% rename from OmiseSDK/Refactoring/New/Models/Token/TokenNew.swift rename to OmiseSDK/Refactoring/New/Models/Token.swift index e5efac4b..c543d990 100644 --- a/OmiseSDK/Refactoring/New/Models/Token/TokenNew.swift +++ b/OmiseSDK/Refactoring/New/Models/Token.swift @@ -1,16 +1,16 @@ import Foundation // TODO: Rename to Token -// TODO: Add Unit Tests to TokenNew -public struct TokenNew: Decodable { +// TODO: Add Unit Tests to Token +public struct Token: Decodable { /// Omise ID of the token public let id: String - /// Boolean indicates that if this Token is in the live mode + /// Boolean indicates that if this TokenOld is in the live mode public let isLiveMode: Bool /// Boolean indicates that if this token is already used for creating a charge already public var isUsed: Bool - /// Card that is used for creating this Token - public let card: TokenNew.Card? + /// Card that is used for creating this TokenOld + public let card: Token.Card? /// Status of charge created using this token public let chargeStatus: ChargeStatus diff --git a/OmiseSDK/Refactoring/New/Client/OmiseAPI.swift b/OmiseSDK/Refactoring/New/OmiseAPI.swift similarity index 86% rename from OmiseSDK/Refactoring/New/Client/OmiseAPI.swift rename to OmiseSDK/Refactoring/New/OmiseAPI.swift index 1bc79a7a..6af6bbd2 100644 --- a/OmiseSDK/Refactoring/New/Client/OmiseAPI.swift +++ b/OmiseSDK/Refactoring/New/OmiseAPI.swift @@ -15,8 +15,8 @@ extension OmiseServerType { enum OmiseAPI { case capability case token(tokenID: String) - case createToken(cardPayment: CardPayment) - case createSource(sourcePayment: SourcePayment) + case createToken(payload: CardPaymentPayload) + case createSource(payload: SourcePaymentPayload) } extension OmiseAPI: APIProtocol { @@ -61,11 +61,11 @@ extension OmiseAPI: APIProtocol { var httpBody: Data? { switch self { - case .createToken(let cardPayment): - struct CardPaymentContainer: Encodable { - let card: CardPayment + case .createToken(let payload): + struct TokenPaymentPayloadContainer: Encodable { + let card: CardPaymentPayload } - let token = CardPaymentContainer(card: cardPayment) + let token = TokenPaymentPayloadContainer(card: payload) return try? jsonEncoder.encode(token) case .createSource(let sourcePayment): return try? jsonEncoder.encode(sourcePayment) diff --git a/OmiseSDK/Refactoring/Old/ClientOld.swift b/OmiseSDK/Refactoring/Old/ClientOld.swift index 9d72fd74..34549772 100644 --- a/OmiseSDK/Refactoring/Old/ClientOld.swift +++ b/OmiseSDK/Refactoring/Old/ClientOld.swift @@ -24,7 +24,7 @@ public class ClientOld: NSObject { // // Shared latest capability requested from API - static var sharedCapability: Capability? { + static var sharedCapability: CapabilityOld? { didSet { if let countryCode = sharedCapability?.countryCode { OmiseSDK.shared.setCurrentCountry(countryCode: countryCode) @@ -98,16 +98,16 @@ public class ClientOld: NSObject { } // swiftlint:disable:next function_body_length - public func capabilityDataWithCompletionHandler(_ completionHandler: ((RequestResult) -> Void)?) { + public func capabilityDataWithCompletionHandler(_ completionHandler: ((RequestResult) -> Void)?) { // swiftlint:disable:next closure_body_length let dataTask = session.dataTask(with: buildCapabilityAPIURLRequest()) { (data, response, error) in guard let completionHandler = completionHandler else { return } // nobody around to hear the leaf falls - var result: RequestResult + var result: RequestResult defer { switch result { case .success: - os_log("Request succeed: Capability", log: sdkLogObject, type: .debug) + os_log("Request succeed: CapabilityOld", log: sdkLogObject, type: .debug) case .failure(let error): os_log("Request failed %{public}@", log: sdkLogObject, type: .info, error.localizedDescription) } @@ -154,7 +154,7 @@ public class ClientOld: NSObject { } do { - let capability = try decoder.decode(Capability.self, from: data) + let capability = try decoder.decode(CapabilityOld.self, from: data) Self.sharedCapability = capability result = .success(capability) } catch { @@ -217,7 +217,7 @@ public class ClientOld: NSObject { } do { - let token = try decoder.decode(Token.self, from: data) + let token = try decoder.decode(TokenOld.self, from: data) result = .success(token.chargeStatus) } catch { let omiseError = OmiseError.unexpected(error: .httpSuccessWithInvalidData, underlying: error) diff --git a/OmiseSDKTests/New Tests/CapabilityTests.swift b/OmiseSDKTests/Draft Tests/CapabilityTests.swift similarity index 83% rename from OmiseSDKTests/New Tests/CapabilityTests.swift rename to OmiseSDKTests/Draft Tests/CapabilityTests.swift index b0136eea..c2a1a5d5 100644 --- a/OmiseSDKTests/New Tests/CapabilityTests.swift +++ b/OmiseSDKTests/Draft Tests/CapabilityTests.swift @@ -8,7 +8,7 @@ class CapabilityTests: XCTestCase { do { let jsonData = try XCTestCase.fixturesData(forFilename: "capability") - let capability = try decoder.decode(CapabilityNew.self, from: jsonData) + let capability = try decoder.decode(Capability.self, from: jsonData) print(capability) XCTAssertTrue(true) } catch { diff --git a/OmiseSDKTests/New Tests/CardPaymenTests.swift b/OmiseSDKTests/Draft Tests/CardPaymenTests.swift similarity index 100% rename from OmiseSDKTests/New Tests/CardPaymenTests.swift rename to OmiseSDKTests/Draft Tests/CardPaymenTests.swift diff --git a/OmiseSDKTests/New Tests/ClientTests.swift b/OmiseSDKTests/Draft Tests/ClientTests.swift similarity index 95% rename from OmiseSDKTests/New Tests/ClientTests.swift rename to OmiseSDKTests/Draft Tests/ClientTests.swift index 8a505612..1fc25c06 100644 --- a/OmiseSDKTests/New Tests/ClientTests.swift +++ b/OmiseSDKTests/Draft Tests/ClientTests.swift @@ -7,11 +7,11 @@ class ClientTests: XCTestCase { let publicKeyBase64 = "cGtleV90ZXN0XzU4d2ZubHdveHoxdGJrZGQ5OTM=" let requestTimeout: TimeInterval = 15.0 - var testClient: ClientNew! + var testClient: Client! override func setUp() { super.setUp() - testClient = ClientNew(publicKey: publicKey) + testClient = Client(publicKey: publicKey) // swiftlint:disable force_unwrapping let testEnvironment = Environment.dev( @@ -66,7 +66,7 @@ class ClientTests: XCTestCase { /* func testCapabilityAPI() { - let expectation = self.expectation(description: "API: Capability") + let expectation = self.expectation(description: "API: CapabilityOld") testClient?.capability { result in print(result) @@ -88,7 +88,7 @@ class ClientTests: XCTestCase { /* func testCreateTokenAPI() { - let expectation = self.expectation(description: "API: Create Token") + let expectation = self.expectation(description: "API: Create TokenOld") // TODO: Move to test data collection let card = PaymentInformationNew.Card( @@ -107,7 +107,7 @@ class ClientTests: XCTestCase { ) let publicKey = "..." - let client = ClientNew(publicKey: publicKey) + let client = Client(publicKey: publicKey) client.createToken(card: card) { result in print(result) @@ -133,7 +133,7 @@ class ClientTests: XCTestCase { let tokenID = "test token id" let publicKey = "test pkey" - let client = ClientNew(publicKey: publicKey) + let client = Client(publicKey: publicKey) client.observeChargeStatusUntilChange(tokenID: tokenID) { result in do { let value = try result.get() diff --git a/OmiseSDKTests/New Tests/PaymentPayload.swift b/OmiseSDKTests/New Tests/PaymentPayload.swift deleted file mode 100644 index 654bb9a5..00000000 --- a/OmiseSDKTests/New Tests/PaymentPayload.swift +++ /dev/null @@ -1,32 +0,0 @@ -import Foundation -import XCTest -@testable import OmiseSDK - -class PaymentPayloadTests: XCTestCase { - let decoder = JSONDecoder() - - func testAtomeParser() { - let atomeInfo = SourcePayload.Atome(phoneNumber: "123", shippingAddress: .init(country: "aa", city: "bb", postalCode: "sdd", state: "dfg", street1: "dfg", street2: "dfg"), items: []) - let payment = SourcePayload(amount: 1, currency: "th", sourceType: .atome, details: .atome(atomeInfo)) - if let data = try? JSONEncoder().encode(payment) { - print(String(data: data, encoding: .utf8)!) - } - - - parse(filename: "source_duitnow_obw") - parse(filename: "source_atome") - parse(filename: "source_paypay") - } - - func parse(filename: String) { - do { - let jsonData = try XCTestCase.fixturesData(forFilename: filename) - let data = try decoder.decode(Source.self, from: jsonData) - print(data) - XCTAssertTrue(true) - } catch { - print(error) - XCTFail("Parsing results with errpr") - } - } -} diff --git a/OmiseSDKTests/New Tests/SourcePaymentTests.swift b/OmiseSDKTests/New Tests/SourcePaymentTests.swift deleted file mode 100644 index 702c4439..00000000 --- a/OmiseSDKTests/New Tests/SourcePaymentTests.swift +++ /dev/null @@ -1,22 +0,0 @@ -import Foundation -import XCTest -@testable import OmiseSDK - -class SourcePaymentPayloadTest: XCTestCase { - func testJSONEncoding() { - let sourcePayload = SourcePayment(amount: 1, currency: "THB", details: .other(.alipay)) - - let encoder = JSONEncoder() - encoder.outputFormatting = [.sortedKeys] - - let data = try? encoder.encode(sourcePayload) - let result = data == nil ? "" : String(data: data!, encoding: .utf8) - - let expectedResult = - "{\"amount\":1,\"currency\":\"THB\",\"platform_type\":\"IOS\",\"type\":\"alipay\"}" - - print(result) - print(expectedResult) - XCTAssertEqual(result, expectedResult) - } -} diff --git a/OmiseSDKTests/Old tests/CapabilityOperationFixtureTests.swift b/OmiseSDKTests/Old tests/CapabilityOperationFixtureTests.swift index 50c43798..2039fe99 100644 --- a/OmiseSDKTests/Old tests/CapabilityOperationFixtureTests.swift +++ b/OmiseSDKTests/Old tests/CapabilityOperationFixtureTests.swift @@ -3,11 +3,11 @@ import XCTest class CapabilityOperationFixtureTests: XCTestCase { - func validateCapabilitySupportsCurrency(_ capability: Capability, sourceType: SourceTypeValue, currencies: Set) { + func validateCapabilitySupportsCurrency(_ capability: CapabilityOld, sourceType: SourceTypeValue, currencies: Set) { if let backend = capability[sourceType] { XCTAssertEqual(backend.supportedCurrencies, currencies) } else { - XCTFail("Capability doesn't have the \(sourceType) backend") + XCTFail("CapabilityOld doesn't have the \(sourceType) backend") } } @@ -16,7 +16,7 @@ class CapabilityOperationFixtureTests: XCTestCase { do { let capabilityData = try XCTestCase.fixturesData(forFilename: "capability") - let capability = try decoder.decode(Capability.self, from: capabilityData) + let capability = try decoder.decode(CapabilityOld.self, from: capabilityData) XCTAssertEqual(capability.supportedBackends.count, 33) @@ -24,7 +24,7 @@ class CapabilityOperationFixtureTests: XCTestCase { XCTAssertEqual(creditCardBackend.payment, .card([])) XCTAssertEqual(creditCardBackend.supportedCurrencies, [.thb, .jpy, .usd, .eur, .gbp, .sgd, .aud, .chf, .cny, .dkk, .hkd]) } else { - XCTFail("Capability doesn't have the Credit Card backend") + XCTFail("CapabilityOld doesn't have the Credit Card backend") } if let bayInstallmentBackend = capability[SourceTypeValue.installmentBAY] { @@ -34,15 +34,15 @@ class CapabilityOperationFixtureTests: XCTestCase { ) XCTAssertEqual(bayInstallmentBackend.supportedCurrencies, [.thb]) } else { - XCTFail("Capability doesn't have the BAY Installment backend") + XCTFail("CapabilityOld doesn't have the BAY Installment backend") } if let fpxBackend = capability[SourceTypeValue.fpx] { XCTAssertEqual(fpxBackend.banks, [ - Capability.Backend.Bank(name: "UOB", code: "uob", isActive: true) + CapabilityOld.Backend.Bank(name: "UOB", code: "uob", isActive: true) ]) } else { - XCTFail("Capability doesn't have the FPX backend") + XCTFail("CapabilityOld doesn't have the FPX backend") } if let mobileBankingKBankBackend = capability[SourceTypeValue.mobileBankingKBank] { @@ -50,7 +50,7 @@ class CapabilityOperationFixtureTests: XCTestCase { mobileBankingKBankBackend.payment, .mobileBanking(.kbank)) XCTAssertEqual(mobileBankingKBankBackend.supportedCurrencies, [.thb]) } else { - XCTFail("Capability doesn't have the Mobile Banking KBank backend") + XCTFail("CapabilityOld doesn't have the Mobile Banking KBank backend") } validateCapabilitySupportsCurrency(capability, sourceType: .trueMoney, currencies: [.thb]) @@ -67,13 +67,13 @@ class CapabilityOperationFixtureTests: XCTestCase { func testEncodeCapabilityRetrieve() throws { let decoder = ClientOld.makeJSONDecoder(for: Request?.none) let capabilityData = try XCTestCase.fixturesData(forFilename: "capability") - let capability = try decoder.decode(Capability.self, from: capabilityData) + let capability = try decoder.decode(CapabilityOld.self, from: capabilityData) let encoder = JSONEncoder() encoder.dateEncodingStrategy = .iso8601 let encodedData = try encoder.encode(capability) - let decodedCapability = try decoder.decode(Capability.self, from: encodedData) + let decodedCapability = try decoder.decode(CapabilityOld.self, from: encodedData) XCTAssertEqual(capability.supportedBackends.count, decodedCapability.supportedBackends.count) XCTAssertEqual(capability.creditCardBackend?.payment, decodedCapability.creditCardBackend?.payment) diff --git a/OmiseSDKTests/Old tests/Client/ClientOldTestCase.swift b/OmiseSDKTests/Old tests/Client/ClientOldTestCase.swift index 41ebc4a4..817b1ea1 100644 --- a/OmiseSDKTests/Old tests/Client/ClientOldTestCase.swift +++ b/OmiseSDKTests/Old tests/Client/ClientOldTestCase.swift @@ -6,8 +6,8 @@ private let timeout: TimeInterval = 15.0 class ClientTestCase: XCTestCase { - static let requestTokenGenerator: OmiseUnitTestKit.TestCaseValueGenerator.GeneratorFunction> = { gen in - Request(parameter: Token.CreateParameter( + static let requestTokenGenerator: OmiseUnitTestKit.TestCaseValueGenerator.GeneratorFunction> = { gen in + Request(parameter: TokenOld.CreateParameter( name: "JOHN DOE", number: "4242424242424242", expirationMonth: 11, @@ -46,7 +46,7 @@ class ClientTestCase: XCTestCase { XCTAssertEqual(tokenRequest.parameter.expirationMonth, task.request.parameter.expirationMonth) XCTAssertEqual(tokenRequest.parameter.expirationYear, task.request.parameter.expirationYear) - XCTAssertEqual(Token.postURL, task.dataTask.currentRequest?.url) + XCTAssertEqual(TokenOld.postURL, task.dataTask.currentRequest?.url) XCTAssertEqual("POST", task.dataTask.currentRequest?.httpMethod) waitForExpectations(timeout: timeout, handler: nil) @@ -66,7 +66,7 @@ class ClientTestCase: XCTestCase { XCTAssertEqual(tokenRequest.parameter.expirationMonth, task.request.parameter.expirationMonth) XCTAssertEqual(tokenRequest.parameter.expirationYear, task.request.parameter.expirationYear) - XCTAssertEqual(Token.postURL, task.dataTask.currentRequest?.url) + XCTAssertEqual(TokenOld.postURL, task.dataTask.currentRequest?.url) XCTAssertEqual("POST", task.dataTask.currentRequest?.httpMethod) waitForExpectations(timeout: timeout, handler: nil) @@ -123,11 +123,11 @@ class ClientTestCase: XCTestCase { extension ClientTestCase { // MARK: Request factory methods - static func makeValidTokenRequest() -> Request { + static func makeValidTokenRequest() -> Request { // swiftlint:disable:next force_unwrapping TestCaseValueGenerator.validCases(self.requestTokenGenerator).first! } - static func makeInvalidTokenRequest() -> Request { + static func makeInvalidTokenRequest() -> Request { // swiftlint:disable:next force_unwrapping TestCaseValueGenerator.invalidCases(self.requestTokenGenerator).first! } diff --git a/OmiseSDKTests/Old tests/ModelTestCase.swift b/OmiseSDKTests/Old tests/ModelTestCase.swift index 364e8c38..29cdedaf 100644 --- a/OmiseSDKTests/Old tests/ModelTestCase.swift +++ b/OmiseSDKTests/Old tests/ModelTestCase.swift @@ -6,9 +6,9 @@ import XCTest class ModelTestCase: XCTestCase { func testDecodeToken() throws { - let decoder = ClientOld.makeJSONDecoder(for: Request?.none) + let decoder = ClientOld.makeJSONDecoder(for: Request?.none) let tokenData = try XCTestCase.fixturesData(forFilename: "token_object") - let token = try decoder.decode(Token.self, from: tokenData) + let token = try decoder.decode(TokenOld.self, from: tokenData) XCTAssertEqual("tokn_test_5086xl7c9k5rnx35qba", token.id) XCTAssertEqual("/tokens/tokn_test_5086xl7c9k5rnx35qba", token.location) @@ -20,9 +20,9 @@ class ModelTestCase: XCTestCase { } func testDecodeTokenWithoutCard() throws { - let decoder = ClientOld.makeJSONDecoder(for: Request?.none) + let decoder = ClientOld.makeJSONDecoder(for: Request?.none) let tokenData = try XCTestCase.fixturesData(forFilename: "token_with_empty_card_object") - let token = try decoder.decode(Token.self, from: tokenData) + let token = try decoder.decode(TokenOld.self, from: tokenData) XCTAssertEqual("tokn_test_5086xl7c9k5rnx35qba", token.id) XCTAssertEqual("/tokens/tokn_test_5086xl7c9k5rnx35qba", token.location) @@ -34,7 +34,7 @@ class ModelTestCase: XCTestCase { } func testDecodeCard() throws { - let decoder = ClientOld.makeJSONDecoder(for: Request?.none) + let decoder = ClientOld.makeJSONDecoder(for: Request?.none) let cardData = try XCTestCase.fixturesData(forFilename: "card_object") let card = try decoder.decode(Card.self, from: cardData) @@ -668,7 +668,7 @@ class ModelTestCase: XCTestCase { encoder.outputFormatting = [.sortedKeys, .prettyPrinted] do { - let tokenParameter = Token.CreateParameter(name: "John Appleseed", + let tokenParameter = TokenOld.CreateParameter(name: "John Appleseed", number: "4242424242424242", expirationMonth: 6, expirationYear: 2018, @@ -690,7 +690,7 @@ class ModelTestCase: XCTestCase { } do { - let tokenParameter = Token.CreateParameter(name: "John Appleseed", + let tokenParameter = TokenOld.CreateParameter(name: "John Appleseed", number: "4242424242424242", expirationMonth: 6, expirationYear: 2018, diff --git a/OmiseSDKTests/Old tests/Views/CardExpiryDatePickerTests.swift b/OmiseSDKTests/Old tests/Views/CardExpiryDatePickerTests.swift index fb597a2b..3d5b7445 100644 --- a/OmiseSDKTests/Old tests/Views/CardExpiryDatePickerTests.swift +++ b/OmiseSDKTests/Old tests/Views/CardExpiryDatePickerTests.swift @@ -1,5 +1,5 @@ import XCTest -import OmiseSDK +@testable import OmiseSDK class CardExpiryDatePickerTests: XCTestCase { diff --git a/OmiseSDKTests/SourcePaymentPayloadTest.swift b/OmiseSDKTests/SourcePaymentPayloadTest.swift new file mode 100644 index 00000000..16f324a0 --- /dev/null +++ b/OmiseSDKTests/SourcePaymentPayloadTest.swift @@ -0,0 +1,17 @@ +import Foundation +import XCTest +@testable import OmiseSDK + +class SourcePaymentPayloadTest: XCTestCase { + func testJSONEncoding() throws { + let sourcePayload = SourcePaymentPayload(amount: 1, currency: "THB", details: .other(.alipay)) + + let encoder = JSONEncoder() + encoder.outputFormatting = [.sortedKeys] + + let data = try encoder.encode(sourcePayload) + let result = String(data: data, encoding: .utf8) + let expectedResult = "{\"amount\":1,\"currency\":\"THB\",\"platform_type\":\"IOS\",\"type\":\"alipay\"}" + XCTAssertEqual(result, expectedResult) + } +} diff --git a/OmiseSDKTests/SourceTests/SourceTests+Helpers.swift b/OmiseSDKTests/SourceTests+Helpers.swift similarity index 100% rename from OmiseSDKTests/SourceTests/SourceTests+Helpers.swift rename to OmiseSDKTests/SourceTests+Helpers.swift diff --git a/OmiseSDKTests/SourceTests/SourceTests.swift b/OmiseSDKTests/SourceTests.swift similarity index 100% rename from OmiseSDKTests/SourceTests/SourceTests.swift rename to OmiseSDKTests/SourceTests.swift diff --git a/QuickStart.playground/Pages/Credit Card Form.xcplaygroundpage/Contents.swift b/QuickStart.playground/Pages/Credit Card Form.xcplaygroundpage/Contents.swift index d0e04f45..0561a7fc 100644 --- a/QuickStart.playground/Pages/Credit Card Form.xcplaygroundpage/Contents.swift +++ b/QuickStart.playground/Pages/Credit Card Form.xcplaygroundpage/Contents.swift @@ -28,11 +28,11 @@ PlaygroundPage.current.needsIndefiniteExecution = true */ extension CheckoutViewController: CreditCardFormViewControllerDelegate { - public func creditCardFormViewController(_ controller: CreditCardFormViewController, didSucceedWithToken token: Token) { + public func creditCardFormViewController(_ controller: CreditCardFormViewController, didSucceedWithToken token: TokenOld) { dismiss(animated: true, completion: nil) print("token created: \(token.id )") - let alert = UIAlertController(title: "Token", message: token.id, preferredStyle: .alert) + let alert = UIAlertController(title: "TokenOld", message: token.id, preferredStyle: .alert) present(alert, animated: true, completion: nil) } diff --git a/QuickStart.playground/Pages/Payment Creator.xcplaygroundpage/Contents.swift b/QuickStart.playground/Pages/Payment Creator.xcplaygroundpage/Contents.swift index f4aa882d..d58831bc 100644 --- a/QuickStart.playground/Pages/Payment Creator.xcplaygroundpage/Contents.swift +++ b/QuickStart.playground/Pages/Payment Creator.xcplaygroundpage/Contents.swift @@ -31,7 +31,7 @@ extension CheckoutViewController: PaymentCreatorControllerDelegate { switch payment { case .token(let token): - title = "Token" + title = "TokenOld" message = token.id case .source(let source): title = "SourceOLD" diff --git a/QuickStart.playground/Pages/Tokenization API Call.xcplaygroundpage/Contents.swift b/QuickStart.playground/Pages/Tokenization API Call.xcplaygroundpage/Contents.swift index b4544550..f01ef725 100644 --- a/QuickStart.playground/Pages/Tokenization API Call.xcplaygroundpage/Contents.swift +++ b/QuickStart.playground/Pages/Tokenization API Call.xcplaygroundpage/Contents.swift @@ -6,7 +6,7 @@ let publicKey = "pkey_test_<#Omise Public Key#>" /*: tokenization-api-call - You can do manual credit card tokenization by using our Token Request API. + You can do manual credit card tokenization by using our TokenOld Request API. */ /*: create-a-client-step @@ -17,7 +17,7 @@ let client = ClientOld(publicKey: publicKey) /*: create-a-request You also need a `Request` object which will have the credit card information that you want to tokenize. */ -let request = Request(parameter: CreateTokenParameter( +let request = Request(parameter: CreateTokenParameter( name: "Customer Name", number: "4242424242424242", expirationMonth: 12, diff --git a/README.md b/README.md index e8fb5e82..5053e3cd 100644 --- a/README.md +++ b/README.md @@ -80,10 +80,10 @@ servers. To collect a card payment from a customer, merchants will need to first *tokenize* the card data using the Opn Payments API and then use the generated token in place of the card data. You can tokenize card data by creating and initializing -a `Request` as follows: +a `Request` as follows: ```swift -let tokenParameters = Token.CreateParameter( +let tokenParameters = TokenOld.CreateParameter( name: "JOHN DOE", number: "4242424242424242", expirationMonth: 11, @@ -91,7 +91,7 @@ let tokenParameters = Token.CreateParameter( securityCode: "123" ) -let request = Request(parameter: tokenParameters) +let request = Request(parameter: tokenParameters) ``` #### Creating a payment source @@ -142,10 +142,10 @@ client.send(request) { [weak self] (result) in A simple completion handler for a token looks as follows. ``` swift -func completionHandler(tokenResult: Result) -> Void { +func completionHandler(tokenResult: Result) -> Void { switch tokenResult { case .success(let value): - // do something with Token id + // do something with TokenOld id print(value.id) case .failure(let error): print(error) @@ -184,14 +184,14 @@ class ViewController: UIViewController { } ``` -Then implement the delegate to receive the `Token` object after user has entered the card data: +Then implement the delegate to receive the `TokenOld` object after user has entered the card data: ```swift extension ViewController: CreditCardFormViewControllerDelegate { - func creditCardFormViewController(_ controller: CreditCardFormViewController, didSucceedWithToken token: Token) { + func creditCardFormViewController(_ controller: CreditCardFormViewController, didSucceedWithToken token: TokenOld) { dismissCreditCardForm() - // Sends `Token` to your server to create a charge, or a customer object. + // Sends `TokenOld` to your server to create a charge, or a customer object. } func creditCardFormViewController(_ controller: CreditCardFormViewController, didFailWithError error: Error) { @@ -281,7 +281,7 @@ extension ProductDetailViewController: PaymentCreatorControllerDelegate { func paymentCreatorController(_ paymentCreatorController: PaymentCreatorController, didCreatePayment payment: Payment) { dismissForm() - // Sends selected `Token` or `SourceOLD` to your server to create a charge, or a customer object. + // Sends selected `TokenOld` or `SourceOLD` to your server to create a charge, or a customer object. } func paymentCreatorController(_ paymentCreatorController: PaymentCreatorController, didFailWithError error: Error) { diff --git a/dev.xcodeproj/project.pbxproj b/dev.xcodeproj/project.pbxproj index c46a83cd..3fa10c35 100644 --- a/dev.xcodeproj/project.pbxproj +++ b/dev.xcodeproj/project.pbxproj @@ -79,27 +79,27 @@ 758244092ACE988700781B3B /* PaymentInformationTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A429E7A2109A3AE007C230F /* PaymentInformationTestCase.swift */; }; 759856242A286C880087B605 /* UIScrollView+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 759856232A286C880087B605 /* UIScrollView+Helpers.swift */; }; 75B420502B7611710036134D /* Capability.PaymentMethod.Bank.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B4204F2B7611710036134D /* Capability.PaymentMethod.Bank.swift */; }; - 75B420572B765BC40036134D /* TokenNew.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420562B765BC40036134D /* TokenNew.swift */; }; + 75B420572B765BC40036134D /* Token.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420562B765BC40036134D /* Token.swift */; }; 75B420592B765C0B0036134D /* Token.ChargeStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420582B765C0B0036134D /* Token.ChargeStatus.swift */; }; 75B4205B2B7670A90036134D /* Token.Card.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B4205A2B7670A90036134D /* Token.Card.swift */; }; 75B4205E2B7674D70036134D /* Calendar+CreditCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B4205D2B7674D70036134D /* Calendar+CreditCard.swift */; }; 75B420612B776D8A0036134D /* APIProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420602B776D8A0036134D /* APIProtocol.swift */; }; - 75B420662B77741E0036134D /* CardPayment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420652B77741E0036134D /* CardPayment.swift */; }; + 75B420662B77741E0036134D /* CardPaymentPayload.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420652B77741E0036134D /* CardPaymentPayload.swift */; }; 75B4206B2B77DD4D0036134D /* Source.Payload.Atome.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B4206A2B77DD4D0036134D /* Source.Payload.Atome.swift */; }; 75B420712B77DE2B0036134D /* Source.Payload.Installment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420702B77DE2B0036134D /* Source.Payload.Installment.swift */; }; 75B420732B77DE330036134D /* Source.Payload.EContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420722B77DE330036134D /* Source.Payload.EContext.swift */; }; 75B420752B77DE390036134D /* Source.Payload.TrueMoney.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420742B77DE390036134D /* Source.Payload.TrueMoney.swift */; }; 75B4207B2B77DE4C0036134D /* Source.Payload.FPX.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B4207A2B77DE4C0036134D /* Source.Payload.FPX.swift */; }; 75B4207D2B77DE540036134D /* Source.Payload.DuitNowOBW.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B4207C2B77DE540036134D /* Source.Payload.DuitNowOBW.swift */; }; - 75B420822B77FAA50036134D /* SourcePayment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420812B77FAA50036134D /* SourcePayment.swift */; }; + 75B420822B77FAA50036134D /* SourcePaymentPayload.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420812B77FAA50036134D /* SourcePaymentPayload.swift */; }; 75B420852B77FC850036134D /* Source.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420842B77FC850036134D /* Source.swift */; }; 75B420872B77FDB10036134D /* Source.Flow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420862B77FDB10036134D /* Source.Flow.swift */; }; 75B420912B78C2450036134D /* CardPaymenTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420902B78C2450036134D /* CardPaymenTests.swift */; }; 75B420942B78DE350036134D /* Capability.PaymentMethod.Provider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420932B78DE350036134D /* Capability.PaymentMethod.Provider.swift */; }; - 75B4209A2B78E56D0036134D /* Capability.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420962B78E56D0036134D /* Capability.swift */; }; + 75B4209A2B78E56D0036134D /* CapabilityOld.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420962B78E56D0036134D /* CapabilityOld.swift */; }; 75B4209B2B78E56D0036134D /* RequestTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420972B78E56D0036134D /* RequestTask.swift */; }; 75B4209C2B78E56D0036134D /* Request.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420982B78E56D0036134D /* Request.swift */; }; - 75B4209D2B78E56D0036134D /* Token.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420992B78E56D0036134D /* Token.swift */; }; + 75B4209D2B78E56D0036134D /* TokenOld.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420992B78E56D0036134D /* TokenOld.swift */; }; 75B4209F2B78E5980036134D /* SourceOLD.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B4209E2B78E5980036134D /* SourceOLD.swift */; }; 75B420A82B78E5B30036134D /* OmiseError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420A12B78E5B30036134D /* OmiseError.swift */; }; 75B420A92B78E5B30036134D /* CardBrand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420A22B78E5B30036134D /* CardBrand.swift */; }; @@ -108,20 +108,21 @@ 75B420AC2B78E5B30036134D /* PAN.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420A52B78E5B30036134D /* PAN.swift */; }; 75B420AD2B78E5B30036134D /* PaymentInformation.Atome.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420A62B78E5B30036134D /* PaymentInformation.Atome.swift */; }; 75B420AF2B78E5D30036134D /* PaymentInformation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420AE2B78E5D30036134D /* PaymentInformation.swift */; }; - 75CFC4CE2B73AF0E00422A8F /* ClientNew.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CFC4CD2B73AF0E00422A8F /* ClientNew.swift */; }; + 75CFC4CE2B73AF0E00422A8F /* Client.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CFC4CD2B73AF0E00422A8F /* Client.swift */; }; 75CFC4D22B73AFD500422A8F /* OmiseSDK.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CFC4D12B73AFD500422A8F /* OmiseSDK.swift */; }; 75CFC4D42B73B21100422A8F /* ClientTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CFC4D32B73B21100422A8F /* ClientTests.swift */; }; 75CFC4DB2B73F5AF00422A8F /* NetworkService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CFC4DA2B73F5AF00422A8F /* NetworkService.swift */; }; 75CFC4DD2B73F75C00422A8F /* OmiseAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CFC4DC2B73F75C00422A8F /* OmiseAPI.swift */; }; - 75CFC4EE2B7537BC00422A8F /* ClientNew+URLRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CFC4ED2B7537BC00422A8F /* ClientNew+URLRequest.swift */; }; - 75CFC4F12B753B0F00422A8F /* CapabilityNew.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CFC4F02B753B0F00422A8F /* CapabilityNew.swift */; }; + 75CFC4EE2B7537BC00422A8F /* Client+URLRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CFC4ED2B7537BC00422A8F /* Client+URLRequest.swift */; }; + 75CFC4F12B753B0F00422A8F /* Capability.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CFC4F02B753B0F00422A8F /* Capability.swift */; }; 75CFC4F32B753BCD00422A8F /* Capability.PaymentMethod.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CFC4F22B753BCD00422A8F /* Capability.PaymentMethod.swift */; }; 75CFC4F52B753C3C00422A8F /* SourceType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CFC4F42B753C3C00422A8F /* SourceType.swift */; }; 75CFC4F72B753D6300422A8F /* CapabilityTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CFC4F62B753D6300422A8F /* CapabilityTests.swift */; }; 75DAD8902A0BB8D80098AF96 /* LocalConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75DAD88F2A0BB8D80098AF96 /* LocalConfig.swift */; }; 75E0EB712B7A904100E3198A /* SourceFlowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75E0EB702B7A904100E3198A /* SourceFlowTests.swift */; }; - 75E0EB722B7A962600E3198A /* SourcePaymentTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B4208D2B78C2120036134D /* SourcePaymentTests.swift */; }; + 75E0EB722B7A962600E3198A /* SourcePaymentPayloadTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B4208D2B78C2120036134D /* SourcePaymentPayloadTest.swift */; }; 75E0EB752B7B280300E3198A /* SourceTests+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75E0EB742B7B280300E3198A /* SourceTests+Helpers.swift */; }; + 75E0EB7C2B7B410600E3198A /* Client+Network.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75E0EB7B2B7B410600E3198A /* Client+Network.swift */; }; 75F2A0182A0BD0D40038FA54 /* Config.local.plist in Resources */ = {isa = PBXBuildFile; fileRef = 75DAD8922A0BC9540098AF96 /* Config.local.plist */; }; 75F2A09A2A13B0B10038FA54 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 75F2A0992A13B0B10038FA54 /* Preview Assets.xcassets */; }; 75F2A0A62A13B70F0038FA54 /* OmiseTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9864062F1CFEA7E4004BCF51 /* OmiseTextField.swift */; }; @@ -292,29 +293,28 @@ 757B0A722AD71DCD00DEAE8F /* OmiseUnitTestKit */ = {isa = PBXFileReference; lastKnownFileType = text; name = OmiseUnitTestKit; path = Helpers/OmiseUnitTestKit; sourceTree = SOURCE_ROOT; }; 759856232A286C880087B605 /* UIScrollView+Helpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIScrollView+Helpers.swift"; sourceTree = ""; }; 75B4204F2B7611710036134D /* Capability.PaymentMethod.Bank.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Capability.PaymentMethod.Bank.swift; sourceTree = ""; }; - 75B420562B765BC40036134D /* TokenNew.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TokenNew.swift; sourceTree = ""; }; + 75B420562B765BC40036134D /* Token.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Token.swift; sourceTree = ""; }; 75B420582B765C0B0036134D /* Token.ChargeStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Token.ChargeStatus.swift; sourceTree = ""; }; 75B4205A2B7670A90036134D /* Token.Card.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Token.Card.swift; sourceTree = ""; }; 75B4205D2B7674D70036134D /* Calendar+CreditCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Calendar+CreditCard.swift"; sourceTree = ""; }; 75B420602B776D8A0036134D /* APIProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIProtocol.swift; sourceTree = ""; }; - 75B420652B77741E0036134D /* CardPayment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardPayment.swift; sourceTree = ""; }; + 75B420652B77741E0036134D /* CardPaymentPayload.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardPaymentPayload.swift; sourceTree = ""; }; 75B4206A2B77DD4D0036134D /* Source.Payload.Atome.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Source.Payload.Atome.swift; sourceTree = ""; }; 75B420702B77DE2B0036134D /* Source.Payload.Installment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Source.Payload.Installment.swift; sourceTree = ""; }; 75B420722B77DE330036134D /* Source.Payload.EContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Source.Payload.EContext.swift; sourceTree = ""; }; 75B420742B77DE390036134D /* Source.Payload.TrueMoney.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Source.Payload.TrueMoney.swift; sourceTree = ""; }; 75B4207A2B77DE4C0036134D /* Source.Payload.FPX.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Source.Payload.FPX.swift; sourceTree = ""; }; 75B4207C2B77DE540036134D /* Source.Payload.DuitNowOBW.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Source.Payload.DuitNowOBW.swift; sourceTree = ""; }; - 75B420812B77FAA50036134D /* SourcePayment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourcePayment.swift; sourceTree = ""; }; + 75B420812B77FAA50036134D /* SourcePaymentPayload.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourcePaymentPayload.swift; sourceTree = ""; }; 75B420842B77FC850036134D /* Source.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Source.swift; sourceTree = ""; }; 75B420862B77FDB10036134D /* Source.Flow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Source.Flow.swift; sourceTree = ""; }; - 75B420882B77FF500036134D /* PaymentPayload.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentPayload.swift; sourceTree = ""; }; - 75B4208D2B78C2120036134D /* SourcePaymentTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourcePaymentTests.swift; sourceTree = ""; }; + 75B4208D2B78C2120036134D /* SourcePaymentPayloadTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourcePaymentPayloadTest.swift; sourceTree = ""; }; 75B420902B78C2450036134D /* CardPaymenTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardPaymenTests.swift; sourceTree = ""; }; 75B420932B78DE350036134D /* Capability.PaymentMethod.Provider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Capability.PaymentMethod.Provider.swift; sourceTree = ""; }; - 75B420962B78E56D0036134D /* Capability.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Capability.swift; sourceTree = ""; }; + 75B420962B78E56D0036134D /* CapabilityOld.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CapabilityOld.swift; sourceTree = ""; }; 75B420972B78E56D0036134D /* RequestTask.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RequestTask.swift; sourceTree = ""; }; 75B420982B78E56D0036134D /* Request.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Request.swift; sourceTree = ""; }; - 75B420992B78E56D0036134D /* Token.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Token.swift; sourceTree = ""; }; + 75B420992B78E56D0036134D /* TokenOld.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TokenOld.swift; sourceTree = ""; }; 75B4209E2B78E5980036134D /* SourceOLD.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SourceOLD.swift; path = OmiseSDK/SourceOLD.swift; sourceTree = ""; }; 75B420A12B78E5B30036134D /* OmiseError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = OmiseError.swift; path = OmiseSDK/OmiseError.swift; sourceTree = ""; }; 75B420A22B78E5B30036134D /* CardBrand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CardBrand.swift; path = OmiseSDK/CardBrand.swift; sourceTree = ""; }; @@ -323,13 +323,13 @@ 75B420A52B78E5B30036134D /* PAN.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PAN.swift; path = OmiseSDK/PAN.swift; sourceTree = ""; }; 75B420A62B78E5B30036134D /* PaymentInformation.Atome.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PaymentInformation.Atome.swift; sourceTree = ""; }; 75B420AE2B78E5D30036134D /* PaymentInformation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PaymentInformation.swift; path = OmiseSDK/PaymentInformation.swift; sourceTree = ""; }; - 75CFC4CD2B73AF0E00422A8F /* ClientNew.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientNew.swift; sourceTree = ""; }; + 75CFC4CD2B73AF0E00422A8F /* Client.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Client.swift; sourceTree = ""; }; 75CFC4D12B73AFD500422A8F /* OmiseSDK.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OmiseSDK.swift; sourceTree = ""; }; 75CFC4D32B73B21100422A8F /* ClientTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientTests.swift; sourceTree = ""; }; 75CFC4DA2B73F5AF00422A8F /* NetworkService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkService.swift; sourceTree = ""; }; 75CFC4DC2B73F75C00422A8F /* OmiseAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OmiseAPI.swift; sourceTree = ""; }; - 75CFC4ED2B7537BC00422A8F /* ClientNew+URLRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ClientNew+URLRequest.swift"; sourceTree = ""; }; - 75CFC4F02B753B0F00422A8F /* CapabilityNew.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CapabilityNew.swift; sourceTree = ""; }; + 75CFC4ED2B7537BC00422A8F /* Client+URLRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Client+URLRequest.swift"; sourceTree = ""; }; + 75CFC4F02B753B0F00422A8F /* Capability.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Capability.swift; sourceTree = ""; }; 75CFC4F22B753BCD00422A8F /* Capability.PaymentMethod.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Capability.PaymentMethod.swift; sourceTree = ""; }; 75CFC4F42B753C3C00422A8F /* SourceType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceType.swift; sourceTree = ""; }; 75CFC4F62B753D6300422A8F /* CapabilityTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CapabilityTests.swift; sourceTree = ""; }; @@ -337,6 +337,7 @@ 75DAD8922A0BC9540098AF96 /* Config.local.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Config.local.plist; sourceTree = ""; }; 75E0EB702B7A904100E3198A /* SourceFlowTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceFlowTests.swift; sourceTree = ""; }; 75E0EB742B7B280300E3198A /* SourceTests+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SourceTests+Helpers.swift"; sourceTree = ""; }; + 75E0EB7B2B7B410600E3198A /* Client+Network.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Client+Network.swift"; sourceTree = ""; }; 75F2A0902A13B0B00038FA54 /* OmiseSDKUITests.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OmiseSDKUITests.app; sourceTree = BUILT_PRODUCTS_DIR; }; 75F2A0992A13B0B10038FA54 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 75F2A0A42A13B1470038FA54 /* AtomeFormViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtomeFormViewController.swift; sourceTree = ""; }; @@ -528,7 +529,6 @@ 750708F22B7A74CE00A48DD0 /* System */ = { isa = PBXGroup; children = ( - 7502CA652A31AEA200766E7D /* Country.swift */, ); path = System; sourceTree = ""; @@ -660,10 +660,6 @@ 75B420512B76120C0036134D /* Capability */ = { isa = PBXGroup; children = ( - 75CFC4F02B753B0F00422A8F /* CapabilityNew.swift */, - 75CFC4F22B753BCD00422A8F /* Capability.PaymentMethod.swift */, - 75B420932B78DE350036134D /* Capability.PaymentMethod.Provider.swift */, - 75B4204F2B7611710036134D /* Capability.PaymentMethod.Bank.swift */, ); path = Capability; sourceTree = ""; @@ -671,9 +667,6 @@ 75B420552B7659860036134D /* Token */ = { isa = PBXGroup; children = ( - 75B420562B765BC40036134D /* TokenNew.swift */, - 75B420582B765C0B0036134D /* Token.ChargeStatus.swift */, - 75B4205A2B7670A90036134D /* Token.Card.swift */, ); path = Token; sourceTree = ""; @@ -689,43 +682,28 @@ 75B420832B77FC720036134D /* Source */ = { isa = PBXGroup; children = ( - 75CFC4F42B753C3C00422A8F /* SourceType.swift */, - 75B420842B77FC850036134D /* Source.swift */, - 75B420862B77FDB10036134D /* Source.Flow.swift */, - 750708DD2B78FB6500A48DD0 /* Source.Payload.swift */, - 750708ED2B7A430300A48DD0 /* Source.Payload.Item.swift */, - 750708EF2B7A431B00A48DD0 /* Source.Payload.Address.swift */, - 75B4206A2B77DD4D0036134D /* Source.Payload.Atome.swift */, - 750708EB2B7A2ACC00A48DD0 /* Source.Payload.BarcodeAlipay.swift */, - 75B4207C2B77DE540036134D /* Source.Payload.DuitNowOBW.swift */, - 75B420722B77DE330036134D /* Source.Payload.EContext.swift */, - 75B4207A2B77DE4C0036134D /* Source.Payload.FPX.swift */, - 75B420702B77DE2B0036134D /* Source.Payload.Installment.swift */, - 75B420742B77DE390036134D /* Source.Payload.TrueMoney.swift */, ); path = Source; sourceTree = ""; }; - 75B4208F2B78C22A0036134D /* New Tests */ = { + 75B4208F2B78C22A0036134D /* Draft Tests */ = { isa = PBXGroup; children = ( 75CFC4D32B73B21100422A8F /* ClientTests.swift */, 75CFC4F62B753D6300422A8F /* CapabilityTests.swift */, - 75B420882B77FF500036134D /* PaymentPayload.swift */, - 75B4208D2B78C2120036134D /* SourcePaymentTests.swift */, 75B420902B78C2450036134D /* CardPaymenTests.swift */, ); - path = "New Tests"; + path = "Draft Tests"; sourceTree = ""; }; 75B420952B78E56D0036134D /* Done */ = { isa = PBXGroup; children = ( 75B420A62B78E5B30036134D /* PaymentInformation.Atome.swift */, - 75B420962B78E56D0036134D /* Capability.swift */, + 75B420962B78E56D0036134D /* CapabilityOld.swift */, 75B420972B78E56D0036134D /* RequestTask.swift */, 75B420982B78E56D0036134D /* Request.swift */, - 75B420992B78E56D0036134D /* Token.swift */, + 75B420992B78E56D0036134D /* TokenOld.swift */, ); name = Done; path = OmiseSDK/Done; @@ -752,11 +730,11 @@ 75CFC4CC2B73AEEA00422A8F /* New */ = { isa = PBXGroup; children = ( - 75CFC4D12B73AFD500422A8F /* OmiseSDK.swift */, - 75B4205C2B7674CF0036134D /* Extensions */, - 75CFC4F92B75503000422A8F /* Services */, + 75E0EB7A2B7B405F00E3198A /* Helpers */, 75CFC4F82B75501800422A8F /* Client */, 75CFC4EF2B753AB900422A8F /* Models */, + 75CFC4D12B73AFD500422A8F /* OmiseSDK.swift */, + 75CFC4DC2B73F75C00422A8F /* OmiseAPI.swift */, ); path = New; sourceTree = ""; @@ -772,11 +750,33 @@ 75CFC4EF2B753AB900422A8F /* Models */ = { isa = PBXGroup; children = ( + 75CFC4F42B753C3C00422A8F /* SourceType.swift */, + 75B420652B77741E0036134D /* CardPaymentPayload.swift */, + 75B420812B77FAA50036134D /* SourcePaymentPayload.swift */, + 7502CA652A31AEA200766E7D /* Country.swift */, + 75CFC4F02B753B0F00422A8F /* Capability.swift */, + 75CFC4F22B753BCD00422A8F /* Capability.PaymentMethod.swift */, + 75B420932B78DE350036134D /* Capability.PaymentMethod.Provider.swift */, + 75B4204F2B7611710036134D /* Capability.PaymentMethod.Bank.swift */, + 75B420562B765BC40036134D /* Token.swift */, + 75B420582B765C0B0036134D /* Token.ChargeStatus.swift */, + 75B4205A2B7670A90036134D /* Token.Card.swift */, + 75B420842B77FC850036134D /* Source.swift */, + 75B420862B77FDB10036134D /* Source.Flow.swift */, + 750708DD2B78FB6500A48DD0 /* Source.Payload.swift */, + 750708ED2B7A430300A48DD0 /* Source.Payload.Item.swift */, + 750708EF2B7A431B00A48DD0 /* Source.Payload.Address.swift */, + 75B4206A2B77DD4D0036134D /* Source.Payload.Atome.swift */, + 750708EB2B7A2ACC00A48DD0 /* Source.Payload.BarcodeAlipay.swift */, + 75B4207C2B77DE540036134D /* Source.Payload.DuitNowOBW.swift */, + 75B420722B77DE330036134D /* Source.Payload.EContext.swift */, + 75B4207A2B77DE4C0036134D /* Source.Payload.FPX.swift */, + 75B420702B77DE2B0036134D /* Source.Payload.Installment.swift */, + 75B420742B77DE390036134D /* Source.Payload.TrueMoney.swift */, 750708F22B7A74CE00A48DD0 /* System */, 75B420512B76120C0036134D /* Capability */, 75B420552B7659860036134D /* Token */, 75B420832B77FC720036134D /* Source */, - 75E0EB732B7A9F8000E3198A /* Payments */, ); path = Models; sourceTree = ""; @@ -784,20 +784,20 @@ 75CFC4F82B75501800422A8F /* Client */ = { isa = PBXGroup; children = ( - 75CFC4CD2B73AF0E00422A8F /* ClientNew.swift */, - 75CFC4ED2B7537BC00422A8F /* ClientNew+URLRequest.swift */, - 75B420602B776D8A0036134D /* APIProtocol.swift */, - 75CFC4DC2B73F75C00422A8F /* OmiseAPI.swift */, + 75CFC4CD2B73AF0E00422A8F /* Client.swift */, + 75CFC4ED2B7537BC00422A8F /* Client+URLRequest.swift */, + 75E0EB7B2B7B410600E3198A /* Client+Network.swift */, ); path = Client; sourceTree = ""; }; - 75CFC4F92B75503000422A8F /* Services */ = { + 75CFC4F92B75503000422A8F /* Network Service */ = { isa = PBXGroup; children = ( 75CFC4DA2B73F5AF00422A8F /* NetworkService.swift */, + 75B420602B776D8A0036134D /* APIProtocol.swift */, ); - path = Services; + path = "Network Service"; sourceTree = ""; }; 75DAD8802A0B9B060098AF96 /* Frameworks */ = { @@ -807,22 +807,13 @@ name = Frameworks; sourceTree = ""; }; - 75E0EB732B7A9F8000E3198A /* Payments */ = { + 75E0EB7A2B7B405F00E3198A /* Helpers */ = { isa = PBXGroup; children = ( - 75B420812B77FAA50036134D /* SourcePayment.swift */, - 75B420652B77741E0036134D /* CardPayment.swift */, - ); - path = Payments; - sourceTree = ""; - }; - 75E0EB762B7B290400E3198A /* SourceTests */ = { - isa = PBXGroup; - children = ( - 750708DF2B7909BB00A48DD0 /* SourceTests.swift */, - 75E0EB742B7B280300E3198A /* SourceTests+Helpers.swift */, + 75B4205C2B7674CF0036134D /* Extensions */, + 75CFC4F92B75503000422A8F /* Network Service */, ); - path = SourceTests; + path = Helpers; sourceTree = ""; }; 75F2A01A2A0BD1CD0038FA54 /* Resources */ = { @@ -967,11 +958,13 @@ 987A02CD1CE35D5E0035417A /* Info.plist */, 987A03AC1CE5CD450035417A /* Fixtures */, 750708E62B790CF200A48DD0 /* SampleData */, - 750708E82B79125200A48DD0 /* Old tests */, - 75B4208F2B78C22A0036134D /* New Tests */, 750708E12B790B2400A48DD0 /* Helpers */, - 75E0EB762B7B290400E3198A /* SourceTests */, + 750708E82B79125200A48DD0 /* Old tests */, + 75B4208F2B78C22A0036134D /* Draft Tests */, + 750708DF2B7909BB00A48DD0 /* SourceTests.swift */, + 75E0EB742B7B280300E3198A /* SourceTests+Helpers.swift */, 75E0EB702B7A904100E3198A /* SourceFlowTests.swift */, + 75B4208D2B78C2120036134D /* SourcePaymentPayloadTest.swift */, 750708F32B7A765500A48DD0 /* OmiseSDKTests.swift */, ); path = OmiseSDKTests; @@ -1222,7 +1215,7 @@ buildActionMask = 2147483647; files = ( 75B4207D2B77DE540036134D /* Source.Payload.DuitNowOBW.swift in Sources */, - 75B4209A2B78E56D0036134D /* Capability.swift in Sources */, + 75B4209A2B78E56D0036134D /* CapabilityOld.swift in Sources */, 75B420A92B78E5B30036134D /* CardBrand.swift in Sources */, 75B420AB2B78E5B30036134D /* Currency.swift in Sources */, 75F2A0B82A1A60630038FA54 /* ProxyProperty.swift in Sources */, @@ -1242,12 +1235,12 @@ 75CFC4D22B73AFD500422A8F /* OmiseSDK.swift in Sources */, 75B420732B77DE330036134D /* Source.Payload.EContext.swift in Sources */, 75131F862AC2BD9D008BCB17 /* UIViewController+NavigationBarStyle.swift in Sources */, - 75B420822B77FAA50036134D /* SourcePayment.swift in Sources */, + 75B420822B77FAA50036134D /* SourcePaymentPayload.swift in Sources */, 8A72CD5E2162358400F14F76 /* PaymentOptionTableViewCell.swift in Sources */, 8AD391B1230C05BC00383286 /* Colors.swift in Sources */, 75F2A0BB2A1A60630038FA54 /* AtomeFormViewContext.swift in Sources */, 75B420AD2B78E5B30036134D /* PaymentInformation.Atome.swift in Sources */, - 75B420662B77741E0036134D /* CardPayment.swift in Sources */, + 75B420662B77741E0036134D /* CardPaymentPayload.swift in Sources */, 986406351CFEA7E4004BCF51 /* OmiseTextField.swift in Sources */, 1121F44028523BED0003EE4F /* DuitNowOBWBankChooserViewController.swift in Sources */, 73F9BA4725E50F4700F55CA8 /* AdaptableDynamicTableViewController.swift in Sources */, @@ -1256,12 +1249,12 @@ 7502CA5F2A31A7D600766E7D /* CountryListViewController.swift in Sources */, 75B420942B78DE350036134D /* Capability.PaymentMethod.Provider.swift in Sources */, F3497368254C067000D05C7B /* MobileBankingSourceChooserViewController.swift in Sources */, - 75CFC4EE2B7537BC00422A8F /* ClientNew+URLRequest.swift in Sources */, + 75CFC4EE2B7537BC00422A8F /* Client+URLRequest.swift in Sources */, 8AF9857221479F72007E18ED /* CreditCardFormViewController.swift in Sources */, 8AC1D3A32139224D0051F966 /* InternetBankingSourceChooserViewController.swift in Sources */, 75B4209C2B78E56D0036134D /* Request.swift in Sources */, 7502CA662A31AEA200766E7D /* Country.swift in Sources */, - 75B4209D2B78E56D0036134D /* Token.swift in Sources */, + 75B4209D2B78E56D0036134D /* TokenOld.swift in Sources */, 75B420852B77FC850036134D /* Source.swift in Sources */, 75B420AF2B78E5D30036134D /* PaymentInformation.swift in Sources */, 75405A8B2A26340E008C21F6 /* UIStackView+Helpers.swift in Sources */, @@ -1270,6 +1263,7 @@ 756C8F262A40698600D53059 /* TextFieldView.swift in Sources */, 986406341CFEA7E4004BCF51 /* CardNameTextField.swift in Sources */, 8AF9857121479F38007E18ED /* MoreInformationOnCVVViewController.swift in Sources */, + 75E0EB7C2B7B410600E3198A /* Client+Network.swift in Sources */, 75405A7C2A25EC88008C21F6 /* Array+Helpers.swift in Sources */, 8A188BB01D951E3C00FFF467 /* AuthorizingPaymentViewController.swift in Sources */, 75B4205B2B7670A90036134D /* Token.Card.swift in Sources */, @@ -1307,11 +1301,11 @@ 75B420712B77DE2B0036134D /* Source.Payload.Installment.swift in Sources */, 75F2A0C22A1A87AE0038FA54 /* UIColor+Helpers.swift in Sources */, 7509D4DD2A1A9FD70050AB38 /* MainActionButton.swift in Sources */, - 75B420572B765BC40036134D /* TokenNew.swift in Sources */, + 75B420572B765BC40036134D /* Token.swift in Sources */, 752E40C42ACD420C00B62A49 /* SourceTypeValue.swift in Sources */, 750708EC2B7A2ACC00A48DD0 /* Source.Payload.BarcodeAlipay.swift in Sources */, - 75CFC4F12B753B0F00422A8F /* CapabilityNew.swift in Sources */, - 75CFC4CE2B73AF0E00422A8F /* ClientNew.swift in Sources */, + 75CFC4F12B753B0F00422A8F /* Capability.swift in Sources */, + 75CFC4CE2B73AF0E00422A8F /* Client.swift in Sources */, 7502CA622A31A7E100766E7D /* CountryListViewModelProtocol.swift in Sources */, 8AC1D3A5213922570051F966 /* InstallmentBankingSourceChooserViewController.swift in Sources */, 75CFC4F52B753C3C00422A8F /* SourceType.swift in Sources */, @@ -1376,7 +1370,7 @@ 75E0EB712B7A904100E3198A /* SourceFlowTests.swift in Sources */, 75CFC4F72B753D6300422A8F /* CapabilityTests.swift in Sources */, F615CBF8261565D600E1A2D9 /* CardExpiryDatePickerTests.swift in Sources */, - 75E0EB722B7A962600E3198A /* SourcePaymentTests.swift in Sources */, + 75E0EB722B7A962600E3198A /* SourcePaymentPayloadTest.swift in Sources */, 753279382A31B40F008048AD /* CountryListViewModelMockup.swift in Sources */, 7509D4E72A1C8E3D0050AB38 /* AtomeFormViewModelTests.swift in Sources */, 7509D4E22A1C876B0050AB38 /* AtomeFormViewContextMockup.swift in Sources */, From ebc659390ca38224f22c12c98fb65e752d713be0 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Tue, 13 Feb 2024 17:19:01 +0700 Subject: [PATCH 061/204] Clean tests. Added Client unit tests --- OmiseSDK/Refactoring/New/Client/Client.swift | 4 +- .../New/Models/CardPaymentPayload.swift | 13 +- .../New/Models/SourcePaymentPayload.swift | 11 +- OmiseSDK/Refactoring/New/OmiseAPI.swift | 4 - OmiseSDKTests/ClientTests.swift | 144 ++++++++++++++++ .../Draft Tests/CapabilityTests.swift | 19 --- .../Draft Tests/CardPaymenTests.swift | 1 - OmiseSDKTests/Draft Tests/ClientTests.swift | 157 ------------------ .../objects/source_alipay_object.json | 11 -- .../objects/source_alipay_plus/alipay_cn.json | 11 -- .../objects/source_alipay_plus/alipay_hk.json | 11 -- .../objects/source_alipay_plus/dana.json | 11 -- .../objects/source_alipay_plus/gcash.json | 11 -- .../objects/source_alipay_plus/kakaopay.json | 11 -- .../source_alipay_plus/touch_n_go.json | 11 -- .../Fixtures/objects/source_atome.json | 18 -- .../objects/source_barcode/alipay.json | 15 -- .../source_bill_payment/tesco_lotus.json | 11 -- .../Fixtures/objects/source_boost.json | 10 -- .../Fixtures/objects/source_duitnow_obw.json | 11 -- .../Fixtures/objects/source_duitnow_qr.json | 10 -- .../Fixtures/objects/source_fpx.json | 13 -- .../Fixtures/objects/source_grabpay.json | 10 -- .../objects/source_installments/bay.json | 13 -- .../objects/source_installments/bbl.json | 13 -- .../objects/source_installments/citi.json | 13 -- .../source_installments/first_choice.json | 13 -- .../objects/source_installments/kbank.json | 13 -- .../objects/source_installments/ktc.json | 13 -- .../objects/source_installments/mbb.json | 14 -- .../objects/source_installments/ttb.json | 13 -- .../objects/source_installments/uob.json | 13 -- .../objects/source_internet_banking/bay.json | 10 -- .../objects/source_internet_banking/bbl.json | 10 -- .../objects/source_internet_banking/ktb.json | 10 -- .../objects/source_internet_banking/scb.json | 10 -- .../Fixtures/objects/source_maybank_qr.json | 10 -- .../objects/source_mobile_banking/bay.json | 10 -- .../objects/source_mobile_banking/bbl.json | 10 -- .../objects/source_mobile_banking/kbank.json | 10 -- .../objects/source_mobile_banking/ktb.json | 10 -- .../objects/source_mobile_banking/scb.json | 10 -- .../Fixtures/objects/source_paypay.json | 10 -- .../objects/source_points/city_points.json | 11 -- .../objects/source_qr_payment/paynow.json | 11 -- .../objects/source_qr_payment/promptpay.json | 11 -- .../objects/source_rabbit_linepay.json | 11 -- .../Fixtures/objects/source_shopeepay.json | 10 -- .../objects/source_shopeepay_jumpapp.json | 10 -- .../objects/source_truemoney_object.json | 12 -- OmiseSDKTests/Helpers/SampleData.swift | 57 ++++++- OmiseSDKTests/Old tests/SDKTestCase.swift | 23 --- OmiseSDKTests/OmiseSDKTests.swift | 18 +- .../card_object.json => SampleData/card.json} | 10 +- .../token.json} | 0 .../CardPaymentPayloadTests.swift | 29 ++++ .../SourceFlowTests.swift | 0 .../SourcePaymentPayloadTest.swift | 15 ++ .../SourceTests.swift | 85 +++++----- OmiseSDKTests/SourcePaymentPayloadTest.swift | 17 -- OmiseSDKTests/SourceTests+Helpers.swift | 28 ---- dev.xcodeproj/project.pbxproj | 56 ++----- 62 files changed, 335 insertions(+), 835 deletions(-) create mode 100644 OmiseSDKTests/ClientTests.swift delete mode 100644 OmiseSDKTests/Draft Tests/CapabilityTests.swift delete mode 100644 OmiseSDKTests/Draft Tests/CardPaymenTests.swift delete mode 100644 OmiseSDKTests/Draft Tests/ClientTests.swift delete mode 100644 OmiseSDKTests/Fixtures/objects/source_alipay_object.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_alipay_plus/alipay_cn.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_alipay_plus/alipay_hk.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_alipay_plus/dana.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_alipay_plus/gcash.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_alipay_plus/kakaopay.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_alipay_plus/touch_n_go.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_atome.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_barcode/alipay.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_bill_payment/tesco_lotus.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_boost.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_duitnow_obw.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_duitnow_qr.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_fpx.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_grabpay.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_installments/bay.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_installments/bbl.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_installments/citi.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_installments/first_choice.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_installments/kbank.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_installments/ktc.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_installments/mbb.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_installments/ttb.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_installments/uob.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_internet_banking/bay.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_internet_banking/bbl.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_internet_banking/ktb.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_internet_banking/scb.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_maybank_qr.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_mobile_banking/bay.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_mobile_banking/bbl.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_mobile_banking/kbank.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_mobile_banking/ktb.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_mobile_banking/scb.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_paypay.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_points/city_points.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_qr_payment/paynow.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_qr_payment/promptpay.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_rabbit_linepay.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_shopeepay.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_shopeepay_jumpapp.json delete mode 100644 OmiseSDKTests/Fixtures/objects/source_truemoney_object.json delete mode 100644 OmiseSDKTests/Old tests/SDKTestCase.swift rename OmiseSDKTests/{Fixtures/objects/card_object.json => SampleData/card.json} (75%) rename OmiseSDKTests/{Fixtures/objects/token_object.json => SampleData/token.json} (100%) create mode 100644 OmiseSDKTests/Source and Token JSON Codable Tests/CardPaymentPayloadTests.swift rename OmiseSDKTests/{ => Source and Token JSON Codable Tests}/SourceFlowTests.swift (100%) create mode 100644 OmiseSDKTests/Source and Token JSON Codable Tests/SourcePaymentPayloadTest.swift rename OmiseSDKTests/{ => Source and Token JSON Codable Tests}/SourceTests.swift (87%) delete mode 100644 OmiseSDKTests/SourcePaymentPayloadTest.swift delete mode 100644 OmiseSDKTests/SourceTests+Helpers.swift diff --git a/OmiseSDK/Refactoring/New/Client/Client.swift b/OmiseSDK/Refactoring/New/Client/Client.swift index 841c6125..0ea0da47 100644 --- a/OmiseSDK/Refactoring/New/Client/Client.swift +++ b/OmiseSDK/Refactoring/New/Client/Client.swift @@ -11,13 +11,13 @@ public class Client { } let publicKey: String - let network: NetworkService + let network: NetworkServiceProtocol public convenience init(publicKey: String) { self.init(publicKey: publicKey, network: NetworkService()) } - init(publicKey: String, network: NetworkService) { + init(publicKey: String, network: NetworkServiceProtocol) { self.publicKey = publicKey self.network = network } diff --git a/OmiseSDK/Refactoring/New/Models/CardPaymentPayload.swift b/OmiseSDK/Refactoring/New/Models/CardPaymentPayload.swift index cca317d7..ba7f978a 100644 --- a/OmiseSDK/Refactoring/New/Models/CardPaymentPayload.swift +++ b/OmiseSDK/Refactoring/New/Models/CardPaymentPayload.swift @@ -1,10 +1,15 @@ import Foundation -// TODO: Add Unit Tests for CardPayment -/// Information to create a token +/// Card Information to create a token container +/// Used as payload in createToken API +struct TokenPaymentPayloadContainer: Codable { + let card: CardPaymentPayload +} + +/// Card Information to create a token /// A token represents a credit or debit card /// https://docs.opn.ooo/tokens-api -public struct CardPaymentPayload: Encodable { +public struct CardPaymentPayload: Codable, Equatable { /// Card holder's full name public let name: String /// Card number @@ -45,5 +50,3 @@ public struct CardPaymentPayload: Encodable { case phoneNumber = "phone_number" } } - - diff --git a/OmiseSDK/Refactoring/New/Models/SourcePaymentPayload.swift b/OmiseSDK/Refactoring/New/Models/SourcePaymentPayload.swift index cbe59187..ca45a26f 100644 --- a/OmiseSDK/Refactoring/New/Models/SourcePaymentPayload.swift +++ b/OmiseSDK/Refactoring/New/Models/SourcePaymentPayload.swift @@ -2,7 +2,7 @@ import Foundation /// Information to create payment source /// Sources are methods for accepting payments through non-credit-card channels -public struct SourcePaymentPayload: Encodable { +public struct SourcePaymentPayload: Codable, Equatable { /// Source amount in smallest unit of source currency let amount: Int64 /// Currency for source as three-letter ISO 4217 code @@ -32,5 +32,12 @@ public struct SourcePaymentPayload: Encodable { try container.encode(currency, forKey: .currency) try details.encode(to: encoder) } -} + // Decode SourcePaymentPayload object from JSON string + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + self.amount = try container.decode(Int64.self, forKey: .amount) + self.currency = try container.decode(String.self, forKey: .currency) + self.details = try Source.Payload(from: decoder) + } +} diff --git a/OmiseSDK/Refactoring/New/OmiseAPI.swift b/OmiseSDK/Refactoring/New/OmiseAPI.swift index 6af6bbd2..329face2 100644 --- a/OmiseSDK/Refactoring/New/OmiseAPI.swift +++ b/OmiseSDK/Refactoring/New/OmiseAPI.swift @@ -11,7 +11,6 @@ extension OmiseServerType { // swiftlint:enable force_unwrapping } -// TODO: Add Sample Data to test Client enum OmiseAPI { case capability case token(tokenID: String) @@ -62,9 +61,6 @@ extension OmiseAPI: APIProtocol { var httpBody: Data? { switch self { case .createToken(let payload): - struct TokenPaymentPayloadContainer: Encodable { - let card: CardPaymentPayload - } let token = TokenPaymentPayloadContainer(card: payload) return try? jsonEncoder.encode(token) case .createSource(let sourcePayment): diff --git a/OmiseSDKTests/ClientTests.swift b/OmiseSDKTests/ClientTests.swift new file mode 100644 index 00000000..f60a0280 --- /dev/null +++ b/OmiseSDKTests/ClientTests.swift @@ -0,0 +1,144 @@ +import Foundation +import XCTest +@testable import OmiseSDK + +struct NetworkMockup: NetworkServiceProtocol { + var sendClosure: (URLRequest) -> Void = { _ in } + + func send( + urlRequest: URLRequest, + dateFormatter: DateFormatter?, + completion: @escaping RequestResultClosure + ) { + self.sendClosure(urlRequest) + } +} + +class ClientTests: XCTestCase { + let publicKey = "pkey_test_58wfnlwoxz1tbkdd993" + let publicKeyBase64 = "cGtleV90ZXN0XzU4d2ZubHdveHoxdGJrZGQ5OTM=" + let requestTimeout: TimeInterval = 15.0 + + var testClient: Client! + + override func setUp() { + super.setUp() + testClient = Client(publicKey: publicKey) + + // swiftlint:disable force_unwrapping + let testEnvironment = Environment.dev( + vaultURL: URL(string: "https://vault.staging-omise.co")!, + apiURL: URL(string: "https://api.staging-omise.co")! + ) + // swiftlint:enable force_unwrapping + Configuration.setDefault(Configuration(environment: testEnvironment)) + } + + override func tearDown() { + testClient = nil + super.tearDown() + } + + /// Testing createToken API Request. + /// Testing if `Client` generates URLRequest with correct HTTP body to perform API request + func testCreateTokenURLRequest() throws { + let expectation = self.expectation(description: "Create Token Mockup Callback") + let cardPayload: CardPaymentPayload = try sampleFromJSONBy(.card) + + let networkMockup = NetworkMockup { [cardPayload] urlRequest in + defer { expectation.fulfill() } + + func validateURLRequest() { + if let data = urlRequest.httpBody, let jsonString = String(data: data, encoding: .utf8) { + do { + let decodedCardPayload: TokenPaymentPayloadContainer = try parse(jsonString: jsonString) + XCTAssertEqual(cardPayload, decodedCardPayload.card) + } catch { + XCTFail("Unable to decode payload from encoded JSON string") + } + + } else { + XCTFail("Unable to decode payload from encoded JSON string") + } + } + + validateURLRequest() + } + + let client = Client(publicKey: publicKey, network: networkMockup) + client.createToken(payload: cardPayload) { _ in + /// Testing URLRequst in through Network Mockup closure + /// Closure implementation is nor required + } + waitForExpectations(timeout: requestTimeout, handler: nil) + } + + /// Testing createToken API Request. + /// Testing if `Client` generates URLRequest with correct HTTP body to perform API request + func testCreateSourceURLRequest() throws { + let expectation = self.expectation(description: "Create Source Mockup Callback") + let sourcePayload: SourcePaymentPayload = try sampleFromJSONBy(.source(type: .atome)) + + let networkMockup = NetworkMockup { [sourcePayload] urlRequest in + defer { expectation.fulfill() } + + func validateURLRequest() { + if let data = urlRequest.httpBody, let jsonString = String(data: data, encoding: .utf8) { + do { + let decodedCardPayload: SourcePaymentPayload = try parse(jsonString: jsonString) + XCTAssertEqual(sourcePayload, decodedCardPayload) + } catch { + XCTFail("Unable to decode payload from encoded JSON string") + } + + } else { + XCTFail("Unable to decode payload from encoded JSON string") + } + } + + validateURLRequest() + } + + let client = Client(publicKey: publicKey, network: networkMockup) + client.createSource(payload: sourcePayload) { _ in + /// Testing URLRequst in through Network Mockup closure + /// Closure implementation is nor required + } + waitForExpectations(timeout: requestTimeout, handler: nil) + } + + // - Mark testClient.userAgent as private + // - Move this test to testUrlRequest + func testUserAgent() { + let sdkVersion = "1.0.0" + let platform = "12.0.0" + let device = "iPhone" + + let expectedResult = "OmiseIOS/\(sdkVersion) iOS/\(platform) Apple/\(device)" + let result = testClient.userAgent(sdkVersion: sdkVersion, platform: platform, device: device) + XCTAssertEqual(expectedResult, result) + } + + // - Mark testClient.httpHeaders as private + // - Move this test to testUrlRequest + func testHTTPHeaders() { + let userAgent = "OmiseIOSSDK/3.0.0 iOS/12.0.0 Apple/iPhone" + let apiVersion = "2019-05-29" + let contentType = "application/json; charset=utf8" + + let expectedResult = [ + "Authorization": "Basic \(publicKeyBase64)", + "User-Agent": userAgent, + "Content-Type": contentType, + "Omise-Version": apiVersion + ] + + let result = testClient.httpHeaders( + publicKey: publicKey, + userAgent: userAgent, + apiVersion: apiVersion, + contentType: contentType + ) + XCTAssertEqual(expectedResult, result) + } +} diff --git a/OmiseSDKTests/Draft Tests/CapabilityTests.swift b/OmiseSDKTests/Draft Tests/CapabilityTests.swift deleted file mode 100644 index c2a1a5d5..00000000 --- a/OmiseSDKTests/Draft Tests/CapabilityTests.swift +++ /dev/null @@ -1,19 +0,0 @@ -import Foundation -import XCTest -@testable import OmiseSDK - -class CapabilityTests: XCTestCase { - func testParser() { - let decoder = JSONDecoder() - - do { - let jsonData = try XCTestCase.fixturesData(forFilename: "capability") - let capability = try decoder.decode(Capability.self, from: jsonData) - print(capability) - XCTAssertTrue(true) - } catch { - print(error) - XCTFail("Parsing results with errpr") - } - } -} diff --git a/OmiseSDKTests/Draft Tests/CardPaymenTests.swift b/OmiseSDKTests/Draft Tests/CardPaymenTests.swift deleted file mode 100644 index fecc4ab4..00000000 --- a/OmiseSDKTests/Draft Tests/CardPaymenTests.swift +++ /dev/null @@ -1 +0,0 @@ -import Foundation diff --git a/OmiseSDKTests/Draft Tests/ClientTests.swift b/OmiseSDKTests/Draft Tests/ClientTests.swift deleted file mode 100644 index 1fc25c06..00000000 --- a/OmiseSDKTests/Draft Tests/ClientTests.swift +++ /dev/null @@ -1,157 +0,0 @@ -import Foundation -import XCTest -@testable import OmiseSDK - -class ClientTests: XCTestCase { - let publicKey = "pkey_test_58wfnlwoxz1tbkdd993" - let publicKeyBase64 = "cGtleV90ZXN0XzU4d2ZubHdveHoxdGJrZGQ5OTM=" - let requestTimeout: TimeInterval = 15.0 - - var testClient: Client! - - override func setUp() { - super.setUp() - testClient = Client(publicKey: publicKey) - - // swiftlint:disable force_unwrapping - let testEnvironment = Environment.dev( - vaultURL: URL(string: "https://vault.staging-omise.co")!, - apiURL: URL(string: "https://api.staging-omise.co")! - ) - // swiftlint:enable force_unwrapping - Configuration.setDefault(Configuration(environment: testEnvironment)) - } - - override func tearDown() { - testClient = nil - super.tearDown() - } - - // TODO: - // - Mark testClient.userAgent as private - // - Move this test to testUrlRequest - func testUserAgent() { - let sdkVersion = "1.0.0" - let platform = "12.0.0" - let device = "iPhone" - - let expectedResult = "OmiseIOS/\(sdkVersion) iOS/\(platform) Apple/\(device)" - let result = testClient.userAgent(sdkVersion: sdkVersion, platform: platform, device: device) - XCTAssertEqual(expectedResult, result) - } - - // TODO: - // - Mark testClient.httpHeaders as private - // - Move this test to testUrlRequest - func testHTTPHeaders() { - let userAgent = "OmiseIOSSDK/3.0.0 iOS/12.0.0 Apple/iPhone" - let apiVersion = "2019-05-29" - let contentType = "application/json; charset=utf8" - - let expectedResult = [ - "Authorization": "Basic \(publicKeyBase64)", - "User-Agent": userAgent, - "Content-Type": contentType, - "Omise-Version": apiVersion - ] - - let result = testClient.httpHeaders( - publicKey: publicKey, - userAgent: userAgent, - apiVersion: apiVersion, - contentType: contentType - ) - XCTAssertEqual(expectedResult, result) - } - - /* - func testCapabilityAPI() { - let expectation = self.expectation(description: "API: CapabilityOld") - - testClient?.capability { result in - print(result) - - do { - let value = try result.get() - print(value) - XCTAssertNotNil(value) - } catch { - XCTFail("Failed with \(error)") - } - - expectation.fulfill() - } - - waitForExpectations(timeout: 15.0, handler: nil) - } - */ - - /* - func testCreateTokenAPI() { - let expectation = self.expectation(description: "API: Create TokenOld") - - // TODO: Move to test data collection - let card = PaymentInformationNew.Card( - name: "Test User", - number: "4242424242424242", - expirationMonth: 4, - expirationYear: 2024, - securityCode: "123", - countryCode: "th", - city: nil, - state: nil, - street1: nil, - street2: nil, - postalCode: nil, - phoneNumber: nil - ) - - let publicKey = "..." - let client = Client(publicKey: publicKey) - - client.createToken(card: card) { result in - print(result) - - do { - let value = try result.get() - print(value) - XCTAssertNotNil(value) - } catch { - XCTFail("Failed with \(error)") - } - - expectation.fulfill() - } - - waitForExpectations(timeout: requestTimeout, handler: nil) - } - */ - - /* - func testObserveChargeStatus() { - let expectation = self.expectation(description: "API: Observe Charge Status") - - let tokenID = "test token id" - let publicKey = "test pkey" - let client = Client(publicKey: publicKey) - client.observeChargeStatusUntilChange(tokenID: tokenID) { result in - do { - let value = try result.get() - print(value) - XCTAssertNotNil(value) - } catch { - XCTFail("Failed with \(error)") - } - - expectation.fulfill() - } - - waitForExpectations(timeout: 15.0, handler: nil) - - } - */ -} - -class MockupNetwork: NetworkService { - -} diff --git a/OmiseSDKTests/Fixtures/objects/source_alipay_object.json b/OmiseSDKTests/Fixtures/objects/source_alipay_object.json deleted file mode 100644 index a6450ef0..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_alipay_object.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "object": "source", - "id": "src_test_5avnfnqxzzj2yu7a34e", - "livemode": false, - "location": "/sources/src_test_5avnfnqxzzj2yu7a34e", - "created_at": "2019-05-22T06:21:47Z", - "type": "alipay", - "flow": "redirect", - "amount": 1000000, - "currency": "THB" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_alipay_plus/alipay_cn.json b/OmiseSDKTests/Fixtures/objects/source_alipay_plus/alipay_cn.json deleted file mode 100644 index 00010d50..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_alipay_plus/alipay_cn.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "object": "source", - "id": "src_test_5owftw9kjhjisssm0n2", - "livemode": false, - "location": "/sources/src_test_5owftw9kjhjisssm0n2", - "created_at": "2021-08-22T06:22:18Z", - "type": "alipay_cn", - "flow": "app_redirect", - "amount": 500000, - "currency": "THB" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_alipay_plus/alipay_hk.json b/OmiseSDKTests/Fixtures/objects/source_alipay_plus/alipay_hk.json deleted file mode 100644 index eefe471a..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_alipay_plus/alipay_hk.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "object": "source", - "id": "src_test_5oxesy9ovpgawobhf6n", - "livemode": false, - "location": "/sources/src_test_5oxesy9ovpgawobhf6n", - "created_at": "2021-08-22T06:22:18Z", - "type": "alipay_hk", - "flow": "app_redirect", - "amount": 500000, - "currency": "HKD" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_alipay_plus/dana.json b/OmiseSDKTests/Fixtures/objects/source_alipay_plus/dana.json deleted file mode 100644 index 21b2da1c..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_alipay_plus/dana.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "object": "source", - "id": "src_test_5oxew5l8jxhss03ybfb", - "livemode": false, - "location": "/sources/src_test_5oxew5l8jxhss03ybfb", - "created_at": "2021-08-22T06:22:18Z", - "type": "dana", - "flow": "app_redirect", - "amount": 500000, - "currency": "JPY" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_alipay_plus/gcash.json b/OmiseSDKTests/Fixtures/objects/source_alipay_plus/gcash.json deleted file mode 100644 index ce0111b3..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_alipay_plus/gcash.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "object": "source", - "id": "src_test_5oxesgzoekdn5nukcdf", - "livemode": false, - "location": "/sources/src_test_5oxesgzoekdn5nukcdf", - "created_at": "2021-08-22T06:22:18Z", - "type": "gcash", - "flow": "app_redirect", - "amount": 500000, - "currency": "USD" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_alipay_plus/kakaopay.json b/OmiseSDKTests/Fixtures/objects/source_alipay_plus/kakaopay.json deleted file mode 100644 index 0058004c..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_alipay_plus/kakaopay.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "object": "source", - "id": "src_test_5oxetau2owhu0rbzg7y", - "livemode": false, - "location": "/sources/src_test_5oxetau2owhu0rbzg7y", - "created_at": "2021-08-22T06:22:18Z", - "type": "kakaopay", - "flow": "app_redirect", - "amount": 500000, - "currency": "USD" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_alipay_plus/touch_n_go.json b/OmiseSDKTests/Fixtures/objects/source_alipay_plus/touch_n_go.json deleted file mode 100644 index 0fc2b5ce..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_alipay_plus/touch_n_go.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "object": "source", - "id": "src_test_5oxet335rx3xzdyn06g", - "livemode": false, - "location": "/sources/src_test_5oxet335rx3xzdyn06g", - "created_at": "2021-08-22T06:22:18Z", - "type": "touch_n_go", - "flow": "app_redirect", - "amount": 500000, - "currency": "SGD" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_atome.json b/OmiseSDKTests/Fixtures/objects/source_atome.json deleted file mode 100644 index f68548ca..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_atome.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "object": "source", - "id": "src_test_5jhmesi7s4at1qctloy", - "livemode": false, - "location": "/sources/src_test_5jhmesi7s4at1qctloy", - "created_at": "2020-04-09T02:47:32Z", - "type": "atome", - "flow": "redirect", - "amount": 100000, - "currency": "THB", - "phone_number": "+66800000101", - "name": "name surname", - "email": "test_user@opn.ooo", - "shipping_street": "4 Sukhumvit 103 rd.", - "shipping_city": "Bangkok", - "shipping_country_code": "TH", - "shipping_postal_code": "10260" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_barcode/alipay.json b/OmiseSDKTests/Fixtures/objects/source_barcode/alipay.json deleted file mode 100644 index c9ffe575..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_barcode/alipay.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "object": "source", - "id": "src_test_5cq1tilrnz7d62t8y87", - "livemode": false, - "location": "/sources/src_test_5cq1tilrnz7d62t8y87", - "created_at": "2019-05-22T06:21:59Z", - "type": "barcode_alipay", - "flow": "offline", - "amount": 100000, - "currency": "THB", - "barcode": "1234567890123456", - "store_id": "1", - "store_name": "Main Store", - "terminal_id": null -} diff --git a/OmiseSDKTests/Fixtures/objects/source_bill_payment/tesco_lotus.json b/OmiseSDKTests/Fixtures/objects/source_bill_payment/tesco_lotus.json deleted file mode 100644 index b4551283..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_bill_payment/tesco_lotus.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "object": "source", - "id": "src_test_59trf2nxk43b5nml8z0", - "livemode": false, - "location": "/sources/src_test_59trf2nxk43b5nml8z0", - "created_at": "2019-05-22T06:22:08Z", - "type": "bill_payment_tesco_lotus", - "flow": "offline", - "amount": 1000000, - "currency": "THB" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_boost.json b/OmiseSDKTests/Fixtures/objects/source_boost.json deleted file mode 100644 index 122c1ebc..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_boost.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "object": "source", - "id": "src_5pqcjr6tu4xvqut5nh5", - "livemode": true, - "location": "/sources/src_5pqcjr6tu4xvqut5nh5", - "type": "boost", - "flow": "redirect", - "amount": 100000, - "currency": "MYR" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_duitnow_obw.json b/OmiseSDKTests/Fixtures/objects/source_duitnow_obw.json deleted file mode 100644 index e36260e2..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_duitnow_obw.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "object": "source", - "id": "src_5pqcjr6tu4xvqut5nh5", - "livemode": true, - "location": "/sources/src_5pqcjr6tu4xvqut5nh5", - "type": "duitnow_obw", - "flow": "redirect", - "amount": 100000, - "currency": "MYR", - "bank": "affin" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_duitnow_qr.json b/OmiseSDKTests/Fixtures/objects/source_duitnow_qr.json deleted file mode 100644 index d355db18..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_duitnow_qr.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "object": "source", - "id": "src_5pqcjr6tu4xvqut5nh5", - "livemode": true, - "location": "/sources/src_5pqcjr6tu4xvqut5nh5", - "type": "duitnow_qr", - "flow": "redirect", - "amount": 100000, - "currency": "MYR" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_fpx.json b/OmiseSDKTests/Fixtures/objects/source_fpx.json deleted file mode 100644 index 82dddef4..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_fpx.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "object": "source", - "id": "src_test_5jhmesi7s4at1qctloz", - "livemode": false, - "location": "/sources/src_test_5jhmesi7s4at1qctloz", - "created_at": "2020-04-09T02:47:32Z", - "type": "fpx", - "flow": "redirect", - "amount": 100000, - "currency": "MYR", - "bank": "uob", - "email": "support@omise.co" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_grabpay.json b/OmiseSDKTests/Fixtures/objects/source_grabpay.json deleted file mode 100644 index 656bf040..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_grabpay.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "object": "source", - "id": "src_test_5pqcjr6tu4xvqut5nh5", - "livemode": false, - "location": "/sources/src_test_5pqcjr6tu4xvqut5nh5", - "type": "grabpay", - "flow": "redirect", - "amount": 100000, - "currency": "SGD" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_installments/bay.json b/OmiseSDKTests/Fixtures/objects/source_installments/bay.json deleted file mode 100644 index b584c58e..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_installments/bay.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "object": "source", - "id": "src_test_5cs0t6x8n0z8rcfrsfi", - "livemode": false, - "location": "/sources/src_test_5cs0t6x8n0z8rcfrsfi", - "created_at": "2019-05-22T06:22:18Z", - "type": "installment_bay", - "flow": "redirect", - "amount": 500000, - "currency": "THB", - "installment_term": 6, - "zero_interest_installments": false -} diff --git a/OmiseSDKTests/Fixtures/objects/source_installments/bbl.json b/OmiseSDKTests/Fixtures/objects/source_installments/bbl.json deleted file mode 100644 index b79faec6..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_installments/bbl.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "object": "source", - "id": "src_test_5cs0tdinbyypg6kn1fa", - "livemode": false, - "location": "/sources/src_test_5cs0tdinbyypg6kn1fa", - "created_at": "2019-05-22T06:22:18Z", - "type": "installment_bbl", - "flow": "redirect", - "amount": 500000, - "currency": "THB", - "installment_term": 6, - "zero_interest_installments": false -} diff --git a/OmiseSDKTests/Fixtures/objects/source_installments/citi.json b/OmiseSDKTests/Fixtures/objects/source_installments/citi.json deleted file mode 100644 index fb5c6b2e..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_installments/citi.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "object": "source", - "id": "src_test_5obr9ossd5huc93kd71", - "livemode": false, - "location": "/sources/src_test_5obr9opqz5huc6tefw8", - "created_at": "2019-05-22T06:22:18Z", - "type": "installment_citi", - "flow": "redirect", - "amount": 500000, - "currency": "THB", - "installment_term": 6, - "zero_interest_installments": false -} diff --git a/OmiseSDKTests/Fixtures/objects/source_installments/first_choice.json b/OmiseSDKTests/Fixtures/objects/source_installments/first_choice.json deleted file mode 100644 index e2ca012b..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_installments/first_choice.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "object": "source", - "id": "src_test_5cq1ugk8m0un1yefb2u", - "livemode": false, - "location": "/sources/src_test_5cq1ugk8m0un1yefb2u", - "created_at": "2019-05-22T06:22:18Z", - "type": "installment_first_choice", - "flow": "redirect", - "amount": 500000, - "currency": "THB", - "installment_term": 6, - "zero_interest_installments": false -} diff --git a/OmiseSDKTests/Fixtures/objects/source_installments/kbank.json b/OmiseSDKTests/Fixtures/objects/source_installments/kbank.json deleted file mode 100644 index 3f5b6daa..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_installments/kbank.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "object": "source", - "id": "src_test_5cs0totfv87k1i6y45l", - "livemode": false, - "location": "/sources/src_test_5cs0totfv87k1i6y45l", - "created_at": "2019-05-22T06:22:18Z", - "type": "installment_kbank", - "flow": "redirect", - "amount": 500000, - "currency": "THB", - "installment_term": 6, - "zero_interest_installments": false -} diff --git a/OmiseSDKTests/Fixtures/objects/source_installments/ktc.json b/OmiseSDKTests/Fixtures/objects/source_installments/ktc.json deleted file mode 100644 index 7250e419..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_installments/ktc.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "object": "source", - "id": "src_test_5cs0tk7m2e5ivctrq30", - "livemode": false, - "location": "/sources/src_test_5cs0tk7m2e5ivctrq30", - "created_at": "2019-05-22T06:22:18Z", - "type": "installment_ktc", - "flow": "redirect", - "amount": 500000, - "currency": "THB", - "installment_term": 6, - "zero_interest_installments": false -} diff --git a/OmiseSDKTests/Fixtures/objects/source_installments/mbb.json b/OmiseSDKTests/Fixtures/objects/source_installments/mbb.json deleted file mode 100644 index f63f77fa..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_installments/mbb.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "object": "source", - "id": "src_test_5obr9opqz5huc6tefw8", - "livemode": false, - "location": "/sources/src_test_5obr9opqz5huc6tefw8", - "created_at": "2019-05-22T06:22:18Z", - "type": "installment_mbb", - "flow": "redirect", - "amount": 500000, - "currency": "MYR", - "installment_term": 6, - "zero_interest_installments": false -} - diff --git a/OmiseSDKTests/Fixtures/objects/source_installments/ttb.json b/OmiseSDKTests/Fixtures/objects/source_installments/ttb.json deleted file mode 100644 index 2c648e56..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_installments/ttb.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "object": "source", - "id": "src_test_5obr9opd7ej5c6tefw8", - "livemode": false, - "location": "/sources/src_test_5obr9opqz5huc6tefw8", - "created_at": "2019-05-22T06:22:18Z", - "type": "installment_ttb", - "flow": "redirect", - "amount": 500000, - "currency": "THB", - "installment_term": 6, - "zero_interest_installments": false -} diff --git a/OmiseSDKTests/Fixtures/objects/source_installments/uob.json b/OmiseSDKTests/Fixtures/objects/source_installments/uob.json deleted file mode 100644 index 9cefe88c..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_installments/uob.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "object": "source", - "id": "src_test_5oe7fj1qz5huc6tefw8", - "livemode": false, - "location": "/sources/src_test_5obr9opqz5huc6tefw8", - "created_at": "2019-05-22T06:22:18Z", - "type": "installment_uob", - "flow": "redirect", - "amount": 500000, - "currency": "THB", - "installment_term": 6, - "zero_interest_installments": false -} diff --git a/OmiseSDKTests/Fixtures/objects/source_internet_banking/bay.json b/OmiseSDKTests/Fixtures/objects/source_internet_banking/bay.json deleted file mode 100644 index 4efc90dd..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_internet_banking/bay.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "object": "source", - "id": "src_test_5cs0sm8u8h8nqo5hwcs", - "livemode": false, - "location": "/sources/src_test_5cs0sm8u8h8nqo5hwcs", - "type": "internet_banking_bay", - "flow": "redirect", - "amount": 100000, - "currency": "THB" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_internet_banking/bbl.json b/OmiseSDKTests/Fixtures/objects/source_internet_banking/bbl.json deleted file mode 100644 index a7e1d988..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_internet_banking/bbl.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "object": "source", - "id": "src_test_5cs0sfy7phu06yhyz5c", - "livemode": false, - "location": "/sources/src_test_5cs0sfy7phu06yhyz5c", - "type": "internet_banking_bbl", - "flow": "redirect", - "amount": 100000, - "currency": "THB" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_internet_banking/ktb.json b/OmiseSDKTests/Fixtures/objects/source_internet_banking/ktb.json deleted file mode 100644 index 3e22f352..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_internet_banking/ktb.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "object": "source", - "id": "src_test_5cs0swjx9zguxt0kd0z", - "livemode": false, - "location": "/sources/src_test_5cs0swjx9zguxt0kd0z", - "type": "internet_banking_ktb", - "flow": "redirect", - "amount": 100000, - "currency": "THB" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_internet_banking/scb.json b/OmiseSDKTests/Fixtures/objects/source_internet_banking/scb.json deleted file mode 100644 index b9339b0e..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_internet_banking/scb.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "object": "source", - "id": "src_test_5avnh1p1dt3hkh161ac", - "livemode": false, - "location": "/sources/src_test_5avnh1p1dt3hkh161ac", - "type": "internet_banking_scb", - "flow": "redirect", - "amount": 1000000, - "currency": "THB" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_maybank_qr.json b/OmiseSDKTests/Fixtures/objects/source_maybank_qr.json deleted file mode 100644 index dbffdb21..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_maybank_qr.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "object": "source", - "id": "src_5pqcjr6tu4xvqut5nh5", - "livemode": true, - "location": "/sources/src_5pqcjr6tu4xvqut5nh5", - "type": "maybank_qr", - "flow": "redirect", - "amount": 100000, - "currency": "MYR" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_mobile_banking/bay.json b/OmiseSDKTests/Fixtures/objects/source_mobile_banking/bay.json deleted file mode 100644 index 56ce76dc..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_mobile_banking/bay.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "object": "source", - "id": "src_test_5cs0sm8u8h8nqo5zasd", - "livemode": false, - "location": "/sources/src_test_5avnh1p1dt3hkh161ac", - "type": "mobile_banking_bay", - "flow": "app_redirect", - "amount": 1000000, - "currency": "THB" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_mobile_banking/bbl.json b/OmiseSDKTests/Fixtures/objects/source_mobile_banking/bbl.json deleted file mode 100644 index 63a95702..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_mobile_banking/bbl.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "object": "source", - "id": "src_test_5cs0sm8u8h8nqo5zasd", - "livemode": false, - "location": "/sources/src_test_5avnh1p1dt3hkh161ac", - "type": "mobile_banking_bbl", - "flow": "app_redirect", - "amount": 1000000, - "currency": "THB" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_mobile_banking/kbank.json b/OmiseSDKTests/Fixtures/objects/source_mobile_banking/kbank.json deleted file mode 100644 index 83e9c21d..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_mobile_banking/kbank.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "object": "source", - "id": "src_test_5cs0sm8u8h8nqo5zasd", - "livemode": false, - "location": "/sources/src_test_5avnh1p1dt3hkh161ac", - "type": "mobile_banking_kbank", - "flow": "app_redirect", - "amount": 1000000, - "currency": "THB" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_mobile_banking/ktb.json b/OmiseSDKTests/Fixtures/objects/source_mobile_banking/ktb.json deleted file mode 100644 index a9694b42..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_mobile_banking/ktb.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "object": "source", - "id": "src_test_5cs0sm8u8h8nqo5zasd", - "livemode": false, - "location": "/sources/src_test_5avnh1p1dt3hkh161ac", - "type": "mobile_banking_ktb", - "flow": "app_redirect", - "amount": 1000000, - "currency": "THB" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_mobile_banking/scb.json b/OmiseSDKTests/Fixtures/objects/source_mobile_banking/scb.json deleted file mode 100644 index 84e74ebc..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_mobile_banking/scb.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "object": "source", - "id": "src_test_5cs0sm8u8h8nqo5zasd", - "livemode": false, - "location": "/sources/src_test_5avnh1p1dt3hkh161ac", - "type": "mobile_banking_scb", - "flow": "app_redirect", - "amount": 1000000, - "currency": "THB" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_paypay.json b/OmiseSDKTests/Fixtures/objects/source_paypay.json deleted file mode 100644 index 0d0d0c7b..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_paypay.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "object": "source", - "id": "src_5pqcjr6tu4xvqut5nh5", - "livemode": true, - "location": "/sources/src_5pqcjr6tu4xvqut5nh5", - "type": "paypay", - "flow": "redirect", - "amount": 100000, - "currency": "JPY" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_points/city_points.json b/OmiseSDKTests/Fixtures/objects/source_points/city_points.json deleted file mode 100644 index 175dbc0b..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_points/city_points.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "object": "source", - "id": "src_test_5ji0d5y5w8xd9ll3loh", - "livemode": false, - "location": "/sources/src_test_5ji0d5y5w8xd9ll3loh", - "created_at": "2020-04-10T02:34:39Z", - "type": "points_citi", - "flow": "redirect", - "amount": 100000, - "currency": "THB" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_qr_payment/paynow.json b/OmiseSDKTests/Fixtures/objects/source_qr_payment/paynow.json deleted file mode 100644 index accd5375..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_qr_payment/paynow.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "object": "source", - "id": "src_test_5iso4taobco8j5jehx5", - "livemode": false, - "location": "/sources/src_test_5iso4taobco8j5jehx5", - "created_at": "2020-02-05T07:43:13Z", - "type": "paynow", - "flow": "offline", - "amount": 100000, - "currency": "SGD" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_qr_payment/promptpay.json b/OmiseSDKTests/Fixtures/objects/source_qr_payment/promptpay.json deleted file mode 100644 index cadf30ad..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_qr_payment/promptpay.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "object": "source", - "id": "src_test_5jb2cjjyjea25nps3ya", - "livemode": false, - "location": "/sources/src_test_5jb2cjjyjea25nps3ya", - "amount": 100000, - "created_at": "2020-03-23T08:26:05Z", - "currency": "THB", - "flow": "offline", - "type": "promptpay" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_rabbit_linepay.json b/OmiseSDKTests/Fixtures/objects/source_rabbit_linepay.json deleted file mode 100644 index 5ef6f037..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_rabbit_linepay.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "object": "source", - "id": "src_test_5owftw9kjhjisssm0n2", - "livemode": false, - "location": "/sources/src_test_5owftw9kjhjisssm0n2", - "created_at": "2021-08-22T06:22:18Z", - "type": "rabbit_linepay", - "flow": "redirect", - "amount": 500000, - "currency": "THB" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_shopeepay.json b/OmiseSDKTests/Fixtures/objects/source_shopeepay.json deleted file mode 100644 index 8943aa2f..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_shopeepay.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "object": "source", - "id": "src_5pqcjr6tu4xvqut5nh5", - "livemode": true, - "location": "/sources/src_5pqcjr6tu4xvqut5nh5", - "type": "shopeepay", - "flow": "redirect", - "amount": 100000, - "currency": "MYR" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_shopeepay_jumpapp.json b/OmiseSDKTests/Fixtures/objects/source_shopeepay_jumpapp.json deleted file mode 100644 index 05a42a71..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_shopeepay_jumpapp.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "object": "source", - "id": "src_5pqcjr6tu4xvqut5nh5", - "livemode": true, - "location": "/sources/src_5pqcjr6tu4xvqut5nh5", - "type": "shopeepay_jumpapp", - "flow": "redirect", - "amount": 100000, - "currency": "MYR" -} diff --git a/OmiseSDKTests/Fixtures/objects/source_truemoney_object.json b/OmiseSDKTests/Fixtures/objects/source_truemoney_object.json deleted file mode 100644 index 7c9f8904..00000000 --- a/OmiseSDKTests/Fixtures/objects/source_truemoney_object.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "object": "source", - "id": "src_test_5jhmesi7s4at1qctloy", - "livemode": false, - "location": "/sources/src_test_5jhmesi7s4at1qctloy", - "created_at": "2020-04-09T02:47:32Z", - "type": "truemoney", - "flow": "redirect", - "amount": 100000, - "currency": "THB", - "phone_number": "0123456789" -} diff --git a/OmiseSDKTests/Helpers/SampleData.swift b/OmiseSDKTests/Helpers/SampleData.swift index 0d1c0142..403325a9 100644 --- a/OmiseSDKTests/Helpers/SampleData.swift +++ b/OmiseSDKTests/Helpers/SampleData.swift @@ -4,12 +4,21 @@ import OmiseSDK class SampleData { enum Entity { - case source(sourceType: SourceType) - + case source(type: SourceType) + case card + case token + case capability + var path: String { switch self { case .source(let type): return "sources/\(type.rawValue)" + case .card: + return "card" + case .token: + return "token" + case .capability: + return "capability" } } } @@ -23,3 +32,47 @@ class SampleData { return data } } + +private let sampleData = SampleData() +private let jsonDecoder = JSONDecoder() + +/// Load JSON sample data from resources by given SourceType +func sampleFromJSONBy(_ entity: SampleData.Entity) throws -> T { + do { + switch entity { + case .card: + print("aa") + default: + break + } + let data = try sampleData.jsonData(for: entity) + let obj = try jsonDecoder.decode(T.self, from: data) + return obj + } catch { + XCTFail("Cannot decode \(T.self): \(entity) \(error)") + throw error + } +} + +struct StringToDataCastError: Error {} +struct DataToStringCastError: Error {} + +func encodeToJson(_ object: T) throws -> String { + let encoder = JSONEncoder() + encoder.outputFormatting = [.sortedKeys] + + let data = try encoder.encode(object) + guard let result = String(data: data, encoding: .utf8) else { + throw DataToStringCastError() + } + + return result +} +/// Decode JSON string into Decodable +func parse(jsonString: String) throws -> T { + guard let data = jsonString.data(using: .utf8) else { + throw StringToDataCastError() + } + + return try jsonDecoder.decode(T.self, from: data) +} diff --git a/OmiseSDKTests/Old tests/SDKTestCase.swift b/OmiseSDKTests/Old tests/SDKTestCase.swift deleted file mode 100644 index 9bab11e4..00000000 --- a/OmiseSDKTests/Old tests/SDKTestCase.swift +++ /dev/null @@ -1,23 +0,0 @@ -import XCTest - -extension XCTestCase { - static func fixturesData(forFilename filename: String) throws -> Data { - let bundle = Bundle(for: ClientTests.self) - let path = try XCTUnwrap(bundle.url(forResource: "Fixtures/objects/\(filename)", withExtension: "json")) - let data = try Data(contentsOf: path) - - return data - } - - static let jsonDateFormatter: DateFormatter = { - let formatter = DateFormatter() - formatter.locale = Locale(identifier: "en_US_POSIX") - formatter.timeZone = TimeZone(identifier: "UTC") - formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'" - return formatter - }() - - static func dateFromJSONString(_ dateString: String) -> Date? { - return jsonDateFormatter.date(from: dateString) - } -} diff --git a/OmiseSDKTests/OmiseSDKTests.swift b/OmiseSDKTests/OmiseSDKTests.swift index d76bd35e..156c42d3 100644 --- a/OmiseSDKTests/OmiseSDKTests.swift +++ b/OmiseSDKTests/OmiseSDKTests.swift @@ -1,9 +1,11 @@ -// -// OmiseSDKTests.swift -// OmiseSDKTests -// -// Created by Andrei Solovev on 12/2/24. -// Copyright © 2024 Omise. All rights reserved. -// - import Foundation +import XCTest +@testable import OmiseSDK + +class OmiseSDKTests: XCTestCase { + func testCountry() { + let expectedCountry = Country(name: "Thailand", code: "TH") + OmiseSDK.shared.setCurrentCountry(countryCode: "TH") + XCTAssertEqual(expectedCountry, OmiseSDK.shared.currentCountry) + } +} diff --git a/OmiseSDKTests/Fixtures/objects/card_object.json b/OmiseSDKTests/SampleData/card.json similarity index 75% rename from OmiseSDKTests/Fixtures/objects/card_object.json rename to OmiseSDKTests/SampleData/card.json index 664fe559..63d932c7 100644 --- a/OmiseSDKTests/Fixtures/objects/card_object.json +++ b/OmiseSDKTests/SampleData/card.json @@ -5,13 +5,13 @@ "location": null, "created_at": "2019-07-26T05:45:20Z", "deleted": false, - "street1": null, - "street2": null, + "street1": "Sukhumvit", + "street2": "MBK", "city": "Bangkok", - "state": null, + "state": "Bangkok Metropolis", "postal_code": "10240", "country": "gb", - "phone_number": null, + "phone_number": "0123456789", "financing": "credit", "bank": "STRIPE PAYMENTS UK LIMITED", "first_digits": null, @@ -19,7 +19,9 @@ "brand": "Visa", "expiration_month": 12, "expiration_year": 2020, + "number": "4242424242424242", "fingerprint": "mKleiBfwp+PoJWB/ipngANuECUmRKjyxROwFW5IO7TM=", "name": "John Doe", + "security_code": "123", "security_code_check": true } diff --git a/OmiseSDKTests/Fixtures/objects/token_object.json b/OmiseSDKTests/SampleData/token.json similarity index 100% rename from OmiseSDKTests/Fixtures/objects/token_object.json rename to OmiseSDKTests/SampleData/token.json diff --git a/OmiseSDKTests/Source and Token JSON Codable Tests/CardPaymentPayloadTests.swift b/OmiseSDKTests/Source and Token JSON Codable Tests/CardPaymentPayloadTests.swift new file mode 100644 index 00000000..a95918f1 --- /dev/null +++ b/OmiseSDKTests/Source and Token JSON Codable Tests/CardPaymentPayloadTests.swift @@ -0,0 +1,29 @@ +import Foundation +import XCTest +@testable import OmiseSDK + +class CardPaymentPayloadTests: XCTestCase { + func testJSONEncodingDecoding() throws { + let sourcePayload = CardPaymentPayload( + name: "John Doe", + number: "4242424242424242", + expirationMonth: 12, + expirationYear: 2020, + securityCode: "123", + countryCode: "gb", + city: "Bangkok", + state: "Bangkok Metropolis", + street1: "Sukhumvit", + street2: "MBK", + postalCode: "10240", + phoneNumber: "0123456789" + ) + + let samplePayload: CardPaymentPayload = try sampleFromJSONBy(.card) + XCTAssertEqual(samplePayload, sourcePayload) + let jsonString = try encodeToJson(samplePayload) + + let decoded: CardPaymentPayload = try parse(jsonString: jsonString) + XCTAssertEqual(samplePayload, decoded) + } +} diff --git a/OmiseSDKTests/SourceFlowTests.swift b/OmiseSDKTests/Source and Token JSON Codable Tests/SourceFlowTests.swift similarity index 100% rename from OmiseSDKTests/SourceFlowTests.swift rename to OmiseSDKTests/Source and Token JSON Codable Tests/SourceFlowTests.swift diff --git a/OmiseSDKTests/Source and Token JSON Codable Tests/SourcePaymentPayloadTest.swift b/OmiseSDKTests/Source and Token JSON Codable Tests/SourcePaymentPayloadTest.swift new file mode 100644 index 00000000..4c04938c --- /dev/null +++ b/OmiseSDKTests/Source and Token JSON Codable Tests/SourcePaymentPayloadTest.swift @@ -0,0 +1,15 @@ +import Foundation +import XCTest +@testable import OmiseSDK + +class SourcePaymentPayloadTest: XCTestCase { + func testJSONEncoding() throws { + let sourcePayload = SourcePaymentPayload(amount: 1, currency: "THB", details: .other(.alipay)) + + let jsonString = try encodeToJson(sourcePayload) + let decoded: SourcePaymentPayload = try parse(jsonString: jsonString) + XCTAssertEqual(sourcePayload, decoded) + let expectedJsonString = "{\"amount\":1,\"currency\":\"THB\",\"platform_type\":\"IOS\",\"type\":\"alipay\"}" + XCTAssertEqual(jsonString, expectedJsonString) + } +} diff --git a/OmiseSDKTests/SourceTests.swift b/OmiseSDKTests/Source and Token JSON Codable Tests/SourceTests.swift similarity index 87% rename from OmiseSDKTests/SourceTests.swift rename to OmiseSDKTests/Source and Token JSON Codable Tests/SourceTests.swift index 050ebc05..573115e6 100644 --- a/OmiseSDKTests/SourceTests.swift +++ b/OmiseSDKTests/Source and Token JSON Codable Tests/SourceTests.swift @@ -6,9 +6,6 @@ import XCTest // swiftlint:disable:next type_body_length class SourceTests: XCTestCase { - let sampleData = SampleData() - var jsonDecoder = JSONDecoder() - /// Test Source.Payload's Codable protocol func validatePayloadCodable(_ payload: Source.Payload) throws { let encodedPayload = try JSONEncoder().encode(payload) @@ -18,12 +15,12 @@ class SourceTests: XCTestCase { print("") } - let decodedPayload = try parsePayload(jsonString: encodedPayloadJson) + let decodedPayload: Source.Payload = try parse(jsonString: encodedPayloadJson) XCTAssertEqual(payload, decodedPayload) } func testAlipayCN() throws { - let source = try sourceFromSampleJSONFileBy(type: .alipayCN) + let source: Source = try sampleFromJSONBy(.source(type: .alipayCN)) XCTAssertEqual(source.id, "src_test_5owftw9kjhjisssm0n2") XCTAssertFalse(source.isLiveMode) XCTAssertEqual(source.paymentInformation, .other(.alipayCN)) @@ -33,7 +30,7 @@ class SourceTests: XCTestCase { try validatePayloadCodable(source.paymentInformation) } func testDecodeAlipayHK() throws { - let source = try sourceFromSampleJSONFileBy(type: .alipayHK) + let source: Source = try sampleFromJSONBy(.source(type: .alipayHK)) XCTAssertEqual(source.id, "src_test_5oxesy9ovpgawobhf6n") XCTAssertFalse(source.isLiveMode) XCTAssertEqual(source.paymentInformation, .other(.alipayHK)) @@ -43,7 +40,7 @@ class SourceTests: XCTestCase { try validatePayloadCodable(source.paymentInformation) } func testDecodeAlipay() throws { - let source = try sourceFromSampleJSONFileBy(type: .alipay) + let source: Source = try sampleFromJSONBy(.source(type: .alipay)) XCTAssertEqual(source.id, "src_test_5avnfnqxzzj2yu7a34e") XCTAssertFalse(source.isLiveMode) XCTAssertEqual(source.paymentInformation, .other(.alipay)) @@ -53,7 +50,7 @@ class SourceTests: XCTestCase { try validatePayloadCodable(source.paymentInformation) } func testDecodeBoost() throws { - let source = try sourceFromSampleJSONFileBy(type: .boost) + let source: Source = try sampleFromJSONBy(.source(type: .boost)) XCTAssertEqual(source.id, "src_5pqcjr6tu4xvqut5nh5") XCTAssertTrue(source.isLiveMode) XCTAssertEqual(source.paymentInformation, .other(.boost)) @@ -63,7 +60,7 @@ class SourceTests: XCTestCase { try validatePayloadCodable(source.paymentInformation) } func testDecodeDana() throws { - let source = try sourceFromSampleJSONFileBy(type: .dana) + let source: Source = try sampleFromJSONBy(.source(type: .dana)) XCTAssertEqual(source.id, "src_test_5oxew5l8jxhss03ybfb") XCTAssertFalse(source.isLiveMode) XCTAssertEqual(source.paymentInformation, .other(.dana)) @@ -73,7 +70,7 @@ class SourceTests: XCTestCase { try validatePayloadCodable(source.paymentInformation) } func testDecodeDuitNowQR() throws { - let source = try sourceFromSampleJSONFileBy(type: .duitNowQR) + let source: Source = try sampleFromJSONBy(.source(type: .duitNowQR)) XCTAssertEqual(source.id, "src_5pqcjr6tu4xvqut5nh5") XCTAssertTrue(source.isLiveMode) XCTAssertEqual(source.paymentInformation, .other(.duitNowQR)) @@ -83,7 +80,7 @@ class SourceTests: XCTestCase { try validatePayloadCodable(source.paymentInformation) } func testDecodeGcash() throws { - let source = try sourceFromSampleJSONFileBy(type: .gcash) + let source: Source = try sampleFromJSONBy(.source(type: .gcash)) XCTAssertEqual(source.id, "src_test_5oxesgzoekdn5nukcdf") XCTAssertFalse(source.isLiveMode) XCTAssertEqual(source.paymentInformation, .other(.gcash)) @@ -93,7 +90,7 @@ class SourceTests: XCTestCase { try validatePayloadCodable(source.paymentInformation) } func testDecodeGrabPay() throws { - let source = try sourceFromSampleJSONFileBy(type: .grabPay) + let source: Source = try sampleFromJSONBy(.source(type: .grabPay)) XCTAssertEqual(source.id, "src_test_5pqcjr6tu4xvqut5nh5") XCTAssertFalse(source.isLiveMode) XCTAssertEqual(source.paymentInformation, .other(.grabPay)) @@ -103,7 +100,7 @@ class SourceTests: XCTestCase { try validatePayloadCodable(source.paymentInformation) } func testDecodeKakaoPay() throws { - let source = try sourceFromSampleJSONFileBy(type: .kakaoPay) + let source: Source = try sampleFromJSONBy(.source(type: .kakaoPay)) XCTAssertEqual(source.id, "src_test_5oxetau2owhu0rbzg7y") XCTAssertFalse(source.isLiveMode) XCTAssertEqual(source.paymentInformation, .other(.kakaoPay)) @@ -113,7 +110,7 @@ class SourceTests: XCTestCase { try validatePayloadCodable(source.paymentInformation) } func testDecodeMaybankQRPay() throws { - let source = try sourceFromSampleJSONFileBy(type: .maybankQRPay) + let source: Source = try sampleFromJSONBy(.source(type: .maybankQRPay)) XCTAssertEqual(source.id, "src_5pqcjr6tu4xvqut5nh5") XCTAssertTrue(source.isLiveMode) XCTAssertEqual(source.paymentInformation, .other(.maybankQRPay)) @@ -123,7 +120,7 @@ class SourceTests: XCTestCase { try validatePayloadCodable(source.paymentInformation) } func testDecodePayNow() throws { - let source = try sourceFromSampleJSONFileBy(type: .payNow) + let source: Source = try sampleFromJSONBy(.source(type: .payNow)) XCTAssertEqual(source.id, "src_test_5iso4taobco8j5jehx5") XCTAssertFalse(source.isLiveMode) XCTAssertEqual(source.paymentInformation, .other(.payNow)) @@ -133,7 +130,7 @@ class SourceTests: XCTestCase { try validatePayloadCodable(source.paymentInformation) } func testDecodePayPay() throws { - let source = try sourceFromSampleJSONFileBy(type: .payPay) + let source: Source = try sampleFromJSONBy(.source(type: .payPay)) XCTAssertEqual(source.id, "src_5pqcjr6tu4xvqut5nh5") XCTAssertTrue(source.isLiveMode) XCTAssertEqual(source.paymentInformation, .other(.payPay)) @@ -143,7 +140,7 @@ class SourceTests: XCTestCase { try validatePayloadCodable(source.paymentInformation) } func testDecodePromptPay() throws { - let source = try sourceFromSampleJSONFileBy(type: .promptPay) + let source: Source = try sampleFromJSONBy(.source(type: .promptPay)) XCTAssertEqual(source.id, "src_test_5jb2cjjyjea25nps3ya") XCTAssertFalse(source.isLiveMode) XCTAssertEqual(source.paymentInformation, .other(.promptPay)) @@ -153,7 +150,7 @@ class SourceTests: XCTestCase { try validatePayloadCodable(source.paymentInformation) } func testDecodeRabbitLinepay() throws { - let source = try sourceFromSampleJSONFileBy(type: .rabbitLinepay) + let source: Source = try sampleFromJSONBy(.source(type: .rabbitLinepay)) XCTAssertEqual(source.id, "src_test_5owftw9kjhjisssm0n2") XCTAssertFalse(source.isLiveMode) XCTAssertEqual(source.paymentInformation, .other(.rabbitLinepay)) @@ -163,7 +160,7 @@ class SourceTests: XCTestCase { try validatePayloadCodable(source.paymentInformation) } func testDecodeShopeePayJumpApp() throws { - let source = try sourceFromSampleJSONFileBy(type: .shopeePayJumpApp) + let source: Source = try sampleFromJSONBy(.source(type: .shopeePayJumpApp)) XCTAssertEqual(source.id, "src_5pqcjr6tu4xvqut5nh5") XCTAssertTrue(source.isLiveMode) XCTAssertEqual(source.paymentInformation, .other(.shopeePayJumpApp)) @@ -173,7 +170,7 @@ class SourceTests: XCTestCase { try validatePayloadCodable(source.paymentInformation) } func testDecodeShopeePay() throws { - let source = try sourceFromSampleJSONFileBy(type: .shopeePay) + let source: Source = try sampleFromJSONBy(.source(type: .shopeePay)) XCTAssertEqual(source.id, "src_5pqcjr6tu4xvqut5nh5") XCTAssertTrue(source.isLiveMode) XCTAssertEqual(source.paymentInformation, .other(.shopeePay)) @@ -183,7 +180,7 @@ class SourceTests: XCTestCase { try validatePayloadCodable(source.paymentInformation) } func testDecodeTouchNGo() throws { - let source = try sourceFromSampleJSONFileBy(type: .touchNGo) + let source: Source = try sampleFromJSONBy(.source(type: .touchNGo)) XCTAssertEqual(source.id, "src_test_5oxet335rx3xzdyn06g") XCTAssertFalse(source.isLiveMode) XCTAssertEqual(source.paymentInformation, .other(.touchNGo)) @@ -194,7 +191,7 @@ class SourceTests: XCTestCase { } func testDecodeTrueMoneyJumpApp() throws { - let source = try sourceFromSampleJSONFileBy(type: .trueMoneyJumpApp) + let source: Source = try sampleFromJSONBy(.source(type: .trueMoneyJumpApp)) XCTAssertEqual(source.id, "src_5yqlbf5w206mcfybj8v") XCTAssertTrue(source.isLiveMode) XCTAssertEqual(source.paymentInformation, .other(.trueMoneyJumpApp)) @@ -205,7 +202,7 @@ class SourceTests: XCTestCase { } func testDecodeBarcodeAlipay() throws { - let source = try sourceFromSampleJSONFileBy(type: .barcodeAlipay) + let source: Source = try sampleFromJSONBy(.source(type: .barcodeAlipay)) let payload = Source.Payload.BarcodeAlipay( barcode: "1234567890123456", storeID: "1", @@ -222,7 +219,7 @@ class SourceTests: XCTestCase { } func testDecodeBillPaymentTescoLotus() throws { - let source = try sourceFromSampleJSONFileBy(type: .billPaymentTescoLotus) + let source: Source = try sampleFromJSONBy(.source(type: .billPaymentTescoLotus)) XCTAssertEqual(source.id, "src_test_59trf2nxk43b5nml8z0") XCTAssertFalse(source.isLiveMode) XCTAssertEqual(source.paymentInformation, .other(.billPaymentTescoLotus)) @@ -277,7 +274,7 @@ class SourceTests: XCTestCase { ] ) - let source = try sourceFromSampleJSONFileBy(type: .atome) + let source: Source = try sampleFromJSONBy(.source(type: .atome)) XCTAssertEqual(source.id, "src_5yqiaqtbbog2pxjdg6b") XCTAssertTrue(source.isLiveMode) XCTAssertEqual(source.paymentInformation, .atome(payload)) @@ -288,7 +285,7 @@ class SourceTests: XCTestCase { } func testDecodeDuitNowOBW() throws { - let source = try sourceFromSampleJSONFileBy(type: .duitNowOBW) + let source: Source = try sampleFromJSONBy(.source(type: .duitNowOBW)) let payload = Source.Payload.DuitNowOBW(bank: .affin) XCTAssertEqual(source.id, "src_5pqcjr6tu4xvqut5nh5") XCTAssertTrue(source.isLiveMode) @@ -301,7 +298,7 @@ class SourceTests: XCTestCase { func testDecodeInstallmentBay() throws { let sourceType: SourceType = .installmentBAY - let source = try sourceFromSampleJSONFileBy(type: sourceType) + let source: Source = try sampleFromJSONBy(.source(type: sourceType)) let payload = Source.Payload.Installment( installmentTerm: 6, zeroInterestInstallments: false, @@ -318,7 +315,7 @@ class SourceTests: XCTestCase { func testDecodeInstallmentBBL() throws { let sourceType: SourceType = .installmentBBL - let source = try sourceFromSampleJSONFileBy(type: sourceType) + let source: Source = try sampleFromJSONBy(.source(type: sourceType)) let payload = Source.Payload.Installment( installmentTerm: 6, zeroInterestInstallments: false, @@ -335,7 +332,7 @@ class SourceTests: XCTestCase { func testDecodeInstallmentFirstChoice() throws { let sourceType: SourceType = .installmentFirstChoice - let source = try sourceFromSampleJSONFileBy(type: sourceType) + let source: Source = try sampleFromJSONBy(.source(type: sourceType)) let payload = Source.Payload.Installment( installmentTerm: 6, zeroInterestInstallments: false, @@ -353,7 +350,7 @@ class SourceTests: XCTestCase { func testDecodeInstallmentKBank() throws { let sourceType: SourceType = .installmentKBank - let source = try sourceFromSampleJSONFileBy(type: sourceType) + let source: Source = try sampleFromJSONBy(.source(type: sourceType)) let payload = Source.Payload.Installment( installmentTerm: 6, zeroInterestInstallments: false, @@ -370,7 +367,7 @@ class SourceTests: XCTestCase { func testDecodeInstallmentKTC() throws { let sourceType: SourceType = .installmentKTC - let source = try sourceFromSampleJSONFileBy(type: sourceType) + let source: Source = try sampleFromJSONBy(.source(type: sourceType)) let payload = Source.Payload.Installment( installmentTerm: 6, zeroInterestInstallments: false, @@ -387,7 +384,7 @@ class SourceTests: XCTestCase { func testDecodeInstallmentMBB() throws { let sourceType: SourceType = .installmentMBB - let source = try sourceFromSampleJSONFileBy(type: sourceType) + let source: Source = try sampleFromJSONBy(.source(type: sourceType)) let payload = Source.Payload.Installment( installmentTerm: 6, zeroInterestInstallments: false, @@ -404,7 +401,7 @@ class SourceTests: XCTestCase { func testDecodeInstallmentTTB() throws { let sourceType: SourceType = .installmentTTB - let source = try sourceFromSampleJSONFileBy(type: sourceType) + let source: Source = try sampleFromJSONBy(.source(type: sourceType)) let payload = Source.Payload.Installment( installmentTerm: 6, zeroInterestInstallments: false, @@ -421,7 +418,7 @@ class SourceTests: XCTestCase { func testDecodeInstallmentUOB() throws { let sourceType: SourceType = .installmentUOB - let source = try sourceFromSampleJSONFileBy(type: sourceType) + let source: Source = try sampleFromJSONBy(.source(type: sourceType)) let payload = Source.Payload.Installment( installmentTerm: 6, zeroInterestInstallments: false, @@ -437,7 +434,7 @@ class SourceTests: XCTestCase { } func testDecodeTrueMoneyWallet() throws { - let source = try sourceFromSampleJSONFileBy(type: .trueMoneyWallet) + let source: Source = try sampleFromJSONBy(.source(type: .trueMoneyWallet)) let payload = Source.Payload.TrueMoneyWallet(phoneNumber: "0123456789") XCTAssertEqual(source.id, "src_test_5jhmesi7s4at1qctloy") XCTAssertFalse(source.isLiveMode) @@ -450,7 +447,7 @@ class SourceTests: XCTestCase { func testDecodeInternetBankingBay() throws { let sourceType: SourceType = .internetBankingBAY - let source = try sourceFromSampleJSONFileBy(type: sourceType) + let source: Source = try sampleFromJSONBy(.source(type: sourceType)) XCTAssertEqual(source.id, "src_test_5cs0sm8u8h8nqo5hwcs") XCTAssertFalse(source.isLiveMode) XCTAssertEqual(source.paymentInformation, .other(sourceType)) @@ -462,7 +459,7 @@ class SourceTests: XCTestCase { func testDecodeInternetBankingBBL() throws { let sourceType: SourceType = .internetBankingBBL - let source = try sourceFromSampleJSONFileBy(type: sourceType) + let source: Source = try sampleFromJSONBy(.source(type: sourceType)) XCTAssertEqual(source.id, "src_test_5cs0sfy7phu06yhyz5c") XCTAssertFalse(source.isLiveMode) XCTAssertEqual(source.paymentInformation, .other(sourceType)) @@ -474,7 +471,7 @@ class SourceTests: XCTestCase { func testDecodeMobileBankingBAY() throws { let sourceType: SourceType = .mobileBankingBAY - let source = try sourceFromSampleJSONFileBy(type: sourceType) + let source: Source = try sampleFromJSONBy(.source(type: sourceType)) XCTAssertEqual(source.id, "src_test_5cs0sm8u8h8nqo5zasd") XCTAssertFalse(source.isLiveMode) XCTAssertEqual(source.paymentInformation, .other(sourceType)) @@ -486,7 +483,7 @@ class SourceTests: XCTestCase { func testDecodeMobileBankingBBL() throws { let sourceType: SourceType = .mobileBankingBBL - let source = try sourceFromSampleJSONFileBy(type: sourceType) + let source: Source = try sampleFromJSONBy(.source(type: sourceType)) XCTAssertEqual(source.id, "src_test_5cs0sm8u8h8nqo5zasd") XCTAssertFalse(source.isLiveMode) XCTAssertEqual(source.paymentInformation, .other(sourceType)) @@ -498,7 +495,7 @@ class SourceTests: XCTestCase { func testDecodeMobileBankingKBank() throws { let sourceType: SourceType = .mobileBankingKBank - let source = try sourceFromSampleJSONFileBy(type: sourceType) + let source: Source = try sampleFromJSONBy(.source(type: sourceType)) XCTAssertEqual(source.id, "src_test_5cs0sm8u8h8nqo5zasd") XCTAssertFalse(source.isLiveMode) XCTAssertEqual(source.paymentInformation, .other(sourceType)) @@ -509,7 +506,7 @@ class SourceTests: XCTestCase { } func testDecodeMobileBankingTKB() throws { let sourceType: SourceType = .mobileBankingKTB - let source = try sourceFromSampleJSONFileBy(type: sourceType) + let source: Source = try sampleFromJSONBy(.source(type: sourceType)) XCTAssertEqual(source.id, "src_test_5cs0sm8u8h8nqo5zasd") XCTAssertFalse(source.isLiveMode) XCTAssertEqual(source.paymentInformation, .other(sourceType)) @@ -521,7 +518,7 @@ class SourceTests: XCTestCase { func testDecodeMobileBankingSCB() throws { let sourceType: SourceType = .mobileBankingSCB - let source = try sourceFromSampleJSONFileBy(type: sourceType) + let source: Source = try sampleFromJSONBy(.source(type: sourceType)) XCTAssertEqual(source.id, "src_test_5cs0sm8u8h8nqo5zasd") XCTAssertFalse(source.isLiveMode) XCTAssertEqual(source.paymentInformation, .other(sourceType)) @@ -533,7 +530,7 @@ class SourceTests: XCTestCase { func testDecodeEContext() throws { let sourceType: SourceType = .eContext - let source = try sourceFromSampleJSONFileBy(type: sourceType) + let source: Source = try sampleFromJSONBy(.source(type: sourceType)) let payload = Source.Payload.EContext( name: "ヤマダタロウ", email: "test@opn.com", @@ -550,7 +547,7 @@ class SourceTests: XCTestCase { func testDecodeFPX() throws { let sourceType: SourceType = .fpx - let source = try sourceFromSampleJSONFileBy(type: sourceType) + let source: Source = try sampleFromJSONBy(.source(type: sourceType)) let payload = Source.Payload.FPX( bank: .uob, email: "support@omise.co" diff --git a/OmiseSDKTests/SourcePaymentPayloadTest.swift b/OmiseSDKTests/SourcePaymentPayloadTest.swift deleted file mode 100644 index 16f324a0..00000000 --- a/OmiseSDKTests/SourcePaymentPayloadTest.swift +++ /dev/null @@ -1,17 +0,0 @@ -import Foundation -import XCTest -@testable import OmiseSDK - -class SourcePaymentPayloadTest: XCTestCase { - func testJSONEncoding() throws { - let sourcePayload = SourcePaymentPayload(amount: 1, currency: "THB", details: .other(.alipay)) - - let encoder = JSONEncoder() - encoder.outputFormatting = [.sortedKeys] - - let data = try encoder.encode(sourcePayload) - let result = String(data: data, encoding: .utf8) - let expectedResult = "{\"amount\":1,\"currency\":\"THB\",\"platform_type\":\"IOS\",\"type\":\"alipay\"}" - XCTAssertEqual(result, expectedResult) - } -} diff --git a/OmiseSDKTests/SourceTests+Helpers.swift b/OmiseSDKTests/SourceTests+Helpers.swift deleted file mode 100644 index ecb09bfe..00000000 --- a/OmiseSDKTests/SourceTests+Helpers.swift +++ /dev/null @@ -1,28 +0,0 @@ -import Foundation -import XCTest -@testable import OmiseSDK - -// MARK: Encode/Decode sample data from JSON mock-ups -extension SourceTests { - /// Load JSON sample data from resources by given SourceType - func sourceFromSampleJSONFileBy(type: SourceType) throws -> Source { - do { - let sourceData = try sampleData.jsonData(for: .source(sourceType: type)) - let source = try jsonDecoder.decode(Source.self, from: sourceData) - return source - } catch { - XCTFail("Cannot decode the source \(error)") - throw error - } - } - - /// Decode JSON string into Source.Payload - func parsePayload(jsonString: String) throws -> Source.Payload { - guard let data = jsonString.data(using: .utf8) else { - struct JsonToDataCastError: Error {} - throw JsonToDataCastError() - } - - return try jsonDecoder.decode(Source.Payload.self, from: data) - } -} diff --git a/dev.xcodeproj/project.pbxproj b/dev.xcodeproj/project.pbxproj index 3fa10c35..714a6d04 100644 --- a/dev.xcodeproj/project.pbxproj +++ b/dev.xcodeproj/project.pbxproj @@ -11,7 +11,6 @@ 14ACEF831D02D641001C5319 /* CardExpiryDatePicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14ACEF821D02D641001C5319 /* CardExpiryDatePicker.swift */; }; 2225B3541D0FDD63003EB396 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2225B3531D0FDD63003EB396 /* Assets.xcassets */; }; 22445FFC1CF41DD300801D0F /* Globals.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22445FFB1CF41DD300801D0F /* Globals.swift */; }; - 224460041CF43A1200801D0F /* SDKTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 225931561CE4745200841B86 /* SDKTestCase.swift */; settings = {COMPILER_FLAGS = "-Wnodeprecated-declarations"; }; }; 229E14581D0EBAB5000511DE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 229E14541D0EBAB5000511DE /* AppDelegate.swift */; }; 229E145A1D0EBAB5000511DE /* ProductDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 229E14561D0EBAB5000511DE /* ProductDetailViewController.swift */; }; 22E0DBD71D0EBE2E00472C74 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 22E0DBD61D0EBE2E00472C74 /* Assets.xcassets */; }; @@ -76,7 +75,6 @@ 756C8F262A40698600D53059 /* TextFieldView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 756C8F252A40698600D53059 /* TextFieldView.swift */; }; 757B0A742AD71E3100DEAE8F /* OmiseUnitTestKit in Frameworks */ = {isa = PBXBuildFile; productRef = 757B0A732AD71E3100DEAE8F /* OmiseUnitTestKit */; }; 757B0A752AD71E3100DEAE8F /* OmiseUnitTestKit in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 757B0A732AD71E3100DEAE8F /* OmiseUnitTestKit */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; - 758244092ACE988700781B3B /* PaymentInformationTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A429E7A2109A3AE007C230F /* PaymentInformationTestCase.swift */; }; 759856242A286C880087B605 /* UIScrollView+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 759856232A286C880087B605 /* UIScrollView+Helpers.swift */; }; 75B420502B7611710036134D /* Capability.PaymentMethod.Bank.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B4204F2B7611710036134D /* Capability.PaymentMethod.Bank.swift */; }; 75B420572B765BC40036134D /* Token.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420562B765BC40036134D /* Token.swift */; }; @@ -94,7 +92,6 @@ 75B420822B77FAA50036134D /* SourcePaymentPayload.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420812B77FAA50036134D /* SourcePaymentPayload.swift */; }; 75B420852B77FC850036134D /* Source.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420842B77FC850036134D /* Source.swift */; }; 75B420872B77FDB10036134D /* Source.Flow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420862B77FDB10036134D /* Source.Flow.swift */; }; - 75B420912B78C2450036134D /* CardPaymenTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420902B78C2450036134D /* CardPaymenTests.swift */; }; 75B420942B78DE350036134D /* Capability.PaymentMethod.Provider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420932B78DE350036134D /* Capability.PaymentMethod.Provider.swift */; }; 75B4209A2B78E56D0036134D /* CapabilityOld.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420962B78E56D0036134D /* CapabilityOld.swift */; }; 75B4209B2B78E56D0036134D /* RequestTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B420972B78E56D0036134D /* RequestTask.swift */; }; @@ -117,12 +114,11 @@ 75CFC4F12B753B0F00422A8F /* Capability.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CFC4F02B753B0F00422A8F /* Capability.swift */; }; 75CFC4F32B753BCD00422A8F /* Capability.PaymentMethod.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CFC4F22B753BCD00422A8F /* Capability.PaymentMethod.swift */; }; 75CFC4F52B753C3C00422A8F /* SourceType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CFC4F42B753C3C00422A8F /* SourceType.swift */; }; - 75CFC4F72B753D6300422A8F /* CapabilityTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CFC4F62B753D6300422A8F /* CapabilityTests.swift */; }; 75DAD8902A0BB8D80098AF96 /* LocalConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75DAD88F2A0BB8D80098AF96 /* LocalConfig.swift */; }; 75E0EB712B7A904100E3198A /* SourceFlowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75E0EB702B7A904100E3198A /* SourceFlowTests.swift */; }; 75E0EB722B7A962600E3198A /* SourcePaymentPayloadTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B4208D2B78C2120036134D /* SourcePaymentPayloadTest.swift */; }; - 75E0EB752B7B280300E3198A /* SourceTests+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75E0EB742B7B280300E3198A /* SourceTests+Helpers.swift */; }; 75E0EB7C2B7B410600E3198A /* Client+Network.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75E0EB7B2B7B410600E3198A /* Client+Network.swift */; }; + 75E0EB7E2B7B5EE400E3198A /* CardPaymentPayloadTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75E0EB7D2B7B5EE400E3198A /* CardPaymentPayloadTests.swift */; }; 75F2A0182A0BD0D40038FA54 /* Config.local.plist in Resources */ = {isa = PBXBuildFile; fileRef = 75DAD8922A0BC9540098AF96 /* Config.local.plist */; }; 75F2A09A2A13B0B10038FA54 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 75F2A0992A13B0B10038FA54 /* Preview Assets.xcassets */; }; 75F2A0A62A13B70F0038FA54 /* OmiseTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9864062F1CFEA7E4004BCF51 /* OmiseTextField.swift */; }; @@ -138,16 +134,11 @@ 75F8C0B72B1F78E300AE78D9 /* PaymentChooserViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F8C0B62B1F78E300AE78D9 /* PaymentChooserViewControllerTests.swift */; }; 8A0A67E72137EE49006356B7 /* AdaptableStaticTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A0A67E62137EE49006356B7 /* AdaptableStaticTableViewController.swift */; }; 8A0A67E821383614006356B7 /* PaymentChooserViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AE23AAD20F8CA8800BC9D8F /* PaymentChooserViewController.swift */; }; - 8A14C20B220AE241003F5B20 /* CapabilityOperationFixtureTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A14C20A220AE241003F5B20 /* CapabilityOperationFixtureTests.swift */; }; 8A188BB01D951E3C00FFF467 /* AuthorizingPaymentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A188BAF1D951E3C00FFF467 /* AuthorizingPaymentViewController.swift */; }; 8A2C451920ECC7A60033E2EB /* OmiseSDK.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 225931181CE3210700841B86 /* OmiseSDK.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 8A30FB7D214929C900DC09DC /* PaymentCreatorController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A30FB7C214929C900DC09DC /* PaymentCreatorController.swift */; }; - 8A37E43620B584D300E2DA18 /* ModelTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A37E43520B584D300E2DA18 /* ModelTestCase.swift */; }; - 8A3C10562159F7FC00BEFD8A /* InvalidCardAPIErrorParsingTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A3C10552159F7FC00BEFD8A /* InvalidCardAPIErrorParsingTestCase.swift */; }; - 8A3C10582159FCE900BEFD8A /* BadRequestAPIErrorParsingTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A3C10572159FCE900BEFD8A /* BadRequestAPIErrorParsingTestCase.swift */; }; 8A40DA29216B441E00749F45 /* PaymentSettingTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A7A9EBC2166160300F12D86 /* PaymentSettingTableViewController.swift */; }; 8A40DA2B216B53E900749F45 /* Tools.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A40DA2A216B53E900749F45 /* Tools.swift */; }; - 8A43454720DBAE76005C5C94 /* PANModelTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A43454620DBAE76005C5C94 /* PANModelTestCase.swift */; }; 8A5D59811D5317DD005D3346 /* OmiseSDK.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8A5D59831D5317DD005D3346 /* OmiseSDK.storyboard */; }; 8A72CD5E2162358400F14F76 /* PaymentOptionTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A72CD5D2162358400F14F76 /* PaymentOptionTableViewCell.swift */; }; 8A7567652178956800C684C9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8A7567642178956800C684C9 /* Main.storyboard */; }; @@ -237,7 +228,6 @@ 22445FFB1CF41DD300801D0F /* Globals.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Globals.swift; sourceTree = ""; }; 225931181CE3210700841B86 /* OmiseSDK.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OmiseSDK.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 2259311D1CE3210700841B86 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 225931561CE4745200841B86 /* SDKTestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SDKTestCase.swift; sourceTree = ""; }; 226E16101D2268B400219652 /* QuickStart.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = QuickStart.playground; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; 229E14541D0EBAB5000511DE /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 229E14561D0EBAB5000511DE /* ProductDetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProductDetailViewController.swift; sourceTree = ""; }; @@ -309,7 +299,6 @@ 75B420842B77FC850036134D /* Source.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Source.swift; sourceTree = ""; }; 75B420862B77FDB10036134D /* Source.Flow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Source.Flow.swift; sourceTree = ""; }; 75B4208D2B78C2120036134D /* SourcePaymentPayloadTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourcePaymentPayloadTest.swift; sourceTree = ""; }; - 75B420902B78C2450036134D /* CardPaymenTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardPaymenTests.swift; sourceTree = ""; }; 75B420932B78DE350036134D /* Capability.PaymentMethod.Provider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Capability.PaymentMethod.Provider.swift; sourceTree = ""; }; 75B420962B78E56D0036134D /* CapabilityOld.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CapabilityOld.swift; sourceTree = ""; }; 75B420972B78E56D0036134D /* RequestTask.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RequestTask.swift; sourceTree = ""; }; @@ -332,12 +321,11 @@ 75CFC4F02B753B0F00422A8F /* Capability.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Capability.swift; sourceTree = ""; }; 75CFC4F22B753BCD00422A8F /* Capability.PaymentMethod.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Capability.PaymentMethod.swift; sourceTree = ""; }; 75CFC4F42B753C3C00422A8F /* SourceType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceType.swift; sourceTree = ""; }; - 75CFC4F62B753D6300422A8F /* CapabilityTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CapabilityTests.swift; sourceTree = ""; }; 75DAD88F2A0BB8D80098AF96 /* LocalConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalConfig.swift; sourceTree = ""; }; 75DAD8922A0BC9540098AF96 /* Config.local.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Config.local.plist; sourceTree = ""; }; 75E0EB702B7A904100E3198A /* SourceFlowTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceFlowTests.swift; sourceTree = ""; }; - 75E0EB742B7B280300E3198A /* SourceTests+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SourceTests+Helpers.swift"; sourceTree = ""; }; 75E0EB7B2B7B410600E3198A /* Client+Network.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Client+Network.swift"; sourceTree = ""; }; + 75E0EB7D2B7B5EE400E3198A /* CardPaymentPayloadTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardPaymentPayloadTests.swift; sourceTree = ""; }; 75F2A0902A13B0B00038FA54 /* OmiseSDKUITests.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OmiseSDKUITests.app; sourceTree = BUILT_PRODUCTS_DIR; }; 75F2A0992A13B0B10038FA54 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 75F2A0A42A13B1470038FA54 /* AtomeFormViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtomeFormViewController.swift; sourceTree = ""; }; @@ -513,7 +501,6 @@ isa = PBXGroup; children = ( F615CBFB2615696100E1A2D9 /* Views */, - 225931561CE4745200841B86 /* SDKTestCase.swift */, 7509D4DE2A1AA1060050AB38 /* Atome */, 75CFC4D52B73EFB600422A8F /* Client */, 8A3C10572159FCE900BEFD8A /* BadRequestAPIErrorParsingTestCase.swift */, @@ -686,16 +673,6 @@ path = Source; sourceTree = ""; }; - 75B4208F2B78C22A0036134D /* Draft Tests */ = { - isa = PBXGroup; - children = ( - 75CFC4D32B73B21100422A8F /* ClientTests.swift */, - 75CFC4F62B753D6300422A8F /* CapabilityTests.swift */, - 75B420902B78C2450036134D /* CardPaymenTests.swift */, - ); - path = "Draft Tests"; - sourceTree = ""; - }; 75B420952B78E56D0036134D /* Done */ = { isa = PBXGroup; children = ( @@ -816,6 +793,17 @@ path = Helpers; sourceTree = ""; }; + 75E0EB7F2B7B6D4C00E3198A /* Source and Token JSON Codable Tests */ = { + isa = PBXGroup; + children = ( + 750708DF2B7909BB00A48DD0 /* SourceTests.swift */, + 75E0EB702B7A904100E3198A /* SourceFlowTests.swift */, + 75B4208D2B78C2120036134D /* SourcePaymentPayloadTest.swift */, + 75E0EB7D2B7B5EE400E3198A /* CardPaymentPayloadTests.swift */, + ); + path = "Source and Token JSON Codable Tests"; + sourceTree = ""; + }; 75F2A01A2A0BD1CD0038FA54 /* Resources */ = { isa = PBXGroup; children = ( @@ -960,11 +948,8 @@ 750708E62B790CF200A48DD0 /* SampleData */, 750708E12B790B2400A48DD0 /* Helpers */, 750708E82B79125200A48DD0 /* Old tests */, - 75B4208F2B78C22A0036134D /* Draft Tests */, - 750708DF2B7909BB00A48DD0 /* SourceTests.swift */, - 75E0EB742B7B280300E3198A /* SourceTests+Helpers.swift */, - 75E0EB702B7A904100E3198A /* SourceFlowTests.swift */, - 75B4208D2B78C2120036134D /* SourcePaymentPayloadTest.swift */, + 75E0EB7F2B7B6D4C00E3198A /* Source and Token JSON Codable Tests */, + 75CFC4D32B73B21100422A8F /* ClientTests.swift */, 750708F32B7A765500A48DD0 /* OmiseSDKTests.swift */, ); path = OmiseSDKTests; @@ -1359,30 +1344,21 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 8A14C20B220AE241003F5B20 /* CapabilityOperationFixtureTests.swift in Sources */, 7509D4E02A1AA1450050AB38 /* AtomeFormViewControllerTests.swift in Sources */, 7509D4E42A1C89F10050AB38 /* AtomeFormViewModelMockup.swift in Sources */, - 8A43454720DBAE76005C5C94 /* PANModelTestCase.swift in Sources */, 750708F42B7A765500A48DD0 /* OmiseSDKTests.swift in Sources */, - 224460041CF43A1200801D0F /* SDKTestCase.swift in Sources */, - 75E0EB752B7B280300E3198A /* SourceTests+Helpers.swift in Sources */, - 8A3C10582159FCE900BEFD8A /* BadRequestAPIErrorParsingTestCase.swift in Sources */, + 75E0EB7E2B7B5EE400E3198A /* CardPaymentPayloadTests.swift in Sources */, 75E0EB712B7A904100E3198A /* SourceFlowTests.swift in Sources */, - 75CFC4F72B753D6300422A8F /* CapabilityTests.swift in Sources */, F615CBF8261565D600E1A2D9 /* CardExpiryDatePickerTests.swift in Sources */, 75E0EB722B7A962600E3198A /* SourcePaymentPayloadTest.swift in Sources */, 753279382A31B40F008048AD /* CountryListViewModelMockup.swift in Sources */, 7509D4E72A1C8E3D0050AB38 /* AtomeFormViewModelTests.swift in Sources */, 7509D4E22A1C876B0050AB38 /* AtomeFormViewContextMockup.swift in Sources */, - 75B420912B78C2450036134D /* CardPaymenTests.swift in Sources */, - 8A3C10562159F7FC00BEFD8A /* InvalidCardAPIErrorParsingTestCase.swift in Sources */, 75F8C0B72B1F78E300AE78D9 /* PaymentChooserViewControllerTests.swift in Sources */, 750708E32B790B8300A48DD0 /* String+JSON.swift in Sources */, 750708E52B790BD600A48DD0 /* SampleData.swift in Sources */, - 758244092ACE988700781B3B /* PaymentInformationTestCase.swift in Sources */, 750708E02B7909BB00A48DD0 /* SourceTests.swift in Sources */, 75CFC4D42B73B21100422A8F /* ClientTests.swift in Sources */, - 8A37E43620B584D300E2DA18 /* ModelTestCase.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; From e59f34887fca575f3e6c383fd7c6bf4290cd5ead Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Tue, 13 Feb 2024 17:52:04 +0700 Subject: [PATCH 062/204] Capability tests added --- .../Capability.PaymentMethod.Provider.swift | 4 +- .../New/Models/Capability.PaymentMethod.swift | 11 ++++- .../objects => SampleData}/capability.json | 0 .../CapabilityTests.swift | 41 +++++++++++++++++++ dev.xcodeproj/project.pbxproj | 4 ++ 5 files changed, 57 insertions(+), 3 deletions(-) rename OmiseSDKTests/{Fixtures/objects => SampleData}/capability.json (100%) create mode 100644 OmiseSDKTests/Source and Token JSON Codable Tests/CapabilityTests.swift diff --git a/OmiseSDK/Refactoring/New/Models/Capability.PaymentMethod.Provider.swift b/OmiseSDK/Refactoring/New/Models/Capability.PaymentMethod.Provider.swift index 003cd0c1..2b465309 100644 --- a/OmiseSDK/Refactoring/New/Models/Capability.PaymentMethod.Provider.swift +++ b/OmiseSDK/Refactoring/New/Models/Capability.PaymentMethod.Provider.swift @@ -3,12 +3,12 @@ import Foundation extension Capability.PaymentMethod { // TODO: Add Unit Tests to Provider // TODO: Add comments to Provider's properties - enum Provider: String, Codable, Hashable { + public enum Provider: String, Codable, Hashable { case alipayPlus = "Alipay_plus" case rms = "RMS" case unknown - init(from decoder: Decoder) throws { + public init(from decoder: Decoder) throws { self = try Self(rawValue: decoder.singleValueContainer().decode(RawValue.self)) ?? .unknown } } diff --git a/OmiseSDK/Refactoring/New/Models/Capability.PaymentMethod.swift b/OmiseSDK/Refactoring/New/Models/Capability.PaymentMethod.swift index ba0256d1..e79ae9ae 100644 --- a/OmiseSDK/Refactoring/New/Models/Capability.PaymentMethod.swift +++ b/OmiseSDK/Refactoring/New/Models/Capability.PaymentMethod.swift @@ -3,7 +3,7 @@ import Foundation extension Capability { // TODO: Add Unit Tests to PaymentMethod // TODO: Add comments to PaymentMethod's properties - public struct PaymentMethod: Codable { + public struct PaymentMethod: Codable, Equatable { public let name: String public let currencies: Set public let cardBrands: Set? @@ -11,6 +11,15 @@ extension Capability { public let banks: Set? private let provider: Provider? + public init(name: String, currencies: Set, cardBrands: Set?, installmentTerms: Set?, banks: Set?, provider: Provider?) { + self.name = name + self.currencies = currencies + self.cardBrands = cardBrands + self.installmentTerms = installmentTerms + self.banks = banks + self.provider = provider + } + private enum CodingKeys: String, CodingKey { case name case currencies diff --git a/OmiseSDKTests/Fixtures/objects/capability.json b/OmiseSDKTests/SampleData/capability.json similarity index 100% rename from OmiseSDKTests/Fixtures/objects/capability.json rename to OmiseSDKTests/SampleData/capability.json diff --git a/OmiseSDKTests/Source and Token JSON Codable Tests/CapabilityTests.swift b/OmiseSDKTests/Source and Token JSON Codable Tests/CapabilityTests.swift new file mode 100644 index 00000000..c659af8b --- /dev/null +++ b/OmiseSDKTests/Source and Token JSON Codable Tests/CapabilityTests.swift @@ -0,0 +1,41 @@ +import Foundation +import XCTest +@testable import OmiseSDK + +class CapabilityTests: XCTestCase { + func testJSONEncodingDecoding() throws { + let payments: [Capability.PaymentMethod] = [ + Capability.PaymentMethod( + name: "card", + currencies: ["THB", "JPY", "USD", "EUR", "GBP", "SGD", "AUD", "CHF", "CNY", "DKK", "HKD"], + cardBrands: ["JCB", "Visa", "MasterCard", "UnionPay"], + installmentTerms: nil, + banks: nil, + provider: nil + ), + Capability.PaymentMethod( + name: "installment_bay", + currencies: ["THB"], + cardBrands: nil, + installmentTerms: [3, 4, 6, 9, 10], + banks: nil, + provider: nil + ) + ] + + // swiftlint:disable:next line_length + let banks = ["test", "bbl", "kbank", "rbs", "ktb", "jpm", "mufg", "tmb", "scb", "smbc", "sc", "cimb", "uob", "bay", "mega", "boa", "cacib", "gsb", "hsbc", "db", "ghb", "baac", "mb", "bnp", "tbank", "ibank", "tisco", "kk", "icbc", "tcrb", "lhb"] + + let capability = Capability( + countryCode: "TH", + paymentMethods: payments, + banks: Set(banks) + ) + + let sample: Capability = try sampleFromJSONBy(.capability) + XCTAssertEqual(sample.banks, capability.banks) + XCTAssertEqual(sample.countryCode, capability.countryCode) + XCTAssertEqual(sample.paymentMethods[0], payments[0]) + XCTAssertEqual(sample.paymentMethods[1], payments[1]) + } +} diff --git a/dev.xcodeproj/project.pbxproj b/dev.xcodeproj/project.pbxproj index 714a6d04..301b8d6b 100644 --- a/dev.xcodeproj/project.pbxproj +++ b/dev.xcodeproj/project.pbxproj @@ -119,6 +119,7 @@ 75E0EB722B7A962600E3198A /* SourcePaymentPayloadTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B4208D2B78C2120036134D /* SourcePaymentPayloadTest.swift */; }; 75E0EB7C2B7B410600E3198A /* Client+Network.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75E0EB7B2B7B410600E3198A /* Client+Network.swift */; }; 75E0EB7E2B7B5EE400E3198A /* CardPaymentPayloadTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75E0EB7D2B7B5EE400E3198A /* CardPaymentPayloadTests.swift */; }; + 75E0EB832B7B79E700E3198A /* CapabilityTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75E0EB822B7B79E700E3198A /* CapabilityTests.swift */; }; 75F2A0182A0BD0D40038FA54 /* Config.local.plist in Resources */ = {isa = PBXBuildFile; fileRef = 75DAD8922A0BC9540098AF96 /* Config.local.plist */; }; 75F2A09A2A13B0B10038FA54 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 75F2A0992A13B0B10038FA54 /* Preview Assets.xcassets */; }; 75F2A0A62A13B70F0038FA54 /* OmiseTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9864062F1CFEA7E4004BCF51 /* OmiseTextField.swift */; }; @@ -326,6 +327,7 @@ 75E0EB702B7A904100E3198A /* SourceFlowTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceFlowTests.swift; sourceTree = ""; }; 75E0EB7B2B7B410600E3198A /* Client+Network.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Client+Network.swift"; sourceTree = ""; }; 75E0EB7D2B7B5EE400E3198A /* CardPaymentPayloadTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardPaymentPayloadTests.swift; sourceTree = ""; }; + 75E0EB822B7B79E700E3198A /* CapabilityTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CapabilityTests.swift; sourceTree = ""; }; 75F2A0902A13B0B00038FA54 /* OmiseSDKUITests.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OmiseSDKUITests.app; sourceTree = BUILT_PRODUCTS_DIR; }; 75F2A0992A13B0B10038FA54 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 75F2A0A42A13B1470038FA54 /* AtomeFormViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtomeFormViewController.swift; sourceTree = ""; }; @@ -800,6 +802,7 @@ 75E0EB702B7A904100E3198A /* SourceFlowTests.swift */, 75B4208D2B78C2120036134D /* SourcePaymentPayloadTest.swift */, 75E0EB7D2B7B5EE400E3198A /* CardPaymentPayloadTests.swift */, + 75E0EB822B7B79E700E3198A /* CapabilityTests.swift */, ); path = "Source and Token JSON Codable Tests"; sourceTree = ""; @@ -1349,6 +1352,7 @@ 750708F42B7A765500A48DD0 /* OmiseSDKTests.swift in Sources */, 75E0EB7E2B7B5EE400E3198A /* CardPaymentPayloadTests.swift in Sources */, 75E0EB712B7A904100E3198A /* SourceFlowTests.swift in Sources */, + 75E0EB832B7B79E700E3198A /* CapabilityTests.swift in Sources */, F615CBF8261565D600E1A2D9 /* CardExpiryDatePickerTests.swift in Sources */, 75E0EB722B7A962600E3198A /* SourcePaymentPayloadTest.swift in Sources */, 753279382A31B40F008048AD /* CountryListViewModelMockup.swift in Sources */, From 9867b313cd518e99f4dce6ac908921766da90d28 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Tue, 13 Feb 2024 20:29:44 +0700 Subject: [PATCH 063/204] Remove old Data Layer and replaced with new one --- ExampleApp/Models/Tools.swift | 10 +- ExampleApp/Resources/Main.storyboard | 25 +- ExampleApp/Views/BaseViewController.swift | 2 +- .../CustomCreditCardFormViewController.swift | 6 +- .../PaymentSettingTableViewController.swift | 10 +- .../Views/ProductDetailViewController.swift | 18 +- .../OmiseSwiftUIKit/App/ContentView.swift | 4 +- OmiseSDK/AtomeFormViewModel.swift | 38 +- OmiseSDK/CreditCardFormViewController.swift | 181 ++- OmiseSDK/CreditCardFormViewModel.swift | 19 +- .../CreditCardFormViewModelProtocol.swift | 2 +- OmiseSDK/Currency.swift | 104 +- OmiseSDK/Done/CapabilityOld.swift | 502 ------- OmiseSDK/Done/PaymentInformation.Atome.swift | 103 -- OmiseSDK/Done/Request.swift | 15 - OmiseSDK/Done/RequestTask.swift | 18 - OmiseSDK/Done/TokenOld.swift | 300 ---- .../DuitNowOBWBankChooserViewController.swift | 15 +- ...ontextInformationInputViewController.swift | 6 +- OmiseSDK/FPXBankChooserViewController.swift | 13 +- OmiseSDK/FPXFormViewController.swift | 4 +- OmiseSDK/Globals.swift | 4 +- ...ntBankingSourceChooserViewController.swift | 53 +- ...tsNumberOfTermsChooserViewController.swift | 26 +- ...etBankingSourceChooserViewController.swift | 26 +- ...leBankingSourceChooserViewController.swift | 30 +- OmiseSDK/Object.swift | 13 - OmiseSDK/OmiseError.swift | 9 +- OmiseSDK/PaymentChooserViewController.swift | 165 +-- OmiseSDK/PaymentCreatorController.swift | 48 +- OmiseSDK/PaymentInformation.swift | 1221 ----------------- OmiseSDK/PaymentUI.swift | 112 +- OmiseSDK/Refactoring/New/Client/Client.swift | 3 +- .../Refactoring/New/Models/Capability.swift | 15 +- .../New/Models/Source.Payload.Atome.swift | 2 +- .../Models/Source.Payload.DuitNowOBW.swift | 6 +- .../Models/Source.Payload.Installment.swift | 25 + .../Refactoring/New/Models/SourceType.swift | 84 +- OmiseSDK/Refactoring/New/Models/Token.swift | 4 +- OmiseSDK/Refactoring/Old/ClientOld.swift | 430 ------ OmiseSDK/SourceOLD.swift | 163 --- OmiseSDK/TrueMoneyFormViewController.swift | 6 +- .../Atome/AtomeFormViewControllerTests.swift | 0 .../Atome/AtomeFormViewModelTests.swift | 0 .../CountryListViewModelMockup.swift | 0 .../Mockups/AtomeFormViewContextMockup.swift | 0 .../Mockups/AtomeFormViewModelMockup.swift | 0 .../BadRequestAPIErrorParsingTestCase.swift | 0 .../InvalidCardAPIErrorParsingTestCase.swift | 0 .../PANModelTestCase.swift | 0 .../PaymentInformationTestCase.swift | 124 +- .../Views/CardExpiryDatePickerTests.swift | 0 .../PaymentChooserViewControllerTests.swift | 14 +- .../CapabilityOperationFixtureTests.swift | 91 -- .../Old tests/Client/ClientOldTestCase.swift | 145 -- OmiseSDKTests/Old tests/ModelTestCase.swift | 735 ---------- .../Contents.swift | 4 +- .../Contents.swift | 4 +- .../Contents.swift | 10 +- .../Contents.swift | 8 +- README.md | 38 +- SourceTypeValue.swift | 66 - dev.xcodeproj/project.pbxproj | 69 +- 63 files changed, 535 insertions(+), 4613 deletions(-) delete mode 100644 OmiseSDK/Done/CapabilityOld.swift delete mode 100644 OmiseSDK/Done/PaymentInformation.Atome.swift delete mode 100644 OmiseSDK/Done/Request.swift delete mode 100644 OmiseSDK/Done/RequestTask.swift delete mode 100644 OmiseSDK/Done/TokenOld.swift delete mode 100644 OmiseSDK/Object.swift delete mode 100644 OmiseSDK/PaymentInformation.swift delete mode 100644 OmiseSDK/Refactoring/Old/ClientOld.swift delete mode 100644 OmiseSDK/SourceOLD.swift rename OmiseSDKTests/{Old tests => Not Refactored Tests}/Atome/AtomeFormViewControllerTests.swift (100%) rename OmiseSDKTests/{Old tests => Not Refactored Tests}/Atome/AtomeFormViewModelTests.swift (100%) rename OmiseSDKTests/{Old tests => Not Refactored Tests}/Atome/CountryLists/CountryListViewModelMockup.swift (100%) rename OmiseSDKTests/{Old tests => Not Refactored Tests}/Atome/Mockups/AtomeFormViewContextMockup.swift (100%) rename OmiseSDKTests/{Old tests => Not Refactored Tests}/Atome/Mockups/AtomeFormViewModelMockup.swift (100%) rename OmiseSDKTests/{Old tests => Not Refactored Tests}/BadRequestAPIErrorParsingTestCase.swift (100%) rename OmiseSDKTests/{Old tests => Not Refactored Tests}/InvalidCardAPIErrorParsingTestCase.swift (100%) rename OmiseSDKTests/{Old tests => Not Refactored Tests}/PANModelTestCase.swift (100%) rename OmiseSDKTests/{Old tests => Not Refactored Tests}/PaymentInformationTestCase.swift (86%) rename OmiseSDKTests/{Old tests => Not Refactored Tests}/Views/CardExpiryDatePickerTests.swift (100%) rename OmiseSDKTests/{Old tests => Not Refactored Tests}/Views/PaymentChooserViewControllerTests.swift (94%) delete mode 100644 OmiseSDKTests/Old tests/CapabilityOperationFixtureTests.swift delete mode 100644 OmiseSDKTests/Old tests/Client/ClientOldTestCase.swift delete mode 100644 OmiseSDKTests/Old tests/ModelTestCase.swift delete mode 100644 SourceTypeValue.swift diff --git a/ExampleApp/Models/Tools.swift b/ExampleApp/Models/Tools.swift index 601cf8dc..b7e11bb8 100644 --- a/ExampleApp/Models/Tools.swift +++ b/ExampleApp/Models/Tools.swift @@ -4,7 +4,7 @@ import OmiseSDK struct PaymentPreset { var paymentAmount: Int64 var paymentCurrency: Currency - var allowedPaymentMethods: [SourceTypeValue] + var allowedPaymentMethods: [SourceType] static let thailandPreset = PaymentPreset( paymentAmount: 5_000_00, @@ -35,19 +35,19 @@ class Tool: NSObject { static let thailandPaymentAmount: Int64 = PaymentPreset.thailandPreset.paymentAmount static let thailandPaymentCurrency: String = PaymentPreset.thailandPreset.paymentCurrency.code - static let thailandAllowedPaymentMethods: [SourceTypeValue] = PaymentPreset.thailandPreset.allowedPaymentMethods + static let thailandAllowedPaymentMethods: [SourceType] = PaymentPreset.thailandPreset.allowedPaymentMethods static let japanPaymentAmount: Int64 = PaymentPreset.japanPreset.paymentAmount static let japanPaymentCurrency: String = PaymentPreset.japanPreset.paymentCurrency.code - static let japanAllowedPaymentMethods: [SourceTypeValue] = PaymentPreset.japanPreset.allowedPaymentMethods + static let japanAllowedPaymentMethods: [SourceType] = PaymentPreset.japanPreset.allowedPaymentMethods static let singaporePaymentAmount: Int64 = PaymentPreset.singaporePreset.paymentAmount static let singaporePaymentCurrency: String = PaymentPreset.singaporePreset.paymentCurrency.code - static let singaporeAllowedPaymentMethods: [SourceTypeValue] = PaymentPreset.singaporePreset.allowedPaymentMethods + static let singaporeAllowedPaymentMethods: [SourceType] = PaymentPreset.singaporePreset.allowedPaymentMethods static let malaysiaPaymentAmount: Int64 = PaymentPreset.malaysiaPreset.paymentAmount static let malaysiaPaymentCurrency: String = PaymentPreset.malaysiaPreset.paymentCurrency.code - static let malaysiaAllowedPaymentMethods: [SourceTypeValue] = PaymentPreset.malaysiaPreset.allowedPaymentMethods + static let malaysiaAllowedPaymentMethods: [SourceType] = PaymentPreset.malaysiaPreset.allowedPaymentMethods static func imageWith(size: CGSize, color: UIColor) -> UIImage? { return Tool.imageWith(size: size) { (context) in diff --git a/ExampleApp/Resources/Main.storyboard b/ExampleApp/Resources/Main.storyboard index a0323c6e..0de80adc 100644 --- a/ExampleApp/Resources/Main.storyboard +++ b/ExampleApp/Resources/Main.storyboard @@ -2,6 +2,7 @@ + @@ -16,7 +17,7 @@ - + @@ -184,7 +185,7 @@ You can present via either Storyboard or Code and you can see the code in the Ex - + @@ -315,7 +316,7 @@ You can present via either Storyboard or Code and you can see the code in the Ex - "Try CapabilityOld API" will try to load the allowed payment methods from tCapabilityOld API and use it if it's available. + "Try Capability API" will try to load the allowed payment methods from tCapabilityOld API and use it if it's available. "Use specific payment methods" will ignore the allowed payment methods from tCapabilityOld API and always use the payment method specified below @@ -325,7 +326,7 @@ You can present via either Storyboard or Code and you can see the code in the Ex - @@ -2689,7 +2689,7 @@ - + @@ -2841,6 +2841,35 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -2945,7 +2974,7 @@ - + @@ -2968,13 +2997,13 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + - + @@ -1490,250 +958,12 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -2527,11 +1757,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - @@ -2554,24 +1822,12 @@ - - - - - - - - - - - - diff --git a/OmiseSDK/Sources/OmiseAPI/Client.swift b/OmiseSDK/Sources/OmiseAPI/Client.swift index d2845928..3ae0a6b0 100644 --- a/OmiseSDK/Sources/OmiseAPI/Client.swift +++ b/OmiseSDK/Sources/OmiseAPI/Client.swift @@ -65,9 +65,8 @@ public class Client { /// - Parameters: /// - payload: Information required to perform Create a Token API request /// - completion: Returns `Token`object on success and `Error` on request failed - public func createToken(payload: CreateTokenPayload.Card, _ completion: @escaping RequestResultClosure) { - let apiPayload = CreateTokenPayload(card: payload) - performRequest(api: OmiseAPI.createToken(payload: apiPayload), completion: completion) + public func createToken(payload: CreateTokenPayload, _ completion: @escaping RequestResultClosure) { + performRequest(api: OmiseAPI.createToken(payload: payload), completion: completion) } /// Request a Token from API with given Token ID diff --git a/OmiseSDK/Sources/OmiseAPI/Payloads/CreateTokenPayload.swift b/OmiseSDK/Sources/OmiseAPI/Payloads/CreateTokenPayload.swift index 5bee2428..ee22f5fa 100644 --- a/OmiseSDK/Sources/OmiseAPI/Payloads/CreateTokenPayload.swift +++ b/OmiseSDK/Sources/OmiseAPI/Payloads/CreateTokenPayload.swift @@ -2,9 +2,13 @@ import Foundation /// Card Information to create a token container /// Used as payload in createToken API -public struct CreateTokenPayload: Codable { - let card: Card +public struct CreateTokenPayload: Codable, Equatable { + public let card: Card + public init(card: Card) { + self.card = card + } + /// Card Information to create a token /// A token represents a credit or debit card /// https://docs.opn.ooo/tokens-api diff --git a/OmiseSDK/Sources/Views/Components/CCVInfoPopupController.xib b/OmiseSDK/Sources/Views/Components/CCVInfoPopupController.xib new file mode 100644 index 00000000..40cb7551 --- /dev/null +++ b/OmiseSDK/Sources/Views/Components/CCVInfoPopupController.xib @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/AtomePaymentController/AtomePaymentController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentController.swift similarity index 98% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/AtomePaymentController/AtomePaymentController.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentController.swift index 3798e1b5..a8e9cc60 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/AtomePaymentController/AtomePaymentController.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentController.swift @@ -39,19 +39,7 @@ class AtomePaymentController: UIViewController { } } } - - var preferredPrimaryColor: UIColor? { - didSet { - applyPrimaryColor() - } - } - - var preferredSecondaryColor: UIColor? { - didSet { - applySecondaryColor() - } - } - + private var style = Style() private lazy var logoImageView: UIImageView = { diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/AtomePaymentController/AtomePaymentViewContext.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentViewContext.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/AtomePaymentController/AtomePaymentViewContext.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentViewContext.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/AtomePaymentController/AtomePaymentViewModel.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentViewModel.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/AtomePaymentController/AtomePaymentViewModel.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentViewModel.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/AtomePaymentController/AtomePaymentViewModelProtocol.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentViewModelProtocol.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/AtomePaymentController/AtomePaymentViewModelProtocol.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentViewModelProtocol.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift index 5c1eac5d..3ad9988d 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift @@ -98,8 +98,26 @@ class ChoosePaymentCoordinator: ViewAttachable { viewController.title = SourceType.atome.localizedTitle return viewController } + + /// Creates Atome screen and attach current flow object inside created controller to be deallocated together + func createCardPaymentController() -> CreditCardPaymentController { + let viewModel = CreditCardPaymentViewModel(delegate: self) + let viewController = CreditCardPaymentController(nibName: nil, bundle: .omiseSDK) + viewController.viewModel = viewModel + viewController.title = PaymentMethod.creditCard.localizedTitle + return viewController + } } +extension ChoosePaymentCoordinator: CreditCardPaymentDelegate { + func didSelectCardPayment(_ card: CreateTokenPayload.Card) { + processPayment(card) + } + + func didCancelCardPayment() { + didCancelPayment() + } +} extension ChoosePaymentCoordinator: SelectPaymentMethodDelegate { func didSelectPaymentMethod(_ paymentMethod: PaymentMethod) { if paymentMethod.requiresAdditionalDetails { @@ -146,6 +164,20 @@ extension ChoosePaymentCoordinator { ) } + func processPayment(_ card: CreateTokenPayload.Card) { + guard let delegate = choosePaymentMethodDelegate else { return } + let tokenPayload = CreateTokenPayload(card: card) + + client.createToken(payload: tokenPayload) { [weak delegate] result in + switch result { + case .success(let token): + delegate?.choosePaymentMethodDidComplete(with: token) + case .failure(let error): + delegate?.choosePaymentMethodDidComplete(with: error) + } + } + } + func processPayment(_ payment: Source.Payment) { guard let delegate = choosePaymentMethodDelegate else { return } let sourcePayload = CreateSourcePayload( @@ -186,7 +218,7 @@ extension ChoosePaymentCoordinator { // func navigate(to: Route) { // // override func prepare(for segue: UIStoryboardSegue, sender: Any?) { // // switch (segue.identifier, segue.destination) { -// // case ("GoToCreditCardFormSegue"?, let controller as CreditCardFormViewController): +// // case ("GoToCreditCardPaymentSegue"?, let controller as CreditCardPaymentController): // // controller.publicKey = viewModel.flowSession?.client?.publicKey // // controller.delegate = viewModel.flowSession // // controller.navigationItem.rightBarButtonItem = nil diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Delegates/SelectPaymentMethodDelegate.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment Delegates/SelectPaymentMethodDelegate.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Delegates/SelectPaymentMethodDelegate.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment Delegates/SelectPaymentMethodDelegate.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Delegates/SelectSourcePaymentDelegate.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment Delegates/SelectSourcePaymentDelegate.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Delegates/SelectSourcePaymentDelegate.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment Delegates/SelectSourcePaymentDelegate.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Delegates/SelectSourceTypeDelegate.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment Delegates/SelectSourceTypeDelegate.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Delegates/SelectSourceTypeDelegate.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment Delegates/SelectSourceTypeDelegate.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment/SelectInstallmentTermsViewModel.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectInstallmentTermsViewModel.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment/SelectInstallmentTermsViewModel.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectInstallmentTermsViewModel.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment/SelectPaymentController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectPaymentController.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment/SelectPaymentController.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectPaymentController.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment/SelectPaymentMethodViewModel.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectPaymentMethodViewModel.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment/SelectPaymentMethodViewModel.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectPaymentMethodViewModel.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment/SelectPaymentPresentableProtocol.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectPaymentPresentableProtocol.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment/SelectPaymentPresentableProtocol.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectPaymentPresentableProtocol.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment/SelectSourceTypePaymentViewModel.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectSourceTypePaymentViewModel.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment/SelectSourceTypePaymentViewModel.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectSourceTypePaymentViewModel.swift diff --git a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardFormViewModel.swift b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardFormViewModel.swift deleted file mode 100644 index 25c3c0db..00000000 --- a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardFormViewModel.swift +++ /dev/null @@ -1,74 +0,0 @@ -// -// CreditCardFormViewModel.swift -// OmiseSDK -// -// Created by Andrei Solovev on 19/6/23. -// Copyright © 2023 Omise. All rights reserved. -// - -import Foundation -import os.log - -class CreditCardFormViewModel: CreditCardFormViewModelProtocol, CountryListViewModelProtocol { - var addressFields: [AddressField] = [.address, .city, .state, .postalCode] - - var fieldForShippingAddressHeader: AddressField? - - var isAddressFieldsVisible: Bool { - selectedCountry?.isAVS ?? false - } - - func title(for field: AddressField) -> String? { - field.title - } - - var countryListViewModel: CountryListViewModelProtocol { return self } - - // MARK: CountryListViewModelProtocol - lazy var countries: [Country] = Country.sortedAll - - lazy var selectedCountry: Country? = OmiseSDK.shared.country { - didSet { - if let selectedCountry = selectedCountry { - onSelectCountry(selectedCountry) - } - } - } - var onSelectCountry: (Country) -> Void = { _ in } - - func error(for field: AddressField, validate text: String?) -> String? { - guard isAddressFieldsVisible else { return nil } - let result = (text?.isEmpty ?? true) ? field.error : nil - return result - } - func onSubmitButtonPressed(_ viewContext: ViewContext, publicKey: String?, onComplete: @escaping (Result) -> Void) { - guard let publicKey = publicKey else { - os_log("Missing or invalid public key information - %{private}@", log: uiLogObject, type: .error, publicKey ?? "") - assertionFailure("Missing public key information. Please set the public key before request token.") - return - } - - os_log("Requesting to create token", log: uiLogObject, type: .info) - - let payload = CreateTokenPayload.Card( - name: viewContext.name, - number: viewContext.number, - expirationMonth: viewContext.expirationMonth, - expirationYear: viewContext.expirationYear, - securityCode: viewContext.securityCode, - phoneNumber: nil, - countryCode: viewContext.countryCode, - city: viewContext[.city], - state: viewContext[.state], - street1: viewContext[.address], - street2: nil, - postalCode: viewContext[.postalCode] - ) - - let client = OmiseSDK(publicKey: publicKey).client - client.createToken(payload: payload) { result in - onComplete(result) - } - } - -} diff --git a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardFormViewController.swift b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift similarity index 84% rename from OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardFormViewController.swift rename to OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift index 243e9659..e0e8b3a7 100644 --- a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardFormViewController.swift +++ b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift @@ -3,29 +3,13 @@ import UIKit import os.log -public protocol CreditCardFormViewControllerDelegate: AnyObject { - /// Delegate method for receiving token data when card tokenization succeeds. - /// - parameter token: `OmiseToken` instance created from supplied credit card data. - /// - seealso: [Tokens API](https://www.omise.co/tokens-api) - func creditCardFormViewController(_ controller: CreditCardFormViewController, didSucceedWithToken token: Token) - - /// Delegate method for receiving error information when card tokenization failed. - /// This allows you to have fine-grained control over error handling when setting - /// `handleErrors` to `false`. - /// - parameter error: The error that occurred during tokenization. - /// - note: This delegate method will *never* be called if `handleErrors` property is set to `true`. - func creditCardFormViewController(_ controller: CreditCardFormViewController, didFailWithError error: Error) - - func creditCardFormViewControllerDidCancel(_ controller: CreditCardFormViewController) -} - /// Drop-in credit card input form view controller that automatically tokenizes credit /// card information. -public class CreditCardFormViewController: UIViewController, PaymentFormUIController { +public class CreditCardPaymentController: UIViewController { // swiftlint:disable:previous type_body_length - typealias ViewModel = CreditCardFormViewModel - typealias ViewContext = CreditCardFormViewContext + typealias ViewModel = CreditCardPaymentViewModel + typealias ViewContext = CreditCardPaymentViewContext typealias Field = ViewContext.Field struct Style { @@ -33,35 +17,21 @@ public class CreditCardFormViewController: UIViewController, PaymentFormUIContro } var style = Style() - lazy var viewModel: ViewModel = { - ViewModel() - }() - /// Omise public key for calling tokenization API. - public var publicKey: String? - - /// Delegate to receive CreditCardFormController result. - public weak var delegate: CreditCardFormViewControllerDelegate? - /// Delegate to receive CreditCardFormController result. - - /// A boolean flag to enables/disables automatic error handling. Defaults to `true`. - public var handleErrors = true - - @IBInspectable public var preferredPrimaryColor: UIColor? { + var viewModel: ViewModel? { didSet { - applyPrimaryColor() + if let newViewModel = viewModel { + bind(to: newViewModel) + } } } - @IBInspectable public var preferredSecondaryColor: UIColor? { - didSet { - applySecondaryColor() - } - } + /// A boolean flag to enables/disables automatic error handling. Defaults to `true`. + public var handleErrors = true - @IBInspectable public var errorMessageTextColor: UIColor! = CreditCardFormViewController.defaultErrorMessageTextColor { + @IBInspectable public var errorMessageTextColor: UIColor! = CreditCardPaymentController.defaultErrorMessageTextColor { didSet { if errorMessageTextColor == nil { - errorMessageTextColor = CreditCardFormViewController.defaultErrorMessageTextColor + errorMessageTextColor = CreditCardPaymentController.defaultErrorMessageTextColor } if isViewLoaded { @@ -82,11 +52,16 @@ public class CreditCardFormViewController: UIViewController, PaymentFormUIContro var currentEditingTextField: OmiseTextField? var hasErrorMessage = false - @IBOutlet var formFields: [OmiseTextField]! - @IBOutlet var formLabels: [UILabel]! - @IBOutlet var errorLabels: [UILabel]! + var formFields: [OmiseTextField] = [] + var formLabels: [UILabel] = [] + + var errorLabels: [UILabel] = [] + var contentView: UIScrollView! - @IBOutlet var contentView: UIScrollView! + @IBOutlet var cardNumberLabel: UILabel! + @IBOutlet var cardNameLabel: UILabel! + @IBOutlet var expiryDateLabel: UILabel! + @IBOutlet var secureCodeLabel: UILabel! @IBOutlet var cardNumberTextField: CardNumberTextField! @IBOutlet var cardNameTextField: CardNameTextField! @@ -128,14 +103,12 @@ public class CreditCardFormViewController: UIViewController, PaymentFormUIContro @IBOutlet var requestingIndicatorView: UIActivityIndicatorView! public static let defaultErrorMessageTextColor = UIColor.error - /// Factory method for creating CreditCardFormController with given public key. + /// Factory method for creating CreditCardPaymentController with given public key. /// - parameter publicKey: Omise public key. - public static func makeCreditCardFormViewController(withPublicKey publicKey: String) -> CreditCardFormViewController { + public static func makeCreditCardPaymentController(withPublicKey publicKey: String) -> CreditCardPaymentController { let storyboard = UIStoryboard(name: "OmiseSDK", bundle: .omiseSDK) // swiftlint:disable:next force_cast - let creditCardForm = storyboard.instantiateInitialViewController() as! CreditCardFormViewController - creditCardForm.publicKey = publicKey - + let creditCardForm = storyboard.instantiateInitialViewController() as! CreditCardPaymentController return creditCardForm } @@ -157,6 +130,27 @@ public class CreditCardFormViewController: UIViewController, PaymentFormUIContro public override func loadView() { super.loadView() + errorLabels = [ + cardHolderNameErrorLabel, + creditCardNumberErrorLabel, + cardSecurityCodeErrorLabel, + cardExpiryDateErrorLabel + ] + + formLabels = [ + cardNameLabel, + cardNumberLabel, + secureCodeLabel, + expiryDateLabel + ] + + formFields = [ + cardNumberTextField, + cardNameTextField, + secureCodeTextField, + expiryDateTextField + ] + view.backgroundColor = UIColor.background submitButton.defaultBackgroundColor = view.tintColor submitButton.disabledBackgroundColor = .line @@ -164,31 +158,45 @@ public class CreditCardFormViewController: UIViewController, PaymentFormUIContro cvvInfoButton.tintColor = .badgeBackground formFieldsAccessoryView.barTintColor = .formAccessoryBarTintColor - applyNavigationBarStyle(.shadow(color: preferredSecondaryColor ?? defaultPaymentChooserUISecondaryColor)) + applyNavigationBarStyle(.shadow(color: .omiseSecondary)) } - func setupBillingStackView() { + private func setupBillingStackView() { billingStackView.distribution = .equalSpacing billingStackView.alignment = .fill billingStackView.spacing = style.billingStackSpacing setupCountryField() } - func setupCountryField() { + func bind(to viewModel: ViewModel) { + guard isViewLoaded else { return } + countryInputView.text = viewModel.countryListViewModel.selectedCountry?.name + + viewModel.addressFields.forEach { + let input = TextFieldView(id: $0.rawValue) + addressStackView.addArrangedSubview(input) + setupInput(input, field: $0, isLast: $0 == viewModel.addressFields.last, viewModel: viewModel) + } + addressStackView.isHiddenInStackView = !viewModel.isAddressFieldsVisible + updateSupplementaryUI() + } + + private func setupCountryField() { let input = countryInputView input.title = "CreditCard.field.country".localized() billingStackView.addArrangedSubview(input) input.textFieldUserInteractionEnabled = false - input.text = viewModel.countryListViewModel.selectedCountry?.name input.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(onCountryInputTapped))) } @objc func onCountryInputTapped() { + guard let viewModel = viewModel else { return } + let vc = CountryListController(viewModel: viewModel.countryListViewModel) vc.title = countryInputView.title vc.viewModel?.onSelectCountry = { [weak self] country in - guard let self = self else { return } + guard let self = self, let viewModel = self.viewModel else { return } self.countryInputView.text = country.name if let nc = self.navigationController { @@ -197,7 +205,7 @@ public class CreditCardFormViewController: UIViewController, PaymentFormUIContro self.dismiss(animated: true) } - self.addressStackView.isHiddenInStackView = !self.viewModel.isAddressFieldsVisible + self.addressStackView.isHiddenInStackView = !viewModel.isAddressFieldsVisible self.updateSubmitButtonState() } @@ -210,13 +218,7 @@ public class CreditCardFormViewController: UIViewController, PaymentFormUIContro } func setupAddressFields() { - viewModel.addressFields.forEach { - let input = TextFieldView(id: $0.rawValue) - addressStackView.addArrangedSubview(input) - setupInput(input, field: $0, isLast: $0 == viewModel.addressFields.last, viewModel: viewModel) - } billingStackView.addArrangedSubview(addressStackView) - addressStackView.isHiddenInStackView = !viewModel.isAddressFieldsVisible } func setupInput(_ input: TextFieldView, field: Field, isLast: Bool, viewModel: ViewModel) { @@ -276,28 +278,12 @@ public class CreditCardFormViewController: UIViewController, PaymentFormUIContro // We'll leave the adjusting scroll view insets job for iOS 11 and later to the layoutMargins + safeAreaInsets here automaticallyAdjustsScrollViewInsets = true } - - // Storyboard shows wrong warning on textContentType == .creditCardNumber - // Set textContentType manually - cardNumberTextField.textContentType = .creditCardNumber + cardNumberTextField.textContentType = .creditCardNumber cardNumberTextField.textContentType = .creditCardNumber cardNumberTextField.rightView = cardBrandIconImageView secureCodeTextField.rightView = cvvInfoButton secureCodeTextField.rightViewMode = .always - -// NotificationCenter.default.addObserver( -// self, -// selector: #selector(keyboardWillChangeFrame(_:)), -// name: UIResponder.keyboardWillChangeFrameNotification, -// object: nil -// ) -// NotificationCenter.default.addObserver( -// self, -// selector: #selector(keyboardWillHide(_:)), -// name: UIResponder.keyboardWillHideNotification, -// object: nil -// ) } public override func viewWillLayoutSubviews() { @@ -315,17 +301,6 @@ public class CreditCardFormViewController: UIViewController, PaymentFormUIContro } } -// public override func viewDidAppear(_ animated: Bool) { -// super.viewDidAppear(animated) -// -// NotificationCenter.default.addObserver( -// self, -// selector: #selector(self.keyboardWillAppear(_:)), -// name: UIResponder.keyboardWillShowNotification, -// object: nil -// ) -// } - public override func viewDidDisappear(_ animated: Bool) { super.viewDidDisappear(animated) @@ -358,27 +333,32 @@ public class CreditCardFormViewController: UIViewController, PaymentFormUIContro @discardableResult func performCancelingForm() -> Bool { - os_log("Credit Card Form dismissing requested, Asking the delegate what should the form controler do", - log: uiLogObject, - type: .default) - - if let delegate = self.delegate { - delegate.creditCardFormViewControllerDidCancel(self) - os_log("Canceling form delegate notified", log: uiLogObject, type: .default) - return true - } else if let delegateMethod = delegate?.creditCardFormViewControllerDidCancel { - delegateMethod(self) - os_log("Canceling form delegate notified", log: uiLogObject, type: .default) - return true - } else { - os_log("Credit Card Form dismissing requested but there is not delegate to ask. Ignore the request", - log: uiLogObject, - type: .default) - return false - } + guard let viewModel = viewModel else { return false } + viewModel.viewDidTapClose() + return true +// os_log("Credit Card Form dismissing requested, Asking the delegate what should the form controler do", +// log: uiLogObject, +// type: .default) +// +// if let delegate = self.delegate { +// delegate.creditCardFormViewControllerDidCancel(self) +// os_log("Canceling form delegate notified", log: uiLogObject, type: .default) +// return true +// } else if let delegateMethod = delegate?.creditCardFormViewControllerDidCancel { +// delegateMethod(self) +// os_log("Canceling form delegate notified", log: uiLogObject, type: .default) +// return true +// } else { +// os_log("Credit Card Form dismissing requested but there is not delegate to ask. Ignore the request", +// log: uiLogObject, +// type: .default) +// return false +// } } func makeViewContext() -> ViewContext { + guard let viewModel = viewModel else { return ViewContext () } + var context = ViewContext() let fields = viewModel.addressFields for field in fields { @@ -399,23 +379,26 @@ public class CreditCardFormViewController: UIViewController, PaymentFormUIContro @IBAction private func requestToken() { doneEditing(nil) + guard let viewModel = viewModel else { return } UIAccessibility.post(notification: UIAccessibility.Notification.announcement, argument: "Submitting payment, please wait") startActivityIndicator() - viewModel.onSubmitButtonPressed(makeViewContext(), publicKey: publicKey) { [weak self] result in - guard let self = self else { return } - self.stopActivityIndicator() - switch result { - case .success(let token): - os_log("Credit Card Form's Request succeed %{private}@, trying to notify the delegate", - log: uiLogObject, - type: .default, - token.id) - self.delegate?.creditCardFormViewController(self, didSucceedWithToken: token) - case .failure(let error): - self.handleError(error) - } - } + viewModel.onSubmitButtonPressed(makeViewContext()) + +// { [weak self] result in +// guard let self = self else { return } +// self.stopActivityIndicator() +// switch result { +// case .success(let token): +// os_log("Credit Card Form's Request succeed %{private}@, trying to notify the delegate", +// log: uiLogObject, +// type: .default, +// token.id) +// self.delegate?.creditCardFormViewController(self, didSucceedWithToken: token) +// case .failure(let error): +// self.handleError(error) +// } +// } } func keyboardWillAppear(_ notification: Notification) { @@ -450,7 +433,7 @@ public class CreditCardFormViewController: UIViewController, PaymentFormUIContro } func handleError(_ error: Error) { - delegate?.creditCardFormViewController(self, didFailWithError: error) +// delegate?.creditCardFormViewController(self, didFailWithError: error) displayError(error) hasErrorMessage = true } @@ -596,7 +579,7 @@ public class CreditCardFormViewController: UIViewController, PaymentFormUIContro textFields.forEach { if let input = $0 as? TextFieldView { - input.titleColor = preferredPrimaryColor + input.titleColor = UIColor.omisePrimary input.borderColor = UIColor.omiseSecondary input.placeholderTextColor = UIColor.omiseSecondary } @@ -681,7 +664,7 @@ public class CreditCardFormViewController: UIViewController, PaymentFormUIContro } // MARK: - Fields Accessory methods -extension CreditCardFormViewController { +extension CreditCardPaymentController { @IBAction private func validateTextFieldDataOf(_ sender: OmiseTextField) { let duration = TimeInterval(UINavigationController.hideShowBarDuration) @@ -721,7 +704,7 @@ extension CreditCardFormViewController { } // MARK: - Accessibility -extension CreditCardFormViewController { +extension CreditCardPaymentController { @IBAction private func updateAccessibilityValue(_ sender: OmiseTextField) { updateSupplementaryUI() @@ -849,14 +832,16 @@ extension CreditCardFormViewController { } } -extension CreditCardFormViewController: MoreInformationOnCVVViewControllerDelegate { +extension CreditCardPaymentController: MoreInformationOnCVVViewControllerDelegate { func moreInformationOnCVVViewControllerDidAskToClose(_ controller: CCVInfoPopupController) { dismiss(animated: true, completion: nil) } } -extension CreditCardFormViewController { +extension CreditCardPaymentController { func updateSubmitButtonState() { + guard let viewModel = viewModel else { return } + let valid = isInputDataValid submitButton?.isEnabled = valid && viewModel.isSubmitButtonEnabled(makeViewContext()) @@ -868,6 +853,7 @@ extension CreditCardFormViewController { } func updateError(for field: Field) { + guard let viewModel = viewModel else { return } guard let input = input(for: field) else { return } input.error = viewModel.error(for: field, validate: input.text) } @@ -885,6 +871,7 @@ extension CreditCardFormViewController { func input(after input: TextFieldView) -> TextFieldView? { guard + let viewModel = viewModel, let inputField = Field(rawValue: input.identifier), let index = viewModel.addressFields.firstIndex(of: inputField), let nextField = viewModel.addressFields.at(index + 1), @@ -900,6 +887,8 @@ extension CreditCardFormViewController { } func hideErrorIfNil(field: Field) { + guard let viewModel = viewModel else { return } + if let input = input(for: field) { let error = viewModel.error(for: field, validate: input.text) if error == nil { @@ -969,6 +958,7 @@ extension CreditCardFormViewController { } func goToFirstInvalidField() { + guard let viewModel = viewModel else { return } for field in viewModel.addressFields { if let input = input(for: field), input.error != nil { input.becomeFirstResponder() @@ -979,9 +969,44 @@ extension CreditCardFormViewController { } func showAllErrors() { + guard let viewModel = viewModel else { return } for field in viewModel.addressFields { updateError(for: field) } } } + +extension CreditCardPaymentController { + func updateInputAccessoryViewWithFirstResponder(_ firstResponder: OmiseTextField) { + guard formFields.contains(firstResponder) else { return } + + currentEditingTextField = firstResponder + gotoPreviousFieldBarButtonItem.isEnabled = firstResponder !== formFields.first + gotoNextFieldBarButtonItem.isEnabled = firstResponder !== formFields.last + } + + func gotoPreviousField() { + guard let currentTextField = currentEditingTextField, let index = formFields.firstIndex(of: currentTextField) else { + return + } + + let prevIndex = index - 1 + guard prevIndex >= 0 else { return } + formFields[prevIndex].becomeFirstResponder() + } + + func gotoNextField() { + guard let currentTextField = currentEditingTextField, let index = formFields.firstIndex(of: currentTextField) else { + return + } + + let nextIndex = index + 1 + guard nextIndex < formFields.count else { return } + formFields[nextIndex].becomeFirstResponder() + } + + func doneEditing() { + view.endEditing(true) + } +} diff --git a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.xib b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.xib new file mode 100644 index 00000000..1d40ce8e --- /dev/null +++ b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.xib @@ -0,0 +1,422 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentDelegate.swift b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentDelegate.swift new file mode 100644 index 00000000..2b1e6018 --- /dev/null +++ b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentDelegate.swift @@ -0,0 +1,6 @@ +import Foundation + +protocol CreditCardPaymentDelegate: AnyObject { + func didSelectCardPayment(_ card: CreateTokenPayload.Card) + func didCancelCardPayment() +} diff --git a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardFormViewContext.swift b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentViewContext.swift similarity index 92% rename from OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardFormViewContext.swift rename to OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentViewContext.swift index 00f59327..7bee634b 100644 --- a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardFormViewContext.swift +++ b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentViewContext.swift @@ -1,5 +1,5 @@ // -// CreditCardFormViewContext.swift +// CreditCardPaymentViewContext.swift // OmiseSDK // // Created by Andrei Solovev on 19/6/23. @@ -8,7 +8,7 @@ import UIKit -struct CreditCardFormViewContext { +struct CreditCardPaymentViewContext { enum Field: String, CaseIterable { case address case city @@ -39,7 +39,7 @@ struct CreditCardFormViewContext { } } -extension CreditCardFormViewContext.Field { +extension CreditCardPaymentViewContext.Field { var title: String { "CreditCard.field.\(self.rawValue)".localized() } diff --git a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentViewModel.swift b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentViewModel.swift new file mode 100644 index 00000000..6361ca90 --- /dev/null +++ b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentViewModel.swift @@ -0,0 +1,120 @@ +// +// CreditCardPaymentViewModel.swift +// OmiseSDK +// +// Created by Andrei Solovev on 19/6/23. +// Copyright © 2023 Omise. All rights reserved. +// + +import Foundation +import os.log + +class CreditCardPaymentViewModel: CreditCardPaymentViewModelProtocol, CountryListViewModelProtocol { + var addressFields: [AddressField] = [.address, .city, .state, .postalCode] + + var fieldForShippingAddressHeader: AddressField? + + var isAddressFieldsVisible: Bool { + selectedCountry?.isAVS ?? false + } + + func title(for field: AddressField) -> String? { + field.title + } + + var countryListViewModel: CountryListViewModelProtocol { return self } + + private weak var delegate: CreditCardPaymentDelegate? + + init(delegate: CreditCardPaymentDelegate?) { + self.delegate = delegate + } + + // MARK: CountryListViewModelProtocol + lazy var countries: [Country] = Country.sortedAll + + lazy var selectedCountry: Country? = OmiseSDK.shared.country { + didSet { + if let selectedCountry = selectedCountry { + onSelectCountry(selectedCountry) + } + } + } + var onSelectCountry: (Country) -> Void = { _ in } + + func error(for field: AddressField, validate text: String?) -> String? { + guard isAddressFieldsVisible else { return nil } + let result = (text?.isEmpty ?? true) ? field.error : nil + return result + } + + func viewDidTapClose() { + delegate?.didCancelCardPayment() + } + + func onSubmitButtonPressed(_ viewContext: ViewContext) { + + let card = CreateTokenPayload.Card( + name: viewContext.name, + number: viewContext.number, + expirationMonth: viewContext.expirationMonth, + expirationYear: viewContext.expirationYear, + securityCode: viewContext.securityCode, + phoneNumber: nil, + countryCode: viewContext.countryCode, + city: viewContext[.city], + state: viewContext[.state], + street1: viewContext[.address], + street2: nil, + postalCode: viewContext[.postalCode] + ) + + delegate?.didSelectCardPayment(card) + + /* + viewModel.onSubmitButtonPressed(makeViewContext(), publicKey: publicKey) { [weak self] result in + guard let self = self else { return } + self.stopActivityIndicator() + switch result { + case .success(let token): + os_log("Credit Card Form's Request succeed %{private}@, trying to notify the delegate", + log: uiLogObject, + type: .default, + token.id) + self.delegate?.creditCardFormViewController(self, didSucceedWithToken: token) + case .failure(let error): + self.handleError(error) + } + } + */ + +// guard let publicKey = publicKey else { +// os_log("Missing or invalid public key information - %{private}@", log: uiLogObject, type: .error, publicKey ?? "") +// assertionFailure("Missing public key information. Please set the public key before request token.") +// return +// } +// +// os_log("Requesting to create token", log: uiLogObject, type: .info) +// +// let payload = CreateTokenPayload.Card( +// name: viewContext.name, +// number: viewContext.number, +// expirationMonth: viewContext.expirationMonth, +// expirationYear: viewContext.expirationYear, +// securityCode: viewContext.securityCode, +// phoneNumber: nil, +// countryCode: viewContext.countryCode, +// city: viewContext[.city], +// state: viewContext[.state], +// street1: viewContext[.address], +// street2: nil, +// postalCode: viewContext[.postalCode] +// ) +// +// let client = OmiseSDK(publicKey: publicKey).client +// client.createToken(payload: payload) { result in +// onComplete(result) +// } + } + +} diff --git a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardFormViewModelProtocol.swift b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentViewModelProtocol.swift similarity index 84% rename from OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardFormViewModelProtocol.swift rename to OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentViewModelProtocol.swift index ec2466d4..fd9a8921 100644 --- a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardFormViewModelProtocol.swift +++ b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentViewModelProtocol.swift @@ -1,5 +1,5 @@ // -// CreditCardFormViewModelProtocol.swift +// CreditCardPaymentViewModelProtocol.swift // OmiseSDK // // Created by Andrei Solovev on 19/6/23. @@ -8,15 +8,15 @@ import UIKit -protocol CreditCardFormViewModelProtocol { - typealias ViewContext = CreditCardFormViewContext +protocol CreditCardPaymentViewModelProtocol { + typealias ViewContext = CreditCardPaymentViewContext typealias AddressField = ViewContext.Field var addressFields: [AddressField] { get } var fieldForShippingAddressHeader: AddressField? { get } var countryListViewModel: CountryListViewModelProtocol { get } var isAddressFieldsVisible: Bool { get } - func onSubmitButtonPressed(_ viewContext: ViewContext, publicKey: String?, onComplete: @escaping (Result) -> Void) + func onSubmitButtonPressed(_ viewContext: ViewContext) func error(for: AddressField, validate: String?) -> String? func title(for: AddressField) -> String? func placeholder(for: AddressField) -> String? @@ -25,7 +25,7 @@ protocol CreditCardFormViewModelProtocol { func contentType(for: AddressField) -> UITextContentType } -extension CreditCardFormViewModelProtocol { +extension CreditCardPaymentViewModelProtocol { func isSubmitButtonEnabled(_ viewContext: ViewContext) -> Bool { addressFields.allSatisfy { error(for: $0, validate: viewContext[$0]) == nil diff --git a/OmiseSDK/Sources/Views/ToDelete/PaymentCreatorController.swift b/OmiseSDK/Sources/Views/ToDelete/PaymentCreatorController.swift index ca8f1142..70dd66a4 100644 --- a/OmiseSDK/Sources/Views/ToDelete/PaymentCreatorController.swift +++ b/OmiseSDK/Sources/Views/ToDelete/PaymentCreatorController.swift @@ -57,7 +57,7 @@ public class PaymentCreatorController: UINavigationController { /// Defaults to `true`. public var handleErrors = true - /// Delegate to receive CreditCardFormController result. + /// Delegate to receive CreditCardPaymentController result. // public weak var paymentDelegate: PaymentCreatorControllerDelegate? var client: Client? { @@ -90,7 +90,7 @@ public class PaymentCreatorController: UINavigationController { } } -// /// Factory method for creating CreditCardFormController with given public key. +// /// Factory method for creating CreditCardPaymentController with given public key. // /// - parameter publicKey: Omise public key. // public static func makePaymentCreatorControllerWith( // publicKey: String, diff --git a/OmiseSDK/Sources/Views/ToDelete/PaymentUI.swift b/OmiseSDK/Sources/Views/ToDelete/PaymentUI.swift index bb40de2c..9288bfec 100644 --- a/OmiseSDK/Sources/Views/ToDelete/PaymentUI.swift +++ b/OmiseSDK/Sources/Views/ToDelete/PaymentUI.swift @@ -74,19 +74,19 @@ internal class PaymentCreatorFlowSession { } } -extension PaymentCreatorFlowSession: CreditCardFormViewControllerDelegate { - func creditCardFormViewController(_ controller: CreditCardFormViewController, didSucceedWithToken token: Token) { - delegate?.paymentCreatorFlowSession(self, didCreateToken: token) - } - - func creditCardFormViewController(_ controller: CreditCardFormViewController, didFailWithError error: Error) { - delegate?.paymentCreatorFlowSession(self, didFailWithError: error) - } - - func creditCardFormViewControllerDidCancel(_ controller: CreditCardFormViewController) { - // Intentionally empty (SonarCloud warning fix) - } -} +// extension PaymentCreatorFlowSession: CreditCardPaymentControllerDelegate { +// func creditCardFormViewController(_ controller: CreditCardPaymentController, didSucceedWithToken token: Token) { +// delegate?.paymentCreatorFlowSession(self, didCreateToken: token) +// } +// +// func creditCardFormViewController(_ controller: CreditCardPaymentController, didFailWithError error: Error) { +// delegate?.paymentCreatorFlowSession(self, didFailWithError: error) +// } +// +// func creditCardFormViewControllerDidCancel(_ controller: CreditCardPaymentController) { +// // Intentionally empty (SonarCloud warning fix) +// } +// } protocol PaymentSourceChooser: AnyObject { var flowSession: PaymentCreatorFlowSession? { get set } diff --git a/OmiseSDKTests/ClientTests.swift b/OmiseSDKTests/ClientTests.swift index e7d89d65..a43e2c43 100644 --- a/OmiseSDKTests/ClientTests.swift +++ b/OmiseSDKTests/ClientTests.swift @@ -48,7 +48,7 @@ class ClientTests: XCTestCase { /// Testing if `Client` generates URLRequest with correct HTTP body to perform API request func testCreateTokenURLRequest() throws { let expectation = self.expectation(description: "Create Token Mockup Callback") - let cardPayload: CreateTokenPayload.Card = try sampleFromJSONBy(.card) + let cardPayload = CreateTokenPayload(card: try sampleFromJSONBy(.card)) let networkMockup = NetworkMockup { [cardPayload] urlRequest in defer { expectation.fulfill() } @@ -57,7 +57,7 @@ class ClientTests: XCTestCase { if let data = urlRequest.httpBody, let jsonString = String(data: data, encoding: .utf8) { do { let decodedCardPayload: CreateTokenPayload = try parse(jsonString: jsonString) - XCTAssertEqual(cardPayload, decodedCardPayload.card) + XCTAssertEqual(cardPayload, decodedCardPayload) } catch { XCTFail("Unable to decode payload from encoded JSON string") } diff --git a/QuickStart.playground/Pages/Credit Card Form.xcplaygroundpage/Contents.swift b/QuickStart.playground/Pages/Credit Card Form.xcplaygroundpage/Contents.swift index d0e04f45..7d575f55 100644 --- a/QuickStart.playground/Pages/Credit Card Form.xcplaygroundpage/Contents.swift +++ b/QuickStart.playground/Pages/Credit Card Form.xcplaygroundpage/Contents.swift @@ -24,11 +24,11 @@ PlaygroundPage.current.needsIndefiniteExecution = true /*: implement-delegate - The form will automatically tokenizes credit card data for you as the user click on the submit button. To receive the resulting token data, implement the `CreditCardFormDelegate` methods on your view controller. + The form will automatically tokenizes credit card data for you as the user click on the submit button. To receive the resulting token data, implement the `CreditCardPaymentDelegate` methods on your view controller. */ -extension CheckoutViewController: CreditCardFormViewControllerDelegate { - public func creditCardFormViewController(_ controller: CreditCardFormViewController, didSucceedWithToken token: Token) { +extension CheckoutViewController: CreditCardPaymentControllerDelegate { + public func creditCardFormViewController(_ controller: CreditCardPaymentController, didSucceedWithToken token: Token) { dismiss(animated: true, completion: nil) print("token created: \(token.id )") @@ -37,7 +37,7 @@ extension CheckoutViewController: CreditCardFormViewControllerDelegate { } - public func creditCardFormViewController(_ controller: CreditCardFormViewController, didFailWithError error: Error) { + public func creditCardFormViewController(_ controller: CreditCardPaymentController, didFailWithError error: Error) { dismiss(animated: true, completion: nil) print("error: \(error)") @@ -46,14 +46,14 @@ extension CheckoutViewController: CreditCardFormViewControllerDelegate { } - public func creditCardFormViewControllerDidCancel(_ controller: CreditCardFormViewController) { + public func creditCardFormViewControllerDidCancel(_ controller: CreditCardPaymentController) { dismiss(animated: true, completion: nil) } } extension CheckoutViewController: CheckoutViewControllerDelegate { public func checkoutViewControllerDidTapCheckout(_ checkoutViewController: CheckoutViewController) { - let creditCardForm = CreditCardFormViewController.makeCreditCardFormViewController(withPublicKey: publicKey) + let creditCardForm = CreditCardPaymentController.makeCreditCardPaymentController(withPublicKey: publicKey) creditCardForm.delegate = self let navigationController = UINavigationController(rootViewController: creditCardForm) diff --git a/README.md b/README.md index bccd1e7e..a21ff04c 100644 --- a/README.md +++ b/README.md @@ -145,7 +145,7 @@ you can easily integrate into your application. #### Card form -The `CreditCardFormViewController` provides a pre-made card form and will automatically +The `CreditCardPaymentController` provides a pre-made card form and will automatically [tokenize card information](https://docs.opn.ooo/security-best-practices) for you. You only need to implement two delegate methods and a way to display the form. @@ -159,8 +159,8 @@ import OmiseSDK // at the top of the file class ViewController: UIViewController { private let publicKey = "pkey_test_123" - @IBAction func displayCreditCardForm() { - let creditCardView = CreditCardFormViewController.makeCreditCardFormViewController(withPublicKey: publicKey) + @IBAction func displayCreditCardPayment() { + let creditCardView = CreditCardPaymentController.makeCreditCardPaymentController(withPublicKey: publicKey) creditCardView.delegate = self creditCardView.handleErrors = true @@ -172,15 +172,15 @@ class ViewController: UIViewController { Then implement the delegate to receive the `Token` object after user has entered the card data: ```swift -extension ViewController: CreditCardFormViewControllerDelegate { - func creditCardFormViewController(_ controller: CreditCardFormViewController, didSucceedWithToken token: Token) { - dismissCreditCardForm() +extension ViewController: CreditCardPaymentControllerDelegate { + func creditCardFormViewController(_ controller: CreditCardPaymentController, didSucceedWithToken token: Token) { + dismissCreditCardPayment() // Sends `Token` to your server to create a charge, or a customer object. } - func creditCardFormViewController(_ controller: CreditCardFormViewController, didFailWithError error: Error) { - dismissCreditCardForm() + func creditCardFormViewController(_ controller: CreditCardPaymentController, didFailWithError error: Error) { + dismissCreditCardPayment() // Only important if we set `handleErrors = false`. // You can send errors to a logging service, or display them to the user here. @@ -192,8 +192,8 @@ Alternatively, you can also push the view controller onto a `UINavigationControl as follows: ```swift -@IBAction func displayCreditCardForm() { - let creditCardView = CreditCardFormViewController.makeCreditCardFormViewController(publicKey) +@IBAction func displayCreditCardPayment() { + let creditCardView = CreditCardPaymentController.makeCreditCardPaymentController(publicKey) creditCardView.delegate = self creditCardView.handleErrors = true @@ -204,14 +204,14 @@ as follows: ##### Use card form in storyboard -`CreditCardFormViewController` comes with built-in storyboard support. You can use `CreditCardFormViewController` in your storybard by using `Storyboard Reference`. Drag the `Storyboard Reference` object onto your canvas and set its bundle identifier to `co.omise.OmiseSDK` and Storyboard to `OmiseSDK`. You can either leave `Referenced ID` empty or use `CreditCardFormController` as a `Referenced ID` -You can setup `CreditCardFormViewController` in `UIViewController.prepare(for:sender:)` method +`CreditCardPaymentController` comes with built-in storyboard support. You can use `CreditCardPaymentController` in your storybard by using `Storyboard Reference`. Drag the `Storyboard Reference` object onto your canvas and set its bundle identifier to `co.omise.OmiseSDK` and Storyboard to `OmiseSDK`. You can either leave `Referenced ID` empty or use `CreditCardPaymentController` as a `Referenced ID` +You can setup `CreditCardPaymentController` in `UIViewController.prepare(for:sender:)` method ```swift override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if segue.identifier == "PresentCreditFormWithModal", let creditCardFormNavigationController = segue.destination as? UINavigationController, - let creditCardFormViewController = creditCardFormNavigationController.topViewController as? CreditCardFormViewController { + let creditCardFormViewController = creditCardFormNavigationController.topViewController as? CreditCardPaymentController { creditCardFormViewController.publicKey = publicKey creditCardFormViewController.handleErrors = true creditCardFormViewController.delegate = self @@ -324,7 +324,7 @@ self.present(handlerController, animated: true, completion: nil) ##### Use `OmiseAuthorizingPaymentViewController` in storyboard -`OmiseAuthorizingPaymentViewController` also comes with built-in storyboard support such as `CreditCardFormViewController`. You can use `OmiseAuthorizingPaymentViewController` in your storyboard by using `Storyboard Reference`. Drag `Storyboard Reference` object onto your canvas, set its bundle identifier to `co.omise.OmiseSDK` and storyboard to `OmiseSDK`, then use `DefaultAuthorizingPaymentViewController` as a `Referenced ID`. +`OmiseAuthorizingPaymentViewController` also comes with built-in storyboard support such as `CreditCardPaymentController`. You can use `OmiseAuthorizingPaymentViewController` in your storyboard by using `Storyboard Reference`. Drag `Storyboard Reference` object onto your canvas, set its bundle identifier to `co.omise.OmiseSDK` and storyboard to `OmiseSDK`, then use `DefaultAuthorizingPaymentViewController` as a `Referenced ID`. You can setup `OmiseAuthorizingPaymentViewController` in `UIViewController.prepare(for:sender:)` method ```swift override func prepare(for segue: UIStoryboardSegue, sender: Any?) { diff --git a/dev.xcodeproj/project.pbxproj b/dev.xcodeproj/project.pbxproj index a85db9b4..332dbf53 100644 --- a/dev.xcodeproj/project.pbxproj +++ b/dev.xcodeproj/project.pbxproj @@ -67,9 +67,9 @@ 75405AA42A27F5D3008C21F6 /* AtomePaymentViewContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0B52A1A5F020038FA54 /* AtomePaymentViewContext.swift */; }; 75405AA52A27F5D3008C21F6 /* AtomePaymentViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0B32A1A5EAD0038FA54 /* AtomePaymentViewModelProtocol.swift */; }; 75405AA82A27F97E008C21F6 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 75405AA62A27F97E008C21F6 /* Localizable.strings */; }; - 756C8F1E2A40693B00D53059 /* CreditCardFormViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 756C8F1D2A40693B00D53059 /* CreditCardFormViewModelProtocol.swift */; }; - 756C8F202A40694000D53059 /* CreditCardFormViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 756C8F1F2A40694000D53059 /* CreditCardFormViewModel.swift */; }; - 756C8F222A40694F00D53059 /* CreditCardFormViewContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 756C8F212A40694F00D53059 /* CreditCardFormViewContext.swift */; }; + 756C8F1E2A40693B00D53059 /* CreditCardPaymentViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 756C8F1D2A40693B00D53059 /* CreditCardPaymentViewModelProtocol.swift */; }; + 756C8F202A40694000D53059 /* CreditCardPaymentViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 756C8F1F2A40694000D53059 /* CreditCardPaymentViewModel.swift */; }; + 756C8F222A40694F00D53059 /* CreditCardPaymentViewContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 756C8F212A40694F00D53059 /* CreditCardPaymentViewContext.swift */; }; 756C8F262A40698600D53059 /* TextFieldView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 756C8F252A40698600D53059 /* TextFieldView.swift */; }; 757B0A742AD71E3100DEAE8F /* OmiseUnitTestKit in Frameworks */ = {isa = PBXBuildFile; productRef = 757B0A732AD71E3100DEAE8F /* OmiseUnitTestKit */; }; 757B0A752AD71E3100DEAE8F /* OmiseUnitTestKit in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 757B0A732AD71E3100DEAE8F /* OmiseUnitTestKit */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; @@ -139,6 +139,10 @@ 75D13E042B866E040073A831 /* MobileBankingSourceChooserViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3497367254C066F00D05C7B /* MobileBankingSourceChooserViewController.swift */; }; 75D13E0F2B8678530073A831 /* OmiseSwiftUIKit in Frameworks */ = {isa = PBXBuildFile; productRef = 75D13E0E2B8678530073A831 /* OmiseSwiftUIKit */; }; 75D13E102B8678530073A831 /* OmiseSwiftUIKit in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 75D13E0E2B8678530073A831 /* OmiseSwiftUIKit */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; + 75D13E1B2B86FD2D0073A831 /* CCVInfoPopupController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 75D13E192B86FD2D0073A831 /* CCVInfoPopupController.xib */; }; + 75D13E1D2B86FF8C0073A831 /* CreditCardPaymentDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75D13E1C2B86FF8C0073A831 /* CreditCardPaymentDelegate.swift */; }; + 75D13E202B8703F80073A831 /* CreditCardPaymentController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75D13E1E2B8703F70073A831 /* CreditCardPaymentController.swift */; }; + 75D13E212B8703F80073A831 /* CreditCardPaymentController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 75D13E1F2B8703F80073A831 /* CreditCardPaymentController.xib */; }; 75DAD8902A0BB8D80098AF96 /* LocalConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75DAD88F2A0BB8D80098AF96 /* LocalConfig.swift */; }; 75E0EB712B7A904100E3198A /* SourceFlowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75E0EB702B7A904100E3198A /* SourceFlowTests.swift */; }; 75E0EB722B7A962600E3198A /* CreateSourcePayloadTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75B4208D2B78C2120036134D /* CreateSourcePayloadTests.swift */; }; @@ -177,7 +181,6 @@ 8AF5517A213D4C0100D61C98 /* Localizable.stringsdict in Resources */ = {isa = PBXBuildFile; fileRef = 8AF5517C213D4C0100D61C98 /* Localizable.stringsdict */; }; 8AF56E62226878070097CFEE /* CustomCreditCardFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AF56E61226878070097CFEE /* CustomCreditCardFormViewController.swift */; }; 8AF9857121479F38007E18ED /* CCVInfoPopupController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A3150AD2146B6C300A4F429 /* CCVInfoPopupController.swift */; }; - 8AF9857221479F72007E18ED /* CreditCardFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A1D4C651D51B72200C7837C /* CreditCardFormViewController.swift */; }; 8AF985732147CC3D007E18ED /* Error.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8AF985752147CC3D007E18ED /* Error.strings */; }; 986406301CFEA7E4004BCF51 /* CardCVVTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9864062A1CFEA7E4004BCF51 /* CardCVVTextField.swift */; }; 986406311CFEA7E4004BCF51 /* CardExpiryDateTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9864062B1CFEA7E4004BCF51 /* CardExpiryDateTextField.swift */; }; @@ -310,9 +313,9 @@ 75405AA72A27F97E008C21F6 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; 75405AA92A27F985008C21F6 /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Localizable.strings; sourceTree = ""; }; 75405AAA2A27F988008C21F6 /* th */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = th; path = th.lproj/Localizable.strings; sourceTree = ""; }; - 756C8F1D2A40693B00D53059 /* CreditCardFormViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreditCardFormViewModelProtocol.swift; sourceTree = ""; }; - 756C8F1F2A40694000D53059 /* CreditCardFormViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreditCardFormViewModel.swift; sourceTree = ""; }; - 756C8F212A40694F00D53059 /* CreditCardFormViewContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreditCardFormViewContext.swift; sourceTree = ""; }; + 756C8F1D2A40693B00D53059 /* CreditCardPaymentViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreditCardPaymentViewModelProtocol.swift; sourceTree = ""; }; + 756C8F1F2A40694000D53059 /* CreditCardPaymentViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreditCardPaymentViewModel.swift; sourceTree = ""; }; + 756C8F212A40694F00D53059 /* CreditCardPaymentViewContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreditCardPaymentViewContext.swift; sourceTree = ""; }; 756C8F252A40698600D53059 /* TextFieldView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextFieldView.swift; sourceTree = ""; }; 757B0A712AD71D7B00DEAE8F /* OmiseSwiftUIKit */ = {isa = PBXFileReference; lastKnownFileType = text; name = OmiseSwiftUIKit; path = Helpers/OmiseSwiftUIKit; sourceTree = SOURCE_ROOT; }; 757B0A722AD71DCD00DEAE8F /* OmiseUnitTestKit */ = {isa = PBXFileReference; lastKnownFileType = text; name = OmiseUnitTestKit; path = Helpers/OmiseUnitTestKit; sourceTree = SOURCE_ROOT; }; @@ -372,6 +375,10 @@ 75D13DE12B8666C40073A831 /* SelectPaymentMethodDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectPaymentMethodDelegate.swift; sourceTree = ""; }; 75D13DE32B8666CC0073A831 /* SelectSourceTypeDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectSourceTypeDelegate.swift; sourceTree = ""; }; 75D13DE52B8666DB0073A831 /* SelectSourcePaymentDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectSourcePaymentDelegate.swift; sourceTree = ""; }; + 75D13E192B86FD2D0073A831 /* CCVInfoPopupController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CCVInfoPopupController.xib; sourceTree = ""; }; + 75D13E1C2B86FF8C0073A831 /* CreditCardPaymentDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreditCardPaymentDelegate.swift; sourceTree = ""; }; + 75D13E1E2B8703F70073A831 /* CreditCardPaymentController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreditCardPaymentController.swift; sourceTree = ""; }; + 75D13E1F2B8703F80073A831 /* CreditCardPaymentController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CreditCardPaymentController.xib; sourceTree = ""; }; 75DAD88F2A0BB8D80098AF96 /* LocalConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalConfig.swift; sourceTree = ""; }; 75DAD8922A0BC9540098AF96 /* Config.local.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Config.local.plist; sourceTree = ""; }; 75E0EB702B7A904100E3198A /* SourceFlowTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceFlowTests.swift; sourceTree = ""; }; @@ -398,7 +405,6 @@ 75F8C0B62B1F78E300AE78D9 /* PaymentChooserViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentChooserViewControllerTests.swift; sourceTree = ""; }; 8A00FEC21F1DE88600246078 /* README.md */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; tabWidth = 2; }; 8A188BAF1D951E3C00FFF467 /* AuthorizingPaymentViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthorizingPaymentViewController.swift; sourceTree = ""; }; - 8A1D4C651D51B72200C7837C /* CreditCardFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.swift; path = CreditCardFormViewController.swift; sourceTree = ""; tabWidth = 4; }; 8A25E929213CF6F300D48252 /* EContextInformationInputViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EContextInformationInputViewController.swift; sourceTree = ""; }; 8A275CBB21241E4500C5716F /* MainActionButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainActionButton.swift; sourceTree = ""; }; 8A30FB7C214929C900DC09DC /* PaymentCreatorController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentCreatorController.swift; sourceTree = ""; }; @@ -725,6 +731,7 @@ 75D13DF12B866BFC0073A831 /* TextFields */, 75D13DF22B866C070073A831 /* CountryListController */, 8A3150AD2146B6C300A4F429 /* CCVInfoPopupController.swift */, + 75D13E192B86FD2D0073A831 /* CCVInfoPopupController.xib */, 8A275CBB21241E4500C5716F /* MainActionButton.swift */, 756C8F252A40698600D53059 /* TextFieldView.swift */, 75405A802A2633B6008C21F6 /* SpacerView.swift */, @@ -759,8 +766,9 @@ isa = PBXGroup; children = ( 75D13DF42B866C590073A831 /* ViewPresentable */, - 75D13DF52B866C600073A831 /* Delegates */, - 75D13DF62B866C650073A831 /* Select Payment */, + 75D13DF52B866C600073A831 /* Select Payment Delegates */, + 75D13DF62B866C650073A831 /* Select Payment From Lists */, + 75D13DF82B866CA90073A831 /* Atome Payment */, 75D13D5F2B807AC90073A831 /* ChoosePaymentCoordinator.swift */, 751E7BD82B7E5D130031B4A2 /* PaymentMethod.swift */, 75D13DF72B866C900073A831 /* ToDo */, @@ -779,17 +787,17 @@ path = ViewPresentable; sourceTree = ""; }; - 75D13DF52B866C600073A831 /* Delegates */ = { + 75D13DF52B866C600073A831 /* Select Payment Delegates */ = { isa = PBXGroup; children = ( 75D13DE12B8666C40073A831 /* SelectPaymentMethodDelegate.swift */, 75D13DE32B8666CC0073A831 /* SelectSourceTypeDelegate.swift */, 75D13DE52B8666DB0073A831 /* SelectSourcePaymentDelegate.swift */, ); - path = Delegates; + path = "Select Payment Delegates"; sourceTree = ""; }; - 75D13DF62B866C650073A831 /* Select Payment */ = { + 75D13DF62B866C650073A831 /* Select Payment From Lists */ = { isa = PBXGroup; children = ( 75D13DDC2B8658660073A831 /* SelectPaymentPresentableProtocol.swift */, @@ -798,13 +806,12 @@ 75D13DC82B8529790073A831 /* SelectSourceTypePaymentViewModel.swift */, 75D13DCC2B8536B10073A831 /* SelectInstallmentTermsViewModel.swift */, ); - path = "Select Payment"; + path = "Select Payment From Lists"; sourceTree = ""; }; 75D13DF72B866C900073A831 /* ToDo */ = { isa = PBXGroup; children = ( - 75D13DF82B866CA90073A831 /* AtomePaymentController */, 8A25E929213CF6F300D48252 /* EContextInformationInputViewController.swift */, F6614CD5243DB8E7005B656E /* TrueMoneyFormViewController.swift */, 75D13DCF2B85A4240073A831 /* ChooseDuitNowObwBankViewModel.swift */, @@ -816,7 +823,7 @@ path = ToDo; sourceTree = ""; }; - 75D13DF82B866CA90073A831 /* AtomePaymentController */ = { + 75D13DF82B866CA90073A831 /* Atome Payment */ = { isa = PBXGroup; children = ( 75F2A0A42A13B1470038FA54 /* AtomePaymentController.swift */, @@ -824,7 +831,7 @@ 75F2A0B32A1A5EAD0038FA54 /* AtomePaymentViewModelProtocol.swift */, 75405A9B2A266F50008C21F6 /* AtomePaymentViewModel.swift */, ); - path = AtomePaymentController; + path = "Atome Payment"; sourceTree = ""; }; 75D13DFA2B866CF40073A831 /* AuthorizingPaymentViewController */ = { @@ -838,10 +845,12 @@ 75D13DFB2B866D070073A831 /* Credit Card Payment */ = { isa = PBXGroup; children = ( - 8A1D4C651D51B72200C7837C /* CreditCardFormViewController.swift */, - 756C8F1D2A40693B00D53059 /* CreditCardFormViewModelProtocol.swift */, - 756C8F1F2A40694000D53059 /* CreditCardFormViewModel.swift */, - 756C8F212A40694F00D53059 /* CreditCardFormViewContext.swift */, + 75D13E1E2B8703F70073A831 /* CreditCardPaymentController.swift */, + 75D13E1F2B8703F80073A831 /* CreditCardPaymentController.xib */, + 756C8F212A40694F00D53059 /* CreditCardPaymentViewContext.swift */, + 756C8F1F2A40694000D53059 /* CreditCardPaymentViewModel.swift */, + 756C8F1D2A40693B00D53059 /* CreditCardPaymentViewModelProtocol.swift */, + 75D13E1C2B86FF8C0073A831 /* CreditCardPaymentDelegate.swift */, ); path = "Credit Card Payment"; sourceTree = ""; @@ -850,8 +859,8 @@ isa = PBXGroup; children = ( 75D13DF32B866C420073A831 /* ChoosePaymentMethods */, - 75D13DFA2B866CF40073A831 /* AuthorizingPaymentViewController */, 75D13DFB2B866D070073A831 /* Credit Card Payment */, + 75D13DFA2B866CF40073A831 /* AuthorizingPaymentViewController */, ); path = Screens; sourceTree = ""; @@ -1227,6 +1236,8 @@ buildActionMask = 2147483647; files = ( 8A5D59811D5317DD005D3346 /* OmiseSDK.storyboard in Resources */, + 75D13E212B8703F80073A831 /* CreditCardPaymentController.xib in Resources */, + 75D13E1B2B86FD2D0073A831 /* CCVInfoPopupController.xib in Resources */, 75405AA82A27F97E008C21F6 /* Localizable.strings in Resources */, 8A776647214A5FC60029D166 /* NoticeView.xib in Resources */, 2225B3541D0FDD63003EB396 /* Assets.xcassets in Resources */, @@ -1313,6 +1324,7 @@ 75B420612B776D8A0036134D /* APIProtocol.swift in Sources */, 75CFC4D22B73AFD500422A8F /* OmiseSDK.swift in Sources */, 75131F862AC2BD9D008BCB17 /* UIViewController+NavigationBarStyle.swift in Sources */, + 75D13E1D2B86FF8C0073A831 /* CreditCardPaymentDelegate.swift in Sources */, 75B420822B77FAA50036134D /* CreateSourcePayload.swift in Sources */, 8AD391B1230C05BC00383286 /* Colors.swift in Sources */, 75F2A0BB2A1A60630038FA54 /* AtomePaymentViewContext.swift in Sources */, @@ -1323,7 +1335,7 @@ 75D13DA62B83B58B0073A831 /* Source.Payment.swift in Sources */, 75D13D792B833F160073A831 /* ViewAttachable.swift in Sources */, 75D13DD42B8652230073A831 /* SourceType+Helpers.swift in Sources */, - 756C8F1E2A40693B00D53059 /* CreditCardFormViewModelProtocol.swift in Sources */, + 756C8F1E2A40693B00D53059 /* CreditCardPaymentViewModelProtocol.swift in Sources */, 75E0EB9B2B7BD00F00E3198A /* PAN.swift in Sources */, 751E7BD52B7E2F2A0031B4A2 /* SourceType+ViewPresentable.swift in Sources */, 7502CA5F2A31A7D600766E7D /* CountryListViewController.swift in Sources */, @@ -1331,7 +1343,6 @@ 75D13DBB2B83FB470073A831 /* SelectPaymentController.swift in Sources */, 75D13DFD2B866E040073A831 /* InstallmentBankingSourceChooserViewController.swift in Sources */, 75CFC4EE2B7537BC00422A8F /* Client+URLRequest.swift in Sources */, - 8AF9857221479F72007E18ED /* CreditCardFormViewController.swift in Sources */, 75D13DAC2B83B58B0073A831 /* Source.Payment.EContext.swift in Sources */, 75D13D8C2B8385820073A831 /* UIBarButtonItem+Helpers.swift in Sources */, 75E0EBA22B7BD02200E3198A /* Token.Card.swift in Sources */, @@ -1365,6 +1376,7 @@ 75F2A0B92A1A60630038FA54 /* AtomePaymentViewModelProtocol.swift in Sources */, 75D13DD82B86539C0073A831 /* Optional+Helpers.swift in Sources */, 75D13DD22B85A4490073A831 /* ChooseFPXBankViewModel.swift in Sources */, + 75D13E202B8703F80073A831 /* CreditCardPaymentController.swift in Sources */, 75D13DE22B8666C40073A831 /* SelectPaymentMethodDelegate.swift in Sources */, 75D13DAE2B83B58B0073A831 /* Source.Payment.DuitNowOBW.Bank.swift in Sources */, 75405A782A25D327008C21F6 /* String+Helpers.swift in Sources */, @@ -1375,7 +1387,7 @@ 751E7BEA2B7F77120031B4A2 /* Localized+Omise.swift in Sources */, 75D13DA52B83B58B0073A831 /* Source.swift in Sources */, 22445FFC1CF41DD300801D0F /* Globals.swift in Sources */, - 756C8F222A40694F00D53059 /* CreditCardFormViewContext.swift in Sources */, + 756C8F222A40694F00D53059 /* CreditCardPaymentViewContext.swift in Sources */, 751E7BF02B7FBA760031B4A2 /* UIColor+Omise.swift in Sources */, 751E7BF22B7FC90C0031B4A2 /* SourceType+Collections.swift in Sources */, 75D13DE42B8666CC0073A831 /* SelectSourceTypeDelegate.swift in Sources */, @@ -1408,7 +1420,7 @@ 75CFC4CE2B73AF0E00422A8F /* Client.swift in Sources */, 7502CA622A31A7E100766E7D /* CountryListViewModelProtocol.swift in Sources */, 75D13DC12B8400610073A831 /* SelectPaymentMethodViewModel.swift in Sources */, - 756C8F202A40694000D53059 /* CreditCardFormViewModel.swift in Sources */, + 756C8F202A40694000D53059 /* CreditCardPaymentViewModel.swift in Sources */, 75D13D732B833A810073A831 /* TableCellContext.swift in Sources */, 759C7EC42B7DC8270029D555 /* SourceType+Installments.swift in Sources */, 8AEF7804224CABF800787470 /* EContextInformationInputViewController.swift in Sources */, From 8e663ef96e65f09fcb241df5cd78acb518c4abb9 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Thu, 22 Feb 2024 16:42:07 +0700 Subject: [PATCH 138/204] Credit Card ccv popup added --- .../Resources/Base.lproj/OmiseSDK.storyboard | 94 +++--- OmiseSDK/Sources/OmiseSDK.swift | 4 + .../Components/CCVInfoPopupController.swift | 317 ------------------ .../Components/CCVInfoPopupController.xib | 56 ---- .../ClosureBarButtonItem.swift | 0 .../Views/Components/TapGestureHandler.swift | 16 + .../Sources/Views/Helpers/UIColor+Omise.swift | 10 +- .../AuthorizingPaymentViewController.swift | 14 +- .../ChoosePaymentCoordinator.swift | 4 +- ...ontextInformationInputViewController.swift | 16 +- .../ToDo/FPXFormViewController.swift | 12 +- .../ToDo/TrueMoneyFormViewController.swift | 14 +- .../CCVInfoController.swift | 67 ++++ .../Credit Card Payment/CCVInfoController.xib | 62 ++++ .../CreditCardPaymentController.swift | 190 ++++++----- .../CreditCardPaymentController.xib | 41 +-- dev.xcodeproj/project.pbxproj | 22 +- 17 files changed, 359 insertions(+), 580 deletions(-) delete mode 100644 OmiseSDK/Sources/Views/Components/CCVInfoPopupController.swift delete mode 100644 OmiseSDK/Sources/Views/Components/CCVInfoPopupController.xib rename OmiseSDK/Sources/Views/{Helpers => Components}/ClosureBarButtonItem.swift (100%) create mode 100644 OmiseSDK/Sources/Views/Components/TapGestureHandler.swift create mode 100644 OmiseSDK/Sources/Views/Screens/Credit Card Payment/CCVInfoController.swift create mode 100644 OmiseSDK/Sources/Views/Screens/Credit Card Payment/CCVInfoController.xib diff --git a/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard b/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard index 974a5c27..190b9d21 100644 --- a/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard +++ b/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard @@ -33,7 +33,7 @@ - + @@ -87,7 +87,7 @@ - + @@ -114,7 +114,7 @@ - + @@ -141,7 +141,7 @@ - + @@ -168,13 +168,13 @@ - + - + - + @@ -456,7 +456,7 @@ - + @@ -481,7 +481,7 @@ - + @@ -533,7 +533,7 @@ - + @@ -556,13 +556,13 @@ @@ -719,7 +719,7 @@ - + @@ -761,7 +761,7 @@ - + @@ -785,7 +785,7 @@ - + @@ -809,7 +809,7 @@ @@ -1040,7 +1040,7 @@ - + @@ -1063,13 +1063,13 @@ - + @@ -18,6 +18,7 @@ + @@ -81,7 +82,7 @@ - + @@ -107,7 +108,7 @@ - + @@ -155,7 +156,7 @@ - + @@ -176,7 +177,7 @@ - + @@ -197,7 +198,7 @@ - + @@ -218,13 +219,13 @@ - + @@ -395,19 +396,19 @@ - + - + - + - + diff --git a/dev.xcodeproj/project.pbxproj b/dev.xcodeproj/project.pbxproj index 332dbf53..cfc6a7c1 100644 --- a/dev.xcodeproj/project.pbxproj +++ b/dev.xcodeproj/project.pbxproj @@ -67,6 +67,7 @@ 75405AA42A27F5D3008C21F6 /* AtomePaymentViewContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0B52A1A5F020038FA54 /* AtomePaymentViewContext.swift */; }; 75405AA52A27F5D3008C21F6 /* AtomePaymentViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0B32A1A5EAD0038FA54 /* AtomePaymentViewModelProtocol.swift */; }; 75405AA82A27F97E008C21F6 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 75405AA62A27F97E008C21F6 /* Localizable.strings */; }; + 754B78182B8741CD00973B71 /* TapGestureHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 754B78172B8741CD00973B71 /* TapGestureHandler.swift */; }; 756C8F1E2A40693B00D53059 /* CreditCardPaymentViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 756C8F1D2A40693B00D53059 /* CreditCardPaymentViewModelProtocol.swift */; }; 756C8F202A40694000D53059 /* CreditCardPaymentViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 756C8F1F2A40694000D53059 /* CreditCardPaymentViewModel.swift */; }; 756C8F222A40694F00D53059 /* CreditCardPaymentViewContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 756C8F212A40694F00D53059 /* CreditCardPaymentViewContext.swift */; }; @@ -139,7 +140,7 @@ 75D13E042B866E040073A831 /* MobileBankingSourceChooserViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3497367254C066F00D05C7B /* MobileBankingSourceChooserViewController.swift */; }; 75D13E0F2B8678530073A831 /* OmiseSwiftUIKit in Frameworks */ = {isa = PBXBuildFile; productRef = 75D13E0E2B8678530073A831 /* OmiseSwiftUIKit */; }; 75D13E102B8678530073A831 /* OmiseSwiftUIKit in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 75D13E0E2B8678530073A831 /* OmiseSwiftUIKit */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; - 75D13E1B2B86FD2D0073A831 /* CCVInfoPopupController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 75D13E192B86FD2D0073A831 /* CCVInfoPopupController.xib */; }; + 75D13E1B2B86FD2D0073A831 /* CCVInfoController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 75D13E192B86FD2D0073A831 /* CCVInfoController.xib */; }; 75D13E1D2B86FF8C0073A831 /* CreditCardPaymentDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75D13E1C2B86FF8C0073A831 /* CreditCardPaymentDelegate.swift */; }; 75D13E202B8703F80073A831 /* CreditCardPaymentController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75D13E1E2B8703F70073A831 /* CreditCardPaymentController.swift */; }; 75D13E212B8703F80073A831 /* CreditCardPaymentController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 75D13E1F2B8703F80073A831 /* CreditCardPaymentController.xib */; }; @@ -180,7 +181,7 @@ 8AEF7804224CABF800787470 /* EContextInformationInputViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A25E929213CF6F300D48252 /* EContextInformationInputViewController.swift */; }; 8AF5517A213D4C0100D61C98 /* Localizable.stringsdict in Resources */ = {isa = PBXBuildFile; fileRef = 8AF5517C213D4C0100D61C98 /* Localizable.stringsdict */; }; 8AF56E62226878070097CFEE /* CustomCreditCardFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AF56E61226878070097CFEE /* CustomCreditCardFormViewController.swift */; }; - 8AF9857121479F38007E18ED /* CCVInfoPopupController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A3150AD2146B6C300A4F429 /* CCVInfoPopupController.swift */; }; + 8AF9857121479F38007E18ED /* CCVInfoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A3150AD2146B6C300A4F429 /* CCVInfoController.swift */; }; 8AF985732147CC3D007E18ED /* Error.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8AF985752147CC3D007E18ED /* Error.strings */; }; 986406301CFEA7E4004BCF51 /* CardCVVTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9864062A1CFEA7E4004BCF51 /* CardCVVTextField.swift */; }; 986406311CFEA7E4004BCF51 /* CardExpiryDateTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9864062B1CFEA7E4004BCF51 /* CardExpiryDateTextField.swift */; }; @@ -313,6 +314,7 @@ 75405AA72A27F97E008C21F6 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; 75405AA92A27F985008C21F6 /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Localizable.strings; sourceTree = ""; }; 75405AAA2A27F988008C21F6 /* th */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = th; path = th.lproj/Localizable.strings; sourceTree = ""; }; + 754B78172B8741CD00973B71 /* TapGestureHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TapGestureHandler.swift; sourceTree = ""; }; 756C8F1D2A40693B00D53059 /* CreditCardPaymentViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreditCardPaymentViewModelProtocol.swift; sourceTree = ""; }; 756C8F1F2A40694000D53059 /* CreditCardPaymentViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreditCardPaymentViewModel.swift; sourceTree = ""; }; 756C8F212A40694F00D53059 /* CreditCardPaymentViewContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreditCardPaymentViewContext.swift; sourceTree = ""; }; @@ -375,7 +377,7 @@ 75D13DE12B8666C40073A831 /* SelectPaymentMethodDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectPaymentMethodDelegate.swift; sourceTree = ""; }; 75D13DE32B8666CC0073A831 /* SelectSourceTypeDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectSourceTypeDelegate.swift; sourceTree = ""; }; 75D13DE52B8666DB0073A831 /* SelectSourcePaymentDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectSourcePaymentDelegate.swift; sourceTree = ""; }; - 75D13E192B86FD2D0073A831 /* CCVInfoPopupController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CCVInfoPopupController.xib; sourceTree = ""; }; + 75D13E192B86FD2D0073A831 /* CCVInfoController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CCVInfoController.xib; sourceTree = ""; }; 75D13E1C2B86FF8C0073A831 /* CreditCardPaymentDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreditCardPaymentDelegate.swift; sourceTree = ""; }; 75D13E1E2B8703F70073A831 /* CreditCardPaymentController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreditCardPaymentController.swift; sourceTree = ""; }; 75D13E1F2B8703F80073A831 /* CreditCardPaymentController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CreditCardPaymentController.xib; sourceTree = ""; }; @@ -408,7 +410,7 @@ 8A25E929213CF6F300D48252 /* EContextInformationInputViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EContextInformationInputViewController.swift; sourceTree = ""; }; 8A275CBB21241E4500C5716F /* MainActionButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainActionButton.swift; sourceTree = ""; }; 8A30FB7C214929C900DC09DC /* PaymentCreatorController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentCreatorController.swift; sourceTree = ""; }; - 8A3150AD2146B6C300A4F429 /* CCVInfoPopupController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CCVInfoPopupController.swift; sourceTree = ""; }; + 8A3150AD2146B6C300A4F429 /* CCVInfoController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CCVInfoController.swift; sourceTree = ""; }; 8A3C10552159F7FC00BEFD8A /* InvalidCardAPIErrorParsingTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InvalidCardAPIErrorParsingTestCase.swift; sourceTree = ""; }; 8A3C10572159FCE900BEFD8A /* BadRequestAPIErrorParsingTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BadRequestAPIErrorParsingTestCase.swift; sourceTree = ""; }; 8A40DA2A216B53E900749F45 /* Tools.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tools.swift; sourceTree = ""; }; @@ -717,7 +719,6 @@ 75131F852AC2BD9D008BCB17 /* UIViewController+NavigationBarStyle.swift */, 75D13D782B833F160073A831 /* ViewAttachable.swift */, 75D13D6B2B8335850073A831 /* ViewContainer.swift */, - 75D13D892B8382760073A831 /* ClosureBarButtonItem.swift */, 75D13D8B2B8385820073A831 /* UIBarButtonItem+Helpers.swift */, 75D13D762B833C200073A831 /* UITableViewCell+ActivityIndicator.swift */, 75D13D722B833A810073A831 /* TableCellContext.swift */, @@ -730,10 +731,10 @@ children = ( 75D13DF12B866BFC0073A831 /* TextFields */, 75D13DF22B866C070073A831 /* CountryListController */, - 8A3150AD2146B6C300A4F429 /* CCVInfoPopupController.swift */, - 75D13E192B86FD2D0073A831 /* CCVInfoPopupController.xib */, 8A275CBB21241E4500C5716F /* MainActionButton.swift */, 756C8F252A40698600D53059 /* TextFieldView.swift */, + 75D13D892B8382760073A831 /* ClosureBarButtonItem.swift */, + 754B78172B8741CD00973B71 /* TapGestureHandler.swift */, 75405A802A2633B6008C21F6 /* SpacerView.swift */, 8AD391B0230C05BC00383286 /* Colors.swift */, ); @@ -845,6 +846,8 @@ 75D13DFB2B866D070073A831 /* Credit Card Payment */ = { isa = PBXGroup; children = ( + 8A3150AD2146B6C300A4F429 /* CCVInfoController.swift */, + 75D13E192B86FD2D0073A831 /* CCVInfoController.xib */, 75D13E1E2B8703F70073A831 /* CreditCardPaymentController.swift */, 75D13E1F2B8703F80073A831 /* CreditCardPaymentController.xib */, 756C8F212A40694F00D53059 /* CreditCardPaymentViewContext.swift */, @@ -1237,7 +1240,7 @@ files = ( 8A5D59811D5317DD005D3346 /* OmiseSDK.storyboard in Resources */, 75D13E212B8703F80073A831 /* CreditCardPaymentController.xib in Resources */, - 75D13E1B2B86FD2D0073A831 /* CCVInfoPopupController.xib in Resources */, + 75D13E1B2B86FD2D0073A831 /* CCVInfoController.xib in Resources */, 75405AA82A27F97E008C21F6 /* Localizable.strings in Resources */, 8A776647214A5FC60029D166 /* NoticeView.xib in Resources */, 2225B3541D0FDD63003EB396 /* Assets.xcassets in Resources */, @@ -1356,7 +1359,7 @@ 75D13E032B866E040073A831 /* PaymentOptionTableViewCell.swift in Sources */, 756C8F262A40698600D53059 /* TextFieldView.swift in Sources */, 986406341CFEA7E4004BCF51 /* CardNameTextField.swift in Sources */, - 8AF9857121479F38007E18ED /* CCVInfoPopupController.swift in Sources */, + 8AF9857121479F38007E18ED /* CCVInfoController.swift in Sources */, 75D13E012B866E040073A831 /* AdaptableDynamicTableViewController.swift in Sources */, 75E0EB7C2B7B410600E3198A /* Client+NetworkService.swift in Sources */, 75D13D602B807AC90073A831 /* ChoosePaymentCoordinator.swift in Sources */, @@ -1401,6 +1404,7 @@ 75E0EBA32B7BD02200E3198A /* Token.swift in Sources */, 75405A932A26340E008C21F6 /* UIButton+Helpers.swift in Sources */, 751E7BD92B7E5D130031B4A2 /* PaymentMethod.swift in Sources */, + 754B78182B8741CD00973B71 /* TapGestureHandler.swift in Sources */, 75D13DCB2B8531D20073A831 /* Assets.swift in Sources */, 986406321CFEA7E4004BCF51 /* CardNumberTextField.swift in Sources */, 75D13E042B866E040073A831 /* MobileBankingSourceChooserViewController.swift in Sources */, From 3ca53a6e2b703c75190ed7ed7a4d27702ae9457e Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Thu, 22 Feb 2024 17:17:55 +0700 Subject: [PATCH 139/204] Fix CreditCardController --- .../Resources/Base.lproj/OmiseSDK.storyboard | 444 +----------------- OmiseSDK/Sources/OmiseSDK.swift | 8 +- .../TextFields/OmiseTextField.swift | 5 +- .../Atome Payment/AtomePaymentViewModel.swift | 5 +- .../ChoosePaymentCoordinator.swift | 8 +- .../CreditCardPaymentController.swift | 22 +- .../CreditCardPaymentViewModel.swift | 5 +- 7 files changed, 31 insertions(+), 466 deletions(-) diff --git a/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard b/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard index 190b9d21..3e30e90d 100644 --- a/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard +++ b/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard @@ -1,5 +1,5 @@ - + @@ -8,429 +8,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1764,27 +1341,12 @@ - - - - - - - - - - - - - - - @@ -1799,10 +1361,8 @@ - - @@ -1822,11 +1382,9 @@ - - diff --git a/OmiseSDK/Sources/OmiseSDK.swift b/OmiseSDK/Sources/OmiseSDK.swift index 3d295acd..5e3f3c9d 100644 --- a/OmiseSDK/Sources/OmiseSDK.swift +++ b/OmiseSDK/Sources/OmiseSDK.swift @@ -69,7 +69,7 @@ public class OmiseSDK { allowedCardPayment: Bool, delegate: ChoosePaymentMethodDelegate ) -> UINavigationController { - let paymentFlow = ChoosePaymentCoordinator(client: client, amount: amount, currency: currency) + let paymentFlow = ChoosePaymentCoordinator(client: client, amount: amount, currency: currency, currentCountry: country) let viewController = paymentFlow.createChoosePaymentMethodController( allowedPaymentMethods: allowedPaymentMethods, allowedCardPayment: allowedCardPayment, @@ -93,7 +93,7 @@ public class OmiseSDK { currency: String, delegate: ChoosePaymentMethodDelegate ) -> UINavigationController { - let paymentFlow = ChoosePaymentCoordinator(client: client, amount: amount, currency: currency) + let paymentFlow = ChoosePaymentCoordinator(client: client, amount: amount, currency: currency, currentCountry: country) let viewController = paymentFlow.createChoosePaymentMethodController( usePaymentMethodsFromCapability: true, delegate: delegate @@ -113,7 +113,9 @@ public extension OmiseSDK { var latestLoadedCapability: Capability? { client.latestLoadedCapability } /// Country associated with `latestLoadedCapability` - var country: Country? { Country(code: latestLoadedCapability?.countryCode) } + var country: Country? { + Country(code: latestLoadedCapability?.countryCode) + } } private extension OmiseSDK { diff --git a/OmiseSDK/Sources/Views/Components/TextFields/OmiseTextField.swift b/OmiseSDK/Sources/Views/Components/TextFields/OmiseTextField.swift index 6576337e..5cbd0413 100644 --- a/OmiseSDK/Sources/Views/Components/TextFields/OmiseTextField.swift +++ b/OmiseSDK/Sources/Views/Components/TextFields/OmiseTextField.swift @@ -21,7 +21,8 @@ public class OmiseTextField: UITextField { } public var onTextFieldShouldReturn: () -> (Bool) = { return false } - + public var onValueChanged: () -> () = { } + @IBInspectable var borderWidth: CGFloat { get { switch style { @@ -170,7 +171,7 @@ public class OmiseTextField: UITextField { } @objc func textDidChange() { - // Intentionally empty (SonarCloud warning fix) + onValueChanged() } public override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentViewModel.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentViewModel.swift index 353a3d12..76992cc3 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentViewModel.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentViewModel.swift @@ -27,7 +27,7 @@ class AtomePaymentViewModel: AtomePaymentViewModelProtocol, CountryListViewModel // MARK: CountryListViewModelProtocol lazy var countries: [Country] = Country.sortedAll - lazy var selectedCountry: Country? = OmiseSDK.shared.country { + var selectedCountry: Country? { didSet { if let selectedCountry = selectedCountry { onSelectCountry(selectedCountry) @@ -44,9 +44,10 @@ class AtomePaymentViewModel: AtomePaymentViewModelProtocol, CountryListViewModel var headerText = "Atome.header.text".localized() var logoName = "Atome_Big" - init(amount: Int64, delegate: SelectSourcePaymentDelegate?) { + init(amount: Int64, currentCountry: Country?, delegate: SelectSourcePaymentDelegate?) { self.amount = amount self.delegate = delegate + self.selectedCountry = currentCountry } func title(for field: Field) -> String? { diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift index bbdc80f5..d3f8d8ed 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift @@ -4,6 +4,7 @@ class ChoosePaymentCoordinator: ViewAttachable { let client: Client let amount: Int64 let currency: String + let currentCountry: Country? enum ResultState { case cancelled @@ -14,10 +15,11 @@ class ChoosePaymentCoordinator: ViewAttachable { weak var rootViewController: UIViewController? - init(client: Client, amount: Int64, currency: String) { + init(client: Client, amount: Int64, currency: String, currentCountry: Country?) { self.client = client self.amount = amount self.currency = currency + self.currentCountry = currentCountry } /// Creates SelectPaymentController and attach current flow object inside created controller to be deallocated together @@ -93,7 +95,7 @@ class ChoosePaymentCoordinator: ViewAttachable { /// Creates Atome screen and attach current flow object inside created controller to be deallocated together func createAtomeController() -> AtomePaymentController { - let viewModel = AtomePaymentViewModel(amount: amount, delegate: self) + let viewModel = AtomePaymentViewModel(amount: amount, currentCountry: currentCountry, delegate: self) let viewController = AtomePaymentController(viewModel: viewModel) viewController.title = SourceType.atome.localizedTitle return viewController @@ -101,7 +103,7 @@ class ChoosePaymentCoordinator: ViewAttachable { /// Creates Atome screen and attach current flow object inside created controller to be deallocated together func createCreditCardPaymentController() -> CreditCardPaymentController { - let viewModel = CreditCardPaymentViewModel(delegate: self) + let viewModel = CreditCardPaymentViewModel(currentCountry: currentCountry, delegate: self) let viewController = CreditCardPaymentController(nibName: nil, bundle: .omiseSDK) viewController.viewModel = viewModel viewController.title = PaymentMethod.creditCard.localizedTitle diff --git a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift index 90e13314..33e49bf9 100644 --- a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift +++ b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift @@ -68,7 +68,7 @@ public class CreditCardPaymentController: UIViewController { @IBOutlet var expiryDateTextField: CardExpiryDateTextField! @IBOutlet var secureCodeTextField: CardCVVTextField! - var countryInputView = TextFieldView(id: "country") + let countryInputView = TextFieldView(id: "country") @IBOutlet var submitButton: MainActionButton! @@ -170,14 +170,15 @@ public class CreditCardPaymentController: UIViewController { formFields.forEach { $0.inputAccessoryView = formFieldsAccessoryView + $0.onValueChanged = { [weak self] in + self?.updateAccessibilityValue() + } } errorLabels.forEach { $0.textColor = errorMessageTextColor } - formFields.forEach(self.updateAccessibilityValue) - updateSupplementaryUI() configureAccessibility() @@ -199,6 +200,10 @@ public class CreditCardPaymentController: UIViewController { cardNumberTextField.rightView = cardBrandIconImageView secureCodeTextField.rightView = cvvInfoButton secureCodeTextField.rightViewMode = .always + + if let viewModel = viewModel { + bind(to: viewModel) + } } public override func viewWillLayoutSubviews() { @@ -726,7 +731,7 @@ extension CreditCardPaymentController { // MARK: - Accessibility extension CreditCardPaymentController { - @IBAction private func updateAccessibilityValue(_ sender: OmiseTextField) { + @IBAction private func updateAccessibilityValue() { updateSupplementaryUI() } @@ -739,14 +744,9 @@ extension CreditCardPaymentController { $0.adjustsFontForContentSizeCategory = true } - submitButton.titleLabel?.adjustsFontForContentSizeCategory = true + let fields = formFields - let fields = [ - cardNumberTextField, - cardNameTextField, - expiryDateTextField, - secureCodeTextField - ] as [OmiseTextField] + submitButton.titleLabel?.adjustsFontForContentSizeCategory = true // swiftlint:disable:next function_body_length func accessiblityElementAfter( diff --git a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentViewModel.swift b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentViewModel.swift index 6361ca90..9b308aab 100644 --- a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentViewModel.swift +++ b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentViewModel.swift @@ -26,14 +26,15 @@ class CreditCardPaymentViewModel: CreditCardPaymentViewModelProtocol, CountryLis private weak var delegate: CreditCardPaymentDelegate? - init(delegate: CreditCardPaymentDelegate?) { + init(currentCountry: Country?, delegate: CreditCardPaymentDelegate?) { self.delegate = delegate + self.selectedCountry = currentCountry } // MARK: CountryListViewModelProtocol lazy var countries: [Country] = Country.sortedAll - lazy var selectedCountry: Country? = OmiseSDK.shared.country { + var selectedCountry: Country? { didSet { if let selectedCountry = selectedCountry { onSelectCountry(selectedCountry) From c0963b1f8148ed211c56e9b4c5b9fbdbc1384574 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Fri, 23 Feb 2024 02:11:16 +0700 Subject: [PATCH 140/204] New base controller for form type payment information screens --- .../Resources/Base.lproj/OmiseSDK.storyboard | 46 ++--- .../Base/PaymentFormBuilderController.swift | 184 ++++++++++++++++++ dev.xcodeproj/project.pbxproj | 12 ++ 3 files changed, 219 insertions(+), 23 deletions(-) create mode 100644 OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormBuilderController.swift diff --git a/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard b/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard index 3e30e90d..74c470bf 100644 --- a/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard +++ b/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard @@ -110,7 +110,7 @@ - + @@ -133,13 +133,13 @@ @@ -296,7 +296,7 @@ - + @@ -338,7 +338,7 @@ - + @@ -362,7 +362,7 @@ - + @@ -386,7 +386,7 @@ @@ -617,7 +617,7 @@ - + @@ -640,13 +640,13 @@ - + - + - + @@ -1354,10 +1354,10 @@ - + - + diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormBuilderController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormBuilderController.swift new file mode 100644 index 00000000..45c79466 --- /dev/null +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormBuilderController.swift @@ -0,0 +1,184 @@ +import Foundation +import UIKit + +class PaymentFormBuilderController: UIViewController { + struct Style { + var backgroundColorForDisabledNextButton = UIColor(0xE4E7ED) + var backgroundColorForEnabledNextButton = UIColor(0x1957F0) + var textColorForNextButton = UIColor(0xFFFFFF) + var textColor = UIColor(0x3C414D) + var shippingAddressLabelColor = UIColor(0x9B9B9B) + var contentSpacing = CGFloat(18) + var stackSpacing = CGFloat(12) + var inputsSpacing = CGFloat(10) + var nextButtonHeight = CGFloat(47) + } + + var onDidTapSubmitButtonHandler: () -> Void = { } + + @ProxyProperty(\PaymentFormBuilderController.detailsLabel.text) + var details: String? + + @ProxyProperty(\PaymentFormBuilderController.logoImageView.image) + var logoImage: UIImage? + + var style = Style() + + var isSubmitButtonEnabled = false + + // MARK: IU Components to build the form + lazy var logoImageView: UIImageView = { + let imageView = UIImageView() + imageView.contentMode = .scaleAspectFit + return imageView + }() + + lazy var detailsLabel: UILabel = { + let label = UILabel() + label.numberOfLines = 0 + label.textAlignment = .center + label.textColor = style.textColor + label.font = .preferredFont(forTextStyle: .body) + return label + }() + + lazy var submitButton: UIButton = { + let button = MainActionButton() + button.translatesAutoresizingMaskIntoConstraints = false + button.heightAnchor.constraint(equalToConstant: style.nextButtonHeight).isActive = true + button.titleLabel?.adjustsFontForContentSizeCategory = true + + button.defaultBackgroundColor = .omise + button.disabledBackgroundColor = .line + + button.cornerRadius(4) + return button + }() + + lazy var activityIndicator: UIActivityIndicatorView = { + let indicator = UIActivityIndicatorView(style: .white) + indicator.color = UIColor(0x3D404C) + indicator.hidesWhenStopped = true + return indicator + }() + + lazy var scrollView: UIScrollView = { + let scrollView = UIScrollView() + scrollView.showsHorizontalScrollIndicator = false + scrollView.adjustContentInsetOnKeyboardAppear() + return scrollView + }() + + lazy var scrollContentView: UIView = { + let view = UIView() + return view + }() + + lazy var stackView: UIStackView = { + let stackView = UIStackView() + stackView.axis = .vertical + stackView.distribution = .equalSpacing + stackView.alignment = .fill + stackView.spacing = style.stackSpacing + return stackView + }() + + lazy var inputsStackView: UIStackView = { + let stackView = UIStackView() + stackView.axis = .vertical + stackView.distribution = .equalSpacing + stackView.alignment = .fill + stackView.spacing = style.stackSpacing + return stackView + }() + + override func viewDidLoad() { + super.viewDidLoad() + setupViews() + } +} + +// MARK: - To override by child or add delegate or ViewModel? +extension PaymentFormBuilderController { + func setupViews() { + view.backgroundColor = .background + + if #available(iOS 11, *) { + navigationItem.largeTitleDisplayMode = .never + } + view.addSubviewAndFit(scrollView) + scrollView.addSubviewAndFit(scrollContentView) + scrollContentView.addSubviewAndFit(stackView, horizontal: style.contentSpacing) + NSLayoutConstraint.activate([ + scrollContentView.widthAnchor.constraint(equalTo: view.widthAnchor) + ]) + + arrangeSubviews() + + navigationItem.titleView = activityIndicator + view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(hideKeyboard))) + } + + func arrangeSubviews() { + stackView.addArrangedSubview(SpacerView(vertical: 12.0)) + stackView.addArrangedSubview(logoImageView) + stackView.addArrangedSubview(detailsLabel) + stackView.addArrangedSubview(SpacerView(vertical: 12.0)) + stackView.addArrangedSubview(inputsStackView) + stackView.addArrangedSubview(submitButton) + } + + func updateSubmitButtonState() { + self.submitButton.isEnabled = false + } + + func setupSubmitButton(title: String, color: UIColor) { + submitButton.setTitle(title, for: UIControl.State.normal) + submitButton.setTitleColor(color, for: .normal) + submitButton.addTarget(self, action: #selector(onSubmitButtonTapped), for: .touchUpInside) + } + + func removeAllInputs() { + for view in inputsStackView.arrangedSubviews { + inputsStackView.removeArrangedSubview(view) + } + } + + +} + +// MARK: Actions +extension PaymentFormBuilderController { + @objc func hideKeyboard() { + self.view.endEditing(true) + } + + func startActivityIndicator() { + activityIndicator.startAnimating() + scrollContentView.isUserInteractionEnabled = false + submitButton.isEnabled = false + view.tintAdjustmentMode = .dimmed + } + + func stopActivityIndicator() { + activityIndicator.stopAnimating() + scrollContentView.isUserInteractionEnabled = true + updateSubmitButtonState() + view.tintAdjustmentMode = .automatic + } +} + +// MARK: AtomePaymentControllerInterface +extension PaymentFormBuilderController { + @objc func onSubmitButtonTapped() { + guard isSubmitButtonEnabled else { + return + } + + hideKeyboard() + startActivityIndicator() + onDidTapSubmitButtonHandler() + + // TODO: Add error and stop activity processing in PaymentFormBuilderController + } +} diff --git a/dev.xcodeproj/project.pbxproj b/dev.xcodeproj/project.pbxproj index cfc6a7c1..05d46a7c 100644 --- a/dev.xcodeproj/project.pbxproj +++ b/dev.xcodeproj/project.pbxproj @@ -15,6 +15,7 @@ 22E0DBD71D0EBE2E00472C74 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 22E0DBD61D0EBE2E00472C74 /* Assets.xcassets */; }; 731A75D325E3604A002353C0 /* FPXBankChooserViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 731A75D225E3604A002353C0 /* FPXBankChooserViewController.swift */; }; 73F9BA4B25E6053700F55CA8 /* FPXFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73F9BA4A25E6053700F55CA8 /* FPXFormViewController.swift */; }; + 7501265D2B87CB6500ED5E14 /* PaymentFormBuilderController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7501265C2B87CB6500ED5E14 /* PaymentFormBuilderController.swift */; }; 7502CA532A3011A900766E7D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7502CA562A3011A900766E7D /* LaunchScreen.storyboard */; }; 7502CA5F2A31A7D600766E7D /* CountryListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7502CA5E2A31A7D600766E7D /* CountryListViewController.swift */; }; 7502CA602A31A7D600766E7D /* CountryListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7502CA5E2A31A7D600766E7D /* CountryListViewController.swift */; }; @@ -275,6 +276,7 @@ 731A75D225E3604A002353C0 /* FPXBankChooserViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FPXBankChooserViewController.swift; sourceTree = ""; }; 73F9BA4625E50F4700F55CA8 /* AdaptableDynamicTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdaptableDynamicTableViewController.swift; sourceTree = ""; }; 73F9BA4A25E6053700F55CA8 /* FPXFormViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FPXFormViewController.swift; sourceTree = ""; }; + 7501265C2B87CB6500ED5E14 /* PaymentFormBuilderController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentFormBuilderController.swift; sourceTree = ""; }; 7502CA552A3011A900766E7D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 7502CA582A3011B000766E7D /* th */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = th; path = th.lproj/LaunchScreen.strings; sourceTree = ""; }; 7502CA5A2A3011B100766E7D /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/LaunchScreen.strings; sourceTree = ""; }; @@ -538,6 +540,14 @@ path = ExampleApp; sourceTree = ""; }; + 7501265B2B87CB3F00ED5E14 /* Base */ = { + isa = PBXGroup; + children = ( + 7501265C2B87CB6500ED5E14 /* PaymentFormBuilderController.swift */, + ); + path = Base; + sourceTree = ""; + }; 750708E12B790B2400A48DD0 /* Helpers */ = { isa = PBXGroup; children = ( @@ -827,6 +837,7 @@ 75D13DF82B866CA90073A831 /* Atome Payment */ = { isa = PBXGroup; children = ( + 7501265B2B87CB3F00ED5E14 /* Base */, 75F2A0A42A13B1470038FA54 /* AtomePaymentController.swift */, 75F2A0B52A1A5F020038FA54 /* AtomePaymentViewContext.swift */, 75F2A0B32A1A5EAD0038FA54 /* AtomePaymentViewModelProtocol.swift */, @@ -1407,6 +1418,7 @@ 754B78182B8741CD00973B71 /* TapGestureHandler.swift in Sources */, 75D13DCB2B8531D20073A831 /* Assets.swift in Sources */, 986406321CFEA7E4004BCF51 /* CardNumberTextField.swift in Sources */, + 7501265D2B87CB6500ED5E14 /* PaymentFormBuilderController.swift in Sources */, 75D13E042B866E040073A831 /* MobileBankingSourceChooserViewController.swift in Sources */, 75D13DCD2B8536B10073A831 /* SelectInstallmentTermsViewModel.swift in Sources */, 75D13DB02B83B58B0073A831 /* Source.Payment.Address.swift in Sources */, From 25c4a81285e99b50f9288a585cc6ea26df2ba499 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Fri, 23 Feb 2024 02:33:32 +0700 Subject: [PATCH 141/204] AtomeController subclassed of PaymentFormBuilderController --- .../AtomePaymentController.swift | 197 +++--------------- .../Base/PaymentFormBuilderController.swift | 17 +- 2 files changed, 30 insertions(+), 184 deletions(-) diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentController.swift index a8e9cc60..55b48923 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentController.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentController.swift @@ -6,16 +6,10 @@ // Copyright © 2023 Omise. All rights reserved. // -// swiftlint:disable file_length - import Foundation import UIKit -protocol AtomePaymentControllerInterface { - func onSubmitButtonTapped() -} - -class AtomePaymentController: UIViewController { +class AtomePaymentController: PaymentFormBuilderController { struct Style { var backgroundColorForDisabledNextButton = UIColor(0xE4E7ED) var backgroundColorForEnabledNextButton = UIColor(0x1957F0) @@ -39,25 +33,8 @@ class AtomePaymentController: UIViewController { } } } - - private var style = Style() - - private lazy var logoImageView: UIImageView = { - let imageView = UIImageView() - imageView.contentMode = .scaleAspectFit - return imageView - }() - private lazy var detailsLabel: UILabel = { - let label = UILabel() - label.numberOfLines = 0 - label.textAlignment = .center - label.textColor = style.textColor - label.font = .preferredFont(forTextStyle: .body) - return label - }() - - private lazy var shippingAddressLabel: UILabel = { + lazy var shippingAddressLabel: UILabel = { let label = UILabel() label.numberOfLines = 0 label.textAlignment = .left @@ -67,56 +44,6 @@ class AtomePaymentController: UIViewController { return label }() - private lazy var submitButton: UIButton = { - let button = MainActionButton() - button.translatesAutoresizingMaskIntoConstraints = false - button.heightAnchor.constraint(equalToConstant: style.nextButtonHeight).isActive = true - button.titleLabel?.adjustsFontForContentSizeCategory = true - - button.defaultBackgroundColor = .omise - button.disabledBackgroundColor = .line - - button.cornerRadius(4) - return button - }() - - private lazy var activityIndicator: UIActivityIndicatorView = { - let indicator = UIActivityIndicatorView(style: .white) - indicator.color = UIColor(0x3D404C) - indicator.hidesWhenStopped = true - return indicator - }() - - private lazy var scrollView: UIScrollView = { - let scrollView = UIScrollView() - scrollView.showsHorizontalScrollIndicator = false - scrollView.adjustContentInsetOnKeyboardAppear() - return scrollView - }() - - private lazy var scrollContentView: UIView = { - let view = UIView() - return view - }() - - private lazy var stackView: UIStackView = { - let stackView = UIStackView() - stackView.axis = .vertical - stackView.distribution = .equalSpacing - stackView.alignment = .fill - stackView.spacing = style.stackSpacing - return stackView - }() - - private lazy var inputsStackView: UIStackView = { - let stackView = UIStackView() - stackView.axis = .vertical - stackView.distribution = .equalSpacing - stackView.alignment = .fill - stackView.spacing = style.stackSpacing - return stackView - }() - init(viewModel: ViewModel? = nil) { super.init(nibName: nil, bundle: nil) self.viewModel = viewModel @@ -128,66 +55,48 @@ class AtomePaymentController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - setupViews() if let viewModel = viewModel { bind(to: viewModel) } + + didTapSubmitButtonHandler = onSubmitButtonHandler + } + + override func updateSubmitButtonState() { + let isEnabled = viewModel?.isSubmitButtonEnabled(makeViewContext()) ?? false + self.submitButton.isEnabled = isEnabled + isSubmitButtonEnabled = isEnabled } } -// MARK: Setups private extension AtomePaymentController { - func setupViews() { - view.backgroundColor = .background - applyPrimaryColor() - applySecondaryColor() - - if #available(iOS 11, *) { - navigationItem.largeTitleDisplayMode = .never + + func onSubmitButtonHandler() { + let currentContext = makeViewContext() + guard let viewModel = self.viewModel, viewModel.isSubmitButtonEnabled(currentContext) else { + return + } + + hideKeyboard() + startActivityIndicator() + viewModel.onSubmitButtonPressed(currentContext) { [weak self] in + self?.stopActivityIndicator() } - view.addSubviewAndFit(scrollView) - scrollView.addSubviewAndFit(scrollContentView) - scrollContentView.addSubviewAndFit(stackView, horizontal: style.contentSpacing) - NSLayoutConstraint.activate([ - scrollContentView.widthAnchor.constraint(equalTo: view.widthAnchor) - ]) - - stackView.addArrangedSubview(SpacerView(vertical: 12.0)) - stackView.addArrangedSubview(logoImageView) - stackView.addArrangedSubview(detailsLabel) - stackView.addArrangedSubview(SpacerView(vertical: 12.0)) - stackView.addArrangedSubview(inputsStackView) - stackView.addArrangedSubview(submitButton) - - navigationItem.titleView = activityIndicator - view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(hideKeyboard))) } func bind(to viewModel: ViewModel) { guard isViewLoaded else { return } setupInputs(viewModel: viewModel) - setupSubmitButton(viewModel: viewModel) - detailsLabel.text = viewModel.headerText - logoImageView.image = UIImage(omise: viewModel.logoName) + setupSubmitButton(title: viewModel.submitButtonTitle, color: style.textColorForNextButton) + details = viewModel.headerText + logoImage = UIImage(omise: viewModel.logoName) updateSubmitButtonState() applyPrimaryColor() applySecondaryColor() } - func setupSubmitButton(viewModel: ViewModel) { - submitButton.setTitleColor(style.textColorForNextButton, for: .normal) - submitButton.setTitle(viewModel.submitButtonTitle, for: UIControl.State.normal) - submitButton.addTarget(self, action: #selector(onSubmitButtonTapped), for: .touchUpInside) - } - - func removeAllInputs() { - for view in inputsStackView.arrangedSubviews { - inputsStackView.removeArrangedSubview(view) - } - } - func setupInputs(viewModel: ViewModel) { removeAllInputs() @@ -286,24 +195,6 @@ private extension AtomePaymentController { } } } - - @objc func hideKeyboard() { - self.view.endEditing(true) - } - - func startActivityIndicator() { - activityIndicator.startAnimating() - scrollContentView.isUserInteractionEnabled = false - submitButton.isEnabled = false - view.tintAdjustmentMode = .dimmed - } - - func stopActivityIndicator() { - activityIndicator.stopAnimating() - scrollContentView.isUserInteractionEnabled = true - updateSubmitButtonState() - view.tintAdjustmentMode = .automatic - } } // MARK: Non-private for Unit-Testing @@ -330,11 +221,6 @@ extension AtomePaymentController { return context } - func updateSubmitButtonState() { - let isEnabled = viewModel?.isSubmitButtonEnabled(makeViewContext()) ?? false - self.submitButton.isEnabled = isEnabled - } - func updateError(for field: Field) { guard let input = input(for: field) else { return } input.error = viewModel?.error(for: field, validate: input.text) @@ -446,38 +332,3 @@ private extension AtomePaymentController { } } - -// MARK: AtomePaymentControllerInterface -extension AtomePaymentController: AtomePaymentControllerInterface { - @objc func onSubmitButtonTapped() { - let currentContext = makeViewContext() - guard let viewModel = self.viewModel, viewModel.isSubmitButtonEnabled(currentContext) else { - return - } - - hideKeyboard() - startActivityIndicator() - viewModel.onSubmitButtonPressed(currentContext) { [weak self] in - self?.stopActivityIndicator() - } - } -} - -/* -#if LIVE_PREVIEW_ENABLED -import SwiftUI -import OmiseSwiftUIKit - -// MARK: Preview -struct AtomePaymentController_Previews: PreviewProvider { - static var previews: some View { - UIKitViewControllerPresentable( - viewController: - AtomePaymentController( - viewModel: AtomePaymentViewModelMockup().applyMockupTitles().applyMockupFields() - ) - ) - } -} -#endif -*/ diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormBuilderController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormBuilderController.swift index 45c79466..060afd18 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormBuilderController.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormBuilderController.swift @@ -14,7 +14,7 @@ class PaymentFormBuilderController: UIViewController { var nextButtonHeight = CGFloat(47) } - var onDidTapSubmitButtonHandler: () -> Void = { } + var didTapSubmitButtonHandler: () -> Void = { } @ProxyProperty(\PaymentFormBuilderController.detailsLabel.text) var details: String? @@ -96,6 +96,10 @@ class PaymentFormBuilderController: UIViewController { super.viewDidLoad() setupViews() } + + func updateSubmitButtonState() { + self.submitButton.isEnabled = false + } } // MARK: - To override by child or add delegate or ViewModel? @@ -128,10 +132,6 @@ extension PaymentFormBuilderController { stackView.addArrangedSubview(submitButton) } - func updateSubmitButtonState() { - self.submitButton.isEnabled = false - } - func setupSubmitButton(title: String, color: UIColor) { submitButton.setTitle(title, for: UIControl.State.normal) submitButton.setTitleColor(color, for: .normal) @@ -143,8 +143,6 @@ extension PaymentFormBuilderController { inputsStackView.removeArrangedSubview(view) } } - - } // MARK: Actions @@ -168,7 +166,6 @@ extension PaymentFormBuilderController { } } -// MARK: AtomePaymentControllerInterface extension PaymentFormBuilderController { @objc func onSubmitButtonTapped() { guard isSubmitButtonEnabled else { @@ -177,8 +174,6 @@ extension PaymentFormBuilderController { hideKeyboard() startActivityIndicator() - onDidTapSubmitButtonHandler() - - // TODO: Add error and stop activity processing in PaymentFormBuilderController + didTapSubmitButtonHandler() } } From 0109d3ec8b931d53b5e3f36d3901e4f7998a6eac Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Fri, 23 Feb 2024 16:00:39 +0700 Subject: [PATCH 142/204] Define 2 base classes to build payment form view controllers --- ...wift => AtomeFormPaymentViewContext.swift} | 12 +---- ....swift => AtomeFormPaymentViewModel.swift} | 10 +--- ...> AtomeFormPaymentViewModelProtocol.swift} | 14 ++--- ...swift => AtomePaymentFormController.swift} | 16 +++--- .../Base/PaymentFormController.swift | 5 ++ ...er.swift => PaymentMarkupController.swift} | 13 +++-- .../ChoosePaymentCoordinator.swift | 6 +-- .../Atome/AtomeFormViewControllerTests.swift | 10 ++-- .../Atome/AtomeFormViewModelTests.swift | 12 ++--- .../Mockups/AtomeFormViewContextMockup.swift | 6 +-- .../Mockups/AtomeFormViewModelMockup.swift | 6 +-- dev.xcodeproj/project.pbxproj | 52 ++++++++++--------- 12 files changed, 73 insertions(+), 89 deletions(-) rename OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/{AtomePaymentViewContext.swift => AtomeFormPaymentViewContext.swift} (90%) rename OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/{AtomePaymentViewModel.swift => AtomeFormPaymentViewModel.swift} (93%) rename OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/{AtomePaymentViewModelProtocol.swift => AtomeFormPaymentViewModelProtocol.swift} (84%) rename OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/{AtomePaymentController.swift => AtomePaymentFormController.swift} (96%) create mode 100644 OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormController.swift rename OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/{PaymentFormBuilderController.swift => PaymentMarkupController.swift} (94%) diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentViewContext.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomeFormPaymentViewContext.swift similarity index 90% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentViewContext.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomeFormPaymentViewContext.swift index 9bb4df37..982ac369 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentViewContext.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomeFormPaymentViewContext.swift @@ -1,14 +1,6 @@ -// -// AtomePaymentViewContext.swift -// OmiseSDKUITests -// -// Created by Andrei Solovev on 21/5/23. -// Copyright © 2023 Omise. All rights reserved. -// - import UIKit -struct AtomePaymentViewContext { +struct AtomePaymentFormViewContext { enum Field: String, CaseIterable { case name case email @@ -37,7 +29,7 @@ struct AtomePaymentViewContext { } } -extension AtomePaymentViewContext.Field { +extension AtomePaymentFormViewContext.Field { var isOptional: Bool { switch self { case .name, .email, .street2: return true diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentViewModel.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomeFormPaymentViewModel.swift similarity index 93% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentViewModel.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomeFormPaymentViewModel.swift index 76992cc3..6d013d5b 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentViewModel.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomeFormPaymentViewModel.swift @@ -1,14 +1,6 @@ -// -// AtomePaymentViewModel.swift -// OmiseSDK -// -// Created by Andrei Solovev on 31/5/23. -// Copyright © 2023 Omise. All rights reserved. -// - import Foundation -class AtomePaymentViewModel: AtomePaymentViewModelProtocol, CountryListViewModelProtocol { +class AtomePaymentFormViewModel: AtomePaymentFormViewModelProtocol, CountryListViewModelProtocol { var fields: [Field] = [ .name, .email, diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentViewModelProtocol.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomeFormPaymentViewModelProtocol.swift similarity index 84% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentViewModelProtocol.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomeFormPaymentViewModelProtocol.swift index 1572c09c..11c58b5c 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentViewModelProtocol.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomeFormPaymentViewModelProtocol.swift @@ -1,15 +1,7 @@ -// -// AtomePaymentViewModelProtocol.swift -// OmiseSDKUITests -// -// Created by Andrei Solovev on 21/5/23. -// Copyright © 2023 Omise. All rights reserved. -// - import UIKit -protocol AtomePaymentViewModelProtocol { - typealias ViewContext = AtomePaymentViewContext +protocol AtomePaymentFormViewModelProtocol { + typealias ViewContext = AtomePaymentFormViewContext typealias Field = ViewContext.Field var fields: [Field] { get } var submitButtonTitle: String { get } @@ -27,7 +19,7 @@ protocol AtomePaymentViewModelProtocol { func contentType(for: Field) -> UITextContentType } -extension AtomePaymentViewModelProtocol { +extension AtomePaymentFormViewModelProtocol { func isSubmitButtonEnabled(_ viewContext: ViewContext) -> Bool { Field.allCases.allSatisfy { error(for: $0, validate: viewContext[$0]) == nil diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentFormController.swift similarity index 96% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentController.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentFormController.swift index 55b48923..7b6bcd77 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentController.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentFormController.swift @@ -1,5 +1,5 @@ // -// AtomePaymentController.swift +// AtomePaymentFormController.swift // OmiseSDKUITests // // Created by Andrei Solovev on 16/5/23. @@ -9,7 +9,7 @@ import Foundation import UIKit -class AtomePaymentController: PaymentFormBuilderController { +class AtomePaymentFormController: PaymentMarkupController { struct Style { var backgroundColorForDisabledNextButton = UIColor(0xE4E7ED) var backgroundColorForEnabledNextButton = UIColor(0x1957F0) @@ -22,8 +22,8 @@ class AtomePaymentController: PaymentFormBuilderController { var nextButtonHeight = CGFloat(47) } - typealias ViewModel = AtomePaymentViewModelProtocol - typealias ViewContext = AtomePaymentViewContext + typealias ViewModel = AtomePaymentFormViewModelProtocol + typealias ViewContext = AtomePaymentFormViewContext typealias Field = ViewContext.Field var viewModel: ViewModel? { @@ -70,7 +70,7 @@ class AtomePaymentController: PaymentFormBuilderController { } } -private extension AtomePaymentController { +private extension AtomePaymentFormController { func onSubmitButtonHandler() { let currentContext = makeViewContext() @@ -186,7 +186,7 @@ private extension AtomePaymentController { } // MARK: Actions -private extension AtomePaymentController { +private extension AtomePaymentFormController { func hideErrorIfNil(field: Field) { if let viewModel = viewModel, let input = input(for: field) { let error = viewModel.error(for: field, validate: input.text) @@ -198,7 +198,7 @@ private extension AtomePaymentController { } // MARK: Non-private for Unit-Testing -extension AtomePaymentController { +extension AtomePaymentFormController { func showAllErrors() { guard let viewModel = self.viewModel else { return } @@ -255,7 +255,7 @@ extension AtomePaymentController { } // MARK: Input Processing -private extension AtomePaymentController { +private extension AtomePaymentFormController { func onTextChanged(field: Field) { updateSubmitButtonState() hideErrorIfNil(field: field) diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormController.swift new file mode 100644 index 00000000..dbc63f4d --- /dev/null +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormController.swift @@ -0,0 +1,5 @@ +import UIKit + +class PaymentFormController: PaymentMarkupController { + +} diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormBuilderController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentMarkupController.swift similarity index 94% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormBuilderController.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentMarkupController.swift index 060afd18..39d3676f 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormBuilderController.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentMarkupController.swift @@ -1,7 +1,6 @@ import Foundation import UIKit - -class PaymentFormBuilderController: UIViewController { +class PaymentMarkupController: UIViewController { struct Style { var backgroundColorForDisabledNextButton = UIColor(0xE4E7ED) var backgroundColorForEnabledNextButton = UIColor(0x1957F0) @@ -16,10 +15,10 @@ class PaymentFormBuilderController: UIViewController { var didTapSubmitButtonHandler: () -> Void = { } - @ProxyProperty(\PaymentFormBuilderController.detailsLabel.text) + @ProxyProperty(\PaymentMarkupController.detailsLabel.text) var details: String? - @ProxyProperty(\PaymentFormBuilderController.logoImageView.image) + @ProxyProperty(\PaymentMarkupController.logoImageView.image) var logoImage: UIImage? var style = Style() @@ -103,7 +102,7 @@ class PaymentFormBuilderController: UIViewController { } // MARK: - To override by child or add delegate or ViewModel? -extension PaymentFormBuilderController { +extension PaymentMarkupController { func setupViews() { view.backgroundColor = .background @@ -146,7 +145,7 @@ extension PaymentFormBuilderController { } // MARK: Actions -extension PaymentFormBuilderController { +extension PaymentMarkupController { @objc func hideKeyboard() { self.view.endEditing(true) } @@ -166,7 +165,7 @@ extension PaymentFormBuilderController { } } -extension PaymentFormBuilderController { +extension PaymentMarkupController { @objc func onSubmitButtonTapped() { guard isSubmitButtonEnabled else { return diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift index d3f8d8ed..2249356c 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift @@ -94,9 +94,9 @@ class ChoosePaymentCoordinator: ViewAttachable { } /// Creates Atome screen and attach current flow object inside created controller to be deallocated together - func createAtomeController() -> AtomePaymentController { - let viewModel = AtomePaymentViewModel(amount: amount, currentCountry: currentCountry, delegate: self) - let viewController = AtomePaymentController(viewModel: viewModel) + func createAtomeController() -> AtomePaymentFormController { + let viewModel = AtomePaymentFormViewModel(amount: amount, currentCountry: currentCountry, delegate: self) + let viewController = AtomePaymentFormController(viewModel: viewModel) viewController.title = SourceType.atome.localizedTitle return viewController } diff --git a/OmiseSDKTests/Not Refactored Tests/Atome/AtomeFormViewControllerTests.swift b/OmiseSDKTests/Not Refactored Tests/Atome/AtomeFormViewControllerTests.swift index d81f5ada..878b603a 100644 --- a/OmiseSDKTests/Not Refactored Tests/Atome/AtomeFormViewControllerTests.swift +++ b/OmiseSDKTests/Not Refactored Tests/Atome/AtomeFormViewControllerTests.swift @@ -1,5 +1,5 @@ // -// AtomePaymentControllerTests.swift +// AtomePaymentFormControllerTests.swift // OmiseSDKTests // // Created by Andrei Solovev on 22/5/23. @@ -10,17 +10,17 @@ import XCTest import OmiseUnitTestKit @testable import OmiseSDK -class AtomePaymentControllerTests: XCTestCase { - typealias ViewModel = AtomePaymentViewModelMockup +class AtomePaymentFormControllerTests: XCTestCase { + typealias ViewModel = AtomePaymentFormViewModelMockup // func testBindInputs() { // let viewModel = ViewModel() -// for field in AtomePaymentViewContext.Field.allCases { +// for field in AtomePaymentFormViewContext.Field.allCases { // viewModel.titles[field] = "title: " + field.rawValue // viewModel.errors[field] = "error: " + field.rawValue // } // -// let vc = AtomePaymentController(viewModel: viewModel) +// let vc = AtomePaymentFormController(viewModel: viewModel) // for field in ViewModel.Field.allCases { // XCTAssertEqual(vc.input(for: field)?.title, "title: " + field.rawValue) // XCTAssertEqual(vc.input(for: field)?.error, "") diff --git a/OmiseSDKTests/Not Refactored Tests/Atome/AtomeFormViewModelTests.swift b/OmiseSDKTests/Not Refactored Tests/Atome/AtomeFormViewModelTests.swift index effab476..269c6ce4 100644 --- a/OmiseSDKTests/Not Refactored Tests/Atome/AtomeFormViewModelTests.swift +++ b/OmiseSDKTests/Not Refactored Tests/Atome/AtomeFormViewModelTests.swift @@ -1,5 +1,5 @@ // -// AtomePaymentViewModelTests.swift +// AtomePaymentFormViewModelTests.swift // OmiseSDKTests // // Created by Andrei Solovev on 23/5/23. @@ -10,11 +10,11 @@ import XCTest import OmiseUnitTestKit @testable import OmiseSDK -class AtomePaymentViewModelTests: XCTestCase { - typealias ViewModel = AtomePaymentViewModelMockup +class AtomePaymentFormViewModelTests: XCTestCase { + typealias ViewModel = AtomePaymentFormViewModelMockup - let validCases = TestCaseValueGenerator.validCases(AtomePaymentViewContext.generateMockup) - let invalidCases = TestCaseValueGenerator.invalidCases(AtomePaymentViewContext.generateMockup) - let mostInvalidCases = TestCaseValueGenerator.mostInvalidCases(AtomePaymentViewContext.generateMockup) + let validCases = TestCaseValueGenerator.validCases(AtomePaymentFormViewContext.generateMockup) + let invalidCases = TestCaseValueGenerator.invalidCases(AtomePaymentFormViewContext.generateMockup) + let mostInvalidCases = TestCaseValueGenerator.mostInvalidCases(AtomePaymentFormViewContext.generateMockup) } diff --git a/OmiseSDKTests/Not Refactored Tests/Atome/Mockups/AtomeFormViewContextMockup.swift b/OmiseSDKTests/Not Refactored Tests/Atome/Mockups/AtomeFormViewContextMockup.swift index 7458039f..9a46c76a 100644 --- a/OmiseSDKTests/Not Refactored Tests/Atome/Mockups/AtomeFormViewContextMockup.swift +++ b/OmiseSDKTests/Not Refactored Tests/Atome/Mockups/AtomeFormViewContextMockup.swift @@ -1,5 +1,5 @@ // -// AtomePaymentViewContextMockup.swift +// AtomePaymentFormViewContextMockup.swift // OmiseSDKTests // // Created by Andrei Solovev on 23/5/23. @@ -12,9 +12,9 @@ import OmiseUnitTestKit @testable import OmiseSDK #endif -extension AtomePaymentViewContext { +extension AtomePaymentFormViewContext { static func generateMockup(_ generator: OmiseUnitTestKit.TestCaseValueGenerator) -> Self { - AtomePaymentViewContext(fields: [ + AtomePaymentFormViewContext(fields: [ .name: generator.cases( .valid("Tester"), .valid("", "Name is optional"), diff --git a/OmiseSDKTests/Not Refactored Tests/Atome/Mockups/AtomeFormViewModelMockup.swift b/OmiseSDKTests/Not Refactored Tests/Atome/Mockups/AtomeFormViewModelMockup.swift index bb8a7b6e..07b31597 100644 --- a/OmiseSDKTests/Not Refactored Tests/Atome/Mockups/AtomeFormViewModelMockup.swift +++ b/OmiseSDKTests/Not Refactored Tests/Atome/Mockups/AtomeFormViewModelMockup.swift @@ -1,5 +1,5 @@ // -// AtomePaymentViewModelMockup.swift +// AtomePaymentFormViewModelMockup.swift // OmiseSDKTests // // Created by Andrei Solovev on 23/5/23. @@ -11,7 +11,7 @@ import Foundation @testable import OmiseSDK #endif -class AtomePaymentViewModelMockup: AtomePaymentViewModelProtocol { +class AtomePaymentFormViewModelMockup: AtomePaymentFormViewModelProtocol { var countryListViewModel: CountryListViewModelProtocol = CountryListViewModelMockup() var submitButtonTitle: String = "Next" @@ -51,7 +51,7 @@ class AtomePaymentViewModelMockup: AtomePaymentViewModelProtocol { } } -extension AtomePaymentViewModelMockup { +extension AtomePaymentFormViewModelMockup { @discardableResult func applyMockupTitles() -> Self { self.titles = Field.allCases.reduce(into: [Field: String]()) { list, field in diff --git a/dev.xcodeproj/project.pbxproj b/dev.xcodeproj/project.pbxproj index 05d46a7c..26eea110 100644 --- a/dev.xcodeproj/project.pbxproj +++ b/dev.xcodeproj/project.pbxproj @@ -15,7 +15,8 @@ 22E0DBD71D0EBE2E00472C74 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 22E0DBD61D0EBE2E00472C74 /* Assets.xcassets */; }; 731A75D325E3604A002353C0 /* FPXBankChooserViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 731A75D225E3604A002353C0 /* FPXBankChooserViewController.swift */; }; 73F9BA4B25E6053700F55CA8 /* FPXFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73F9BA4A25E6053700F55CA8 /* FPXFormViewController.swift */; }; - 7501265D2B87CB6500ED5E14 /* PaymentFormBuilderController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7501265C2B87CB6500ED5E14 /* PaymentFormBuilderController.swift */; }; + 7501265D2B87CB6500ED5E14 /* PaymentFormController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7501265C2B87CB6500ED5E14 /* PaymentFormController.swift */; }; + 7501265F2B8893C900ED5E14 /* PaymentMarkupController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7501265E2B8893C900ED5E14 /* PaymentMarkupController.swift */; }; 7502CA532A3011A900766E7D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7502CA562A3011A900766E7D /* LaunchScreen.storyboard */; }; 7502CA5F2A31A7D600766E7D /* CountryListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7502CA5E2A31A7D600766E7D /* CountryListViewController.swift */; }; 7502CA602A31A7D600766E7D /* CountryListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7502CA5E2A31A7D600766E7D /* CountryListViewController.swift */; }; @@ -64,9 +65,9 @@ 75405A942A26340E008C21F6 /* UIButton+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75405A8A2A26340E008C21F6 /* UIButton+Helpers.swift */; }; 75405A952A26343F008C21F6 /* SpacerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75405A802A2633B6008C21F6 /* SpacerView.swift */; }; 75405A992A2634D9008C21F6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 75405A972A2634D9008C21F6 /* Assets.xcassets */; }; - 75405A9C2A266F50008C21F6 /* AtomePaymentViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75405A9B2A266F50008C21F6 /* AtomePaymentViewModel.swift */; }; - 75405AA42A27F5D3008C21F6 /* AtomePaymentViewContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0B52A1A5F020038FA54 /* AtomePaymentViewContext.swift */; }; - 75405AA52A27F5D3008C21F6 /* AtomePaymentViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0B32A1A5EAD0038FA54 /* AtomePaymentViewModelProtocol.swift */; }; + 75405A9C2A266F50008C21F6 /* AtomeFormPaymentViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75405A9B2A266F50008C21F6 /* AtomeFormPaymentViewModel.swift */; }; + 75405AA42A27F5D3008C21F6 /* AtomeFormPaymentViewContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0B52A1A5F020038FA54 /* AtomeFormPaymentViewContext.swift */; }; + 75405AA52A27F5D3008C21F6 /* AtomeFormPaymentViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0B32A1A5EAD0038FA54 /* AtomeFormPaymentViewModelProtocol.swift */; }; 75405AA82A27F97E008C21F6 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 75405AA62A27F97E008C21F6 /* Localizable.strings */; }; 754B78182B8741CD00973B71 /* TapGestureHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 754B78172B8741CD00973B71 /* TapGestureHandler.swift */; }; 756C8F1E2A40693B00D53059 /* CreditCardPaymentViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 756C8F1D2A40693B00D53059 /* CreditCardPaymentViewModelProtocol.swift */; }; @@ -165,10 +166,10 @@ 75F2A09A2A13B0B10038FA54 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 75F2A0992A13B0B10038FA54 /* Preview Assets.xcassets */; }; 75F2A0A62A13B70F0038FA54 /* OmiseTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9864062F1CFEA7E4004BCF51 /* OmiseTextField.swift */; }; 75F2A0B02A1A5BF30038FA54 /* ProxyProperty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0AF2A1A5BF30038FA54 /* ProxyProperty.swift */; }; - 75F2A0B72A1A60630038FA54 /* AtomePaymentController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0A42A13B1470038FA54 /* AtomePaymentController.swift */; }; + 75F2A0B72A1A60630038FA54 /* AtomePaymentFormController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0A42A13B1470038FA54 /* AtomePaymentFormController.swift */; }; 75F2A0B82A1A60630038FA54 /* ProxyProperty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0AF2A1A5BF30038FA54 /* ProxyProperty.swift */; }; - 75F2A0B92A1A60630038FA54 /* AtomePaymentViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0B32A1A5EAD0038FA54 /* AtomePaymentViewModelProtocol.swift */; }; - 75F2A0BB2A1A60630038FA54 /* AtomePaymentViewContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0B52A1A5F020038FA54 /* AtomePaymentViewContext.swift */; }; + 75F2A0B92A1A60630038FA54 /* AtomeFormPaymentViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0B32A1A5EAD0038FA54 /* AtomeFormPaymentViewModelProtocol.swift */; }; + 75F2A0BB2A1A60630038FA54 /* AtomeFormPaymentViewContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0B52A1A5F020038FA54 /* AtomeFormPaymentViewContext.swift */; }; 75F2A0C12A1A84900038FA54 /* UIColor+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0C02A1A84900038FA54 /* UIColor+Helpers.swift */; }; 75F2A0C22A1A87AE0038FA54 /* UIColor+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0C02A1A84900038FA54 /* UIColor+Helpers.swift */; }; 8A188BB01D951E3C00FFF467 /* AuthorizingPaymentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A188BAF1D951E3C00FFF467 /* AuthorizingPaymentViewController.swift */; }; @@ -276,7 +277,8 @@ 731A75D225E3604A002353C0 /* FPXBankChooserViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FPXBankChooserViewController.swift; sourceTree = ""; }; 73F9BA4625E50F4700F55CA8 /* AdaptableDynamicTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdaptableDynamicTableViewController.swift; sourceTree = ""; }; 73F9BA4A25E6053700F55CA8 /* FPXFormViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FPXFormViewController.swift; sourceTree = ""; }; - 7501265C2B87CB6500ED5E14 /* PaymentFormBuilderController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentFormBuilderController.swift; sourceTree = ""; }; + 7501265C2B87CB6500ED5E14 /* PaymentFormController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentFormController.swift; sourceTree = ""; }; + 7501265E2B8893C900ED5E14 /* PaymentMarkupController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentMarkupController.swift; sourceTree = ""; }; 7502CA552A3011A900766E7D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 7502CA582A3011B000766E7D /* th */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = th; path = th.lproj/LaunchScreen.strings; sourceTree = ""; }; 7502CA5A2A3011B100766E7D /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/LaunchScreen.strings; sourceTree = ""; }; @@ -312,7 +314,7 @@ 75405A892A26340E008C21F6 /* UILabel+Helpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UILabel+Helpers.swift"; sourceTree = ""; }; 75405A8A2A26340E008C21F6 /* UIButton+Helpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIButton+Helpers.swift"; sourceTree = ""; }; 75405A972A2634D9008C21F6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - 75405A9B2A266F50008C21F6 /* AtomePaymentViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtomePaymentViewModel.swift; sourceTree = ""; }; + 75405A9B2A266F50008C21F6 /* AtomeFormPaymentViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtomeFormPaymentViewModel.swift; sourceTree = ""; }; 75405AA72A27F97E008C21F6 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; 75405AA92A27F985008C21F6 /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Localizable.strings; sourceTree = ""; }; 75405AAA2A27F988008C21F6 /* th */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = th; path = th.lproj/Localizable.strings; sourceTree = ""; }; @@ -401,10 +403,10 @@ 75E0EBC12B7D1F9E00E3198A /* OmiseError+LocalizedDescription.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OmiseError+LocalizedDescription.swift"; sourceTree = ""; }; 75F2A0902A13B0B00038FA54 /* OmiseSDKUITests.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OmiseSDKUITests.app; sourceTree = BUILT_PRODUCTS_DIR; }; 75F2A0992A13B0B10038FA54 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; - 75F2A0A42A13B1470038FA54 /* AtomePaymentController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtomePaymentController.swift; sourceTree = ""; }; + 75F2A0A42A13B1470038FA54 /* AtomePaymentFormController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtomePaymentFormController.swift; sourceTree = ""; }; 75F2A0AF2A1A5BF30038FA54 /* ProxyProperty.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProxyProperty.swift; sourceTree = ""; }; - 75F2A0B32A1A5EAD0038FA54 /* AtomePaymentViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtomePaymentViewModelProtocol.swift; sourceTree = ""; }; - 75F2A0B52A1A5F020038FA54 /* AtomePaymentViewContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtomePaymentViewContext.swift; sourceTree = ""; }; + 75F2A0B32A1A5EAD0038FA54 /* AtomeFormPaymentViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtomeFormPaymentViewModelProtocol.swift; sourceTree = ""; }; + 75F2A0B52A1A5F020038FA54 /* AtomeFormPaymentViewContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtomeFormPaymentViewContext.swift; sourceTree = ""; }; 75F2A0C02A1A84900038FA54 /* UIColor+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Helpers.swift"; sourceTree = ""; }; 75F8C0B62B1F78E300AE78D9 /* PaymentChooserViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentChooserViewControllerTests.swift; sourceTree = ""; }; 8A00FEC21F1DE88600246078 /* README.md */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; tabWidth = 2; }; @@ -543,7 +545,8 @@ 7501265B2B87CB3F00ED5E14 /* Base */ = { isa = PBXGroup; children = ( - 7501265C2B87CB6500ED5E14 /* PaymentFormBuilderController.swift */, + 7501265E2B8893C900ED5E14 /* PaymentMarkupController.swift */, + 7501265C2B87CB6500ED5E14 /* PaymentFormController.swift */, ); path = Base; sourceTree = ""; @@ -838,10 +841,10 @@ isa = PBXGroup; children = ( 7501265B2B87CB3F00ED5E14 /* Base */, - 75F2A0A42A13B1470038FA54 /* AtomePaymentController.swift */, - 75F2A0B52A1A5F020038FA54 /* AtomePaymentViewContext.swift */, - 75F2A0B32A1A5EAD0038FA54 /* AtomePaymentViewModelProtocol.swift */, - 75405A9B2A266F50008C21F6 /* AtomePaymentViewModel.swift */, + 75F2A0A42A13B1470038FA54 /* AtomePaymentFormController.swift */, + 75F2A0B52A1A5F020038FA54 /* AtomeFormPaymentViewContext.swift */, + 75F2A0B32A1A5EAD0038FA54 /* AtomeFormPaymentViewModelProtocol.swift */, + 75405A9B2A266F50008C21F6 /* AtomeFormPaymentViewModel.swift */, ); path = "Atome Payment"; sourceTree = ""; @@ -1341,7 +1344,7 @@ 75D13E1D2B86FF8C0073A831 /* CreditCardPaymentDelegate.swift in Sources */, 75B420822B77FAA50036134D /* CreateSourcePayload.swift in Sources */, 8AD391B1230C05BC00383286 /* Colors.swift in Sources */, - 75F2A0BB2A1A60630038FA54 /* AtomePaymentViewContext.swift in Sources */, + 75F2A0BB2A1A60630038FA54 /* AtomeFormPaymentViewContext.swift in Sources */, 75D13DB12B83B58B0073A831 /* Source.Payment.FPX.Bank.swift in Sources */, 75B420662B77741E0036134D /* CreateTokenPayload.swift in Sources */, 986406351CFEA7E4004BCF51 /* OmiseTextField.swift in Sources */, @@ -1387,7 +1390,7 @@ 75D13D5E2B8069650073A831 /* UIImage+Omise.swift in Sources */, 75D13DA92B83B58B0073A831 /* Source.Payment.Item.swift in Sources */, 75E0EB9E2B7BD00F00E3198A /* OmiseError.swift in Sources */, - 75F2A0B92A1A60630038FA54 /* AtomePaymentViewModelProtocol.swift in Sources */, + 75F2A0B92A1A60630038FA54 /* AtomeFormPaymentViewModelProtocol.swift in Sources */, 75D13DD82B86539C0073A831 /* Optional+Helpers.swift in Sources */, 75D13DD22B85A4490073A831 /* ChooseFPXBankViewModel.swift in Sources */, 75D13E202B8703F80073A831 /* CreditCardPaymentController.swift in Sources */, @@ -1401,6 +1404,7 @@ 751E7BEA2B7F77120031B4A2 /* Localized+Omise.swift in Sources */, 75D13DA52B83B58B0073A831 /* Source.swift in Sources */, 22445FFC1CF41DD300801D0F /* Globals.swift in Sources */, + 7501265F2B8893C900ED5E14 /* PaymentMarkupController.swift in Sources */, 756C8F222A40694F00D53059 /* CreditCardPaymentViewContext.swift in Sources */, 751E7BF02B7FBA760031B4A2 /* UIColor+Omise.swift in Sources */, 751E7BF22B7FC90C0031B4A2 /* SourceType+Collections.swift in Sources */, @@ -1409,7 +1413,7 @@ 75348D4E29C3FCC70008C8A3 /* Bundle+OmiseSDK.swift in Sources */, 75E0EB9D2B7BD00F00E3198A /* CardBrand.swift in Sources */, 75E0EB9A2B7BD00F00E3198A /* Currency.swift in Sources */, - 75405A9C2A266F50008C21F6 /* AtomePaymentViewModel.swift in Sources */, + 75405A9C2A266F50008C21F6 /* AtomeFormPaymentViewModel.swift in Sources */, 75D13DA72B83B58B0073A831 /* Source.Payment.BarcodeAlipay.swift in Sources */, 75CFC4DB2B73F5AF00422A8F /* NetworkService.swift in Sources */, 75E0EBA32B7BD02200E3198A /* Token.swift in Sources */, @@ -1418,13 +1422,13 @@ 754B78182B8741CD00973B71 /* TapGestureHandler.swift in Sources */, 75D13DCB2B8531D20073A831 /* Assets.swift in Sources */, 986406321CFEA7E4004BCF51 /* CardNumberTextField.swift in Sources */, - 7501265D2B87CB6500ED5E14 /* PaymentFormBuilderController.swift in Sources */, + 7501265D2B87CB6500ED5E14 /* PaymentFormController.swift in Sources */, 75D13E042B866E040073A831 /* MobileBankingSourceChooserViewController.swift in Sources */, 75D13DCD2B8536B10073A831 /* SelectInstallmentTermsViewModel.swift in Sources */, 75D13DB02B83B58B0073A831 /* Source.Payment.Address.swift in Sources */, 75405A8F2A26340E008C21F6 /* UIImage+Helpers.swift in Sources */, F6614CD6243DB8E7005B656E /* TrueMoneyFormViewController.swift in Sources */, - 75F2A0B72A1A60630038FA54 /* AtomePaymentController.swift in Sources */, + 75F2A0B72A1A60630038FA54 /* AtomePaymentFormController.swift in Sources */, 75F2A0C22A1A87AE0038FA54 /* UIColor+Helpers.swift in Sources */, 75D13D6C2B8335850073A831 /* ViewContainer.swift in Sources */, 7509D4DD2A1A9FD70050AB38 /* MainActionButton.swift in Sources */, @@ -1471,9 +1475,9 @@ 75F2A0A62A13B70F0038FA54 /* OmiseTextField.swift in Sources */, 75405A8E2A26340E008C21F6 /* UIView+Helpers.swift in Sources */, 75405A902A26340E008C21F6 /* UIImage+Helpers.swift in Sources */, - 75405AA42A27F5D3008C21F6 /* AtomePaymentViewContext.swift in Sources */, + 75405AA42A27F5D3008C21F6 /* AtomeFormPaymentViewContext.swift in Sources */, 75405A792A25D33F008C21F6 /* String+Helpers.swift in Sources */, - 75405AA52A27F5D3008C21F6 /* AtomePaymentViewModelProtocol.swift in Sources */, + 75405AA52A27F5D3008C21F6 /* AtomeFormPaymentViewModelProtocol.swift in Sources */, 75F2A0C12A1A84900038FA54 /* UIColor+Helpers.swift in Sources */, 75405A8C2A26340E008C21F6 /* UIStackView+Helpers.swift in Sources */, 751E7BE32B7F4DD00031B4A2 /* MainActionButton.swift in Sources */, From 9c546df886e3f7329d41c2a4b1532ceff9ad7700 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Sat, 24 Feb 2024 00:55:25 +0700 Subject: [PATCH 143/204] PaymentFormController cleanup --- .vscode/settings.json | 3 + .../CustomCreditCardFormViewController.swift | 24 +-- .../Views/Components/TextFieldView.swift | 12 +- .../AtomePaymentFormController.swift | 24 +-- .../Base/PaymentFormController.swift | 171 ++++++++++++++++- .../Atome Payment/Base/PaymentFormStyle.swift | 85 +++++++++ .../Base/PaymentInputsFormController.swift | 5 + .../Base/PaymentMarkupController.swift | 178 ------------------ .../ChoosePaymentCoordinator.swift | 4 +- .../CreditCardPaymentController.swift | 12 +- .../Atome/AtomeFormViewControllerTests.swift | 6 +- dev.xcodeproj/project.pbxproj | 20 +- 12 files changed, 316 insertions(+), 228 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormStyle.swift create mode 100644 OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentInputsFormController.swift delete mode 100644 OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentMarkupController.swift diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..5bdb7e50 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "editor.inlayHints.fontSize": 12 +} \ No newline at end of file diff --git a/ExampleApp/Views/CustomCreditCardFormViewController.swift b/ExampleApp/Views/CustomCreditCardFormViewController.swift index 5433b1b7..74b4bee9 100644 --- a/ExampleApp/Views/CustomCreditCardFormViewController.swift +++ b/ExampleApp/Views/CustomCreditCardFormViewController.swift @@ -102,19 +102,19 @@ class CustomCreditCardPaymentController: UIViewController { lowerRowStackView.alignment = .fill lowerRowStackView.spacing = 10 - let stackView = UIStackView(arrangedSubviews: [cardNumberStackView, cardNameStackView, lowerRowStackView]) - stackView.translatesAutoresizingMaskIntoConstraints = false - stackView.axis = .vertical - stackView.distribution = .fill - stackView.alignment = .fill - stackView.spacing = 20 - - view.addSubview(stackView) + let verticalContainerStack = UIStackView(arrangedSubviews: [cardNumberStackView, cardNameStackView, lowerRowStackView]) + verticalContainerStack.translatesAutoresizingMaskIntoConstraints = false + verticalContainerStack.axis = .vertical + verticalContainerStack.distribution = .fill + verticalContainerStack.alignment = .fill + verticalContainerStack.spacing = 20 + + view.addSubview(verticalContainerStack) NSLayoutConstraint.activate([ - stackView.leadingAnchor.constraint(equalTo: view.layoutMarginsGuide.leadingAnchor), - stackView.trailingAnchor.constraint(equalTo: view.layoutMarginsGuide.trailingAnchor), - stackView.topAnchor.constraint(equalTo: view.layoutMarginsGuide.topAnchor, constant: 20), - stackView.bottomAnchor.constraint(lessThanOrEqualTo: view.layoutMarginsGuide.bottomAnchor) + verticalContainerStack.leadingAnchor.constraint(equalTo: view.layoutMarginsGuide.leadingAnchor), + verticalContainerStack.trailingAnchor.constraint(equalTo: view.layoutMarginsGuide.trailingAnchor), + verticalContainerStack.topAnchor.constraint(equalTo: view.layoutMarginsGuide.topAnchor, constant: 20), + verticalContainerStack.bottomAnchor.constraint(lessThanOrEqualTo: view.layoutMarginsGuide.bottomAnchor) ]) } diff --git a/OmiseSDK/Sources/Views/Components/TextFieldView.swift b/OmiseSDK/Sources/Views/Components/TextFieldView.swift index 3549bc6b..89cc2b9a 100644 --- a/OmiseSDK/Sources/Views/Components/TextFieldView.swift +++ b/OmiseSDK/Sources/Views/Components/TextFieldView.swift @@ -45,12 +45,12 @@ class TextFieldView: UIView { return label }() private lazy var contentView: UIStackView = { - let stackView = UIStackView() - stackView.axis = .vertical - stackView.distribution = .equalSpacing - stackView.alignment = .fill - stackView.spacing = 4 - return stackView + let verticalContainerStack = UIStackView() + verticalContainerStack.axis = .vertical + verticalContainerStack.distribution = .equalSpacing + verticalContainerStack.alignment = .fill + verticalContainerStack.spacing = 4 + return verticalContainerStack }() var onTextFieldShouldReturn: () -> (Bool) = { return false } diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentFormController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentFormController.swift index 7b6bcd77..693d7487 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentFormController.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentFormController.swift @@ -1,5 +1,5 @@ // -// AtomePaymentFormController.swift +// AtomePaymentInputsFormController.swift // OmiseSDKUITests // // Created by Andrei Solovev on 16/5/23. @@ -9,17 +9,17 @@ import Foundation import UIKit -class AtomePaymentFormController: PaymentMarkupController { +class AtomePaymentInputsFormController: PaymentFormController { struct Style { var backgroundColorForDisabledNextButton = UIColor(0xE4E7ED) var backgroundColorForEnabledNextButton = UIColor(0x1957F0) var textColorForNextButton = UIColor(0xFFFFFF) var textColor = UIColor(0x3C414D) var shippingAddressLabelColor = UIColor(0x9B9B9B) - var contentSpacing = CGFloat(18) - var stackSpacing = CGFloat(12) - var inputsSpacing = CGFloat(10) - var nextButtonHeight = CGFloat(47) + var containerStackSideSpacer = CGFloat(18) + var verticalContainerStackSpacer = CGFloat(12) + var verticalInputsStackSpacer = CGFloat(10) + var buttoneHeight = CGFloat(47) } typealias ViewModel = AtomePaymentFormViewModelProtocol @@ -60,7 +60,7 @@ class AtomePaymentFormController: PaymentMarkupController { bind(to: viewModel) } - didTapSubmitButtonHandler = onSubmitButtonHandler + onSubmitButtonTappedClosure = onSubmitButtonHandler } override func updateSubmitButtonState() { @@ -70,7 +70,7 @@ class AtomePaymentFormController: PaymentMarkupController { } } -private extension AtomePaymentFormController { +private extension AtomePaymentInputsFormController { func onSubmitButtonHandler() { let currentContext = makeViewContext() @@ -161,7 +161,7 @@ private extension AtomePaymentFormController { return } - detailsLabel.textColor = UIColor.omisePrimary + headerTextLabel.textColor = UIColor.omisePrimary activityIndicator.color = UIColor.omisePrimary inputsStackView.arrangedSubviews.forEach { if let input = $0 as? TextFieldView { @@ -186,7 +186,7 @@ private extension AtomePaymentFormController { } // MARK: Actions -private extension AtomePaymentFormController { +private extension AtomePaymentInputsFormController { func hideErrorIfNil(field: Field) { if let viewModel = viewModel, let input = input(for: field) { let error = viewModel.error(for: field, validate: input.text) @@ -198,7 +198,7 @@ private extension AtomePaymentFormController { } // MARK: Non-private for Unit-Testing -extension AtomePaymentFormController { +extension AtomePaymentInputsFormController { func showAllErrors() { guard let viewModel = self.viewModel else { return } @@ -255,7 +255,7 @@ extension AtomePaymentFormController { } // MARK: Input Processing -private extension AtomePaymentFormController { +private extension AtomePaymentInputsFormController { func onTextChanged(field: Field) { updateSubmitButtonState() hideErrorIfNil(field: field) diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormController.swift index dbc63f4d..3221d688 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormController.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormController.swift @@ -1,5 +1,174 @@ +import Foundation import UIKit -class PaymentFormController: PaymentMarkupController { +class PaymentFormController: UIViewController { + var onSubmitButtonTappedClosure: () -> Void = { } + @ProxyProperty(\PaymentFormController.headerTextLabel.text) + var details: String? + @ProxyProperty(\PaymentFormController.logoImageView.image) + var logoImage: UIImage? + + var style = DefaultPaymentFormStyle() + + var isSubmitButtonEnabled = false { + didSet { + submitButton.isEnabled = isSubmitButtonEnabled + } + } + + // MARK: UI components of the form + lazy var logoImageView: UIImageView = { + let imageView = UIImageView() + imageView.contentMode = .scaleAspectFit + return imageView + }() + + lazy var headerTextLabel: UILabel = { + let label = UILabel() + label.numberOfLines = 0 + label.textAlignment = .center + label.textColor = style.textColor + label.font = .preferredFont(forTextStyle: .body) + return label + }() + + lazy var submitButton: UIButton = { + let button = MainActionButton() + button.translatesAutoresizingMaskIntoConstraints = false + button.heightAnchor.constraint(equalToConstant: style.buttonHeight).isActive = true + button.titleLabel?.adjustsFontForContentSizeCategory = true + + button.defaultBackgroundColor = style.buttonBackgroundColor + button.disabledBackgroundColor = style.buttonDisabledBackgroundColor + button.cornerRadius(style.buttonCornerRadius) + return button + }() + + lazy var activityIndicator: UIActivityIndicatorView = { + let indicator = UIActivityIndicatorView(style: .white) + indicator.color = style.activityIndicatorColor + indicator.hidesWhenStopped = true + return indicator + }() + + lazy var scrollView: UIScrollView = { + let scrollView = UIScrollView() + scrollView.showsHorizontalScrollIndicator = false + scrollView.adjustContentInsetOnKeyboardAppear() + return scrollView + }() + + lazy var scrollContentView: UIView = { + let view = UIView() + return view + }() + + lazy var verticalContainerStack: UIStackView = { + let verticalContainerStack = UIStackView() + verticalContainerStack.axis = .vertical + verticalContainerStack.distribution = .equalSpacing + verticalContainerStack.alignment = .fill + verticalContainerStack.spacing = style.verticalContainerStackSpacer + return verticalContainerStack + }() + + lazy var inputsStackView: UIStackView = { + let verticalContainerStack = UIStackView() + verticalContainerStack.axis = .vertical + verticalContainerStack.distribution = .equalSpacing + verticalContainerStack.alignment = .fill + verticalContainerStack.spacing = style.verticalInputsStackSpacer + return verticalContainerStack + }() + + override func viewDidLoad() { + super.viewDidLoad() + setupViews() + } + + func updateSubmitButtonState() { + self.submitButton.isEnabled = false + } +} + +// MARK: - To override by child or add delegate or ViewModel? +extension PaymentFormController { + func setupViews() { + view.backgroundColor = .background + + if #available(iOS 11, *) { + navigationItem.largeTitleDisplayMode = .never + } + view.addSubviewAndFit(scrollView) + scrollView.addSubviewAndFit(scrollContentView) + scrollContentView.addSubviewAndFit(verticalContainerStack, horizontal: style.containerStackSideSpacer) + NSLayoutConstraint.activate([ + scrollContentView.widthAnchor.constraint(equalTo: view.widthAnchor) + ]) + + arrangeSubviews() + + navigationItem.titleView = activityIndicator + view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(hideKeyboard))) + } + + func arrangeSubviews() { + verticalContainerStack.addArrangedSubview(SpacerView(vertical: style.verticalContainerStackSpacer)) + verticalContainerStack.addArrangedSubview(logoImageView) + verticalContainerStack.addArrangedSubview(headerTextLabel) + verticalContainerStack.addArrangedSubview(SpacerView(vertical: style.verticalContainerStackSpacer)) + verticalContainerStack.addArrangedSubview(inputsStackView) + verticalContainerStack.addArrangedSubview(submitButton) + } + + func setupSubmitButton(title: String, color: UIColor? = nil) { + submitButton.setTitle(title, for: UIControl.State.normal) + submitButton.setTitleColor(color ?? style.buttonTextColor, for: .normal) + submitButton.addTarget(self, action: #selector(onSubmitButtonTapped), for: .touchUpInside) + } + + func removeAllInputs() { + for view in inputsStackView.arrangedSubviews { + inputsStackView.removeArrangedSubview(view) + } + } +} + +// MARK: Activities +extension PaymentFormController { + @objc func hideKeyboard() { + self.view.endEditing(true) + } + + func startActivityIndicator() { + activityIndicator.startAnimating() + scrollContentView.isUserInteractionEnabled = false + submitButton.isEnabled = false + view.tintAdjustmentMode = .dimmed + } + + func stopActivityIndicator() { + activityIndicator.stopAnimating() + scrollContentView.isUserInteractionEnabled = true + updateSubmitButtonState() + view.tintAdjustmentMode = .automatic + } +} + +// MARK: User Interaction +extension PaymentFormController { + @objc func onSubmitButtonTapped() { + guard isSubmitButtonEnabled else { + return + } + + hideKeyboard() + startActivityIndicator() + submitButtonTapped() + } + + func submitButtonTapped() { + onSubmitButtonTappedClosure() + } } diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormStyle.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormStyle.swift new file mode 100644 index 00000000..eab953d0 --- /dev/null +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormStyle.swift @@ -0,0 +1,85 @@ +import Foundation +import UIKit + +/// Payment Form Base styles that could be extended by PaymentFormController's subclasses to add additional UI elements styling +/// by adding extentions to the protocol +protocol PaymentFormStyle { + var buttonBackgroundColor: UIColor { get set } + var buttonDisabledBackgroundColor: UIColor { get set } + var buttonTextColor: UIColor { get set } + var buttonHeight: CGFloat { get set } + var buttonCornerRadius: CGFloat { get set } + + var textColor: UIColor { get set } + var sectionTitleColor: UIColor { get set } + var activityIndicatorColor: UIColor { get set } + + var containerStackSideSpacer: CGFloat { get set } + var verticalContainerStackSpacer: CGFloat { get set } + var verticalInputsStackSpacer: CGFloat { get set } +} + +struct DefaultPaymentFormStyle: PaymentFormStyle {} + +// swiftlint:disable unused_setter_value +extension PaymentFormStyle { + static func create() -> PaymentFormStyle { + return DefaultPaymentFormStyle() + } + + var buttonBackgroundColor: UIColor { + get { return UIColor(0x1A56F0) } + set {} + } + + var buttonDisabledBackgroundColor: UIColor { + get { return UIColor(0xE4E7ED) } + set {} + } + + var buttonTextColor: UIColor { + get { return UIColor(0xFFFFFF) } + set {} + } + + var buttonHeight: CGFloat { + get { return 48 } + set {} + } + + var buttonCornerRadius: CGFloat { + get { return 4 } + set {} + } + + var textColor: UIColor { + get { return UIColor(0x3C414D) } + set {} + } + + var sectionTitleColor: UIColor { + get { return UIColor(0x9B9B9B) } + set {} + } + + var activityIndicatorColor: UIColor { + get { return UIColor(0x3D404C) } + set {} + } + + var containerStackSideSpacer: CGFloat { + get { return CGFloat(18) } + set {} + } + + var verticalContainerStackSpacer: CGFloat { + get { return CGFloat(12) } + set {} + } + + var verticalInputsStackSpacer: CGFloat { + get { return CGFloat(10) } + set {} + } +} +// swiftlint:enable unused_setter_value diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentInputsFormController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentInputsFormController.swift new file mode 100644 index 00000000..82518688 --- /dev/null +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentInputsFormController.swift @@ -0,0 +1,5 @@ +import UIKit + +class PaymentInputsFormController: PaymentFormController { + +} diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentMarkupController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentMarkupController.swift deleted file mode 100644 index 39d3676f..00000000 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentMarkupController.swift +++ /dev/null @@ -1,178 +0,0 @@ -import Foundation -import UIKit -class PaymentMarkupController: UIViewController { - struct Style { - var backgroundColorForDisabledNextButton = UIColor(0xE4E7ED) - var backgroundColorForEnabledNextButton = UIColor(0x1957F0) - var textColorForNextButton = UIColor(0xFFFFFF) - var textColor = UIColor(0x3C414D) - var shippingAddressLabelColor = UIColor(0x9B9B9B) - var contentSpacing = CGFloat(18) - var stackSpacing = CGFloat(12) - var inputsSpacing = CGFloat(10) - var nextButtonHeight = CGFloat(47) - } - - var didTapSubmitButtonHandler: () -> Void = { } - - @ProxyProperty(\PaymentMarkupController.detailsLabel.text) - var details: String? - - @ProxyProperty(\PaymentMarkupController.logoImageView.image) - var logoImage: UIImage? - - var style = Style() - - var isSubmitButtonEnabled = false - - // MARK: IU Components to build the form - lazy var logoImageView: UIImageView = { - let imageView = UIImageView() - imageView.contentMode = .scaleAspectFit - return imageView - }() - - lazy var detailsLabel: UILabel = { - let label = UILabel() - label.numberOfLines = 0 - label.textAlignment = .center - label.textColor = style.textColor - label.font = .preferredFont(forTextStyle: .body) - return label - }() - - lazy var submitButton: UIButton = { - let button = MainActionButton() - button.translatesAutoresizingMaskIntoConstraints = false - button.heightAnchor.constraint(equalToConstant: style.nextButtonHeight).isActive = true - button.titleLabel?.adjustsFontForContentSizeCategory = true - - button.defaultBackgroundColor = .omise - button.disabledBackgroundColor = .line - - button.cornerRadius(4) - return button - }() - - lazy var activityIndicator: UIActivityIndicatorView = { - let indicator = UIActivityIndicatorView(style: .white) - indicator.color = UIColor(0x3D404C) - indicator.hidesWhenStopped = true - return indicator - }() - - lazy var scrollView: UIScrollView = { - let scrollView = UIScrollView() - scrollView.showsHorizontalScrollIndicator = false - scrollView.adjustContentInsetOnKeyboardAppear() - return scrollView - }() - - lazy var scrollContentView: UIView = { - let view = UIView() - return view - }() - - lazy var stackView: UIStackView = { - let stackView = UIStackView() - stackView.axis = .vertical - stackView.distribution = .equalSpacing - stackView.alignment = .fill - stackView.spacing = style.stackSpacing - return stackView - }() - - lazy var inputsStackView: UIStackView = { - let stackView = UIStackView() - stackView.axis = .vertical - stackView.distribution = .equalSpacing - stackView.alignment = .fill - stackView.spacing = style.stackSpacing - return stackView - }() - - override func viewDidLoad() { - super.viewDidLoad() - setupViews() - } - - func updateSubmitButtonState() { - self.submitButton.isEnabled = false - } -} - -// MARK: - To override by child or add delegate or ViewModel? -extension PaymentMarkupController { - func setupViews() { - view.backgroundColor = .background - - if #available(iOS 11, *) { - navigationItem.largeTitleDisplayMode = .never - } - view.addSubviewAndFit(scrollView) - scrollView.addSubviewAndFit(scrollContentView) - scrollContentView.addSubviewAndFit(stackView, horizontal: style.contentSpacing) - NSLayoutConstraint.activate([ - scrollContentView.widthAnchor.constraint(equalTo: view.widthAnchor) - ]) - - arrangeSubviews() - - navigationItem.titleView = activityIndicator - view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(hideKeyboard))) - } - - func arrangeSubviews() { - stackView.addArrangedSubview(SpacerView(vertical: 12.0)) - stackView.addArrangedSubview(logoImageView) - stackView.addArrangedSubview(detailsLabel) - stackView.addArrangedSubview(SpacerView(vertical: 12.0)) - stackView.addArrangedSubview(inputsStackView) - stackView.addArrangedSubview(submitButton) - } - - func setupSubmitButton(title: String, color: UIColor) { - submitButton.setTitle(title, for: UIControl.State.normal) - submitButton.setTitleColor(color, for: .normal) - submitButton.addTarget(self, action: #selector(onSubmitButtonTapped), for: .touchUpInside) - } - - func removeAllInputs() { - for view in inputsStackView.arrangedSubviews { - inputsStackView.removeArrangedSubview(view) - } - } -} - -// MARK: Actions -extension PaymentMarkupController { - @objc func hideKeyboard() { - self.view.endEditing(true) - } - - func startActivityIndicator() { - activityIndicator.startAnimating() - scrollContentView.isUserInteractionEnabled = false - submitButton.isEnabled = false - view.tintAdjustmentMode = .dimmed - } - - func stopActivityIndicator() { - activityIndicator.stopAnimating() - scrollContentView.isUserInteractionEnabled = true - updateSubmitButtonState() - view.tintAdjustmentMode = .automatic - } -} - -extension PaymentMarkupController { - @objc func onSubmitButtonTapped() { - guard isSubmitButtonEnabled else { - return - } - - hideKeyboard() - startActivityIndicator() - didTapSubmitButtonHandler() - } -} diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift index 2249356c..d32c5774 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift @@ -94,9 +94,9 @@ class ChoosePaymentCoordinator: ViewAttachable { } /// Creates Atome screen and attach current flow object inside created controller to be deallocated together - func createAtomeController() -> AtomePaymentFormController { + func createAtomeController() -> AtomePaymentInputsFormController { let viewModel = AtomePaymentFormViewModel(amount: amount, currentCountry: currentCountry, delegate: self) - let viewController = AtomePaymentFormController(viewModel: viewModel) + let viewController = AtomePaymentInputsFormController(viewModel: viewModel) viewController.title = SourceType.atome.localizedTitle return viewController } diff --git a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift index 33e49bf9..e80cebaa 100644 --- a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift +++ b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift @@ -92,12 +92,12 @@ public class CreditCardPaymentController: UIViewController { @IBOutlet var billingStackView: UIStackView! lazy var addressStackView: UIStackView = { - let stackView = UIStackView() - stackView.axis = .vertical - stackView.distribution = .equalSpacing - stackView.alignment = .fill - stackView.spacing = style.billingStackSpacing - return stackView + let verticalContainerStack = UIStackView() + verticalContainerStack.axis = .vertical + verticalContainerStack.distribution = .equalSpacing + verticalContainerStack.alignment = .fill + verticalContainerStack.spacing = style.billingStackSpacing + return verticalContainerStack }() @IBOutlet var requestingIndicatorView: UIActivityIndicatorView! diff --git a/OmiseSDKTests/Not Refactored Tests/Atome/AtomeFormViewControllerTests.swift b/OmiseSDKTests/Not Refactored Tests/Atome/AtomeFormViewControllerTests.swift index 878b603a..05ad5ecc 100644 --- a/OmiseSDKTests/Not Refactored Tests/Atome/AtomeFormViewControllerTests.swift +++ b/OmiseSDKTests/Not Refactored Tests/Atome/AtomeFormViewControllerTests.swift @@ -1,5 +1,5 @@ // -// AtomePaymentFormControllerTests.swift +// AtomePaymentInputsFormControllerTests.swift // OmiseSDKTests // // Created by Andrei Solovev on 22/5/23. @@ -10,7 +10,7 @@ import XCTest import OmiseUnitTestKit @testable import OmiseSDK -class AtomePaymentFormControllerTests: XCTestCase { +class AtomePaymentInputsFormControllerTests: XCTestCase { typealias ViewModel = AtomePaymentFormViewModelMockup // func testBindInputs() { @@ -20,7 +20,7 @@ class AtomePaymentFormControllerTests: XCTestCase { // viewModel.errors[field] = "error: " + field.rawValue // } // -// let vc = AtomePaymentFormController(viewModel: viewModel) +// let vc = AtomePaymentInputsFormController(viewModel: viewModel) // for field in ViewModel.Field.allCases { // XCTAssertEqual(vc.input(for: field)?.title, "title: " + field.rawValue) // XCTAssertEqual(vc.input(for: field)?.error, "") diff --git a/dev.xcodeproj/project.pbxproj b/dev.xcodeproj/project.pbxproj index 26eea110..d93ff058 100644 --- a/dev.xcodeproj/project.pbxproj +++ b/dev.xcodeproj/project.pbxproj @@ -15,8 +15,9 @@ 22E0DBD71D0EBE2E00472C74 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 22E0DBD61D0EBE2E00472C74 /* Assets.xcassets */; }; 731A75D325E3604A002353C0 /* FPXBankChooserViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 731A75D225E3604A002353C0 /* FPXBankChooserViewController.swift */; }; 73F9BA4B25E6053700F55CA8 /* FPXFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73F9BA4A25E6053700F55CA8 /* FPXFormViewController.swift */; }; - 7501265D2B87CB6500ED5E14 /* PaymentFormController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7501265C2B87CB6500ED5E14 /* PaymentFormController.swift */; }; - 7501265F2B8893C900ED5E14 /* PaymentMarkupController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7501265E2B8893C900ED5E14 /* PaymentMarkupController.swift */; }; + 7501265D2B87CB6500ED5E14 /* PaymentInputsFormController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7501265C2B87CB6500ED5E14 /* PaymentInputsFormController.swift */; }; + 7501265F2B8893C900ED5E14 /* PaymentFormController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7501265E2B8893C900ED5E14 /* PaymentFormController.swift */; }; + 750126612B8902A500ED5E14 /* PaymentFormStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 750126602B8902A500ED5E14 /* PaymentFormStyle.swift */; }; 7502CA532A3011A900766E7D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7502CA562A3011A900766E7D /* LaunchScreen.storyboard */; }; 7502CA5F2A31A7D600766E7D /* CountryListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7502CA5E2A31A7D600766E7D /* CountryListViewController.swift */; }; 7502CA602A31A7D600766E7D /* CountryListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7502CA5E2A31A7D600766E7D /* CountryListViewController.swift */; }; @@ -277,8 +278,9 @@ 731A75D225E3604A002353C0 /* FPXBankChooserViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FPXBankChooserViewController.swift; sourceTree = ""; }; 73F9BA4625E50F4700F55CA8 /* AdaptableDynamicTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdaptableDynamicTableViewController.swift; sourceTree = ""; }; 73F9BA4A25E6053700F55CA8 /* FPXFormViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FPXFormViewController.swift; sourceTree = ""; }; - 7501265C2B87CB6500ED5E14 /* PaymentFormController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentFormController.swift; sourceTree = ""; }; - 7501265E2B8893C900ED5E14 /* PaymentMarkupController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentMarkupController.swift; sourceTree = ""; }; + 7501265C2B87CB6500ED5E14 /* PaymentInputsFormController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentInputsFormController.swift; sourceTree = ""; }; + 7501265E2B8893C900ED5E14 /* PaymentFormController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentFormController.swift; sourceTree = ""; }; + 750126602B8902A500ED5E14 /* PaymentFormStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentFormStyle.swift; sourceTree = ""; }; 7502CA552A3011A900766E7D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 7502CA582A3011B000766E7D /* th */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = th; path = th.lproj/LaunchScreen.strings; sourceTree = ""; }; 7502CA5A2A3011B100766E7D /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/LaunchScreen.strings; sourceTree = ""; }; @@ -545,8 +547,9 @@ 7501265B2B87CB3F00ED5E14 /* Base */ = { isa = PBXGroup; children = ( - 7501265E2B8893C900ED5E14 /* PaymentMarkupController.swift */, - 7501265C2B87CB6500ED5E14 /* PaymentFormController.swift */, + 750126602B8902A500ED5E14 /* PaymentFormStyle.swift */, + 7501265E2B8893C900ED5E14 /* PaymentFormController.swift */, + 7501265C2B87CB6500ED5E14 /* PaymentInputsFormController.swift */, ); path = Base; sourceTree = ""; @@ -1404,7 +1407,7 @@ 751E7BEA2B7F77120031B4A2 /* Localized+Omise.swift in Sources */, 75D13DA52B83B58B0073A831 /* Source.swift in Sources */, 22445FFC1CF41DD300801D0F /* Globals.swift in Sources */, - 7501265F2B8893C900ED5E14 /* PaymentMarkupController.swift in Sources */, + 7501265F2B8893C900ED5E14 /* PaymentFormController.swift in Sources */, 756C8F222A40694F00D53059 /* CreditCardPaymentViewContext.swift in Sources */, 751E7BF02B7FBA760031B4A2 /* UIColor+Omise.swift in Sources */, 751E7BF22B7FC90C0031B4A2 /* SourceType+Collections.swift in Sources */, @@ -1422,7 +1425,7 @@ 754B78182B8741CD00973B71 /* TapGestureHandler.swift in Sources */, 75D13DCB2B8531D20073A831 /* Assets.swift in Sources */, 986406321CFEA7E4004BCF51 /* CardNumberTextField.swift in Sources */, - 7501265D2B87CB6500ED5E14 /* PaymentFormController.swift in Sources */, + 7501265D2B87CB6500ED5E14 /* PaymentInputsFormController.swift in Sources */, 75D13E042B866E040073A831 /* MobileBankingSourceChooserViewController.swift in Sources */, 75D13DCD2B8536B10073A831 /* SelectInstallmentTermsViewModel.swift in Sources */, 75D13DB02B83B58B0073A831 /* Source.Payment.Address.swift in Sources */, @@ -1430,6 +1433,7 @@ F6614CD6243DB8E7005B656E /* TrueMoneyFormViewController.swift in Sources */, 75F2A0B72A1A60630038FA54 /* AtomePaymentFormController.swift in Sources */, 75F2A0C22A1A87AE0038FA54 /* UIColor+Helpers.swift in Sources */, + 750126612B8902A500ED5E14 /* PaymentFormStyle.swift in Sources */, 75D13D6C2B8335850073A831 /* ViewContainer.swift in Sources */, 7509D4DD2A1A9FD70050AB38 /* MainActionButton.swift in Sources */, 75E0EBC22B7D1F9E00E3198A /* OmiseError+LocalizedDescription.swift in Sources */, From ae79927b378afd4ad94b5c63186d0f0850439ad9 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Sat, 24 Feb 2024 01:50:39 +0700 Subject: [PATCH 144/204] PaymentInputsFormController base implementatino added --- .../AtomePaymentFormController.swift | 45 +++++++------------ ...wift => AtomePaymentFormViewContext.swift} | 0 ....swift => AtomePaymentFormViewModel.swift} | 7 +++ ...> AtomePaymentFormViewModelProtocol.swift} | 0 .../Base/PaymentFormController.swift | 4 -- .../Atome Payment/Base/PaymentFormStyle.swift | 4 +- .../Base/PaymentInputProtocol.swift | 25 +++++++++++ .../Base/PaymentInputsFormController.swift | 17 ++++++- dev.xcodeproj/project.pbxproj | 36 ++++++++------- 9 files changed, 86 insertions(+), 52 deletions(-) rename OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/{AtomeFormPaymentViewContext.swift => AtomePaymentFormViewContext.swift} (100%) rename OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/{AtomeFormPaymentViewModel.swift => AtomePaymentFormViewModel.swift} (95%) rename OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/{AtomeFormPaymentViewModelProtocol.swift => AtomePaymentFormViewModelProtocol.swift} (100%) create mode 100644 OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentInputProtocol.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentFormController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentFormController.swift index 693d7487..c7dd9166 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentFormController.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentFormController.swift @@ -10,57 +10,43 @@ import Foundation import UIKit class AtomePaymentInputsFormController: PaymentFormController { - struct Style { - var backgroundColorForDisabledNextButton = UIColor(0xE4E7ED) - var backgroundColorForEnabledNextButton = UIColor(0x1957F0) - var textColorForNextButton = UIColor(0xFFFFFF) - var textColor = UIColor(0x3C414D) - var shippingAddressLabelColor = UIColor(0x9B9B9B) - var containerStackSideSpacer = CGFloat(18) - var verticalContainerStackSpacer = CGFloat(12) - var verticalInputsStackSpacer = CGFloat(10) - var buttoneHeight = CGFloat(47) - } - typealias ViewModel = AtomePaymentFormViewModelProtocol typealias ViewContext = AtomePaymentFormViewContext typealias Field = ViewContext.Field - var viewModel: ViewModel? { - didSet { - if let newViewModel = viewModel { - bind(to: newViewModel) - } - } - } - lazy var shippingAddressLabel: UILabel = { let label = UILabel() label.numberOfLines = 0 label.textAlignment = .left - label.textColor = style.shippingAddressLabelColor + label.textColor = style.sectionTitleColor label.font = .preferredFont(forTextStyle: .callout) label.text = "Atome.shippingAddress".localized() return label }() - init(viewModel: ViewModel? = nil) { - super.init(nibName: nil, bundle: nil) - self.viewModel = viewModel + var viewModel: ViewModel? { + didSet { + if let newViewModel = viewModel { + bind(to: newViewModel) + } + } } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } + init(viewModel: ViewModel? = nil) { + super.init(nibName: nil, bundle: nil) + self.viewModel = viewModel + } + override func viewDidLoad() { super.viewDidLoad() if let viewModel = viewModel { bind(to: viewModel) } - - onSubmitButtonTappedClosure = onSubmitButtonHandler } override func updateSubmitButtonState() { @@ -88,7 +74,7 @@ private extension AtomePaymentInputsFormController { func bind(to viewModel: ViewModel) { guard isViewLoaded else { return } setupInputs(viewModel: viewModel) - setupSubmitButton(title: viewModel.submitButtonTitle, color: style.textColorForNextButton) + setupSubmitButton(title: viewModel.submitButtonTitle, color: style.buttonTextColor) details = viewModel.headerText logoImage = UIImage(omise: viewModel.logoName) @@ -97,11 +83,13 @@ private extension AtomePaymentInputsFormController { applySecondaryColor() } + func setupInputs(viewModel: ViewModel) { removeAllInputs() let fields = viewModel.fields for field in fields { + // Shipping Address section header title if field == viewModel.fieldForShippingAddressHeader { inputsStackView.addArrangedSubview(SpacerView(vertical: 1)) inputsStackView.addArrangedSubview(shippingAddressLabel) @@ -109,6 +97,7 @@ private extension AtomePaymentInputsFormController { let input = TextFieldView(id: field.rawValue) inputsStackView.addArrangedSubview(input) + setupInput(input, field: field, isLast: field == fields.last, viewModel: viewModel) if field == .country { @@ -161,8 +150,6 @@ private extension AtomePaymentInputsFormController { return } - headerTextLabel.textColor = UIColor.omisePrimary - activityIndicator.color = UIColor.omisePrimary inputsStackView.arrangedSubviews.forEach { if let input = $0 as? TextFieldView { input.textColor = UIColor.omisePrimary diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomeFormPaymentViewContext.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentFormViewContext.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomeFormPaymentViewContext.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentFormViewContext.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomeFormPaymentViewModel.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentFormViewModel.swift similarity index 95% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomeFormPaymentViewModel.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentFormViewModel.swift index 6d013d5b..dd3f71cf 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomeFormPaymentViewModel.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentFormViewModel.swift @@ -1,5 +1,12 @@ import Foundation +struct AtomeInputField: PaymenFormtInputProtocol { + var next: PaymenFormtInputProtocol? + var title: String + var error: String + var isError: Bool +} + class AtomePaymentFormViewModel: AtomePaymentFormViewModelProtocol, CountryListViewModelProtocol { var fields: [Field] = [ .name, diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomeFormPaymentViewModelProtocol.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentFormViewModelProtocol.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomeFormPaymentViewModelProtocol.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentFormViewModelProtocol.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormController.swift index 3221d688..e0343a64 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormController.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormController.swift @@ -165,10 +165,6 @@ extension PaymentFormController { hideKeyboard() startActivityIndicator() - submitButtonTapped() - } - - func submitButtonTapped() { onSubmitButtonTappedClosure() } } diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormStyle.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormStyle.swift index eab953d0..82f10158 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormStyle.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormStyle.swift @@ -53,7 +53,7 @@ extension PaymentFormStyle { } var textColor: UIColor { - get { return UIColor(0x3C414D) } + get { return .omisePrimary } set {} } @@ -63,7 +63,7 @@ extension PaymentFormStyle { } var activityIndicatorColor: UIColor { - get { return UIColor(0x3D404C) } + get { return .omisePrimary } set {} } diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentInputProtocol.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentInputProtocol.swift new file mode 100644 index 00000000..ebd2cfe5 --- /dev/null +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentInputProtocol.swift @@ -0,0 +1,25 @@ +import Foundation +import UIKit + +protocol PaymenFormtInputProtocol { + var next: PaymenFormtInputProtocol? { get set } + var section: String? { get } // optional + var title: String { get } + var error: String { get } + var isError: Bool { get } + + var contentType: UITextContentType? { get } // optional + var capitalization: UITextAutocapitalizationType { get } // optional + var keyboardType: UIKeyboardType { get } // default asciiCapable + var validatorRegex: String? { get } // optional + var isOptional: Bool { get } // by default false +} + +extension PaymenFormtInputProtocol { + var section: String? { nil } + var contentType: UITextContentType? { nil } + var capitalization: UITextAutocapitalizationType { .none } + var keyboardType: UIKeyboardType { .asciiCapable } + var validatorRegex: String? { nil } + var isOptional: Bool { false } +} diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentInputsFormController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentInputsFormController.swift index 82518688..172571f5 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentInputsFormController.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentInputsFormController.swift @@ -1,5 +1,20 @@ import UIKit -class PaymentInputsFormController: PaymentFormController { +class PaymentInputsFormController: PaymentFormController { + private var fields: [Field: String] = [:] + + init(fields: [Field: String] = [:]) { + self.fields = fields + super.init(nibName: nil, bundle: nil) + } + + required init?(coder: NSCoder) { + super.init(coder: coder) + } + + subscript(field: Field) -> String { + get { fields[field] ?? "" } + set { fields[field] = newValue } + } } diff --git a/dev.xcodeproj/project.pbxproj b/dev.xcodeproj/project.pbxproj index d93ff058..9729bc9a 100644 --- a/dev.xcodeproj/project.pbxproj +++ b/dev.xcodeproj/project.pbxproj @@ -18,6 +18,7 @@ 7501265D2B87CB6500ED5E14 /* PaymentInputsFormController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7501265C2B87CB6500ED5E14 /* PaymentInputsFormController.swift */; }; 7501265F2B8893C900ED5E14 /* PaymentFormController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7501265E2B8893C900ED5E14 /* PaymentFormController.swift */; }; 750126612B8902A500ED5E14 /* PaymentFormStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 750126602B8902A500ED5E14 /* PaymentFormStyle.swift */; }; + 750126632B89200B00ED5E14 /* PaymentInputProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 750126622B89200B00ED5E14 /* PaymentInputProtocol.swift */; }; 7502CA532A3011A900766E7D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7502CA562A3011A900766E7D /* LaunchScreen.storyboard */; }; 7502CA5F2A31A7D600766E7D /* CountryListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7502CA5E2A31A7D600766E7D /* CountryListViewController.swift */; }; 7502CA602A31A7D600766E7D /* CountryListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7502CA5E2A31A7D600766E7D /* CountryListViewController.swift */; }; @@ -66,9 +67,9 @@ 75405A942A26340E008C21F6 /* UIButton+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75405A8A2A26340E008C21F6 /* UIButton+Helpers.swift */; }; 75405A952A26343F008C21F6 /* SpacerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75405A802A2633B6008C21F6 /* SpacerView.swift */; }; 75405A992A2634D9008C21F6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 75405A972A2634D9008C21F6 /* Assets.xcassets */; }; - 75405A9C2A266F50008C21F6 /* AtomeFormPaymentViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75405A9B2A266F50008C21F6 /* AtomeFormPaymentViewModel.swift */; }; - 75405AA42A27F5D3008C21F6 /* AtomeFormPaymentViewContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0B52A1A5F020038FA54 /* AtomeFormPaymentViewContext.swift */; }; - 75405AA52A27F5D3008C21F6 /* AtomeFormPaymentViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0B32A1A5EAD0038FA54 /* AtomeFormPaymentViewModelProtocol.swift */; }; + 75405A9C2A266F50008C21F6 /* AtomePaymentFormViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75405A9B2A266F50008C21F6 /* AtomePaymentFormViewModel.swift */; }; + 75405AA42A27F5D3008C21F6 /* AtomePaymentFormViewContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0B52A1A5F020038FA54 /* AtomePaymentFormViewContext.swift */; }; + 75405AA52A27F5D3008C21F6 /* AtomePaymentFormViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0B32A1A5EAD0038FA54 /* AtomePaymentFormViewModelProtocol.swift */; }; 75405AA82A27F97E008C21F6 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 75405AA62A27F97E008C21F6 /* Localizable.strings */; }; 754B78182B8741CD00973B71 /* TapGestureHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 754B78172B8741CD00973B71 /* TapGestureHandler.swift */; }; 756C8F1E2A40693B00D53059 /* CreditCardPaymentViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 756C8F1D2A40693B00D53059 /* CreditCardPaymentViewModelProtocol.swift */; }; @@ -169,8 +170,8 @@ 75F2A0B02A1A5BF30038FA54 /* ProxyProperty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0AF2A1A5BF30038FA54 /* ProxyProperty.swift */; }; 75F2A0B72A1A60630038FA54 /* AtomePaymentFormController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0A42A13B1470038FA54 /* AtomePaymentFormController.swift */; }; 75F2A0B82A1A60630038FA54 /* ProxyProperty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0AF2A1A5BF30038FA54 /* ProxyProperty.swift */; }; - 75F2A0B92A1A60630038FA54 /* AtomeFormPaymentViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0B32A1A5EAD0038FA54 /* AtomeFormPaymentViewModelProtocol.swift */; }; - 75F2A0BB2A1A60630038FA54 /* AtomeFormPaymentViewContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0B52A1A5F020038FA54 /* AtomeFormPaymentViewContext.swift */; }; + 75F2A0B92A1A60630038FA54 /* AtomePaymentFormViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0B32A1A5EAD0038FA54 /* AtomePaymentFormViewModelProtocol.swift */; }; + 75F2A0BB2A1A60630038FA54 /* AtomePaymentFormViewContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0B52A1A5F020038FA54 /* AtomePaymentFormViewContext.swift */; }; 75F2A0C12A1A84900038FA54 /* UIColor+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0C02A1A84900038FA54 /* UIColor+Helpers.swift */; }; 75F2A0C22A1A87AE0038FA54 /* UIColor+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0C02A1A84900038FA54 /* UIColor+Helpers.swift */; }; 8A188BB01D951E3C00FFF467 /* AuthorizingPaymentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A188BAF1D951E3C00FFF467 /* AuthorizingPaymentViewController.swift */; }; @@ -281,6 +282,7 @@ 7501265C2B87CB6500ED5E14 /* PaymentInputsFormController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentInputsFormController.swift; sourceTree = ""; }; 7501265E2B8893C900ED5E14 /* PaymentFormController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentFormController.swift; sourceTree = ""; }; 750126602B8902A500ED5E14 /* PaymentFormStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentFormStyle.swift; sourceTree = ""; }; + 750126622B89200B00ED5E14 /* PaymentInputProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentInputProtocol.swift; sourceTree = ""; }; 7502CA552A3011A900766E7D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 7502CA582A3011B000766E7D /* th */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = th; path = th.lproj/LaunchScreen.strings; sourceTree = ""; }; 7502CA5A2A3011B100766E7D /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/LaunchScreen.strings; sourceTree = ""; }; @@ -316,7 +318,7 @@ 75405A892A26340E008C21F6 /* UILabel+Helpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UILabel+Helpers.swift"; sourceTree = ""; }; 75405A8A2A26340E008C21F6 /* UIButton+Helpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIButton+Helpers.swift"; sourceTree = ""; }; 75405A972A2634D9008C21F6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - 75405A9B2A266F50008C21F6 /* AtomeFormPaymentViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtomeFormPaymentViewModel.swift; sourceTree = ""; }; + 75405A9B2A266F50008C21F6 /* AtomePaymentFormViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtomePaymentFormViewModel.swift; sourceTree = ""; }; 75405AA72A27F97E008C21F6 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; 75405AA92A27F985008C21F6 /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Localizable.strings; sourceTree = ""; }; 75405AAA2A27F988008C21F6 /* th */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = th; path = th.lproj/Localizable.strings; sourceTree = ""; }; @@ -407,8 +409,8 @@ 75F2A0992A13B0B10038FA54 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 75F2A0A42A13B1470038FA54 /* AtomePaymentFormController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtomePaymentFormController.swift; sourceTree = ""; }; 75F2A0AF2A1A5BF30038FA54 /* ProxyProperty.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProxyProperty.swift; sourceTree = ""; }; - 75F2A0B32A1A5EAD0038FA54 /* AtomeFormPaymentViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtomeFormPaymentViewModelProtocol.swift; sourceTree = ""; }; - 75F2A0B52A1A5F020038FA54 /* AtomeFormPaymentViewContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtomeFormPaymentViewContext.swift; sourceTree = ""; }; + 75F2A0B32A1A5EAD0038FA54 /* AtomePaymentFormViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtomePaymentFormViewModelProtocol.swift; sourceTree = ""; }; + 75F2A0B52A1A5F020038FA54 /* AtomePaymentFormViewContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtomePaymentFormViewContext.swift; sourceTree = ""; }; 75F2A0C02A1A84900038FA54 /* UIColor+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Helpers.swift"; sourceTree = ""; }; 75F8C0B62B1F78E300AE78D9 /* PaymentChooserViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentChooserViewControllerTests.swift; sourceTree = ""; }; 8A00FEC21F1DE88600246078 /* README.md */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; tabWidth = 2; }; @@ -550,6 +552,7 @@ 750126602B8902A500ED5E14 /* PaymentFormStyle.swift */, 7501265E2B8893C900ED5E14 /* PaymentFormController.swift */, 7501265C2B87CB6500ED5E14 /* PaymentInputsFormController.swift */, + 750126622B89200B00ED5E14 /* PaymentInputProtocol.swift */, ); path = Base; sourceTree = ""; @@ -845,9 +848,9 @@ children = ( 7501265B2B87CB3F00ED5E14 /* Base */, 75F2A0A42A13B1470038FA54 /* AtomePaymentFormController.swift */, - 75F2A0B52A1A5F020038FA54 /* AtomeFormPaymentViewContext.swift */, - 75F2A0B32A1A5EAD0038FA54 /* AtomeFormPaymentViewModelProtocol.swift */, - 75405A9B2A266F50008C21F6 /* AtomeFormPaymentViewModel.swift */, + 75F2A0B52A1A5F020038FA54 /* AtomePaymentFormViewContext.swift */, + 75F2A0B32A1A5EAD0038FA54 /* AtomePaymentFormViewModelProtocol.swift */, + 75405A9B2A266F50008C21F6 /* AtomePaymentFormViewModel.swift */, ); path = "Atome Payment"; sourceTree = ""; @@ -1347,7 +1350,7 @@ 75D13E1D2B86FF8C0073A831 /* CreditCardPaymentDelegate.swift in Sources */, 75B420822B77FAA50036134D /* CreateSourcePayload.swift in Sources */, 8AD391B1230C05BC00383286 /* Colors.swift in Sources */, - 75F2A0BB2A1A60630038FA54 /* AtomeFormPaymentViewContext.swift in Sources */, + 75F2A0BB2A1A60630038FA54 /* AtomePaymentFormViewContext.swift in Sources */, 75D13DB12B83B58B0073A831 /* Source.Payment.FPX.Bank.swift in Sources */, 75B420662B77741E0036134D /* CreateTokenPayload.swift in Sources */, 986406351CFEA7E4004BCF51 /* OmiseTextField.swift in Sources */, @@ -1393,7 +1396,7 @@ 75D13D5E2B8069650073A831 /* UIImage+Omise.swift in Sources */, 75D13DA92B83B58B0073A831 /* Source.Payment.Item.swift in Sources */, 75E0EB9E2B7BD00F00E3198A /* OmiseError.swift in Sources */, - 75F2A0B92A1A60630038FA54 /* AtomeFormPaymentViewModelProtocol.swift in Sources */, + 75F2A0B92A1A60630038FA54 /* AtomePaymentFormViewModelProtocol.swift in Sources */, 75D13DD82B86539C0073A831 /* Optional+Helpers.swift in Sources */, 75D13DD22B85A4490073A831 /* ChooseFPXBankViewModel.swift in Sources */, 75D13E202B8703F80073A831 /* CreditCardPaymentController.swift in Sources */, @@ -1416,7 +1419,7 @@ 75348D4E29C3FCC70008C8A3 /* Bundle+OmiseSDK.swift in Sources */, 75E0EB9D2B7BD00F00E3198A /* CardBrand.swift in Sources */, 75E0EB9A2B7BD00F00E3198A /* Currency.swift in Sources */, - 75405A9C2A266F50008C21F6 /* AtomeFormPaymentViewModel.swift in Sources */, + 75405A9C2A266F50008C21F6 /* AtomePaymentFormViewModel.swift in Sources */, 75D13DA72B83B58B0073A831 /* Source.Payment.BarcodeAlipay.swift in Sources */, 75CFC4DB2B73F5AF00422A8F /* NetworkService.swift in Sources */, 75E0EBA32B7BD02200E3198A /* Token.swift in Sources */, @@ -1435,6 +1438,7 @@ 75F2A0C22A1A87AE0038FA54 /* UIColor+Helpers.swift in Sources */, 750126612B8902A500ED5E14 /* PaymentFormStyle.swift in Sources */, 75D13D6C2B8335850073A831 /* ViewContainer.swift in Sources */, + 750126632B89200B00ED5E14 /* PaymentInputProtocol.swift in Sources */, 7509D4DD2A1A9FD70050AB38 /* MainActionButton.swift in Sources */, 75E0EBC22B7D1F9E00E3198A /* OmiseError+LocalizedDescription.swift in Sources */, 75D13DDD2B8658660073A831 /* SelectPaymentPresentableProtocol.swift in Sources */, @@ -1479,9 +1483,9 @@ 75F2A0A62A13B70F0038FA54 /* OmiseTextField.swift in Sources */, 75405A8E2A26340E008C21F6 /* UIView+Helpers.swift in Sources */, 75405A902A26340E008C21F6 /* UIImage+Helpers.swift in Sources */, - 75405AA42A27F5D3008C21F6 /* AtomeFormPaymentViewContext.swift in Sources */, + 75405AA42A27F5D3008C21F6 /* AtomePaymentFormViewContext.swift in Sources */, 75405A792A25D33F008C21F6 /* String+Helpers.swift in Sources */, - 75405AA52A27F5D3008C21F6 /* AtomeFormPaymentViewModelProtocol.swift in Sources */, + 75405AA52A27F5D3008C21F6 /* AtomePaymentFormViewModelProtocol.swift in Sources */, 75F2A0C12A1A84900038FA54 /* UIColor+Helpers.swift in Sources */, 75405A8C2A26340E008C21F6 /* UIStackView+Helpers.swift in Sources */, 751E7BE32B7F4DD00031B4A2 /* MainActionButton.swift in Sources */, From b36a74de3d046d4570d82bc075abe17d27a940ca Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Sat, 24 Feb 2024 17:27:19 +0700 Subject: [PATCH 145/204] move econtext from storyboard to xib --- .../Resources/Base.lproj/OmiseSDK.storyboard | 301 +----------------- .../Base/PaymentInputProtocol.swift | 25 -- .../ChoosePaymentCoordinator.swift | 12 +- .../AtomePaymentFormController.swift | 1 - .../AtomePaymentFormViewContext.swift | 0 .../AtomePaymentFormViewModel.swift | 7 - .../AtomePaymentFormViewModelProtocol.swift | 0 .../Base/PaymentFormController.swift | 0 .../Atome Payment/Base/PaymentFormStyle.swift | 0 .../PaymentInputProtocol.swift | 25 ++ .../PaymentInputsFormController.swift | 2 + .../EContextInformationInputController.swift} | 56 +++- .../EContextInformationInputController.xib | 262 +++++++++++++++ dev.xcodeproj/project.pbxproj | 60 +++- 14 files changed, 399 insertions(+), 352 deletions(-) delete mode 100644 OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentInputProtocol.swift rename OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/{ => Other Payments}/Atome Payment/AtomePaymentFormController.swift (99%) rename OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/{ => Other Payments}/Atome Payment/AtomePaymentFormViewContext.swift (100%) rename OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/{ => Other Payments}/Atome Payment/AtomePaymentFormViewModel.swift (95%) rename OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/{ => Other Payments}/Atome Payment/AtomePaymentFormViewModelProtocol.swift (100%) rename OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/{ => Other Payments}/Atome Payment/Base/PaymentFormController.swift (100%) rename OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/{ => Other Payments}/Atome Payment/Base/PaymentFormStyle.swift (100%) create mode 100644 OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/Base/To Be Implemented/PaymentInputProtocol.swift rename OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/{Atome Payment/Base => Other Payments/Atome Payment/Base/To Be Implemented}/PaymentInputsFormController.swift (98%) rename OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/{ToDo/EContextInformationInputViewController.swift => Other Payments/EContext/EContextInformationInputController.swift} (86%) create mode 100644 OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/EContext/EContextInformationInputController.xib diff --git a/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard b/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard index 74c470bf..459f0213 100644 --- a/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard +++ b/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard @@ -159,7 +159,6 @@ - @@ -232,16 +231,8 @@ - - - - - - - - - - + + @@ -271,270 +262,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -739,16 +466,8 @@ - - - - - - - - - - + + @@ -1341,24 +1060,12 @@ - - - - - - - - - - - - diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentInputProtocol.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentInputProtocol.swift deleted file mode 100644 index ebd2cfe5..00000000 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentInputProtocol.swift +++ /dev/null @@ -1,25 +0,0 @@ -import Foundation -import UIKit - -protocol PaymenFormtInputProtocol { - var next: PaymenFormtInputProtocol? { get set } - var section: String? { get } // optional - var title: String { get } - var error: String { get } - var isError: Bool { get } - - var contentType: UITextContentType? { get } // optional - var capitalization: UITextAutocapitalizationType { get } // optional - var keyboardType: UIKeyboardType { get } // default asciiCapable - var validatorRegex: String? { get } // optional - var isOptional: Bool { get } // by default false -} - -extension PaymenFormtInputProtocol { - var section: String? { nil } - var contentType: UITextContentType? { nil } - var capitalization: UITextAutocapitalizationType { .none } - var keyboardType: UIKeyboardType { .asciiCapable } - var validatorRegex: String? { nil } - var isOptional: Bool { false } -} diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift index d32c5774..e49a3d76 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift @@ -109,6 +109,14 @@ class ChoosePaymentCoordinator: ViewAttachable { viewController.title = PaymentMethod.creditCard.localizedTitle return viewController } + + /// Creates Atome screen and attach current flow object inside created controller to be deallocated together + func createEContextController(title: String) -> EContextInformationInputController { + let viewController = EContextInformationInputController(nibName: nil, bundle: .omiseSDK) + viewController.title = title + viewController.delegate = self + return viewController + } } extension ChoosePaymentCoordinator: CreditCardPaymentDelegate { @@ -130,6 +138,8 @@ extension ChoosePaymentCoordinator: SelectPaymentMethodDelegate { case .installment: navigate(to: createInstallmentController()) case .creditCard: navigate(to: createCreditCardPaymentController()) case .sourceType(.atome): navigate(to: createAtomeController()) + case .eContextConbini, .eContextPayEasy, .eContextNetBanking: + navigate(to: createEContextController(title: paymentMethod.localizedTitle)) default: break } } else if let sourceType = paymentMethod.sourceType { @@ -235,7 +245,7 @@ extension ChoosePaymentCoordinator { // // case ("GoToInstallmentBrandChooserSegue"?, let controller as InstallmentBankingSourceChooserViewController): // // controller.showingValues = allowedPaymentMethods.filter({ $0.isInstallment }) // // controller.flowSession = self.viewModel.flowSession -// // case (_, let controller as EContextInformationInputViewController): +// // case (_, let controller as EContextInformationInputController): // // controller.flowSession = self.viewModel.flowSession // // if let element = (sender as? UITableViewCell).flatMap(tableView.indexPath(for:)).map(item(at:)) { // // switch element { diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentFormController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/AtomePaymentFormController.swift similarity index 99% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentFormController.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/AtomePaymentFormController.swift index c7dd9166..47e299be 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentFormController.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/AtomePaymentFormController.swift @@ -83,7 +83,6 @@ private extension AtomePaymentInputsFormController { applySecondaryColor() } - func setupInputs(viewModel: ViewModel) { removeAllInputs() diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentFormViewContext.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/AtomePaymentFormViewContext.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentFormViewContext.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/AtomePaymentFormViewContext.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentFormViewModel.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/AtomePaymentFormViewModel.swift similarity index 95% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentFormViewModel.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/AtomePaymentFormViewModel.swift index dd3f71cf..6d013d5b 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentFormViewModel.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/AtomePaymentFormViewModel.swift @@ -1,12 +1,5 @@ import Foundation -struct AtomeInputField: PaymenFormtInputProtocol { - var next: PaymenFormtInputProtocol? - var title: String - var error: String - var isError: Bool -} - class AtomePaymentFormViewModel: AtomePaymentFormViewModelProtocol, CountryListViewModelProtocol { var fields: [Field] = [ .name, diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentFormViewModelProtocol.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/AtomePaymentFormViewModelProtocol.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/AtomePaymentFormViewModelProtocol.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/AtomePaymentFormViewModelProtocol.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/Base/PaymentFormController.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormController.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/Base/PaymentFormController.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormStyle.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/Base/PaymentFormStyle.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentFormStyle.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/Base/PaymentFormStyle.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/Base/To Be Implemented/PaymentInputProtocol.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/Base/To Be Implemented/PaymentInputProtocol.swift new file mode 100644 index 00000000..80d05e4b --- /dev/null +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/Base/To Be Implemented/PaymentInputProtocol.swift @@ -0,0 +1,25 @@ +import Foundation +import UIKit + +//protocol PaymenFormtInputProtocol { +// var next: PaymenFormtInputProtocol? { get set } +// var section: String? { get } // optional +// var title: String { get } +// var error: String { get } +// var isError: Bool { get } +// +// var contentType: UITextContentType? { get } // optional +// var capitalization: UITextAutocapitalizationType { get } // optional +// var keyboardType: UIKeyboardType { get } // default asciiCapable +// var validatorRegex: String? { get } // optional +// var isOptional: Bool { get } // by default false +//} +// +//extension PaymenFormtInputProtocol { +// var section: String? { nil } +// var contentType: UITextContentType? { nil } +// var capitalization: UITextAutocapitalizationType { .none } +// var keyboardType: UIKeyboardType { .asciiCapable } +// var validatorRegex: String? { nil } +// var isOptional: Bool { false } +//} diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentInputsFormController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/Base/To Be Implemented/PaymentInputsFormController.swift similarity index 98% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentInputsFormController.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/Base/To Be Implemented/PaymentInputsFormController.swift index 172571f5..833463a5 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Atome Payment/Base/PaymentInputsFormController.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/Base/To Be Implemented/PaymentInputsFormController.swift @@ -1,5 +1,6 @@ import UIKit +/* class PaymentInputsFormController: PaymentFormController { private var fields: [Field: String] = [:] @@ -18,3 +19,4 @@ class PaymentInputsFormController + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev.xcodeproj/project.pbxproj b/dev.xcodeproj/project.pbxproj index 9729bc9a..6a9b4c71 100644 --- a/dev.xcodeproj/project.pbxproj +++ b/dev.xcodeproj/project.pbxproj @@ -19,6 +19,7 @@ 7501265F2B8893C900ED5E14 /* PaymentFormController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7501265E2B8893C900ED5E14 /* PaymentFormController.swift */; }; 750126612B8902A500ED5E14 /* PaymentFormStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 750126602B8902A500ED5E14 /* PaymentFormStyle.swift */; }; 750126632B89200B00ED5E14 /* PaymentInputProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 750126622B89200B00ED5E14 /* PaymentInputProtocol.swift */; }; + 7501266A2B89F25000ED5E14 /* EContextInformationInputController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 750126692B89F25000ED5E14 /* EContextInformationInputController.xib */; }; 7502CA532A3011A900766E7D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7502CA562A3011A900766E7D /* LaunchScreen.storyboard */; }; 7502CA5F2A31A7D600766E7D /* CountryListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7502CA5E2A31A7D600766E7D /* CountryListViewController.swift */; }; 7502CA602A31A7D600766E7D /* CountryListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7502CA5E2A31A7D600766E7D /* CountryListViewController.swift */; }; @@ -182,7 +183,7 @@ 8A7567652178956800C684C9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8A7567642178956800C684C9 /* Main.storyboard */; }; 8A776647214A5FC60029D166 /* NoticeView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8A776646214A5FC60029D166 /* NoticeView.xib */; }; 8AD391B1230C05BC00383286 /* Colors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AD391B0230C05BC00383286 /* Colors.swift */; }; - 8AEF7804224CABF800787470 /* EContextInformationInputViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A25E929213CF6F300D48252 /* EContextInformationInputViewController.swift */; }; + 8AEF7804224CABF800787470 /* EContextInformationInputController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A25E929213CF6F300D48252 /* EContextInformationInputController.swift */; }; 8AF5517A213D4C0100D61C98 /* Localizable.stringsdict in Resources */ = {isa = PBXBuildFile; fileRef = 8AF5517C213D4C0100D61C98 /* Localizable.stringsdict */; }; 8AF56E62226878070097CFEE /* CustomCreditCardFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AF56E61226878070097CFEE /* CustomCreditCardFormViewController.swift */; }; 8AF9857121479F38007E18ED /* CCVInfoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A3150AD2146B6C300A4F429 /* CCVInfoController.swift */; }; @@ -283,6 +284,7 @@ 7501265E2B8893C900ED5E14 /* PaymentFormController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentFormController.swift; sourceTree = ""; }; 750126602B8902A500ED5E14 /* PaymentFormStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentFormStyle.swift; sourceTree = ""; }; 750126622B89200B00ED5E14 /* PaymentInputProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentInputProtocol.swift; sourceTree = ""; }; + 750126692B89F25000ED5E14 /* EContextInformationInputController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = EContextInformationInputController.xib; sourceTree = ""; }; 7502CA552A3011A900766E7D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 7502CA582A3011B000766E7D /* th */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = th; path = th.lproj/LaunchScreen.strings; sourceTree = ""; }; 7502CA5A2A3011B100766E7D /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/LaunchScreen.strings; sourceTree = ""; }; @@ -415,7 +417,7 @@ 75F8C0B62B1F78E300AE78D9 /* PaymentChooserViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentChooserViewControllerTests.swift; sourceTree = ""; }; 8A00FEC21F1DE88600246078 /* README.md */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; tabWidth = 2; }; 8A188BAF1D951E3C00FFF467 /* AuthorizingPaymentViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthorizingPaymentViewController.swift; sourceTree = ""; }; - 8A25E929213CF6F300D48252 /* EContextInformationInputViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EContextInformationInputViewController.swift; sourceTree = ""; }; + 8A25E929213CF6F300D48252 /* EContextInformationInputController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EContextInformationInputController.swift; sourceTree = ""; }; 8A275CBB21241E4500C5716F /* MainActionButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainActionButton.swift; sourceTree = ""; }; 8A30FB7C214929C900DC09DC /* PaymentCreatorController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentCreatorController.swift; sourceTree = ""; }; 8A3150AD2146B6C300A4F429 /* CCVInfoController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CCVInfoController.swift; sourceTree = ""; }; @@ -549,12 +551,54 @@ 7501265B2B87CB3F00ED5E14 /* Base */ = { isa = PBXGroup; children = ( + 750126642B89D31400ED5E14 /* To Be Implemented */, 750126602B8902A500ED5E14 /* PaymentFormStyle.swift */, 7501265E2B8893C900ED5E14 /* PaymentFormController.swift */, + ); + path = Base; + sourceTree = ""; + }; + 750126642B89D31400ED5E14 /* To Be Implemented */ = { + isa = PBXGroup; + children = ( 7501265C2B87CB6500ED5E14 /* PaymentInputsFormController.swift */, 750126622B89200B00ED5E14 /* PaymentInputProtocol.swift */, ); - path = Base; + path = "To Be Implemented"; + sourceTree = ""; + }; + 750126652B89F09F00ED5E14 /* Other Payments */ = { + isa = PBXGroup; + children = ( + 750126682B89F0C200ED5E14 /* EContext */, + 750126672B89F0B200ED5E14 /* TrueMoneyWallet */, + 750126662B89F0AD00ED5E14 /* FPX */, + 75D13DF82B866CA90073A831 /* Atome Payment */, + ); + path = "Other Payments"; + sourceTree = ""; + }; + 750126662B89F0AD00ED5E14 /* FPX */ = { + isa = PBXGroup; + children = ( + ); + path = FPX; + sourceTree = ""; + }; + 750126672B89F0B200ED5E14 /* TrueMoneyWallet */ = { + isa = PBXGroup; + children = ( + ); + path = TrueMoneyWallet; + sourceTree = ""; + }; + 750126682B89F0C200ED5E14 /* EContext */ = { + isa = PBXGroup; + children = ( + 8A25E929213CF6F300D48252 /* EContextInformationInputController.swift */, + 750126692B89F25000ED5E14 /* EContextInformationInputController.xib */, + ); + path = EContext; sourceTree = ""; }; 750708E12B790B2400A48DD0 /* Helpers */ = { @@ -785,12 +829,12 @@ 75D13DF32B866C420073A831 /* ChoosePaymentMethods */ = { isa = PBXGroup; children = ( + 75D13D5F2B807AC90073A831 /* ChoosePaymentCoordinator.swift */, + 751E7BD82B7E5D130031B4A2 /* PaymentMethod.swift */, 75D13DF42B866C590073A831 /* ViewPresentable */, 75D13DF52B866C600073A831 /* Select Payment Delegates */, 75D13DF62B866C650073A831 /* Select Payment From Lists */, - 75D13DF82B866CA90073A831 /* Atome Payment */, - 75D13D5F2B807AC90073A831 /* ChoosePaymentCoordinator.swift */, - 751E7BD82B7E5D130031B4A2 /* PaymentMethod.swift */, + 750126652B89F09F00ED5E14 /* Other Payments */, 75D13DF72B866C900073A831 /* ToDo */, ); path = ChoosePaymentMethods; @@ -832,7 +876,6 @@ 75D13DF72B866C900073A831 /* ToDo */ = { isa = PBXGroup; children = ( - 8A25E929213CF6F300D48252 /* EContextInformationInputViewController.swift */, F6614CD5243DB8E7005B656E /* TrueMoneyFormViewController.swift */, 75D13DCF2B85A4240073A831 /* ChooseDuitNowObwBankViewModel.swift */, 75D13DD12B85A4490073A831 /* ChooseFPXBankViewModel.swift */, @@ -1266,6 +1309,7 @@ 2225B3541D0FDD63003EB396 /* Assets.xcassets in Resources */, 8AF5517A213D4C0100D61C98 /* Localizable.stringsdict in Resources */, 8AF985732147CC3D007E18ED /* Error.strings in Resources */, + 7501266A2B89F25000ED5E14 /* EContextInformationInputController.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1451,7 +1495,7 @@ 756C8F202A40694000D53059 /* CreditCardPaymentViewModel.swift in Sources */, 75D13D732B833A810073A831 /* TableCellContext.swift in Sources */, 759C7EC42B7DC8270029D555 /* SourceType+Installments.swift in Sources */, - 8AEF7804224CABF800787470 /* EContextInformationInputViewController.swift in Sources */, + 8AEF7804224CABF800787470 /* EContextInformationInputController.swift in Sources */, 75D13DC92B8529790073A831 /* SelectSourceTypePaymentViewModel.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; From ccf64ebc1dad11db9ff24352719bf1c30ada1085 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Sat, 24 Feb 2024 22:18:52 +0700 Subject: [PATCH 146/204] Add completion to payment details controllers --- .../ChoosePaymentCoordinator.swift | 26 ++++++++++--------- .../AtomePaymentFormViewModel.swift | 2 +- .../EContextInformationInputController.swift | 8 +++++- .../TrueMoneyFormViewController.swift | 10 +++---- .../SelectPaymentMethodDelegate.swift | 2 +- .../SelectSourcePaymentDelegate.swift | 2 +- .../SelectSourceTypeDelegate.swift | 2 +- .../SelectInstallmentTermsViewModel.swift | 4 +-- .../SelectPaymentController.swift | 6 ++++- .../SelectPaymentMethodViewModel.swift | 4 +-- .../SelectPaymentPresentableProtocol.swift | 2 +- .../SelectSourceTypePaymentViewModel.swift | 4 +-- .../CreditCardPaymentController.swift | 5 +++- .../CreditCardPaymentDelegate.swift | 2 +- .../CreditCardPaymentViewModel.swift | 4 +-- .../CreditCardPaymentViewModelProtocol.swift | 2 +- dev.xcodeproj/project.pbxproj | 2 +- 17 files changed, 51 insertions(+), 36 deletions(-) rename OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/{ToDo => Other Payments/TrueMoneyWallet}/TrueMoneyFormViewController.swift (96%) diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift index e49a3d76..18396097 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift @@ -120,8 +120,8 @@ class ChoosePaymentCoordinator: ViewAttachable { } extension ChoosePaymentCoordinator: CreditCardPaymentDelegate { - func didSelectCardPayment(_ card: CreateTokenPayload.Card) { - processPayment(card) + func didSelectCardPayment(_ card: CreateTokenPayload.Card, completion: @escaping () -> Void) { + processPayment(card, completion: completion) } func didCancelCardPayment() { @@ -130,7 +130,7 @@ extension ChoosePaymentCoordinator: CreditCardPaymentDelegate { } extension ChoosePaymentCoordinator: SelectPaymentMethodDelegate { - func didSelectPaymentMethod(_ paymentMethod: PaymentMethod) { + func didSelectPaymentMethod(_ paymentMethod: PaymentMethod, completion: @escaping () -> Void) { if paymentMethod.requiresAdditionalDetails { switch paymentMethod { case .mobileBanking: navigate(to: createMobileBankingController()) @@ -140,11 +140,11 @@ extension ChoosePaymentCoordinator: SelectPaymentMethodDelegate { case .sourceType(.atome): navigate(to: createAtomeController()) case .eContextConbini, .eContextPayEasy, .eContextNetBanking: navigate(to: createEContextController(title: paymentMethod.localizedTitle)) - default: break - } + default: break } } else if let sourceType = paymentMethod.sourceType { - processPayment(.sourceType(sourceType)) + processPayment(.sourceType(sourceType), completion: completion) } else { + completion() assertionFailure("Unexpected case for selected payment method: \(paymentMethod)") } } @@ -155,18 +155,18 @@ extension ChoosePaymentCoordinator: SelectPaymentMethodDelegate { } extension ChoosePaymentCoordinator: SelectSourceTypeDelegate { - func didSelectSourceType(_ sourceType: SourceType) { + func didSelectSourceType(_ sourceType: SourceType, completion: @escaping () -> Void) { if sourceType.isInstallment { navigate(to: createInstallmentTermsController(sourceType: sourceType)) } else { - processPayment(.sourceType(sourceType)) + processPayment(.sourceType(sourceType), completion: completion) } } } extension ChoosePaymentCoordinator: SelectSourcePaymentDelegate { - func didSelectSourcePayment(_ payment: Source.Payment) { - processPayment(payment) + func didSelectSourcePayment(_ payment: Source.Payment, completion: @escaping () -> Void) { + processPayment(payment, completion: completion) } } @@ -178,7 +178,7 @@ extension ChoosePaymentCoordinator { ) } - func processPayment(_ card: CreateTokenPayload.Card) { + func processPayment(_ card: CreateTokenPayload.Card, completion: @escaping () -> Void) { guard let delegate = choosePaymentMethodDelegate else { return } let tokenPayload = CreateTokenPayload(card: card) @@ -189,10 +189,11 @@ extension ChoosePaymentCoordinator { case .failure(let error): delegate?.choosePaymentMethodDidComplete(with: error) } + completion() } } - func processPayment(_ payment: Source.Payment) { + func processPayment(_ payment: Source.Payment, completion: @escaping () -> Void) { guard let delegate = choosePaymentMethodDelegate else { return } let sourcePayload = CreateSourcePayload( amount: amount, @@ -207,6 +208,7 @@ extension ChoosePaymentCoordinator { case .failure(let error): delegate?.choosePaymentMethodDidComplete(with: error) } + completion() } } } diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/AtomePaymentFormViewModel.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/AtomePaymentFormViewModel.swift index 6d013d5b..649448ab 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/AtomePaymentFormViewModel.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/AtomePaymentFormViewModel.swift @@ -104,6 +104,6 @@ class AtomePaymentFormViewModel: AtomePaymentFormViewModelProtocol, CountryListV items: items ) - delegate.didSelectSourcePayment(.atome(paymentInformation)) + delegate.didSelectSourcePayment(.atome(paymentInformation), completion: onComplete) } } diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/EContext/EContextInformationInputController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/EContext/EContextInformationInputController.swift index 2ef9b578..8f6095fb 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/EContext/EContextInformationInputController.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/EContext/EContextInformationInputController.swift @@ -140,7 +140,13 @@ class EContextInformationInputController: UIViewController, PaymentFormUIControl view.tintAdjustmentMode = .dimmed submitButton.isEnabled = false let payment = Source.Payment.eContext(eContextInformation) - delegate?.didSelectSourcePayment(payment) + delegate?.didSelectSourcePayment(payment) { [weak self] in + guard let self = self else { return } + self.requestingIndicatorView.stopAnimating() + self.view.isUserInteractionEnabled = true + self.view.tintAdjustmentMode = .automatic + self.submitButton.isEnabled = true + } } @IBAction private func updateInputAccessoryViewFor(_ sender: OmiseTextField) { diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/TrueMoneyFormViewController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/TrueMoneyWallet/TrueMoneyFormViewController.swift similarity index 96% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/TrueMoneyFormViewController.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/TrueMoneyWallet/TrueMoneyFormViewController.swift index e71fdfdc..0eaa5946 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/TrueMoneyFormViewController.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/TrueMoneyWallet/TrueMoneyFormViewController.swift @@ -1,9 +1,8 @@ import UIKit -class TrueMoneyFormViewController: UIViewController, PaymentSourceChooser, PaymentFormUIController { - - var flowSession: PaymentCreatorFlowSession? - +class TrueMoneyFormViewController: UIViewController, PaymentFormUIController { + weak var delegate: SelectSourcePaymentDelegate? + private var client: Client? private var isInputDataValid: Bool { @@ -97,7 +96,8 @@ class TrueMoneyFormViewController: UIViewController, PaymentSourceChooser, Payme view.isUserInteractionEnabled = false view.tintAdjustmentMode = .dimmed submitButton.isEnabled = false - flowSession?.requestCreateSource(.trueMoneyWallet(paymentInformation)) { _ in + delegate?.didSelectSourcePayment(.trueMoneyWallet(paymentInformation)) { [weak self] in + guard let self = self else { return } self.requestingIndicatorView.stopAnimating() self.view.isUserInteractionEnabled = true self.view.tintAdjustmentMode = .automatic diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment Delegates/SelectPaymentMethodDelegate.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment Delegates/SelectPaymentMethodDelegate.swift index 3289517b..83106302 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment Delegates/SelectPaymentMethodDelegate.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment Delegates/SelectPaymentMethodDelegate.swift @@ -1,6 +1,6 @@ import Foundation protocol SelectPaymentMethodDelegate: AnyObject { - func didSelectPaymentMethod(_ paymentMethod: PaymentMethod) + func didSelectPaymentMethod(_ paymentMethod: PaymentMethod, completion: @escaping () -> Void) func didCancelPayment() } diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment Delegates/SelectSourcePaymentDelegate.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment Delegates/SelectSourcePaymentDelegate.swift index c9c46530..c064a217 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment Delegates/SelectSourcePaymentDelegate.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment Delegates/SelectSourcePaymentDelegate.swift @@ -1,5 +1,5 @@ import Foundation protocol SelectSourcePaymentDelegate: AnyObject { - func didSelectSourcePayment(_ payment: Source.Payment) + func didSelectSourcePayment(_ payment: Source.Payment, completion: @escaping () -> Void) } diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment Delegates/SelectSourceTypeDelegate.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment Delegates/SelectSourceTypeDelegate.swift index 71a91a3b..a32cd64c 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment Delegates/SelectSourceTypeDelegate.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment Delegates/SelectSourceTypeDelegate.swift @@ -1,5 +1,5 @@ import Foundation protocol SelectSourceTypeDelegate: AnyObject { - func didSelectSourceType(_ sourceType: SourceType) + func didSelectSourceType(_ sourceType: SourceType, completion: @escaping () -> Void) } diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectInstallmentTermsViewModel.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectInstallmentTermsViewModel.swift index 6bcfb182..eaeda240 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectInstallmentTermsViewModel.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectInstallmentTermsViewModel.swift @@ -46,14 +46,14 @@ extension SelectInstallmentTermsViewModel: SelectPaymentPresentableProtocol { ) } - func viewDidSelectCell(at index: Int) { + func viewDidSelectCell(at index: Int, completion: @escaping () -> Void) { guard let value = values.at(index) else { return } let payment = Source.Payment.Installment( installmentTerm: value, zeroInterestInstallments: nil, sourceType: sourceType ) - delegate?.didSelectSourcePayment(.installment(payment)) + delegate?.didSelectSourcePayment(.installment(payment), completion: completion) } func viewShouldAnimateSelectedCell(at index: Int) -> Bool { diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectPaymentController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectPaymentController.swift index 7cc9d23b..d63f1e64 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectPaymentController.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectPaymentController.swift @@ -66,7 +66,11 @@ class SelectPaymentController: UITableViewController { startCellActivity(at: indexPath) } - viewModel.viewDidSelectCell(at: indexPath.row) + viewModel.viewDidSelectCell(at: indexPath.row) { [indexPath, weak self] in + guard let self = self else { return } + self.stopCellActivity(at: indexPath) + self.view.isUserInteractionEnabled = true + } } } diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectPaymentMethodViewModel.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectPaymentMethodViewModel.swift index ffab5c93..3abb6527 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectPaymentMethodViewModel.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectPaymentMethodViewModel.swift @@ -84,9 +84,9 @@ extension SelectPaymentMethodViewModel: SelectPaymentPresentableProtocol { ) } - func viewDidSelectCell(at index: Int) { + func viewDidSelectCell(at index: Int, completion: @escaping () -> Void) { guard let paymentMethod = paymentMethods.at(index) else { return } - delegate?.didSelectPaymentMethod(paymentMethod) + delegate?.didSelectPaymentMethod(paymentMethod, completion: completion) } func viewShouldAnimateSelectedCell(at index: Int) -> Bool { diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectPaymentPresentableProtocol.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectPaymentPresentableProtocol.swift index 44cf1486..84e336dd 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectPaymentPresentableProtocol.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectPaymentPresentableProtocol.swift @@ -8,7 +8,7 @@ protocol SelectPaymentPresentableProtocol { func viewOnDataReloadHandler(_ handler: @escaping () -> Void) func viewContext(at: Int) -> TableCellContext? - func viewDidSelectCell(at: Int) + func viewDidSelectCell(at: Int, completion: @escaping () -> Void) func viewShouldAnimateSelectedCell(at: Int) -> Bool func viewDidTapClose() } diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectSourceTypePaymentViewModel.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectSourceTypePaymentViewModel.swift index 7c52d318..4bf1f8a8 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectSourceTypePaymentViewModel.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectSourceTypePaymentViewModel.swift @@ -45,9 +45,9 @@ extension SelectSourceTypePaymentViewModel: SelectPaymentPresentableProtocol { ) } - func viewDidSelectCell(at index: Int) { + func viewDidSelectCell(at index: Int, completion: @escaping () -> Void) { guard let sourceType = sourceTypes.at(index) else { return } - delegate?.didSelectSourceType(sourceType) + delegate?.didSelectSourceType(sourceType, completion: completion) } func viewShouldAnimateSelectedCell(at index: Int) -> Bool { diff --git a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift index e80cebaa..dae404f9 100644 --- a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift +++ b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift @@ -408,7 +408,8 @@ public class CreditCardPaymentController: UIViewController { UIAccessibility.post(notification: UIAccessibility.Notification.announcement, argument: "Submitting payment, please wait") startActivityIndicator() - viewModel.onSubmitButtonPressed(makeViewContext()) + viewModel.onSubmitButtonPressed(makeViewContext()) { + self.stopActivityIndicator() // { [weak self] result in // guard let self = self else { return } @@ -424,6 +425,8 @@ public class CreditCardPaymentController: UIViewController { // self.handleError(error) // } // } + } + } func keyboardWillAppear(_ notification: Notification) { diff --git a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentDelegate.swift b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentDelegate.swift index 2b1e6018..f05ef430 100644 --- a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentDelegate.swift +++ b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentDelegate.swift @@ -1,6 +1,6 @@ import Foundation protocol CreditCardPaymentDelegate: AnyObject { - func didSelectCardPayment(_ card: CreateTokenPayload.Card) + func didSelectCardPayment(_ card: CreateTokenPayload.Card, completion: @escaping () -> Void) func didCancelCardPayment() } diff --git a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentViewModel.swift b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentViewModel.swift index 9b308aab..e1034f2d 100644 --- a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentViewModel.swift +++ b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentViewModel.swift @@ -53,7 +53,7 @@ class CreditCardPaymentViewModel: CreditCardPaymentViewModelProtocol, CountryLis delegate?.didCancelCardPayment() } - func onSubmitButtonPressed(_ viewContext: ViewContext) { + func onSubmitButtonPressed(_ viewContext: ViewContext, completion: @escaping () -> Void) { let card = CreateTokenPayload.Card( name: viewContext.name, @@ -70,7 +70,7 @@ class CreditCardPaymentViewModel: CreditCardPaymentViewModelProtocol, CountryLis postalCode: viewContext[.postalCode] ) - delegate?.didSelectCardPayment(card) + delegate?.didSelectCardPayment(card, completion: completion) /* viewModel.onSubmitButtonPressed(makeViewContext(), publicKey: publicKey) { [weak self] result in diff --git a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentViewModelProtocol.swift b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentViewModelProtocol.swift index fd9a8921..5cac4c6e 100644 --- a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentViewModelProtocol.swift +++ b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentViewModelProtocol.swift @@ -16,7 +16,7 @@ protocol CreditCardPaymentViewModelProtocol { var countryListViewModel: CountryListViewModelProtocol { get } var isAddressFieldsVisible: Bool { get } - func onSubmitButtonPressed(_ viewContext: ViewContext) + func onSubmitButtonPressed(_ viewContext: ViewContext, completion: @escaping () -> Void ) func error(for: AddressField, validate: String?) -> String? func title(for: AddressField) -> String? func placeholder(for: AddressField) -> String? diff --git a/dev.xcodeproj/project.pbxproj b/dev.xcodeproj/project.pbxproj index 6a9b4c71..310bfc50 100644 --- a/dev.xcodeproj/project.pbxproj +++ b/dev.xcodeproj/project.pbxproj @@ -588,6 +588,7 @@ 750126672B89F0B200ED5E14 /* TrueMoneyWallet */ = { isa = PBXGroup; children = ( + F6614CD5243DB8E7005B656E /* TrueMoneyFormViewController.swift */, ); path = TrueMoneyWallet; sourceTree = ""; @@ -876,7 +877,6 @@ 75D13DF72B866C900073A831 /* ToDo */ = { isa = PBXGroup; children = ( - F6614CD5243DB8E7005B656E /* TrueMoneyFormViewController.swift */, 75D13DCF2B85A4240073A831 /* ChooseDuitNowObwBankViewModel.swift */, 75D13DD12B85A4490073A831 /* ChooseFPXBankViewModel.swift */, 73F9BA4A25E6053700F55CA8 /* FPXFormViewController.swift */, From cddb1a16eea3b3152db475dd010ff996451396a0 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Sat, 24 Feb 2024 23:53:09 +0700 Subject: [PATCH 147/204] FPX payment is refactored --- .../Resources/Base.lproj/OmiseSDK.storyboard | 4 +- .../Source/Source.Payment.FPX.Bank.swift | 3 +- .../Source/Source.Payment.FPX.swift | 8 +- .../ChoosePaymentCoordinator.swift | 62 +++++-- ...ft => EContextPaymentFormController.swift} | 3 +- ....xib => EContextPaymentFormController.xib} | 2 +- .../FPX/FPXPaymentFormController.swift} | 64 ++++--- .../FPX/FPXPaymentFormController.xib | 175 ++++++++++++++++++ ...t => TrueMoneyPaymentFormController.swift} | 6 +- .../TrueMoneyPaymentFormController.xib | 155 ++++++++++++++++ .../SelectFPXBankViewModel.swift | 59 ++++++ .../SelectPaymentController.swift | 3 + .../ToDo/FPXBankChooserViewController.swift | 8 +- .../FPX.Bank+ViewPresentable.swift | 96 ++++++++++ dev.xcodeproj/project.pbxproj | 48 +++-- 15 files changed, 631 insertions(+), 65 deletions(-) rename OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/EContext/{EContextInformationInputController.swift => EContextPaymentFormController.swift} (99%) rename OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/EContext/{EContextInformationInputController.xib => EContextPaymentFormController.xib} (99%) rename OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/{ToDo/FPXFormViewController.swift => Other Payments/FPX/FPXPaymentFormController.swift} (78%) create mode 100644 OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/FPX/FPXPaymentFormController.xib rename OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/TrueMoneyWallet/{TrueMoneyFormViewController.swift => TrueMoneyPaymentFormController.swift} (97%) create mode 100644 OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.xib create mode 100644 OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectFPXBankViewModel.swift create mode 100644 OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ViewPresentable/FPX.Bank+ViewPresentable.swift diff --git a/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard b/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard index 459f0213..3d7b6e6f 100644 --- a/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard +++ b/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard @@ -88,7 +88,7 @@ - + @@ -322,7 +322,7 @@ - + diff --git a/OmiseSDK/Sources/OmiseAPI/JSON Models/Source/Source.Payment.FPX.Bank.swift b/OmiseSDK/Sources/OmiseAPI/JSON Models/Source/Source.Payment.FPX.Bank.swift index eade2131..7527a8f0 100644 --- a/OmiseSDK/Sources/OmiseAPI/JSON Models/Source/Source.Payment.FPX.Bank.swift +++ b/OmiseSDK/Sources/OmiseAPI/JSON Models/Source/Source.Payment.FPX.Bank.swift @@ -2,7 +2,7 @@ import Foundation extension Source.Payment.FPX { /// Bank code selected by customer - public enum Bank: String, Codable { + public enum Bank: String, Codable, CaseIterable { /// Affin Bank case affin /// Alliance Bank (Personal) @@ -43,5 +43,6 @@ extension Source.Payment.FPX { case sc /// UOB Bank case uob + /// Other bank } } diff --git a/OmiseSDK/Sources/OmiseAPI/JSON Models/Source/Source.Payment.FPX.swift b/OmiseSDK/Sources/OmiseAPI/JSON Models/Source/Source.Payment.FPX.swift index b3fb2e87..a6dcb09b 100644 --- a/OmiseSDK/Sources/OmiseAPI/JSON Models/Source/Source.Payment.FPX.swift +++ b/OmiseSDK/Sources/OmiseAPI/JSON Models/Source/Source.Payment.FPX.swift @@ -5,7 +5,7 @@ extension Source.Payment { /// https://docs.opn.ooo/fpx public struct FPX: Equatable { /// Bank code selected by customer - public let bank: Bank + public let bank: String /// Customer email public let email: String? @@ -14,13 +14,13 @@ extension Source.Payment { /// - Parameters: /// - bank: Bank code selected by customer /// - email: Customer email - public init(bank: Bank, email: String?) { + public init(bank: String, email: String?) { self.bank = bank self.email = email } /// Convenient static function to create a new DuitNowOBW instance - static func bank(_ bank: Bank, email: String?) -> Self { + static func bank(_ bank: String, email: String?) -> Self { Self(bank: bank, email: email) } } @@ -37,7 +37,7 @@ extension Source.Payment.FPX: Codable { /// Decode DuitNowOBW object from JSON string public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - self.bank = try container.decode(Bank.self, forKey: .bank) + self.bank = try container.decode(String.self, forKey: .bank) self.email = try container.decodeIfPresent(String.self, forKey: .email) } } diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift index 18396097..ccb50f49 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift @@ -111,12 +111,44 @@ class ChoosePaymentCoordinator: ViewAttachable { } /// Creates Atome screen and attach current flow object inside created controller to be deallocated together - func createEContextController(title: String) -> EContextInformationInputController { - let viewController = EContextInformationInputController(nibName: nil, bundle: .omiseSDK) + func createEContextController(title: String) -> EContextPaymentFormController { + let viewController = EContextPaymentFormController(nibName: nil, bundle: .omiseSDK) viewController.title = title viewController.delegate = self return viewController } + + /// Creates Atome screen and attach current flow object inside created controller to be deallocated together + func createFPXController() -> FPXPaymentFormController { + let viewController = FPXPaymentFormController(nibName: nil, bundle: .omiseSDK) + viewController.title = SourceType.fpx.localizedTitle + viewController.delegate = self + return viewController + } + + /// Creates Atome screen and attach current flow object inside created controller to be deallocated together + func createFPXBanksController(email: String?) -> SelectPaymentController { + let fpx = client.latestLoadedCapability?.paymentMethods.first { $0.name == SourceType.fpx.rawValue } + let banks: [Capability.PaymentMethod.Bank] = Array(fpx?.banks ?? []) + let viewModel = SelectFPXBankViewModel(email: email, banks: banks, delegate: self) + let listController = SelectPaymentController(viewModel: viewModel) + + listController.customizeCellAtIndexPathClosure = { [banks] cell, indexPath in + guard let bank = banks.at(indexPath.row) else { return } + if !bank.isActive { + cell.selectionStyle = UITableViewCell.SelectionStyle.none + cell.contentView.alpha = 0.5 + cell.isUserInteractionEnabled = false + } + } + return listController + } +} + +extension ChoosePaymentCoordinator: FPXPaymentFormControllerDelegate { + func fpxDidCompleteWith(email: String?, completion: @escaping () -> Void) { + navigate(to: createFPXBanksController(email: email)) + } } extension ChoosePaymentCoordinator: CreditCardPaymentDelegate { @@ -133,14 +165,22 @@ extension ChoosePaymentCoordinator: SelectPaymentMethodDelegate { func didSelectPaymentMethod(_ paymentMethod: PaymentMethod, completion: @escaping () -> Void) { if paymentMethod.requiresAdditionalDetails { switch paymentMethod { - case .mobileBanking: navigate(to: createMobileBankingController()) - case .internetBanking: navigate(to: createInternetBankingController()) - case .installment: navigate(to: createInstallmentController()) - case .creditCard: navigate(to: createCreditCardPaymentController()) - case .sourceType(.atome): navigate(to: createAtomeController()) + case .mobileBanking: + navigate(to: createMobileBankingController()) + case .internetBanking: + navigate(to: createInternetBankingController()) + case .installment: + navigate(to: createInstallmentController()) + case .creditCard: + navigate(to: createCreditCardPaymentController()) + case .sourceType(.atome): + navigate(to: createAtomeController()) case .eContextConbini, .eContextPayEasy, .eContextNetBanking: navigate(to: createEContextController(title: paymentMethod.localizedTitle)) - default: break } + case .sourceType(.fpx): + navigate(to: createFPXController()) + default: break + } } else if let sourceType = paymentMethod.sourceType { processPayment(.sourceType(sourceType), completion: completion) } else { @@ -247,7 +287,7 @@ extension ChoosePaymentCoordinator { // // case ("GoToInstallmentBrandChooserSegue"?, let controller as InstallmentBankingSourceChooserViewController): // // controller.showingValues = allowedPaymentMethods.filter({ $0.isInstallment }) // // controller.flowSession = self.viewModel.flowSession -// // case (_, let controller as EContextInformationInputController): +// // case (_, let controller as EContextPaymentFormController): // // controller.flowSession = self.viewModel.flowSession // // if let element = (sender as? UITableViewCell).flatMap(tableView.indexPath(for:)).map(item(at:)) { // // switch element { @@ -275,9 +315,9 @@ extension ChoosePaymentCoordinator { // // default: break // // } // // } -// // case ("GoToTrueMoneyFormSegue"?, let controller as TrueMoneyFormViewController): +// // case ("GoToTrueMoneyFormSegue"?, let controller as TrueMoneyPaymentFormController): // // controller.flowSession = self.viewModel.flowSession -// // case ("GoToFPXFormSegue"?, let controller as FPXFormViewController): +// // case ("GoToFPXFormSegue"?, let controller as FPXPaymentFormController): // // // controller.showingValues = capability?.paymentMethod(for: .fpx)?.banks // // // capability?[.fpx]?.banks ?? [] // // diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/EContext/EContextInformationInputController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/EContext/EContextPaymentFormController.swift similarity index 99% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/EContext/EContextInformationInputController.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/EContext/EContextPaymentFormController.swift index 8f6095fb..32bcb068 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/EContext/EContextInformationInputController.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/EContext/EContextPaymentFormController.swift @@ -1,6 +1,6 @@ import UIKit -class EContextInformationInputController: UIViewController, PaymentFormUIController { +class EContextPaymentFormController: UIViewController, PaymentFormUIController { weak var delegate: SelectSourcePaymentDelegate? var client: Client? @@ -109,7 +109,6 @@ class EContextInformationInputController: UIViewController, PaymentFormUIControl field.addTarget(self, action: #selector(validateFieldData), for: .editingChanged) field.addTarget(self, action: #selector(updateInputAccessoryViewFor), for: .editingDidBegin) field.addTarget(self, action: #selector(validateTextFieldDataOf), for: .editingDidEnd) - } override func viewWillLayoutSubviews() { diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/EContext/EContextInformationInputController.xib b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/EContext/EContextPaymentFormController.xib similarity index 99% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/EContext/EContextInformationInputController.xib rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/EContext/EContextPaymentFormController.xib index 139c0865..e5ba3a90 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/EContext/EContextInformationInputController.xib +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/EContext/EContextPaymentFormController.xib @@ -7,7 +7,7 @@ - + diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/FPXFormViewController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/FPX/FPXPaymentFormController.swift similarity index 78% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/FPXFormViewController.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/FPX/FPXPaymentFormController.swift index 3a562b16..8998fd0b 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/FPXFormViewController.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/FPX/FPXPaymentFormController.swift @@ -1,9 +1,14 @@ import UIKit -class FPXFormViewController: UIViewController, PaymentSourceChooser, PaymentFormUIController { +protocol FPXPaymentFormControllerDelegate: AnyObject { + func fpxDidCompleteWith(email: String?, completion: @escaping () -> Void) +} + +class FPXPaymentFormController: UIViewController, PaymentFormUIController { + + weak var delegate: FPXPaymentFormControllerDelegate? private let destinationSegue: String = "GoToFPXBankChooserSegue" - var flowSession: PaymentCreatorFlowSession? var showingValues: [Capability.PaymentMethod.Bank]? private var emailValue: String? @@ -21,14 +26,23 @@ class FPXFormViewController: UIViewController, PaymentSourceChooser, PaymentForm @IBOutlet var contentView: UIScrollView! + @IBOutlet private var emailLabel: UILabel! + @IBOutlet private var emailErrorLabel: UILabel! @IBOutlet private var emailTextField: OmiseTextField! @IBOutlet private var submitButton: MainActionButton! @IBOutlet private var requestingIndicatorView: UIActivityIndicatorView! - @IBOutlet private var errorLabel: UILabel! + lazy var formLabels: [UILabel]! = { + [emailLabel] + }() + + lazy var formFields: [OmiseTextField]! = { + [emailTextField] + }() - @IBOutlet var formLabels: [UILabel]! - @IBOutlet var formFields: [OmiseTextField]! + lazy var errorLabels: [UILabel] = { + [emailErrorLabel] + }() @IBOutlet var formFieldsAccessoryView: UIToolbar! @IBOutlet var gotoPreviousFieldBarButtonItem: UIBarButtonItem! @@ -44,6 +58,10 @@ class FPXFormViewController: UIViewController, PaymentSourceChooser, PaymentForm submitButton.defaultBackgroundColor = .omise submitButton.disabledBackgroundColor = .line + if #available(iOSApplicationExtension 11.0, *) { + navigationItem.largeTitleDisplayMode = .never + } + navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil) formFields.forEach { @@ -80,6 +98,19 @@ class FPXFormViewController: UIViewController, PaymentSourceChooser, PaymentForm // check for 1st time validateFieldData(emailTextField) + setupTextFieldHandlers() + } + + private func setupTextFieldHandlers() { + self.formFields.forEach { field in + setupTextField(field) + } + } + + private func setupTextField(_ field: OmiseTextField) { + field.addTarget(self, action: #selector(validateFieldData), for: .editingChanged) + field.addTarget(self, action: #selector(updateInputAccessoryViewFor), for: .editingDidBegin) + field.addTarget(self, action: #selector(validateTextFieldDataOf), for: .editingDidEnd) } override func viewWillLayoutSubviews() { @@ -99,18 +130,9 @@ class FPXFormViewController: UIViewController, PaymentSourceChooser, PaymentForm @IBAction private func submitForm(_ sender: AnyObject) { emailValue = emailTextField.text?.trimmingCharacters(in: CharacterSet.whitespaces) - - performSegue(withIdentifier: destinationSegue, sender: sender) + delegate?.fpxDidCompleteWith(email: emailValue, completion: {}) } - override func prepare(for segue: UIStoryboardSegue, sender: Any?) { - if segue.identifier == destinationSegue, - let fpxBankChooserViewController = segue.destination as? FPXBankChooserViewController { - fpxBankChooserViewController.email = emailValue - fpxBankChooserViewController.showingValues = showingValues ?? [] - fpxBankChooserViewController.flowSession = self.flowSession - } - } @IBAction private func validateFieldData(_ textField: OmiseTextField) { submitButton.isEnabled = isInputDataValid @@ -131,7 +153,7 @@ class FPXFormViewController: UIViewController, PaymentSourceChooser, PaymentForm UIView.animate(withDuration: duration, delay: 0.0, options: [.curveEaseInOut, .allowUserInteraction, .beginFromCurrentState, .layoutSubviews]) { - self.errorLabel.alpha = 0.0 + self.emailErrorLabel.alpha = 0.0 } updateInputAccessoryViewWithFirstResponder(sender) @@ -145,14 +167,14 @@ class FPXFormViewController: UIViewController, PaymentSourceChooser, PaymentForm private func validateField(_ textField: OmiseTextField) { do { try textField.validate() - errorLabel.alpha = 0.0 + emailErrorLabel.alpha = 0.0 } catch { switch error { case OmiseTextFieldValidationError.emptyText: - errorLabel.text = "-" // We need to set the error label some string in order to have it retains its height + emailErrorLabel.text = "-" // We need to set the error label some string in order to have it retains its height case OmiseTextFieldValidationError.invalidData: - errorLabel.text = NSLocalizedString( + emailErrorLabel.text = NSLocalizedString( "payment-creator.error.api.bad_request.invalid-email.message", tableName: "Error", bundle: .omiseSDK, @@ -161,9 +183,9 @@ class FPXFormViewController: UIViewController, PaymentSourceChooser, PaymentForm ) default: - errorLabel.text = error.localizedDescription + emailErrorLabel.text = error.localizedDescription } - errorLabel.alpha = errorLabel.text != "-" ? 1.0 : 0.0 + emailErrorLabel.alpha = emailErrorLabel.text != "-" ? 1.0 : 0.0 } } diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/FPX/FPXPaymentFormController.xib b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/FPX/FPXPaymentFormController.xib new file mode 100644 index 00000000..467f7606 --- /dev/null +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/FPX/FPXPaymentFormController.xib @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/TrueMoneyWallet/TrueMoneyFormViewController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.swift similarity index 97% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/TrueMoneyWallet/TrueMoneyFormViewController.swift rename to OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.swift index 0eaa5946..f701039e 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/TrueMoneyWallet/TrueMoneyFormViewController.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.swift @@ -1,6 +1,6 @@ import UIKit -class TrueMoneyFormViewController: UIViewController, PaymentFormUIController { +class TrueMoneyPaymentFormController: UIViewController, PaymentFormUIController { weak var delegate: SelectSourcePaymentDelegate? private var client: Client? @@ -36,6 +36,10 @@ class TrueMoneyFormViewController: UIViewController, PaymentFormUIController { submitButton.defaultBackgroundColor = .omise submitButton.disabledBackgroundColor = .line + if #available(iOSApplicationExtension 11.0, *) { + navigationItem.largeTitleDisplayMode = .never + } + navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil) formFields.forEach { diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.xib b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.xib new file mode 100644 index 00000000..0cd8f3bf --- /dev/null +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.xib @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectFPXBankViewModel.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectFPXBankViewModel.swift new file mode 100644 index 00000000..3b8e8ec6 --- /dev/null +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectFPXBankViewModel.swift @@ -0,0 +1,59 @@ +import UIKit + +class SelectFPXBankViewModel { + weak var delegate: SelectSourcePaymentDelegate? + let email: String? + + private var viewOnDataReloadHandler: () -> Void = { } { + didSet { + self.viewOnDataReloadHandler() + } + } + + private var values: [Capability.PaymentMethod.Bank] = [] { + didSet { + viewOnDataReloadHandler() + } + } + + init(email: String?, banks: [Capability.PaymentMethod.Bank], delegate: SelectSourcePaymentDelegate) { + self.email = email + self.values = banks + self.delegate = delegate + } +} + +extension SelectFPXBankViewModel: SelectPaymentPresentableProtocol { + func viewOnDataReloadHandler(_ handler: @escaping () -> Void) { + self.viewOnDataReloadHandler = handler + } + + var numberOfViewContexts: Int { + values.count + } + + var viewNavigationTitle: String { + SourceType.fpx.localizedTitle + } + + func viewContext(at index: Int) -> TableCellContext? { + guard let bank = values.at(index) else { return nil } + let fpxBank = Source.Payment.FPX.Bank(rawValue: bank.code) + return TableCellContext( + title: bank.name, + icon: UIImage(omise: fpxBank?.iconName ?? "FPX/unknown"), + accessoryIcon: UIImage(Assets.Icon.redirect) + ) + } + + func viewDidSelectCell(at index: Int, completion: @escaping () -> Void) { + guard let bank = values.at(index) else { return } + + let payment = Source.Payment.FPX(bank: bank.code, email: email) + delegate?.didSelectSourcePayment(.fpx(payment), completion: completion) + } + + func viewShouldAnimateSelectedCell(at index: Int) -> Bool { + true + } +} diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectPaymentController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectPaymentController.swift index d63f1e64..7ae956cb 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectPaymentController.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectPaymentController.swift @@ -4,6 +4,8 @@ class SelectPaymentController: UITableViewController { let viewModel: SelectPaymentPresentableProtocol + var customizeCellAtIndexPathClosure: (UITableViewCell, IndexPath) -> Void = { _, _ in } + init(viewModel: SelectPaymentPresentableProtocol) { self.viewModel = viewModel super.init(style: .plain) @@ -56,6 +58,7 @@ class SelectPaymentController: UITableViewController { cell.selectedBackgroundView = UIView() .backgroundColor(UIColor.selectedCellBackgroundColor) + customizeCellAtIndexPathClosure(cell, indexPath) return cell } diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/FPXBankChooserViewController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/FPXBankChooserViewController.swift index 2e3c8406..c42e32f2 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/FPXBankChooserViewController.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/FPXBankChooserViewController.swift @@ -76,7 +76,7 @@ class FPXBankChooserViewController: AdaptableDynamicTableViewController Date: Sat, 24 Feb 2024 23:55:14 +0700 Subject: [PATCH 148/204] Storyboard clean up --- .../Resources/Base.lproj/OmiseSDK.storyboard | 278 ------------------ .../SourceTests.swift | 2 +- 2 files changed, 1 insertion(+), 279 deletions(-) diff --git a/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard b/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard index 3d7b6e6f..f5499165 100644 --- a/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard +++ b/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard @@ -8,58 +8,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -262,223 +210,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1054,23 +785,15 @@ - - - - - - - - @@ -1088,7 +811,6 @@ - diff --git a/OmiseSDKTests/Source and Token JSON Codable Tests/SourceTests.swift b/OmiseSDKTests/Source and Token JSON Codable Tests/SourceTests.swift index d7cd0cef..d62c5a35 100644 --- a/OmiseSDKTests/Source and Token JSON Codable Tests/SourceTests.swift +++ b/OmiseSDKTests/Source and Token JSON Codable Tests/SourceTests.swift @@ -551,7 +551,7 @@ class SourceTests: XCTestCase { let sourceType: SourceType = .fpx let source: Source = try sampleFromJSONBy(.source(type: sourceType)) let paymentInformation = Payment.FPX( - bank: .uob, + bank: "uob", email: "support@omise.co" ) XCTAssertEqual(source.id, "src_test_5jhmesi7s4at1qctloz") From 4c7ea9dd9c3880907469d0a9c8029a5a8c7508a3 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Sun, 25 Feb 2024 00:14:42 +0700 Subject: [PATCH 149/204] DuitNowOBW Refactored --- .../ChoosePaymentCoordinator.swift | 21 +++++-- .../SelectDuitNowOBWBankViewModel.swift | 55 +++++++++++++++++++ dev.xcodeproj/project.pbxproj | 4 ++ 3 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectDuitNowOBWBankViewModel.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift index ccb50f49..7aa8c689 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift @@ -101,7 +101,7 @@ class ChoosePaymentCoordinator: ViewAttachable { return viewController } - /// Creates Atome screen and attach current flow object inside created controller to be deallocated together + /// Creates Credit Carc Payment screen and attach current flow object inside created controller to be deallocated together func createCreditCardPaymentController() -> CreditCardPaymentController { let viewModel = CreditCardPaymentViewModel(currentCountry: currentCountry, delegate: self) let viewController = CreditCardPaymentController(nibName: nil, bundle: .omiseSDK) @@ -110,7 +110,7 @@ class ChoosePaymentCoordinator: ViewAttachable { return viewController } - /// Creates Atome screen and attach current flow object inside created controller to be deallocated together + /// Creates EContext screen and attach current flow object inside created controller to be deallocated together func createEContextController(title: String) -> EContextPaymentFormController { let viewController = EContextPaymentFormController(nibName: nil, bundle: .omiseSDK) viewController.title = title @@ -118,7 +118,7 @@ class ChoosePaymentCoordinator: ViewAttachable { return viewController } - /// Creates Atome screen and attach current flow object inside created controller to be deallocated together + /// Creates FPX screen and attach current flow object inside created controller to be deallocated together func createFPXController() -> FPXPaymentFormController { let viewController = FPXPaymentFormController(nibName: nil, bundle: .omiseSDK) viewController.title = SourceType.fpx.localizedTitle @@ -126,7 +126,7 @@ class ChoosePaymentCoordinator: ViewAttachable { return viewController } - /// Creates Atome screen and attach current flow object inside created controller to be deallocated together + /// Creates FPX Banks screen and attach current flow object inside created controller to be deallocated together func createFPXBanksController(email: String?) -> SelectPaymentController { let fpx = client.latestLoadedCapability?.paymentMethods.first { $0.name == SourceType.fpx.rawValue } let banks: [Capability.PaymentMethod.Bank] = Array(fpx?.banks ?? []) @@ -143,6 +143,17 @@ class ChoosePaymentCoordinator: ViewAttachable { } return listController } + + /// Creates Installement screen and attach current flow object inside created controller to be deallocated together + func createDuitNowOBWBanksController() -> SelectPaymentController { + let banks = Source.Payment.DuitNowOBW.Bank.allCases.sorted { + $0.localizedTitle.localizedCompare($1.localizedTitle) == .orderedAscending + } + + let viewModel = SelectDuitNowOBWBankViewModel(banks: banks, delegate: self) + let listController = SelectPaymentController(viewModel: viewModel) + return listController + } } extension ChoosePaymentCoordinator: FPXPaymentFormControllerDelegate { @@ -179,6 +190,8 @@ extension ChoosePaymentCoordinator: SelectPaymentMethodDelegate { navigate(to: createEContextController(title: paymentMethod.localizedTitle)) case .sourceType(.fpx): navigate(to: createFPXController()) + case .sourceType(.duitNowOBW): + navigate(to: createDuitNowOBWBanksController()) default: break } } else if let sourceType = paymentMethod.sourceType { diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectDuitNowOBWBankViewModel.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectDuitNowOBWBankViewModel.swift new file mode 100644 index 00000000..1fc5c7ef --- /dev/null +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectDuitNowOBWBankViewModel.swift @@ -0,0 +1,55 @@ +import UIKit + +class SelectDuitNowOBWBankViewModel { + private weak var delegate: SelectSourcePaymentDelegate? + + private var viewOnDataReloadHandler: () -> Void = { } { + didSet { + self.viewOnDataReloadHandler() + } + } + + private var banks: [Source.Payment.DuitNowOBW.Bank] = [] { + didSet { + viewOnDataReloadHandler() + } + } + + init(banks: [Source.Payment.DuitNowOBW.Bank], delegate: SelectSourcePaymentDelegate) { + self.banks = banks + self.delegate = delegate + } +} + +extension SelectDuitNowOBWBankViewModel: SelectPaymentPresentableProtocol { + func viewOnDataReloadHandler(_ handler: @escaping () -> Void) { + self.viewOnDataReloadHandler = handler + } + + var numberOfViewContexts: Int { + banks.count + } + + var viewNavigationTitle: String { + SourceType.duitNowOBW.localizedTitle + } + + func viewContext(at index: Int) -> TableCellContext? { + guard let bank = banks.at(index) else { return nil } + return TableCellContext( + title: bank.localizedTitle, + icon: UIImage(omise: bank.iconName) ?? UIImage(omise: "FPX/unknown"), + accessoryIcon: UIImage(bank.accessoryIcon) + ) + } + + func viewDidSelectCell(at index: Int, completion: @escaping () -> Void) { + guard let bank = banks.at(index) else { return } + let payment: Source.Payment = .duitNowOBW(.init(bank: bank)) + delegate?.didSelectSourcePayment(payment, completion: completion) + } + + func viewShouldAnimateSelectedCell(at index: Int) -> Bool { + return true + } +} diff --git a/dev.xcodeproj/project.pbxproj b/dev.xcodeproj/project.pbxproj index 62176678..2d31c50b 100644 --- a/dev.xcodeproj/project.pbxproj +++ b/dev.xcodeproj/project.pbxproj @@ -24,6 +24,7 @@ 7501266E2B8A411C00ED5E14 /* FPXPaymentFormController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7501266D2B8A411C00ED5E14 /* FPXPaymentFormController.xib */; }; 750126702B8A490000ED5E14 /* SelectFPXBankViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7501266F2B8A490000ED5E14 /* SelectFPXBankViewModel.swift */; }; 750126722B8A49BC00ED5E14 /* FPX.Bank+ViewPresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 750126712B8A49BC00ED5E14 /* FPX.Bank+ViewPresentable.swift */; }; + 750126742B8A580500ED5E14 /* SelectDuitNowOBWBankViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 750126732B8A580500ED5E14 /* SelectDuitNowOBWBankViewModel.swift */; }; 7502CA532A3011A900766E7D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7502CA562A3011A900766E7D /* LaunchScreen.storyboard */; }; 7502CA5F2A31A7D600766E7D /* CountryListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7502CA5E2A31A7D600766E7D /* CountryListViewController.swift */; }; 7502CA602A31A7D600766E7D /* CountryListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7502CA5E2A31A7D600766E7D /* CountryListViewController.swift */; }; @@ -293,6 +294,7 @@ 7501266D2B8A411C00ED5E14 /* FPXPaymentFormController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = FPXPaymentFormController.xib; sourceTree = ""; }; 7501266F2B8A490000ED5E14 /* SelectFPXBankViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectFPXBankViewModel.swift; sourceTree = ""; }; 750126712B8A49BC00ED5E14 /* FPX.Bank+ViewPresentable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FPX.Bank+ViewPresentable.swift"; sourceTree = ""; }; + 750126732B8A580500ED5E14 /* SelectDuitNowOBWBankViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectDuitNowOBWBankViewModel.swift; sourceTree = ""; }; 7502CA552A3011A900766E7D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 7502CA582A3011B000766E7D /* th */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = th; path = th.lproj/LaunchScreen.strings; sourceTree = ""; }; 7502CA5A2A3011B100766E7D /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/LaunchScreen.strings; sourceTree = ""; }; @@ -883,6 +885,7 @@ 75D13DC82B8529790073A831 /* SelectSourceTypePaymentViewModel.swift */, 75D13DCC2B8536B10073A831 /* SelectInstallmentTermsViewModel.swift */, 7501266F2B8A490000ED5E14 /* SelectFPXBankViewModel.swift */, + 750126732B8A580500ED5E14 /* SelectDuitNowOBWBankViewModel.swift */, ); path = "Select Payment From Lists"; sourceTree = ""; @@ -1487,6 +1490,7 @@ 754B78182B8741CD00973B71 /* TapGestureHandler.swift in Sources */, 75D13DCB2B8531D20073A831 /* Assets.swift in Sources */, 986406321CFEA7E4004BCF51 /* CardNumberTextField.swift in Sources */, + 750126742B8A580500ED5E14 /* SelectDuitNowOBWBankViewModel.swift in Sources */, 7501265D2B87CB6500ED5E14 /* PaymentInputsFormController.swift in Sources */, 75D13E042B866E040073A831 /* MobileBankingSourceChooserViewController.swift in Sources */, 75D13DCD2B8536B10073A831 /* SelectInstallmentTermsViewModel.swift in Sources */, From c1e11d71946d024812fd4a4e8e556da760ac21ae Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Sun, 25 Feb 2024 00:36:32 +0700 Subject: [PATCH 150/204] truemoney wallet refactored --- .../Resources/Base.lproj/OmiseSDK.storyboard | 592 ------------------ .../ChoosePaymentCoordinator.swift | 11 +- .../EContextPaymentFormController.swift | 4 - .../FPX/FPXPaymentFormController.xib | 2 +- .../TrueMoneyPaymentFormController.swift | 29 +- .../TrueMoneyPaymentFormController.xib | 39 +- 6 files changed, 64 insertions(+), 613 deletions(-) diff --git a/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard b/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard index f5499165..ec68c61f 100644 --- a/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard +++ b/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard @@ -210,579 +210,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -794,27 +221,8 @@ - - - - - - - - - - - - - - - - - - - diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift index 7aa8c689..252cd64b 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift @@ -154,6 +154,13 @@ class ChoosePaymentCoordinator: ViewAttachable { let listController = SelectPaymentController(viewModel: viewModel) return listController } + + /// Creates Installement screen and attach current flow object inside created controller to be deallocated together + func createTrueMoneyWalletController() -> TrueMoneyPaymentFormController { + let viewController = TrueMoneyPaymentFormController(nibName: nil, bundle: .omiseSDK) + viewController.delegate = self + return viewController + } } extension ChoosePaymentCoordinator: FPXPaymentFormControllerDelegate { @@ -176,7 +183,7 @@ extension ChoosePaymentCoordinator: SelectPaymentMethodDelegate { func didSelectPaymentMethod(_ paymentMethod: PaymentMethod, completion: @escaping () -> Void) { if paymentMethod.requiresAdditionalDetails { switch paymentMethod { - case .mobileBanking: + case .mobileBanking: navigate(to: createMobileBankingController()) case .internetBanking: navigate(to: createInternetBankingController()) @@ -192,6 +199,8 @@ extension ChoosePaymentCoordinator: SelectPaymentMethodDelegate { navigate(to: createFPXController()) case .sourceType(.duitNowOBW): navigate(to: createDuitNowOBWBanksController()) + case .sourceType(.trueMoneyWallet): + navigate(to: createTrueMoneyWalletController()) default: break } } else if let sourceType = paymentMethod.sourceType { diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/EContext/EContextPaymentFormController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/EContext/EContextPaymentFormController.swift index 32bcb068..26127c41 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/EContext/EContextPaymentFormController.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/EContext/EContextPaymentFormController.swift @@ -37,10 +37,6 @@ class EContextPaymentFormController: UIViewController, PaymentFormUIController { [fullNameTextField, emailTextField, phoneNumberTextField] }() - lazy var errorLabels: [UILabel] = { - [fullNameErrorLabel, emailErrorLabel, phoneNumberErrorLabel] - }() - @IBOutlet var formFieldsAccessoryView: UIToolbar! @IBOutlet var gotoPreviousFieldBarButtonItem: UIBarButtonItem! @IBOutlet var gotoNextFieldBarButtonItem: UIBarButtonItem! diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/FPX/FPXPaymentFormController.xib b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/FPX/FPXPaymentFormController.xib index 467f7606..e6868a79 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/FPX/FPXPaymentFormController.xib +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/FPX/FPXPaymentFormController.xib @@ -39,6 +39,7 @@ + @@ -154,7 +155,6 @@ - diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.swift index f701039e..f3e56d26 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.swift +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.swift @@ -13,15 +13,21 @@ class TrueMoneyPaymentFormController: UIViewController, PaymentFormUIController @IBOutlet var contentView: UIScrollView! + @IBOutlet private var phoneNumberLabel: UILabel! @IBOutlet private var phoneNumberTextField: OmiseTextField! @IBOutlet private var submitButton: MainActionButton! @IBOutlet private var requestingIndicatorView: UIActivityIndicatorView! @IBOutlet private var errorLabel: UILabel! - - @IBOutlet var formLabels: [UILabel]! - @IBOutlet var formFields: [OmiseTextField]! - + + lazy var formLabels: [UILabel]! = { + [phoneNumberLabel] + }() + + lazy var formFields: [OmiseTextField]! = { + [phoneNumberTextField] + }() + @IBOutlet var formFieldsAccessoryView: UIToolbar! @IBOutlet var gotoPreviousFieldBarButtonItem: UIBarButtonItem! @IBOutlet var gotoNextFieldBarButtonItem: UIBarButtonItem! @@ -73,8 +79,21 @@ class TrueMoneyPaymentFormController: UIViewController, PaymentFormUIController ) phoneNumberTextField.validator = try? NSRegularExpression(pattern: "\\d{10,11}\\s?", options: []) + setupTextFieldHandlers() } - + + private func setupTextFieldHandlers() { + self.formFields.forEach { field in + setupTextField(field) + } + } + + private func setupTextField(_ field: OmiseTextField) { + field.addTarget(self, action: #selector(validateFieldData), for: .editingChanged) + field.addTarget(self, action: #selector(updateInputAccessoryViewFor), for: .editingDidBegin) + field.addTarget(self, action: #selector(validateTextFieldDataOf), for: .editingDidEnd) + } + override func viewWillLayoutSubviews() { super.viewWillLayoutSubviews() diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.xib b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.xib index 0cd8f3bf..2932fdbc 100644 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.xib +++ b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.xib @@ -1,15 +1,28 @@ - + - - + + + + + + + + + + + + + + + @@ -19,7 +32,11 @@ - + + + + + @@ -27,10 +44,10 @@ - + - - From 9c7ae1338ce6082a85f9507087222b88eae42579 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Sun, 25 Feb 2024 00:39:50 +0700 Subject: [PATCH 151/204] cleanup storyboard --- .../Resources/Base.lproj/OmiseSDK.storyboard | 176 ------------------ 1 file changed, 176 deletions(-) diff --git a/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard b/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard index ec68c61f..5f00d14e 100644 --- a/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard +++ b/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard @@ -4,7 +4,6 @@ - @@ -33,165 +32,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -211,20 +51,4 @@ - - - - - - - - - - - - - - - - From b384849c55a7c1f4f32564cd145d387e3bba8807 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Sun, 25 Feb 2024 00:53:06 +0700 Subject: [PATCH 152/204] Project tree cleanup --- .../AuthorizingPaymentViewController.swift | 0 .../ChoosePaymentCoordinator.swift | 0 .../AtomePaymentFormController.swift | 0 .../AtomePaymentFormViewContext.swift | 0 .../AtomePaymentFormViewModel.swift | 0 .../AtomePaymentFormViewModelProtocol.swift | 0 .../Base/PaymentFormController.swift | 0 .../Atome Payment/Base/PaymentFormStyle.swift | 0 .../PaymentInputProtocol.swift | 0 .../PaymentInputsFormController.swift | 0 .../EContextPaymentFormController.swift | 0 .../EContextPaymentFormController.xib | 0 .../FPX/FPXPaymentFormController.swift | 0 .../FPX/FPXPaymentFormController.xib | 0 .../Other Payments}/PaymentUI.swift | 0 .../TrueMoneyPaymentFormController.swift | 0 .../TrueMoneyPaymentFormController.xib | 0 .../PaymentCreatorController.swift | 0 .../PaymentMethod.swift | 0 .../SelectPaymentMethodDelegate.swift | 0 .../SelectSourcePaymentDelegate.swift | 0 .../SelectSourceTypeDelegate.swift | 0 .../SelectDuitNowOBWBankViewModel.swift | 0 .../SelectFPXBankViewModel.swift | 0 .../SelectInstallmentTermsViewModel.swift | 0 .../SelectPaymentController.swift | 0 .../SelectPaymentMethodViewModel.swift | 0 .../SelectPaymentPresentableProtocol.swift | 0 .../SelectSourceTypePaymentViewModel.swift | 0 .../DuitNowOBW.Bank+ViewPresentable.swift | 0 .../FPX.Bank+ViewPresentable.swift | 0 .../PaymentMethod+ViewPresentable.swift | 0 .../SourceType+ViewPresentable.swift | 0 .../ViewPresentable/ViewPresentable.swift | 0 .../ToDo/ChooseDuitNowObwBankViewModel.swift | 5 - .../ToDo/ChooseFPXBankViewModel.swift | 5 - .../ToDo/FPXBankChooserViewController.swift | 138 -------------- .../ToDo/PaymentFlow+DuitNowOBW.swift | 45 ----- .../AdaptableDynamicTableViewController.swift | 20 -- .../DuitNowOBWBankChooserViewController.swift | 87 --------- ...ntBankingSourceChooserViewController.swift | 118 ------------ ...tsNumberOfTermsChooserViewController.swift | 177 ------------------ ...etBankingSourceChooserViewController.swift | 93 --------- ...leBankingSourceChooserViewController.swift | 114 ----------- .../ToDelete/PaymentOptionTableViewCell.swift | 42 ----- dev.xcodeproj/project.pbxproj | 76 +------- 46 files changed, 8 insertions(+), 912 deletions(-) rename OmiseSDK/Sources/Views/Screens/{AuthorizingPaymentViewController => Authorizing Payment}/AuthorizingPaymentViewController.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/ChoosePaymentCoordinator.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/Other Payments/Atome Payment/AtomePaymentFormController.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/Other Payments/Atome Payment/AtomePaymentFormViewContext.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/Other Payments/Atome Payment/AtomePaymentFormViewModel.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/Other Payments/Atome Payment/AtomePaymentFormViewModelProtocol.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/Other Payments/Atome Payment/Base/PaymentFormController.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/Other Payments/Atome Payment/Base/PaymentFormStyle.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/Other Payments/Atome Payment/Base/To Be Implemented/PaymentInputProtocol.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/Other Payments/Atome Payment/Base/To Be Implemented/PaymentInputsFormController.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/Other Payments/EContext/EContextPaymentFormController.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/Other Payments/EContext/EContextPaymentFormController.xib (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/Other Payments/FPX/FPXPaymentFormController.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/Other Payments/FPX/FPXPaymentFormController.xib (100%) rename OmiseSDK/Sources/Views/{ToDelete => Screens/Choose Payment Methods/Other Payments}/PaymentUI.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.xib (100%) rename OmiseSDK/Sources/Views/{ToDelete => Screens/Choose Payment Methods}/PaymentCreatorController.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/PaymentMethod.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/Select Payment Delegates/SelectPaymentMethodDelegate.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/Select Payment Delegates/SelectSourcePaymentDelegate.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/Select Payment Delegates/SelectSourceTypeDelegate.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/Select Payment From Lists/SelectDuitNowOBWBankViewModel.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/Select Payment From Lists/SelectFPXBankViewModel.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/Select Payment From Lists/SelectInstallmentTermsViewModel.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/Select Payment From Lists/SelectPaymentController.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/Select Payment From Lists/SelectPaymentMethodViewModel.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/Select Payment From Lists/SelectPaymentPresentableProtocol.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/Select Payment From Lists/SelectSourceTypePaymentViewModel.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/ViewPresentable/DuitNowOBW.Bank+ViewPresentable.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/ViewPresentable/FPX.Bank+ViewPresentable.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/ViewPresentable/PaymentMethod+ViewPresentable.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/ViewPresentable/SourceType+ViewPresentable.swift (100%) rename OmiseSDK/Sources/Views/Screens/{ChoosePaymentMethods => Choose Payment Methods}/ViewPresentable/ViewPresentable.swift (100%) delete mode 100644 OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/ChooseDuitNowObwBankViewModel.swift delete mode 100644 OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/ChooseFPXBankViewModel.swift delete mode 100644 OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/FPXBankChooserViewController.swift delete mode 100644 OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/PaymentFlow+DuitNowOBW.swift delete mode 100644 OmiseSDK/Sources/Views/ToDelete/AdaptableDynamicTableViewController.swift delete mode 100644 OmiseSDK/Sources/Views/ToDelete/DuitNowOBWBankChooserViewController.swift delete mode 100644 OmiseSDK/Sources/Views/ToDelete/InstallmentBankingSourceChooserViewController.swift delete mode 100644 OmiseSDK/Sources/Views/ToDelete/InstallmentsNumberOfTermsChooserViewController.swift delete mode 100644 OmiseSDK/Sources/Views/ToDelete/InternetBankingSourceChooserViewController.swift delete mode 100644 OmiseSDK/Sources/Views/ToDelete/MobileBankingSourceChooserViewController.swift delete mode 100644 OmiseSDK/Sources/Views/ToDelete/PaymentOptionTableViewCell.swift diff --git a/OmiseSDK/Sources/Views/Screens/AuthorizingPaymentViewController/AuthorizingPaymentViewController.swift b/OmiseSDK/Sources/Views/Screens/Authorizing Payment/AuthorizingPaymentViewController.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/AuthorizingPaymentViewController/AuthorizingPaymentViewController.swift rename to OmiseSDK/Sources/Views/Screens/Authorizing Payment/AuthorizingPaymentViewController.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ChoosePaymentCoordinator.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/AtomePaymentFormController.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/AtomePaymentFormController.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/AtomePaymentFormController.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/AtomePaymentFormController.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/AtomePaymentFormViewContext.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/AtomePaymentFormViewContext.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/AtomePaymentFormViewContext.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/AtomePaymentFormViewContext.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/AtomePaymentFormViewModel.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/AtomePaymentFormViewModel.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/AtomePaymentFormViewModel.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/AtomePaymentFormViewModel.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/AtomePaymentFormViewModelProtocol.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/AtomePaymentFormViewModelProtocol.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/AtomePaymentFormViewModelProtocol.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/AtomePaymentFormViewModelProtocol.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/Base/PaymentFormController.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/Base/PaymentFormController.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/Base/PaymentFormController.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/Base/PaymentFormController.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/Base/PaymentFormStyle.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/Base/PaymentFormStyle.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/Base/PaymentFormStyle.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/Base/PaymentFormStyle.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/Base/To Be Implemented/PaymentInputProtocol.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/Base/To Be Implemented/PaymentInputProtocol.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/Base/To Be Implemented/PaymentInputProtocol.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/Base/To Be Implemented/PaymentInputProtocol.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/Base/To Be Implemented/PaymentInputsFormController.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/Base/To Be Implemented/PaymentInputsFormController.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/Atome Payment/Base/To Be Implemented/PaymentInputsFormController.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/Base/To Be Implemented/PaymentInputsFormController.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/EContext/EContextPaymentFormController.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/EContext/EContextPaymentFormController.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/EContext/EContextPaymentFormController.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/EContext/EContextPaymentFormController.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/EContext/EContextPaymentFormController.xib b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/EContext/EContextPaymentFormController.xib similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/EContext/EContextPaymentFormController.xib rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/EContext/EContextPaymentFormController.xib diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/FPX/FPXPaymentFormController.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/FPX/FPXPaymentFormController.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/FPX/FPXPaymentFormController.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/FPX/FPXPaymentFormController.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/FPX/FPXPaymentFormController.xib b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/FPX/FPXPaymentFormController.xib similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/FPX/FPXPaymentFormController.xib rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/FPX/FPXPaymentFormController.xib diff --git a/OmiseSDK/Sources/Views/ToDelete/PaymentUI.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/PaymentUI.swift similarity index 100% rename from OmiseSDK/Sources/Views/ToDelete/PaymentUI.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/PaymentUI.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.xib b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.xib similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.xib rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.xib diff --git a/OmiseSDK/Sources/Views/ToDelete/PaymentCreatorController.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/PaymentCreatorController.swift similarity index 100% rename from OmiseSDK/Sources/Views/ToDelete/PaymentCreatorController.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/PaymentCreatorController.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/PaymentMethod.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/PaymentMethod.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/PaymentMethod.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/PaymentMethod.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment Delegates/SelectPaymentMethodDelegate.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment Delegates/SelectPaymentMethodDelegate.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment Delegates/SelectPaymentMethodDelegate.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment Delegates/SelectPaymentMethodDelegate.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment Delegates/SelectSourcePaymentDelegate.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment Delegates/SelectSourcePaymentDelegate.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment Delegates/SelectSourcePaymentDelegate.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment Delegates/SelectSourcePaymentDelegate.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment Delegates/SelectSourceTypeDelegate.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment Delegates/SelectSourceTypeDelegate.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment Delegates/SelectSourceTypeDelegate.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment Delegates/SelectSourceTypeDelegate.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectDuitNowOBWBankViewModel.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectDuitNowOBWBankViewModel.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectDuitNowOBWBankViewModel.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectDuitNowOBWBankViewModel.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectFPXBankViewModel.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectFPXBankViewModel.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectFPXBankViewModel.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectFPXBankViewModel.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectInstallmentTermsViewModel.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectInstallmentTermsViewModel.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectInstallmentTermsViewModel.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectInstallmentTermsViewModel.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectPaymentController.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentController.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectPaymentController.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentController.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectPaymentMethodViewModel.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentMethodViewModel.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectPaymentMethodViewModel.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentMethodViewModel.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectPaymentPresentableProtocol.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentPresentableProtocol.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectPaymentPresentableProtocol.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentPresentableProtocol.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectSourceTypePaymentViewModel.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectSourceTypePaymentViewModel.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/Select Payment From Lists/SelectSourceTypePaymentViewModel.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectSourceTypePaymentViewModel.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ViewPresentable/DuitNowOBW.Bank+ViewPresentable.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/DuitNowOBW.Bank+ViewPresentable.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ViewPresentable/DuitNowOBW.Bank+ViewPresentable.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/DuitNowOBW.Bank+ViewPresentable.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ViewPresentable/FPX.Bank+ViewPresentable.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/FPX.Bank+ViewPresentable.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ViewPresentable/FPX.Bank+ViewPresentable.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/FPX.Bank+ViewPresentable.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ViewPresentable/PaymentMethod+ViewPresentable.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/PaymentMethod+ViewPresentable.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ViewPresentable/PaymentMethod+ViewPresentable.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/PaymentMethod+ViewPresentable.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ViewPresentable/SourceType+ViewPresentable.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/SourceType+ViewPresentable.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ViewPresentable/SourceType+ViewPresentable.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/SourceType+ViewPresentable.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ViewPresentable/ViewPresentable.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/ViewPresentable.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ViewPresentable/ViewPresentable.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/ViewPresentable.swift diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/ChooseDuitNowObwBankViewModel.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/ChooseDuitNowObwBankViewModel.swift deleted file mode 100644 index 44150325..00000000 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/ChooseDuitNowObwBankViewModel.swift +++ /dev/null @@ -1,5 +0,0 @@ -import Foundation - -class ChooseDuitNowObwBankViewModel { - -} diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/ChooseFPXBankViewModel.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/ChooseFPXBankViewModel.swift deleted file mode 100644 index e3caa117..00000000 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/ChooseFPXBankViewModel.swift +++ /dev/null @@ -1,5 +0,0 @@ -import Foundation - -class ChooseFPXBankViewModel { - -} diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/FPXBankChooserViewController.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/FPXBankChooserViewController.swift deleted file mode 100644 index c42e32f2..00000000 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/FPXBankChooserViewController.swift +++ /dev/null @@ -1,138 +0,0 @@ -import UIKit -import os - -class FPXBankChooserViewController: AdaptableDynamicTableViewController, PaymentSourceChooser { - var email: String? - var flowSession: PaymentCreatorFlowSession? - private let defaultImage: String = "FPX/unknown" - private let message = NSLocalizedString( - "fpx.bank-chooser.no-banks-available.text", - bundle: .omiseSDK, - value: "Cannot retrieve list of banks.\nPlease try again later.", - comment: "A descriptive text telling the user when there's no banks available" - ) - - override var showingValues: [Capability.PaymentMethod.Bank] { - didSet { - os_log("FPX Bank Chooser: Showing options - %{private}@", - log: uiLogObject, - type: .info, - showingValues.map { $0.name }.joined(separator: ", ")) - } - } - - @IBInspectable var preferredPrimaryColor: UIColor? { - didSet { - applyPrimaryColor() - } - } - - @IBInspectable var preferredSecondaryColor: UIColor? { - didSet { - applySecondaryColor() - } - } - - override func viewDidLoad() { - super.viewDidLoad() - applyPrimaryColor() - applySecondaryColor() - - navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil) - - if showingValues.isEmpty { - displayEmptyMessage() - } else { - restore() - } - } - - override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) - - if let cell = cell as? PaymentOptionTableViewCell { - cell.separatorView.backgroundColor = UIColor.omiseSecondary - } - let bank = showingValues[indexPath.row] - cell.accessoryView?.tintColor = UIColor.omiseSecondary - cell.textLabel?.text = bank.name - cell.imageView?.image = bankImage(bank: bank.code) - cell.textLabel?.textColor = UIColor.omisePrimary - - if !bank.isActive { - disableCell(cell: cell) - } - - return cell - } - - override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - guard let cell = tableView.cellForRow(at: indexPath) else { - return - } - - let selectedBank = item(at: indexPath) - guard let bank = Source.Payment.FPX.Bank(rawValue: selectedBank.code) else { - return - } - -// let paymentInformation = Source.Payment.fpx(.bank(bank, email: email)) - - tableView.deselectRow(at: indexPath, animated: true) - - os_log("FPX Banking Chooser: %{private}@ was selected", log: uiLogObject, type: .info, selectedBank.name) - - let oldAccessoryView = cell.accessoryView - let loadingIndicator = UIActivityIndicatorView(style: UIActivityIndicatorView.Style.gray) - loadingIndicator.color = UIColor.omiseSecondary - cell.accessoryView = loadingIndicator - loadingIndicator.startAnimating() - view.isUserInteractionEnabled = false - -// - } - - private func applyPrimaryColor() { - guard isViewLoaded else { - return - } - } - - private func applySecondaryColor() { - // Intentionally empty (SonarCloud warning fix) - } - - private func bankImage(bank: String) -> UIImage? { - if let image = UIImage(omise: "FPX/" + bank) { - return image - } else { - return UIImage(omise: defaultImage) - } - } - - private func disableCell(cell: UITableViewCell) { - cell.selectionStyle = UITableViewCell.SelectionStyle.none - cell.contentView.alpha = 0.5 - cell.isUserInteractionEnabled = false - } - - private func displayEmptyMessage() { - let label = UILabel( - frame: CGRect(x: 0, y: 0, width: tableView.bounds.size.width, height: tableView.bounds.size.height) - ) - - label.text = message - label.textColor = UIColor.omisePrimary - label.numberOfLines = 0 - label.textAlignment = .center - label.sizeToFit() - - tableView.backgroundView = label - tableView.separatorStyle = .none - } - - private func restore() { - tableView.backgroundView = nil - tableView.separatorStyle = .singleLine - } -} diff --git a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/PaymentFlow+DuitNowOBW.swift b/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/PaymentFlow+DuitNowOBW.swift deleted file mode 100644 index cdcfa9fe..00000000 --- a/OmiseSDK/Sources/Views/Screens/ChoosePaymentMethods/ToDo/PaymentFlow+DuitNowOBW.swift +++ /dev/null @@ -1,45 +0,0 @@ -import UIKit - -// extension ChoosePaymentCoordinator { -// func createDuitNowOBWController(title: String) -> SelectPaymentController { -// let listController = SelectPaymentController() -// if #available(iOSApplicationExtension 11.0, *) { -// listController.navigationItem.largeTitleDisplayMode = .never -// } -// listController.navigationItem.title = title -// listController.navigationItem.backBarButtonItem = .empty -// -// let banks = Source.Payment.DuitNowOBW.Bank.allCases.sorted { -// $0.localizedTitle.localizedCaseInsensitiveCompare($1.localizedTitle) == .orderedAscending -// } -// -// listController.items = banks.map { -// TableCellContext( -// title: $0.localizedTitle, -// icon: UIImage(omise: $0.iconName), -// accessoryIcon: UIImage(omise: "Redirect") -// ) -// } -// -// listController.didSelectCellHandler = { [banks, weak listController] cell, indexPath in -// guard let listController = listController else { return } -// -//// cell.startAccessoryActivityIndicator() -// listController.lockUserInferface() -// -// if let bank = banks.at(indexPath.row) { -// print("Bank selected: \(bank)") -// } -// -// // if let paymentMethod = viewModel.paymentMethod(at: indexPath.row) { -// // self.didSelectPaymentMethod( -// // paymentMethod, -// // listController: listController, -// // delegate: delegate -// // ) -// // } -// } -// -// return listController -// } -// } diff --git a/OmiseSDK/Sources/Views/ToDelete/AdaptableDynamicTableViewController.swift b/OmiseSDK/Sources/Views/ToDelete/AdaptableDynamicTableViewController.swift deleted file mode 100644 index 1e83673c..00000000 --- a/OmiseSDK/Sources/Views/ToDelete/AdaptableDynamicTableViewController.swift +++ /dev/null @@ -1,20 +0,0 @@ -import UIKit - -public class AdaptableDynamicTableViewController: UITableViewController { - - public var showingValues: [Item] = [] { - didSet { - if isViewLoaded { - tableView.reloadData() - } - } - } - - public override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return showingValues.count - } - - public func item(at indexPath: IndexPath) -> Item { - return showingValues[indexPath.row] - } -} diff --git a/OmiseSDK/Sources/Views/ToDelete/DuitNowOBWBankChooserViewController.swift b/OmiseSDK/Sources/Views/ToDelete/DuitNowOBWBankChooserViewController.swift deleted file mode 100644 index b305d67e..00000000 --- a/OmiseSDK/Sources/Views/ToDelete/DuitNowOBWBankChooserViewController.swift +++ /dev/null @@ -1,87 +0,0 @@ -import UIKit -import os - -class DuitNowOBWBankChooserViewController: UITableViewController, - PaymentSourceChooser { - func customize(element bank: Source.Payment.DuitNowOBW.Bank, tableView: UITableView, cell: UITableViewCell, indexPath: IndexPath) { - cell.textLabel?.text = bank.localizedTitle - cell.imageView?.image = UIImage(omise: bank.iconName) - cell.accessoryView = UIImageView(image: UIImage(omise: "Next")) - - if let cell = cell as? PaymentOptionTableViewCell { - cell.separatorView.backgroundColor = UIColor.omiseSecondary - } - cell.accessoryView?.tintColor = UIColor.omiseSecondary - } - - var flowSession: PaymentCreatorFlowSession? - - var showingValues: [Source.Payment.DuitNowOBW.Bank] = [] { - didSet { - os_log("DuitNow OBW Bank Chooser: Showing options - %{private}@", - log: uiLogObject, - type: .info, - showingValues.map { $0.description }.joined(separator: ", ")) - } - } - - @IBOutlet private var bankNameLabels: [UILabel]! - - @IBInspectable var preferredPrimaryColor: UIColor? { - didSet { - applyPrimaryColor() - } - } - - @IBInspectable var preferredSecondaryColor: UIColor? { - didSet { - applySecondaryColor() - } - } - - override func viewDidLoad() { - super.viewDidLoad() - applyPrimaryColor() - applySecondaryColor() - navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil) - } - - override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - guard let cell = tableView.cellForRow(at: indexPath) else { - return - } - - let selectedBank = showingValues[indexPath.row] - - tableView.deselectRow(at: indexPath, animated: true) - - os_log("DuitNow OBW Bank List Chooser: %{private}@ was selected", log: uiLogObject, type: .info, selectedBank.description) - - let oldAccessoryView = cell.accessoryView - let loadingIndicator = UIActivityIndicatorView(style: UIActivityIndicatorView.Style.gray) - loadingIndicator.color = UIColor.omiseSecondary - cell.accessoryView = loadingIndicator - loadingIndicator.startAnimating() - view.isUserInteractionEnabled = false - - flowSession?.requestCreateSource(.duitNowOBW(.bank(selectedBank))) { [weak self] _ in - guard let self = self else { return } - cell.accessoryView = oldAccessoryView - self.view.isUserInteractionEnabled = true - } - } - - private func applyPrimaryColor() { - guard isViewLoaded else { - return - } - - bankNameLabels.forEach { - $0.textColor = UIColor.omisePrimary - } - } - - private func applySecondaryColor() { - // Intentionally empty (SonarCloud warning fix) - } -} diff --git a/OmiseSDK/Sources/Views/ToDelete/InstallmentBankingSourceChooserViewController.swift b/OmiseSDK/Sources/Views/ToDelete/InstallmentBankingSourceChooserViewController.swift deleted file mode 100644 index 3ebee7e9..00000000 --- a/OmiseSDK/Sources/Views/ToDelete/InstallmentBankingSourceChooserViewController.swift +++ /dev/null @@ -1,118 +0,0 @@ -import UIKit -import os - -// swiftlint:disable:next type_name -class InstallmentBankingSourceChooserViewController: UITableViewController, - PaymentSourceChooser { - var flowSession: PaymentCreatorFlowSession? - - var showingValues: [SourceType] = [] { - didSet { - os_log("Installment Brand Chooser: Showing options - %{private}@", - log: uiLogObject, - type: .info, - showingValues.map { $0.rawValue }.joined(separator: ", ")) - } - } - - @IBOutlet var bankNameLabels: [UILabel]! - - @IBInspectable var preferredPrimaryColor: UIColor? { - didSet { - applyPrimaryColor() - } - } - - @IBInspectable var preferredSecondaryColor: UIColor? { - didSet { - applySecondaryColor() - } - } - - override func viewDidLoad() { - super.viewDidLoad() - applyPrimaryColor() - applySecondaryColor() - navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil) - } - - func customize(element: SourceType, tableView: UITableView, cell: UITableViewCell, indexPath: IndexPath) { - - } - - /* - override func staticIndexPath(forValue value: SourceType) -> IndexPath { - switch value { - case .installmentBBL: - return IndexPath(row: 0, section: 0) - case .installmentKBank: - return IndexPath(row: 1, section: 0) - case .installmentBAY: - return IndexPath(row: 2, section: 0) - case .installmentFirstChoice: - return IndexPath(row: 3, section: 0) - case .installmentKTC: - return IndexPath(row: 4, section: 0) - case .installmentMBB: - return IndexPath(row: 5, section: 0) - case .installmentSCB: - return IndexPath(row: 6, section: 0) - case .installmentTTB: - return IndexPath(row: 7, section: 0) - case .installmentUOB: - return IndexPath(row: 8, section: 0) - default: - preconditionFailure("This value is not supported for built-in chooser") - } - } - */ - - override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = super.tableView(tableView, cellForRowAt: indexPath) - - if let cell = cell as? PaymentOptionTableViewCell { - cell.separatorView.backgroundColor = UIColor.omiseSecondary - } - cell.accessoryView?.tintColor = UIColor.omiseSecondary - return cell - } - - override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - guard let cell = tableView.cellForRow(at: indexPath) else { - return - } - -// let selectedBrand = item(at: indexPath) -// os_log("Installment Brand Chooser: %{private}@ was selected", log: uiLogObject, type: .info, selectedBrand.description) - - performSegue(withIdentifier: "GoToInstallmentTermsChooserSegue", sender: cell) - } - - override func prepare(for segue: UIStoryboardSegue, sender: Any?) { - guard let cell = sender as? UITableViewCell, let indexPath = tableView.indexPath(for: cell) else { - return - } - let sourceType = showingValues[indexPath.row] - if segue.identifier == "GoToInstallmentTermsChooserSegue", - let installmentTermsChooserViewController = segue.destination as? InstallmentsNumberOfTermsChooserViewController { - installmentTermsChooserViewController.sourceType = sourceType - installmentTermsChooserViewController.flowSession = self.flowSession - installmentTermsChooserViewController.preferredPrimaryColor = self.preferredPrimaryColor - installmentTermsChooserViewController.preferredSecondaryColor = self.preferredSecondaryColor - } - } - - private func applyPrimaryColor() { - guard isViewLoaded else { - return - } - - bankNameLabels.forEach { - $0.textColor = UIColor.omisePrimary - } - } - - private func applySecondaryColor() { - // Intentionally empty (SonarCloud warning fix) - } -} diff --git a/OmiseSDK/Sources/Views/ToDelete/InstallmentsNumberOfTermsChooserViewController.swift b/OmiseSDK/Sources/Views/ToDelete/InstallmentsNumberOfTermsChooserViewController.swift deleted file mode 100644 index 61feca4e..00000000 --- a/OmiseSDK/Sources/Views/ToDelete/InstallmentsNumberOfTermsChooserViewController.swift +++ /dev/null @@ -1,177 +0,0 @@ -import UIKit -import os - -// swiftlint:disable:next type_name -class InstallmentsNumberOfTermsChooserViewController: UITableViewController, PaymentSourceChooser { - var flowSession: PaymentCreatorFlowSession? - - var sourceType: SourceType? { - didSet { - os_log("Installment Chooser: Showing options - %{private}@", - log: uiLogObject, - type: .info, - numberOfTerms.map { String($0) }.joined(separator: ", ")) - if let sourceType = sourceType { - numberOfTerms = Source.Payment.Installment.availableTerms(for: sourceType) - navigationItem.title = headerTitle(for: sourceType) - } else { - numberOfTerms = [] - navigationItem.title = "" - } - } - } - - // swiftlint:disable:next function_body_length - func headerTitle(for sourceType: SourceType) -> String { - switch sourceType { - case .installmentBAY: - return NSLocalizedString( - "installment-number-of-terms-choosers.bbl.navigation-item.title", - bundle: .omiseSDK, - value: "Krungsri", - comment: "A navigation title for the choosing installment terms screen with the `Krungsri` selected" - ) - case .installmentBBL: - return NSLocalizedString( - "installment-number-of-terms-choosers.bay.navigation-item.title", - bundle: .omiseSDK, - value: "Bangkok Bank", - comment: "A navigation title for the choosing installment terms screen with the `Bangkok Bank` selected" - ) - case .installmentFirstChoice: - return NSLocalizedString( - "installment-number-of-terms-choosers.ktc.navigation-item.title", - bundle: .omiseSDK, - value: "Krungsri First Choice", - comment: "A navigation title for the choosing installment terms screen with the `Krungsri First Choice` selected" - ) - case .installmentKBank: - return NSLocalizedString( - "installment-number-of-terms-choosers.first-choice.navigation-item.title", - bundle: .omiseSDK, - value: "Kasikorn", - comment: "A navigation title for the choosing installment terms screen with the `Kasikorn` selected" - ) - case .installmentKTC: - return NSLocalizedString( - "installment-number-of-terms-choosers.k-bank.navigation-item.title", - bundle: .omiseSDK, - value: "KTC", - comment: "A navigation title for the choosing installment terms screen with the `KTC` selected" - ) - case .installmentMBB: - return NSLocalizedString( - "installment-number-of-terms-choosers.mbb.navigation-item.title", - bundle: .omiseSDK, - value: "MBB", - comment: "A navigation title for the choosing installment terms screen with the `MBB` selected" - ) - case .installmentSCB: - return NSLocalizedString( - "installment-number-of-terms-choosers.scb.navigation-item.title", - bundle: .omiseSDK, - value: "SCB", - comment: "A navigation title for the choosing installment terms screen with the `SCB` selected" - ) - case .installmentTTB: - return NSLocalizedString( - "installment-number-of-terms-choosers.ttb.navigation-item.title", - bundle: .omiseSDK, - value: "TTB", - comment: "A navigation title for the choosing installment terms screen with the `TTB` selected" - ) - case .installmentUOB: - return NSLocalizedString( - "installment-number-of-terms-choosers.default.navigation-item.title", - bundle: .omiseSDK, - value: "Installments Terms", - comment: "A navigation title for the choosing installment terms screen with the `Installments Terms` selected" - ) - default: - return "" - } - } - - var numberOfTerms: [Int] = [] { - didSet { - if isViewLoaded { - tableView.reloadData() - } - } - } - - @IBInspectable var preferredPrimaryColor: UIColor? { - didSet { - applyPrimaryColor() - } - } - - @IBInspectable var preferredSecondaryColor: UIColor? { - didSet { - applySecondaryColor() - } - } - - override func viewDidLoad() { - super.viewDidLoad() - applyPrimaryColor() - applySecondaryColor() - navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil) - } - - override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return numberOfTerms.count - } - - override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCell(withIdentifier: "NumberOfTermCell", for: indexPath) - let numberOfTermsTitleFormat = NSLocalizedString( - "installments.number-of-terms-chooser.number-of-terms-cell.label.text", - bundle: .omiseSDK, - value: "%d months", - comment: "Number of terms option text displayed as a title of the number of terms option cell in number of terms chooser scene" - ) - cell.textLabel?.text = String.localizedStringWithFormat(numberOfTermsTitleFormat, numberOfTerms[indexPath.row]) - cell.textLabel?.textColor = UIColor.omisePrimary - - if let cell = cell as? PaymentOptionTableViewCell { - cell.separatorView.backgroundColor = UIColor.omiseSecondary - } - cell.accessoryView?.tintColor = UIColor.omiseSecondary - - return cell - } - - override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - guard let sourceType = sourceType else { return } - - let cell = tableView.cellForRow(at: indexPath) - tableView.deselectRow(at: indexPath, animated: true) - - let oldAccessoryView = cell?.accessoryView - let loadingIndicator = UIActivityIndicatorView(style: UIActivityIndicatorView.Style.gray) - loadingIndicator.color = UIColor.omiseSecondary - cell?.accessoryView = loadingIndicator - loadingIndicator.startAnimating() - view.isUserInteractionEnabled = false - - let paymentInformation = Source.Payment.Installment( - installmentTerm: self.numberOfTerms[indexPath.row], - zeroInterestInstallments: false, - sourceType: sourceType - ) - - flowSession?.requestCreateSource(.installment(paymentInformation)) { _ in - cell?.accessoryView = oldAccessoryView - self.view.isUserInteractionEnabled = true - } - } - - private func applyPrimaryColor() { - // Intentionally empty (SonarCloud warning fix) - } - - private func applySecondaryColor() { - // Intentionally empty (SonarCloud warning fix) - } -} diff --git a/OmiseSDK/Sources/Views/ToDelete/InternetBankingSourceChooserViewController.swift b/OmiseSDK/Sources/Views/ToDelete/InternetBankingSourceChooserViewController.swift deleted file mode 100644 index d548ece5..00000000 --- a/OmiseSDK/Sources/Views/ToDelete/InternetBankingSourceChooserViewController.swift +++ /dev/null @@ -1,93 +0,0 @@ -import UIKit -import os - -// swiftlint:disable:next type_name -class InternetBankingSourceChooserViewController: UITableViewController, - PaymentSourceChooser { - - var flowSession: PaymentCreatorFlowSession? - - var showingValues: [SourceType] = [] { - didSet { - os_log("Internet Banking Chooser: Showing options - %{private}@", - log: uiLogObject, - type: .info, - showingValues.map { $0.rawValue }.joined(separator: ", ")) - } - } - - @IBOutlet var internetBankingNameLabels: [UILabel]! - - @IBInspectable var preferredPrimaryColor: UIColor? { - didSet { - applyPrimaryColor() - } - } - - @IBInspectable var preferredSecondaryColor: UIColor? { - didSet { - applySecondaryColor() - } - } - - override func viewDidLoad() { - super.viewDidLoad() - applyPrimaryColor() - applySecondaryColor() - navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil) - } - - func customize(element: SourceType, tableView: UITableView, cell: UITableViewCell, indexPath: IndexPath) { - if let cell = cell as? PaymentOptionTableViewCell { - cell.separatorView.backgroundColor = UIColor.omiseSecondary - } - cell.accessoryView?.tintColor = UIColor.omiseSecondary - } - -/* - override func staticIndexPath(forValue value: SourceType) -> IndexPath { - switch value { - case .internetBankingBBL: - return IndexPath(row: 0, section: 0) - case .internetBankingBAY: - return IndexPath(row: 1, section: 0) - default: - preconditionFailure("This value is not supported for the built-in chooser") - } - } - */ - - override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - let cell = tableView.cellForRow(at: indexPath) - tableView.deselectRow(at: indexPath, animated: true) - let sourceType = showingValues[indexPath.row] - - os_log("Internet Banking Chooser: %{private}@ was selected", log: uiLogObject, type: .info, sourceType.rawValue) - - let oldAccessoryView = cell?.accessoryView - let loadingIndicator = UIActivityIndicatorView(style: UIActivityIndicatorView.Style.gray) - loadingIndicator.color = UIColor.omiseSecondary - cell?.accessoryView = loadingIndicator - loadingIndicator.startAnimating() - view.isUserInteractionEnabled = false - - flowSession?.requestCreateSource(.sourceType(sourceType)) { _ in - cell?.accessoryView = oldAccessoryView - self.view.isUserInteractionEnabled = true - } - } - - private func applyPrimaryColor() { - guard isViewLoaded else { - return - } - - internetBankingNameLabels.forEach { - $0.textColor = UIColor.omisePrimary - } - } - - private func applySecondaryColor() { - // Intentionally empty (SonarCloud warning fix) - } -} diff --git a/OmiseSDK/Sources/Views/ToDelete/MobileBankingSourceChooserViewController.swift b/OmiseSDK/Sources/Views/ToDelete/MobileBankingSourceChooserViewController.swift deleted file mode 100644 index aa56f950..00000000 --- a/OmiseSDK/Sources/Views/ToDelete/MobileBankingSourceChooserViewController.swift +++ /dev/null @@ -1,114 +0,0 @@ -import UIKit -import os - -class MobileBankingSourceChooserViewController: UITableViewController, - PaymentSourceChooser { - func customize(element: SourceType, tableView: UITableView, cell: UITableViewCell, indexPath: IndexPath) { -// cell.textLabel?.text = title(for: paymentOption.so) -// cell.imageView?.image = paymentOption.listIcon - cell.accessoryView = UIImageView(image: UIImage(omise: "Next")) - - if let cell = cell as? PaymentOptionTableViewCell { - cell.separatorView.backgroundColor = UIColor.omiseSecondary - } - cell.accessoryView?.tintColor = UIColor.omiseSecondary - } - - var flowSession: PaymentCreatorFlowSession? - - var showingValues: [SourceType] = [] { - didSet { - os_log("Mobile Banking Chooser: Showing options - %{private}@", - log: uiLogObject, - type: .info, - showingValues.map { $0.rawValue }.joined(separator: ", ")) - } - } - - @IBOutlet private var mobileBankingNameLabels: [UILabel]! - - @IBInspectable var preferredPrimaryColor: UIColor? { - didSet { - applyPrimaryColor() - } - } - - @IBInspectable var preferredSecondaryColor: UIColor? { - didSet { - applySecondaryColor() - } - } - - override func viewDidLoad() { - super.viewDidLoad() -// applyPrimaryColor() -// applySecondaryColor() - navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil) - } - - func title(for sourceType: SourceType) -> String? { - switch sourceType { - case .mobileBankingSCB: return "SCB EASY" - case .mobileBankingKBank: return "K PLUS" - case .mobileBankingBAY: return "KMA" - case .mobileBankingBBL: return "Bualuang mBanking" - case .mobileBankingKTB: return "Krungthai Next" - default: return nil - } - } - - func icon(for sourceType: SourceType) -> UIImage? { - switch sourceType { - case .mobileBankingSCB: return UIImage(omise: "SCB") - case .mobileBankingKBank: return UIImage(omise: "KPlus") - case .mobileBankingBAY: return UIImage(omise: "KMA") - case .mobileBankingBBL: return UIImage(omise: "BBL M") - case .mobileBankingKTB: return UIImage(omise: "KTB Next") - default: return nil - } - } - - override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = super.tableView(tableView, cellForRowAt: indexPath) - - if let cell = cell as? PaymentOptionTableViewCell { - cell.separatorView.backgroundColor = UIColor.omiseSecondary - } - cell.accessoryView?.tintColor = UIColor.omiseSecondary - return cell - } - - override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - let cell = tableView.cellForRow(at: indexPath) - tableView.deselectRow(at: indexPath, animated: true) - let sourceType = showingValues[indexPath.row] - - os_log("Mobile Banking Chooser: %{private}@ was selected", log: uiLogObject, type: .info, sourceType.rawValue) - - let oldAccessoryView = cell?.accessoryView - let loadingIndicator = UIActivityIndicatorView(style: UIActivityIndicatorView.Style.gray) - loadingIndicator.color = UIColor.omiseSecondary - cell?.accessoryView = loadingIndicator - loadingIndicator.startAnimating() - view.isUserInteractionEnabled = false - - flowSession?.requestCreateSource(.sourceType(sourceType)) { _ in - cell?.accessoryView = oldAccessoryView - self.view.isUserInteractionEnabled = true - } - } - - private func applyPrimaryColor() { - guard isViewLoaded else { - return - } - - mobileBankingNameLabels.forEach { - $0.textColor = UIColor.omisePrimary - } - } - - private func applySecondaryColor() { - // Intentionally empty (SonarCloud warning fix) - } -} diff --git a/OmiseSDK/Sources/Views/ToDelete/PaymentOptionTableViewCell.swift b/OmiseSDK/Sources/Views/ToDelete/PaymentOptionTableViewCell.swift deleted file mode 100644 index f489dda8..00000000 --- a/OmiseSDK/Sources/Views/ToDelete/PaymentOptionTableViewCell.swift +++ /dev/null @@ -1,42 +0,0 @@ -import UIKit - -class PaymentOptionTableViewCell: UITableViewCell { - - let separatorView = UIView() - @IBInspectable var separatorHeight: CGFloat = 1 - - override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - super.init(style: style, reuseIdentifier: reuseIdentifier) - initializeInstance() - } - - required init?(coder aDecoder: NSCoder) { - super.init(coder: aDecoder) - initializeInstance() - } - - private func initializeInstance() { - addSubview(separatorView) - - let selectedBackgroundView = UIView() - selectedBackgroundView.backgroundColor = UIColor.selectedCellBackgroundColor - self.selectedBackgroundView = selectedBackgroundView - } - - override func layoutSubviews() { - super.layoutSubviews() - - contentView.frame.size.height = bounds.height - separatorHeight - var separatorFrame = bounds - if let textLabel = self.textLabel { - let textLabelFrame = self.convert(textLabel.frame, from: contentView) - (_, separatorFrame) = separatorFrame.divided(atDistance: textLabelFrame.minX, from: .minXEdge) - } else { - (_, separatorFrame) = separatorFrame.divided(atDistance: layoutMargins.left, from: .minXEdge) - } - separatorFrame.origin.y = bounds.height - separatorHeight - separatorFrame.size.height = separatorHeight - separatorView.frame = separatorFrame - } - -} diff --git a/dev.xcodeproj/project.pbxproj b/dev.xcodeproj/project.pbxproj index 2d31c50b..823c953e 100644 --- a/dev.xcodeproj/project.pbxproj +++ b/dev.xcodeproj/project.pbxproj @@ -13,7 +13,6 @@ 229E14581D0EBAB5000511DE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 229E14541D0EBAB5000511DE /* AppDelegate.swift */; }; 229E145A1D0EBAB5000511DE /* ProductDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 229E14561D0EBAB5000511DE /* ProductDetailViewController.swift */; }; 22E0DBD71D0EBE2E00472C74 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 22E0DBD61D0EBE2E00472C74 /* Assets.xcassets */; }; - 731A75D325E3604A002353C0 /* FPXBankChooserViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 731A75D225E3604A002353C0 /* FPXBankChooserViewController.swift */; }; 73F9BA4B25E6053700F55CA8 /* FPXPaymentFormController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73F9BA4A25E6053700F55CA8 /* FPXPaymentFormController.swift */; }; 7501265D2B87CB6500ED5E14 /* PaymentInputsFormController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7501265C2B87CB6500ED5E14 /* PaymentInputsFormController.swift */; }; 7501265F2B8893C900ED5E14 /* PaymentFormController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7501265E2B8893C900ED5E14 /* PaymentFormController.swift */; }; @@ -110,7 +109,6 @@ 75D13D792B833F160073A831 /* ViewAttachable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75D13D782B833F160073A831 /* ViewAttachable.swift */; }; 75D13D8A2B8382760073A831 /* ClosureBarButtonItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75D13D892B8382760073A831 /* ClosureBarButtonItem.swift */; }; 75D13D8C2B8385820073A831 /* UIBarButtonItem+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75D13D8B2B8385820073A831 /* UIBarButtonItem+Helpers.swift */; }; - 75D13D902B839FC60073A831 /* PaymentFlow+DuitNowOBW.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75D13D8F2B839FC60073A831 /* PaymentFlow+DuitNowOBW.swift */; }; 75D13DA52B83B58B0073A831 /* Source.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75D13D982B83B58B0073A831 /* Source.swift */; }; 75D13DA62B83B58B0073A831 /* Source.Payment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75D13D992B83B58B0073A831 /* Source.Payment.swift */; }; 75D13DA72B83B58B0073A831 /* Source.Payment.BarcodeAlipay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75D13D9A2B83B58B0073A831 /* Source.Payment.BarcodeAlipay.swift */; }; @@ -130,8 +128,6 @@ 75D13DC92B8529790073A831 /* SelectSourceTypePaymentViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75D13DC82B8529790073A831 /* SelectSourceTypePaymentViewModel.swift */; }; 75D13DCB2B8531D20073A831 /* Assets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75D13DCA2B8531D20073A831 /* Assets.swift */; }; 75D13DCD2B8536B10073A831 /* SelectInstallmentTermsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75D13DCC2B8536B10073A831 /* SelectInstallmentTermsViewModel.swift */; }; - 75D13DD02B85A4250073A831 /* ChooseDuitNowObwBankViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75D13DCF2B85A4240073A831 /* ChooseDuitNowObwBankViewModel.swift */; }; - 75D13DD22B85A4490073A831 /* ChooseFPXBankViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75D13DD12B85A4490073A831 /* ChooseFPXBankViewModel.swift */; }; 75D13DD42B8652230073A831 /* SourceType+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75D13DD32B8652230073A831 /* SourceType+Helpers.swift */; }; 75D13DD62B8653360073A831 /* UIControl.State+Hashable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75D13DD52B8653360073A831 /* UIControl.State+Hashable.swift */; }; 75D13DD82B86539C0073A831 /* Optional+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75D13DD72B86539C0073A831 /* Optional+Helpers.swift */; }; @@ -140,14 +136,7 @@ 75D13DE42B8666CC0073A831 /* SelectSourceTypeDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75D13DE32B8666CC0073A831 /* SelectSourceTypeDelegate.swift */; }; 75D13DE62B8666DB0073A831 /* SelectSourcePaymentDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75D13DE52B8666DB0073A831 /* SelectSourcePaymentDelegate.swift */; }; 75D13DFC2B866DFE0073A831 /* PaymentCreatorController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A30FB7C214929C900DC09DC /* PaymentCreatorController.swift */; }; - 75D13DFD2B866E040073A831 /* InstallmentBankingSourceChooserViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AC1D3A4213922570051F966 /* InstallmentBankingSourceChooserViewController.swift */; }; - 75D13DFE2B866E040073A831 /* InstallmentsNumberOfTermsChooserViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AC1D3A6213941C80051F966 /* InstallmentsNumberOfTermsChooserViewController.swift */; }; - 75D13DFF2B866E040073A831 /* InternetBankingSourceChooserViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AC1D3A22139224D0051F966 /* InternetBankingSourceChooserViewController.swift */; }; - 75D13E002B866E040073A831 /* DuitNowOBWBankChooserViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1121F43F28523BED0003EE4F /* DuitNowOBWBankChooserViewController.swift */; }; - 75D13E012B866E040073A831 /* AdaptableDynamicTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73F9BA4625E50F4700F55CA8 /* AdaptableDynamicTableViewController.swift */; }; 75D13E022B866E040073A831 /* PaymentUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A76791E214663560085DE3C /* PaymentUI.swift */; }; - 75D13E032B866E040073A831 /* PaymentOptionTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A72CD5D2162358400F14F76 /* PaymentOptionTableViewCell.swift */; }; - 75D13E042B866E040073A831 /* MobileBankingSourceChooserViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3497367254C066F00D05C7B /* MobileBankingSourceChooserViewController.swift */; }; 75D13E0F2B8678530073A831 /* OmiseSwiftUIKit in Frameworks */ = {isa = PBXBuildFile; productRef = 75D13E0E2B8678530073A831 /* OmiseSwiftUIKit */; }; 75D13E102B8678530073A831 /* OmiseSwiftUIKit in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 75D13E0E2B8678530073A831 /* OmiseSwiftUIKit */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 75D13E1B2B86FD2D0073A831 /* CCVInfoController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 75D13E192B86FD2D0073A831 /* CCVInfoController.xib */; }; @@ -270,7 +259,6 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 1121F43F28523BED0003EE4F /* DuitNowOBWBankChooserViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DuitNowOBWBankChooserViewController.swift; sourceTree = ""; }; 14ACEF821D02D641001C5319 /* CardExpiryDatePicker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardExpiryDatePicker.swift; sourceTree = ""; }; 2225B3531D0FDD63003EB396 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 22445FFB1CF41DD300801D0F /* Globals.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Globals.swift; sourceTree = ""; }; @@ -282,8 +270,6 @@ 22D4809D1D0EB29C00544CE1 /* ExampleApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ExampleApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 22D480AB1D0EB29C00544CE1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 22E0DBD61D0EBE2E00472C74 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - 731A75D225E3604A002353C0 /* FPXBankChooserViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FPXBankChooserViewController.swift; sourceTree = ""; }; - 73F9BA4625E50F4700F55CA8 /* AdaptableDynamicTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdaptableDynamicTableViewController.swift; sourceTree = ""; }; 73F9BA4A25E6053700F55CA8 /* FPXPaymentFormController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FPXPaymentFormController.swift; sourceTree = ""; }; 7501265C2B87CB6500ED5E14 /* PaymentInputsFormController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentInputsFormController.swift; sourceTree = ""; }; 7501265E2B8893C900ED5E14 /* PaymentFormController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentFormController.swift; sourceTree = ""; }; @@ -368,7 +354,6 @@ 75D13D782B833F160073A831 /* ViewAttachable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewAttachable.swift; sourceTree = ""; }; 75D13D892B8382760073A831 /* ClosureBarButtonItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClosureBarButtonItem.swift; sourceTree = ""; }; 75D13D8B2B8385820073A831 /* UIBarButtonItem+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIBarButtonItem+Helpers.swift"; sourceTree = ""; }; - 75D13D8F2B839FC60073A831 /* PaymentFlow+DuitNowOBW.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PaymentFlow+DuitNowOBW.swift"; sourceTree = ""; }; 75D13D982B83B58B0073A831 /* Source.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Source.swift; sourceTree = ""; }; 75D13D992B83B58B0073A831 /* Source.Payment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Source.Payment.swift; sourceTree = ""; }; 75D13D9A2B83B58B0073A831 /* Source.Payment.BarcodeAlipay.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Source.Payment.BarcodeAlipay.swift; sourceTree = ""; }; @@ -388,8 +373,6 @@ 75D13DC82B8529790073A831 /* SelectSourceTypePaymentViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectSourceTypePaymentViewModel.swift; sourceTree = ""; }; 75D13DCA2B8531D20073A831 /* Assets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Assets.swift; sourceTree = ""; }; 75D13DCC2B8536B10073A831 /* SelectInstallmentTermsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectInstallmentTermsViewModel.swift; sourceTree = ""; }; - 75D13DCF2B85A4240073A831 /* ChooseDuitNowObwBankViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChooseDuitNowObwBankViewModel.swift; sourceTree = ""; }; - 75D13DD12B85A4490073A831 /* ChooseFPXBankViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChooseFPXBankViewModel.swift; sourceTree = ""; }; 75D13DD32B8652230073A831 /* SourceType+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SourceType+Helpers.swift"; sourceTree = ""; }; 75D13DD52B8653360073A831 /* UIControl.State+Hashable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIControl.State+Hashable.swift"; sourceTree = ""; }; 75D13DD72B86539C0073A831 /* Optional+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Optional+Helpers.swift"; sourceTree = ""; }; @@ -438,16 +421,12 @@ 8A5D59821D5317DD005D3346 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/OmiseSDK.storyboard; sourceTree = ""; }; 8A5D59851D5317E0005D3346 /* th */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = th; path = th.lproj/OmiseSDK.strings; sourceTree = ""; }; 8A5D59871D5317E1005D3346 /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/OmiseSDK.strings; sourceTree = ""; }; - 8A72CD5D2162358400F14F76 /* PaymentOptionTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentOptionTableViewCell.swift; sourceTree = ""; }; 8A7567642178956800C684C9 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; }; 8A76791E214663560085DE3C /* PaymentUI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentUI.swift; sourceTree = ""; }; 8A776646214A5FC60029D166 /* NoticeView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NoticeView.xib; sourceTree = ""; }; 8A776657214AA4E70029D166 /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = ja; path = ja.lproj/Localizable.stringsdict; sourceTree = ""; }; 8A776658214AA4F10029D166 /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Error.strings; sourceTree = ""; }; 8A7A9EBC2166160300F12D86 /* PaymentSettingTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentSettingTableViewController.swift; sourceTree = ""; }; - 8AC1D3A22139224D0051F966 /* InternetBankingSourceChooserViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InternetBankingSourceChooserViewController.swift; sourceTree = ""; }; - 8AC1D3A4213922570051F966 /* InstallmentBankingSourceChooserViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstallmentBankingSourceChooserViewController.swift; sourceTree = ""; }; - 8AC1D3A6213941C80051F966 /* InstallmentsNumberOfTermsChooserViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstallmentsNumberOfTermsChooserViewController.swift; sourceTree = ""; }; 8AD391B0230C05BC00383286 /* Colors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Colors.swift; sourceTree = ""; }; 8ADAA9AC20B71EDA00DD7CCF /* module.map */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = module.map; sourceTree = ""; }; 8AF5517B213D4C0100D61C98 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = en; path = en.lproj/Localizable.stringsdict; sourceTree = ""; }; @@ -465,7 +444,6 @@ 987A03AC1CE5CD450035417A /* Fixtures */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Fixtures; sourceTree = ""; }; 98FF99BA2577789800476487 /* Configuration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Configuration.swift; sourceTree = ""; }; C2ED0BC3298237EA00D985A8 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/OmiseSDK.strings; sourceTree = ""; }; - F3497367254C066F00D05C7B /* MobileBankingSourceChooserViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MobileBankingSourceChooserViewController.swift; sourceTree = ""; }; F615CBF7261565D600E1A2D9 /* CardExpiryDatePickerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardExpiryDatePickerTests.swift; sourceTree = ""; }; F6614CD5243DB8E7005B656E /* TrueMoneyPaymentFormController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrueMoneyPaymentFormController.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -580,6 +558,7 @@ 750126652B89F09F00ED5E14 /* Other Payments */ = { isa = PBXGroup; children = ( + 8A76791E214663560085DE3C /* PaymentUI.swift */, 750126682B89F0C200ED5E14 /* EContext */, 750126672B89F0B200ED5E14 /* TrueMoneyWallet */, 750126662B89F0AD00ED5E14 /* FPX */, @@ -762,26 +741,9 @@ path = Source; sourceTree = ""; }; - 75D13DEC2B866AEB0073A831 /* ToDelete */ = { - isa = PBXGroup; - children = ( - 8A72CD5D2162358400F14F76 /* PaymentOptionTableViewCell.swift */, - 8A30FB7C214929C900DC09DC /* PaymentCreatorController.swift */, - 8A76791E214663560085DE3C /* PaymentUI.swift */, - F3497367254C066F00D05C7B /* MobileBankingSourceChooserViewController.swift */, - 8AC1D3A4213922570051F966 /* InstallmentBankingSourceChooserViewController.swift */, - 8AC1D3A6213941C80051F966 /* InstallmentsNumberOfTermsChooserViewController.swift */, - 8AC1D3A22139224D0051F966 /* InternetBankingSourceChooserViewController.swift */, - 1121F43F28523BED0003EE4F /* DuitNowOBWBankChooserViewController.swift */, - 73F9BA4625E50F4700F55CA8 /* AdaptableDynamicTableViewController.swift */, - ); - path = ToDelete; - sourceTree = ""; - }; 75D13DEE2B866BCA0073A831 /* Views */ = { isa = PBXGroup; children = ( - 75D13DEC2B866AEB0073A831 /* ToDelete */, 75D13DEF2B866BE90073A831 /* Helpers */, 75D13DF02B866BF60073A831 /* Components */, 75D13E052B8670A80073A831 /* Screens */, @@ -840,18 +802,18 @@ path = CountryListController; sourceTree = ""; }; - 75D13DF32B866C420073A831 /* ChoosePaymentMethods */ = { + 75D13DF32B866C420073A831 /* Choose Payment Methods */ = { isa = PBXGroup; children = ( + 8A30FB7C214929C900DC09DC /* PaymentCreatorController.swift */, 75D13D5F2B807AC90073A831 /* ChoosePaymentCoordinator.swift */, 751E7BD82B7E5D130031B4A2 /* PaymentMethod.swift */, 75D13DF42B866C590073A831 /* ViewPresentable */, 75D13DF52B866C600073A831 /* Select Payment Delegates */, 75D13DF62B866C650073A831 /* Select Payment From Lists */, 750126652B89F09F00ED5E14 /* Other Payments */, - 75D13DF72B866C900073A831 /* ToDo */, ); - path = ChoosePaymentMethods; + path = "Choose Payment Methods"; sourceTree = ""; }; 75D13DF42B866C590073A831 /* ViewPresentable */ = { @@ -890,17 +852,6 @@ path = "Select Payment From Lists"; sourceTree = ""; }; - 75D13DF72B866C900073A831 /* ToDo */ = { - isa = PBXGroup; - children = ( - 75D13DCF2B85A4240073A831 /* ChooseDuitNowObwBankViewModel.swift */, - 75D13DD12B85A4490073A831 /* ChooseFPXBankViewModel.swift */, - 731A75D225E3604A002353C0 /* FPXBankChooserViewController.swift */, - 75D13D8F2B839FC60073A831 /* PaymentFlow+DuitNowOBW.swift */, - ); - path = ToDo; - sourceTree = ""; - }; 75D13DF82B866CA90073A831 /* Atome Payment */ = { isa = PBXGroup; children = ( @@ -913,12 +864,12 @@ path = "Atome Payment"; sourceTree = ""; }; - 75D13DFA2B866CF40073A831 /* AuthorizingPaymentViewController */ = { + 75D13DFA2B866CF40073A831 /* Authorizing Payment */ = { isa = PBXGroup; children = ( 8A188BAF1D951E3C00FFF467 /* AuthorizingPaymentViewController.swift */, ); - path = AuthorizingPaymentViewController; + path = "Authorizing Payment"; sourceTree = ""; }; 75D13DFB2B866D070073A831 /* Credit Card Payment */ = { @@ -939,9 +890,9 @@ 75D13E052B8670A80073A831 /* Screens */ = { isa = PBXGroup; children = ( - 75D13DF32B866C420073A831 /* ChoosePaymentMethods */, + 75D13DF32B866C420073A831 /* Choose Payment Methods */, 75D13DFB2B866D070073A831 /* Credit Card Payment */, - 75D13DFA2B866CF40073A831 /* AuthorizingPaymentViewController */, + 75D13DFA2B866CF40073A831 /* Authorizing Payment */, ); path = Screens; sourceTree = ""; @@ -1394,7 +1345,6 @@ 75D13DAD2B83B58B0073A831 /* Source.Payment.TrueMoney.swift in Sources */, 75D13E022B866E040073A831 /* PaymentUI.swift in Sources */, 759C7EC22B7DC80A0029D555 /* SourceType+InternetBanking.swift in Sources */, - 75D13E002B866E040073A831 /* DuitNowOBWBankChooserViewController.swift in Sources */, 75405A912A26340E008C21F6 /* UILabel+Helpers.swift in Sources */, 759856242A286C880087B605 /* UIScrollView+Helpers.swift in Sources */, 75E0EB9C2B7BD00F00E3198A /* Country.swift in Sources */, @@ -1415,7 +1365,6 @@ 75D13DB12B83B58B0073A831 /* Source.Payment.FPX.Bank.swift in Sources */, 75B420662B77741E0036134D /* CreateTokenPayload.swift in Sources */, 986406351CFEA7E4004BCF51 /* OmiseTextField.swift in Sources */, - 75D13DFF2B866E040073A831 /* InternetBankingSourceChooserViewController.swift in Sources */, 75D13DA62B83B58B0073A831 /* Source.Payment.swift in Sources */, 75D13D792B833F160073A831 /* ViewAttachable.swift in Sources */, 75D13DD42B8652230073A831 /* SourceType+Helpers.swift in Sources */, @@ -1425,7 +1374,6 @@ 7502CA5F2A31A7D600766E7D /* CountryListViewController.swift in Sources */, 75B420942B78DE350036134D /* Capability.PaymentMethod.Provider.swift in Sources */, 75D13DBB2B83FB470073A831 /* SelectPaymentController.swift in Sources */, - 75D13DFD2B866E040073A831 /* InstallmentBankingSourceChooserViewController.swift in Sources */, 75CFC4EE2B7537BC00422A8F /* Client+URLRequest.swift in Sources */, 75D13DAC2B83B58B0073A831 /* Source.Payment.EContext.swift in Sources */, 75D13D8C2B8385820073A831 /* UIBarButtonItem+Helpers.swift in Sources */, @@ -1434,32 +1382,25 @@ 75D13DA82B83B58B0073A831 /* Source.Payment.DuitNowOBW.swift in Sources */, 75D13DAB2B83B58B0073A831 /* Source.Payment.FPX.swift in Sources */, 751E7BEE2B7F7DD20031B4A2 /* PaymentMethod+ViewPresentable.swift in Sources */, - 75D13DFE2B866E040073A831 /* InstallmentsNumberOfTermsChooserViewController.swift in Sources */, 75D13D772B833C200073A831 /* UITableViewCell+ActivityIndicator.swift in Sources */, 986406311CFEA7E4004BCF51 /* CardExpiryDateTextField.swift in Sources */, - 75D13E032B866E040073A831 /* PaymentOptionTableViewCell.swift in Sources */, 756C8F262A40698600D53059 /* TextFieldView.swift in Sources */, 986406341CFEA7E4004BCF51 /* CardNameTextField.swift in Sources */, 8AF9857121479F38007E18ED /* CCVInfoController.swift in Sources */, - 75D13E012B866E040073A831 /* AdaptableDynamicTableViewController.swift in Sources */, 75E0EB7C2B7B410600E3198A /* Client+NetworkService.swift in Sources */, 75D13D602B807AC90073A831 /* ChoosePaymentCoordinator.swift in Sources */, 75D13DB42B83B71D0073A831 /* DuitNowOBW.Bank+ViewPresentable.swift in Sources */, - 75D13DD02B85A4250073A831 /* ChooseDuitNowObwBankViewModel.swift in Sources */, 75405A7C2A25EC88008C21F6 /* Array+Helpers.swift in Sources */, 8A188BB01D951E3C00FFF467 /* AuthorizingPaymentViewController.swift in Sources */, - 731A75D325E3604A002353C0 /* FPXBankChooserViewController.swift in Sources */, 75D13DFC2B866DFE0073A831 /* PaymentCreatorController.swift in Sources */, 14ACEF831D02D641001C5319 /* CardExpiryDatePicker.swift in Sources */, 75CFC4F32B753BCD00422A8F /* Capability.PaymentMethod.swift in Sources */, 75B4205E2B7674D70036134D /* Calendar+CreditCard.swift in Sources */, - 75D13D902B839FC60073A831 /* PaymentFlow+DuitNowOBW.swift in Sources */, 75D13D5E2B8069650073A831 /* UIImage+Omise.swift in Sources */, 75D13DA92B83B58B0073A831 /* Source.Payment.Item.swift in Sources */, 75E0EB9E2B7BD00F00E3198A /* OmiseError.swift in Sources */, 75F2A0B92A1A60630038FA54 /* AtomePaymentFormViewModelProtocol.swift in Sources */, 75D13DD82B86539C0073A831 /* Optional+Helpers.swift in Sources */, - 75D13DD22B85A4490073A831 /* ChooseFPXBankViewModel.swift in Sources */, 75D13E202B8703F80073A831 /* CreditCardPaymentController.swift in Sources */, 75D13DE22B8666C40073A831 /* SelectPaymentMethodDelegate.swift in Sources */, 75D13DAE2B83B58B0073A831 /* Source.Payment.DuitNowOBW.Bank.swift in Sources */, @@ -1492,7 +1433,6 @@ 986406321CFEA7E4004BCF51 /* CardNumberTextField.swift in Sources */, 750126742B8A580500ED5E14 /* SelectDuitNowOBWBankViewModel.swift in Sources */, 7501265D2B87CB6500ED5E14 /* PaymentInputsFormController.swift in Sources */, - 75D13E042B866E040073A831 /* MobileBankingSourceChooserViewController.swift in Sources */, 75D13DCD2B8536B10073A831 /* SelectInstallmentTermsViewModel.swift in Sources */, 75D13DB02B83B58B0073A831 /* Source.Payment.Address.swift in Sources */, 75405A8F2A26340E008C21F6 /* UIImage+Helpers.swift in Sources */, From ee6023ab4837337aad028612630065ad47747177 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Mon, 4 Mar 2024 12:19:48 +0700 Subject: [PATCH 153/204] Update eContext payment translations --- .../Contents.json | 0 .../konbini.pdf | Bin .../PaymentMethod+ViewPresentable.swift | 8 ++++---- .../SourceType+ViewPresentable.swift | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) rename OmiseSDK/Resources/Assets.xcassets/Method/{Conbini.imageset => Konbini.imageset}/Contents.json (100%) rename OmiseSDK/Resources/Assets.xcassets/Method/{Conbini.imageset => Konbini.imageset}/konbini.pdf (100%) diff --git a/OmiseSDK/Resources/Assets.xcassets/Method/Conbini.imageset/Contents.json b/OmiseSDK/Resources/Assets.xcassets/Method/Konbini.imageset/Contents.json similarity index 100% rename from OmiseSDK/Resources/Assets.xcassets/Method/Conbini.imageset/Contents.json rename to OmiseSDK/Resources/Assets.xcassets/Method/Konbini.imageset/Contents.json diff --git a/OmiseSDK/Resources/Assets.xcassets/Method/Conbini.imageset/konbini.pdf b/OmiseSDK/Resources/Assets.xcassets/Method/Konbini.imageset/konbini.pdf similarity index 100% rename from OmiseSDK/Resources/Assets.xcassets/Method/Conbini.imageset/konbini.pdf rename to OmiseSDK/Resources/Assets.xcassets/Method/Konbini.imageset/konbini.pdf diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/PaymentMethod+ViewPresentable.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/PaymentMethod+ViewPresentable.swift index 7e988507..3a2a7f5f 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/PaymentMethod+ViewPresentable.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/PaymentMethod+ViewPresentable.swift @@ -27,11 +27,11 @@ extension PaymentMethod: ViewPresentable { case .mobileBanking: return localized("\(prefixCode).mobileBanking", text: "Mobile Banking") case .eContextConbini: - return localized("\(prefixCode).eContext.conbini", text: "Conbini") + return localized("\(prefixCode).eContext.conbini", text: "Konbini") case .eContextPayEasy: - return localized("\(prefixCode).eContext.payEasy", text: "PayEasy") + return localized("\(prefixCode).eContext.payEasy", text: "Pay-easy") case .eContextNetBanking: - return localized("\(prefixCode).eContext.netBanking", text: "NetBanking") + return localized("\(prefixCode).eContext.netBanking", text: "Net Bank") case .sourceType(let sourceType): return sourceType.localizedTitle } @@ -44,7 +44,7 @@ extension PaymentMethod: ViewPresentable { case .installment: return "Installment" case .internetBanking: return "Banking" case .mobileBanking: return "MobileBanking" - case .eContextConbini: return "Conbini" + case .eContextConbini: return "Konbini" case .eContextPayEasy: return "Payeasy" case .eContextNetBanking: return "Netbank" case .sourceType(let sourceType): return sourceType.iconName diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/SourceType+ViewPresentable.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/SourceType+ViewPresentable.swift index 9417ab52..b32d4c49 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/SourceType+ViewPresentable.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/SourceType+ViewPresentable.swift @@ -19,7 +19,7 @@ extension SourceType: ViewPresentable { case .billPaymentTescoLotus: return "Tesco Lotus" case .eContext: - return "Conbini" + return "" // Doesn't have specific title case .alipay: return "Alipay" case .alipayCN: @@ -119,7 +119,7 @@ extension SourceType: ViewPresentable { case .billPaymentTescoLotus: return "Tesco" case .eContext: - return "Conbini" + return "" // Doesn't have specific icon case .alipay: return "Alipay" case .alipayCN: From 4e9b2ff1fbde0b4917c3bd4913edaf440e0265b1 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Mon, 4 Mar 2024 13:30:04 +0700 Subject: [PATCH 154/204] Move Credit card to OmiseSDK --- .../Views/ProductDetailViewController.swift | 15 +- .../OmiseError+LocalizedDescription.swift | 1 - OmiseSDK/Sources/OmiseSDK.swift | 51 ++++- .../ChoosePaymentCoordinator+Helpers.swift | 172 ++++++++++++++++ .../ChoosePaymentCoordinator.swift | 188 ++++-------------- .../PaymentCreatorController.swift | 0 .../PaymentUI.swift | 0 .../CreditCardPaymentController.swift | 64 ++---- dev.xcodeproj/project.pbxproj | 16 +- 9 files changed, 298 insertions(+), 209 deletions(-) create mode 100644 OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator+Helpers.swift rename OmiseSDK/Sources/Views/Screens/Choose Payment Methods/{ => New Group}/PaymentCreatorController.swift (100%) rename OmiseSDK/Sources/Views/Screens/Choose Payment Methods/{Other Payments => New Group}/PaymentUI.swift (100%) diff --git a/ExampleApp/Views/ProductDetailViewController.swift b/ExampleApp/Views/ProductDetailViewController.swift index 050e4fcf..911652e1 100644 --- a/ExampleApp/Views/ProductDetailViewController.swift +++ b/ExampleApp/Views/ProductDetailViewController.swift @@ -32,10 +32,6 @@ class ProductDetailViewController: BaseViewController { return true } - override func viewDidLoad() { - super.viewDidLoad() - } - // override func prepare(for segue: UIStoryboardSegue, sender: Any?) { // super.prepare(for: segue, sender: sender) // @@ -71,6 +67,10 @@ class ProductDetailViewController: BaseViewController { guard currentCodePathMode == .code else { return } + + let viewController = omiseSDK.creditCardController(delegate: self) + present(viewController, animated: true, completion: nil) + // let creditCardFormController = CreditCardPaymentController.makeCreditCardPaymentController(withPublicKey: publicKey) // creditCardFormController.handleErrors = true // creditCardFormController.delegate = self @@ -82,6 +82,13 @@ class ProductDetailViewController: BaseViewController { guard currentCodePathMode == .code else { return } + + let nc = omiseSDK.creditCardController(delegate: self) + addChild(nc) + if let vc = nc.topViewController { + navigationController?.pushViewController(vc, animated: true) + } + // let creditCardFormController = CreditCardPaymentController.makeCreditCardPaymentController(withPublicKey: publicKey) // creditCardFormController.handleErrors = true // creditCardFormController.delegate = self diff --git a/OmiseSDK/Sources/Models/OmiseError+LocalizedDescription.swift b/OmiseSDK/Sources/Models/OmiseError+LocalizedDescription.swift index e65f8c2a..9416805f 100644 --- a/OmiseSDK/Sources/Models/OmiseError+LocalizedDescription.swift +++ b/OmiseSDK/Sources/Models/OmiseError+LocalizedDescription.swift @@ -222,7 +222,6 @@ extension OmiseError { } var localizedRecoverySuggestion: String { - enum CommonStrings: String { case tryAgainLater = "Please try again later" } diff --git a/OmiseSDK/Sources/OmiseSDK.swift b/OmiseSDK/Sources/OmiseSDK.swift index 5e3f3c9d..ff982f15 100644 --- a/OmiseSDK/Sources/OmiseSDK.swift +++ b/OmiseSDK/Sources/OmiseSDK.swift @@ -34,13 +34,17 @@ public class OmiseSDK { /// Client is used to communicate with Omise API public let client: Client + /// If it's `true` SDK will handle errors and will not notify ChoosePaymentMethodDelegate + public let handleErrors: Bool + /// Creates a new instance of Omise SDK that provides interface to functionallity that SDK provides /// /// - Parameters: /// - publicKey: Omise public key /// - configuration: Optional configuration is used for testing - public init(publicKey: String, configuration: Configuration? = nil) { + public init(publicKey: String, handleErrors: Bool = true, configuration: Configuration? = nil) { self.publicKey = publicKey + self.handleErrors = handleErrors self.client = Client( publicKey: publicKey, version: version, @@ -69,7 +73,13 @@ public class OmiseSDK { allowedCardPayment: Bool, delegate: ChoosePaymentMethodDelegate ) -> UINavigationController { - let paymentFlow = ChoosePaymentCoordinator(client: client, amount: amount, currency: currency, currentCountry: country) + let paymentFlow = ChoosePaymentCoordinator( + client: client, + amount: amount, + currency: currency, + currentCountry: country, + handleErrors: handleErrors + ) let viewController = paymentFlow.createChoosePaymentMethodController( allowedPaymentMethods: allowedPaymentMethods, allowedCardPayment: allowedCardPayment, @@ -78,6 +88,7 @@ public class OmiseSDK { ) let navigationController = UINavigationController(rootViewController: viewController) + navigationController.delegate = paymentFlow return navigationController } @@ -93,7 +104,13 @@ public class OmiseSDK { currency: String, delegate: ChoosePaymentMethodDelegate ) -> UINavigationController { - let paymentFlow = ChoosePaymentCoordinator(client: client, amount: amount, currency: currency, currentCountry: country) + let paymentFlow = ChoosePaymentCoordinator( + client: client, + amount: amount, + currency: currency, + currentCountry: country, + handleErrors: handleErrors + ) let viewController = paymentFlow.createChoosePaymentMethodController( usePaymentMethodsFromCapability: true, delegate: delegate @@ -104,8 +121,36 @@ public class OmiseSDK { navigationController.navigationBar.prefersLargeTitles = true } + navigationController.delegate = paymentFlow + return navigationController + } + + /// Creates a Credit Card Controller with payment methods loaded from Capability API + /// + /// - Parameters: + /// - delegate: Delegate to be notified when Source or Token is created + public func creditCardController(delegate: ChoosePaymentMethodDelegate) -> UINavigationController { + let paymentFlow = ChoosePaymentCoordinator( + client: client, + amount: 0, + currency: "", + currentCountry: country, + handleErrors: handleErrors + ) + let viewController = paymentFlow.createCreditCardPaymentController(delegate: delegate) + + let navigationController = UINavigationController(rootViewController: viewController) + if #available(iOSApplicationExtension 11.0, *) { + navigationController.navigationBar.prefersLargeTitles = true + } + + navigationController.delegate = paymentFlow return navigationController } + + func showAuthorizedController() { + + } } public extension OmiseSDK { diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator+Helpers.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator+Helpers.swift new file mode 100644 index 00000000..7b667a60 --- /dev/null +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator+Helpers.swift @@ -0,0 +1,172 @@ +import UIKit + +extension ChoosePaymentCoordinator { + func navigate(to viewController: UIViewController) { + rootViewController?.navigationController?.pushViewController( + viewController, + animated: true + ) + } + + func processError(_ error: Error) { + if handleErrors { + if let error = error as? OmiseError { + displayErrorWith(title: error.localizedDescription, + message: error.localizedRecoverySuggestion, + animated: true, + sender: self) + } else if let error = error as? LocalizedError { + displayErrorWith(title: error.localizedDescription, + message: error.recoverySuggestion, + animated: true, + sender: self) + } else { + displayErrorWith(title: error.localizedDescription, + message: nil, + animated: true, + sender: self) + } + } else { + choosePaymentMethodDelegate?.choosePaymentMethodDidComplete(with: error) + } + } + + func processPayment(_ card: CreateTokenPayload.Card, completion: @escaping () -> Void) { + guard let delegate = choosePaymentMethodDelegate else { return } + let tokenPayload = CreateTokenPayload(card: card) + + client.createToken(payload: tokenPayload) { [weak self, weak delegate] result in + switch result { + case .success(let token): + delegate?.choosePaymentMethodDidComplete(with: token) + case .failure(let error): + self?.processError(error) + } + completion() + } + } + + func processPayment(_ payment: Source.Payment, completion: @escaping () -> Void) { + guard let delegate = choosePaymentMethodDelegate else { return } + let sourcePayload = CreateSourcePayload( + amount: amount, + currency: currency, + details: payment + ) + + client.createSource(payload: sourcePayload) { [weak self, weak delegate] result in + switch result { + case .success(let source): + delegate?.choosePaymentMethodDidComplete(with: source) + case .failure(let error): + self?.processError(error) + } + completion() + } + } +} + +extension ChoosePaymentCoordinator { + func setupErrorView() { + errorViewHeightConstraint = errorView.heightAnchor.constraint(equalToConstant: 0) + errorViewHeightConstraint?.isActive = true + + let dismissErrorBannerTapGestureRecognizer = UITapGestureRecognizer(target: self, + action: #selector(self.dismissErrorMessageBanner(_:))) + errorView.addGestureRecognizer(dismissErrorBannerTapGestureRecognizer) + } + + /// Displays an error banner at the top of the UI with the given error message. + /// + /// - Parameters: + /// - title: Title message to be displayed in the banner + /// - message: Subtitle message to be displayed in the banner + /// - animated: Pass true to animate the presentation; otherwise, pass false + /// - sender: The object that initiated the request + func displayErrorWith(title: String, message: String?, animated: Bool, sender: Any?) { + guard let navController = rootViewController?.navigationController else { return } + + errorView.titleLabel.text = title + errorView.detailLabel.text = message + navController.view.insertSubview(self.errorView, belowSubview: navController.navigationBar) + + NSLayoutConstraint.activate([ + errorView.topAnchor.constraint(equalTo: navController.navigationBar.bottomAnchor), + errorView.leadingAnchor.constraint(equalTo: navController.view.leadingAnchor), + errorView.trailingAnchor.constraint(equalTo: navController.view.trailingAnchor) + ]) + + errorViewHeightConstraint?.isActive = true + navController.view.layoutIfNeeded() + + let animationBlock = { [weak navController] in + guard let navController = navController else { return } + self.errorViewHeightConstraint?.isActive = false + navController.view.layoutIfNeeded() + if #available(iOS 13, *) { + navController.topViewController?.additionalSafeAreaInsets.top = self.errorView.bounds.height + } else if #available(iOS 11, *) { + navController.additionalSafeAreaInsets.top = self.errorView.bounds.height + } + } + + if animated { + UIView.animate(withDuration: TimeInterval(UINavigationController.hideShowBarDuration) + 0.07, + delay: 0.0, + options: [.layoutSubviews, .beginFromCurrentState], + animations: animationBlock) + } else { + animationBlock() + } + } + + @objc func dismissErrorMessageBanner(_ sender: AnyObject) { + dismissErrorMessage(animated: true, sender: sender) + } + + func dismissErrorMessage(animated: Bool, sender: Any?) { + guard errorView.superview != nil, let navController = rootViewController?.navigationController else { + return + } + + let animationBlock = { [weak navController] in + self.errorViewHeightConstraint?.isActive = true + navController?.view.layoutIfNeeded() + if #available(iOS 13, *) { + navController?.topViewController?.additionalSafeAreaInsets.top = 0 + } else if #available(iOS 11, *) { + navController?.topViewController?.additionalSafeAreaInsets.top = 0 + } + } + + if animated { + UIView.animate( + withDuration: TimeInterval(UINavigationController.hideShowBarDuration), + delay: 0.0, + options: [.layoutSubviews], + animations: animationBlock + ) { [weak navController] _ in + var isCompleted: Bool { + if #available(iOS 13, *) { + return navController?.topViewController?.additionalSafeAreaInsets.top == 0 + } else if #available(iOS 11, *) { + return navController?.topViewController?.additionalSafeAreaInsets.top == 0 + } else { + return true + } + } + guard isCompleted else { return } + self.errorView.removeFromSuperview() + } + } else { + animationBlock() + self.errorView.removeFromSuperview() + } + } +} + +extension ChoosePaymentCoordinator: UINavigationControllerDelegate { + func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) { + dismissErrorMessage(animated: animated, sender: nil) + } +} diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator.swift index 252cd64b..4e2fe658 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator.swift @@ -1,10 +1,11 @@ import UIKit -class ChoosePaymentCoordinator: ViewAttachable { +class ChoosePaymentCoordinator: NSObject, ViewAttachable { let client: Client let amount: Int64 let currency: String let currentCountry: Country? + let handleErrors: Bool enum ResultState { case cancelled @@ -12,14 +13,26 @@ class ChoosePaymentCoordinator: ViewAttachable { } weak var choosePaymentMethodDelegate: ChoosePaymentMethodDelegate? - weak var rootViewController: UIViewController? - init(client: Client, amount: Int64, currency: String, currentCountry: Country?) { + var errorViewHeightConstraint: NSLayoutConstraint? + let errorView: NoticeView = { + let noticeViewNib = UINib(nibName: "NoticeView", bundle: .omiseSDK) + let noticeView = noticeViewNib.instantiate(withOwner: nil, options: nil).first as! NoticeView // swiftlint:disable:this force_cast + noticeView.translatesAutoresizingMaskIntoConstraints = false + noticeView.backgroundColor = .error + return noticeView + }() + + init(client: Client, amount: Int64, currency: String, currentCountry: Country?, handleErrors: Bool) { self.client = client self.amount = amount self.currency = currency self.currentCountry = currentCountry + self.handleErrors = handleErrors + super.init() + + self.setupErrorView() } /// Creates SelectPaymentController and attach current flow object inside created controller to be deallocated together @@ -28,6 +41,7 @@ class ChoosePaymentCoordinator: ViewAttachable { /// - allowedPaymentMethods: List of Payment Methods to be presented in the list if `usePaymentMethodsFromCapability` is `false` /// - allowedCardPayment: Shows credit card payment option if `true` and `usePaymentMethodsFromCapability` is `false` /// - usePaymentMethodsFromCapability: If `true`then it loads list of Payment Methods from Capability API and ignores previous parameters + /// - delegate: Payment method delegate func createChoosePaymentMethodController( allowedPaymentMethods paymentMethods: [SourceType] = [], allowedCardPayment isCardEnabled: Bool = true, @@ -50,6 +64,30 @@ class ChoosePaymentCoordinator: ViewAttachable { return listController } + /// Creates CreditCardController and attach current flow object inside created controller to be deallocated together + /// + /// - Parameters: + /// - delegate: Payment method delegate + func createCreditCardPaymentController(delegate: ChoosePaymentMethodDelegate) -> CreditCardPaymentController { + let viewController = createCreditCardPaymentController() + viewController.attach(self) + + self.choosePaymentMethodDelegate = delegate + self.rootViewController = viewController + + return viewController + } + + /// Creates Credit Carc Payment screen and attach current flow object inside created controller to be deallocated together + func createCreditCardPaymentController() -> CreditCardPaymentController { + let viewModel = CreditCardPaymentViewModel(currentCountry: currentCountry, delegate: self) + let viewController = CreditCardPaymentController(nibName: nil, bundle: .omiseSDK) + viewController.viewModel = viewModel + viewController.title = PaymentMethod.creditCard.localizedTitle + return viewController + } + + /// Creates Mobile Banking screen and attach current flow object inside created controller to be deallocated together func createMobileBankingController() -> SelectPaymentController { let viewModel = SelectSourceTypePaymentViewModel( @@ -101,15 +139,6 @@ class ChoosePaymentCoordinator: ViewAttachable { return viewController } - /// Creates Credit Carc Payment screen and attach current flow object inside created controller to be deallocated together - func createCreditCardPaymentController() -> CreditCardPaymentController { - let viewModel = CreditCardPaymentViewModel(currentCountry: currentCountry, delegate: self) - let viewController = CreditCardPaymentController(nibName: nil, bundle: .omiseSDK) - viewController.viewModel = viewModel - viewController.title = PaymentMethod.creditCard.localizedTitle - return viewController - } - /// Creates EContext screen and attach current flow object inside created controller to be deallocated together func createEContextController(title: String) -> EContextPaymentFormController { let viewController = EContextPaymentFormController(nibName: nil, bundle: .omiseSDK) @@ -231,138 +260,3 @@ extension ChoosePaymentCoordinator: SelectSourcePaymentDelegate { processPayment(payment, completion: completion) } } - -extension ChoosePaymentCoordinator { - func navigate(to viewController: UIViewController) { - rootViewController?.navigationController?.pushViewController( - viewController, - animated: true - ) - } - - func processPayment(_ card: CreateTokenPayload.Card, completion: @escaping () -> Void) { - guard let delegate = choosePaymentMethodDelegate else { return } - let tokenPayload = CreateTokenPayload(card: card) - - client.createToken(payload: tokenPayload) { [weak delegate] result in - switch result { - case .success(let token): - delegate?.choosePaymentMethodDidComplete(with: token) - case .failure(let error): - delegate?.choosePaymentMethodDidComplete(with: error) - } - completion() - } - } - - func processPayment(_ payment: Source.Payment, completion: @escaping () -> Void) { - guard let delegate = choosePaymentMethodDelegate else { return } - let sourcePayload = CreateSourcePayload( - amount: amount, - currency: currency, - details: payment - ) - - client.createSource(payload: sourcePayload) { [weak delegate] result in - switch result { - case .success(let source): - delegate?.choosePaymentMethodDidComplete(with: source) - case .failure(let error): - delegate?.choosePaymentMethodDidComplete(with: error) - } - completion() - } - } -} - -// protocol NavigationFlow { -// associatedtype Route -// func navigate(to: Route) -// } -// -// extension ChoosePaymentCoordinator: NavigationFlow { -// enum Route { -// case creditCard -// case installments -// case mobileBanking -// case internetBanking -// case atome -// case trueMoneyWallet -// case duitNowOBW -// case eContext -// case fpx -// } -// -// func navigate(to: Route) { -// // override func prepare(for segue: UIStoryboardSegue, sender: Any?) { -// // switch (segue.identifier, segue.destination) { -// // case ("GoToCreditCardPaymentSegue"?, let controller as CreditCardPaymentController): -// // controller.publicKey = viewModel.flowSession?.client?.publicKey -// // controller.delegate = viewModel.flowSession -// // controller.navigationItem.rightBarButtonItem = nil -// // case ("GoToInternetBankingChooserSegue"?, let controller as InternetBankingSourceChooserViewController): -// // controller.showingValues = allowedPaymentMethods.filter({ $0.isInternetBanking }) -// // controller.flowSession = self.viewModel.flowSession -// // case ("GoToMobileBankingChooserSegue"?, let controller as MobileBankingSourceChooserViewController): -// // controller.showingValues = allowedPaymentMethods.filter({ $0.isMobileBanking }) -// // controller.flowSession = self.viewModel.flowSession -// // case ("GoToInstallmentBrandChooserSegue"?, let controller as InstallmentBankingSourceChooserViewController): -// // controller.showingValues = allowedPaymentMethods.filter({ $0.isInstallment }) -// // controller.flowSession = self.viewModel.flowSession -// // case (_, let controller as EContextPaymentFormController): -// // controller.flowSession = self.viewModel.flowSession -// // if let element = (sender as? UITableViewCell).flatMap(tableView.indexPath(for:)).map(item(at:)) { -// // switch element { -// // case .conbini: -// // controller.navigationItem.title = NSLocalizedString( -// // "econtext.convenience-store.navigation-item.title", -// // bundle: .omiseSDK, -// // value: "Konbini", -// // comment: "A navigaiton title for the EContext screen when the `Konbini` is selected" -// // ) -// // case .netBanking: -// // controller.navigationItem.title = NSLocalizedString( -// // "econtext.netbanking.navigation-item.title", -// // bundle: .omiseSDK, -// // value: "Net Bank", -// // comment: "A navigaiton title for the EContext screen when the `Net Bank` is selected" -// // ) -// // case .payEasy: -// // controller.navigationItem.title = NSLocalizedString( -// // "econtext.pay-easy.navigation-item.title", -// // bundle: .omiseSDK, -// // value: "Pay-easy", -// // comment: "A navigaiton title for the EContext screen when the `Pay-easy` is selected" -// // ) -// // default: break -// // } -// // } -// // case ("GoToTrueMoneyFormSegue"?, let controller as TrueMoneyPaymentFormController): -// // controller.flowSession = self.viewModel.flowSession -// // case ("GoToFPXFormSegue"?, let controller as FPXPaymentFormController): -// // // controller.showingValues = capability?.paymentMethod(for: .fpx)?.banks -// // // capability?[.fpx]?.banks ?? [] -// // -// // controller.flowSession = self.viewModel.flowSession -// // case ("GoToDuitNowOBWBankChooserSegue"?, let controller as DuitNowOBWBankChooserViewController): -// //// controller.showingValues = [.duitNowOBWBanks] -// //// [Payment.DuitNowOBW.Bank] -// // controller.flowSession = self.viewModel.flowSession -// // default: -// // break -// // } -// // -// // if let paymentShourceChooserUI = segue.destination as? PaymentChooserUI { -// // paymentShourceChooserUI.preferredPrimaryColor = self.preferredPrimaryColor -// // paymentShourceChooserUI.preferredSecondaryColor = self.preferredSecondaryColor -// // } -// // } -// } -// -// private func viewController(for route: Route) -> UIViewController { -// switch self { -// default: -// return UIViewController() -// } -// } -// } diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/PaymentCreatorController.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/New Group/PaymentCreatorController.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/Choose Payment Methods/PaymentCreatorController.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/New Group/PaymentCreatorController.swift diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/PaymentUI.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/New Group/PaymentUI.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/PaymentUI.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/New Group/PaymentUI.swift diff --git a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift index dae404f9..49d5d2ae 100644 --- a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift +++ b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift @@ -5,7 +5,7 @@ import os.log /// Drop-in credit card input form view controller that automatically tokenizes credit /// card information. -public class CreditCardPaymentController: UIViewController { +class CreditCardPaymentController: UIViewController { // swiftlint:disable:previous type_body_length typealias ViewModel = CreditCardPaymentViewModel @@ -25,10 +25,7 @@ public class CreditCardPaymentController: UIViewController { } } - /// A boolean flag to enables/disables automatic error handling. Defaults to `true`. - public var handleErrors = true - - @IBInspectable public var errorMessageTextColor: UIColor! = CreditCardPaymentController.defaultErrorMessageTextColor { + @IBInspectable var errorMessageTextColor: UIColor! = CreditCardPaymentController.defaultErrorMessageTextColor { didSet { if errorMessageTextColor == nil { errorMessageTextColor = CreditCardPaymentController.defaultErrorMessageTextColor @@ -42,9 +39,6 @@ public class CreditCardPaymentController: UIViewController { } } - // swiftlint:disable:next weak_delegate -// lazy var overlayTransitionDelegate = OverlayPanelTransitioningDelegate() - var isInputDataValid: Bool { return formFields.allSatisfy { $0.isValid } } @@ -101,18 +95,18 @@ public class CreditCardPaymentController: UIViewController { }() @IBOutlet var requestingIndicatorView: UIActivityIndicatorView! - public static let defaultErrorMessageTextColor = UIColor.error + static let defaultErrorMessageTextColor = UIColor.error /// Factory method for creating CreditCardPaymentController with given public key. /// - parameter publicKey: Omise public key. - public static func makeCreditCardPaymentController(withPublicKey publicKey: String) -> CreditCardPaymentController { + static func makeCreditCardPaymentController(withPublicKey publicKey: String) -> CreditCardPaymentController { let storyboard = UIStoryboard(name: "OmiseSDK", bundle: .omiseSDK) // swiftlint:disable:next force_cast let creditCardForm = storyboard.instantiateInitialViewController() as! CreditCardPaymentController return creditCardForm } - public func setCreditCardInformationWith(number: String?, name: String?, expiration: (month: Int, year: Int)?) { + func setCreditCardInformationWith(number: String?, name: String?, expiration: (month: Int, year: Int)?) { cardNumberTextField.text = number cardNameTextField.text = name @@ -148,7 +142,7 @@ public class CreditCardPaymentController: UIViewController { ] } - public override func viewDidLoad() { + override func viewDidLoad() { super.viewDidLoad() setupArrays() @@ -206,7 +200,7 @@ public class CreditCardPaymentController: UIViewController { } } - public override func viewWillLayoutSubviews() { + override func viewWillLayoutSubviews() { super.viewWillLayoutSubviews() if #unavailable(iOS 11) { @@ -221,13 +215,13 @@ public class CreditCardPaymentController: UIViewController { } } - public override func viewDidDisappear(_ animated: Bool) { + override func viewDidDisappear(_ animated: Bool) { super.viewDidDisappear(animated) NotificationCenter().removeObserver(self, name: UIResponder.keyboardWillShowNotification, object: nil) } - public override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { + override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { if previousTraitCollection?.preferredContentSizeCategory != traitCollection.preferredContentSizeCategory { view.setNeedsUpdateConstraints() } @@ -361,28 +355,10 @@ public class CreditCardPaymentController: UIViewController { guard let viewModel = viewModel else { return false } viewModel.viewDidTapClose() return true -// os_log("Credit Card Form dismissing requested, Asking the delegate what should the form controler do", -// log: uiLogObject, -// type: .default) -// -// if let delegate = self.delegate { -// delegate.creditCardFormViewControllerDidCancel(self) -// os_log("Canceling form delegate notified", log: uiLogObject, type: .default) -// return true -// } else if let delegateMethod = delegate?.creditCardFormViewControllerDidCancel { -// delegateMethod(self) -// os_log("Canceling form delegate notified", log: uiLogObject, type: .default) -// return true -// } else { -// os_log("Credit Card Form dismissing requested but there is not delegate to ask. Ignore the request", -// log: uiLogObject, -// type: .default) -// return false -// } } func makeViewContext() -> ViewContext { - guard let viewModel = viewModel else { return ViewContext () } + guard let viewModel = viewModel else { return ViewContext() } var context = ViewContext() let fields = viewModel.addressFields @@ -410,23 +386,7 @@ public class CreditCardPaymentController: UIViewController { startActivityIndicator() viewModel.onSubmitButtonPressed(makeViewContext()) { self.stopActivityIndicator() - -// { [weak self] result in -// guard let self = self else { return } -// self.stopActivityIndicator() -// switch result { -// case .success(let token): -// os_log("Credit Card Form's Request succeed %{private}@, trying to notify the delegate", -// log: uiLogObject, -// type: .default, -// token.id) -// self.delegate?.creditCardFormViewController(self, didSucceedWithToken: token) -// case .failure(let error): -// self.handleError(error) -// } -// } } - } func keyboardWillAppear(_ notification: Notification) { @@ -841,7 +801,7 @@ extension CreditCardPaymentController { ] } - public override func accessibilityPerformMagicTap() -> Bool { + override func accessibilityPerformMagicTap() -> Bool { guard isInputDataValid else { return false } @@ -850,7 +810,7 @@ extension CreditCardPaymentController { return true } - public override func accessibilityPerformEscape() -> Bool { + override func accessibilityPerformEscape() -> Bool { return performCancelingForm() } } diff --git a/dev.xcodeproj/project.pbxproj b/dev.xcodeproj/project.pbxproj index 823c953e..f4e0b1ee 100644 --- a/dev.xcodeproj/project.pbxproj +++ b/dev.xcodeproj/project.pbxproj @@ -24,6 +24,7 @@ 750126702B8A490000ED5E14 /* SelectFPXBankViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7501266F2B8A490000ED5E14 /* SelectFPXBankViewModel.swift */; }; 750126722B8A49BC00ED5E14 /* FPX.Bank+ViewPresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 750126712B8A49BC00ED5E14 /* FPX.Bank+ViewPresentable.swift */; }; 750126742B8A580500ED5E14 /* SelectDuitNowOBWBankViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 750126732B8A580500ED5E14 /* SelectDuitNowOBWBankViewModel.swift */; }; + 750126772B95971A00ED5E14 /* ChoosePaymentCoordinator+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 750126762B95971A00ED5E14 /* ChoosePaymentCoordinator+Helpers.swift */; }; 7502CA532A3011A900766E7D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7502CA562A3011A900766E7D /* LaunchScreen.storyboard */; }; 7502CA5F2A31A7D600766E7D /* CountryListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7502CA5E2A31A7D600766E7D /* CountryListViewController.swift */; }; 7502CA602A31A7D600766E7D /* CountryListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7502CA5E2A31A7D600766E7D /* CountryListViewController.swift */; }; @@ -281,6 +282,7 @@ 7501266F2B8A490000ED5E14 /* SelectFPXBankViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectFPXBankViewModel.swift; sourceTree = ""; }; 750126712B8A49BC00ED5E14 /* FPX.Bank+ViewPresentable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FPX.Bank+ViewPresentable.swift"; sourceTree = ""; }; 750126732B8A580500ED5E14 /* SelectDuitNowOBWBankViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectDuitNowOBWBankViewModel.swift; sourceTree = ""; }; + 750126762B95971A00ED5E14 /* ChoosePaymentCoordinator+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ChoosePaymentCoordinator+Helpers.swift"; sourceTree = ""; }; 7502CA552A3011A900766E7D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 7502CA582A3011B000766E7D /* th */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = th; path = th.lproj/LaunchScreen.strings; sourceTree = ""; }; 7502CA5A2A3011B100766E7D /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/LaunchScreen.strings; sourceTree = ""; }; @@ -558,7 +560,6 @@ 750126652B89F09F00ED5E14 /* Other Payments */ = { isa = PBXGroup; children = ( - 8A76791E214663560085DE3C /* PaymentUI.swift */, 750126682B89F0C200ED5E14 /* EContext */, 750126672B89F0B200ED5E14 /* TrueMoneyWallet */, 750126662B89F0AD00ED5E14 /* FPX */, @@ -594,6 +595,15 @@ path = EContext; sourceTree = ""; }; + 750126752B95948D00ED5E14 /* New Group */ = { + isa = PBXGroup; + children = ( + 8A76791E214663560085DE3C /* PaymentUI.swift */, + 8A30FB7C214929C900DC09DC /* PaymentCreatorController.swift */, + ); + path = "New Group"; + sourceTree = ""; + }; 750708E12B790B2400A48DD0 /* Helpers */ = { isa = PBXGroup; children = ( @@ -805,8 +815,9 @@ 75D13DF32B866C420073A831 /* Choose Payment Methods */ = { isa = PBXGroup; children = ( - 8A30FB7C214929C900DC09DC /* PaymentCreatorController.swift */, + 750126752B95948D00ED5E14 /* New Group */, 75D13D5F2B807AC90073A831 /* ChoosePaymentCoordinator.swift */, + 750126762B95971A00ED5E14 /* ChoosePaymentCoordinator+Helpers.swift */, 751E7BD82B7E5D130031B4A2 /* PaymentMethod.swift */, 75D13DF42B866C590073A831 /* ViewPresentable */, 75D13DF52B866C600073A831 /* Select Payment Delegates */, @@ -1396,6 +1407,7 @@ 14ACEF831D02D641001C5319 /* CardExpiryDatePicker.swift in Sources */, 75CFC4F32B753BCD00422A8F /* Capability.PaymentMethod.swift in Sources */, 75B4205E2B7674D70036134D /* Calendar+CreditCard.swift in Sources */, + 750126772B95971A00ED5E14 /* ChoosePaymentCoordinator+Helpers.swift in Sources */, 75D13D5E2B8069650073A831 /* UIImage+Omise.swift in Sources */, 75D13DA92B83B58B0073A831 /* Source.Payment.Item.swift in Sources */, 75E0EB9E2B7BD00F00E3198A /* OmiseError.swift in Sources */, From b1d51f674f1ddd8f2db33e266fe69ffe6e0f450c Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Mon, 4 Mar 2024 14:04:47 +0700 Subject: [PATCH 155/204] Move AuthorizingPaymentViewController.xib out of Storyboard --- .../Views/ProductDetailViewController.swift | 14 +++-- OmiseSDK/Sources/OmiseSDK.swift | 61 ++++++++++++++++-- .../AuthorizingPaymentViewController.swift | 63 +++---------------- .../AuthorizingPaymentViewController.xib | 25 ++++++++ .../EContextPaymentFormController.swift | 2 +- .../FPX/FPXPaymentFormController.swift | 2 +- .../TrueMoneyPaymentFormController.swift | 2 +- dev.xcodeproj/project.pbxproj | 4 ++ 8 files changed, 106 insertions(+), 67 deletions(-) create mode 100644 OmiseSDK/Sources/Views/Screens/Authorizing Payment/AuthorizingPaymentViewController.xib diff --git a/ExampleApp/Views/ProductDetailViewController.swift b/ExampleApp/Views/ProductDetailViewController.swift index 911652e1..5efdf0b8 100644 --- a/ExampleApp/Views/ProductDetailViewController.swift +++ b/ExampleApp/Views/ProductDetailViewController.swift @@ -134,16 +134,18 @@ class ProductDetailViewController: BaseViewController { preferredStyle: .alert) alertController.addTextField(configurationHandler: nil) alertController.addAction(UIAlertAction(title: "Cancel", style: UIAlertAction.Style.cancel, handler: nil)) - alertController.addAction(UIAlertAction(title: "Go", style: UIAlertAction.Style.default) { (_) in - guard let textField = alertController.textFields?.first, + alertController.addAction(UIAlertAction(title: "Go", style: UIAlertAction.Style.default) { [weak self ](_) in + guard let self = self, + let textField = alertController.textFields?.first, let text = textField.text, let url = URL(string: text), let expectedReturnURL = URLComponents(string: "https://opn.ooo/") else { return } - let handlerController = - AuthorizingPaymentViewController - .makeAuthorizingPaymentViewControllerNavigationWithAuthorizedURL( - url, expectedReturnURLPatterns: [expectedReturnURL], delegate: self) + let handlerController = self.omiseSDK.authorizedController( + authorizedURL: url, + expectedReturnURLPatterns: [expectedReturnURL], + delegate: self + ) self.present(handlerController, animated: true, completion: nil) }) present(alertController, animated: true, completion: nil) diff --git a/OmiseSDK/Sources/OmiseSDK.swift b/OmiseSDK/Sources/OmiseSDK.swift index ff982f15..856c012e 100644 --- a/OmiseSDK/Sources/OmiseSDK.swift +++ b/OmiseSDK/Sources/OmiseSDK.swift @@ -58,7 +58,7 @@ public class OmiseSDK { client.capability { _ in } } - /// Creates a Payment controller with given payment methods details + /// Creates a Payment controller with given payment methods details comes in UINavigationController stack /// /// - Parameters: /// - amount: Payment amount @@ -92,7 +92,7 @@ public class OmiseSDK { return navigationController } - /// Creates a Payment controller with payment methods loaded from Capability API + /// Creates a Payment controller with payment methods loaded from Capability API comes in UINavigationController stack /// /// - Parameters: /// - from: ViewController is used as a base to present UINavigationController @@ -125,7 +125,7 @@ public class OmiseSDK { return navigationController } - /// Creates a Credit Card Controller with payment methods loaded from Capability API + /// Creates a Credit Card Controller comes in UINavigationController stack /// /// - Parameters: /// - delegate: Delegate to be notified when Source or Token is created @@ -148,8 +148,59 @@ public class OmiseSDK { return navigationController } - func showAuthorizedController() { - + /// Creates a authorizing payment view controller comes in UINavigationController stack. + /// + /// - parameter authorizedURL: The authorized URL given in `Charge` object that will be set to `OmiseAuthorizingPaymentViewController` + /// - parameter expectedReturnURLPatterns: The expected return URL patterns. + /// - parameter delegate: A delegate object that will recieved authorizing payment events. + /// + /// - returns: A UINavigationController with `OmiseAuthorizingPaymentViewController` as its root view controller + public func authorizedController( + authorizedURL: URL, + expectedReturnURLPatterns: [URLComponents], + delegate: AuthorizingPaymentViewControllerDelegate + ) -> UINavigationController { + let viewController = AuthorizingPaymentViewController(nibName: nil, bundle: .omiseSDK) + viewController.authorizedURL = authorizedURL + viewController.expectedReturnURLPatterns = expectedReturnURLPatterns + viewController.delegate = delegate + viewController.applyNavigationBarStyle() + + let navigationController = UINavigationController(rootViewController: viewController) + navigationController.navigationBar.isTranslucent = false + navigationController.navigationBar.backgroundColor = .white + + if #available(iOSApplicationExtension 11.0, *) { + navigationController.navigationBar.prefersLargeTitles = true + } + + return navigationController + } + + /// A factory method for creating a authorizing payment view controller comes in UINavigationController stack. + /// + /// - parameter authorizedURL: The authorized URL given in `Charge` object that will be set to `OmiseAuthorizingPaymentViewController` + /// - parameter expectedReturnURLPatterns: The expected return URL patterns. + /// - parameter delegate: A delegate object that will recieved authorizing payment events. + /// + /// - returns: A UINavigationController with `OmiseAuthorizingPaymentViewController` as its root view controller + public static func authorizingPaymentController(_ authorizedURL: URL, expectedReturnURLPatterns: [URLComponents], delegate: AuthorizingPaymentViewControllerDelegate) -> UINavigationController { + let storyboard = UIStoryboard(name: "OmiseSDK", bundle: .omiseSDK) + let navigationController = storyboard.instantiateViewController( + withIdentifier: "DefaultAuthorizingPaymentViewControllerWithNavigation" + ) as! UINavigationController // swiftlint:disable:this force_cast + + navigationController.navigationBar.isTranslucent = false + navigationController.navigationBar.backgroundColor = .white + + // swiftlint:disable:next force_cast + let viewController = navigationController.topViewController as! AuthorizingPaymentViewController + viewController.authorizedURL = authorizedURL + viewController.expectedReturnURLPatterns = expectedReturnURLPatterns + viewController.delegate = delegate + viewController.applyNavigationBarStyle() + + return navigationController } } diff --git a/OmiseSDK/Sources/Views/Screens/Authorizing Payment/AuthorizingPaymentViewController.swift b/OmiseSDK/Sources/Views/Screens/Authorizing Payment/AuthorizingPaymentViewController.swift index a7fc9365..be0b9749 100644 --- a/OmiseSDK/Sources/Views/Screens/Authorizing Payment/AuthorizingPaymentViewController.swift +++ b/OmiseSDK/Sources/Views/Screens/Authorizing Payment/AuthorizingPaymentViewController.swift @@ -2,9 +2,6 @@ import Foundation import WebKit import os -/// Delegate to receive authorizing payment events. -@available(iOSApplicationExtension, unavailable) -// swiftlint:disable:next attributes public protocol AuthorizingPaymentViewControllerDelegate: AnyObject { /// A delegation method called when the authorizing payment process is completed. /// - parameter viewController: The authorizing payment controller that call this method. @@ -22,11 +19,9 @@ public protocol AuthorizingPaymentViewControllerDelegate: AnyObject { - remark: This is still an experimental API. If you encountered with any problem with this API, please feel free to report to Omise. */ -@available(iOSApplicationExtension, unavailable) -// swiftlint:disable:next attributes public class AuthorizingPaymentViewController: UIViewController { /// Authorized URL given from Omise in the created `Charge` object. - public var authorizedURL: URL? { + var authorizedURL: URL? { didSet { guard isViewLoaded else { return @@ -40,61 +35,16 @@ public class AuthorizingPaymentViewController: UIViewController { /// /// The rule is the scheme and host must be matched and must have the path as a prefix. /// Example: if the return URL is `https://www.example.com/products/12345` the expected return URL should have a URLComponents with scheme of `https`, host of `www.example.com` and the path of `/products/` - public var expectedReturnURLPatterns: [URLComponents] = [] + var expectedReturnURLPatterns: [URLComponents] = [] /// A delegate object that will recieved the authorizing payment events. - public weak var delegate: AuthorizingPaymentViewControllerDelegate? + weak var delegate: AuthorizingPaymentViewControllerDelegate? let webView = WKWebView(frame: CGRect.zero, configuration: WKWebViewConfiguration()) let okButtonTitle = NSLocalizedString("OK", comment: "OK button for JavaScript panel") let confirmButtonTitle = NSLocalizedString("Confirm", comment: "Confirm button for JavaScript panel") let cancelButtonTitle = NSLocalizedString("Cancel", comment: "Cancel button for JavaScript panel") - - /// A factory method for creating a authorizing payment view controller comes in UINavigationController stack. - /// - /// - parameter authorizedURL: The authorized URL given in `Charge` object that will be set to `OmiseAuthorizingPaymentViewController` - /// - parameter expectedReturnURLPatterns: The expected return URL patterns. - /// - parameter delegate: A delegate object that will recieved authorizing payment events. - /// - /// - returns: A UINavigationController with `OmiseAuthorizingPaymentViewController` as its root view controller - public static func makeAuthorizingPaymentViewControllerNavigationWithAuthorizedURL(_ authorizedURL: URL, expectedReturnURLPatterns: [URLComponents], delegate: AuthorizingPaymentViewControllerDelegate) -> UINavigationController { - let storyboard = UIStoryboard(name: "OmiseSDK", bundle: .omiseSDK) - let navigationController = storyboard.instantiateViewController( - withIdentifier: "DefaultAuthorizingPaymentViewControllerWithNavigation" - ) as! UINavigationController // swiftlint:disable:this force_cast - - navigationController.navigationBar.isTranslucent = false - navigationController.navigationBar.backgroundColor = .white - // swiftlint:disable:next force_cast - let viewController = navigationController.topViewController as! AuthorizingPaymentViewController - viewController.authorizedURL = authorizedURL - viewController.expectedReturnURLPatterns = expectedReturnURLPatterns - viewController.delegate = delegate - viewController.applyNavigationBarStyle() - - return navigationController - } - - /// A factory method for creating a authorizing payment view controller comes in UINavigationController stack. - /// - /// - parameter authorizedURL: The authorized URL given in `Charge` object that will be set to `OmiseAuthorizingPaymentViewController` - /// - parameter expectedReturnURLPatterns: The expected return URL patterns. - /// - parameter delegate: A delegate object that will recieved authorizing payment events. - /// - /// - returns: An `OmiseAuthorizingPaymentViewController` with given authorized URL and delegate. - public static func makeAuthorizingPaymentViewControllerWithAuthorizedURL(_ authorizedURL: URL, expectedReturnURLPatterns: [URLComponents], delegate: AuthorizingPaymentViewControllerDelegate) -> AuthorizingPaymentViewController { - let storyboard = UIStoryboard(name: "OmiseSDK", bundle: .omiseSDK) - let viewController = storyboard.instantiateViewController( - withIdentifier: "DefaultAuthorizingPaymentViewController" - ) as! AuthorizingPaymentViewController // swiftlint:disable:this force_cast - viewController.authorizedURL = authorizedURL - viewController.expectedReturnURLPatterns = expectedReturnURLPatterns - viewController.delegate = delegate - - return viewController - } - public override func viewDidLoad() { super.viewDidLoad() webView.translatesAutoresizingMaskIntoConstraints = false @@ -107,6 +57,13 @@ public class AuthorizingPaymentViewController: UIViewController { webView.navigationDelegate = self webView.uiDelegate = self + + let cancelButtonItem = UIBarButtonItem( + barButtonSystemItem: .cancel, + target: self, + action: #selector(cancelAuthorizingPaymentProcess) + ) + navigationItem.rightBarButtonItem = cancelButtonItem } public override func viewDidAppear(_ animated: Bool) { diff --git a/OmiseSDK/Sources/Views/Screens/Authorizing Payment/AuthorizingPaymentViewController.xib b/OmiseSDK/Sources/Views/Screens/Authorizing Payment/AuthorizingPaymentViewController.xib new file mode 100644 index 00000000..3ca6f73e --- /dev/null +++ b/OmiseSDK/Sources/Views/Screens/Authorizing Payment/AuthorizingPaymentViewController.xib @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/EContext/EContextPaymentFormController.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/EContext/EContextPaymentFormController.swift index 26127c41..8029a229 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/EContext/EContextPaymentFormController.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/EContext/EContextPaymentFormController.swift @@ -55,7 +55,7 @@ class EContextPaymentFormController: UIViewController, PaymentFormUIController { navigationItem.largeTitleDisplayMode = .never } - navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil) + navigationItem.backBarButtonItem = .empty formFields.forEach { $0.inputAccessoryView = formFieldsAccessoryView diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/FPX/FPXPaymentFormController.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/FPX/FPXPaymentFormController.swift index 8998fd0b..52762d43 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/FPX/FPXPaymentFormController.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/FPX/FPXPaymentFormController.swift @@ -62,7 +62,7 @@ class FPXPaymentFormController: UIViewController, PaymentFormUIController { navigationItem.largeTitleDisplayMode = .never } - navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil) + navigationItem.backBarButtonItem = .empty formFields.forEach { $0.inputAccessoryView = formFieldsAccessoryView diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.swift index f3e56d26..8525c268 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.swift @@ -46,7 +46,7 @@ class TrueMoneyPaymentFormController: UIViewController, PaymentFormUIController navigationItem.largeTitleDisplayMode = .never } - navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil) + navigationItem.backBarButtonItem = .empty formFields.forEach { $0.inputAccessoryView = formFieldsAccessoryView diff --git a/dev.xcodeproj/project.pbxproj b/dev.xcodeproj/project.pbxproj index f4e0b1ee..83633f94 100644 --- a/dev.xcodeproj/project.pbxproj +++ b/dev.xcodeproj/project.pbxproj @@ -25,6 +25,7 @@ 750126722B8A49BC00ED5E14 /* FPX.Bank+ViewPresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 750126712B8A49BC00ED5E14 /* FPX.Bank+ViewPresentable.swift */; }; 750126742B8A580500ED5E14 /* SelectDuitNowOBWBankViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 750126732B8A580500ED5E14 /* SelectDuitNowOBWBankViewModel.swift */; }; 750126772B95971A00ED5E14 /* ChoosePaymentCoordinator+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 750126762B95971A00ED5E14 /* ChoosePaymentCoordinator+Helpers.swift */; }; + 750126792B95A34000ED5E14 /* AuthorizingPaymentViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 750126782B95A34000ED5E14 /* AuthorizingPaymentViewController.xib */; }; 7502CA532A3011A900766E7D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7502CA562A3011A900766E7D /* LaunchScreen.storyboard */; }; 7502CA5F2A31A7D600766E7D /* CountryListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7502CA5E2A31A7D600766E7D /* CountryListViewController.swift */; }; 7502CA602A31A7D600766E7D /* CountryListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7502CA5E2A31A7D600766E7D /* CountryListViewController.swift */; }; @@ -283,6 +284,7 @@ 750126712B8A49BC00ED5E14 /* FPX.Bank+ViewPresentable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FPX.Bank+ViewPresentable.swift"; sourceTree = ""; }; 750126732B8A580500ED5E14 /* SelectDuitNowOBWBankViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectDuitNowOBWBankViewModel.swift; sourceTree = ""; }; 750126762B95971A00ED5E14 /* ChoosePaymentCoordinator+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ChoosePaymentCoordinator+Helpers.swift"; sourceTree = ""; }; + 750126782B95A34000ED5E14 /* AuthorizingPaymentViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AuthorizingPaymentViewController.xib; sourceTree = ""; }; 7502CA552A3011A900766E7D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 7502CA582A3011B000766E7D /* th */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = th; path = th.lproj/LaunchScreen.strings; sourceTree = ""; }; 7502CA5A2A3011B100766E7D /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/LaunchScreen.strings; sourceTree = ""; }; @@ -879,6 +881,7 @@ isa = PBXGroup; children = ( 8A188BAF1D951E3C00FFF467 /* AuthorizingPaymentViewController.swift */, + 750126782B95A34000ED5E14 /* AuthorizingPaymentViewController.xib */, ); path = "Authorizing Payment"; sourceTree = ""; @@ -1284,6 +1287,7 @@ 75D13E1B2B86FD2D0073A831 /* CCVInfoController.xib in Resources */, 75405AA82A27F97E008C21F6 /* Localizable.strings in Resources */, 7501266E2B8A411C00ED5E14 /* FPXPaymentFormController.xib in Resources */, + 750126792B95A34000ED5E14 /* AuthorizingPaymentViewController.xib in Resources */, 8A776647214A5FC60029D166 /* NoticeView.xib in Resources */, 2225B3541D0FDD63003EB396 /* Assets.xcassets in Resources */, 8AF5517A213D4C0100D61C98 /* Localizable.stringsdict in Resources */, From 9764e47a057d3b133308c796bdb779a7eb9c5540 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Mon, 4 Mar 2024 14:29:00 +0700 Subject: [PATCH 156/204] Cleanup example app Storyboard --- ExampleApp/Resources/Main.storyboard | 104 +++------ ExampleApp/Views/BaseViewController.swift | 21 -- .../CustomCreditCardFormViewController.swift | 162 +++++++------ .../Views/ProductDetailViewController.swift | 76 ------ .../Resources/Base.lproj/OmiseSDK.storyboard | 54 ----- OmiseSDK/Resources/en.lproj/OmiseSDK.strings | 216 ------------------ OmiseSDK/Resources/ja.lproj/OmiseSDK.strings | 173 -------------- OmiseSDK/Resources/th.lproj/OmiseSDK.strings | 194 ---------------- OmiseSDK/Sources/OmiseSDK.swift | 44 +--- .../CreditCardPaymentController.swift | 9 - .../PaymentCreatorController.swift | 0 .../PaymentUI.swift | 0 README.md | 51 ----- dev.xcodeproj/project.pbxproj | 24 +- 14 files changed, 119 insertions(+), 1009 deletions(-) delete mode 100644 OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard delete mode 100644 OmiseSDK/Resources/en.lproj/OmiseSDK.strings delete mode 100644 OmiseSDK/Resources/ja.lproj/OmiseSDK.strings delete mode 100644 OmiseSDK/Resources/th.lproj/OmiseSDK.strings rename OmiseSDK/Sources/Views/Screens/{Choose Payment Methods/New Group => _ to refactor and delete}/PaymentCreatorController.swift (100%) rename OmiseSDK/Sources/Views/Screens/{Choose Payment Methods/New Group => _ to refactor and delete}/PaymentUI.swift (100%) diff --git a/ExampleApp/Resources/Main.storyboard b/ExampleApp/Resources/Main.storyboard index 01c69422..c58018dd 100644 --- a/ExampleApp/Resources/Main.storyboard +++ b/ExampleApp/Resources/Main.storyboard @@ -30,18 +30,18 @@ - + - + - @@ -121,8 +102,8 @@ You can present via either Storyboard or Code and you can see the code in the Ex - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1318,20 +1197,6 @@ You can see the code in the ExampleApp targets. - - - - - - - - - - - - - - diff --git a/OmiseSDK/Sources/OmiseAPI/JSON Models/Source/Source.Payment.DuitNowOBW.swift b/OmiseSDK/Sources/OmiseAPI/JSON Models/Source/Source.Payment.DuitNowOBW.swift index 3ddb95df..a7aa5e46 100644 --- a/OmiseSDK/Sources/OmiseAPI/JSON Models/Source/Source.Payment.DuitNowOBW.swift +++ b/OmiseSDK/Sources/OmiseAPI/JSON Models/Source/Source.Payment.DuitNowOBW.swift @@ -37,4 +37,3 @@ extension Source.Payment.DuitNowOBW: Codable { self.bank = try container.decode(Bank.self, forKey: .bank) } } - diff --git a/OmiseSDK/Sources/OmiseAPI/JSON Models/Source/Source.Payment.swift b/OmiseSDK/Sources/OmiseAPI/JSON Models/Source/Source.Payment.swift index a307bb8e..1e7eda3c 100644 --- a/OmiseSDK/Sources/OmiseAPI/JSON Models/Source/Source.Payment.swift +++ b/OmiseSDK/Sources/OmiseAPI/JSON Models/Source/Source.Payment.swift @@ -97,7 +97,7 @@ extension Source.Payment: Codable { extension Source.Payment { static func requiresAdditionalDetails(sourceType: SourceType) -> Bool { - var requiresDetails: [SourceType] = [ + let requiresDetails: [SourceType] = [ Atome.sourceType, BarcodeAlipay.sourceType, DuitNowOBW.sourceType, diff --git a/OmiseSDK/Sources/OmiseAPI/SourceType/SourceType+Collections.swift b/OmiseSDK/Sources/OmiseAPI/SourceType/SourceType+Collections.swift index de2190d0..165c00b8 100644 --- a/OmiseSDK/Sources/OmiseAPI/SourceType/SourceType+Collections.swift +++ b/OmiseSDK/Sources/OmiseAPI/SourceType/SourceType+Collections.swift @@ -1,32 +1,30 @@ - import Foundation extension SourceType { - // TODO: Revert before release - public static let availableByDefaultInThailand: [SourceType] = SourceType.allCases -// [ -// .internetBankingBAY, -// .internetBankingBBL, -// .mobileBankingSCB, -// .mobileBankingKBank, -// .mobileBankingBAY, -// .mobileBankingBBL, -// .mobileBankingKTB, -// .alipay, -// .billPaymentTescoLotus, -// .installmentBAY, -// .installmentFirstChoice, -// .installmentBBL, -// .installmentKTC, -// .installmentKBank, -// .installmentSCB, -// .installmentTTB, -// .installmentUOB, -// .promptPay, -// .trueMoneyWallet, -// .pointsCiti, -// .shopeePayJumpApp -// ] + public static let availableByDefaultInThailand: [SourceType] = + [ + .internetBankingBAY, + .internetBankingBBL, + .mobileBankingSCB, + .mobileBankingKBank, + .mobileBankingBAY, + .mobileBankingBBL, + .mobileBankingKTB, + .alipay, + .billPaymentTescoLotus, + .installmentBAY, + .installmentFirstChoice, + .installmentBBL, + .installmentKTC, + .installmentKBank, + .installmentSCB, + .installmentTTB, + .installmentUOB, + .promptPay, + .trueMoneyWallet, + .pointsCiti, + .shopeePayJumpApp + ] public static let availableByDefaultInJapan: [SourceType] = [ .eContext, diff --git a/OmiseSDK/Sources/OmiseSDK.swift b/OmiseSDK/Sources/OmiseSDK.swift index 149b0bca..27585117 100644 --- a/OmiseSDK/Sources/OmiseSDK.swift +++ b/OmiseSDK/Sources/OmiseSDK.swift @@ -163,6 +163,7 @@ public class OmiseSDK { /// - parameter delegate: A delegate object that will recieved authorizing payment events. /// /// - returns: A UINavigationController with `OmiseAuthorizingPaymentViewController` as its root view controller + @available(iOSApplicationExtension, unavailable) public func authorizedController( authorizedURL: URL, expectedReturnURLPatterns: [URLComponents], diff --git a/OmiseSDK/Sources/Views/Components/TextFields/OmiseTextField.swift b/OmiseSDK/Sources/Views/Components/TextFields/OmiseTextField.swift index 5cbd0413..e730b489 100644 --- a/OmiseSDK/Sources/Views/Components/TextFields/OmiseTextField.swift +++ b/OmiseSDK/Sources/Views/Components/TextFields/OmiseTextField.swift @@ -21,7 +21,7 @@ public class OmiseTextField: UITextField { } public var onTextFieldShouldReturn: () -> (Bool) = { return false } - public var onValueChanged: () -> () = { } + public var onValueChanged: () -> Void = { } @IBInspectable var borderWidth: CGFloat { get { diff --git a/OmiseSDK/Sources/Views/Screens/Authorizing Payment/AuthorizingPaymentViewController.swift b/OmiseSDK/Sources/Views/Screens/Authorizing Payment/AuthorizingPaymentViewController.swift index be0b9749..7e43bf4f 100644 --- a/OmiseSDK/Sources/Views/Screens/Authorizing Payment/AuthorizingPaymentViewController.swift +++ b/OmiseSDK/Sources/Views/Screens/Authorizing Payment/AuthorizingPaymentViewController.swift @@ -2,6 +2,7 @@ import Foundation import WebKit import os +@available(iOSApplicationExtension, unavailable) public protocol AuthorizingPaymentViewControllerDelegate: AnyObject { /// A delegation method called when the authorizing payment process is completed. /// - parameter viewController: The authorizing payment controller that call this method. @@ -19,6 +20,7 @@ public protocol AuthorizingPaymentViewControllerDelegate: AnyObject { - remark: This is still an experimental API. If you encountered with any problem with this API, please feel free to report to Omise. */ +@available(iOSApplicationExtension, unavailable) public class AuthorizingPaymentViewController: UIViewController { /// Authorized URL given from Omise in the created `Charge` object. var authorizedURL: URL? { diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator.swift index 4e2fe658..314abb6e 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator.swift @@ -87,7 +87,6 @@ class ChoosePaymentCoordinator: NSObject, ViewAttachable { return viewController } - /// Creates Mobile Banking screen and attach current flow object inside created controller to be deallocated together func createMobileBankingController() -> SelectPaymentController { let viewModel = SelectSourceTypePaymentViewModel( diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/Base/To Be Implemented/PaymentInputProtocol.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/Base/To Be Implemented/PaymentInputProtocol.swift index 80d05e4b..cb68c15c 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/Base/To Be Implemented/PaymentInputProtocol.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/Base/To Be Implemented/PaymentInputProtocol.swift @@ -1,7 +1,7 @@ import Foundation import UIKit -//protocol PaymenFormtInputProtocol { +// protocol PaymenFormtInputProtocol { // var next: PaymenFormtInputProtocol? { get set } // var section: String? { get } // optional // var title: String { get } @@ -13,13 +13,13 @@ import UIKit // var keyboardType: UIKeyboardType { get } // default asciiCapable // var validatorRegex: String? { get } // optional // var isOptional: Bool { get } // by default false -//} +// } // -//extension PaymenFormtInputProtocol { +// extension PaymenFormtInputProtocol { // var section: String? { nil } // var contentType: UITextContentType? { nil } // var capitalization: UITextAutocapitalizationType { .none } // var keyboardType: UIKeyboardType { .asciiCapable } // var validatorRegex: String? { nil } // var isOptional: Bool { false } -//} +// } diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/FPX/FPXPaymentFormController.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/FPX/FPXPaymentFormController.swift index 52762d43..51919d9d 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/FPX/FPXPaymentFormController.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/FPX/FPXPaymentFormController.swift @@ -130,10 +130,9 @@ class FPXPaymentFormController: UIViewController, PaymentFormUIController { @IBAction private func submitForm(_ sender: AnyObject) { emailValue = emailTextField.text?.trimmingCharacters(in: CharacterSet.whitespaces) - delegate?.fpxDidCompleteWith(email: emailValue, completion: {}) + delegate?.fpxDidCompleteWith(email: emailValue) {} } - @IBAction private func validateFieldData(_ textField: OmiseTextField) { submitButton.isEnabled = isInputDataValid } diff --git a/OmiseSDK/Sources/Views/Screens/_ to refactor and delete/PaymentCreatorController.swift b/OmiseSDK/Sources/Views/Screens/_ to refactor and delete/PaymentCreatorController.swift index 70dd66a4..c600818d 100644 --- a/OmiseSDK/Sources/Views/Screens/_ to refactor and delete/PaymentCreatorController.swift +++ b/OmiseSDK/Sources/Views/Screens/_ to refactor and delete/PaymentCreatorController.swift @@ -1,5 +1,3 @@ -// swiftlint:disable file_length - import UIKit import os @@ -57,9 +55,6 @@ public class PaymentCreatorController: UINavigationController { /// Defaults to `true`. public var handleErrors = true - /// Delegate to receive CreditCardPaymentController result. -// public weak var paymentDelegate: PaymentCreatorControllerDelegate? - var client: Client? { didSet { paymentSourceCreatorFlowSession.client = client @@ -243,13 +238,6 @@ public class PaymentCreatorController: UINavigationController { return super.popViewController(animated: animated) } - public override func addChild(_ childController: UIViewController) { -// if let viewController = childController as? ChoosePaymentMethodControllerOld { -// viewController.viewModel.flowSession = self.paymentSourceCreatorFlowSession -// } - super.addChild(childController) - } - // need to refactor loadView, removing super results in crash // swiftlint:disable:next prohibited_super_call public override func loadView() { @@ -289,7 +277,6 @@ extension PaymentCreatorController: PaymentCreatorFlowSessionDelegate { type: .default, token.id) - // if let paymentDelegate = self.paymentDelegate { // paymentDelegate.paymentCreatorController(self, didCreatePayment: Payment.token(token)) // } diff --git a/dev.xcodeproj/project.pbxproj b/dev.xcodeproj/project.pbxproj index 42130201..0ee78249 100644 --- a/dev.xcodeproj/project.pbxproj +++ b/dev.xcodeproj/project.pbxproj @@ -1664,7 +1664,7 @@ ); INFOPLIST_FILE = OmiseSDK/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 10; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1896,7 +1896,7 @@ ); INFOPLIST_FILE = OmiseSDK/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 10; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", From 7e9ddefed9fbc21364b863296e6cd97f7e28376e Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Mon, 4 Mar 2024 15:22:39 +0700 Subject: [PATCH 158/204] Changing Readme --- OmiseSDK/Sources/OmiseSDK.swift | 21 +++++++++++++-------- README.md | 6 +++--- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/OmiseSDK/Sources/OmiseSDK.swift b/OmiseSDK/Sources/OmiseSDK.swift index 27585117..5b62ec36 100644 --- a/OmiseSDK/Sources/OmiseSDK.swift +++ b/OmiseSDK/Sources/OmiseSDK.swift @@ -34,9 +34,6 @@ public class OmiseSDK { /// Client is used to communicate with Omise API public let client: Client - /// If it's `true` SDK will handle errors and will not notify ChoosePaymentMethodDelegate - public let handleErrors: Bool - /// Latest capability loaded with `client.capability()` var latestLoadedCapability: Capability? { client.latestLoadedCapability } @@ -50,9 +47,8 @@ public class OmiseSDK { /// - Parameters: /// - publicKey: Omise public key /// - configuration: Optional configuration is used for testing - public init(publicKey: String, handleErrors: Bool = true, configuration: Configuration? = nil) { + public init(publicKey: String, configuration: Configuration? = nil) { self.publicKey = publicKey - self.handleErrors = handleErrors self.client = Client( publicKey: publicKey, version: version, @@ -79,6 +75,7 @@ public class OmiseSDK { currency: String, allowedPaymentMethods: [SourceType], allowedCardPayment: Bool, + handleErrors: Bool = true, delegate: ChoosePaymentMethodDelegate ) -> UINavigationController { let paymentFlow = ChoosePaymentCoordinator( @@ -106,10 +103,12 @@ public class OmiseSDK { /// - from: ViewController is used as a base to present UINavigationController /// - allowedPaymentMethods: Custom list of payment methods to be shown in the list. If value is nill then SDK will load list from Capability API /// - allowedCardPayment: Should present Card Payment Method in the list + /// - handleErrors: If the value is `true` the controller will show an error alerts in the UI, if `false` the controller will notify delegate /// - delegate: Delegate to be notified when Source or Token is created public func choosePaymentMethodFromCapabilityController( amount: Int64, currency: String, + handleErrors: Bool = true, delegate: ChoosePaymentMethodDelegate ) -> UINavigationController { let paymentFlow = ChoosePaymentCoordinator( @@ -136,13 +135,19 @@ public class OmiseSDK { /// Creates a Credit Card Controller comes in UINavigationController stack /// /// - Parameters: + /// - countryCode: Delegate to be notified when Source or Token is created + /// - handleErrors: If the value is `true` the controller will show an error alerts in the UI, if `false` the controller will notify delegate /// - delegate: Delegate to be notified when Source or Token is created - public func creditCardController(delegate: ChoosePaymentMethodDelegate) -> UINavigationController { + public func creditCardController( + countryCode: String? = nil, + handleErrors: Bool = true, + delegate: ChoosePaymentMethodDelegate + ) -> UINavigationController { let paymentFlow = ChoosePaymentCoordinator( client: client, amount: 0, currency: "", - currentCountry: country, + currentCountry: Country(code: countryCode) ?? self.country, handleErrors: handleErrors ) let viewController = paymentFlow.createCreditCardPaymentController(delegate: delegate) @@ -162,7 +167,7 @@ public class OmiseSDK { /// - parameter expectedReturnURLPatterns: The expected return URL patterns. /// - parameter delegate: A delegate object that will recieved authorizing payment events. /// - /// - returns: A UINavigationController with `OmiseAuthorizingPaymentViewController` as its root view controller + /// - returns: A UINavigationController with `AuthorizingPaymentViewController` as its root view controller @available(iOSApplicationExtension, unavailable) public func authorizedController( authorizedURL: URL, diff --git a/README.md b/README.md index 0566d8af..2a53d4c0 100644 --- a/README.md +++ b/README.md @@ -58,14 +58,14 @@ details, read on: ### Opn Payments API The Opn Payments iOS SDK provides an easy-to-use library for calling the -Opn Payments API. The main class for the Opn Payments iOS SDK is `Client` through +Opn Payments API. The main classes for the Opn Payments iOS SDK is `OmiseSDK` and `Client` through which all requests to the Opn Payments API will be sent. Creating a new -`Client` object requires an Opn Payments public key. +`OmiseSDK` object requires an Opn Payments public key. ``` swift import OmiseSDK -let client = OmiseSDK.Client.init(publicKey: "omise_public_key") +let omiseSDK = OmiseSDK(publicKey: "omise_public_key") ``` From 4f77e620afedbbfcae8bc698f69efb184090bb09 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Mon, 4 Mar 2024 15:27:34 +0700 Subject: [PATCH 159/204] Clean sonarcloud warning --- OmiseSDK/Sources/OmiseSDK.swift | 7 ++++--- .../Views/Components/TextFields/CardNumberTextField.swift | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/OmiseSDK/Sources/OmiseSDK.swift b/OmiseSDK/Sources/OmiseSDK.swift index 5b62ec36..316d5e78 100644 --- a/OmiseSDK/Sources/OmiseSDK.swift +++ b/OmiseSDK/Sources/OmiseSDK.swift @@ -69,6 +69,7 @@ public class OmiseSDK { /// - currency: Payment currency code /// - allowedPaymentMethods: Custom list of payment methods to be shown in the list. If value is nill then SDK will load list from Capability API /// - allowedCardPayment: Should present Card Payment Method in the list + /// - handleErrors: If `true` the controller will show an error alerts in the UI, if `false` the controller will notify delegate /// - completion: Completion handler triggered when payment completes with Token, Source, Error or was Cancelled public func choosePaymentMethodController( amount: Int64, @@ -103,7 +104,7 @@ public class OmiseSDK { /// - from: ViewController is used as a base to present UINavigationController /// - allowedPaymentMethods: Custom list of payment methods to be shown in the list. If value is nill then SDK will load list from Capability API /// - allowedCardPayment: Should present Card Payment Method in the list - /// - handleErrors: If the value is `true` the controller will show an error alerts in the UI, if `false` the controller will notify delegate + /// - handleErrors: If `true` the controller will show an error alerts in the UI, if `false` the controller will notify delegate /// - delegate: Delegate to be notified when Source or Token is created public func choosePaymentMethodFromCapabilityController( amount: Int64, @@ -136,7 +137,7 @@ public class OmiseSDK { /// /// - Parameters: /// - countryCode: Delegate to be notified when Source or Token is created - /// - handleErrors: If the value is `true` the controller will show an error alerts in the UI, if `false` the controller will notify delegate + /// - handleErrors: If `true` the controller will show an error alerts in the UI, if `false` the controller will notify delegate /// - delegate: Delegate to be notified when Source or Token is created public func creditCardController( countryCode: String? = nil, @@ -163,7 +164,7 @@ public class OmiseSDK { /// Creates a authorizing payment view controller comes in UINavigationController stack. /// - /// - parameter authorizedURL: The authorized URL given in `Charge` object that will be set to `OmiseAuthorizingPaymentViewController` + /// - parameter authorizedURL: The authorized URL given in `Charge` object /// - parameter expectedReturnURLPatterns: The expected return URL patterns. /// - parameter delegate: A delegate object that will recieved authorizing payment events. /// diff --git a/OmiseSDK/Sources/Views/Components/TextFields/CardNumberTextField.swift b/OmiseSDK/Sources/Views/Components/TextFields/CardNumberTextField.swift index 27fd9698..82cec6e4 100644 --- a/OmiseSDK/Sources/Views/Components/TextFields/CardNumberTextField.swift +++ b/OmiseSDK/Sources/Views/Components/TextFields/CardNumberTextField.swift @@ -65,8 +65,8 @@ public class CardNumberTextField: OmiseTextField { super.delegate = self - placeholder = placeholder - + updatePlaceholderTextColor() + textContentType = .creditCardNumber } From ce5f037d359b8f19358743fd5fc085d123fe813d Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Wed, 6 Mar 2024 15:22:17 +0700 Subject: [PATCH 160/204] Update ExampleApp testing branch for OmiseSDK --- ExampleApp.xcodeproj/project.pbxproj | 2 +- .../project.xcworkspace/xcshareddata/swiftpm/Package.resolved | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ExampleApp.xcodeproj/project.pbxproj b/ExampleApp.xcodeproj/project.pbxproj index be84f8ad..54ea45b1 100644 --- a/ExampleApp.xcodeproj/project.pbxproj +++ b/ExampleApp.xcodeproj/project.pbxproj @@ -453,7 +453,7 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/omise/omise-ios.git"; requirement = { - branch = "feature/MIT-2251_v5_AdaptableTableView"; + branch = feature/v5_refactoring; kind = branch; }; }; diff --git a/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index ff610e98..6c46f6bd 100644 --- a/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/omise/omise-ios.git", "state" : { - "branch" : "feature/MIT-2251_v5_AdaptableTableView", - "revision" : "bf2e8840edf4cd937fdb1daf2d8e1d3a030b96bb" + "branch" : "feature/v5_refactoring", + "revision" : "a2b256dc8fb9b2a7deca380b2ae8441342ec29d8" } } ], From 736fed32c8149c49f2f521bcc339c25b8abd55bc Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Wed, 13 Mar 2024 00:04:02 +0700 Subject: [PATCH 161/204] Update ChoosePaymentMethod filter --- .../Views/ProductDetailViewController.swift | 27 +++----- OmiseSDK/Sources/OmiseSDK.swift | 65 +++++++------------ .../ChoosePaymentCoordinator.swift | 16 +---- .../SelectPaymentMethodViewModel.swift | 58 +++++++++++------ 4 files changed, 74 insertions(+), 92 deletions(-) diff --git a/ExampleApp/Views/ProductDetailViewController.swift b/ExampleApp/Views/ProductDetailViewController.swift index 77a7ff42..575ea5ef 100644 --- a/ExampleApp/Views/ProductDetailViewController.swift +++ b/ExampleApp/Views/ProductDetailViewController.swift @@ -27,23 +27,16 @@ class ProductDetailViewController: BaseViewController { } @IBAction private func showModalPaymentCreator(_ sender: Any) { - if usesCapabilityDataForPaymentMethods { - let viewController = omiseSDK.choosePaymentMethodFromCapabilityController( - amount: paymentAmount, - currency: paymentCurrencyCode, - delegate: self - ) - present(viewController, animated: true, completion: nil) - } else { - let viewController = omiseSDK.choosePaymentMethodController( - amount: paymentAmount, - currency: paymentCurrencyCode, - allowedPaymentMethods: allowedPaymentMethods, - allowedCardPayment: true, - delegate: self - ) - present(viewController, animated: true, completion: nil) - } + omiseSDK.presentChoosePaymentMethod( + from: self, + amount: paymentAmount, + currency: paymentCurrencyCode, + allowedPaymentMethods: usesCapabilityDataForPaymentMethods ? [] : allowedPaymentMethods, + forcePaymentMethods: true, + isCardPaymentAllowed: true, + handleErrors: true, + delegate: self + ) } @IBAction private func showCustomCreditCardPayment(_ sender: Any) { diff --git a/OmiseSDK/Sources/OmiseSDK.swift b/OmiseSDK/Sources/OmiseSDK.swift index 316d5e78..637d4dc4 100644 --- a/OmiseSDK/Sources/OmiseSDK.swift +++ b/OmiseSDK/Sources/OmiseSDK.swift @@ -57,25 +57,28 @@ public class OmiseSDK { vaultURL: configuration?.vaultURL ) - let color = UIColor(red: 0.26, green: 0.27, blue: 0.28, alpha: 0.5) - print(color.hexString) - client.capability { _ in } + preloadCapabilityAPI() } - /// Creates a Payment controller with given payment methods details comes in UINavigationController stack + /// Creates and presents modal Choose Payment Methods Controller with given parameters /// /// - Parameters: + /// - from: ViewController to be used to present Choose Payment Methods /// - amount: Payment amount - /// - currency: Payment currency code - /// - allowedPaymentMethods: Custom list of payment methods to be shown in the list. If value is nill then SDK will load list from Capability API - /// - allowedCardPayment: Should present Card Payment Method in the list - /// - handleErrors: If `true` the controller will show an error alerts in the UI, if `false` the controller will notify delegate + /// - currency: Payment currency code (ISO 4217) + /// - allowedPaymentMethods: Custom list of payment methods to be shown in the list. Only payment methods presented in the Capabilities will be shown + /// - forcePaymentMethods: If `true` all payment methods from `paymentMethods` will be shown if it's not empty (for test purposes) + /// - isCardPaymentAllowed: Should present Card Payment Method in the list + /// - handleErrors: If `true` the controller will show an error alerts in the UI, if `false` the controller will notify delegate /// - completion: Completion handler triggered when payment completes with Token, Source, Error or was Cancelled - public func choosePaymentMethodController( + @discardableResult + public func presentChoosePaymentMethod( + from topViewController: UIViewController, amount: Int64, currency: String, - allowedPaymentMethods: [SourceType], - allowedCardPayment: Bool, + allowedPaymentMethods: [SourceType] = [], + forcePaymentMethods: Bool = false, + isCardPaymentAllowed: Bool = true, handleErrors: Bool = true, delegate: ChoosePaymentMethodDelegate ) -> UINavigationController { @@ -86,41 +89,15 @@ public class OmiseSDK { currentCountry: country, handleErrors: handleErrors ) - let viewController = paymentFlow.createChoosePaymentMethodController( - allowedPaymentMethods: allowedPaymentMethods, - allowedCardPayment: allowedCardPayment, - usePaymentMethodsFromCapability: false, - delegate: delegate - ) - - let navigationController = UINavigationController(rootViewController: viewController) - navigationController.delegate = paymentFlow - return navigationController - } - /// Creates a Payment controller with payment methods loaded from Capability API comes in UINavigationController stack - /// - /// - Parameters: - /// - from: ViewController is used as a base to present UINavigationController - /// - allowedPaymentMethods: Custom list of payment methods to be shown in the list. If value is nill then SDK will load list from Capability API - /// - allowedCardPayment: Should present Card Payment Method in the list - /// - handleErrors: If `true` the controller will show an error alerts in the UI, if `false` the controller will notify delegate - /// - delegate: Delegate to be notified when Source or Token is created - public func choosePaymentMethodFromCapabilityController( - amount: Int64, - currency: String, - handleErrors: Bool = true, - delegate: ChoosePaymentMethodDelegate - ) -> UINavigationController { - let paymentFlow = ChoosePaymentCoordinator( - client: client, - amount: amount, - currency: currency, - currentCountry: country, - handleErrors: handleErrors + let filter = SelectPaymentMethodViewModel.Filter( + sourceTypes: allowedPaymentMethods, + isCardPaymentAllowed: isCardPaymentAllowed, + isForced: forcePaymentMethods ) + let viewController = paymentFlow.createChoosePaymentMethodController( - usePaymentMethodsFromCapability: true, + filter: filter, delegate: delegate ) @@ -130,6 +107,8 @@ public class OmiseSDK { } navigationController.delegate = paymentFlow + + topViewController.present(navigationController, animated: true, completion: nil) return navigationController } diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator.swift index 314abb6e..d26d371d 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator.swift @@ -38,23 +38,13 @@ class ChoosePaymentCoordinator: NSObject, ViewAttachable { /// Creates SelectPaymentController and attach current flow object inside created controller to be deallocated together /// /// - Parameters: - /// - allowedPaymentMethods: List of Payment Methods to be presented in the list if `usePaymentMethodsFromCapability` is `false` - /// - allowedCardPayment: Shows credit card payment option if `true` and `usePaymentMethodsFromCapability` is `false` - /// - usePaymentMethodsFromCapability: If `true`then it loads list of Payment Methods from Capability API and ignores previous parameters + /// - filter: Filter for Payment Methods list to be presented in the list /// - delegate: Payment method delegate func createChoosePaymentMethodController( - allowedPaymentMethods paymentMethods: [SourceType] = [], - allowedCardPayment isCardEnabled: Bool = true, - usePaymentMethodsFromCapability useCapability: Bool, + filter: SelectPaymentMethodViewModel.Filter, delegate: ChoosePaymentMethodDelegate ) -> SelectPaymentController { - let viewModel = SelectPaymentMethodViewModel(client: client, delegate: self) - if useCapability { - viewModel.setupCapability() - } else { - viewModel.setupAllowedPaymentMethods(paymentMethods, isCardEnabled: isCardEnabled) - } - + let viewModel = SelectPaymentMethodViewModel(client: client, filter: filter, delegate: self) let listController = SelectPaymentController(viewModel: viewModel) listController.attach(self) diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentMethodViewModel.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentMethodViewModel.swift index 3abb6527..dffe427e 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentMethodViewModel.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentMethodViewModel.swift @@ -2,8 +2,15 @@ import Foundation import UIKit.UIImage class SelectPaymentMethodViewModel { - private weak var delegate: SelectPaymentMethodDelegate? + struct Filter { + let sourceTypes: [SourceType] + let isCardPaymentAllowed: Bool + let isForced: Bool + } + private let client: Client + private let filter: Filter + private weak var delegate: SelectPaymentMethodDelegate? private var viewOnDataReloadHandler: () -> Void = { } { didSet { @@ -17,33 +24,46 @@ class SelectPaymentMethodViewModel { } } - init(client: Client, delegate: SelectPaymentMethodDelegate) { + init(client: Client, filter: Filter, delegate: SelectPaymentMethodDelegate) { self.client = client self.delegate = delegate - } + self.filter = filter - func setupAllowedPaymentMethods(_ paymentMethods: [SourceType], isCardEnabled: Bool) { - self.paymentMethods = PaymentMethod.createPaymentMethods( - from: paymentMethods, - showsCreditCard: isCardEnabled - ) - } + if !filter.sourceTypes.isEmpty, filter.isForced { + self.paymentMethods = PaymentMethod.createPaymentMethods( + from: filter.sourceTypes, + showsCreditCard: filter.isCardPaymentAllowed + ) + } else { - func setupCapability() { - var allowedPaymentMethods: [SourceType] = [] - var isCardEnabled = false + setupCapability(client.latestLoadedCapability) + } + } - if let capability = client.latestLoadedCapability { - isCardEnabled = capability.cardPaymentMethod != nil - allowedPaymentMethods = capability.paymentMethods.compactMap { - SourceType(rawValue: $0.name) - } - } else { + func setupCapability(_ capability: Capability? = nil) { + guard let capability = capability else { client.capability { [weak self] result in if let capability = try? result.get() { - self?.paymentMethods = PaymentMethod.createPaymentMethods(with: capability) + self?.setupCapability(capability) } } + return + } + let sourceTypes = capability.paymentMethods.compactMap { SourceType(rawValue: $0.name) } + let isCardPaymentAllowed = capability.cardPaymentMethod != nil + setupPaymentMethodsAndFilter(sourceTypes: sourceTypes, isCardPaymentAllowed: isCardPaymentAllowed) + } + + func setupPaymentMethodsAndFilter(sourceTypes: [SourceType], isCardPaymentAllowed: Bool) { + let filterSourceTypes = filter.sourceTypes + + let isCardEnabled = isCardPaymentAllowed && filter.isCardPaymentAllowed + let allowedPaymentMethods = sourceTypes.filter { [filterSourceTypes] sourceType in + if filterSourceTypes.isEmpty { + return true + } else { + return filterSourceTypes.contains(sourceType) + } } self.paymentMethods = PaymentMethod.createPaymentMethods( From 4da56b4b29772804893a9074c95d7917ab519f59 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Wed, 13 Mar 2024 00:05:35 +0700 Subject: [PATCH 162/204] Update ExampleApp function name to present Payment Methods list --- ExampleApp/Resources/Main.storyboard | 7 +++---- ExampleApp/Views/ProductDetailViewController.swift | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/ExampleApp/Resources/Main.storyboard b/ExampleApp/Resources/Main.storyboard index c14fb6e6..a2b8a170 100644 --- a/ExampleApp/Resources/Main.storyboard +++ b/ExampleApp/Resources/Main.storyboard @@ -2,7 +2,6 @@ - @@ -17,7 +16,7 @@ - + @@ -58,7 +57,7 @@ You can see the code in the ExampleApp targets. - + @@ -165,7 +166,7 @@ You can see the code in the ExampleApp targets. - + diff --git a/OmiseSDK/Sources/ClientProtocol.swift b/OmiseSDK/Sources/ClientProtocol.swift new file mode 100644 index 00000000..e1e87949 --- /dev/null +++ b/OmiseSDK/Sources/ClientProtocol.swift @@ -0,0 +1,33 @@ +import Foundation + +/// Network Client Protocol to communicate with Omise APIs +public protocol ClientProtocol { + typealias ResponseClosure = (Result) -> Void + + /// Latest capability loaded with `capability()` + var latestLoadedCapability: Capability? { get } + + /// Performs a Capability API Request + /// - parameter completion: Returns `Capability` object on success and `Error` on request failed + func capability(_ completion: @escaping ResponseClosure) + + /// Sends `Create a Source` API request with given Payment Payload + /// - parameter payload: Information required to perform Create a Source API request + /// - parameter completion: Returns `Source` object on success and `Error` on request failed + func createSource(payload: CreateSourcePayload, _ completion: @escaping ResponseClosure) + + /// Sends `Create a Token` API request with given Card Payment + /// - parameter payload: Information required to perform Create a Token API request + /// - parameter completion: Returns `Token`object on success and `Error` on request failed + func createToken(payload: CreateTokenPayload, _ completion: @escaping ResponseClosure) + + /// Requests a `Token` from API with given Token ID + /// - parameter tokenID: Token identifier + /// - parameter completion: Returns `Token`object on success and `Error` on request failed + func token(tokenID: String, _ completion: @escaping ResponseClosure) + + /// Observes `Token Charge Status` until it changes or max attempts is reached + /// - parameter tokenID: Token identifier + /// - parameter completion: Returns `Token.ChargeStatus`object with token charge status value on success and `Error` on request failed + func observeChargeStatus(tokenID: String, _ completion: @escaping ResponseClosure) +} diff --git a/OmiseSDK/Sources/OmiseAPI/Client.swift b/OmiseSDK/Sources/OmiseAPI/Client.swift index 3ae0a6b0..aaf107d4 100644 --- a/OmiseSDK/Sources/OmiseAPI/Client.swift +++ b/OmiseSDK/Sources/OmiseAPI/Client.swift @@ -2,9 +2,7 @@ import Foundation import os /// Network Client to communicate with Omise APIs -public class Client { - public typealias RequestResultClosure = (Result) -> Void - +class Client: ClientProtocol { let version: String let publicKey: String var customApiURL: URL? @@ -15,7 +13,7 @@ public class Client { private let pollingTimeInterval = 3 /// Latest capability loaded with `capability()` - public private(set) var latestLoadedCapability: Capability? + private(set) var latestLoadedCapability: Capability? /// Creates a new Client item with given public key /// @@ -40,9 +38,9 @@ public class Client { self.customVaultURL = vaultURL } - /// Perform Capability API Request - /// - returns Capability - public func capability(_ completion: @escaping RequestResultClosure) { + /// Performs a Capability API Request + /// - parameter completion: Returns `Capability` object on success and `Error` on request failed + func capability(_ completion: @escaping ResponseClosure) { performRequest(api: OmiseAPI.capability) { [weak self] (result: Result) in if let capability = try? result.get() { self?.latestLoadedCapability = capability @@ -51,40 +49,31 @@ public class Client { } } - /// Sends Create a Source API request with given Payment Payload - /// - /// - Parameters: - /// - payload: Information required to perform Create a Source API request - /// - completion: Returns `Source` object on success and `Error` on request failed - public func createSource(payload: CreateSourcePayload, _ completion: @escaping RequestResultClosure) { + /// Sends `Create a Source` API request with given Payment Payload + /// - parameter payload: Information required to perform Create a Source API request + /// - parameter completion: Returns `Source` object on success and `Error` on request failed + func createSource(payload: CreateSourcePayload, _ completion: @escaping ResponseClosure) { performRequest(api: OmiseAPI.createSource(payload: payload), completion: completion) } - /// Send Create a Token API request with given Card Payment - /// - /// - Parameters: - /// - payload: Information required to perform Create a Token API request - /// - completion: Returns `Token`object on success and `Error` on request failed - public func createToken(payload: CreateTokenPayload, _ completion: @escaping RequestResultClosure) { + /// Sends `Create a Token` API request with given Card Payment + /// - parameter payload: Information required to perform Create a Token API request + /// - parameter completion: Returns `Token`object on success and `Error` on request failed + func createToken(payload: CreateTokenPayload, _ completion: @escaping ResponseClosure) { performRequest(api: OmiseAPI.createToken(payload: payload), completion: completion) } - /// Request a Token from API with given Token ID - /// - /// - Parameters: - /// - tokenID: Token identifier - /// - completion: Returns `Token`object on success and `Error` on request failed - public func token(tokenID: String, _ completion: @escaping RequestResultClosure) { + /// Requests a `Token` from API with given Token ID + /// - parameter tokenID: Token identifier + /// - parameter completion: Returns `Token`object on success and `Error` on request failed + func token(tokenID: String, _ completion: @escaping ResponseClosure) { performRequest(api: OmiseAPI.token(tokenID: tokenID), completion: completion) } - /// Observe Token Charge Status until it changes - /// Sends API request every `timeInterval` with number of`maxAttempt`attempts. - /// - /// - Parameters: - /// - tokenID: Token identifier - /// - completion: Returns `Token.ChargeStatus`object with token charge status value on success and `Error` on request failed - public func observeChargeStatus(tokenID: String, _ completion: @escaping RequestResultClosure) { + /// Observes `Token Charge Status` until it changes or max attempts is reached + /// - parameter tokenID: Token identifier + /// - parameter completion: Returns `Token.ChargeStatus`object with token charge status value on success and `Error` on request failed + func observeChargeStatus(tokenID: String, _ completion: @escaping ResponseClosure) { observeUntilChargeStatusIsFinal( tokenID: tokenID, timeInterval: pollingTimeInterval, diff --git a/OmiseSDK/Sources/OmiseAPI/Helpers/Client+NetworkService.swift b/OmiseSDK/Sources/OmiseAPI/Helpers/Client+NetworkService.swift index 322f5060..13fc886a 100644 --- a/OmiseSDK/Sources/OmiseAPI/Helpers/Client+NetworkService.swift +++ b/OmiseSDK/Sources/OmiseAPI/Helpers/Client+NetworkService.swift @@ -3,7 +3,7 @@ import Foundation extension Client { /// Creates urlRequest and performs API request with currenly used Network Service /// - returns Generic Decodable from JSON string - func performRequest(api: APIProtocol, completion: @escaping RequestResultClosure) { + func performRequest(api: APIProtocol, completion: @escaping ResponseClosure) { let urlRequest = urlRequest(publicKey: publicKey, api: api) network.send( urlRequest: urlRequest, @@ -24,7 +24,7 @@ extension Client { timeInterval: Int, attemp: Int, maxAttempt: Int, - _ completion: @escaping RequestResultClosure + _ completion: @escaping ResponseClosure ) { guard maxAttempt > attemp else { return diff --git a/OmiseSDK/Sources/OmiseAPI/Helpers/NetworkService.swift b/OmiseSDK/Sources/OmiseAPI/Helpers/NetworkService.swift index 991b5bb5..e464fa7b 100644 --- a/OmiseSDK/Sources/OmiseAPI/Helpers/NetworkService.swift +++ b/OmiseSDK/Sources/OmiseAPI/Helpers/NetworkService.swift @@ -2,12 +2,12 @@ import Foundation import os protocol NetworkServiceProtocol { - typealias RequestResultClosure = (Result) -> Void + typealias ResponseClosure = (Result) -> Void func send( urlRequest: URLRequest, dateFormatter: DateFormatter?, - completion: @escaping RequestResultClosure + completion: @escaping ResponseClosure ) } @@ -29,7 +29,7 @@ extension NetworkService: NetworkServiceProtocol { func send( urlRequest: URLRequest, dateFormatter: DateFormatter?, - completion: @escaping RequestResultClosure + completion: @escaping ResponseClosure ) { let dataTask = session.dataTask(with: urlRequest) { [weak self] (data, response, error) in guard let self = self else { return } diff --git a/OmiseSDK/Sources/OmiseSDK.swift b/OmiseSDK/Sources/OmiseSDK.swift index e9cd119c..8ada65c3 100644 --- a/OmiseSDK/Sources/OmiseSDK.swift +++ b/OmiseSDK/Sources/OmiseSDK.swift @@ -32,7 +32,7 @@ public class OmiseSDK { public let publicKey: String /// Client is used to communicate with Omise API - public let client: Client + public let client: ClientProtocol /// Latest capability loaded with `client.capability()` var latestLoadedCapability: Capability? { client.latestLoadedCapability } diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator.swift index d26d371d..e86adf95 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator.swift @@ -1,7 +1,7 @@ import UIKit class ChoosePaymentCoordinator: NSObject, ViewAttachable { - let client: Client + let client: ClientProtocol let amount: Int64 let currency: String let currentCountry: Country? @@ -24,7 +24,7 @@ class ChoosePaymentCoordinator: NSObject, ViewAttachable { return noticeView }() - init(client: Client, amount: Int64, currency: String, currentCountry: Country?, handleErrors: Bool) { + init(client: ClientProtocol, amount: Int64, currency: String, currentCountry: Country?, handleErrors: Bool) { self.client = client self.amount = amount self.currency = currency diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/EContext/EContextPaymentFormController.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/EContext/EContextPaymentFormController.swift index 80915d25..944f1ddd 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/EContext/EContextPaymentFormController.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/EContext/EContextPaymentFormController.swift @@ -3,7 +3,7 @@ import UIKit class EContextPaymentFormController: UIViewController, PaymentFormUIController { weak var delegate: SelectSourcePaymentDelegate? - var client: Client? + var client: ClientProtocol? var paymentAmount: Int64? var paymentCurrency: Currency? diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/FPX/FPXPaymentFormController.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/FPX/FPXPaymentFormController.swift index ef3dae18..cf052514 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/FPX/FPXPaymentFormController.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/FPX/FPXPaymentFormController.swift @@ -12,7 +12,7 @@ class FPXPaymentFormController: UIViewController, PaymentFormUIController { var showingValues: [Capability.PaymentMethod.Bank]? private var emailValue: String? - private var client: Client? + private var client: ClientProtocol? private var isInputDataValid: Bool { return formFields.allSatisfy { $0.isValid } || isEmailInputEmpty diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.swift index c56934c3..d771e403 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.swift @@ -3,7 +3,7 @@ import UIKit class TrueMoneyPaymentFormController: UIViewController, PaymentFormUIController { weak var delegate: SelectSourcePaymentDelegate? - private var client: Client? + private var client: ClientProtocol? private var isInputDataValid: Bool { return formFields.allSatisfy { $0.isValid } diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentMethodViewModel.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentMethodViewModel.swift index dffe427e..d9d95020 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentMethodViewModel.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentMethodViewModel.swift @@ -8,7 +8,7 @@ class SelectPaymentMethodViewModel { let isForced: Bool } - private let client: Client + private let client: ClientProtocol private let filter: Filter private weak var delegate: SelectPaymentMethodDelegate? @@ -24,7 +24,7 @@ class SelectPaymentMethodViewModel { } } - init(client: Client, filter: Filter, delegate: SelectPaymentMethodDelegate) { + init(client: ClientProtocol, filter: Filter, delegate: SelectPaymentMethodDelegate) { self.client = client self.delegate = delegate self.filter = filter diff --git a/OmiseSDK/Sources/Views/Screens/_ to refactor and delete/PaymentCreatorController.swift b/OmiseSDK/Sources/Views/Screens/_ to refactor and delete/PaymentCreatorController.swift index c600818d..03f65c2e 100644 --- a/OmiseSDK/Sources/Views/Screens/_ to refactor and delete/PaymentCreatorController.swift +++ b/OmiseSDK/Sources/Views/Screens/_ to refactor and delete/PaymentCreatorController.swift @@ -55,7 +55,7 @@ public class PaymentCreatorController: UINavigationController { /// Defaults to `true`. public var handleErrors = true - var client: Client? { + var client: ClientProtocol? { didSet { paymentSourceCreatorFlowSession.client = client } diff --git a/OmiseSDK/Sources/Views/Screens/_ to refactor and delete/PaymentUI.swift b/OmiseSDK/Sources/Views/Screens/_ to refactor and delete/PaymentUI.swift index 9288bfec..0970590f 100644 --- a/OmiseSDK/Sources/Views/Screens/_ to refactor and delete/PaymentUI.swift +++ b/OmiseSDK/Sources/Views/Screens/_ to refactor and delete/PaymentUI.swift @@ -13,7 +13,7 @@ internal protocol PaymentCreatorFlowSessionDelegate: AnyObject { } internal class PaymentCreatorFlowSession { - var client: Client? + var client: ClientProtocol? var paymentAmount: Int64? var paymentCurrency: Currency? diff --git a/OmiseSDKTests/ClientTests.swift b/OmiseSDKTests/ClientTests.swift index a43e2c43..58a0a571 100644 --- a/OmiseSDKTests/ClientTests.swift +++ b/OmiseSDKTests/ClientTests.swift @@ -8,7 +8,7 @@ struct NetworkMockup: NetworkServiceProtocol { func send( urlRequest: URLRequest, dateFormatter: DateFormatter?, - completion: @escaping RequestResultClosure + completion: @escaping ResponseClosure ) { self.sendClosure(urlRequest) } diff --git a/OmiseSDKTests/OmiseSDKTests.swift b/OmiseSDKTests/OmiseSDKTests.swift index 0e68d80d..743ea729 100644 --- a/OmiseSDKTests/OmiseSDKTests.swift +++ b/OmiseSDKTests/OmiseSDKTests.swift @@ -6,8 +6,11 @@ class OmiseSDKTests: XCTestCase { func testCountry() { let expectedCountry = Country(name: "Thailand", code: "TH") let capability = Capability(countryCode: "TH", paymentMethods: [], banks: Set()) - OmiseSDK.shared.client.setLatestLoadedCapability(capability) - - XCTAssertEqual(expectedCountry, OmiseSDK.shared.country) + if let client = OmiseSDK.shared.client as? Client { + client.setLatestLoadedCapability(capability) + XCTAssertEqual(expectedCountry, OmiseSDK.shared.country) + } else { + XCTFail("Client has a wrong type") + } } } diff --git a/dev.xcodeproj/project.pbxproj b/dev.xcodeproj/project.pbxproj index 71212a7a..bb4bb418 100644 --- a/dev.xcodeproj/project.pbxproj +++ b/dev.xcodeproj/project.pbxproj @@ -80,6 +80,7 @@ 75405AA82A27F97E008C21F6 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 75405AA62A27F97E008C21F6 /* Localizable.strings */; }; 754B78182B8741CD00973B71 /* TapGestureHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 754B78172B8741CD00973B71 /* TapGestureHandler.swift */; }; 755CD9212BA1C81600E8FCDA /* UIViewController+KeyboardAppearance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 755CD9202BA1C81600E8FCDA /* UIViewController+KeyboardAppearance.swift */; }; + 755CD9232BA2000600E8FCDA /* ClientProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 755CD9222BA2000600E8FCDA /* ClientProtocol.swift */; }; 756C8F1E2A40693B00D53059 /* CreditCardPaymentViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 756C8F1D2A40693B00D53059 /* CreditCardPaymentViewModelProtocol.swift */; }; 756C8F202A40694000D53059 /* CreditCardPaymentViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 756C8F1F2A40694000D53059 /* CreditCardPaymentViewModel.swift */; }; 756C8F222A40694F00D53059 /* CreditCardPaymentViewContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 756C8F212A40694F00D53059 /* CreditCardPaymentViewContext.swift */; }; @@ -325,6 +326,7 @@ 75405AAA2A27F988008C21F6 /* th */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = th; path = th.lproj/Localizable.strings; sourceTree = ""; }; 754B78172B8741CD00973B71 /* TapGestureHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TapGestureHandler.swift; sourceTree = ""; }; 755CD9202BA1C81600E8FCDA /* UIViewController+KeyboardAppearance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+KeyboardAppearance.swift"; sourceTree = ""; }; + 755CD9222BA2000600E8FCDA /* ClientProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientProtocol.swift; sourceTree = ""; }; 756C8F1D2A40693B00D53059 /* CreditCardPaymentViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreditCardPaymentViewModelProtocol.swift; sourceTree = ""; }; 756C8F1F2A40694000D53059 /* CreditCardPaymentViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreditCardPaymentViewModel.swift; sourceTree = ""; }; 756C8F212A40694F00D53059 /* CreditCardPaymentViewContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreditCardPaymentViewContext.swift; sourceTree = ""; }; @@ -964,6 +966,7 @@ 75E0EBBF2B7D13D200E3198A /* OmiseAPI */, 75D13DEE2B866BCA0073A831 /* Views */, 75CFC4D12B73AFD500422A8F /* OmiseSDK.swift */, + 755CD9222BA2000600E8FCDA /* ClientProtocol.swift */, ); path = Sources; sourceTree = ""; @@ -1430,6 +1433,7 @@ 75D13DE42B8666CC0073A831 /* SelectSourceTypeDelegate.swift in Sources */, 75CFC4DD2B73F75C00422A8F /* OmiseAPI.swift in Sources */, 75348D4E29C3FCC70008C8A3 /* Bundle+OmiseSDK.swift in Sources */, + 755CD9232BA2000600E8FCDA /* ClientProtocol.swift in Sources */, 75E0EB9D2B7BD00F00E3198A /* CardBrand.swift in Sources */, 75E0EB9A2B7BD00F00E3198A /* Currency.swift in Sources */, 75405A9C2A266F50008C21F6 /* AtomePaymentFormViewModel.swift in Sources */, From 4c784fa69bc77e7982562a9d302e7b294d592c3a Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Wed, 13 Mar 2024 23:07:45 +0700 Subject: [PATCH 182/204] Replace Client with ClientProtocol in Readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ee4fa921..2f6e587c 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ To integrate the Opn Payments SDK into your Xcode project using the [Swift Packa The Opn Payments iOS SDK provides an easy-to-use library for calling the Opn Payments API and presenting UI forms. -The main classes for the Opn Payments iOS SDK are `OmiseSDK` and `Client` through +The main class and protocol for the Opn Payments iOS SDK are `OmiseSDK` and `ClientProtocol` through which all requests to the Opn Payments API will be sent. To start working with OmiseSDK, you must create a new instance of the `OmiseSDK` class with an Opn Payments public key. @@ -158,7 +158,7 @@ Now, send the request: #### Sending the request Whether you are charging a source or a card, sending the -request is the same. Use the `Client` object to perform one-off API calls +request is the same. Use the `ClientProtocol` to perform one-off API calls with the completion handler block. ```swift From a1187a6fb34803490e52b60ff65eb6a36d052834 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Thu, 14 Mar 2024 17:18:14 +0700 Subject: [PATCH 183/204] add translations and sort SourceType for better code reading --- .../Resources/en.lproj/Localizable.strings | 51 ++--- .../Resources/ja.lproj/Localizable.strings | 61 ++---- .../Resources/th.lproj/Localizable.strings | 62 ++---- .../SelectPaymentMethodViewModel.swift | 2 +- .../SourceType+ViewPresentable.swift | 184 +++++++++--------- 5 files changed, 138 insertions(+), 222 deletions(-) diff --git a/OmiseSDK/Resources/en.lproj/Localizable.strings b/OmiseSDK/Resources/en.lproj/Localizable.strings index 940723f2..1455a477 100644 --- a/OmiseSDK/Resources/en.lproj/Localizable.strings +++ b/OmiseSDK/Resources/en.lproj/Localizable.strings @@ -1,4 +1,5 @@ // Payment Methods +"PaymentMethods.title" = "Payment Methods"; "PaymentMethod.creditCard" = "Credit Card"; "PaymentMethod.installments" = "Installments"; "PaymentMethod.internetBanking" = "Internet Banking"; @@ -7,21 +8,23 @@ "PaymentMethod.eContext.payEasy" = "Pay-easy"; "PaymentMethod.eContext.netBanking" = "Net Bank"; -"SourceType.paynow" = "PayNow"; -"SourceType.truemoney" = "TrueMoney Wallet"; -"SourceType.promptpay" = "PromptPay"; "SourceType.alipay" = "Alipay"; -"SourceType.points_citi" = "Pay with Citi Rewards Points"; "SourceType.bill_payment_tesco_lotus" = "Lotus's Bill Payment"; -"SourceType." = ""; -"SourceType." = ""; -"SourceType." = ""; -"SourceType." = ""; -"SourceType." = ""; -"SourceType." = ""; -"SourceType." = ""; -"SourceType." = ""; - +"SourceType.installment_bay" = "Krungsri"; +"SourceType.installment_bbl" = "Bangkok Bank"; +"SourceType.installment_first_choice" = "Krungsri First Choice"; +"SourceType.installment_kbank" = "Kasikorn Bank"; +"SourceType.installment_ktc" = "KTC"; +"SourceType.installment_scb" = "Siam Commercial Bank"; +"SourceType.installment_ttb" = "TMBThanachart Bank"; +"SourceType.installment_uob" = "United Overseas Bank"; +"SourceType.internet_banking_bay" = "Bank of Ayudhya"; +"SourceType.internet_banking_bbl" = "Bangkok Bank"; +"SourceType.paynow" = "PayNow"; +"SourceType.points_citi" = "Pay with Citi Rewards Points"; +"SourceType.promptpay" = "PromptPay"; +"SourceType.truemoney" = "TrueMoney Wallet"; +"SourceType.truemoney_jumpapp" = "TrueMoney"; // Authorizing Payment "AuthorizingPayment.title" = "Authorizing Payment"; @@ -60,29 +63,7 @@ "Atome.field.street1.error" = "Shipping street is required"; "Atome.field.optional" = "(optional)"; -"installments.number-of-terms-chooser.number-of-terms-cell.label.text" = "%d months"; - -"econtext.convenience-store.navigation-item.title" = "Konbini"; -"econtext.netbanking.navigation-item.title" = "Net Bank"; -"econtext.pay-easy.navigation-item.title" = "Pay-easy"; - -"installment-number-of-terms-choosers.bay.navigation-item.title" = "Bangkok Bank"; - -"installment-number-of-terms-choosers.first-choice.navigation-item.title" = "Kasikorn"; -"installment-number-of-terms-choosers.bbl.navigation-item.title" = "Krungsri"; -"installment-number-of-terms-choosers.ktc.navigation-item.title" = "Krungsri First Choice"; -"installment-number-of-terms-choosers.k-bank.navigation-item.title" = "KTC"; -"installment-number-of-terms-choosers.mbb.navigation-item.title" = "MayBank"; -"installment-number-of-terms-choosers.scb.navigation-item.title" = "Siam Commercial Bank"; -"installment-number-of-terms-choosers.ttb.navigation-item.title" = "TMBThanachart Bank"; -"installment-number-of-terms-choosers.uob.navigation-item.title" = "United Overseas Bank"; - -/* A navigation title for the choosing installment terms screen with the `Installments Terms` selected */ -"installment-number-of-terms-choosers.default.navigation-item.title" = "Installment terms"; - "more-info.cvv-location.amex.text" = "4 digit number on the front of your card"; "more-info.cvv-location.default.text" = "3 digit number on the back of your card"; "fpx.bank-chooser.no-banks-available.text" = "Cannot retrieve list of banks.\nPlease try again later."; - -"paymentMethods.title" = "Payment Methods"; diff --git a/OmiseSDK/Resources/ja.lproj/Localizable.strings b/OmiseSDK/Resources/ja.lproj/Localizable.strings index c1d5950a..b34f6809 100644 --- a/OmiseSDK/Resources/ja.lproj/Localizable.strings +++ b/OmiseSDK/Resources/ja.lproj/Localizable.strings @@ -1,4 +1,5 @@ // Payment Methods +"PaymentMethods.title" = "決済方法"; "PaymentMethod.creditCard" = "クレジットカード"; "PaymentMethod.installments" = "分割払い"; "PaymentMethod.internetBanking" = "インターネットバンク"; @@ -7,12 +8,23 @@ "PaymentMethod.eContext.payEasy" = "ペイジー"; "PaymentMethod.eContext.netBanking" = "ネットバンク"; -"SourceType.paynow" = "PayNow"; -"SourceType.truemoney" = "TrueMoneyウォレット"; -"SourceType.promptpay" = "プロンプトペイ"; "SourceType.alipay" = "アリペイ"; -"SourceType.points_citi" = "Citi Rewardsポイント"; "SourceType.bill_payment_tesco_lotus" = "ロータス"; +"SourceType.installment_bay" = "クルンシィ"; +"SourceType.installment_bbl" = "バンコク銀行"; +"SourceType.installment_first_choice" = "クルンシィ・ファーストチョイス"; +"SourceType.installment_kbank" = "カシコン銀行"; +"SourceType.installment_ktc" = "クルンタイカード"; +"SourceType.installment_scb" = "サイアム・コマーシャル銀行"; +"SourceType.installment_ttb" = "TMBタナチャート銀行"; +"SourceType.installment_uob" = "ユナイテッド・オーバーシーズ銀行"; +"SourceType.internet_banking_bay" = "アユタヤ銀行"; +"SourceType.internet_banking_bbl" = "バンコク銀行"; +"SourceType.paynow" = "PayNow"; +"SourceType.points_citi" = "Citi Rewardsポイント"; +"SourceType.promptpay" = "プロンプトペイ"; +"SourceType.truemoney" = "TrueMoneyウォレット"; +"SourceType.truemoney_jumpapp" = "TrueMoney"; // Authorizing Payment "AuthorizingPayment.title" = "決済の認可"; @@ -51,46 +63,5 @@ "Atome.field.street1.error" = "配送先の通り名が必要です"; "Atome.field.optional" = "(任意)"; -/* A navigaiton title for the EContext screen when the `Konbini` is selected */ -"econtext.convenience-store.navigation-item.title" = "コンビニ"; - -/* A navigaiton title for the EContext screen when the `Net Bank` is selected */ -"econtext.netbanking.navigation-item.title" = "ネットバンク"; - -/* A navigaiton title for the EContext screen when the `Pay-easy` is selected */ -"econtext.pay-easy.navigation-item.title" = "ペイジー"; - -/* A navigation title for the choosing installment terms screen with the `Bangkok Bank` selected */ -"installment-number-of-terms-choosers.bay.navigation-item.title" = "バンコク銀行"; - -/* A navigation title for the choosing installment terms screen with the `Krungsri` selected */ -"installment-number-of-terms-choosers.bbl.navigation-item.title" = "クルンシィ"; - -/* A navigation title for the choosing installment terms screen with the `Installments Terms` selected */ -"installment-number-of-terms-choosers.default.navigation-item.title" = "分割払い条件"; - -/* A navigation title for the choosing installment terms screen with the `Kasikorn` selected */ -"installment-number-of-terms-choosers.first-choice.navigation-item.title" = "カシコン"; - -/* A navigation title for the choosing installment terms screen with the `KTC` selected */ -"installment-number-of-terms-choosers.k-bank.navigation-item.title" = "クルンタイカード"; - -/* A navigation title for the choosing installment terms screen with the `Krungsri First Choice` selected */ -"installment-number-of-terms-choosers.ktc.navigation-item.title" = "クルンシィ・ファーストチョイス"; - -/* A navigation title for the choosing installment terms screen with the `Siam Commercial Bank` selected */ -"installment-number-of-terms-choosers.scb.navigation-item.title" = "サイアム・コマーシャル銀行"; - -/* Number of terms option text displayed as a title of the number of terms option cell in number of terms chooser scene */ -"installments.number-of-terms-chooser.number-of-terms-cell.label.text" = "%d 月々"; - -/* A navigation title for the choosing installment terms screen with the `TTB Bank` selected */ -"installment-number-of-terms-choosers.ttb.navigation-item.title" = "TMBタナチャート銀行"; - -/* A navigation title for the choosing installment terms screen with the `UOB Bank` selected */ -"installment-number-of-terms-choosers.uob.navigation-item.title" = "ユナイテッド・オーバーシーズ銀行"; - "more-info.cvv-location.amex.text" = "カード表面の4桁の番号"; "more-info.cvv-location.default.text" = "カード裏面の3桁の番号"; - -"paymentMethods.title" = "決済方法"; diff --git a/OmiseSDK/Resources/th.lproj/Localizable.strings b/OmiseSDK/Resources/th.lproj/Localizable.strings index e3f6ea67..afda53e6 100644 --- a/OmiseSDK/Resources/th.lproj/Localizable.strings +++ b/OmiseSDK/Resources/th.lproj/Localizable.strings @@ -1,4 +1,5 @@ // Payment Methods +"PaymentMethods.title" = "ช่องทางชำระเงิน"; "PaymentMethod.creditCard" = "บัตรเครดิต"; "PaymentMethod.installments" = "ผ่อนชำระ"; "PaymentMethod.internetBanking" = "อินเทอร์เน็ตแบงก์กิ้ง"; @@ -7,12 +8,23 @@ "PaymentMethod.eContext.payEasy" = "เพย์อีซี"; "PaymentMethod.eContext.netBanking" = "เน็ตแบงก์"; -"SourceType.paynow" = "เพย์นาว"; -"SourceType.truemoney" = "ทรูมันนี่วอลเล็ท"; -"SourceType.promptpay" = "พร้อมเพย์"; "SourceType.alipay" = "อาลีเพย์"; -"SourceType.points_citi" = "ชำระด้วยคะแนนซิตี้รีวอร์ด"; "SourceType.bill_payment_tesco_lotus" = "โลตัสบิลเพย์เมนต์"; +"SourceType.installment_bay" = "ธนาคารกรุงศรี"; +"SourceType.installment_bbl" = "ธนาคารกรุงเทพ"; +"SourceType.installment_first_choice" = "กรุงศรีเฟิร์สช้อยส์"; +"SourceType.installment_kbank" = "ธนาคารกสิกรไทย"; +"SourceType.installment_ktc" = "เคทีซี"; +"SourceType.installment_scb" = "ธนาคารไทยพาณิชย์"; +"SourceType.installment_ttb" = "ธนาคารทีเอ็มบีธนชาต"; +"SourceType.installment_uob" = "ธนาคารยูโอบี"; +"SourceType.internet_banking_bay" = "ธนาคารกรุงศรีอยุธยา"; +"SourceType.internet_banking_bbl" = "ธนาคารกรุงเทพ"; +"SourceType.paynow" = "เพย์นาว"; +"SourceType.points_citi" = "ชำระด้วยคะแนนซิตี้รีวอร์ด"; +"SourceType.promptpay" = "พร้อมเพย์"; +"SourceType.truemoney" = "ทรูมันนี่วอลเล็ท"; +"SourceType.truemoney_jumpapp" = "ทรูมันนี่"; // Authorizing Payment "AuthorizingPayment.title" = "กำลังอนุมัติวงเงิน"; @@ -51,47 +63,5 @@ "Atome.field.street1.error" = "จำเป็นต้องใส่ชื่อถนนสำหรับจัดส่งสินค้า"; "Atome.field.optional" = "(ถ้ามี)"; -/* A navigaiton title for the EContext screen when the `Konbini` is selected */ -"econtext.convenience-store.navigation-item.title" = "ร้านสะดวกซื้อ"; - -/* A navigaiton title for the EContext screen when the `Net Bank` is selected */ -"econtext.netbanking.navigation-item.title" = "เน็ตแบงก์"; - -/* A navigaiton title for the EContext screen when the `Pay-easy` is selected */ -"econtext.pay-easy.navigation-item.title" = "เพย์อีซี"; - -/* A navigation title for the choosing installment terms screen with the `Bangkok Bank` selected */ -"installment-number-of-terms-choosers.bay.navigation-item.title" = "ธนาคารกรุงเทพ"; - -/* A navigation title for the choosing installment terms screen with the `Krungsri` selected */ -"installment-number-of-terms-choosers.bbl.navigation-item.title" = "ธนาคารกรุงศรี"; - -/* A navigation title for the choosing installment terms screen with the `Installments Terms` selected */ -"installment-number-of-terms-choosers.default.navigation-item.title" = "ระยะเวลาผ่อนชำระ"; - -/* A navigation title for the choosing installment terms screen with the `Kasikorn` selected */ -"installment-number-of-terms-choosers.first-choice.navigation-item.title" = "ธนาคารกสิกรไทย"; - -/* A navigation title for the choosing installment terms screen with the `KTC` selected */ -"installment-number-of-terms-choosers.k-bank.navigation-item.title" = "เคทีซี"; - -/* A navigation title for the choosing installment terms screen with the `Krungsri First Choice` selected */ -"installment-number-of-terms-choosers.ktc.navigation-item.title" = "กรุงศรีเฟิร์สช้อยส์"; - -/* A navigation title for the choosing installment terms screen with the `Siam Commercial Bank` selected */ -"installment-number-of-terms-choosers.scb.navigation-item.title" = "ธนาคารไทยพาณิชย์"; - -/* A navigation title for the choosing installment terms screen with the `TTB Bank` selected */ -"installment-number-of-terms-choosers.ttb.navigation-item.title" = "ธนาคารทีเอ็มบีธนชาต"; - -/* A navigation title for the choosing installment terms screen with the `UOB Bank` selected */ -"installment-number-of-terms-choosers.uob.navigation-item.title" = "ธนาคารยูโอบี"; - -/* Number of terms option text displayed as a title of the number of terms option cell in number of terms chooser scene */ -"installments.number-of-terms-chooser.number-of-terms-cell.label.text" = "%d เดือน"; - - "more-info.cvv-location.amex.text" = "หมายเลข 4 หลักบนหน้าบัตร"; "more-info.cvv-location.default.text" = "หมายเลข 3 หลักด้านหลังบัตร"; - -"paymentMethods.title" = "ช่องทางชำระเงิน"; diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentMethodViewModel.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentMethodViewModel.swift index dffe427e..ecef8eab 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentMethodViewModel.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentMethodViewModel.swift @@ -83,7 +83,7 @@ extension SelectPaymentMethodViewModel: SelectPaymentPresentableProtocol { } var viewNavigationTitle: String { - localized("paymentMethods.title", text: "Payment Methods") + localized("PaymentMethods.title", text: "Payment Methods") } var viewDisplayLargeTitle: Bool { diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/SourceType+ViewPresentable.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/SourceType+ViewPresentable.swift index 9fee03d4..8a4d405a 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/SourceType+ViewPresentable.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/SourceType+ViewPresentable.swift @@ -6,7 +6,7 @@ extension SourceType: CustomStringConvertible { extension SourceType: ViewPresentable { public var localizedTitle: String { - localized("SourceType.\(self.rawValue)", text: title) + localized("SourceType.\(self.rawValue).title", text: title) } public var localizedSubtitle: String? { @@ -16,10 +16,6 @@ extension SourceType: ViewPresentable { public var title: String { switch self { - case .billPaymentTescoLotus: - return "Tesco Lotus" - case .eContext: - return "" // Doesn't have specific title case .alipay: return "Alipay" case .alipayCN: @@ -28,55 +24,28 @@ extension SourceType: ViewPresentable { return "Alipay HK" case .atome: return "Atome" + case .barcodeAlipay: + return "Alipay In-Store" + case .billPaymentTescoLotus: + return "Tesco Lotus" + case .boost: + return "Boost" case .dana: return "DANA" - case .gcash: - return "GCash" - case .kakaoPay: - return "Kakao Pay" - case .touchNGoAlipayPlus: - return "TNG eWallet" - case .promptPay: - return "PromptPay" - case .payNow: - return "PayNow" - case .trueMoneyWallet: - return "TrueMoney Wallet" - case .trueMoneyJumpApp: - return "TrueMoney" - case .pointsCiti: - return "Pay with Citi Rewards Points" + case .duitNowOBW: + return "DuitNow Online Banking/Wallets" + case .duitNowQR: + return "DuitNow QR" + case .eContext: + return "" // Doesn't have specific title case .fpx: return "FPX" - case .rabbitLinepay: - return "Rabbit LINE Pay" - case .ocbcDigital: - return "OCBC Digital" + case .gcash: + return "GCash" case .grabPay: return "Grab" - case .boost: - return "Boost" - case .shopeePay: - return "ShopeePay" - case .shopeePayJumpApp: - return "ShopeePay" - case .maybankQRPay: - return "Maybank QRPay" - case .duitNowQR: - return "DuitNow QR" - case .duitNowOBW: - return "DuitNow Online Banking/Wallets" - case .touchNGo: - return "Touch 'n Go" case .grabPayRms: return "GrabPay" - case .payPay: - return "PayPay" - case .weChat: - return "WeChat Pay" - case .barcodeAlipay: - return "Alipay In-Store" - case .installmentBAY: return "Krungsri" case .installmentBBL: @@ -95,12 +64,14 @@ extension SourceType: ViewPresentable { return "TMBThanachart Bank" case .installmentUOB: return "United Overseas Bank" - case .internetBankingBAY: return "Bank of Ayudhya" case .internetBankingBBL: return "Bangkok Bank" - + case .kakaoPay: + return "Kakao Pay" + case .maybankQRPay: + return "Maybank QRPay" case .mobileBankingBAY: return "KMA" case .mobileBankingBBL: @@ -111,15 +82,37 @@ extension SourceType: ViewPresentable { return "Krungthai Next" case .mobileBankingSCB: return "SCB EASY" + case .ocbcDigital: + return "OCBC Digital" + case .payNow: + return "PayNow" + case .payPay: + return "PayPay" + case .pointsCiti: + return "Pay with Citi Rewards Points" + case .promptPay: + return "PromptPay" + case .rabbitLinepay: + return "Rabbit LINE Pay" + case .shopeePay: + return "ShopeePay" + case .shopeePayJumpApp: + return "ShopeePay" + case .touchNGo: + return "Touch 'n Go" + case .touchNGoAlipayPlus: + return "TNG eWallet" + case .trueMoneyWallet: + return "TrueMoney Wallet" + case .trueMoneyJumpApp: + return "TrueMoney" + case .weChat: + return "WeChat Pay" } } public var iconName: String { switch self { - case .billPaymentTescoLotus: - return "Tesco" - case .eContext: - return "" // Doesn't have specific icon case .alipay: return "Alipay" case .alipayCN: @@ -128,55 +121,28 @@ extension SourceType: ViewPresentable { return "AlipayHK" case .atome: return "Atome" + case .barcodeAlipay: + return "Alipay" + case .billPaymentTescoLotus: + return "Tesco" + case .boost: + return "Boost" case .dana: return "dana" - case .gcash: - return "gcash" - case .kakaoPay: - return "kakaopay" - case .touchNGoAlipayPlus: - return "touch-n-go" - case .promptPay: - return "PromptPay" - case .payNow: - return "PayNow" - case .trueMoneyWallet: - return "TrueMoney" - case .trueMoneyJumpApp: - return "TrueMoney" - case .pointsCiti: - return "CitiBank" + case .duitNowOBW: + return "Duitnow-OBW" + case .duitNowQR: + return "DuitNow-QR" + case .eContext: + return "" // Doesn't have specific icon case .fpx: return "FPX" - case .rabbitLinepay: - return "RabbitLinePay" - case .ocbcDigital: - return "ocbc-digital" + case .gcash: + return "gcash" case .grabPay: return "Grab" - case .boost: - return "Boost" - case .shopeePay: - return "Shopeepay" - case .shopeePayJumpApp: - return "Shopeepay" - case .maybankQRPay: - return "MAE-maybank" - case .duitNowQR: - return "DuitNow-QR" - case .duitNowOBW: - return "Duitnow-OBW" - case .touchNGo: - return "touch-n-go" case .grabPayRms: return "Grab" - case .payPay: - return "PayPay" - case .weChat: - return "wechat_pay" - case .barcodeAlipay: - return "Alipay" - case .installmentBAY: return "BAY" case .installmentBBL: @@ -195,12 +161,14 @@ extension SourceType: ViewPresentable { return "ttb" case .installmentUOB: return "uob" - case .internetBankingBAY: return "BAY" case .internetBankingBBL: return "BBL" - + case .kakaoPay: + return "kakaopay" + case .maybankQRPay: + return "MAE-maybank" case .mobileBankingBAY: return "KMA" case .mobileBankingBBL: @@ -211,6 +179,32 @@ extension SourceType: ViewPresentable { return "KTB Next" case .mobileBankingSCB: return "SCB" + case .ocbcDigital: + return "ocbc-digital" + case .payNow: + return "PayNow" + case .payPay: + return "PayPay" + case .pointsCiti: + return "CitiBank" + case .promptPay: + return "PromptPay" + case .rabbitLinepay: + return "RabbitLinePay" + case .shopeePay: + return "Shopeepay" + case .shopeePayJumpApp: + return "Shopeepay" + case .touchNGo: + return "touch-n-go" + case .touchNGoAlipayPlus: + return "touch-n-go" + case .trueMoneyWallet: + return "TrueMoney" + case .trueMoneyJumpApp: + return "TrueMoney" + case .weChat: + return "wechat_pay" } } From 9b8475bf660e7af79f186c686b384a703f4310f7 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Thu, 14 Mar 2024 18:04:22 +0700 Subject: [PATCH 184/204] Fix localization identifier for SourceType --- ExampleApp.xcodeproj/project.pbxproj | 2 +- .../project.xcworkspace/xcshareddata/swiftpm/Package.resolved | 4 ++-- .../Select Payment From Lists/SelectPaymentController.swift | 2 +- .../ViewPresentable/SourceType+ViewPresentable.swift | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ExampleApp.xcodeproj/project.pbxproj b/ExampleApp.xcodeproj/project.pbxproj index 54ea45b1..1b4909a1 100644 --- a/ExampleApp.xcodeproj/project.pbxproj +++ b/ExampleApp.xcodeproj/project.pbxproj @@ -453,7 +453,7 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/omise/omise-ios.git"; requirement = { - branch = feature/v5_refactoring; + branch = "feature/MIT-2316-Translations"; kind = branch; }; }; diff --git a/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 6c46f6bd..c8d07126 100644 --- a/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/omise/omise-ios.git", "state" : { - "branch" : "feature/v5_refactoring", - "revision" : "a2b256dc8fb9b2a7deca380b2ae8441342ec29d8" + "branch" : "feature/MIT-2316-Translations", + "revision" : "a1187a6fb34803490e52b60ff65eb6a36d052834" } } ], diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentController.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentController.swift index 7ae956cb..861be496 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentController.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentController.swift @@ -100,7 +100,7 @@ private extension SelectPaymentController { func setupTableView() { tableView.separatorColor = UIColor.omiseSecondary tableView.rowHeight = 64 - tableView.backgroundColor = .white + tableView.backgroundColor = .background } func setupNavigationItems() { diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/SourceType+ViewPresentable.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/SourceType+ViewPresentable.swift index 8a4d405a..9e7924f2 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/SourceType+ViewPresentable.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/SourceType+ViewPresentable.swift @@ -6,7 +6,7 @@ extension SourceType: CustomStringConvertible { extension SourceType: ViewPresentable { public var localizedTitle: String { - localized("SourceType.\(self.rawValue).title", text: title) + localized("SourceType.\(self.rawValue)", text: title) } public var localizedSubtitle: String? { From 987171818f6b6669e9859c1fba306be20704e05c Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Thu, 14 Mar 2024 18:24:00 +0700 Subject: [PATCH 185/204] Fix PaymentMethods and Atome submit button background colors --- .../xcshareddata/swiftpm/Package.resolved | 2 +- .../AtomePaymentFormController.swift | 2 +- .../AtomePaymentFormViewContext.swift | 0 .../AtomePaymentFormViewModel.swift | 0 .../AtomePaymentFormViewModelProtocol.swift | 0 .../Base/PaymentFormController.swift | 9 +++++---- .../{Atome Payment => Atome}/Base/PaymentFormStyle.swift | 0 .../Base/To Be Implemented/PaymentInputProtocol.swift | 0 .../To Be Implemented/PaymentInputsFormController.swift | 0 .../SelectPaymentController.swift | 2 +- dev.xcodeproj/project.pbxproj | 6 +++--- 11 files changed, 11 insertions(+), 10 deletions(-) rename OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/{Atome Payment => Atome}/AtomePaymentFormController.swift (99%) rename OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/{Atome Payment => Atome}/AtomePaymentFormViewContext.swift (100%) rename OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/{Atome Payment => Atome}/AtomePaymentFormViewModel.swift (100%) rename OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/{Atome Payment => Atome}/AtomePaymentFormViewModelProtocol.swift (100%) rename OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/{Atome Payment => Atome}/Base/PaymentFormController.swift (94%) rename OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/{Atome Payment => Atome}/Base/PaymentFormStyle.swift (100%) rename OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/{Atome Payment => Atome}/Base/To Be Implemented/PaymentInputProtocol.swift (100%) rename OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/{Atome Payment => Atome}/Base/To Be Implemented/PaymentInputsFormController.swift (100%) diff --git a/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 6c46f6bd..c3c67270 100644 --- a/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -6,7 +6,7 @@ "location" : "https://github.com/omise/omise-ios.git", "state" : { "branch" : "feature/v5_refactoring", - "revision" : "a2b256dc8fb9b2a7deca380b2ae8441342ec29d8" + "revision" : "4c784fa69bc77e7982562a9d302e7b294d592c3a" } } ], diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/AtomePaymentFormController.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome/AtomePaymentFormController.swift similarity index 99% rename from OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/AtomePaymentFormController.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome/AtomePaymentFormController.swift index 24c2c402..a5c50bce 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/AtomePaymentFormController.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome/AtomePaymentFormController.swift @@ -66,7 +66,7 @@ private extension AtomePaymentInputsFormController { func bind(to viewModel: ViewModel) { guard isViewLoaded else { return } setupInputs(viewModel: viewModel) - setupSubmitButton(title: viewModel.submitButtonTitle, color: style.buttonTextColor) + setupSubmitButton(title: viewModel.submitButtonTitle) details = viewModel.headerText logoImage = UIImage(omise: viewModel.logoName) diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/AtomePaymentFormViewContext.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome/AtomePaymentFormViewContext.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/AtomePaymentFormViewContext.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome/AtomePaymentFormViewContext.swift diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/AtomePaymentFormViewModel.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome/AtomePaymentFormViewModel.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/AtomePaymentFormViewModel.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome/AtomePaymentFormViewModel.swift diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/AtomePaymentFormViewModelProtocol.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome/AtomePaymentFormViewModelProtocol.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/AtomePaymentFormViewModelProtocol.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome/AtomePaymentFormViewModelProtocol.swift diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/Base/PaymentFormController.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome/Base/PaymentFormController.swift similarity index 94% rename from OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/Base/PaymentFormController.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome/Base/PaymentFormController.swift index e0343a64..c05f63a0 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/Base/PaymentFormController.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome/Base/PaymentFormController.swift @@ -39,8 +39,9 @@ class PaymentFormController: UIViewController { button.heightAnchor.constraint(equalToConstant: style.buttonHeight).isActive = true button.titleLabel?.adjustsFontForContentSizeCategory = true - button.defaultBackgroundColor = style.buttonBackgroundColor - button.disabledBackgroundColor = style.buttonDisabledBackgroundColor + button.defaultBackgroundColor = .omise + button.disabledBackgroundColor = .line + button.cornerRadius(style.buttonCornerRadius) return button }() @@ -122,9 +123,9 @@ extension PaymentFormController { verticalContainerStack.addArrangedSubview(submitButton) } - func setupSubmitButton(title: String, color: UIColor? = nil) { + func setupSubmitButton(title: String, textColor: UIColor? = nil) { submitButton.setTitle(title, for: UIControl.State.normal) - submitButton.setTitleColor(color ?? style.buttonTextColor, for: .normal) + submitButton.setTitleColor(textColor ?? style.buttonTextColor, for: .normal) submitButton.addTarget(self, action: #selector(onSubmitButtonTapped), for: .touchUpInside) } diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/Base/PaymentFormStyle.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome/Base/PaymentFormStyle.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/Base/PaymentFormStyle.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome/Base/PaymentFormStyle.swift diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/Base/To Be Implemented/PaymentInputProtocol.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome/Base/To Be Implemented/PaymentInputProtocol.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/Base/To Be Implemented/PaymentInputProtocol.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome/Base/To Be Implemented/PaymentInputProtocol.swift diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/Base/To Be Implemented/PaymentInputsFormController.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome/Base/To Be Implemented/PaymentInputsFormController.swift similarity index 100% rename from OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome Payment/Base/To Be Implemented/PaymentInputsFormController.swift rename to OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/Atome/Base/To Be Implemented/PaymentInputsFormController.swift diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentController.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentController.swift index 7ae956cb..861be496 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentController.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentController.swift @@ -100,7 +100,7 @@ private extension SelectPaymentController { func setupTableView() { tableView.separatorColor = UIColor.omiseSecondary tableView.rowHeight = 64 - tableView.backgroundColor = .white + tableView.backgroundColor = .background } func setupNavigationItems() { diff --git a/dev.xcodeproj/project.pbxproj b/dev.xcodeproj/project.pbxproj index bb4bb418..7634500a 100644 --- a/dev.xcodeproj/project.pbxproj +++ b/dev.xcodeproj/project.pbxproj @@ -562,7 +562,7 @@ 750126682B89F0C200ED5E14 /* EContext */, 750126672B89F0B200ED5E14 /* TrueMoneyWallet */, 750126662B89F0AD00ED5E14 /* FPX */, - 75D13DF82B866CA90073A831 /* Atome Payment */, + 75D13DF82B866CA90073A831 /* Atome */, ); path = "Other Payments"; sourceTree = ""; @@ -862,7 +862,7 @@ path = "Select Payment From Lists"; sourceTree = ""; }; - 75D13DF82B866CA90073A831 /* Atome Payment */ = { + 75D13DF82B866CA90073A831 /* Atome */ = { isa = PBXGroup; children = ( 7501265B2B87CB3F00ED5E14 /* Base */, @@ -871,7 +871,7 @@ 75F2A0B32A1A5EAD0038FA54 /* AtomePaymentFormViewModelProtocol.swift */, 75405A9B2A266F50008C21F6 /* AtomePaymentFormViewModel.swift */, ); - path = "Atome Payment"; + path = Atome; sourceTree = ""; }; 75D13DFA2B866CF40073A831 /* Authorizing Payment */ = { From 1ac049b922d0f5b7366a4d5ad3fc8d39bdc99e26 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Thu, 14 Mar 2024 18:30:49 +0700 Subject: [PATCH 186/204] Add warning for debug code --- .../project.xcworkspace/xcshareddata/swiftpm/Package.resolved | 2 +- .../Sources/OmiseAPI/SourceType/SourceType+Collections.swift | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index c8d07126..3ac650a1 100644 --- a/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -6,7 +6,7 @@ "location" : "https://github.com/omise/omise-ios.git", "state" : { "branch" : "feature/MIT-2316-Translations", - "revision" : "a1187a6fb34803490e52b60ff65eb6a36d052834" + "revision" : "857277dd2a0a853688ea28baca2829149a76dfbb" } } ], diff --git a/OmiseSDK/Sources/OmiseAPI/SourceType/SourceType+Collections.swift b/OmiseSDK/Sources/OmiseAPI/SourceType/SourceType+Collections.swift index ef0307f5..6b8cd3da 100644 --- a/OmiseSDK/Sources/OmiseAPI/SourceType/SourceType+Collections.swift +++ b/OmiseSDK/Sources/OmiseAPI/SourceType/SourceType+Collections.swift @@ -1,6 +1,7 @@ import Foundation extension SourceType { + // TODO: Revert changes before create PR public static let availableByDefaultInThailand: [SourceType] = SourceType.allCases // // [ From 7e38e0cee5c0c6eef6cb368074a3ef11a796ebec Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Thu, 14 Mar 2024 22:51:00 +0700 Subject: [PATCH 187/204] Add missing payments to Localized file. Add error text for empty FPX bank list --- .../Resources/en.lproj/Localizable.strings | 40 +++++++++++++++++-- .../Resources/ja.lproj/Localizable.strings | 39 +++++++++++++++++- .../Resources/th.lproj/Localizable.strings | 39 +++++++++++++++++- .../SelectFPXBankViewModel.swift | 14 ++++--- .../SelectPaymentController.swift | 24 +++++++++++ .../SelectPaymentPresentableProtocol.swift | 2 + 6 files changed, 145 insertions(+), 13 deletions(-) diff --git a/OmiseSDK/Resources/en.lproj/Localizable.strings b/OmiseSDK/Resources/en.lproj/Localizable.strings index 1455a477..71e24cd6 100644 --- a/OmiseSDK/Resources/en.lproj/Localizable.strings +++ b/OmiseSDK/Resources/en.lproj/Localizable.strings @@ -8,6 +8,7 @@ "PaymentMethod.eContext.payEasy" = "Pay-easy"; "PaymentMethod.eContext.netBanking" = "Net Bank"; +// Source Types "SourceType.alipay" = "Alipay"; "SourceType.bill_payment_tesco_lotus" = "Lotus's Bill Payment"; "SourceType.installment_bay" = "Krungsri"; @@ -26,8 +27,35 @@ "SourceType.truemoney" = "TrueMoney Wallet"; "SourceType.truemoney_jumpapp" = "TrueMoney"; -// Authorizing Payment -"AuthorizingPayment.title" = "Authorizing Payment"; +// Source Types without localization +"SourceType.alipay_cn" = "Alipay CN"; +"SourceType.alipay_hk" = "Alipay HK"; +"SourceType.atome" = "Atome"; +"SourceType.barcode_alipay" = "Alipay In-Store"; +"SourceType.boost" = "Boost"; +"SourceType.dana" = "DANA"; +"SourceType.duitnow_obw" = "DuitNow Online Banking/Wallets"; +"SourceType.duitnow_qr" = "DuitNow QR"; +"SourceType.fpx" = "FPX"; +"SourceType.gcash" = "GCash"; +"SourceType.grabpay" = "Grab"; +"SourceType.grabpay_rms" = "GrabPay"; +"SourceType.installment_mbb" = "MayBank"; +"SourceType.kakaopay" = "Kakao Pay"; +"SourceType.maybank_qr" = "Maybank QRPay"; +"SourceType.mobile_banking_bay" = "KMA"; +"SourceType.mobile_banking_bbl" = "Bualuang mBanking"; +"SourceType.mobile_banking_kbank" = "K PLUS"; +"SourceType.mobile_banking_ktb" = "Krungthai Next"; +"SourceType.mobile_banking_ocbc" = "OCBC Digital"; +"SourceType.mobile_banking_scb" = "SCB EASY"; +"SourceType.paypay" = "PayPay"; +"SourceType.rabbit_linepay" = "Rabbit LINE Pay"; +"SourceType.shopeepay" = "ShopeePay"; +"SourceType.shopeepay_jumpapp" = "ShopeePay"; +"SourceType.touch_n_go" = "Touch 'n Go"; +"SourceType.touch_n_go_alipay_plus" = "TNG eWallet"; +"SourceType.wechat_pay" = "WeChat Pay"; // Credit Card "CreditCard.field.country" = "Country or region"; @@ -63,7 +91,11 @@ "Atome.field.street1.error" = "Shipping street is required"; "Atome.field.optional" = "(optional)"; +// FPX +"fpx.bank-chooser.no-banks-available.text" = "Cannot retrieve list of banks.\nPlease try again later."; + +// Authorizing Payment +"AuthorizingPayment.title" = "Authorizing Payment"; +// CCV Info "more-info.cvv-location.amex.text" = "4 digit number on the front of your card"; "more-info.cvv-location.default.text" = "3 digit number on the back of your card"; - -"fpx.bank-chooser.no-banks-available.text" = "Cannot retrieve list of banks.\nPlease try again later."; diff --git a/OmiseSDK/Resources/ja.lproj/Localizable.strings b/OmiseSDK/Resources/ja.lproj/Localizable.strings index b34f6809..3fd043ae 100644 --- a/OmiseSDK/Resources/ja.lproj/Localizable.strings +++ b/OmiseSDK/Resources/ja.lproj/Localizable.strings @@ -8,6 +8,7 @@ "PaymentMethod.eContext.payEasy" = "ペイジー"; "PaymentMethod.eContext.netBanking" = "ネットバンク"; +// Source Types "SourceType.alipay" = "アリペイ"; "SourceType.bill_payment_tesco_lotus" = "ロータス"; "SourceType.installment_bay" = "クルンシィ"; @@ -26,8 +27,35 @@ "SourceType.truemoney" = "TrueMoneyウォレット"; "SourceType.truemoney_jumpapp" = "TrueMoney"; -// Authorizing Payment -"AuthorizingPayment.title" = "決済の認可"; +// Source Types without localization +"SourceType.alipay_cn" = "Alipay CN"; +"SourceType.alipay_hk" = "Alipay HK"; +"SourceType.atome" = "Atome"; +"SourceType.barcode_alipay" = "Alipay In-Store"; +"SourceType.boost" = "Boost"; +"SourceType.dana" = "DANA"; +"SourceType.duitnow_obw" = "DuitNow Online Banking/Wallets"; +"SourceType.duitnow_qr" = "DuitNow QR"; +"SourceType.fpx" = "FPX"; +"SourceType.gcash" = "GCash"; +"SourceType.grabpay" = "Grab"; +"SourceType.grabpay_rms" = "GrabPay"; +"SourceType.installment_mbb" = "MayBank"; +"SourceType.kakaopay" = "Kakao Pay"; +"SourceType.maybank_qr" = "Maybank QRPay"; +"SourceType.mobile_banking_bay" = "KMA"; +"SourceType.mobile_banking_bbl" = "Bualuang mBanking"; +"SourceType.mobile_banking_kbank" = "K PLUS"; +"SourceType.mobile_banking_ktb" = "Krungthai Next"; +"SourceType.mobile_banking_ocbc" = "OCBC Digital"; +"SourceType.mobile_banking_scb" = "SCB EASY"; +"SourceType.paypay" = "PayPay"; +"SourceType.rabbit_linepay" = "Rabbit LINE Pay"; +"SourceType.shopeepay" = "ShopeePay"; +"SourceType.shopeepay_jumpapp" = "ShopeePay"; +"SourceType.touch_n_go" = "Touch 'n Go"; +"SourceType.touch_n_go_alipay_plus" = "TNG eWallet"; +"SourceType.wechat_pay" = "WeChat Pay"; // Credit Card "CreditCard.field.country" = "国または地域"; @@ -63,5 +91,12 @@ "Atome.field.street1.error" = "配送先の通り名が必要です"; "Atome.field.optional" = "(任意)"; +// FPX +"fpx.bank-chooser.no-banks-available.text" = "Cannot retrieve list of banks.\nPlease try again later."; + +// Authorizing Payment +"AuthorizingPayment.title" = "決済の認可"; + +// CCV Info "more-info.cvv-location.amex.text" = "カード表面の4桁の番号"; "more-info.cvv-location.default.text" = "カード裏面の3桁の番号"; diff --git a/OmiseSDK/Resources/th.lproj/Localizable.strings b/OmiseSDK/Resources/th.lproj/Localizable.strings index afda53e6..a3a86f8d 100644 --- a/OmiseSDK/Resources/th.lproj/Localizable.strings +++ b/OmiseSDK/Resources/th.lproj/Localizable.strings @@ -8,6 +8,7 @@ "PaymentMethod.eContext.payEasy" = "เพย์อีซี"; "PaymentMethod.eContext.netBanking" = "เน็ตแบงก์"; +// Source Types "SourceType.alipay" = "อาลีเพย์"; "SourceType.bill_payment_tesco_lotus" = "โลตัสบิลเพย์เมนต์"; "SourceType.installment_bay" = "ธนาคารกรุงศรี"; @@ -26,8 +27,35 @@ "SourceType.truemoney" = "ทรูมันนี่วอลเล็ท"; "SourceType.truemoney_jumpapp" = "ทรูมันนี่"; -// Authorizing Payment -"AuthorizingPayment.title" = "กำลังอนุมัติวงเงิน"; +// Source Types without localization +"SourceType.alipay_cn" = "Alipay CN"; +"SourceType.alipay_hk" = "Alipay HK"; +"SourceType.atome" = "Atome"; +"SourceType.barcode_alipay" = "Alipay In-Store"; +"SourceType.boost" = "Boost"; +"SourceType.dana" = "DANA"; +"SourceType.duitnow_obw" = "DuitNow Online Banking/Wallets"; +"SourceType.duitnow_qr" = "DuitNow QR"; +"SourceType.fpx" = "FPX"; +"SourceType.gcash" = "GCash"; +"SourceType.grabpay" = "Grab"; +"SourceType.grabpay_rms" = "GrabPay"; +"SourceType.installment_mbb" = "MayBank"; +"SourceType.kakaopay" = "Kakao Pay"; +"SourceType.maybank_qr" = "Maybank QRPay"; +"SourceType.mobile_banking_bay" = "KMA"; +"SourceType.mobile_banking_bbl" = "Bualuang mBanking"; +"SourceType.mobile_banking_kbank" = "K PLUS"; +"SourceType.mobile_banking_ktb" = "Krungthai Next"; +"SourceType.mobile_banking_ocbc" = "OCBC Digital"; +"SourceType.mobile_banking_scb" = "SCB EASY"; +"SourceType.paypay" = "PayPay"; +"SourceType.rabbit_linepay" = "Rabbit LINE Pay"; +"SourceType.shopeepay" = "ShopeePay"; +"SourceType.shopeepay_jumpapp" = "ShopeePay"; +"SourceType.touch_n_go" = "Touch 'n Go"; +"SourceType.touch_n_go_alipay_plus" = "TNG eWallet"; +"SourceType.wechat_pay" = "WeChat Pay"; // Credit Card "CreditCard.field.country" = "ประเทศหรือภูมิภาค"; @@ -63,5 +91,12 @@ "Atome.field.street1.error" = "จำเป็นต้องใส่ชื่อถนนสำหรับจัดส่งสินค้า"; "Atome.field.optional" = "(ถ้ามี)"; +// FPX +"fpx.bank-chooser.no-banks-available.text" = "Cannot retrieve list of banks.\nPlease try again later."; + +// Authorizing Payment +"AuthorizingPayment.title" = "กำลังอนุมัติวงเงิน"; + +// CCV Info "more-info.cvv-location.amex.text" = "หมายเลข 4 หลักบนหน้าบัตร"; "more-info.cvv-location.default.text" = "หมายเลข 3 หลักด้านหลังบัตร"; diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectFPXBankViewModel.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectFPXBankViewModel.swift index 3b8e8ec6..938766f3 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectFPXBankViewModel.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectFPXBankViewModel.swift @@ -4,13 +4,15 @@ class SelectFPXBankViewModel { weak var delegate: SelectSourcePaymentDelegate? let email: String? + let errorMessage: String? + private var viewOnDataReloadHandler: () -> Void = { } { didSet { self.viewOnDataReloadHandler() } } - private var values: [Capability.PaymentMethod.Bank] = [] { + private var banks: [Capability.PaymentMethod.Bank] = [] { didSet { viewOnDataReloadHandler() } @@ -18,8 +20,10 @@ class SelectFPXBankViewModel { init(email: String?, banks: [Capability.PaymentMethod.Bank], delegate: SelectSourcePaymentDelegate) { self.email = email - self.values = banks + self.banks = banks self.delegate = delegate + + errorMessage = banks.isEmpty ? localized("fpx.bank-chooser.no-banks-available.text") : nil } } @@ -29,7 +33,7 @@ extension SelectFPXBankViewModel: SelectPaymentPresentableProtocol { } var numberOfViewContexts: Int { - values.count + banks.count } var viewNavigationTitle: String { @@ -37,7 +41,7 @@ extension SelectFPXBankViewModel: SelectPaymentPresentableProtocol { } func viewContext(at index: Int) -> TableCellContext? { - guard let bank = values.at(index) else { return nil } + guard let bank = banks.at(index) else { return nil } let fpxBank = Source.Payment.FPX.Bank(rawValue: bank.code) return TableCellContext( title: bank.name, @@ -47,7 +51,7 @@ extension SelectFPXBankViewModel: SelectPaymentPresentableProtocol { } func viewDidSelectCell(at index: Int, completion: @escaping () -> Void) { - guard let bank = values.at(index) else { return } + guard let bank = banks.at(index) else { return } let payment = Source.Payment.FPX(bank: bank.code, email: email) delegate?.didSelectSourcePayment(.fpx(payment), completion: completion) diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentController.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentController.swift index 861be496..e3793cdf 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentController.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentController.swift @@ -21,6 +21,10 @@ class SelectPaymentController: UITableViewController { setupNavigationItems() setupTableView() setupViewModel() + + if let errorMessage = viewModel.errorMessage { + showErrorMessage(errorMessage) + } } @objc private func didTapClose() { @@ -119,4 +123,24 @@ private extension SelectPaymentController { } navigationItem.backBarButtonItem = .empty } + + private func showErrorMessage(_ errorMessage: String) { + let label = UILabel( + frame: CGRect(x: 0, y: 0, width: tableView.bounds.size.width, height: tableView.bounds.size.height) + ) + + label.text = errorMessage + label.textColor = UIColor.omisePrimary + label.numberOfLines = 0 + label.textAlignment = .center + label.sizeToFit() + + tableView.backgroundView = label + tableView.separatorStyle = .none + } + + private func hideErrorMessage() { + tableView.backgroundView = nil + tableView.separatorStyle = .singleLine + } } diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentPresentableProtocol.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentPresentableProtocol.swift index 84e336dd..fb19f2d2 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentPresentableProtocol.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Select Payment From Lists/SelectPaymentPresentableProtocol.swift @@ -5,6 +5,7 @@ protocol SelectPaymentPresentableProtocol { var viewNavigationTitle: String { get } var viewDisplayLargeTitle: Bool { get } var viewShowsCloseButton: Bool { get } + var errorMessage: String? { get } func viewOnDataReloadHandler(_ handler: @escaping () -> Void) func viewContext(at: Int) -> TableCellContext? @@ -15,6 +16,7 @@ protocol SelectPaymentPresentableProtocol { // Default implementation for most common cases extension SelectPaymentPresentableProtocol { + var errorMessage: String? { nil } var viewShowsCloseButton: Bool { false } var viewDisplayLargeTitle: Bool { false } func viewDidTapClose() {} From 14d8be6dc148e75a3f547d6296cdaf7d7fc0590d Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Fri, 15 Mar 2024 14:44:08 +0700 Subject: [PATCH 188/204] Copy missing translations from Android SDK --- .../Resources/en.lproj/Localizable.strings | 35 ++++++++++---- .../Resources/ja.lproj/Localizable.strings | 46 +++++++++++++------ .../Resources/th.lproj/Localizable.strings | 46 +++++++++++++------ .../SourceType+ViewPresentable.swift | 4 +- .../CCVInfoController.swift | 12 +---- .../xcshareddata/xcschemes/OmiseSDK.xcscheme | 2 +- 6 files changed, 96 insertions(+), 49 deletions(-) diff --git a/OmiseSDK/Resources/en.lproj/Localizable.strings b/OmiseSDK/Resources/en.lproj/Localizable.strings index 71e24cd6..44b0a620 100644 --- a/OmiseSDK/Resources/en.lproj/Localizable.strings +++ b/OmiseSDK/Resources/en.lproj/Localizable.strings @@ -9,7 +9,8 @@ "PaymentMethod.eContext.netBanking" = "Net Bank"; // Source Types -"SourceType.alipay" = "Alipay"; +"SourceType.alipay" = "Alipay Online"; +"SourceType.alipay.footnote" = "(Alipay+™ Partner)"; "SourceType.bill_payment_tesco_lotus" = "Lotus's Bill Payment"; "SourceType.installment_bay" = "Krungsri"; "SourceType.installment_bbl" = "Bangkok Bank"; @@ -28,8 +29,8 @@ "SourceType.truemoney_jumpapp" = "TrueMoney"; // Source Types without localization -"SourceType.alipay_cn" = "Alipay CN"; -"SourceType.alipay_hk" = "Alipay HK"; +"SourceType.alipay_cn" = "Alipay"; +"SourceType.alipay_hk" = "AlipayHK"; "SourceType.atome" = "Atome"; "SourceType.barcode_alipay" = "Alipay In-Store"; "SourceType.boost" = "Boost"; @@ -39,8 +40,9 @@ "SourceType.fpx" = "FPX"; "SourceType.gcash" = "GCash"; "SourceType.grabpay" = "Grab"; +"SourceType.grabpay.footnote" = "(GrabPay and PayLater)"; "SourceType.grabpay_rms" = "GrabPay"; -"SourceType.installment_mbb" = "MayBank"; +"SourceType.installment_mbb" = "Maybank"; "SourceType.kakaopay" = "Kakao Pay"; "SourceType.maybank_qr" = "Maybank QRPay"; "SourceType.mobile_banking_bay" = "KMA"; @@ -53,7 +55,7 @@ "SourceType.rabbit_linepay" = "Rabbit LINE Pay"; "SourceType.shopeepay" = "ShopeePay"; "SourceType.shopeepay_jumpapp" = "ShopeePay"; -"SourceType.touch_n_go" = "Touch 'n Go"; +"SourceType.touch_n_go" = "Touch ’n Go"; "SourceType.touch_n_go_alipay_plus" = "TNG eWallet"; "SourceType.wechat_pay" = "WeChat Pay"; @@ -67,6 +69,26 @@ "CreditCard.field.city.error" = "City is required"; "CreditCard.field.state.error" = "State is required"; "CreditCard.field.postalCode.error" = "Zip code / Postal code is required"; +"CreditCard.field.cardNumber" = "Card number"; +"CreditCard.field.nameOnCard" = "Name on card"; +"CreditCard.field.expiryDate" = "Expiry date"; +"CreditCard.field.securityCode" = "Security code"; +"CreditCard.field.mmyy.placeholder" = "MM/YY"; +"CreditCard.payButton.title" = "Pay"; + +"CreditCard.ccv.details.amex.text" = "4 digit number on the front of your card"; +"CreditCard.ccv.details.default.text" = "3 digit number on the back of your card"; + +// EContext +"EContext.field.fullName" = "Full name"; +"EContext.field.email" = "Email"; +"EContext.field.phone" = "Phone"; +"EContext.nextButton.title" = "Next"; + +// TrueMoney Wallet +"TrueMoneyWallet.field.phoneNumber" = "Phone number"; +"TrueMoneyWallet.nextButton.title" = "Next"; +"TrueMoneyWallet.label.pleaseInput.text" = "Please input the mobile number connected to your TrueMoney Wallet account"; // Atome "Atome.header.text" = "Please input the below information to complete the charge creation with Atome"; @@ -96,6 +118,3 @@ // Authorizing Payment "AuthorizingPayment.title" = "Authorizing Payment"; -// CCV Info -"more-info.cvv-location.amex.text" = "4 digit number on the front of your card"; -"more-info.cvv-location.default.text" = "3 digit number on the back of your card"; diff --git a/OmiseSDK/Resources/ja.lproj/Localizable.strings b/OmiseSDK/Resources/ja.lproj/Localizable.strings index 3fd043ae..0c519b60 100644 --- a/OmiseSDK/Resources/ja.lproj/Localizable.strings +++ b/OmiseSDK/Resources/ja.lproj/Localizable.strings @@ -3,13 +3,14 @@ "PaymentMethod.creditCard" = "クレジットカード"; "PaymentMethod.installments" = "分割払い"; "PaymentMethod.internetBanking" = "インターネットバンク"; -"PaymentMethod.mobileBanking" = "Mobile Banking"; +"PaymentMethod.mobileBanking" = "モバイルバンキング"; "PaymentMethod.eContext.conbini" = "コンビニ"; "PaymentMethod.eContext.payEasy" = "ペイジー"; "PaymentMethod.eContext.netBanking" = "ネットバンク"; // Source Types -"SourceType.alipay" = "アリペイ"; +"SourceType.alipay" = "アリペイオンライン"; +"SourceType.alipay.footnote" = "(アリペイプラス)"; "SourceType.bill_payment_tesco_lotus" = "ロータス"; "SourceType.installment_bay" = "クルンシィ"; "SourceType.installment_bbl" = "バンコク銀行"; @@ -28,20 +29,21 @@ "SourceType.truemoney_jumpapp" = "TrueMoney"; // Source Types without localization -"SourceType.alipay_cn" = "Alipay CN"; -"SourceType.alipay_hk" = "Alipay HK"; +"SourceType.alipay_cn" = "アリペイ"; +"SourceType.alipay_hk" = "アリペイ香港"; "SourceType.atome" = "Atome"; "SourceType.barcode_alipay" = "Alipay In-Store"; "SourceType.boost" = "Boost"; -"SourceType.dana" = "DANA"; +"SourceType.dana" = "ダナ"; "SourceType.duitnow_obw" = "DuitNow Online Banking/Wallets"; "SourceType.duitnow_qr" = "DuitNow QR"; "SourceType.fpx" = "FPX"; -"SourceType.gcash" = "GCash"; +"SourceType.gcash" = "ジーキャッシュ"; "SourceType.grabpay" = "Grab"; +"SourceType.grabpay.footnote" = "(GrabPay and PayLater)"; "SourceType.grabpay_rms" = "GrabPay"; -"SourceType.installment_mbb" = "MayBank"; -"SourceType.kakaopay" = "Kakao Pay"; +"SourceType.installment_mbb" = "メイバンク"; +"SourceType.kakaopay" = "カカオペイ"; "SourceType.maybank_qr" = "Maybank QRPay"; "SourceType.mobile_banking_bay" = "KMA"; "SourceType.mobile_banking_bbl" = "Bualuang mBanking"; @@ -53,7 +55,7 @@ "SourceType.rabbit_linepay" = "Rabbit LINE Pay"; "SourceType.shopeepay" = "ShopeePay"; "SourceType.shopeepay_jumpapp" = "ShopeePay"; -"SourceType.touch_n_go" = "Touch 'n Go"; +"SourceType.touch_n_go" = "タッチンゴー"; "SourceType.touch_n_go_alipay_plus" = "TNG eWallet"; "SourceType.wechat_pay" = "WeChat Pay"; @@ -67,6 +69,26 @@ "CreditCard.field.city.error" = "市が必要です"; "CreditCard.field.state.error" = "州が必要です"; "CreditCard.field.postalCode.error" = "郵便番号が必要です"; +"CreditCard.field.cardNumber" = "カード番号"; +"CreditCard.field.nameOnCard" = "カード名義"; +"CreditCard.field.expiryDate" = "有効期限"; +"CreditCard.field.securityCode" = "セキュリティコード"; +"CreditCard.field.mmyy.placeholder" = "MM/YY"; +"CreditCard.payButton.title" = "支払う"; + +"CreditCard.ccv.details.amex.text" = "カード表面の4桁の番号"; +"CreditCard.ccv.details.default.text" = "カード裏面の3桁の番号"; + +// EContext +"EContext.field.fullName" = "氏名"; +"EContext.field.email" = "メール"; +"EContext.field.phone" = "電話"; +"EContext.nextButton.title" = "次"; + +// TrueMoney Wallet +"TrueMoneyWallet.field.phoneNumber" = "電話"; +"TrueMoneyWallet.nextButton.title" = "次"; +"TrueMoneyWallet.label.pleaseInput.text" = "TrueMoney ウォレットアカウントに登録されている携帯電話番号を入力してください"; // Atome "Atome.header.text" = "Atomeによるお支払いを完了させるには、以下の情報をご記入ください。"; @@ -92,11 +114,7 @@ "Atome.field.optional" = "(任意)"; // FPX -"fpx.bank-chooser.no-banks-available.text" = "Cannot retrieve list of banks.\nPlease try again later."; +"fpx.bank-chooser.no-banks-available.text" = "銀行のリストを検索できません。後でもう一度お試しください。"; // Authorizing Payment "AuthorizingPayment.title" = "決済の認可"; - -// CCV Info -"more-info.cvv-location.amex.text" = "カード表面の4桁の番号"; -"more-info.cvv-location.default.text" = "カード裏面の3桁の番号"; diff --git a/OmiseSDK/Resources/th.lproj/Localizable.strings b/OmiseSDK/Resources/th.lproj/Localizable.strings index a3a86f8d..9a1dfbf1 100644 --- a/OmiseSDK/Resources/th.lproj/Localizable.strings +++ b/OmiseSDK/Resources/th.lproj/Localizable.strings @@ -3,13 +3,14 @@ "PaymentMethod.creditCard" = "บัตรเครดิต"; "PaymentMethod.installments" = "ผ่อนชำระ"; "PaymentMethod.internetBanking" = "อินเทอร์เน็ตแบงก์กิ้ง"; -"PaymentMethod.mobileBanking" = "โมบายล์แบงก์กิ้ง"; +"PaymentMethod.mobileBanking" = "โมบายแบงก์กิ้ง"; "PaymentMethod.eContext.conbini" = "ร้านสะดวกซื้อ"; "PaymentMethod.eContext.payEasy" = "เพย์อีซี"; "PaymentMethod.eContext.netBanking" = "เน็ตแบงก์"; // Source Types -"SourceType.alipay" = "อาลีเพย์"; +"SourceType.alipay" = "อาลีเพย์ (ออนไลน์)"; +"SourceType.alipay.footnote" = "(อาลีเพย์พลัส)"; "SourceType.bill_payment_tesco_lotus" = "โลตัสบิลเพย์เมนต์"; "SourceType.installment_bay" = "ธนาคารกรุงศรี"; "SourceType.installment_bbl" = "ธนาคารกรุงเทพ"; @@ -28,20 +29,21 @@ "SourceType.truemoney_jumpapp" = "ทรูมันนี่"; // Source Types without localization -"SourceType.alipay_cn" = "Alipay CN"; -"SourceType.alipay_hk" = "Alipay HK"; +"SourceType.alipay_cn" = "อาลีเพย์"; +"SourceType.alipay_hk" = "อาลีเพย์ฮ่องกง"; "SourceType.atome" = "Atome"; "SourceType.barcode_alipay" = "Alipay In-Store"; "SourceType.boost" = "Boost"; -"SourceType.dana" = "DANA"; +"SourceType.dana" = "ดานา"; "SourceType.duitnow_obw" = "DuitNow Online Banking/Wallets"; "SourceType.duitnow_qr" = "DuitNow QR"; "SourceType.fpx" = "FPX"; -"SourceType.gcash" = "GCash"; +"SourceType.gcash" = "จีแคช"; "SourceType.grabpay" = "Grab"; +"SourceType.grabpay.footnote" = "(GrabPay and PayLater)"; "SourceType.grabpay_rms" = "GrabPay"; -"SourceType.installment_mbb" = "MayBank"; -"SourceType.kakaopay" = "Kakao Pay"; +"SourceType.installment_mbb" = "เมย์แบงก์"; +"SourceType.kakaopay" = "กาเกาเพย์"; "SourceType.maybank_qr" = "Maybank QRPay"; "SourceType.mobile_banking_bay" = "KMA"; "SourceType.mobile_banking_bbl" = "Bualuang mBanking"; @@ -53,7 +55,7 @@ "SourceType.rabbit_linepay" = "Rabbit LINE Pay"; "SourceType.shopeepay" = "ShopeePay"; "SourceType.shopeepay_jumpapp" = "ShopeePay"; -"SourceType.touch_n_go" = "Touch 'n Go"; +"SourceType.touch_n_go" = "ทัชแอนด์โก"; "SourceType.touch_n_go_alipay_plus" = "TNG eWallet"; "SourceType.wechat_pay" = "WeChat Pay"; @@ -67,6 +69,26 @@ "CreditCard.field.city.error" = "ต้องระบุเมือง"; "CreditCard.field.state.error" = "ต้องระบุเขต"; "CreditCard.field.postalCode.error" = "ต้องระบุรหัสไปรษณีย์"; +"CreditCard.field.cardNumber" = "หมายเลขบัตร"; +"CreditCard.field.nameOnCard" = "ชื่อบนบัตร"; +"CreditCard.field.expiryDate" = "หมดอายุ"; +"CreditCard.field.securityCode" = "รหัสความปลอดภัย"; +"CreditCard.field.mmyy.placeholder" = "ดด/ปป"; +"CreditCard.payButton.title" = "ชำระเงิน"; + +"CreditCard.ccv.details.amex.text" = "หมายเลข 4 หลักบนหน้าบัตร"; +"CreditCard.ccv.details.default.text" = "หมายเลข 3 หลักด้านหลังบัตร"; + +// EContext +"EContext.field.fullName" = "ชื่อ-สกุล"; +"EContext.field.email" = "อีเมล์"; +"EContext.field.phone" = "โทร."; +"EContext.nextButton.title" = "ถัดไป"; + +// TrueMoney Wallet +"TrueMoneyWallet.field.phoneNumber" = "โทร."; +"TrueMoneyWallet.nextButton.title" = "ถัดไป"; +"TrueMoneyWallet.label.pleaseInput.text" = "กรุณากรอกหมายเลขโทรศัพท์ที่ผูกกับบัญชีทรูมันนี่วอลเล็ท"; // Atome "Atome.header.text" = "กรุณาใส่ข้อมูลเพื่อสร้างรายการเรียกเก็บเงินกับ Atome ให้เสร็จสมบูรณ์"; @@ -92,11 +114,7 @@ "Atome.field.optional" = "(ถ้ามี)"; // FPX -"fpx.bank-chooser.no-banks-available.text" = "Cannot retrieve list of banks.\nPlease try again later."; +"fpx.bank-chooser.no-banks-available.text" = "ไม่สามารถเรียกข้อมูลรายชื่อธนาคารได้ในขณะนี้ กรุณาลองใหม่อีกครั้ง"; // Authorizing Payment "AuthorizingPayment.title" = "กำลังอนุมัติวงเงิน"; - -// CCV Info -"more-info.cvv-location.amex.text" = "หมายเลข 4 หลักบนหน้าบัตร"; -"more-info.cvv-location.default.text" = "หมายเลข 3 หลักด้านหลังบัตร"; diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/SourceType+ViewPresentable.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/SourceType+ViewPresentable.swift index 9e7924f2..511cbf61 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/SourceType+ViewPresentable.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/SourceType+ViewPresentable.swift @@ -215,9 +215,9 @@ extension SourceType: ViewPresentable { public var subtitle: String? { switch self { case .alipayCN, .alipayHK, .dana, .gcash, .kakaoPay, .touchNGo: - return "(Alipay+™ Partner)" + return localized("SourceType.alipay.footnote") case .grabPay: - return "(GrabPay and PayLater)" + return localized("SourceType.grabpay.footnote)") default: return nil } diff --git a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CCVInfoController.swift b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CCVInfoController.swift index 95c104c0..e2ffac4b 100644 --- a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CCVInfoController.swift +++ b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CCVInfoController.swift @@ -40,18 +40,10 @@ class CCVInfoController: UIViewController { switch preferredCardBrand { case .amex?: cvvLocationImageView.image = UIImage(omise: "CVV AMEX") - cvvLocationDescriptionLabel.text = NSLocalizedString( - "more-info.cvv-location.amex.text", - bundle: .omiseSDK, - value: "4 digit number on the front of your card", - comment: "A descriptive text telling the location of CVV on the AMEX card") + cvvLocationDescriptionLabel.text = localized("CreditCard.ccv.details.amex.text") default: cvvLocationImageView.image = UIImage(omise: "CVV") - cvvLocationDescriptionLabel.text = NSLocalizedString( - "more-info.cvv-location.default.text", - bundle: .omiseSDK, - value: "3 digit number on the back of your card", - comment: "A descriptive text telling the location of CVV on the typical credit card") + cvvLocationDescriptionLabel.text = localized("CreditCard.ccv.details.default.text") } } } diff --git a/dev.xcodeproj/xcshareddata/xcschemes/OmiseSDK.xcscheme b/dev.xcodeproj/xcshareddata/xcschemes/OmiseSDK.xcscheme index acc7aa89..6f87d35a 100644 --- a/dev.xcodeproj/xcshareddata/xcschemes/OmiseSDK.xcscheme +++ b/dev.xcodeproj/xcshareddata/xcschemes/OmiseSDK.xcscheme @@ -68,7 +68,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "ja" + language = "th" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" From 8df9ac1f8b255cc197b7864b4aa8a3d916623c12 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Fri, 15 Mar 2024 15:17:35 +0700 Subject: [PATCH 189/204] Finalize localization --- .../Resources/en.lproj/Localizable.strings | 6 +-- .../Resources/ja.lproj/Localizable.strings | 6 +-- .../Resources/th.lproj/Localizable.strings | 6 +-- .../SourceType/SourceType+Collections.swift | 50 +++++++++---------- .../EContextPaymentFormController.swift | 6 +++ .../TrueMoneyPaymentFormController.swift | 5 ++ .../TrueMoneyPaymentFormController.xib | 1 + .../SourceType+ViewPresentable.swift | 2 +- .../CreditCardPaymentController.swift | 8 +++ .../xcshareddata/xcschemes/OmiseSDK.xcscheme | 1 - 10 files changed, 54 insertions(+), 37 deletions(-) diff --git a/OmiseSDK/Resources/en.lproj/Localizable.strings b/OmiseSDK/Resources/en.lproj/Localizable.strings index 44b0a620..17ca2666 100644 --- a/OmiseSDK/Resources/en.lproj/Localizable.strings +++ b/OmiseSDK/Resources/en.lproj/Localizable.strings @@ -63,12 +63,12 @@ "CreditCard.field.country" = "Country or region"; "CreditCard.field.address" = "Address"; "CreditCard.field.city" = "City"; -"CreditCard.field.state" = "State"; -"CreditCard.field.postalCode" = "Zip code / Postal code"; -"CreditCard.field.address.error" = "Address is required"; "CreditCard.field.city.error" = "City is required"; +"CreditCard.field.state" = "State"; "CreditCard.field.state.error" = "State is required"; +"CreditCard.field.postalCode" = "Zip code / Postal code"; "CreditCard.field.postalCode.error" = "Zip code / Postal code is required"; +"CreditCard.field.address.error" = "Address is required"; "CreditCard.field.cardNumber" = "Card number"; "CreditCard.field.nameOnCard" = "Name on card"; "CreditCard.field.expiryDate" = "Expiry date"; diff --git a/OmiseSDK/Resources/ja.lproj/Localizable.strings b/OmiseSDK/Resources/ja.lproj/Localizable.strings index 0c519b60..d9980345 100644 --- a/OmiseSDK/Resources/ja.lproj/Localizable.strings +++ b/OmiseSDK/Resources/ja.lproj/Localizable.strings @@ -62,12 +62,12 @@ // Credit Card "CreditCard.field.country" = "国または地域"; "CreditCard.field.address" = "住所"; -"CreditCard.field.city" = "市"; -"CreditCard.field.state" = "州"; -"CreditCard.field.postalCode" = "郵便番号"; "CreditCard.field.address.error" = "住所は必須です"; +"CreditCard.field.city" = "市"; "CreditCard.field.city.error" = "市が必要です"; +"CreditCard.field.state" = "州"; "CreditCard.field.state.error" = "州が必要です"; +"CreditCard.field.postalCode" = "郵便番号"; "CreditCard.field.postalCode.error" = "郵便番号が必要です"; "CreditCard.field.cardNumber" = "カード番号"; "CreditCard.field.nameOnCard" = "カード名義"; diff --git a/OmiseSDK/Resources/th.lproj/Localizable.strings b/OmiseSDK/Resources/th.lproj/Localizable.strings index 9a1dfbf1..dd24bd49 100644 --- a/OmiseSDK/Resources/th.lproj/Localizable.strings +++ b/OmiseSDK/Resources/th.lproj/Localizable.strings @@ -62,12 +62,12 @@ // Credit Card "CreditCard.field.country" = "ประเทศหรือภูมิภาค"; "CreditCard.field.address" = "ที่อยู่"; -"CreditCard.field.city" = "จังหวัด"; -"CreditCard.field.state" = "เขต"; -"CreditCard.field.postalCode" = "รหัสไปรษณีย์"; "CreditCard.field.address.error" = "ต้องระบุที่อยู่"; +"CreditCard.field.city" = "จังหวัด"; "CreditCard.field.city.error" = "ต้องระบุเมือง"; +"CreditCard.field.state" = "เขต"; "CreditCard.field.state.error" = "ต้องระบุเขต"; +"CreditCard.field.postalCode" = "รหัสไปรษณีย์"; "CreditCard.field.postalCode.error" = "ต้องระบุรหัสไปรษณีย์"; "CreditCard.field.cardNumber" = "หมายเลขบัตร"; "CreditCard.field.nameOnCard" = "ชื่อบนบัตร"; diff --git a/OmiseSDK/Sources/OmiseAPI/SourceType/SourceType+Collections.swift b/OmiseSDK/Sources/OmiseAPI/SourceType/SourceType+Collections.swift index 6b8cd3da..165c00b8 100644 --- a/OmiseSDK/Sources/OmiseAPI/SourceType/SourceType+Collections.swift +++ b/OmiseSDK/Sources/OmiseAPI/SourceType/SourceType+Collections.swift @@ -1,32 +1,30 @@ import Foundation extension SourceType { - // TODO: Revert changes before create PR - public static let availableByDefaultInThailand: [SourceType] = SourceType.allCases -// -// [ -// .internetBankingBAY, -// .internetBankingBBL, -// .mobileBankingSCB, -// .mobileBankingKBank, -// .mobileBankingBAY, -// .mobileBankingBBL, -// .mobileBankingKTB, -// .alipay, -// .billPaymentTescoLotus, -// .installmentBAY, -// .installmentFirstChoice, -// .installmentBBL, -// .installmentKTC, -// .installmentKBank, -// .installmentSCB, -// .installmentTTB, -// .installmentUOB, -// .promptPay, -// .trueMoneyWallet, -// .pointsCiti, -// .shopeePayJumpApp -// ] + public static let availableByDefaultInThailand: [SourceType] = + [ + .internetBankingBAY, + .internetBankingBBL, + .mobileBankingSCB, + .mobileBankingKBank, + .mobileBankingBAY, + .mobileBankingBBL, + .mobileBankingKTB, + .alipay, + .billPaymentTescoLotus, + .installmentBAY, + .installmentFirstChoice, + .installmentBBL, + .installmentKTC, + .installmentKBank, + .installmentSCB, + .installmentTTB, + .installmentUOB, + .promptPay, + .trueMoneyWallet, + .pointsCiti, + .shopeePayJumpApp + ] public static let availableByDefaultInJapan: [SourceType] = [ .eContext, diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/EContext/EContextPaymentFormController.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/EContext/EContextPaymentFormController.swift index 944f1ddd..6e46185a 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/EContext/EContextPaymentFormController.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/EContext/EContextPaymentFormController.swift @@ -93,6 +93,12 @@ class EContextPaymentFormController: UIViewController, PaymentFormUIController { setupTextFieldHandlers() contentView.adjustContentInsetOnKeyboardAppear() + + fullNameLabel.text = localized("EContext.field.fullName") + emailLabel.text = localized("EContext.field.email") + phoneNumberLabel.text = localized("EContext.field.phone") + submitButton.setTitle(localized("EContext.nextButton.title"), for: .normal) + } private func setupTextFieldHandlers() { diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.swift index d771e403..cdb6b9fd 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.swift @@ -13,6 +13,7 @@ class TrueMoneyPaymentFormController: UIViewController, PaymentFormUIController @IBOutlet var contentView: UIScrollView! + @IBOutlet private var pleaseInputLabel: UILabel! @IBOutlet private var phoneNumberLabel: UILabel! @IBOutlet private var phoneNumberTextField: OmiseTextField! @IBOutlet private var submitButton: MainActionButton! @@ -82,6 +83,10 @@ class TrueMoneyPaymentFormController: UIViewController, PaymentFormUIController setupTextFieldHandlers() contentView.adjustContentInsetOnKeyboardAppear() + + pleaseInputLabel.text = localized("TrueMoneyWallet.label.pleaseInput.text") + phoneNumberLabel.text = localized("TrueMoneyWallet.field.phoneNumber") + submitButton.setTitle(localized("TrueMoneyWallet.nextButton.title"), for: .normal) } private func setupTextFieldHandlers() { diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.xib b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.xib index 2932fdbc..b32d32c6 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.xib +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/TrueMoneyWallet/TrueMoneyPaymentFormController.xib @@ -18,6 +18,7 @@ + diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/SourceType+ViewPresentable.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/SourceType+ViewPresentable.swift index 511cbf61..b209b36e 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/SourceType+ViewPresentable.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ViewPresentable/SourceType+ViewPresentable.swift @@ -217,7 +217,7 @@ extension SourceType: ViewPresentable { case .alipayCN, .alipayHK, .dana, .gcash, .kakaoPay, .touchNGo: return localized("SourceType.alipay.footnote") case .grabPay: - return localized("SourceType.grabpay.footnote)") + return localized("SourceType.grabpay.footnote") default: return nil } diff --git a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift index b7cfff7f..737d2d18 100644 --- a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift +++ b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift @@ -184,9 +184,16 @@ class CreditCardPaymentController: UIViewController { formLabels.forEach { $0.adjustsFontForContentSizeCategory = true } + + cardNumberLabel.text = localized("CreditCard.field.cardNumber") + cardNameLabel.text = localized("CreditCard.field.nameOnCard") + expiryDateLabel.text = localized("CreditCard.field.expiryDate") + secureCodeLabel.text = localized("CreditCard.field.securityCode") } private func setupTextFields() { + expiryDateTextField.placeholder = localized("CreditCard.field.mmyy.placeholder") + formFields.forEach { $0.inputAccessoryView = formFieldsAccessoryView $0.onValueChanged = { [weak self] in @@ -213,6 +220,7 @@ class CreditCardPaymentController: UIViewController { } private func setupSubmitButton() { + submitButton.setTitle(localized("CreditCard.payButton.title"), for: .normal) submitButton.defaultBackgroundColor = view.tintColor submitButton.disabledBackgroundColor = .line submitButton.titleLabel?.adjustsFontForContentSizeCategory = true diff --git a/dev.xcodeproj/xcshareddata/xcschemes/OmiseSDK.xcscheme b/dev.xcodeproj/xcshareddata/xcschemes/OmiseSDK.xcscheme index 6f87d35a..58ad706a 100644 --- a/dev.xcodeproj/xcshareddata/xcschemes/OmiseSDK.xcscheme +++ b/dev.xcodeproj/xcshareddata/xcschemes/OmiseSDK.xcscheme @@ -68,7 +68,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "th" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" From 8a47923e1e758bcf4ab4ae0d0cd3b46d2532fab5 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Fri, 15 Mar 2024 15:23:48 +0700 Subject: [PATCH 190/204] Changed target branch for ExampleApp to be a base branch --- ExampleApp.xcodeproj/project.pbxproj | 2 +- .../project.xcworkspace/xcshareddata/swiftpm/Package.resolved | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ExampleApp.xcodeproj/project.pbxproj b/ExampleApp.xcodeproj/project.pbxproj index 1b4909a1..54ea45b1 100644 --- a/ExampleApp.xcodeproj/project.pbxproj +++ b/ExampleApp.xcodeproj/project.pbxproj @@ -453,7 +453,7 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/omise/omise-ios.git"; requirement = { - branch = "feature/MIT-2316-Translations"; + branch = feature/v5_refactoring; kind = branch; }; }; diff --git a/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 3ac650a1..b4467c45 100644 --- a/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/omise/omise-ios.git", "state" : { - "branch" : "feature/MIT-2316-Translations", - "revision" : "857277dd2a0a853688ea28baca2829149a76dfbb" + "branch" : "feature/v5_refactoring", + "revision" : "987171818f6b6669e9859c1fba306be20704e05c" } } ], From cbae16abd5001e26e59c95a1457c0829d1e547e4 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Fri, 15 Mar 2024 15:30:03 +0700 Subject: [PATCH 191/204] Fix github failed action --- .../Sources/ToolKit/UI Extensions/UIScrollView+Helpers.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OmiseSDK/Sources/ToolKit/UI Extensions/UIScrollView+Helpers.swift b/OmiseSDK/Sources/ToolKit/UI Extensions/UIScrollView+Helpers.swift index d557c30b..76961b02 100644 --- a/OmiseSDK/Sources/ToolKit/UI Extensions/UIScrollView+Helpers.swift +++ b/OmiseSDK/Sources/ToolKit/UI Extensions/UIScrollView+Helpers.swift @@ -24,7 +24,7 @@ extension UIScrollView { bottomScrollIndicatorInset = keyboardFrame.height } - scrollIndicatorInsets.bottom = bottomScrollIndicatorInset + self.scrollIndicatorInsets.bottom = bottomScrollIndicatorInset } // swiftlint:disable:next line_length From 6d54e45f873363daf5aaafabd3b3b81f411a76e9 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Fri, 15 Mar 2024 15:39:25 +0700 Subject: [PATCH 192/204] Fix ScrollView extension to pass github action error --- .../Sources/ToolKit/UI Extensions/UIScrollView+Helpers.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OmiseSDK/Sources/ToolKit/UI Extensions/UIScrollView+Helpers.swift b/OmiseSDK/Sources/ToolKit/UI Extensions/UIScrollView+Helpers.swift index 76961b02..9fd0c08e 100644 --- a/OmiseSDK/Sources/ToolKit/UI Extensions/UIScrollView+Helpers.swift +++ b/OmiseSDK/Sources/ToolKit/UI Extensions/UIScrollView+Helpers.swift @@ -19,7 +19,7 @@ extension UIScrollView { let bottomScrollIndicatorInset: CGFloat if #available(iOS 11.0, *) { - bottomScrollIndicatorInset = keyboardFrame.height - safeAreaInsets.bottom + bottomScrollIndicatorInset = keyboardFrame.height - self.safeAreaInsets.bottom } else { bottomScrollIndicatorInset = keyboardFrame.height } From 4498f76605c8efa4081e1151a333c8618cb7768b Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Fri, 15 Mar 2024 21:48:13 +0700 Subject: [PATCH 193/204] Fixed Installments, Mobile Banking and Internet Banking payment method content to match Capability --- OmiseSDK/Sources/OmiseAPI/Client.swift | 6 ------ .../OmiseAPI/JSON Models/Capabilities/Capability.swift | 6 ++++++ .../ChoosePaymentCoordinator.swift | 9 ++++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/OmiseSDK/Sources/OmiseAPI/Client.swift b/OmiseSDK/Sources/OmiseAPI/Client.swift index aaf107d4..54fbab03 100644 --- a/OmiseSDK/Sources/OmiseAPI/Client.swift +++ b/OmiseSDK/Sources/OmiseAPI/Client.swift @@ -83,9 +83,3 @@ class Client: ClientProtocol { ) } } - -extension Client { - func setLatestLoadedCapability(_ capability: Capability) { - latestLoadedCapability = capability - } -} diff --git a/OmiseSDK/Sources/OmiseAPI/JSON Models/Capabilities/Capability.swift b/OmiseSDK/Sources/OmiseAPI/JSON Models/Capabilities/Capability.swift index 77308013..db9e88a2 100644 --- a/OmiseSDK/Sources/OmiseAPI/JSON Models/Capabilities/Capability.swift +++ b/OmiseSDK/Sources/OmiseAPI/JSON Models/Capabilities/Capability.swift @@ -21,6 +21,12 @@ extension Capability { method.name == "card" } } + + func availableSourceTypes(_ sourceTypes: [SourceType]) -> [SourceType] { + paymentMethods + .compactMap { $0.sourceType } + .filter { sourceTypes.contains($0) } + } } extension Capability: Codable { diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator.swift index e86adf95..72ccc8e8 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator.swift @@ -79,9 +79,10 @@ class ChoosePaymentCoordinator: NSObject, ViewAttachable { /// Creates Mobile Banking screen and attach current flow object inside created controller to be deallocated together func createMobileBankingController() -> SelectPaymentController { + let sourceTypes = client.latestLoadedCapability?.availableSourceTypes(SourceType.mobileBanking) let viewModel = SelectSourceTypePaymentViewModel( title: PaymentMethod.mobileBanking.localizedTitle, - sourceTypes: SourceType.mobileBanking, + sourceTypes: sourceTypes ?? [], delegate: self ) @@ -91,9 +92,10 @@ class ChoosePaymentCoordinator: NSObject, ViewAttachable { /// Creates Mobile Banking screen and attach current flow object inside created controller to be deallocated together func createInternetBankingController() -> SelectPaymentController { + let sourceTypes = client.latestLoadedCapability?.availableSourceTypes(SourceType.internetBanking) let viewModel = SelectSourceTypePaymentViewModel( title: PaymentMethod.internetBanking.localizedTitle, - sourceTypes: SourceType.internetBanking, + sourceTypes: sourceTypes ?? [], delegate: self ) @@ -103,9 +105,10 @@ class ChoosePaymentCoordinator: NSObject, ViewAttachable { /// Creates Installement screen and attach current flow object inside created controller to be deallocated together func createInstallmentController() -> SelectPaymentController { + let sourceTypes = client.latestLoadedCapability?.availableSourceTypes(SourceType.installments) let viewModel = SelectSourceTypePaymentViewModel( title: PaymentMethod.installment.localizedTitle, - sourceTypes: SourceType.installments, + sourceTypes: sourceTypes ?? [], delegate: self ) From 1c6ac534ae7702d1188596322b2e1d92aa81b545 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Sat, 16 Mar 2024 18:50:20 +0700 Subject: [PATCH 194/204] Fix unit tests --- OmiseSDK/Sources/OmiseAPI/Client.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/OmiseSDK/Sources/OmiseAPI/Client.swift b/OmiseSDK/Sources/OmiseAPI/Client.swift index 54fbab03..7301d664 100644 --- a/OmiseSDK/Sources/OmiseAPI/Client.swift +++ b/OmiseSDK/Sources/OmiseAPI/Client.swift @@ -83,3 +83,10 @@ class Client: ClientProtocol { ) } } + +// For Unit Testing +extension Client { + func setLatestLoadedCapability(_ capability: Capability?) { + latestLoadedCapability = capability + } +} From 5f270eeabe988a4e6d4460a9edca7bd1bd845a87 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Wed, 20 Mar 2024 12:31:38 +0700 Subject: [PATCH 195/204] Custom Credit Card form dismiss is fixed --- ExampleApp/Views/ProductDetailViewController.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ExampleApp/Views/ProductDetailViewController.swift b/ExampleApp/Views/ProductDetailViewController.swift index ecba3729..40e6e8ed 100644 --- a/ExampleApp/Views/ProductDetailViewController.swift +++ b/ExampleApp/Views/ProductDetailViewController.swift @@ -85,7 +85,7 @@ extension ProductDetailViewController: AuthorizingPaymentViewControllerDelegate extension ProductDetailViewController: CustomCreditCardPaymentControllerDelegate { func creditCardFormViewController(_ controller: CustomCreditCardPaymentController, didSucceedWithToken token: Token) { - omiseSDK.dismiss { + dismissForm { let alertController = UIAlertController( title: "Token Created", message: "A token with id of \(token.id) was successfully created. Please send this id to server to create a charge.", @@ -98,7 +98,7 @@ extension ProductDetailViewController: CustomCreditCardPaymentControllerDelegate } func creditCardFormViewController(_ controller: CustomCreditCardPaymentController, didFailWithError error: Error) { - omiseSDK.dismiss { + dismissForm { let alertController = UIAlertController( title: "Error", message: error.localizedDescription, From c3db3fd1afe590cb7fcee8229ce7505e88459d7b Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Wed, 20 Mar 2024 12:38:13 +0700 Subject: [PATCH 196/204] Credit Card's address labels dark mode text color is fixed --- .../Credit Card Payment/CreditCardPaymentController.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift index 737d2d18..eccd459f 100644 --- a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift +++ b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift @@ -281,6 +281,8 @@ class CreditCardPaymentController: UIViewController { } addressStackView.isHiddenInStackView = !viewModel.isAddressFieldsVisible updateSupplementaryUI() + applyPrimaryColor() + applySecondaryColor() } private func setupCountryField() { @@ -584,7 +586,6 @@ class CreditCardPaymentController: UIViewController { input.textColor = UIColor.omisePrimary } } - } func applySecondaryColor() { From 2a4ef0e5510444f41323154f4a50424018502cc5 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Wed, 20 Mar 2024 12:41:51 +0700 Subject: [PATCH 197/204] Fix FPX email text color --- .../Other Payments/FPX/FPXPaymentFormController.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/FPX/FPXPaymentFormController.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/FPX/FPXPaymentFormController.swift index cf052514..7f69d5da 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/FPX/FPXPaymentFormController.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/Other Payments/FPX/FPXPaymentFormController.swift @@ -94,6 +94,7 @@ class FPXPaymentFormController: UIViewController, PaymentFormUIController { object: nil ) + emailTextField.textColor = UIColor.omisePrimary emailTextField.validator = try? NSRegularExpression(pattern: "\\A[\\w.+-]+@[a-z\\d.-]+\\.[a-z]{2,}\\z", options: [.caseInsensitive]) // check for 1st time From bd49cfffc5c9a3e5e293d9e95252358c1948a1d8 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Wed, 20 Mar 2024 12:45:00 +0700 Subject: [PATCH 198/204] Add debug output to console for Source and Token Id's in ExampleApp --- .../Views/ProductDetailViewController.swift | 62 ++++++++++--------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/ExampleApp/Views/ProductDetailViewController.swift b/ExampleApp/Views/ProductDetailViewController.swift index 40e6e8ed..b6e25947 100644 --- a/ExampleApp/Views/ProductDetailViewController.swift +++ b/ExampleApp/Views/ProductDetailViewController.swift @@ -81,39 +81,10 @@ extension ProductDetailViewController: AuthorizingPaymentViewControllerDelegate } } -// MARK: - Custom Credit Card Form View Controller Delegate - -extension ProductDetailViewController: CustomCreditCardPaymentControllerDelegate { - func creditCardFormViewController(_ controller: CustomCreditCardPaymentController, didSucceedWithToken token: Token) { - dismissForm { - let alertController = UIAlertController( - title: "Token Created", - message: "A token with id of \(token.id) was successfully created. Please send this id to server to create a charge.", - preferredStyle: .alert - ) - let okAction = UIAlertAction(title: "OK", style: .cancel, handler: nil) - alertController.addAction(okAction) - self.present(alertController, animated: true, completion: nil) - } - } - - func creditCardFormViewController(_ controller: CustomCreditCardPaymentController, didFailWithError error: Error) { - dismissForm { - let alertController = UIAlertController( - title: "Error", - message: error.localizedDescription, - preferredStyle: .alert - ) - let okAction = UIAlertAction(title: "OK", style: .cancel, handler: nil) - alertController.addAction(okAction) - self.present(alertController, animated: true, completion: nil) - } - } -} - /// Processing result of choosing Payment Method screen extension ProductDetailViewController: ChoosePaymentMethodDelegate { func choosePaymentMethodDidComplete(with source: Source) { + print("Source is created with id '\(source.id)'") omiseSDK.dismiss { let alertController = UIAlertController( title: "Source Created\n(\(source.paymentInformation.sourceType.rawValue))", @@ -127,6 +98,7 @@ extension ProductDetailViewController: ChoosePaymentMethodDelegate { } func choosePaymentMethodDidComplete(with token: Token) { + print("Token is created with id '\(token.id)'") omiseSDK.dismiss { let alertController = UIAlertController( title: "Token Created", @@ -152,3 +124,33 @@ extension ProductDetailViewController: ChoosePaymentMethodDelegate { omiseSDK.dismiss() } } + +// MARK: - Custom Credit Card Form View Controller Delegate +extension ProductDetailViewController: CustomCreditCardPaymentControllerDelegate { + func creditCardFormViewController(_ controller: CustomCreditCardPaymentController, didSucceedWithToken token: Token) { + print("Token is created by using custom form with id '\(token.id)'") + dismissForm { + let alertController = UIAlertController( + title: "Token Created", + message: "A token with id of \(token.id) was successfully created. Please send this id to server to create a charge.", + preferredStyle: .alert + ) + let okAction = UIAlertAction(title: "OK", style: .cancel, handler: nil) + alertController.addAction(okAction) + self.present(alertController, animated: true, completion: nil) + } + } + + func creditCardFormViewController(_ controller: CustomCreditCardPaymentController, didFailWithError error: Error) { + dismissForm { + let alertController = UIAlertController( + title: "Error", + message: error.localizedDescription, + preferredStyle: .alert + ) + let okAction = UIAlertAction(title: "OK", style: .cancel, handler: nil) + alertController.addAction(okAction) + self.present(alertController, animated: true, completion: nil) + } + } +} From 39ab641f9cb7c586136c061276b5b21bd462a133 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Wed, 20 Mar 2024 13:33:28 +0700 Subject: [PATCH 199/204] Update Authorized controller interface and add Custom Scheme to Example App to handle deeplinking --- ExampleApp/AppDeeplink.swift | 13 +++++++++ ExampleApp/AppDelegate.swift | 28 +++++++++++++++++++ ExampleApp/Info.plist | 13 +++++++++ .../Views/ProductDetailViewController.swift | 7 +++-- OmiseSDK/Sources/OmiseSDK.swift | 17 +++++++++-- dev.xcodeproj/project.pbxproj | 4 +++ 6 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 ExampleApp/AppDeeplink.swift diff --git a/ExampleApp/AppDeeplink.swift b/ExampleApp/AppDeeplink.swift new file mode 100644 index 00000000..2e06244e --- /dev/null +++ b/ExampleApp/AppDeeplink.swift @@ -0,0 +1,13 @@ +import Foundation + +enum AppDeeplink: String { + case threeDSChallenge = "omise_3ds_challenge" + + var scheme: String { + "omiseExampleApp" + } + + var url: URL? { + URL(string: "\(scheme)://\(rawValue)") + } +} diff --git a/ExampleApp/AppDelegate.swift b/ExampleApp/AppDelegate.swift index 6838358f..d4d2c054 100644 --- a/ExampleApp/AppDelegate.swift +++ b/ExampleApp/AppDelegate.swift @@ -1,4 +1,5 @@ import UIKit +import OmiseSDK @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { @@ -9,4 +10,31 @@ class AppDelegate: UIResponder, UIApplicationDelegate { return true } + + func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool { + // Determine who sent the URL. + print("App open url '\(url)'") + + let sendingAppID = options[.sourceApplication] + print("source application = \(sendingAppID ?? "Unknown")") + + // Process the URL. + guard let components = NSURLComponents(url: url, resolvingAgainstBaseURL: true) else { + print("Invalid url") + return false + } + + switch components.host { + case AppDeeplink.threeDSChallenge.rawValue: + print("Omise 3DS Challenge Callback") + let result = OmiseSDK.shared.handleURLCallback(url) + if result { + OmiseSDK.shared.dismiss() + } + return result + default: + print("Unknown deeplink params \(url.host ?? "nil")") + return false + } + } } diff --git a/ExampleApp/Info.plist b/ExampleApp/Info.plist index 6f460e04..6a9bc8d5 100644 --- a/ExampleApp/Info.plist +++ b/ExampleApp/Info.plist @@ -37,5 +37,18 @@ UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortraitUpsideDown + CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLName + co.omise.ExampleApp + CFBundleURLSchemes + + omiseExampleApp + + + diff --git a/ExampleApp/Views/ProductDetailViewController.swift b/ExampleApp/Views/ProductDetailViewController.swift index b6e25947..90461aff 100644 --- a/ExampleApp/Views/ProductDetailViewController.swift +++ b/ExampleApp/Views/ProductDetailViewController.swift @@ -55,12 +55,13 @@ class ProductDetailViewController: BaseViewController { let textField = alertController.textFields?.first, let text = textField.text, let url = URL(string: text), - let expectedReturnURL = URLComponents(string: "https://opn.ooo/") else { return } + let deeplinkRedirectURL = AppDeeplink.threeDSChallenge.url, + let webRedirectURL = URL(string: "https://exampleapp.opn.ooo") else { return } self.omiseSDK.presentAuthorizingPayment( from: self, authorizeURL: url, - expectedReturnURLPatterns: [expectedReturnURL], + returnURL: [deeplinkRedirectURL, webRedirectURL], delegate: self ) }) @@ -72,7 +73,7 @@ class ProductDetailViewController: BaseViewController { extension ProductDetailViewController: AuthorizingPaymentViewControllerDelegate { func authorizingPaymentViewController(_ viewController: AuthorizingPaymentViewController, didCompleteAuthorizingPaymentWithRedirectedURL redirectedURL: URL) { - print(redirectedURL) + print("Payment is authorized with redirect url `\(redirectedURL)`") omiseSDK.dismiss() } diff --git a/OmiseSDK/Sources/OmiseSDK.swift b/OmiseSDK/Sources/OmiseSDK.swift index 152fee16..559b130a 100644 --- a/OmiseSDK/Sources/OmiseSDK.swift +++ b/OmiseSDK/Sources/OmiseSDK.swift @@ -44,6 +44,8 @@ public class OmiseSDK { public private(set) weak var presentedViewController: UIViewController? + private var handleURLs: [URL] = [] + /// Creates a new instance of Omise SDK that provides interface to functionallity that SDK provides /// /// - Parameters: @@ -165,14 +167,19 @@ public class OmiseSDK { from topViewController: UIViewController, animated: Bool = true, authorizeURL: URL, - expectedReturnURLPatterns: [URLComponents], + returnURL: [URL], delegate: AuthorizingPaymentViewControllerDelegate ) { dismiss(animated: false) + handleURLs = returnURL + let returnURLComponents = returnURL.compactMap { + URLComponents(url: $0, resolvingAgainstBaseURL: false) + } + let viewController = AuthorizingPaymentViewController(nibName: nil, bundle: .omiseSDK) viewController.authorizeURL = authorizeURL - viewController.expectedReturnURLPatterns = expectedReturnURLPatterns + viewController.expectedReturnURLPatterns = returnURLComponents viewController.delegate = delegate viewController.applyNavigationBarStyle() viewController.title = "AuthorizingPayment.title".localized() @@ -194,6 +201,12 @@ public class OmiseSDK { guard let presentedViewController = presentedViewController else { return } presentedViewController.dismiss(animated: animated, completion: completion) } + + /// Handle URL Callback received by AppDelegate + public func handleURLCallback(_ url: URL) -> Bool { + // Will handle callback with 3ds library + return handleURLs.contains(url) + } } private extension OmiseSDK { diff --git a/dev.xcodeproj/project.pbxproj b/dev.xcodeproj/project.pbxproj index 7634500a..cfa6a62e 100644 --- a/dev.xcodeproj/project.pbxproj +++ b/dev.xcodeproj/project.pbxproj @@ -87,6 +87,7 @@ 756C8F262A40698600D53059 /* TextFieldView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 756C8F252A40698600D53059 /* TextFieldView.swift */; }; 757B0A742AD71E3100DEAE8F /* OmiseUnitTestKit in Frameworks */ = {isa = PBXBuildFile; productRef = 757B0A732AD71E3100DEAE8F /* OmiseUnitTestKit */; }; 757B0A752AD71E3100DEAE8F /* OmiseUnitTestKit in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 757B0A732AD71E3100DEAE8F /* OmiseUnitTestKit */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; + 7588011E2BAAB37C00F02934 /* AppDeeplink.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7588011D2BAAB37C00F02934 /* AppDeeplink.swift */; }; 759856242A286C880087B605 /* UIScrollView+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 759856232A286C880087B605 /* UIScrollView+Helpers.swift */; }; 759C7EC02B7DC7F50029D555 /* SourceType+MobileBanking.swift in Sources */ = {isa = PBXBuildFile; fileRef = 759C7EBF2B7DC7F50029D555 /* SourceType+MobileBanking.swift */; }; 759C7EC22B7DC80A0029D555 /* SourceType+InternetBanking.swift in Sources */ = {isa = PBXBuildFile; fileRef = 759C7EC12B7DC80A0029D555 /* SourceType+InternetBanking.swift */; }; @@ -333,6 +334,7 @@ 756C8F252A40698600D53059 /* TextFieldView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextFieldView.swift; sourceTree = ""; }; 757B0A712AD71D7B00DEAE8F /* OmiseSwiftUIKit */ = {isa = PBXFileReference; lastKnownFileType = text; name = OmiseSwiftUIKit; path = Helpers/OmiseSwiftUIKit; sourceTree = SOURCE_ROOT; }; 757B0A722AD71DCD00DEAE8F /* OmiseUnitTestKit */ = {isa = PBXFileReference; lastKnownFileType = text; name = OmiseUnitTestKit; path = Helpers/OmiseUnitTestKit; sourceTree = SOURCE_ROOT; }; + 7588011D2BAAB37C00F02934 /* AppDeeplink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDeeplink.swift; sourceTree = ""; }; 759856232A286C880087B605 /* UIScrollView+Helpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIScrollView+Helpers.swift"; sourceTree = ""; }; 759C7EBF2B7DC7F50029D555 /* SourceType+MobileBanking.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SourceType+MobileBanking.swift"; sourceTree = ""; }; 759C7EC12B7DC80A0029D555 /* SourceType+InternetBanking.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SourceType+InternetBanking.swift"; sourceTree = ""; }; @@ -531,6 +533,7 @@ 75DAD8922A0BC9540098AF96 /* Config.local.plist */, 22D480AB1D0EB29C00544CE1 /* Info.plist */, 229E14541D0EBAB5000511DE /* AppDelegate.swift */, + 7588011D2BAAB37C00F02934 /* AppDeeplink.swift */, 8A723A672164D80200D902F5 /* Views */, 8AB3B85F216DCF5C006497B5 /* Models */, ); @@ -1480,6 +1483,7 @@ buildActionMask = 2147483647; files = ( 8A40DA29216B441E00749F45 /* PaymentSettingTableViewController.swift in Sources */, + 7588011E2BAAB37C00F02934 /* AppDeeplink.swift in Sources */, 229E14581D0EBAB5000511DE /* AppDelegate.swift in Sources */, 8A40DA2B216B53E900749F45 /* Tools.swift in Sources */, 229E145A1D0EBAB5000511DE /* ProductDetailViewController.swift in Sources */, From 83cee97d6406d2940d73a9047f259c3901589fac Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Wed, 20 Mar 2024 14:49:22 +0700 Subject: [PATCH 200/204] Change returnURL type from URL to String pattern --- ExampleApp/AppDeeplink.swift | 8 ++++-- .../Views/ProductDetailViewController.swift | 8 +++--- OmiseSDK/Sources/OmiseSDK.swift | 18 ++++++++----- .../ToolKit/Extensions/URL+Helpers.swift | 26 +++++++++++++++++++ .../AuthorizingPaymentViewController.swift | 4 +-- README.md | 2 +- dev.xcodeproj/project.pbxproj | 4 +++ 7 files changed, 54 insertions(+), 16 deletions(-) create mode 100644 OmiseSDK/Sources/ToolKit/Extensions/URL+Helpers.swift diff --git a/ExampleApp/AppDeeplink.swift b/ExampleApp/AppDeeplink.swift index 2e06244e..57562938 100644 --- a/ExampleApp/AppDeeplink.swift +++ b/ExampleApp/AppDeeplink.swift @@ -1,13 +1,17 @@ import Foundation enum AppDeeplink: String { - case threeDSChallenge = "omise_3ds_challenge" + case threeDSChallenge = "3ds_challenge" var scheme: String { "omiseExampleApp" } + var urlString: String { + "\(scheme)://\(rawValue)" + } + var url: URL? { - URL(string: "\(scheme)://\(rawValue)") + URL(string: urlString) } } diff --git a/ExampleApp/Views/ProductDetailViewController.swift b/ExampleApp/Views/ProductDetailViewController.swift index 90461aff..0c2e9d27 100644 --- a/ExampleApp/Views/ProductDetailViewController.swift +++ b/ExampleApp/Views/ProductDetailViewController.swift @@ -54,14 +54,14 @@ class ProductDetailViewController: BaseViewController { guard let self = self, let textField = alertController.textFields?.first, let text = textField.text, - let url = URL(string: text), - let deeplinkRedirectURL = AppDeeplink.threeDSChallenge.url, - let webRedirectURL = URL(string: "https://exampleapp.opn.ooo") else { return } + let url = URL(string: text) else { return } + let deeplinkRedirectURLPattern = AppDeeplink.threeDSChallenge.urlString + let webRedirectURLPattern = "https://exampleapp.opn.ooo" self.omiseSDK.presentAuthorizingPayment( from: self, authorizeURL: url, - returnURL: [deeplinkRedirectURL, webRedirectURL], + returnURLs: [deeplinkRedirectURLPattern, webRedirectURLPattern], delegate: self ) }) diff --git a/OmiseSDK/Sources/OmiseSDK.swift b/OmiseSDK/Sources/OmiseSDK.swift index 559b130a..63d80edd 100644 --- a/OmiseSDK/Sources/OmiseSDK.swift +++ b/OmiseSDK/Sources/OmiseSDK.swift @@ -44,7 +44,7 @@ public class OmiseSDK { public private(set) weak var presentedViewController: UIViewController? - private var handleURLs: [URL] = [] + private var handleURLs: [String] = [] /// Creates a new instance of Omise SDK that provides interface to functionallity that SDK provides /// @@ -167,14 +167,14 @@ public class OmiseSDK { from topViewController: UIViewController, animated: Bool = true, authorizeURL: URL, - returnURL: [URL], + returnURLs: [String], delegate: AuthorizingPaymentViewControllerDelegate ) { dismiss(animated: false) - handleURLs = returnURL - let returnURLComponents = returnURL.compactMap { - URLComponents(url: $0, resolvingAgainstBaseURL: false) + handleURLs = returnURLs + let returnURLComponents = returnURLs.compactMap { + URLComponents(string: $0) } let viewController = AuthorizingPaymentViewController(nibName: nil, bundle: .omiseSDK) @@ -205,7 +205,13 @@ public class OmiseSDK { /// Handle URL Callback received by AppDelegate public func handleURLCallback(_ url: URL) -> Bool { // Will handle callback with 3ds library - return handleURLs.contains(url) + let containsURL = handleURLs + .map { + url.match(string: $0) + } + .contains(true) + + return containsURL } } diff --git a/OmiseSDK/Sources/ToolKit/Extensions/URL+Helpers.swift b/OmiseSDK/Sources/ToolKit/Extensions/URL+Helpers.swift new file mode 100644 index 00000000..ab34e49d --- /dev/null +++ b/OmiseSDK/Sources/ToolKit/Extensions/URL+Helpers.swift @@ -0,0 +1,26 @@ +import Foundation + +extension URL { + func match(string: String) -> Bool { + guard + let expectedURLComponents = URLComponents(string: string), + let components = URLComponents(url: self, resolvingAgainstBaseURL: false) else { + return false + } + + return expectedURLComponents.match(components: components) + } +} + +extension URLComponents { + func match(string: String) -> Bool { + guard let expectedURLComponents = URLComponents(string: string) else { return false } + return match(components: expectedURLComponents) + } + + func match(components expectedURLComponents: URLComponents) -> Bool { + return expectedURLComponents.scheme?.lowercased() == scheme?.lowercased() + && expectedURLComponents.host?.lowercased() == host?.lowercased() + && path.lowercased().hasPrefix(expectedURLComponents.path.lowercased()) + } +} diff --git a/OmiseSDK/Sources/Views/Screens/Authorizing Payment/AuthorizingPaymentViewController.swift b/OmiseSDK/Sources/Views/Screens/Authorizing Payment/AuthorizingPaymentViewController.swift index 831e0bad..e0016ac6 100644 --- a/OmiseSDK/Sources/Views/Screens/Authorizing Payment/AuthorizingPaymentViewController.swift +++ b/OmiseSDK/Sources/Views/Screens/Authorizing Payment/AuthorizingPaymentViewController.swift @@ -99,9 +99,7 @@ public class AuthorizingPaymentViewController: UIViewController { } return expectedReturnURLPatterns.contains { expectedURLComponents -> Bool in - return expectedURLComponents.scheme == components.scheme - && expectedURLComponents.host == components.host - && components.path.hasPrefix(expectedURLComponents.path) + components.match(components: expectedURLComponents) } } diff --git a/README.md b/README.md index 2f6e587c..ee226795 100644 --- a/README.md +++ b/README.md @@ -344,7 +344,7 @@ You can use the built-in authorizing payment view controller with the `authorize omiseSDK.presentAuthorizingPayment( from: self, authorizeURL: url, - expectedReturnURLPatterns: [expectedReturnURL], + returnURLs: [returnURLs], delegate: self ) ``` diff --git a/dev.xcodeproj/project.pbxproj b/dev.xcodeproj/project.pbxproj index cfa6a62e..97b51833 100644 --- a/dev.xcodeproj/project.pbxproj +++ b/dev.xcodeproj/project.pbxproj @@ -88,6 +88,7 @@ 757B0A742AD71E3100DEAE8F /* OmiseUnitTestKit in Frameworks */ = {isa = PBXBuildFile; productRef = 757B0A732AD71E3100DEAE8F /* OmiseUnitTestKit */; }; 757B0A752AD71E3100DEAE8F /* OmiseUnitTestKit in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 757B0A732AD71E3100DEAE8F /* OmiseUnitTestKit */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 7588011E2BAAB37C00F02934 /* AppDeeplink.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7588011D2BAAB37C00F02934 /* AppDeeplink.swift */; }; + 758801202BAAC70200F02934 /* URL+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7588011F2BAAC70200F02934 /* URL+Helpers.swift */; }; 759856242A286C880087B605 /* UIScrollView+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 759856232A286C880087B605 /* UIScrollView+Helpers.swift */; }; 759C7EC02B7DC7F50029D555 /* SourceType+MobileBanking.swift in Sources */ = {isa = PBXBuildFile; fileRef = 759C7EBF2B7DC7F50029D555 /* SourceType+MobileBanking.swift */; }; 759C7EC22B7DC80A0029D555 /* SourceType+InternetBanking.swift in Sources */ = {isa = PBXBuildFile; fileRef = 759C7EC12B7DC80A0029D555 /* SourceType+InternetBanking.swift */; }; @@ -335,6 +336,7 @@ 757B0A712AD71D7B00DEAE8F /* OmiseSwiftUIKit */ = {isa = PBXFileReference; lastKnownFileType = text; name = OmiseSwiftUIKit; path = Helpers/OmiseSwiftUIKit; sourceTree = SOURCE_ROOT; }; 757B0A722AD71DCD00DEAE8F /* OmiseUnitTestKit */ = {isa = PBXFileReference; lastKnownFileType = text; name = OmiseUnitTestKit; path = Helpers/OmiseUnitTestKit; sourceTree = SOURCE_ROOT; }; 7588011D2BAAB37C00F02934 /* AppDeeplink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDeeplink.swift; sourceTree = ""; }; + 7588011F2BAAC70200F02934 /* URL+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URL+Helpers.swift"; sourceTree = ""; }; 759856232A286C880087B605 /* UIScrollView+Helpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIScrollView+Helpers.swift"; sourceTree = ""; }; 759C7EBF2B7DC7F50029D555 /* SourceType+MobileBanking.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SourceType+MobileBanking.swift"; sourceTree = ""; }; 759C7EC12B7DC80A0029D555 /* SourceType+InternetBanking.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SourceType+InternetBanking.swift"; sourceTree = ""; }; @@ -671,6 +673,7 @@ 75405A772A25D327008C21F6 /* String+Helpers.swift */, 75405A7B2A25EC88008C21F6 /* Array+Helpers.swift */, 75D13DD72B86539C0073A831 /* Optional+Helpers.swift */, + 7588011F2BAAC70200F02934 /* URL+Helpers.swift */, ); path = Extensions; sourceTree = ""; @@ -1399,6 +1402,7 @@ 751E7BEE2B7F7DD20031B4A2 /* PaymentMethod+ViewPresentable.swift in Sources */, 75D13D772B833C200073A831 /* UITableViewCell+ActivityIndicator.swift in Sources */, 986406311CFEA7E4004BCF51 /* CardExpiryDateTextField.swift in Sources */, + 758801202BAAC70200F02934 /* URL+Helpers.swift in Sources */, 756C8F262A40698600D53059 /* TextFieldView.swift in Sources */, 986406341CFEA7E4004BCF51 /* CardNameTextField.swift in Sources */, 8AF9857121479F38007E18ED /* CCVInfoController.swift in Sources */, From ff4b043b95244554c43cc28e6f0f27af41c83dda Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Wed, 20 Mar 2024 15:27:19 +0700 Subject: [PATCH 201/204] Remove deprecated objc files --- OmiseSDKObjc/OMSConstants.h | 71 ------------------------------------- OmiseSDKObjc/OMSConstants.m | 66 ---------------------------------- 2 files changed, 137 deletions(-) delete mode 100644 OmiseSDKObjc/OMSConstants.h delete mode 100644 OmiseSDKObjc/OMSConstants.m diff --git a/OmiseSDKObjc/OMSConstants.h b/OmiseSDKObjc/OMSConstants.h deleted file mode 100644 index ecf43853..00000000 --- a/OmiseSDKObjc/OMSConstants.h +++ /dev/null @@ -1,71 +0,0 @@ -@import Foundation; - - -typedef NSString * OMSSourceTypeValue NS_EXTENSIBLE_STRING_ENUM; - -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueInternetBankingBAY; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueInternetBankingBBL; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueMobileBankingSCB; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueMobileBankingOCBCPAO; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueMobileBankingOCBC; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueMobileBankingBAY; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueMobileBankingBBL; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueMobileBankingKTB; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueAlipay; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueAlipayCN; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueAlipayHK; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueBillPaymentTescoLotus; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueBarcodeAlipay; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueDana; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueGcash; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueInstallmentBAY; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueInstallmentFirstChoice; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueInstallmentBBL; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueInstallmentMBB; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueInstallmentKTC; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueInstallmentKBank; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueInstallmentSCB; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueInstallmentCiti; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueInstallmentTTB; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueInstallmentUOB; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueKakaoPay; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueEContext; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValuePromptPay; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValuePayNow; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueTouchNGo; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueTouchNGoAlipayPlus; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueTrueMoney; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueTrueMoneyJumpApp; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValuePointsCiti; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueFpx; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueMobileBankingKBank; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueRabbitLinepay; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueGrabPay; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueGrabPayRms; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueBoost; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueShopeePay; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueShopeePayJumpApp; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueMaybankQRPay; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueDuitNowQR; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueDuitNowOBW; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueAtome; -extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValuePayPay; - - -typedef NSString * OMSSupportedCurrencyCode NS_EXTENSIBLE_STRING_ENUM; - -extern OMSSupportedCurrencyCode const _Nonnull OMSSupportedCurrencyCodeTHB; -extern OMSSupportedCurrencyCode const _Nonnull OMSSupportedCurrencyCodeJPY; -extern OMSSupportedCurrencyCode const _Nonnull OMSSupportedCurrencyCodeIDR; -extern OMSSupportedCurrencyCode const _Nonnull OMSSupportedCurrencyCodeSGD; -extern OMSSupportedCurrencyCode const _Nonnull OMSSupportedCurrencyCodeUSD; -extern OMSSupportedCurrencyCode const _Nonnull OMSSupportedCurrencyCodeGBP; -extern OMSSupportedCurrencyCode const _Nonnull OMSSupportedCurrencyCodeEUR; -extern OMSSupportedCurrencyCode const _Nonnull OMSSupportedCurrencyCodeMYR; - -extern OMSSupportedCurrencyCode const _Nonnull OMSSupportedCurrencyCodeAUD; -extern OMSSupportedCurrencyCode const _Nonnull OMSSupportedCurrencyCodeCAD; -extern OMSSupportedCurrencyCode const _Nonnull OMSSupportedCurrencyCodeCHF; -extern OMSSupportedCurrencyCode const _Nonnull OMSSupportedCurrencyCodeCNY; -extern OMSSupportedCurrencyCode const _Nonnull OMSSupportedCurrencyCodeDKK; -extern OMSSupportedCurrencyCode const _Nonnull OMSSupportedCurrencyCodeHKD; diff --git a/OmiseSDKObjc/OMSConstants.m b/OmiseSDKObjc/OMSConstants.m deleted file mode 100644 index 5916d00e..00000000 --- a/OmiseSDKObjc/OMSConstants.m +++ /dev/null @@ -1,66 +0,0 @@ -#import "OMSConstants.h" - - -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueInternetBankingBAY = @"internet_banking_bay"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueInternetBankingBBL = @"internet_banking_bbl"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueMobileBankingSCB = @"mobile_banking_scb"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueMobileBankingOCBCPAO = @"mobile_banking_ocbc_pao"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueMobileBankingOCBC = @"mobile_banking_ocbc"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueMobileBankingKBank = @"mobile_banking_kbank"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueMobileBankingBAY = @"mobile_banking_bay"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueMobileBankingBBL = @"mobile_banking_bbl"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueMobileBankingKTB = @"mobile_banking_ktb"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueAlipay = @"alipay"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueAlipayCN = @"alipay_cn"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueAlipayHK = @"alipay_hk"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueDana = @"dana"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueGcash = @"gcash"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueKakaoPay = @"kakaopay"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueTouchNGo = @"touch_n_go"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueTouchNGoAlipayPlus = @"touch_n_go_alipay_plus"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueBillPaymentTescoLotus = @"bill_payment_tesco_lotus"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueBarcodeAlipay = @"barcode_alipay"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueInstallmentBAY = @"installment_bay"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueInstallmentFirstChoice = @"installment_first_choice"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueInstallmentBBL = @"installment_bbl"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueInstallmentMBB = @"installment_mbb"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueInstallmentKTC = @"installment_ktc"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueInstallmentKBank = @"installment_kbank"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueInstallmentSCB = @"installment_scb"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueInstallmentCiti = @"installment_citi"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueInstallmentTTB = @"installment_ttb"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueInstallmentUOB = @"installment_uob"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueEContext = @"econtext"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValuePromptPay = @"promptpay"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValuePayNow = @"paynow"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueTrueMoney = @"truemoney"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueTrueMoneyJumpApp = @"truemoney_jumpapp"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValuePointsCiti = @"points_citi"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueFpx = @"fpx"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueRabbitLinepay = @"rabbit_linepay"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueGrabPay = @"grabpay"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueGrabPayRms = @"grabpay_rms"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueBoost = @"boost"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueShopeePay = @"shopeepay"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueShopeePayJumpApp = @"shopeepay_jumpapp"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueMaybankQRPay = @"maybank_qr"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueDuitNowQR = @"duitnow_qr"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueDuitNowOBW = @"duitnow_obw"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValueAtome = @"atome"; -OMSSourceTypeValue const _Nonnull OMSSourceTypeValuePayPay = @"paypay"; - -OMSSupportedCurrencyCode const _Nonnull OMSSupportedCurrencyCodeTHB = @"THB"; -OMSSupportedCurrencyCode const _Nonnull OMSSupportedCurrencyCodeJPY = @"JPY"; -OMSSupportedCurrencyCode const _Nonnull OMSSupportedCurrencyCodeIDR = @"IDR"; -OMSSupportedCurrencyCode const _Nonnull OMSSupportedCurrencyCodeSGD = @"SGD"; -OMSSupportedCurrencyCode const _Nonnull OMSSupportedCurrencyCodeUSD = @"USD"; -OMSSupportedCurrencyCode const _Nonnull OMSSupportedCurrencyCodeGBP = @"GBP"; -OMSSupportedCurrencyCode const _Nonnull OMSSupportedCurrencyCodeEUR = @"EUR"; -OMSSupportedCurrencyCode const _Nonnull OMSSupportedCurrencyCodeMYR = @"MYR"; - -OMSSupportedCurrencyCode const _Nonnull OMSSupportedCurrencyCodeAUD = @"AUD"; -OMSSupportedCurrencyCode const _Nonnull OMSSupportedCurrencyCodeCAD = @"CAD"; -OMSSupportedCurrencyCode const _Nonnull OMSSupportedCurrencyCodeCHF = @"CHF"; -OMSSupportedCurrencyCode const _Nonnull OMSSupportedCurrencyCodeCNY = @"CNY"; -OMSSupportedCurrencyCode const _Nonnull OMSSupportedCurrencyCodeDKK = @"DKK"; -OMSSupportedCurrencyCode const _Nonnull OMSSupportedCurrencyCodeHKD = @"HKD"; From a59269f3d734ebc17d8e717b5c03b17d5d67a679 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Wed, 20 Mar 2024 15:29:08 +0700 Subject: [PATCH 202/204] Add AppDeeplink to ExampleApp --- ExampleApp.xcodeproj/project.pbxproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ExampleApp.xcodeproj/project.pbxproj b/ExampleApp.xcodeproj/project.pbxproj index 54ea45b1..3d42284b 100644 --- a/ExampleApp.xcodeproj/project.pbxproj +++ b/ExampleApp.xcodeproj/project.pbxproj @@ -19,6 +19,7 @@ 757B0A622AD713A000DEAE8F /* CustomCreditCardFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 757B0A572AD713A000DEAE8F /* CustomCreditCardFormViewController.swift */; }; 757B0A632AD713A000DEAE8F /* LocalConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 757B0A592AD713A000DEAE8F /* LocalConfig.swift */; }; 757B0A642AD713A000DEAE8F /* Tools.swift in Sources */ = {isa = PBXBuildFile; fileRef = 757B0A5A2AD713A000DEAE8F /* Tools.swift */; }; + 758801222BAAD5BA00F02934 /* AppDeeplink.swift in Sources */ = {isa = PBXBuildFile; fileRef = 758801212BAAD5BA00F02934 /* AppDeeplink.swift */; }; 75A6BD2A2B3D2A0D005D9B77 /* OmiseSDK in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 7558BBDF2AE24CD80035CD99 /* OmiseSDK */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 75C2E2292AD712F1008584C0 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75C2E2282AD712F1008584C0 /* AppDelegate.swift */; }; /* End PBXBuildFile section */ @@ -51,6 +52,7 @@ 757B0A572AD713A000DEAE8F /* CustomCreditCardFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomCreditCardFormViewController.swift; sourceTree = ""; }; 757B0A592AD713A000DEAE8F /* LocalConfig.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LocalConfig.swift; sourceTree = ""; }; 757B0A5A2AD713A000DEAE8F /* Tools.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Tools.swift; sourceTree = ""; }; + 758801212BAAD5BA00F02934 /* AppDeeplink.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDeeplink.swift; sourceTree = ""; }; 75C2E2252AD712F1008584C0 /* ExampleApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ExampleApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 75C2E2282AD712F1008584C0 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 75C2E2362AD712F2008584C0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -122,6 +124,7 @@ 757B0A4A2AD7139F00DEAE8F /* Resources */, 757B0A532AD713A000DEAE8F /* Views */, 75C2E2282AD712F1008584C0 /* AppDelegate.swift */, + 758801212BAAD5BA00F02934 /* AppDeeplink.swift */, 757B0A462AD7136800DEAE8F /* Config.local.plist */, 75C2E2362AD712F2008584C0 /* Info.plist */, ); @@ -211,6 +214,7 @@ buildActionMask = 2147483647; files = ( 75C2E2292AD712F1008584C0 /* AppDelegate.swift in Sources */, + 758801222BAAD5BA00F02934 /* AppDeeplink.swift in Sources */, 757B0A612AD713A000DEAE8F /* PaymentSettingTableViewController.swift in Sources */, 757B0A5F2AD713A000DEAE8F /* BaseViewController.swift in Sources */, 757B0A632AD713A000DEAE8F /* LocalConfig.swift in Sources */, From 98243bcdac3a7a51f906b87a036ec7d069ae27ec Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Thu, 21 Mar 2024 09:57:21 +0700 Subject: [PATCH 203/204] Cleanup unused files --- .vscode/settings.json | 3 --- .../project.xcworkspace/xcshareddata/swiftpm/Package.resolved | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 5bdb7e50..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "editor.inlayHints.fontSize": 12 -} \ No newline at end of file diff --git a/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index b4467c45..7df1b24a 100644 --- a/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -6,7 +6,7 @@ "location" : "https://github.com/omise/omise-ios.git", "state" : { "branch" : "feature/v5_refactoring", - "revision" : "987171818f6b6669e9859c1fba306be20704e05c" + "revision" : "a59269f3d734ebc17d8e717b5c03b17d5d67a679" } } ], From 4fff96be3cf9d904baf0bcb2a954573d162a6bdf Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Fri, 22 Mar 2024 12:32:34 +0700 Subject: [PATCH 204/204] Update currentAmount in Settings of ExampleApp. Fix text color for EContext screen --- ExampleApp/Models/Tools.swift | 10 ++-- ExampleApp/Resources/Main.storyboard | 2 +- .../PaymentSettingTableViewController.swift | 54 +++++++++++++++---- .../EContextPaymentFormController.swift | 4 ++ 4 files changed, 55 insertions(+), 15 deletions(-) diff --git a/ExampleApp/Models/Tools.swift b/ExampleApp/Models/Tools.swift index ef4bf806..296f8aa7 100644 --- a/ExampleApp/Models/Tools.swift +++ b/ExampleApp/Models/Tools.swift @@ -7,31 +7,31 @@ struct PaymentPreset { var allowedPaymentMethods: [SourceType] static let allPreset = PaymentPreset( - paymentAmount: 5_000_00, + paymentAmount: 3_500_00, paymentCurrency: .thb, allowedPaymentMethods: SourceType.allCases ) static let thailandPreset = PaymentPreset( - paymentAmount: 5_000_00, + paymentAmount: 3_500_00, paymentCurrency: .thb, allowedPaymentMethods: SourceType.availableByDefaultInThailand ) static let japanPreset = PaymentPreset( - paymentAmount: 5_000, + paymentAmount: 3_500, paymentCurrency: .jpy, allowedPaymentMethods: SourceType.availableByDefaultInJapan ) static let singaporePreset = PaymentPreset( - paymentAmount: 5_000_00, + paymentAmount: 3_500_00, paymentCurrency: .sgd, allowedPaymentMethods: SourceType.availableByDefaultSingapore ) static let malaysiaPreset = PaymentPreset( - paymentAmount: 5_000_00, + paymentAmount: 3_500_00, paymentCurrency: .myr, allowedPaymentMethods: SourceType.availableByDefaultMalaysia ) diff --git a/ExampleApp/Resources/Main.storyboard b/ExampleApp/Resources/Main.storyboard index 7c720226..df09a1f8 100644 --- a/ExampleApp/Resources/Main.storyboard +++ b/ExampleApp/Resources/Main.storyboard @@ -31,7 +31,7 @@