Skip to content

Commit

Permalink
Merge pull request #249 from omise/develop
Browse files Browse the repository at this point in the history
[Dev -> Master] 4.26.0
  • Loading branch information
Andrei Solovev authored Dec 14, 2023
2 parents 8983418 + f7ac795 commit 93be2c6
Show file tree
Hide file tree
Showing 18 changed files with 332 additions and 136 deletions.
162 changes: 90 additions & 72 deletions ExampleApp/Resources/Main.storyboard

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions ExampleApp/Shared/PaymentSettingTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down Expand Up @@ -329,6 +330,8 @@ extension PaymentSettingTableViewController {
return .payNow
case truemoneyPaymentCell:
return .trueMoney
case truemoneyJumpAppPaymentCell:
return .trueMoneyJumpApp
case pointsCitiCell:
return .pointsCiti
case fpxCell:
Expand Down Expand Up @@ -425,6 +428,8 @@ extension PaymentSettingTableViewController {
return payPayPaymentCell
case .trueMoney:
return truemoneyPaymentCell
case .trueMoneyJumpApp:
return truemoneyJumpAppPaymentCell
case .pointsCiti:
return pointsCitiCell
case .fpx:
Expand Down
4 changes: 4 additions & 0 deletions OmiseSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
75F2A0BB2A1A60630038FA54 /* AtomeFormViewContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0B52A1A5F020038FA54 /* AtomeFormViewContext.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 */; };
75F8C0B72B1F78E300AE78D9 /* PaymentChooserViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F8C0B62B1F78E300AE78D9 /* PaymentChooserViewControllerTests.swift */; };
8A01E48D21059EFF00D73FE6 /* PaymentInformation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A01E48C21059EFF00D73FE6 /* PaymentInformation.swift */; };
8A01F78B20D90EC5003FC11E /* Client+ObjC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A01F78A20D90EC5003FC11E /* Client+ObjC.swift */; };
8A01F78E20D91091003FC11E /* OMSTokenRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A01F78D20D91091003FC11E /* OMSTokenRequest.swift */; };
Expand Down Expand Up @@ -316,6 +317,7 @@
75F2A0B32A1A5EAD0038FA54 /* AtomeFormViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtomeFormViewModelProtocol.swift; sourceTree = "<group>"; };
75F2A0B52A1A5F020038FA54 /* AtomeFormViewContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtomeFormViewContext.swift; sourceTree = "<group>"; };
75F2A0C02A1A84900038FA54 /* UIColor+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Helpers.swift"; sourceTree = "<group>"; };
75F8C0B62B1F78E300AE78D9 /* PaymentChooserViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentChooserViewControllerTests.swift; sourceTree = "<group>"; };
8A00FEC21F1DE88600246078 /* README.md */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; tabWidth = 2; };
8A01E48C21059EFF00D73FE6 /* PaymentInformation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentInformation.swift; sourceTree = "<group>"; };
8A01F78A20D90EC5003FC11E /* Client+ObjC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Client+ObjC.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -882,6 +884,7 @@
isa = PBXGroup;
children = (
F615CBF7261565D600E1A2D9 /* CardExpiryDatePickerTests.swift */,
75F8C0B62B1F78E300AE78D9 /* PaymentChooserViewControllerTests.swift */,
);
path = Views;
sourceTree = "<group>";
Expand Down Expand Up @@ -1349,6 +1352,7 @@
7509D4E72A1C8E3D0050AB38 /* AtomeFormViewModelTests.swift in Sources */,
7509D4E22A1C876B0050AB38 /* AtomeFormViewContextMockup.swift in Sources */,
8A3C10562159F7FC00BEFD8A /* InvalidCardAPIErrorParsingTestCase.swift in Sources */,
75F8C0B72B1F78E300AE78D9 /* PaymentChooserViewControllerTests.swift in Sources */,
758244092ACE988700781B3B /* PaymentInformationTestCase.swift in Sources */,
8A37E43620B584D300E2DA18 /* ModelTestCase.swift in Sources */,
);
Expand Down
15 changes: 10 additions & 5 deletions OmiseSDK/Capability.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ extension Capability {
case promptpay
case paynow
case truemoney
case truemoneyJumpApp
case points(PaymentInformation.Points)
case eContext
case fpx
Expand Down Expand Up @@ -276,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):
Expand Down Expand Up @@ -331,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, .points, .billPayment, .eContext, .mobileBanking, .fpx, .rabbitLinepay, .ocbcPao, .ocbcDigital, .grabPay, .grabPayRms, .boost, .shopeePay, .shopeePayJumpApp, .maybankQRPay, .duitNowQR, .duitNowOBW, .payPay:
try container.encode(Array(supportedCurrencies), forKey: .supportedCurrencies)
}
}
}
Expand Down Expand Up @@ -401,14 +404,14 @@ 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:
self = .source(.payNow)
case .truemoney:
self = .source(.trueMoney)
case .truemoneyJumpApp:
self = .source(.trueMoneyJumpApp)
case .points(let points):
self = .source(OMSSourceTypeValue(points.type))
case .eContext:
Expand Down Expand Up @@ -439,6 +442,8 @@ extension Capability.Backend {
self = .source(.duitNowOBW)
case .payPay:
self = .source(.payPay)
case .unknownSource(let sourceType, configurations: _):
self = .source(.init(sourceType))
}
}

