From f3c2f4cb7b1638685268b253c783fde10d1f6f50 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Mon, 27 Nov 2023 08:56:25 +0700 Subject: [PATCH 01/11] Add truemoneyJumpApp payment method enums --- OmiseSDK/Capability.swift | 5 ++++- OmiseSDK/Compatibility/OmiseCapability.swift | 5 +++++ OmiseSDK/Globals.swift | 2 +- OmiseSDK/PaymentChooserViewController.swift | 2 ++ OmiseSDKObjc/OMSConstants.h | 1 + OmiseSDKObjc/OMSConstants.m | 1 + 6 files changed, 14 insertions(+), 2 deletions(-) diff --git a/OmiseSDK/Capability.swift b/OmiseSDK/Capability.swift index 2eb890ed..522ffd1c 100644 --- a/OmiseSDK/Capability.swift +++ b/OmiseSDK/Capability.swift @@ -74,6 +74,7 @@ extension Capability { case promptpay case paynow case truemoney + case truemoneyJumpApp case points(PaymentInformation.Points) case eContext case fpx @@ -335,7 +336,7 @@ extension Capability.Backend { try encoder.encodeJSONDictionary(configurations) try container.encode(Array(supportedCurrencies), forKey: .supportedCurrencies) // swiftlint:disable:next line_length - case .internetBanking, .alipay, .alipayCN, .alipayHK, .atome, .dana, .gcash, .kakaoPay, .touchNGoAlipayPlus, .touchNGo, .promptpay, .paynow, .truemoney, .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: try container.encode(Array(supportedCurrencies), forKey: .supportedCurrencies) } } @@ -409,6 +410,8 @@ extension Capability.Backend { self = .source(.payNow) case .truemoney: self = .source(.trueMoney) + case .truemoneyJumpApp: + self = .source(.trueMoneyJumpApp) case .points(let points): self = .source(OMSSourceTypeValue(points.type)) case .eContext: diff --git a/OmiseSDK/Compatibility/OmiseCapability.swift b/OmiseSDK/Compatibility/OmiseCapability.swift index 1c192b7d..f7a300d9 100644 --- a/OmiseSDK/Compatibility/OmiseCapability.swift +++ b/OmiseSDK/Compatibility/OmiseCapability.swift @@ -88,6 +88,9 @@ public class __OmiseCapabilitySourceBackendPayment: __OmiseCapabilityBackendPaym static let truemoneySourceBackendPayment = __OmiseCapabilitySourceBackendPayment(sourceType: OMSSourceTypeValue.trueMoney) + static let truemoneyJumpAppSourceBackendPayment = + __OmiseCapabilitySourceBackendPayment(sourceType: OMSSourceTypeValue.trueMoneyJumpApp) + static let cityPointsSourceBackendPayment = __OmiseCapabilitySourceBackendPayment(sourceType: OMSSourceTypeValue.pointsCiti) @@ -202,6 +205,8 @@ extension __OmiseCapabilityBackendPayment { return __OmiseCapabilitySourceBackendPayment.paynowSourceBackendPayment case .truemoney: return __OmiseCapabilitySourceBackendPayment.truemoneySourceBackendPayment + case .truemoneyJumpApp: + return __OmiseCapabilitySourceBackendPayment.truemoneyJumpAppSourceBackendPayment case .points(let points): return __OmiseCapabilitySourceBackendPayment(sourceType: OMSSourceTypeValue(points.type)) case .eContext: diff --git a/OmiseSDK/Globals.swift b/OmiseSDK/Globals.swift index 2a21bbb1..915dccf7 100644 --- a/OmiseSDK/Globals.swift +++ b/OmiseSDK/Globals.swift @@ -122,7 +122,7 @@ extension OMSSourceTypeValue { return "promptpay" case .payNow: return "paynow" - case .trueMoney: + case .trueMoney, .trueMoneyJumpApp: return "truemoney" case .pointsCiti: return "points" diff --git a/OmiseSDK/PaymentChooserViewController.swift b/OmiseSDK/PaymentChooserViewController.swift index 5381dd03..edb8353e 100644 --- a/OmiseSDK/PaymentChooserViewController.swift +++ b/OmiseSDK/PaymentChooserViewController.swift @@ -526,6 +526,8 @@ class PaymentChooserViewController: AdaptableStaticTableViewController Date: Mon, 27 Nov 2023 09:05:24 +0700 Subject: [PATCH 02/11] Add truemoneyJumpApp to PaymentInformation --- OmiseSDK/Compatibility/OmiseSource.swift | 6 ++++++ OmiseSDK/PaymentInformation.swift | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/OmiseSDK/Compatibility/OmiseSource.swift b/OmiseSDK/Compatibility/OmiseSource.swift index a0079a01..57500168 100644 --- a/OmiseSDK/Compatibility/OmiseSource.swift +++ b/OmiseSDK/Compatibility/OmiseSource.swift @@ -110,6 +110,9 @@ public class __SourcePaymentInformation: NSObject { /// Payment Information for a PayPay Payment public static let paypayPayment = __SourcePaymentInformation(type: OMSSourceTypeValue.payPay)! + + /// Payment Information for an Truemoney JumpApp + public static let truemoneyJumpAppPayment = __SourcePaymentInformation(type: OMSSourceTypeValue.trueMoneyJumpApp)! } /// Internet Bankning Source Payment Information @@ -649,6 +652,9 @@ extension __SourcePaymentInformation { case .truemoney(let trueMoney): return __SourceTrueMoneyPayment(phoneNumber: trueMoney.phoneNumber) + case .truemoneyJumpApp: + return __SourcePaymentInformation.truemoneyJumpAppPayment + case .points(let points): switch points { case .citiPoints: diff --git a/OmiseSDK/PaymentInformation.swift b/OmiseSDK/PaymentInformation.swift index ee651fce..1a439fb9 100644 --- a/OmiseSDK/PaymentInformation.swift +++ b/OmiseSDK/PaymentInformation.swift @@ -209,6 +209,7 @@ public enum PaymentInformation: Codable, Equatable { /// TrueMoney Payment Source case truemoney(TrueMoney) + case truemoneyJumpApp /// The name of the supported services to process the Points Payment public enum Points: PaymentMethod { @@ -479,6 +480,9 @@ public enum PaymentInformation: Codable, Equatable { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(OMSSourceTypeValue.trueMoney.rawValue, forKey: .type) try trueMoney.encode(to: encoder) + case .truemoneyJumpApp: + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(OMSSourceTypeValue.trueMoneyJumpApp.rawValue, forKey: .type) case .points(let points): try points.encode(to: encoder) case .mobileBanking(let value): @@ -641,6 +645,8 @@ extension PaymentInformation { return OMSSourceTypeValue.payNow.rawValue case .truemoney: return OMSSourceTypeValue.trueMoney.rawValue + case .truemoneyJumpApp: + return OMSSourceTypeValue.trueMoneyJumpApp.rawValue case .rabbitLinepay: return OMSSourceTypeValue.rabbitLinepay.rawValue case .ocbcPao: From 2fe79643c5372f25c81084e053774e558e8e6077 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Mon, 27 Nov 2023 09:06:05 +0700 Subject: [PATCH 03/11] Add unittest --- .../PaymentInformationTestCase.swift | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/OmiseSDKTests/PaymentInformationTestCase.swift b/OmiseSDKTests/PaymentInformationTestCase.swift index e4f763d4..95db11e3 100644 --- a/OmiseSDKTests/PaymentInformationTestCase.swift +++ b/OmiseSDKTests/PaymentInformationTestCase.swift @@ -569,6 +569,30 @@ class PaymentInformationTestCase: XCTestCase { } } + func testEncodeTrueMoneyJumpAppSourceParameter() throws { + let encoder = PaymentInformationTestCase.makeJSONEncoder() + + do { + let sourceParameter = Source.CreateParameter(paymentInformation: .truemoneyJumpApp, + 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" : "truemoney_jumpapp" + } + """, encodedJSONString) + } + } func testEncodePointsSourceParameter() throws { let encoder = PaymentInformationTestCase.makeJSONEncoder() From 0c1d495b51decc116b955679f9b1e64b605e9069 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Mon, 27 Nov 2023 16:49:33 +0700 Subject: [PATCH 04/11] Add Truemoney (JumpApp) payment method --- ExampleApp/Resources/Main.storyboard | 162 ++++++++++-------- .../PaymentSettingTableViewController.swift | 5 + OmiseSDK/Capability.swift | 12 +- OmiseSDK/PaymentChooserViewController.swift | 14 +- .../Resources/Base.lproj/OmiseSDK.storyboard | 34 +++- 5 files changed, 145 insertions(+), 82 deletions(-) diff --git a/ExampleApp/Resources/Main.storyboard b/ExampleApp/Resources/Main.storyboard index ec185662..85c893d5 100644 --- a/ExampleApp/Resources/Main.storyboard +++ b/ExampleApp/Resources/Main.storyboard @@ -1,8 +1,8 @@ - + - + @@ -425,14 +425,14 @@ You can present via either Storyboard or Code and you can see the code in the Ex - + - + - + - + - - + - + - - + @@ -493,7 +493,7 @@ You can present via either Storyboard or Code and you can see the code in the Ex - + @@ -510,7 +510,7 @@ You can present via either Storyboard or Code and you can see the code in the Ex - + @@ -527,7 +527,7 @@ You can present via either Storyboard or Code and you can see the code in the Ex - + @@ -544,7 +544,7 @@ You can present via either Storyboard or Code and you can see the code in the Ex - + @@ -561,7 +561,7 @@ You can present via either Storyboard or Code and you can see the code in the Ex - + @@ -578,7 +578,7 @@ You can present via either Storyboard or Code and you can see the code in the Ex - + @@ -595,7 +595,7 @@ You can present via either Storyboard or Code and you can see the code in the Ex - + @@ -612,7 +612,7 @@ You can present via either Storyboard or Code and you can see the code in the Ex - + @@ -629,7 +629,7 @@ You can present via either Storyboard or Code and you can see the code in the Ex - + @@ -646,13 +646,13 @@ You can present via either Storyboard or Code and you can see the code in the Ex - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + @@ -1020,7 +1020,7 @@ You can present via either Storyboard or Code and you can see the code in the Ex - + @@ -1037,7 +1037,7 @@ You can present via either Storyboard or Code and you can see the code in the Ex - + @@ -1054,7 +1054,7 @@ You can present via either Storyboard or Code and you can see the code in the Ex - + @@ -1070,6 +1070,23 @@ You can present via either Storyboard or Code and you can see the code in the Ex + + + + + + + + + + + @@ -1138,6 +1155,7 @@ You can present via either Storyboard or Code and you can see the code in the Ex + @@ -1382,7 +1400,7 @@ You can present via either Storyboard or Code and you can see the code in the Ex - + diff --git a/ExampleApp/Shared/PaymentSettingTableViewController.swift b/ExampleApp/Shared/PaymentSettingTableViewController.swift index afbcb162..3c75f59d 100644 --- a/ExampleApp/Shared/PaymentSettingTableViewController.swift +++ b/ExampleApp/Shared/PaymentSettingTableViewController.swift @@ -116,6 +116,7 @@ class PaymentSettingTableViewController: UITableViewController { @IBOutlet private var promptpayPaymentCell: UITableViewCell! @IBOutlet private var paynowPaymentCell: UITableViewCell! @IBOutlet private var truemoneyPaymentCell: UITableViewCell! + @IBOutlet private var truemoneyJumpAppPaymentCell: UITableViewCell! @IBOutlet private var pointsCitiCell: UITableViewCell! @IBOutlet private var fpxCell: UITableViewCell! @IBOutlet private var rabbitLinepayCell: UITableViewCell! @@ -329,6 +330,8 @@ extension PaymentSettingTableViewController { return .payNow case truemoneyPaymentCell: return .trueMoney + case truemoneyJumpAppPaymentCell: + return .trueMoneyJumpApp case pointsCitiCell: return .pointsCiti case fpxCell: @@ -425,6 +428,8 @@ extension PaymentSettingTableViewController { return payPayPaymentCell case .trueMoney: return truemoneyPaymentCell + case .trueMoneyJumpApp: + return truemoneyJumpAppPaymentCell case .pointsCiti: return pointsCitiCell case .fpx: diff --git a/OmiseSDK/Capability.swift b/OmiseSDK/Capability.swift index 522ffd1c..968ef310 100644 --- a/OmiseSDK/Capability.swift +++ b/OmiseSDK/Capability.swift @@ -277,6 +277,8 @@ extension Capability.Backend { self.payment = .paynow case .source(.trueMoney): self.payment = .truemoney + case .source(.trueMoneyJumpApp): + self.payment = .truemoneyJumpApp case .source(.pointsCiti): self.payment = .points(.citiPoints) case .source(.billPaymentTescoLotus): @@ -332,12 +334,12 @@ 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: + // swiftlint:disable:previous line_length + try container.encode(Array(supportedCurrencies), forKey: .supportedCurrencies) case .unknownSource(_, configurations: let configurations): try encoder.encodeJSONDictionary(configurations) try container.encode(Array(supportedCurrencies), forKey: .supportedCurrencies) - // swiftlint:disable:next line_length - 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: - try container.encode(Array(supportedCurrencies), forKey: .supportedCurrencies) } } } @@ -402,8 +404,6 @@ extension Capability.Backend { self = .source(OMSSourceTypeValue(banking.type)) case .billPayment(let billPayment): self = .source(OMSSourceTypeValue(billPayment.type)) - case .unknownSource(let sourceType, configurations: _): - self = .source(.init(sourceType)) case .promptpay: self = .source(.promptPay) case .paynow: @@ -442,6 +442,8 @@ extension Capability.Backend { self = .source(.duitNowOBW) case .payPay: self = .source(.payPay) + case .unknownSource(let sourceType, configurations: _): + self = .source(.init(sourceType)) } } diff --git a/OmiseSDK/PaymentChooserViewController.swift b/OmiseSDK/PaymentChooserViewController.swift index edb8353e..08efbce7 100644 --- a/OmiseSDK/PaymentChooserViewController.swift +++ b/OmiseSDK/PaymentChooserViewController.swift @@ -22,6 +22,7 @@ enum PaymentChooserOption: CaseIterable, Equatable, CustomStringConvertible { case promptpay case paynow case truemoney + case truemoneyJumpApp case citiPoints case fpx case rabbitLinepay @@ -38,11 +39,10 @@ enum PaymentChooserOption: CaseIterable, Equatable, CustomStringConvertible { case grabPayRms case payPay - static var allCases: [PaymentChooserOption] { + static var sorting: [PaymentChooserOption] { return [ .creditCard, .installment, - .truemoney, .promptpay, .citiPoints, .alipay, @@ -116,7 +116,9 @@ enum PaymentChooserOption: CaseIterable, Equatable, CustomStringConvertible { case .paynow: return "PayNow" case .truemoney: - return "TrueMoney" + return "TrueMoney Wallet" + case .truemoneyJumpApp: + return "Truemoney" case .citiPoints: return "CitiPoints" case .fpx: @@ -157,6 +159,8 @@ extension PaymentChooserOption { switch sourceType { case .trueMoney: return [.truemoney] + case .trueMoneyJumpApp: + return [.truemoneyJumpApp] case .installmentFirstChoice, .installmentMBB, .installmentKBank, .installmentKTC, .installmentBBL, .installmentBAY, .installmentSCB, .installmentCiti, .installmentTTB, .installmentUOB: return [.installment] @@ -397,6 +401,8 @@ class PaymentChooserViewController: AdaptableStaticTableViewController - + @@ -1541,6 +1541,35 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -1591,6 +1620,7 @@ + @@ -3098,7 +3128,7 @@ - + From f49c024f3034e72f0f8f55f11b67fd0ae93e5d6f Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Mon, 27 Nov 2023 17:00:24 +0700 Subject: [PATCH 05/11] Cleanup unused PaymentChooserOption's sorting property --- OmiseSDK/PaymentChooserViewController.swift | 38 --------------------- 1 file changed, 38 deletions(-) diff --git a/OmiseSDK/PaymentChooserViewController.swift b/OmiseSDK/PaymentChooserViewController.swift index 08efbce7..8fa0540f 100644 --- a/OmiseSDK/PaymentChooserViewController.swift +++ b/OmiseSDK/PaymentChooserViewController.swift @@ -39,44 +39,6 @@ enum PaymentChooserOption: CaseIterable, Equatable, CustomStringConvertible { case grabPayRms case payPay - static var sorting: [PaymentChooserOption] { - return [ - .creditCard, - .installment, - .promptpay, - .citiPoints, - .alipay, - .alipayCN, - .alipayHK, - .atome, - .dana, - .gcash, - .kakaoPay, - .touchNGoAlipayPlus, - .internetBanking, - .mobileBanking, - .tescoLotus, - .paynow, - .conbini, - .payEasy, - .netBanking, - .fpx, - .rabbitLinepay, - .ocbcPao, - .ocbcDigital, - .grabPay, - .boost, - .shopeePay, - .shopeePayJumpApp, - .maybankQRPay, - .duitNowQR, - .duitNowOBW, - .touchNGo, - .grabPayRms, - .payPay - ] - } - var description: String { switch self { case .creditCard: From 0c2715c78f2b372cc5dd673e128dd858f1ddefdf Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Tue, 28 Nov 2023 15:23:25 +0700 Subject: [PATCH 06/11] Fix typo Truemoney->TrueMoney --- OmiseSDK/PaymentChooserViewController.swift | 2 +- OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/OmiseSDK/PaymentChooserViewController.swift b/OmiseSDK/PaymentChooserViewController.swift index 8fa0540f..40ec66a7 100644 --- a/OmiseSDK/PaymentChooserViewController.swift +++ b/OmiseSDK/PaymentChooserViewController.swift @@ -80,7 +80,7 @@ enum PaymentChooserOption: CaseIterable, Equatable, CustomStringConvertible { case .truemoney: return "TrueMoney Wallet" case .truemoneyJumpApp: - return "Truemoney" + return "TrueMoney" case .citiPoints: return "CitiPoints" case .fpx: diff --git a/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard b/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard index 77f11f66..bbd38134 100644 --- a/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard +++ b/OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard @@ -518,7 +518,7 @@ - + @@ -1548,15 +1548,15 @@ -