Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 10 additions & 1 deletion Sources/CorePayments/Networking/Enums/Environment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import Foundation
public enum Environment {
case sandbox
case live

case custom(baseURL: String)

var baseURL: URL {
switch self {
case .sandbox:
return URL(string: "https://api-m.sandbox.paypal.com")!
case .live:
return URL(string: "https://api-m.paypal.com")!
case .custom(let baseURL):
return URL(string: baseURL)!
}
}

Expand All @@ -20,6 +23,8 @@ public enum Environment {
return URL(string: "https://www.sandbox.paypal.com/graphql")!
case .live:
return URL(string: "https://www.paypal.com/graphql")!
case .custom(let baseURL):
return URL(string: "/graphql", relativeTo: URL(string: baseURL))!
}
}

Expand All @@ -30,6 +35,8 @@ public enum Environment {
return URL(string: "https://sandbox.paypal.com/agreements/approve")!
case .live:
return URL(string: "https://paypal.com/agreements/approve")!
case .custom(let baseURL):
return URL(string: "/agreements/approve", relativeTo: URL(string: baseURL))!
}
}

Expand All @@ -39,6 +46,8 @@ public enum Environment {
return "sandbox"
case .live:
return "live"
case .custom(let baseURL):
return "custom with baseURL: \(baseURL)"
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions Sources/FraudProtection/CoreConfig+MagnesSDK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ extension CoreConfig {
return .SANDBOX
case .live:
return .LIVE
case .custom:
// TODO: determine if this is correct, or if Magnes also needs to be custom
return .SANDBOX
}
}
}
2 changes: 2 additions & 0 deletions Sources/PayPalWebPayments/Environment+PayPalWebCheckout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ extension Environment {
return URL(string: "https://www.sandbox.paypal.com")!
case .live:
return URL(string: "https://www.paypal.com")!
case .custom(let baseURL):
return URL(string: baseURL)!
}
}
// swiftlint:enable force_unwrapping
Expand Down
Loading