Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network Layer and Models Refactoring (v5) #273

Merged
merged 125 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
f7ad7d6
Draft Client and URL requests implementation was added
Feb 8, 2024
40fddbb
Add unsupported payment methods name to Capability.PaymentMethod
Feb 8, 2024
0ae8d64
Added properties to Capability and Payment Method.Added Banks to Capa…
Feb 9, 2024
af562f4
Added Token model
Feb 9, 2024
253f854
Refactor CountryInfo model and moved current country to OmiseSDK as a…
Feb 9, 2024
0e16e60
Implement observeChargeStatusUntilChange(tokenID: String)
Feb 10, 2024
f64cb97
Implement createToken API request
Feb 10, 2024
05a0246
PaymentPayload was added
Feb 11, 2024
dcef2bf
Refactor NetworkService and SourcePayments
Feb 11, 2024
c10a74d
Prepared new Source for Unit Testing
Feb 11, 2024
c2d97e1
Add Unit Tests for decoding SourceNew with list of simple sourceTypes
Feb 11, 2024
49f114a
Refactor SourcePayload and adding comments for public properties
Feb 12, 2024
c5f6678
Adding comments to Source Type
Feb 12, 2024
efc3b70
Namespece refactoring. Add unit tests for decoding Source
Feb 12, 2024
45a68ec
Add comments to Source payloads
Feb 12, 2024
e419bc2
Add DuitNowOBW source payment payload and unit tests
Feb 12, 2024
40d1ccc
Add Source json decoder and unit tests for Installment, Truemoney, Mo…
Feb 13, 2024
c8e9d10
Add econtext decode from Json and unit tests
Feb 13, 2024
ccce357
Add unit tests for Source.Payment JSON encoding / decoding
Feb 13, 2024
525d9f2
Refactor namespaces and update unit tests
Feb 13, 2024
ebc6593
Clean tests. Added Client unit tests
Feb 13, 2024
e59f348
Capability tests added
Feb 13, 2024
9867b31
Remove old Data Layer and replaced with new one
Feb 13, 2024
3e58aac
Integrated new Data Model into Example App
Feb 13, 2024
3b19791
Refactor Source.Payload namings
Feb 13, 2024
1d286f0
Rearrange Project tree
Feb 13, 2024
f8e3240
Cleanup warnings
Feb 13, 2024
76b2193
Cleanup warnings
Feb 13, 2024
350df34
Github action checkou@v2 was changed to checkout@v3
Feb 13, 2024
be6cf00
Project tree rearrangements
Feb 14, 2024
4a8a4fb
Fix Custom Credit Card payment request
Feb 14, 2024
6b1fc4d
Remove deprecated test cases
Feb 14, 2024
be43614
Naming refactoring
Feb 14, 2024
a2d769b
Cleanup old code
Feb 14, 2024
4895c3e
Update unit tests
Feb 14, 2024
f626965
Naming refactoring
Feb 14, 2024
f695dc1
Update refactored names in unit tests
Feb 14, 2024
e08e502
Create convenient static initializers to make Source payment code mor…
Feb 14, 2024
10d3d9d
Refactor JSON codable code
Feb 14, 2024
fbcdb3d
Roll back CountryInfo and SourceTypeValue type names to make PR more …
Feb 14, 2024
5f20509
CountryInfo -> Country, SourceTypeValue -> SourceType renamed
Feb 14, 2024
0ec529c
Refactored Card and move Address fields to use Address model
Feb 14, 2024
c324148
Cleanup unit tests
Feb 14, 2024
2d3c324
Clean up namings
Feb 14, 2024
c90fb90
Add comments to Installments
Feb 14, 2024
502df21
Update Readme
Feb 14, 2024
91e9b37
Readme updated
Feb 14, 2024
ced3ba7
Update readme and Playground examples
Feb 14, 2024
34ebee0
Fix Sonarcloud warnings
Feb 14, 2024
b25b21c
Update unit test
Feb 14, 2024
b877399
Update ExampleApp for COnfiguration changes
Feb 15, 2024
258e5fd
Move SourceType extensions to separate files
Feb 15, 2024
a68b9bf
Move OCBC Digital to Mobile Banking section
Feb 15, 2024
2a9cc68
Filter shopeepay and shopeepay_jumpapp
Feb 15, 2024
3147130
Filter shopeepay and shopeepay_jumpapp
Feb 15, 2024
d4f7dd8
Add SHopeepay Jump App to Settings
Feb 15, 2024
f4d8264
Move OCBC Digital out of installment group as it was requested
Feb 15, 2024
e4976d9
Add draft createTableViewCellsClosure
Feb 15, 2024
96d6d60
Make token(tokenID) public
Feb 15, 2024
26a0f60
Merge branch 'fix/MIT-2135_v5' into feature/MIT-2251_v5_AdaptableTabl…
Feb 15, 2024
1667131
Merge branch 'feature/MIT-1554_v5' into feature/MIT-2251_v5_Adaptable…
Feb 15, 2024
8d9b586
PaymentChooserViewController updated
Feb 15, 2024
10db60b
Basic refactoring is done. UI adjustments required
Feb 15, 2024
3c5ee3d
Refactoring PaymentChooserViewController
Feb 15, 2024
826ba67
Updating implementation for ListViewController
Feb 16, 2024
5fffec2
Fix typo
Feb 16, 2024
9abedca
Merge pull request #274 from omise/fix/MIT-2135_v5
Feb 16, 2024
755bfcc
Merge branch 'feature/MIT-1554_v5' into feature/MIT-2251_v5_Adaptable…
Feb 16, 2024
979fccd
Refactor OmiseSDK and Client access level
Feb 16, 2024
bc1b74c
Cleaning up PaymentChooserController
Feb 17, 2024
483a69b
Add PaymentFlow:
Feb 17, 2024
7a2d7d2
Refactor ChoosePaymentMethodViewModel
Feb 17, 2024
4548799
Refactor namings
Feb 17, 2024
4e730d1
Fix tableViewCell for payment method option
Feb 17, 2024
de7e9f7
Rearrange project tree
Feb 17, 2024
4bef101
update results completions
Feb 17, 2024
585ad02
Refactor PaymentMethod screen
Feb 18, 2024
b495de6
add comments to OmiseSDK instance in ExampleApp
Feb 18, 2024
baaf622
Update project tree for views
Feb 18, 2024
07c87ef
ClientTests updated to match new initializer
Feb 18, 2024
a452aea
ChoosePaymentMethodFlow uses tableDelegate and DataSource
Feb 19, 2024
75f4be2
Refactor PaymentFlow.createChoosePaymentMethodController
Feb 19, 2024
e9182e6
Move fields from Address to CardPaymentPayload
Feb 19, 2024
f7035a7
Source items refactored
Feb 19, 2024
42c9edc
Refactor ChoosePaymentMethodViewModel
Feb 19, 2024
15b2c77
Rename Source.PaymentInformation -> Source.Payment
Feb 19, 2024
f4f8a93
Update PaymentFlow to create a Source payment and notify delegate
Feb 20, 2024
f1e0495
PaymentFlow renamed to PaymentFlowCoordinator
Feb 20, 2024
8cab263
Cleaning up
Feb 20, 2024
c50da9e
Added internet banking and mobile banking screens
Feb 20, 2024
af16fd2
Add subtitle to payment method list
Feb 20, 2024
4dd5561
Cleaning up and renaming
Feb 21, 2024
0735559
Rearrange project tree
Feb 21, 2024
0a20440
Cleaning up namings
Feb 21, 2024
e6d27a1
Recreate project groups to arrange files inside subfolders
Feb 21, 2024
bf2e884
Fix building issues after removing obsolete files
Feb 21, 2024
d493570
Update ExampleApp to use current branch for testing
Feb 21, 2024
dea5a8d
Arrange files locations
Feb 21, 2024
c96c807
Update project settings to run ExampleApp from OmiseSDK. Add atome sc…
Feb 21, 2024
6f09d7b
Renamed CCVInfoPopupController
Feb 22, 2024
046874b
Moving Credit Card from Storyboard
Feb 22, 2024
8e663ef
Credit Card ccv popup added
Feb 22, 2024
3ca53a6
Fix CreditCardController
Feb 22, 2024
c0963b1
New base controller for form type payment information screens
Feb 22, 2024
25c4a81
AtomeController subclassed of PaymentFormBuilderController
Feb 22, 2024
0109d3e
Define 2 base classes to build payment form view controllers
Feb 23, 2024
9c546df
PaymentFormController cleanup
Feb 23, 2024
ae79927
PaymentInputsFormController base implementatino added
Feb 23, 2024
b36a74d
move econtext from storyboard to xib
Feb 24, 2024
ccf64eb
Add completion to payment details controllers
Feb 24, 2024
cddb1a1
FPX payment is refactored
Feb 24, 2024
cc44bd5
Storyboard clean up
Feb 24, 2024
4c7ea9d
DuitNowOBW Refactored
Feb 24, 2024
c1e11d7
truemoney wallet refactored
Feb 24, 2024
9c7ae13
cleanup storyboard
Feb 24, 2024
1c9919d
merge
Feb 24, 2024
b384849
Project tree cleanup
Feb 24, 2024
ee6023a
Update eContext payment translations
Mar 4, 2024
4e9b2ff
Move Credit card to OmiseSDK
Mar 4, 2024
b1d51f6
Move AuthorizingPaymentViewController.xib out of Storyboard
Mar 4, 2024
9764e47
Cleanup example app Storyboard
Mar 4, 2024
d5056a8
Clean up warnings
Mar 4, 2024
7e9ddef
Changing Readme
Mar 4, 2024
4f77e62
Clean sonarcloud warning
Mar 4, 2024
10cd9e0
Merge pull request #275 from omise/feature/MIT-2251_v5_AdaptableTable…
Mar 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Run linting
uses: norio-nomura/[email protected]
with:
Expand All @@ -21,7 +21,7 @@ jobs:
env:
BUILD_WRAPPER_OUT_DIR: buildwrapper # Directory where build-wrapper output will be placed
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Run xcodebuild with tests
run: xcodebuild -project dev.xcodeproj/ -scheme OmiseSDK -derivedDataPath Build/ -destination 'platform=iOS Simulator,name=iPhone 11,OS=16.2' -enableCodeCoverage YES clean build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
Expand All @@ -33,7 +33,7 @@ jobs:
run: xattr -w com.apple.xcode.CreatedByBuildSystem true ./build

