From f8e93b09e10689b6614204369e6d7d20bc916cfe Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Tue, 14 May 2024 15:35:07 +0700 Subject: [PATCH] Add white-label installments: BAY, FirstChoice, TTB --- .../Views/ProductDetailViewController.swift | 2 +- .../Resources/en.lproj/Localizable.strings | 3 + .../Resources/ja.lproj/Localizable.strings | 3 + .../Source/Source.Payment.Installment.swift | 24 +++- .../SourceType/SourceType+Installments.swift | 5 +- .../OmiseAPI/SourceType/SourceType.swift | 6 + .../ChoosePaymentCoordinator+Helpers.swift | 6 +- .../ChoosePaymentCoordinator.swift | 5 +- .../SourceType+ViewPresentable.swift | 105 +----------------- .../CreditCardPaymentController.swift | 1 + 10 files changed, 50 insertions(+), 110 deletions(-) diff --git a/ExampleApp/Views/ProductDetailViewController.swift b/ExampleApp/Views/ProductDetailViewController.swift index 351f9d58..112707c1 100644 --- a/ExampleApp/Views/ProductDetailViewController.swift +++ b/ExampleApp/Views/ProductDetailViewController.swift @@ -128,7 +128,7 @@ extension ProductDetailViewController: ChoosePaymentMethodDelegate { print("White-label installment payment Token is created with id '\(token.id)', Source id: '\(source.id)'") omiseSDK.dismiss { let alertController = UIAlertController( - title: "Token & Source Created", + title: "Token & Source Created\n(\(source.paymentInformation.sourceType.rawValue))", message: "A token with id of \(token.id) and source with id of \(source.id) was successfully created. Please send this id to server to create a charge.", preferredStyle: .alert ) diff --git a/OmiseSDK/Resources/en.lproj/Localizable.strings b/OmiseSDK/Resources/en.lproj/Localizable.strings index df971010..c28e3cae 100644 --- a/OmiseSDK/Resources/en.lproj/Localizable.strings +++ b/OmiseSDK/Resources/en.lproj/Localizable.strings @@ -24,6 +24,9 @@ "SourceType.installment_wlb_kbank" = "Kasikorn Bank"; "SourceType.installment_wlb_scb" = "Siam Commercial Bank"; "SourceType.installment_wlb_bbl" = "Bangkok Bank"; +"SourceType.installment_wlb_bay" = "Krungsri"; +"SourceType.installment_wlb_first_choice" = "Krungsri First Choice"; +"SourceType.installment_wlb_ttb" = "TMBThanachart Bank"; "SourceType.internet_banking_bay" = "Bank of Ayudhya"; "SourceType.internet_banking_bbl" = "Bangkok Bank"; "SourceType.paynow" = "PayNow"; diff --git a/OmiseSDK/Resources/ja.lproj/Localizable.strings b/OmiseSDK/Resources/ja.lproj/Localizable.strings index f7f02067..85ab2bf8 100644 --- a/OmiseSDK/Resources/ja.lproj/Localizable.strings +++ b/OmiseSDK/Resources/ja.lproj/Localizable.strings @@ -24,6 +24,9 @@ "SourceType.installment_wlb_kbank" = "カシコン銀行"; "SourceType.installment_wlb_scb" = "サイアム・コマーシャル銀行"; "SourceType.installment_wlb_bbl" = "バンコク銀行"; +"SourceType.installment_wlb_bay" = "クルンシィ"; +"SourceType.installment_wlb_first_choice" = "クルンシィ・ファーストチョイス"; +"SourceType.installment_wlb_ttb" = "TMBタナチャート銀行"; "SourceType.internet_banking_bay" = "アユタヤ銀行"; "SourceType.internet_banking_bbl" = "バンコク銀行"; "SourceType.paynow" = "PayNow"; diff --git a/OmiseSDK/Sources/OmiseAPI/JSON Models/Source/Source.Payment.Installment.swift b/OmiseSDK/Sources/OmiseAPI/JSON Models/Source/Source.Payment.Installment.swift index c08800a5..367d69db 100644 --- a/OmiseSDK/Sources/OmiseAPI/JSON Models/Source/Source.Payment.Installment.swift +++ b/OmiseSDK/Sources/OmiseAPI/JSON Models/Source/Source.Payment.Installment.swift @@ -28,21 +28,35 @@ extension Source.Payment.Installment { public static func availableTerms(for sourceType: SourceType) -> [Int] { switch sourceType { case .installmentBAY: + return [ 3, 4, 6, 10 ] + case .installmentWhiteLabelBAY: return [ 3, 4, 6, 9, 10 ] case .installmentFirstChoice: + return [ 3, 4, 6, 10, 12, 18, 24, 36 ] + case .installmentWhiteLabelFirstChoice: return [ 3, 4, 6, 9, 10, 12, 18, 24, 36 ] - case .installmentBBL, .installmentWhiteLabelBBL: - return [ 4, 6, 8, 9, 10 ] + case .installmentBBL: + return [ 4, 6, 8, 10 ] + case .installmentWhiteLabelBBL: + return [ 4, 6, 8, 10 ] case .installmentMBB: return [ 6, 12, 18, 24 ] - case .installmentKTC, .installmentWhiteLabelKTC: + case .installmentKTC: + return [ 3, 4, 5, 6, 7, 8, 9, 10 ] + case .installmentWhiteLabelKTC: return [ 3, 4, 5, 6, 7, 8, 9, 10 ] - case .installmentKBank, .installmentWhiteLabelKBank: + case .installmentKBank: return [ 3, 4, 6, 10 ] - case .installmentSCB, .installmentWhiteLabelSCB: + case .installmentWhiteLabelKBank: + return [ 3, 6, 10 ] + case .installmentSCB: + return [ 3, 4, 6, 9, 10 ] + case .installmentWhiteLabelSCB: return [ 3, 4, 6, 9, 10 ] case .installmentTTB: return [ 3, 4, 6, 10, 12 ] + case .installmentWhiteLabelTTB: + return [ 4, 6, 10 ] case .installmentUOB: return [ 3, 4, 6, 10 ] default: diff --git a/OmiseSDK/Sources/OmiseAPI/SourceType/SourceType+Installments.swift b/OmiseSDK/Sources/OmiseAPI/SourceType/SourceType+Installments.swift index 7e25b8da..4c1598ab 100644 --- a/OmiseSDK/Sources/OmiseAPI/SourceType/SourceType+Installments.swift +++ b/OmiseSDK/Sources/OmiseAPI/SourceType/SourceType+Installments.swift @@ -20,7 +20,10 @@ extension SourceType { .installmentWhiteLabelKTC, .installmentWhiteLabelKBank, .installmentWhiteLabelSCB, - .installmentWhiteLabelBBL + .installmentWhiteLabelBBL, + .installmentWhiteLabelBAY, + .installmentWhiteLabelFirstChoice, + .installmentWhiteLabelTTB ] } diff --git a/OmiseSDK/Sources/OmiseAPI/SourceType/SourceType.swift b/OmiseSDK/Sources/OmiseAPI/SourceType/SourceType.swift index 90f53565..3f043a5e 100644 --- a/OmiseSDK/Sources/OmiseAPI/SourceType/SourceType.swift +++ b/OmiseSDK/Sources/OmiseAPI/SourceType/SourceType.swift @@ -58,6 +58,12 @@ public enum SourceType: String, Codable, CaseIterable { case installmentWhiteLabelSCB = "installment_wlb_scb" /// Bangkok Bank https://docs.opn.ooo/installment-white-label-payments case installmentWhiteLabelBBL = "installment_wlb_bbl" + /// Krungsri https://docs.opn.ooo/installment-white-label-payments + case installmentWhiteLabelBAY = "installment_wlb_bay" + /// Krungsri First Choice https://docs.opn.ooo/installment-white-label-payments + case installmentWhiteLabelFirstChoice = "installment_wlb_first_choice" + /// TMBThanachart Bank https://docs.opn.ooo/installment-white-label-payments + case installmentWhiteLabelTTB = "installment_wlb_ttb" /// Bank of Ayudhya (Krungsri) https://docs.opn.ooo/internet-banking case internetBankingBAY = "internet_banking_bay" /// Bangkok Bank https://docs.opn.ooo/internet-banking diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator+Helpers.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator+Helpers.swift index 8a1c8dfe..2d26f257 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator+Helpers.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator+Helpers.swift @@ -89,9 +89,13 @@ extension ChoosePaymentCoordinator { case .failure(let error): self?.processError(error) } - completion() } } + + DispatchQueue.main.async { + completion() + } + } } } diff --git a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator.swift b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator.swift index 80e139e9..28aaf377 100644 --- a/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator.swift +++ b/OmiseSDK/Sources/Views/Screens/Choose Payment Methods/ChoosePaymentCoordinator.swift @@ -111,7 +111,10 @@ class ChoosePaymentCoordinator: NSObject, ViewAttachable { .installmentWhiteLabelKTC: .installmentKTC, .installmentWhiteLabelKBank: .installmentKBank, .installmentWhiteLabelSCB: .installmentSCB, - .installmentWhiteLabelBBL: .installmentBBL + .installmentWhiteLabelBBL: .installmentBBL, + .installmentWhiteLabelBAY: .installmentBAY, + .installmentWhiteLabelFirstChoice: .installmentFirstChoice, + .installmentWhiteLabelTTB: .installmentTTB ] for (keepingSourceType, removingSourceType) in filter 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 0fb67c0f..a839ba24 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)") } public var localizedSubtitle: String? { @@ -14,103 +14,6 @@ extension SourceType: ViewPresentable { return localized("SourceType.\(self.rawValue).subtitle", text: subtitle) } - public var title: String { - switch self { - case .alipay: - return "Alipay" - case .alipayCN: - return "Alipay CN" - case .alipayHK: - 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 .duitNowOBW: - return "DuitNow Online Banking/Wallets" - case .duitNowQR: - return "DuitNow QR" - case .eContext: - return "" // Doesn't have specific title - case .fpx: - return "FPX" - case .gcash: - return "GCash" - case .grabPay: - return "Grab" - case .grabPayRms: - return "GrabPay" - case .installmentBAY: - return "Krungsri" - case .installmentBBL, .installmentWhiteLabelBBL: - return "Bangkok Bank" - case .installmentFirstChoice: - return "Krungsri First Choice" - case .installmentKBank, .installmentWhiteLabelKBank: - return "Kasikorn" - case .installmentKTC: - return "KTC" - case .installmentMBB: - return "MayBank" - case .installmentSCB, .installmentWhiteLabelSCB: - return "Siam Commercial Bank" - case .installmentTTB: - return "TMBThanachart Bank" - case .installmentUOB: - return "United Overseas Bank" - case .installmentWhiteLabelKTC: - return "Krungthai Card (KTC)" - 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: - return "Bualuang mBanking" - case .mobileBankingKBank: - return "K PLUS" - case .mobileBankingKTB: - return "Krungthai Next" - case .mobileBankingSCB: - return "SCB EASY" - case .ocbcDigital: - return "OCBC Digital" - case .payNow: - return "PayNow" - case .payPay: - return "PayPay" - 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 .alipay: @@ -143,11 +46,11 @@ extension SourceType: ViewPresentable { return "Grab" case .grabPayRms: return "Grab" - case .installmentBAY: + case .installmentBAY, .installmentWhiteLabelBAY: return "BAY" case .installmentBBL, .installmentWhiteLabelBBL: return "BBL" - case .installmentFirstChoice: + case .installmentFirstChoice, .installmentWhiteLabelFirstChoice: return "First Choice" case .installmentKBank, .installmentWhiteLabelKBank: return "KBANK" @@ -157,7 +60,7 @@ extension SourceType: ViewPresentable { return "FPX/maybank" case .installmentSCB, .installmentWhiteLabelSCB: return "SCB" - case .installmentTTB: + case .installmentTTB, .installmentWhiteLabelTTB: return "ttb" case .installmentUOB: return "uob" diff --git a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift index eccd459f..fab1dcbb 100644 --- a/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift +++ b/OmiseSDK/Sources/Views/Screens/Credit Card Payment/CreditCardPaymentController.swift @@ -462,6 +462,7 @@ class CreditCardPaymentController: UIViewController { // delegate?.creditCardFormViewController(self, didFailWithError: error) displayError(error) hasErrorMessage = true + stopActivityIndicator() } func displayError(_ error: Error) {