Skip to content

Commit

Permalink
Merge pull request #1331 from braintree/payment-insights-feature
Browse files Browse the repository at this point in the history
Merge Shopper Insights Feature Into Main
  • Loading branch information
jaxdesmarais authored Jun 6, 2024
2 parents 6f77f26 + 55e5f0b commit 0b83215
Show file tree
Hide file tree
Showing 42 changed files with 1,569 additions and 66 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,10 @@ jobs:
sourcekitten doc -- -workspace Braintree.xcworkspace -scheme BraintreePayPal -destination 'name=iPhone 14,platform=iOS Simulator' > braintree-paypal.json
sourcekitten doc -- -workspace Braintree.xcworkspace -scheme BraintreeVenmo -destination 'name=iPhone 14,platform=iOS Simulator' > braintree-venmo.json
sourcekitten doc -- -workspace Braintree.xcworkspace -scheme BraintreePayPalMessaging -destination 'name=iPhone 14,platform=iOS Simulator' > braintree-paypal-messaging.json
sourcekitten doc -- -workspace Braintree.xcworkspace -scheme BraintreeShopperInsights -destination 'name=iPhone 14,platform=iOS Simulator' > braintree-shopper-insights.json
# merge sourcekitten output
jq -s '.[0] + .[1] + .[2] + .[3] + .[4] + .[5] + .[6] + .[7] + .[8] + .[9] + .[10] + .[11]' braintree-core.json braintree-pay-pal-native-checkout.json braintree-sepa-direct-debit.json braintree-american-express.json braintree-data-collector.json braintree-apple-pay.json braintree-local-payment.json braintree-three-d-secure.json braintree-card.json braintree-paypal.json braintree-venmo.json braintree-paypal-messaging.json > swiftDoc.json
jq -s '.[0] + .[1] + .[2] + .[3] + .[4] + .[5] + .[6] + .[7] + .[8] + .[9] + .[10] + .[11] + .[12]' braintree-core.json braintree-pay-pal-native-checkout.json braintree-sepa-direct-debit.json braintree-american-express.json braintree-data-collector.json braintree-apple-pay.json braintree-local-payment.json braintree-three-d-secure.json braintree-card.json braintree-paypal.json braintree-venmo.json braintree-paypal-messaging.json braintree-shopper-insights.json > swiftDoc.json
jazzy \
--sourcekitten-sourcefile swiftDoc.json \
Expand Down
6 changes: 6 additions & 0 deletions Braintree.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ Pod::Spec.new do |s|
s.resource_bundle = { "BraintreeSEPADirectDebit_PrivacyInfo" => "Sources/BraintreeSEPADirectDebit/PrivacyInfo.xcprivacy" }
end

s.subspec "ShopperInsights" do |s|
s.source_files = "Sources/BraintreeShopperInsights/*.swift"
s.dependency "Braintree/Core"
s.resource_bundle = { "BraintreeShopperInsights_PrivacyInfo" => "Sources/BraintreeShopperInsights/PrivacyInfo.xcprivacy" }
end

s.subspec "PayPalNativeCheckout" do |s|
s.source_files = "Sources/BraintreePayPalNativeCheckout/*.swift"
s.dependency "Braintree/Core"
Expand Down
437 changes: 435 additions & 2 deletions Braintree.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1500"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8046982F2B27C5340090878E"
BuildableName = "BraintreeShopperInsights.framework"
BlueprintName = "BraintreeShopperInsights"
ReferencedContainer = "container:Braintree.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8046982F2B27C5340090878E"
BuildableName = "BraintreeShopperInsights.framework"
BlueprintName = "BraintreeShopperInsights"
ReferencedContainer = "container:Braintree.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
24 changes: 24 additions & 0 deletions Braintree.xcodeproj/xcshareddata/xcschemes/UnitTests.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@
ReferencedContainer = "container:Braintree.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "NO"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8046983D2B27C5530090878E"
BuildableName = "BraintreeShopperInsightsTests.xctest"
BlueprintName = "BraintreeShopperInsightsTests"
ReferencedContainer = "container:Braintree.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
Expand Down Expand Up @@ -159,6 +173,16 @@
ReferencedContainer = "container:Braintree.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8046983D2B27C5530090878E"
BuildableName = "BraintreeShopperInsightsTests.xctest"
BlueprintName = "BraintreeShopperInsightsTests"
ReferencedContainer = "container:Braintree.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## unreleased
* Re-use existing URLSession instance for `v1/configuration` and subsequent BT GW API calls
* BraintreeShopperInsights (BETA)
* Add PrivacyInfo.xcprivacy file
* Add `BTShopperInsightsClient.getRecommendedPaymentMethods()` for returning recommendations based on the buyer
* BraintreePayPal
* Add `BTPayPalCheckoutRequest.userAuthenticationEmail` optional property