- name: Upload coverage report
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
path: sonarqube-generic-coverage.xml
retention-days: 5 # Artifact will be available only for 5 days.
Expand All @@ -51,7 +51,7 @@ jobs:
needs: test
steps:
- name: Checkout repository on branch
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: ${{ github.HEAD_REF }}
fetch-depth: 0
Expand Down
2 changes: 1 addition & 1 deletion ExampleApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/omise/omise-ios.git";
requirement = {
branch = feature/v5.0.0_improvements;
branch = feature/v5.0.1_improvements;
kind = branch;
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/omise/omise-ios.git",
"state" : {
"branch" : "feature/v5.0.0_improvements",
"revision" : "6ff5a91c43fb163949ffc0369eb4a471fe0edba6"
"branch" : "feature/v5.0.1_improvements",
"revision" : "4d54f2187b9a7c9261563cb9b1acfe830fc5aab0"
}
}
],
Expand Down
10 changes: 5 additions & 5 deletions ExampleApp/Models/Tools.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
252 changes: 135 additions & 117 deletions ExampleApp/Resources/Main.storyboard

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ExampleApp/Views/BaseViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class BaseViewController: UIViewController {
var paymentAmount: Int64 = 0
var paymentCurrencyCode: String = ""
var usesCapabilityDataForPaymentMethods = false
var allowedPaymentMethods: [SourceTypeValue] = []
var allowedPaymentMethods: [SourceType] = []

required init?(coder: NSCoder) {
self.usesCapabilityDataForPaymentMethods = true
Expand Down
24 changes: 14 additions & 10 deletions ExampleApp/Views/CustomCreditCardFormViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,25 +158,29 @@ class CustomCreditCardFormViewController: UIViewController {
@IBAction private func proceed(_ sender: UIBarButtonItem) {
guard let name = cardNameField.text, cardNumberField.isValid,
let expiryMonth = cardExpiryField.selectedMonth, let expiryYear = cardExpiryField.selectedYear,
let cvv = cardCVVField.text else {
let cvv = cardCVVField.text, let number = cardNumberField.text else {
return
}
let tokenRequest = Request<Token>(

let payload = CreateTokenPayload.Card(
name: name,
pan: cardNumberField.pan,
number: number,
expirationMonth: expiryMonth,
expirationYear: expiryYear,
securityCode: cvv,
countryCode: countryCodeField.text ?? "",
city: cityField.text ?? "",
state: stateField.text ?? "",
street1: street1Field.text ?? "",
street2: street2Field.text ?? "",
postalCode: postalCodeField.text ?? ""
phoneNumber: nil,
address: PaymentInformation.Address(
countryCode: countryCodeField.text ?? "",
city: cityField.text ?? "",
state: stateField.text ?? "",
street1: street1Field.text ?? "",
street2: street2Field.text ?? "",
postalCode: postalCodeField.text ?? ""
)
)

doneButton.isEnabled = false
omiseClient.send(tokenRequest) { [weak self] (result) in
omiseClient.createToken(payload: payload) { [weak self] (result) in
guard let self = self else { return }
self.doneButton.isEnabled = false
switch result {
Expand Down
19 changes: 12 additions & 7 deletions ExampleApp/Views/PaymentSettingTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class PaymentSettingTableViewController: UITableViewController {
}
}

var allowedPaymentMethods: Set<SourceTypeValue> = [] {
var allowedPaymentMethods: Set<SourceType> = [] {
willSet {
guard isViewLoaded else {
return
Expand Down Expand Up @@ -122,6 +122,7 @@ class PaymentSettingTableViewController: UITableViewController {
@IBOutlet private var grabPayPaymentCell: UITableViewCell!
@IBOutlet private var boostPaymentCell: UITableViewCell!
@IBOutlet private var shopeePayPaymentCell: UITableViewCell!
@IBOutlet private var shopeePayJumpAppPaymentCell: UITableViewCell!
@IBOutlet private var maybankQRPayPaymentCell: UITableViewCell!
@IBOutlet private var duitNowQRPaymentCell: UITableViewCell!
@IBOutlet private var duitNowOBWPaymentCell: UITableViewCell!
Expand Down Expand Up @@ -264,7 +265,7 @@ extension PaymentSettingTableViewController {
}

// swiftlint:disable:next function_body_length
func paymentSource(for cell: UITableViewCell) -> SourceTypeValue? {
func paymentSource(for cell: UITableViewCell) -> SourceType? {
switch cell {
case internetBankingBAYPaymentCell:
return .internetBankingBAY
Expand Down Expand Up @@ -325,7 +326,7 @@ extension PaymentSettingTableViewController {
case paynowPaymentCell:
return .payNow
case truemoneyPaymentCell:
return .trueMoney
return .trueMoneyWallet
case truemoneyJumpAppPaymentCell:
return .trueMoneyJumpApp
case pointsCitiCell:
Expand All @@ -335,13 +336,15 @@ extension PaymentSettingTableViewController {
case rabbitLinepayCell:
return .rabbitLinepay
case OCBCDigitalPaymentCell:
return .mobileBankingOCBC
return .ocbcDigital
case grabPayPaymentCell:
return .grabPay
case boostPaymentCell:
return .boost
case shopeePayPaymentCell:
return .shopeePay
case shopeePayJumpAppPaymentCell:
return .shopeePayJumpApp
case maybankQRPayPaymentCell:
return .maybankQRPay
case duitNowQRPaymentCell:
Expand All @@ -356,7 +359,7 @@ extension PaymentSettingTableViewController {
}

// swiftlint:disable:next function_body_length
func cell(for paymentSource: SourceTypeValue) -> UITableViewCell? {
func cell(for paymentSource: SourceType) -> UITableViewCell? {
switch paymentSource {
case .internetBankingBAY:
return internetBankingBAYPaymentCell
Expand Down Expand Up @@ -400,7 +403,7 @@ extension PaymentSettingTableViewController {
return installmentUOBPaymentCell
case .mobileBankingSCB:
return mobileBankingSCBPaymentCell
case .mobileBankingOCBC:
case .ocbcDigital:
return OCBCDigitalPaymentCell
case .mobileBankingKBank:
return mobileBankingKBankPaymentCell
Expand All @@ -418,7 +421,7 @@ extension PaymentSettingTableViewController {
return paynowPaymentCell
case .payPay:
return payPayPaymentCell
case .trueMoney:
case .trueMoneyWallet:
return truemoneyPaymentCell
case .trueMoneyJumpApp:
return truemoneyJumpAppPaymentCell
Expand All @@ -434,6 +437,8 @@ extension PaymentSettingTableViewController {
return boostPaymentCell
case .shopeePay:
return shopeePayPaymentCell
case .shopeePayJumpApp:
return shopeePayJumpAppPaymentCell
case .maybankQRPay:
return maybankQRPayPaymentCell
case .duitNowQR:
Expand Down
4 changes: 2 additions & 2 deletions ExampleApp/Views/ProductDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class ProductDetailViewController: BaseViewController {

private func setupClient() {
// Setup dev environment for staging
Configuration.setDefault(Configuration(environment: LocalConfig.default.env))
Configuration.setShared(Configuration(environment: LocalConfig.default.env))

let client = Client(publicKey: publicKey)

client.capabilityDataWithCompletionHandler { (result) in
client.capability { (result) in
if case .success(let capability) = result {
self.capability = capability
print("Capability Country: \(capability.countryCode)")
Expand Down
44 changes: 23 additions & 21 deletions OmiseSDK/AtomeFormViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ class AtomeFormViewModel: AtomeFormViewModelProtocol, CountryListViewModelProtoc
]

// MARK: CountryListViewModelProtocol
lazy var countries: [CountryInfo] = CountryInfo.sortedAll
lazy var countries: [Country] = Country.sortedAll

lazy var selectedCountry: CountryInfo? = CountryInfo.default {
lazy var selectedCountry: Country? = OmiseSDK.shared.country {
didSet {
if let selectedCountry = selectedCountry {
onSelectCountry(selectedCountry)
}
}
}
var onSelectCountry: (CountryInfo) -> Void = { _ in }
var onSelectCountry: (Country) -> Void = { _ in }

var countryListViewModel: CountryListViewModelProtocol { return self }

Expand Down Expand Up @@ -79,17 +79,17 @@ class AtomeFormViewModel: AtomeFormViewModelProtocol, CountryListViewModelProtoc
onComplete()
return
}

let shippingAddress: PaymentInformation.Atome.ShippingAddress =
.init(country: viewContext[.country],
city: viewContext[.city],
postalCode: viewContext[.postalCode],
state: viewContext[.state],
street1: viewContext[.street1],
street2: viewContext[.street2])

let items: [PaymentInformation.Atome.Item] = [
.init(
let shippingAddress = PaymentInformation.Address(
countryCode: viewContext[.country],
city: viewContext[.city],
state: viewContext[.state],
street1: viewContext[.street1],
street2: viewContext[.street2],
postalCode: viewContext[.postalCode]
)

let items: [PaymentInformation.Item] = [
PaymentInformation.Item(
sku: "3427842",
category: "Shoes",
name: "Prada shoes",
Expand All @@ -101,15 +101,17 @@ class AtomeFormViewModel: AtomeFormViewModelProtocol, CountryListViewModelProtoc
)
]

let atomeData = PaymentInformation.Atome(phoneNumber: viewContext[.phoneNumber],
name: viewContext[.name],
email: viewContext[.email],
shippingAddress: shippingAddress,
items: items)
let paymentInformation = PaymentInformation.atome(
PaymentInformation.Atome(
phoneNumber: viewContext[.phoneNumber],
shipping: shippingAddress,
billing: nil,
items: items
)
)

flowSession.requestCreateSource(.atome(atomeData)) { _ in
flowSession.requestCreateSource(paymentInformation) { _ in
onComplete()
}

}
}
Loading
Loading