Expand Down
2 changes: 1 addition & 1 deletion OmiseSDK/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ extension Client {

// MARK: - Constants
extension Client {
static let sdkVersion: String = "4.25.1"
static let sdkVersion: String = "4.26.0"

static let currentPlatform: String = ProcessInfo.processInfo.operatingSystemVersionString
static let currentDevice: String = UIDevice.current.model
Expand Down
5 changes: 5 additions & 0 deletions OmiseSDK/Compatibility/OmiseCapability.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions OmiseSDK/Compatibility/OmiseSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion OmiseSDK/Globals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ extension OMSSourceTypeValue {
return "promptpay"
case .payNow:
return "paynow"
case .trueMoney:
case .trueMoney, .trueMoneyJumpApp:
return "truemoney"
case .pointsCiti:
return "points"
Expand Down
92 changes: 42 additions & 50 deletions OmiseSDK/PaymentChooserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ enum PaymentChooserOption: CaseIterable, Equatable, CustomStringConvertible {
case promptpay
case paynow
case truemoney
case truemoneyJumpApp
case citiPoints
case fpx
case rabbitLinepay
Expand All @@ -38,45 +39,6 @@ enum PaymentChooserOption: CaseIterable, Equatable, CustomStringConvertible {
case grabPayRms
case payPay

static var allCases: [PaymentChooserOption] {
return [
.creditCard,
.installment,
.truemoney,
.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:
Expand Down Expand Up @@ -116,6 +78,8 @@ enum PaymentChooserOption: CaseIterable, Equatable, CustomStringConvertible {
case .paynow:
return "PayNow"
case .truemoney:
return "TrueMoney Wallet"
case .truemoneyJumpApp:
return "TrueMoney"
case .citiPoints:
return "CitiPoints"
Expand Down Expand Up @@ -157,6 +121,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]
Expand Down Expand Up @@ -397,6 +363,8 @@ class PaymentChooserViewController: AdaptableStaticTableViewController<PaymentCh
case .atome:
goToAtome()
return
case .truemoneyJumpApp:
payment = .truemoneyJumpApp
default:
return
}
Expand Down Expand Up @@ -491,6 +459,8 @@ class PaymentChooserViewController: AdaptableStaticTableViewController<PaymentCh
return IndexPath(row: 31, section: 0)
case .payPay:
return IndexPath(row: 32, section: 0)
case .truemoneyJumpApp:
return IndexPath(row: 33, section: 0)
}
}

Expand Down Expand Up @@ -526,6 +496,8 @@ class PaymentChooserViewController: AdaptableStaticTableViewController<PaymentCh
return OMSSourceTypeValue.payNow
case .truemoney:
return OMSSourceTypeValue.trueMoney
case .truemoneyJumpApp:
return OMSSourceTypeValue.trueMoneyJumpApp
case .points(let points):
return OMSSourceTypeValue(points.type)
case .installment(let brand, availableNumberOfTerms: _):
Expand Down Expand Up @@ -605,17 +577,9 @@ class PaymentChooserViewController: AdaptableStaticTableViewController<PaymentCh
}

private func updateShowingValues() {
var paymentMethodsToShow: [PaymentChooserOption] = allowedPaymentMethods.reduce(into: []) { (result, sourceType) in
let paymentOptions = PaymentChooserOption.paymentOptions(for: sourceType)
for paymentOption in paymentOptions where !result.contains(paymentOption) {
result.append(paymentOption)
}
}

if showsCreditCardPayment {
paymentMethodsToShow.insert(.creditCard, at: 0)
}

var paymentMethodsToShow = paymentOptions(from: allowedPaymentMethods)
paymentMethodsToShow = appendCreditCardPayment(paymentOptions: paymentMethodsToShow)
paymentMethodsToShow = filterTrueMoney(paymentOptions: paymentMethodsToShow)
showingValues = paymentMethodsToShow

os_log("Payment Chooser: Showing options - %{private}@",
Expand All @@ -628,3 +592,31 @@ class PaymentChooserViewController: AdaptableStaticTableViewController<PaymentCh
flowSession?.requestToCancel()
}
}

private extension PaymentChooserViewController {
func paymentOptions(from sourceTypes: [OMSSourceTypeValue]) -> [PaymentChooserOption] {
let paymentOptions: [PaymentChooserOption] = sourceTypes.reduce(into: []) { (result, sourceType) in
let paymentOptions = PaymentChooserOption.paymentOptions(for: sourceType)
for paymentOption in paymentOptions where !result.contains(paymentOption) {
result.append(paymentOption)
}
}
return paymentOptions
}

func appendCreditCardPayment(paymentOptions: [PaymentChooserOption]) -> [PaymentChooserOption] {
var filter = paymentOptions
if showsCreditCardPayment {
filter.insert(.creditCard, at: 0)
}
return filter
}

func filterTrueMoney(paymentOptions: [PaymentChooserOption]) -> [PaymentChooserOption] {
var filter = paymentOptions
if filter.contains(.truemoney) && filter.contains(.truemoneyJumpApp) {
filter.removeAll { $0 == .truemoney }
}
return filter
}
}
6 changes: 6 additions & 0 deletions OmiseSDK/PaymentInformation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down
Loading

0 comments on commit 93be2c6

Please sign in to comment.