Skip to content

Commit

Permalink
Merge pull request #277 from omise/feature/v5_refactoring
Browse files Browse the repository at this point in the history
Release V5.0.0
  • Loading branch information
Andrei Solovev authored Apr 4, 2024
2 parents fd9d287 + 4fff96b commit 59cadd7
Show file tree
Hide file tree
Showing 342 changed files with 11,298 additions and 19,659 deletions.
10 changes: 5 additions & 5 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,10 +21,10 @@ 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 OmiseSDK.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
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

- name: Convert Xcode coverage to SonarCloud format
run: bash xccov-to-sonarqube-generic.sh build/Logs/Test/*.xcresult/ > sonarqube-generic-coverage.xml
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Config.local.plist
sonarqube-generic-coverage.xml
!default.mode1v3
!default.mode2v3
Expand Down
453 changes: 453 additions & 0 deletions ExampleApp.xcodeproj/ExampleApp.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"pins" : [
{
"identity" : "omise-ios",
"kind" : "remoteSourceControl",
"location" : "https://github.com/omise/omise-ios.git",
"state" : {
"branch" : "feature/MIT-1520",
"revision" : "11ab4094210feacb4e42ec29e49a8df41528b54e"
}
}
],
"version" : 2
}
475 changes: 475 additions & 0 deletions ExampleApp.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"pins" : [
{
"identity" : "omise-ios",
"kind" : "remoteSourceControl",
"location" : "https://github.com/omise/omise-ios.git",
"state" : {
"branch" : "feature/v5_refactoring",
"revision" : "a59269f3d734ebc17d8e717b5c03b17d5d67a679"
}
}
],
"version" : 2
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1220"
version = "1.3">
LastUpgradeVersion = "1500"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
Expand All @@ -14,33 +14,23 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8A723A502164D7B100D902F5"
BlueprintIdentifier = "75C2E2242AD712F1008584C0"
BuildableName = "ExampleApp.app"
BlueprintName = "ExampleApp (Objective-C)"
ReferencedContainer = "container:OmiseSDK.xcodeproj">
BlueprintName = "ExampleApp"
ReferencedContainer = "container:ExampleApp.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug (Staging)"
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8A723A502164D7B100D902F5"
BuildableName = "ExampleApp.app"
BlueprintName = "ExampleApp (Objective-C)"
ReferencedContainer = "container:OmiseSDK.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
</Testables>
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug (Staging)"
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
Expand All @@ -53,10 +43,10 @@
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8A723A502164D7B100D902F5"
BlueprintIdentifier = "75C2E2242AD712F1008584C0"
BuildableName = "ExampleApp.app"
BlueprintName = "ExampleApp (Objective-C)"
ReferencedContainer = "container:OmiseSDK.xcodeproj">
BlueprintName = "ExampleApp"
ReferencedContainer = "container:ExampleApp.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
Expand All @@ -70,15 +60,15 @@
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8A723A502164D7B100D902F5"
BlueprintIdentifier = "75C2E2242AD712F1008584C0"
BuildableName = "ExampleApp.app"
BlueprintName = "ExampleApp (Objective-C)"
ReferencedContainer = "container:OmiseSDK.xcodeproj">
BlueprintName = "ExampleApp"
ReferencedContainer = "container:ExampleApp.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug (Staging)">
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
Expand Down
17 changes: 17 additions & 0 deletions ExampleApp/AppDeeplink.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Foundation

enum AppDeeplink: String {
case threeDSChallenge = "3ds_challenge"

var scheme: String {
"omiseExampleApp"
}

var urlString: String {
"\(scheme)://\(rawValue)"
}

var url: URL? {
URL(string: urlString)
}
}
29 changes: 29 additions & 0 deletions ExampleApp/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,40 @@
import UIKit
import OmiseSDK

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
window?.tintColor = UIColor(named: "App Tint") ?? UIColor.blue

return true
}

func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
// Determine who sent the URL.
print("App open url '\(url)'")

let sendingAppID = options[.sourceApplication]
print("source application = \(sendingAppID ?? "Unknown")")

// Process the URL.
guard let components = NSURLComponents(url: url, resolvingAgainstBaseURL: true) else {
print("Invalid url")
return false
}

switch components.host {
case AppDeeplink.threeDSChallenge.rawValue:
print("Omise 3DS Challenge Callback")
let result = OmiseSDK.shared.handleURLCallback(url)
if result {
OmiseSDK.shared.dismiss()
}
return result
default:
print("Unknown deeplink params \(url.host ?? "nil")")
return false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
<dict>
<key>publicKey</key>
<string>pkey_</string>
<key>devMode</key>
<false/>
<key>devVaultBaseURL</key>
<string></string>
<key>devApiBaseURL</key>
Expand Down
7 changes: 0 additions & 7 deletions ExampleApp/ExampleApp-Bridging-Header.h

This file was deleted.

13 changes: 13 additions & 0 deletions ExampleApp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,18 @@
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>co.omise.ExampleApp</string>
<key>CFBundleURLSchemes</key>
<array>
<string>omiseExampleApp</string>
</array>
</dict>
</array>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -1,35 +1,30 @@
//
// LocalConfig.swift
// ExampleApp (Swift)
//
// Created by Andrei Solovev on 10/5/23.
// Copyright © 2023 Omise. All rights reserved.
//

import Foundation
import OmiseSDK

struct LocalConfig: Codable {
var publicKey: String = "pkey_"
var devMode = false

private let devVaultBaseURL: String?
private let devApiBaseURL: String?

var devMode: Bool {
devVaultBaseURL != nil && devApiBaseURL != nil
}

init() {
devVaultBaseURL = nil
devApiBaseURL = nil
}
var env: Environment {

var configuration: Configuration? {
if devMode,
let vaultBaseURLString = devVaultBaseURL,
let vaultBaseURL = URL(string: vaultBaseURLString),
let apiBaseURLString = devApiBaseURL,
let apiBaseURL = URL(string: apiBaseURLString) {
return .dev(vaultURL: vaultBaseURL, apiURL: apiBaseURL)
return .init(vaultURL: vaultBaseURL, apiURL: apiBaseURL)
} else {
return .production
return nil
}
}

Expand Down
75 changes: 75 additions & 0 deletions ExampleApp/Models/Tools.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import UIKit
import OmiseSDK

struct PaymentPreset {
var paymentAmount: Int64
var paymentCurrency: Currency
var allowedPaymentMethods: [SourceType]

static let allPreset = PaymentPreset(
paymentAmount: 3_500_00,
paymentCurrency: .thb,
allowedPaymentMethods: SourceType.allCases
)

static let thailandPreset = PaymentPreset(
paymentAmount: 3_500_00,
paymentCurrency: .thb,
allowedPaymentMethods: SourceType.availableByDefaultInThailand
)

static let japanPreset = PaymentPreset(
paymentAmount: 3_500,
paymentCurrency: .jpy,
allowedPaymentMethods: SourceType.availableByDefaultInJapan
)

static let singaporePreset = PaymentPreset(
paymentAmount: 3_500_00,
paymentCurrency: .sgd,
allowedPaymentMethods: SourceType.availableByDefaultSingapore
)

static let malaysiaPreset = PaymentPreset(
paymentAmount: 3_500_00,
paymentCurrency: .myr,
allowedPaymentMethods: SourceType.availableByDefaultMalaysia
)
}

class Tool: NSObject {

static let allPaymentAmount: Int64 = PaymentPreset.allPreset.paymentAmount
static let allPaymentCurrency: String = PaymentPreset.allPreset.paymentCurrency.code
static let allAllowedPaymentMethods: [SourceType] = PaymentPreset.allPreset.allowedPaymentMethods

static let thailandPaymentAmount: Int64 = PaymentPreset.thailandPreset.paymentAmount
static let thailandPaymentCurrency: String = PaymentPreset.thailandPreset.paymentCurrency.code
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: [SourceType] = PaymentPreset.japanPreset.allowedPaymentMethods

static let singaporePaymentAmount: Int64 = PaymentPreset.singaporePreset.paymentAmount
static let singaporePaymentCurrency: String = PaymentPreset.singaporePreset.paymentCurrency.code
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: [SourceType] = PaymentPreset.malaysiaPreset.allowedPaymentMethods

static func imageWith(size: CGSize, color: UIColor) -> UIImage? {
return Tool.imageWith(size: size) { (context) in
context.setFillColor(color.cgColor)
context.fill(CGRect(origin: .zero, size: size))
}
}

static func imageWith(size: CGSize, actions: (CGContext) -> Void) -> UIImage? {
let renderer = UIGraphicsImageRenderer(size: size)
return renderer.image { context in
actions(context.cgContext)
}
}
}
Loading

0 comments on commit 59cadd7

Please sign in to comment.