diff --git a/Demo/Application/Base/ContainmentViewController.swift b/Demo/Application/Base/ContainmentViewController.swift
index a5d61afdbe..29d5e2b0ea 100644
--- a/Demo/Application/Base/ContainmentViewController.swift
+++ b/Demo/Application/Base/ContainmentViewController.swift
@@ -162,8 +162,9 @@ class ContainmentViewController: UIViewController {
tokenizationKey = "sandbox_9dbg82cq_dcpspy2brwdjr3qn"
case .production:
tokenizationKey = "production_t2wns2y2_dfy45jdj3dxkmz5m"
- default:
- tokenizationKey = "development_testing_integration_merchant_id"
+ case .custom:
+ // swiftlint:disable:next force_unwrapping
+ tokenizationKey = UserDefaults.standard.string(forKey: "BraintreeDemoSettingsCustomAuthorizationKey")!
}
currentViewController = instantiateViewController(with: tokenizationKey)
@@ -171,6 +172,11 @@ class ContainmentViewController: UIViewController {
case .clientToken:
updateStatus("Fetching Client Token...")
+ if BraintreeDemoSettings.currentEnvironment == .custom {
+ updateStatus("Switch the Authorization Type in settings to Tokenization Key to use the custom environment")
+ return
+ }
+
BraintreeDemoMerchantAPIClient.shared.createCustomerAndFetchClientToken { clientToken, error in
if let error {
self.updateStatus(error.localizedDescription)
diff --git a/Demo/Application/Base/Settings/BraintreeDemoSettings.swift b/Demo/Application/Base/Settings/BraintreeDemoSettings.swift
index faf5a19cae..6b2546b06a 100644
--- a/Demo/Application/Base/Settings/BraintreeDemoSettings.swift
+++ b/Demo/Application/Base/Settings/BraintreeDemoSettings.swift
@@ -24,7 +24,7 @@ class BraintreeDemoSettings: NSObject {
static let EnvironmentDefaultsKey = "BraintreeDemoSettingsEnvironmentDefaultsKey"
static let AuthorizationTypeDefaultsKey = "BraintreeDemoSettingsAuthorizationTypeKey"
- static let CustomEnvironmentURLDefaultsKey = "BraintreeDemoSettingsCustomEnvironmentURLDefaultsKey"
+ static let CustomAuthorizationDefaultsKey = "BraintreeDemoSettingsCustomAuthorizationKey"
static let ThreeDSecureRequiredDefaultsKey = "BraintreeDemoSettingsThreeDSecureRequiredDefaultsKey"
static var currentEnvironment: BraintreeDemoEnvironment {
@@ -35,28 +35,19 @@ class BraintreeDemoSettings: NSObject {
static var currentEnvironmentName: String {
switch currentEnvironment {
- case .sandbox:
+ case .sandbox, .custom:
return "Sandbox"
case .production:
return "Production"
- case .custom:
- guard var name = UserDefaults.standard.string(forKey: CustomEnvironmentURLDefaultsKey) else {
- return "(invalid)"
- }
- name = name.replacingOccurrences(of: "http://", with: "")
- name = name.replacingOccurrences(of: "https://", with: "")
- return name
}
}
static var currentEnvironmentURLString: String {
switch currentEnvironment {
- case .sandbox:
+ case .sandbox, .custom:
return "https://braintree-sample-merchant.herokuapp.com"
case .production:
return "https://executive-sample-merchant.herokuapp.com"
- case .custom:
- return UserDefaults.standard.string(forKey: EnvironmentDefaultsKey) ?? ""
}
}
diff --git a/Demo/Application/Base/Settings/Settings.bundle/Root.plist b/Demo/Application/Base/Settings/Settings.bundle/Root.plist
index 4fde86e1c8..f6f0bfc69d 100644
--- a/Demo/Application/Base/Settings/Settings.bundle/Root.plist
+++ b/Demo/Application/Base/Settings/Settings.bundle/Root.plist
@@ -59,13 +59,13 @@
Sandbox
Production
- Custom (enter below)
+ Custom
Titles
Sandbox
Production
- Custom (URL on previous screen)
+ Custom
Values
@@ -78,9 +78,9 @@
Type
PSTextFieldSpecifier
Title
- Custom Base URL
+ Custom Authorization
Key
- BraintreeDemoSettingsCustomEnvironmentURLDefaultsKey
+ BraintreeDemoSettingsCustomAuthorizationKey
IASKTextAlignment
IASKUITextAlignmentRight