## 6.19.0 (2024-05-30)
* BraintreeCore
Expand Down
2 changes: 2 additions & 0 deletions Demo/Application/Base/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import BraintreeCore
userDefaults.set(BraintreeDemoAuthType.clientToken.rawValue, forKey: BraintreeDemoSettings.AuthorizationTypeDefaultsKey)
} else if processInfoArgs.contains("-TokenizationKey") {
userDefaults.set(BraintreeDemoAuthType.tokenizationKey.rawValue, forKey: BraintreeDemoSettings.AuthorizationTypeDefaultsKey)
} else if processInfoArgs.contains("-NewPayPalCheckoutTokenizationKey") {
userDefaults.set(BraintreeDemoAuthType.newPayPalCheckoutTokenizationKey.rawValue, forKey: BraintreeDemoSettings.AuthorizationTypeDefaultsKey)
} else if processInfoArgs.contains("-MockedPayPalTokenizationKey") {
userDefaults.set(BraintreeDemoAuthType.mockedPayPalTokenizationKey.rawValue, forKey: BraintreeDemoSettings.AuthorizationTypeDefaultsKey)
} else if processInfoArgs.contains("-UITestHardcodedClientToken") {
Expand Down
7 changes: 7 additions & 0 deletions Demo/Application/Base/ContainmentViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ class ContainmentViewController: UIViewController {
}
}

case .newPayPalCheckoutTokenizationKey:
updateStatus("Fetching new checkout token...")
let newPayPalCheckoutTokenizationKey = "sandbox_rz48bqvw_jcyycfw6f9j4nj9c"
currentViewController = instantiateViewController(with: newPayPalCheckoutTokenizationKey)

case .mockedPayPalTokenizationKey:
let tokenizationKey = "sandbox_q7v35n9n_555d2htrfsnnmfb3"
currentViewController = instantiateViewController(with: tokenizationKey)
Expand Down Expand Up @@ -208,6 +213,8 @@ class ContainmentViewController: UIViewController {
return PayPalWebCheckoutViewController(authorization: authorization)
case "SEPADirectDebitViewController":
return SEPADirectDebitViewController(authorization: authorization)
case "ShopperInsightsViewController":
return ShopperInsightsViewController(authorization: authorization)
case "ThreeDSecureViewController":
return ThreeDSecureViewController(authorization: authorization)
case "VenmoViewController":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PaymentButtonBaseViewController: BaseViewController {
paymentButton.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20),
paymentButton.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -20),
paymentButton.centerYAnchor.constraint(equalTo: view.centerYAnchor),
paymentButton.heightAnchor.constraint(equalToConstant: 100)
paymentButton.heightAnchor.constraint(equalToConstant: 300)
])
}

Expand Down
1 change: 1 addition & 0 deletions Demo/Application/Base/Settings/BraintreeDemoSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ enum BraintreeDemoEnvironment: Int {
enum BraintreeDemoAuthType: Int {
case clientToken
case tokenizationKey
case newPayPalCheckoutTokenizationKey
case mockedPayPalTokenizationKey
case uiTestHardcodedClientToken
}
Expand Down
5 changes: 5 additions & 0 deletions Demo/Application/Base/Settings/Settings.bundle/Root.plist
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<string>iDEAL</string>
<string>Amex</string>
<string>SEPA Direct Debit</string>
<string>Shopper Insights</string>
<string>PayPal Messaging</string>
</array>
<key>Values</key>
Expand All @@ -41,6 +42,7 @@
<string>IdealViewController</string>
<string>AmexViewController</string>
<string>SEPADirectDebitViewController</string>
<string>ShopperInsightsViewController</string>
<string>PayPalMessagingViewController</string>
</array>
</dict>
Expand Down Expand Up @@ -91,6 +93,7 @@
<array>
<string>Client Token</string>
<string>Tokenization Key</string>
<string>New PayPal Checkout Tokenization Key</string>
</array>
<key>Key</key>
<string>BraintreeDemoSettingsAuthorizationTypeKey</string>
Expand All @@ -100,11 +103,13 @@
<array>
<string>Client Token</string>
<string>Tokenization Key</string>
<string>New PayPal Checkout Tokenization Key</string>
</array>
<key>Values</key>
<array>
<integer>0</integer>
<integer>1</integer>
<integer>2</integer>
</array>
</dict>
<dict>
Expand Down
55 changes: 55 additions & 0 deletions Demo/Application/Features/Helpers/TextFieldWithLabel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import UIKit

class TextFieldWithLabel: UIView {

// MARK: - Views

lazy var label: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.lineBreakMode = .byWordWrapping
label.numberOfLines = 0
return label
}()

lazy var textField: UITextField = {
let textField = UITextField()
textField.translatesAutoresizingMaskIntoConstraints = false
textField.borderStyle = .roundedRect
textField.clearButtonMode = .never
textField.autocapitalizationType = .none
textField.autocorrectionType = .no
return textField
}()

// MARK: - Init

override init(frame: CGRect) {
super.init(frame: frame)
configureStackView()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

// MARK: - Layout

func configureStackView() {
let stackView = UIStackView(arrangedSubviews: [label, textField])
stackView.axis = .vertical
stackView.spacing = 5
stackView.distribution = .fillEqually
stackView.translatesAutoresizingMaskIntoConstraints = false

addSubview(stackView)

NSLayoutConstraint.activate([
stackView.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor),
stackView.bottomAnchor.constraint(equalTo: safeAreaLayoutGuide.bottomAnchor),
stackView.leadingAnchor.constraint(equalTo: safeAreaLayoutGuide.leadingAnchor),
stackView.trailingAnchor.constraint(equalTo: safeAreaLayoutGuide.trailingAnchor),
])
}
}

Loading

0 comments on commit 0b83215

Please sign in to comment.