Skip to content

Commit

Permalink
Add white-label installments: BAY, FirstChoice, TTB
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Solovev committed May 14, 2024
1 parent 6d8fd16 commit f8e93b0
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 110 deletions.
2 changes: 1 addition & 1 deletion ExampleApp/Views/ProductDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
3 changes: 3 additions & 0 deletions OmiseSDK/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
3 changes: 3 additions & 0 deletions OmiseSDK/Resources/ja.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ extension SourceType {
.installmentWhiteLabelKTC,
.installmentWhiteLabelKBank,
.installmentWhiteLabelSCB,
.installmentWhiteLabelBBL
.installmentWhiteLabelBBL,
.installmentWhiteLabelBAY,
.installmentWhiteLabelFirstChoice,
.installmentWhiteLabelTTB
]
}

Expand Down
6 changes: 6 additions & 0 deletions OmiseSDK/Sources/OmiseAPI/SourceType/SourceType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,13 @@ extension ChoosePaymentCoordinator {
case .failure(let error):
self?.processError(error)
}
completion()
}
}

DispatchQueue.main.async {
completion()
}

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,111 +6,14 @@ extension SourceType: CustomStringConvertible {

extension SourceType: ViewPresentable {
public var localizedTitle: String {
localized("SourceType.\(self.rawValue)", text: title)
localized("SourceType.\(self.rawValue)")
}

public var localizedSubtitle: String? {
guard let subtitle = subtitle else { return nil }
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:
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ class CreditCardPaymentController: UIViewController {
// delegate?.creditCardFormViewController(self, didFailWithError: error)
displayError(error)
hasErrorMessage = true
stopActivityIndicator()
}

func displayError(_ error: Error) {
Expand Down

0 comments on commit f8e93b0

Please sign in to comment.