Skip to content

Commit

Permalink
Merge Main into v5 (#1029)
Browse files Browse the repository at this point in the history
* Create PayPalMessaging Module (#847)

* added new module for paypal-messaging
* Created empty PayPalMessagingClient.kt and PayPalMessagingClientUnitTest.ktclass files
* Added AndroidManifest.xml to this module
* Created build.gradle to include necessary dependencies and settings

Co-authored-by: Jax DesMarais-Leder <[email protected]>

* Add Payment Insights Client public API shell (#844)

* Added Shopper Insights client, request, result, stubs and docs

* Added Shopper Insights client unit test

Added Shopper Insights client unit test

* Added insight callback updated unit test

* adding unit test documentation

* remove coroutines

* add new line

* remove open

* fix detekt

* Update BraintreeCore/src/main/java/com/braintreepayments/api/BraintreeShopperInsightsClient.kt

Co-authored-by: Sarah Koop <[email protected]>

* rename ShopperInsightsClient

* lighten ShopperInsight docs

* change ShopperInsightRequest from val to var

* remove special char e.g.

* rename response to info

* Add Email and Phone request sub classes with unit tests

* rename methods

* updated unit tests

* Added Email and Phone data class

* Add docs and make interface a functional interface

* simplify syntax

* updating dependency

* Rename parameters

* fix lint issues

* Addressing PR comment: making email a simple string

* fix tests

* Refactoring tests

* linter fixes

* refactoring

* Renaming class

* formatting

* compact code

* add docs

* add kdoc

* more kdocs

* use constants for key strings

* fix suppress params

* Update BraintreeCore/src/test/java/com/braintreepayments/api/ShopperInsightsClientUnitTest.kt

Co-authored-by: sshropshire <[email protected]>

* Rename classes

* Address PR comments.
Move the object to json conversion to API class

* move class to its own file

* Change the ShopperInsightsRequest class signature

* Moving the validation logic

* adding kdoc

---------

Co-authored-by: Sarah Koop <[email protected]>
Co-authored-by: saperi <[email protected]>
Co-authored-by: saperi22 <[email protected]>
Co-authored-by: sshropshire <[email protected]>

* Create ShopperInsights module and move files there. (#853)

* Create ShopperInsights module and move files there.

* Add EOF line

* Add README.md to the module

* clean up dependencies

* Refactor classes to standard package name

* remove unused files

* Modify release.yml to include newly created ShopperInsights module

* Modify release_snapshot.yml to include newly created ShopperInsights module

* remove example instrumented test

* update dependencies

* add dokka plugin to ShopperInsights module

* removing readme

* Add PayPal Messaging Release Steps (#863)

* Add testing PayPalMessaging to GitHub workflows
* Add PayPalMessaging to build.gradle

* Add Shopping Insights Demo App Integration (#854)

* Add Shopping Insights Fragment

* move insight row

* added shopping insight vm, ui and integration

* fix linting

* Add email and phone null switches

* remove unused import

* import ShopperInsights module

---------

Co-authored-by: Sai <[email protected]>

* rename PayPalMessagingClient to PayPalMessagingView (#870)

* Shopper Insights - Merchant analytics (#869)

* Add events for merchant analytics

* Add API for merchants to call to send shopper insights analytics events

* Adding tests

* fixing lint issue

* Use constants instead of sealed class for analytics event strings

* Adding PayPal and Venmo apps installed check (#872)

* Checking if PayPal and Venmo are installed and returning a success result.

* fix linter

* Change logic to check if both Venmo and PayPal apps are installed

* refactoring logic

* rename class

* Wire up demo app

* rename ShoppingInsights to ShopperInsights

* adding another test

* modify tests

* refactor logic

* Created Shopping Insight Api request with default values

* Created Shopper Insight Api Result

* change api result to camel case

* fix

* create body and api separate classes

* fix unit test

* fix detekt

* remove gson

* add ShopperInsightApiResultTest

* change to internal

* separate data class files

* drop call name from shopping api class

* remove vault tokens not needed

* renamed to ShopperInsightsApi

* var to val for request data

* fixed name shoppingInsightsApi

* removed options and default from ShopperInsightsPaymentMethodDetails

* rename to eligibleInPayPalNetwork

* fix eligibleInPayPalNetwork

* fixed json optional object

* rename to ShoppingInsightsCreateBodyUnitTest

* fix ShopperInsightApiResultUnitTest

* Adding analytics events for Shopper Insights (#882)

* move toJson into shopper request api

* create shopper api wrapper class for client

* fix gradle missing empty space

* reorganize and renamed classes

* update class docs

* move out of findeligiblepayments package

* remove Find

* match class name eligiblePaymentsApi

* Add PayPal Messaging Dependency (#888)

* add PayPal Messages dependency
* update build.grade to reflect min SDK version and import snapshots
* add TODO to remove importing snapshots before release
* add rootProject.minSdkVersionPayPalMessaging

* Paypal Messaging Implementation (#895)

* Add PayPalMessagingRequest, PayPalMessagingColor, PayPalMessagingLogoType, PayPalMessagingOfferType, PayPalMessagingPlacement, PayPalMessagingTextAlignment, and PayPalMessagingListener
* Add PayPalMessagingView as the main entry point for merchants

* Messaging analytics

* Add network call for shopper insights (#894)

* add network call using bt client

* add authorization header

* pass result to demo app

* use bearer token

* fix linting

* add move url todo

* fix detekt

* Update BraintreeCore/src/main/java/com/braintreepayments/api/BraintreeHttpClient.kt

Co-authored-by: sshropshire <[email protected]>

* suppress CyclomaticComplexMethod

* check httpError

* return httpError if responseBody is null

* use config environment for base url

* add eligible payments api unit test class

* Update API response logic in ShopperInsightsClient and add test coverage for BraintreeHttpClient, EligiblePaymentsApi and ShopperInsightsClient

* Use BraintreeException instead of a NullPointerException

---------

Co-authored-by: sshropshire <[email protected]>
Co-authored-by: Timothy Chow <[email protected]>

* Address PR comments

* Remove App Check From Shopper Insights and Analytics Updates (#909)

* Remove app check from Shopper Insights and update analytics logic

* Fix test names

* Add function for callbackSuccess

* update enum for analytics event names

* Helper method for onSuccess

* Adding new line

* Remove .value

* Remove semicolon on package

* Add PayPal-Client-Metadata-Id to Shopper Insights API Call (#912)

* Add PayPal-Client-Metadata-Id to shopper insights API call

* Fix spacing lint issue

* Remove unneeded empty map in ApiClient

* Add PayPal Messaging Feature to Demo App (#915)

* Add PayPalMessagingFragment to Demo app
* Add button to demo app to select this feature
* Implement PayPalMessagingView
* Update PayPalMessagingView method and subclass FrameLayout so the class is a view type
* Move context to constructor vs in start method as it is needed for FrameLayout subclass
* Update CHANGELOG with these changes

* [Shopper Insights] Demo App Parity (#913)

 - Add Venmo & PayPal Vault buttons to ShopperInsights demo
    - Disable Venmo & PP buttons until `getRecommendedPaymentMethods()` result
 - Add default email & phone test values to trigger mocked API response

* Add optional param, payerEmail, to PayPalVaultRequest (#918)

* Cleanup PayPal Messaging Implementation (#927)

* Move to setListener() pattern used in other modules
* Remove unneeded else block

* Remove payee and merchant id from eligible payments API request (#929)

* Add Unit Tests for PayPal Messaging (#925)

* Add Unit Tests for PayPal Messaging feature

Co-authored-by: Justin Warmkessel <[email protected]>

* DocString on Country Restrictions

* fix line length lint error

* Jax PR feedback

* Add merchant logging in the Shopper Insights demo flow (#933)

* Update Dependencies (#936)

* Update Room to 2.6.1 and Dokka to 1.9.10

* Update gson to 2.10.0 in the demo module

* Update Play Services to 19.3.0

* Add network config for Demo app (#938)

* Add has user location consent to Data Collector and PayPal Data Collector (#954)

* Add hasUserLocationConsent param to the Data Collector and PayPal Data Collector modules

* Add unit tests for overloaded methods defaulting to false

* Add deprecation annotation and add feature branch snapshot trigger

* Add test case when request object is passed in

* Add workflow dispatch

* Add has user location consent param in PayPal, PayPal Native, and Local Payment modules (#956)

* Add hasUserLocationConsent parameter to the PayPal module

* Add hasUserLocationConsent parameter to the PayPal Native module

* Add hasUserLocationConsent parameter to the Local Payment Module

* Update changelog for hasUserLocationConsent interface changes

* Update changelog for Data Collector and PayPal Data Collector

* Update changelog wording and change unit test assertion

* Update PayPalNativeCheckout/src/main/java/com/braintreepayments/api/PayPalNativeCheckoutVaultRequest.java

Co-authored-by: Sarah Koop <[email protected]>

* Add empty constructor for PayPalRequest

---------

Co-authored-by: Sarah Koop <[email protected]>

* Update PULL_REQUEST_TEMPLATE.MD (#957)

* Add GooglePay.isReadyToPay() with Context Parameter (#951)

* Add isReadyToPay method for GooglePayClient with Context.

* Add unit tests for GooglePayClient application context when calling isReadyToPay.

* Fix error message for null context in GooglePayClient.isReadyToPay.

* Fix unit test issue.

* Add CHANGELOG entry.

* Update Magnes SDK and Add Javadocs for the hasUserLocationConsent Param (#961)

* Update Magnes SDK to 5.5.0 and add javadocs for the hasUserLocationConsent param in Local Payment and PayPal modules

* Revert PayPalNative interface changes

* Add docs for DataCollector and PayPalDataCollector

* Update CHANGELOG.md to add Magnes version bump

Co-authored-by: Sarah Koop <[email protected]>

* Bump Detekt to 1.23.6 for ignoring maxLineLength for comments that contain URLs

---------

Co-authored-by: Sarah Koop <[email protected]>

* Remove changlog links to developer docs for the Google Play Store Rejection fix

* Update PayPal/src/main/java/com/braintreepayments/api/PayPalCheckoutRequest.java

Co-authored-by: Sarah Koop <[email protected]>

* Use new constructor for LocalPaymentRequest

* Fix indent for Google Play changelog

Co-authored-by: Sarah Koop <[email protected]>

* Remove internal javadoc

Co-authored-by: Sarah Koop <[email protected]>

* Fix indent for Google Play changelog and move riskCorrelationId into PayPalDataCollector

* Fix javadoc syntax

* Fix compile error in PayPalDataCollectorTest (#967)

* Release 4.44.0

* Prepare for development

* Add Google Pay Direct Integration (#972)

* Make direct Google Pay integration method public

* Add new certs to v4 (#969)

* Updated expiring certs

* Update CHANGELOG.md

* Updated cert output file

* PayPal Native - Play Store Compliance Fix (#977)

* Bump MXO SDK to 1.3.2 and bump Magnes SDK to 5.5.1

* Add hasUserLocationConsent boolean to PayPal Native request classes and pass flag to the MXO SDK and Magnes

* Add sections to CHANGELOG.md

Co-authored-by: Sarah Koop <[email protected]>

* Update hasUserLocationConsent doc to remove optional

Co-authored-by: Sarah Koop <[email protected]>

* Make PayPalNativeRequest constructor package private

Co-authored-by: Sarah Koop <[email protected]>

---------

Co-authored-by: Sarah Koop <[email protected]>

* Release 4.45.0

* Prepare for development

* Remove duplicate test

* Buyer Email for PayPal One Time Checkout (#978)

* Pass buyer email to PayPal one time checkout

* Update changelog

* Add input for setting buyer email address in the demo app (#979)

* Send `link_type` FPTI tag (#976)

* Add linkt type parameter used by Venmo Client

* Fix some UTs

* Add description on CHANGELOG

* Update UTs

* Address PR comments

* Migrate database

* Delete unnecessary file

* Fix lint

* Fix lint

* Add database migration support from version 1 to version 3

* Revert changes on v2 json file

* Remove unnecessary manual migration

* Add ExperimentalBetaApi annotation (#985)

* Add ExperimentalBetaApi annotation

* Add kdocs to annotation class

* Add New Demo Tokenization Key for PayPal (#996)

* Add new tokenization key

* Fix keys and settings

* Bump PayPal Messages to v1.0.0 develop.2 (#981)

* Update Gradle with PayPal Messages 1.0.0-develop.2

* Replace PayPalMessagingPlacement with PayPalMessagingPageType

* Update PayPalMessagingRequest

* Fix UTs

* Update CHANGELOG

* Add version SDK name method on Braintree Client

* Rename PayPalMessagingLogoType case simple to none

* Update UT

* Remove getter and add Version Name on gradle file

* Fix UTs

* Replace rawValue with internalValue

* Replace default logo type and textAligment values with the same default values in PayPalMessageStyle

* Revert color parameter on request constructor

* Revert Request default values

* Update README - Added upgrade SDK message (#994)

* Update README - Added upgrade SDK message

* Added Announcements section

* Handle empty email address (#1000)

* Prevent sending email param when email is empty and send postal code in the demo app

* Use put instead of putOpt

* Add `venmo_installed` Analytics tag (#991)

* Add venmo_installed Analytics tag

* revert changes to 3.json

* fix lint error

* fix autoMigration

* venmoInstalled in BraintreeClient

* Steven PR feedback: deviceInspector init in constructor

* Write venmoInstalled values to analytics db

* Steven PR feedback, incremental database migration

---------

Co-authored-by: Sai <[email protected]>

* Add requiresOptin (#1001)

* Add ExperimentalBetaApi annotation

[email protected]
[email protected]

---------

Co-authored-by: Sai <[email protected]>

* Paypal messaging feature update dependency (#1002)

[email protected]
[email protected]
[email protected]

* Update the unit test

* Update to dependency 1.0.0

* Add isEligibleInPayPalNetwork boolean to ShopperInsightsInfo (#1005)

* Add isEligibleInPayPalNetwork boolean to ShopperInsightsInfo

* Add kdoc for isEligibleInPayPalNetwork

* Add Shopper Insights to the changelog (#1006)

* Add Shopper Insights to the changelog

* Remove individual classes

Co-authored-by: Sarah Koop <[email protected]>

---------

Co-authored-by: Sarah Koop <[email protected]>

* Send `is_vault` FPTI tag (#1004)

* Update Analytics database with isVaultResquest parameter

* Add isVaultResquest keys on client

* Update BraintreeClient.sendAnalytics with isVaultRequest parameter

* Add isVaultRequest in sendAnalytics calls for PayPalClient

* Add isVaultRequest in semdAnalytitcs calls for VenmoClient

* Set isVaultRequest up on VenmoClient

* Update AnalyticsClientTests

* Update PayPal client tests

* Update CHANGELOG

* Fix lint

* Fix VisaCheckout module after adding new parameter in sendAnalyticsEvent

* Fix Venmo Client UTs

* Update PayPalNativeCheckoutClient with isVaultRequest parameter in sendAnalytics method

* Update Changelog

* Update CHANGELOG

* Update Changelog

* bump paypal messaging to version 1.0.1 (#1010)

* Chore messaging set global analytics (#1007)

* Use PayPalMessageConfig setGlobalAnalytics for integration and version

[email protected]
[email protected]
[email protected]

* Update PayPalMessaging/src/main/java/com/braintreepayments/api/PayPalMessagingView.kt

Co-authored-by: Jax DesMarais-Leder <[email protected]>

---------

Co-authored-by: Jax DesMarais-Leder <[email protected]>

* Update PayPalInternalClient to use Pairing ID as Client Metadata ID (#983)

* Update PayPalInternalClient to use pairing ID as client metadata ID by default.

* Set applicationGuid for data collector request

* Add unit tests for ba_token and token url param parsing from PayPal redirect URL.

* Fix unit tests for PayPal Native Checkout.

---------

Co-authored-by: Sai <[email protected]>

* Update existing PayPalMessagingView (#1013)

* Create internal messageView property to track if has been initialized

* Add test to validate number of subviews

* Address PR comment

* update changelog.md (#1017)

* Release 4.45.1

* Prepare for development

* Log context ID analytics before launching PayPal browser switch (#1018)

* Release 4.46.0

* Prepare for development

* Shopper Insights Final Changes (#1024)

* Remove merchantId from EligiblePaymentsApiRequest

* Use the default tokenization key for prod

* Remove new line

* Update ShopperInsights changelog

* Fix demo app fragment layout

* Update CHANGELOG with Missing Timestamps (#1022)

* Add missing CHANGELOG for pointed versions.

* Add additional timestamps manually.

* Fix 3DS Black Screen Bug on Android 14 (#1025)

* Add translucent theme to ThreeDSecureActivity.

* Add reference links.

* Update CHANGELOG.

* App links feature (#1027)

* Add appLinkReturnUri to BraintreeClient (#980)

* Add appLinkReturnUri to BraintreeClient and collapse BraintreeClient constructors using default values

* Add doc strings and unit tests

* Update BraintreeCore/src/main/java/com/braintreepayments/api/BraintreeClient.kt

Co-authored-by: Sarah Koop <[email protected]>

* Update changelog for appLinkReturnUri

* Fix lint

---------

Co-authored-by: Sarah Koop <[email protected]>

* Add useAppLinkReturn to PayPalRequest (#984)

* Add useAppLinkReturn to PayPalRequest for Android App Link support

* Update changelog

* Update property name to appLinkEnabled

* Update PayPal/src/main/java/com/braintreepayments/api/PayPalRequest.java

Co-authored-by: Sarah Koop <[email protected]>

---------

Co-authored-by: Sarah Koop <[email protected]>

* Send app link URL to PayPal API (#986)

* Add ability to launch PayPal flows with app links (#988)

* Add ability to launch PayPal flows with app links

* Add demo merchant site URL

* Add intent filter for demo app link (#989)

* Pass app link to browser switch (#999)

* Pass app link uri to BrowserSwtichOptions.

* update browser-switch dependency

* Update CHANGELOG.md

Co-authored-by: Sarah Koop <[email protected]>

* Update PayPal/src/main/java/com/braintreepayments/api/PayPalClient.java

Co-authored-by: Sarah Koop <[email protected]>

---------

Co-authored-by: Sarah Koop <[email protected]>

* exclude tests from LargeClass detekt rule

---------

Co-authored-by: Tim Chow <[email protected]>
Co-authored-by: Sarah Koop <[email protected]>

* Release 4.47.0

* Prepare for development

* Resolve compile issues caused by merge conflicts

* Fix lint issues and failing unit tests (WIP)

* Fix remaining Venmo tests

---------

Co-authored-by: agedd <[email protected]>
Co-authored-by: Jax DesMarais-Leder <[email protected]>
Co-authored-by: Max Hastings <[email protected]>
Co-authored-by: Sarah Koop <[email protected]>
Co-authored-by: saperi <[email protected]>
Co-authored-by: saperi22 <[email protected]>
Co-authored-by: sshropshire <[email protected]>
Co-authored-by: mhastings <[email protected]>
Co-authored-by: Justin Warmkessel <[email protected]>
Co-authored-by: scannillo <[email protected]>
Co-authored-by: warmkesselj <[email protected]>
Co-authored-by: Sammy Cannillo <[email protected]>
Co-authored-by: Victoria Park <[email protected]>
Co-authored-by: braintreeps <[email protected]>
Co-authored-by: Stephanie <[email protected]>
Co-authored-by: Rich Herrera <[email protected]>
17 people authored Jun 13, 2024
1 parent 6ab7d46 commit 83a8eba
Showing 1,221 changed files with 86,368 additions and 62,776 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -114,6 +114,30 @@ jobs:
uses: ./.github/actions/unit_test_module
with:
module: PayPal
unit_test_paypal_messaging:
name: PayPal Messaging Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Setup Java 8
uses: ./.github/actions/setup
- name: Run Unit Tests
uses: ./.github/actions/unit_test_module
with:
module: PayPalMessaging
unit_test_shopper_insights:
name: Shopper Insights Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Setup Java 8
uses: ./.github/actions/setup
- name: Run Unit Tests
uses: ./.github/actions/unit_test_module
with:
module: ShopperInsights
unit_test_three_d_secure:
name: ThreeDSecure Unit Tests
runs-on: ubuntu-latest
@@ -173,6 +197,8 @@ jobs:
unit_test_google_pay,
unit_test_local_payment,
unit_test_paypal,
unit_test_paypal_messaging,
unit_test_shopper_insights,
unit_test_three_d_secure,
unit_test_venmo,
unit_test_visa_checkout,
26 changes: 26 additions & 0 deletions .github/workflows/release_snapshot.yml
Original file line number Diff line number Diff line change
@@ -114,6 +114,30 @@ jobs:
uses: ./.github/actions/unit_test_module
with:
module: PayPal
unit_test_paypal_messaging:
name: PayPal Messaging Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Setup Java 8
uses: ./.github/actions/setup
- name: Run Unit Tests
uses: ./.github/actions/unit_test_module
with:
module: PayPalMessaging
unit_test_shopper_insights:
name: Shopper Insights Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Setup Java 8
uses: ./.github/actions/setup
- name: Run Unit Tests
uses: ./.github/actions/unit_test_module
with:
module: ShopperInsights
unit_test_three_d_secure:
name: ThreeDSecure Unit Tests
runs-on: ubuntu-latest
@@ -173,6 +197,8 @@ jobs:
unit_test_google_pay,
unit_test_local_payment,
unit_test_paypal,
unit_test_paypal_messaging,
unit_test_shopper_insights,
unit_test_three_d_secure,
unit_test_venmo,
unit_test_visa_checkout,
1 change: 1 addition & 0 deletions BraintreeCore/build.gradle
Original file line number Diff line number Diff line change
@@ -94,6 +94,7 @@ dependencies {
testImplementation deps.mockitoCore
testImplementation deps.jsonAssert
testImplementation deps.mockk
testImplementation deps.kotlinTest
testImplementation project(':PayPal')
testImplementation project(':TestUtils')
testImplementation project(':Venmo')
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"formatVersion": 1,
"database": {
"version": 4,
"identityHash": "aea9bd6b15fd0bdcccc15f2ee9ed326a",
"entities": [
{
"tableName": "analytics_event",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`name` TEXT NOT NULL, `paypal_context_id` TEXT, `link_type` TEXT, `timestamp` INTEGER NOT NULL, `venmo_installed` INTEGER NOT NULL DEFAULT 0, `_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)",
"fields": [
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "payPalContextId",
"columnName": "paypal_context_id",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "linkType",
"columnName": "link_type",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "timestamp",
"columnName": "timestamp",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "venmoInstalled",
"columnName": "venmo_installed",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "id",
"columnName": "_id",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"_id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'aea9bd6b15fd0bdcccc15f2ee9ed326a')"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"formatVersion": 1,
"database": {
"version": 5,
"identityHash": "be2819613b2d28975a74cd80ed788cd5",
"entities": [
{
"tableName": "analytics_event",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`name` TEXT NOT NULL, `paypal_context_id` TEXT, `link_type` TEXT, `timestamp` INTEGER NOT NULL, `venmo_installed` INTEGER NOT NULL DEFAULT 0, `is_vault` INTEGER NOT NULL DEFAULT 0, `_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)",
"fields": [
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "payPalContextId",
"columnName": "paypal_context_id",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "linkType",
"columnName": "link_type",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "timestamp",
"columnName": "timestamp",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "venmoInstalled",
"columnName": "venmo_installed",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "isVault",
"columnName": "is_vault",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "id",
"columnName": "_id",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"_id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'be2819613b2d28975a74cd80ed788cd5')"
]
}
}
Original file line number Diff line number Diff line change
@@ -41,8 +41,8 @@ public void setUp() {
public void sendsCorrectlyFormattedAnalyticsRequestToWorkManager() throws Exception {
Authorization authorization = Authorization.fromString(Fixtures.TOKENIZATION_KEY);
Configuration configuration = Configuration.fromJson(Fixtures.CONFIGURATION_WITH_ENVIRONMENT);

AnalyticsEvent event = new AnalyticsEvent("event.started", null, null, 123);
AnalyticsEvent event = new AnalyticsEvent("event.started", null, null, 123, false, false);

AnalyticsClient sut = new AnalyticsClient(context);
UUID workSpecId = sut.sendEvent(configuration, event, "sessionId", "custom", authorization);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.braintreepayments.api

/**
* The annotated method or class is in beta. It's public API may change or be removed in future releases.
*/
@RequiresOptIn
@Retention(AnnotationRetention.BINARY)
annotation class ExperimentalBetaApi
Original file line number Diff line number Diff line change
@@ -49,6 +49,8 @@ internal class AnalyticsClient @VisibleForTesting constructor(
.putString(WORK_INPUT_KEY_PAYPAL_CONTEXT_ID, event.payPalContextId)
.putString(WORK_INPUT_KEY_LINK_TYPE, event.linkType)
.putLong(WORK_INPUT_KEY_TIMESTAMP, event.timestamp)
.putBoolean(WORK_INPUT_KEY_VENMO_INSTALLED, event.venmoInstalled)
.putBoolean(WORK_INPUT_KEY_IS_VAULT_REQUEST, event.isVaultRequest)
.build()

val analyticsWorkRequest =
@@ -65,11 +67,20 @@ internal class AnalyticsClient @VisibleForTesting constructor(
val payPalContextId = inputData.getString(WORK_INPUT_KEY_PAYPAL_CONTEXT_ID)
val linkType = inputData.getString(WORK_INPUT_KEY_LINK_TYPE)
val timestamp = inputData.getLong(WORK_INPUT_KEY_TIMESTAMP, INVALID_TIMESTAMP)
val venmoInstalled = inputData.getBoolean(WORK_INPUT_KEY_VENMO_INSTALLED, false)
val isVaultRequest = inputData.getBoolean(WORK_INPUT_KEY_IS_VAULT_REQUEST, false)

return if (eventName == null || timestamp == INVALID_TIMESTAMP) {
ListenableWorker.Result.failure()
} else {
val event = AnalyticsEvent(eventName, payPalContextId, linkType, timestamp)
val event = AnalyticsEvent(
eventName,
payPalContextId,
linkType,
timestamp,
venmoInstalled,
isVaultRequest
)
val analyticsEventDao = analyticsDatabase.analyticsEventDao()
analyticsEventDao.insertEvent(event)
ListenableWorker.Result.success()
@@ -159,11 +170,11 @@ internal class AnalyticsClient @VisibleForTesting constructor(
try {
val analyticsRequest = serializeEvents(authorization, events, metadata)
httpClient.post(
FPTI_ANALYTICS_URL,
analyticsRequest.toString(),
null,
authorization,
HttpNoResponse()
path = FPTI_ANALYTICS_URL,
data = analyticsRequest.toString(),
configuration = null,
authorization = authorization,
callback = HttpNoResponse()
)
} catch (e: JSONException) { /* ignored */
}
@@ -195,6 +206,8 @@ internal class AnalyticsClient @VisibleForTesting constructor(
.putOpt(PAYPAL_CONTEXT_ID_KEY, analyticsEvent.payPalContextId)
.putOpt(LINK_TYPE_KEY, analyticsEvent.linkType)
.put(TIMESTAMP_KEY, analyticsEvent.timestamp)
.put(VENMO_INSTALLED_KEY, analyticsEvent.venmoInstalled)
.put(IS_VAULT_REQUEST_KEY, analyticsEvent.isVaultRequest)
.put(TENANT_NAME_KEY, "Braintree")
eventParamsJSON.put(singleEventJSON)
}
@@ -208,6 +221,8 @@ internal class AnalyticsClient @VisibleForTesting constructor(
companion object {
private const val FPTI_ANALYTICS_URL = "https://api-m.paypal.com/v1/tracking/batch/events"
private const val PAYPAL_CONTEXT_ID_KEY = "paypal_context_id"
private const val VENMO_INSTALLED_KEY = "venmo_installed"
private const val IS_VAULT_REQUEST_KEY = "is_vault"
private const val LINK_TYPE_KEY = "link_type"
private const val TOKENIZATION_KEY = "tokenization_key"

@@ -229,6 +244,8 @@ internal class AnalyticsClient @VisibleForTesting constructor(
const val WORK_INPUT_KEY_SESSION_ID = "sessionId"
const val WORK_INPUT_KEY_TIMESTAMP = "timestamp"
const val WORK_INPUT_KEY_PAYPAL_CONTEXT_ID = "payPalContextId"
const val WORK_INPUT_KEY_VENMO_INSTALLED = "venmoInstalled"
const val WORK_INPUT_KEY_IS_VAULT_REQUEST = "isVaultRequest"
const val WORK_INPUT_KEY_LINK_TYPE = "linkType"
private const val DELAY_TIME_SECONDS = 30L

Original file line number Diff line number Diff line change
@@ -8,11 +8,13 @@ import androidx.room.RoomDatabase

// Ref: https://developer.android.com/training/data-storage/room/migrating-db-versions
@Database(
version = 3,
version = 5,
entities = [AnalyticsEvent::class],
autoMigrations = [
AutoMigration(from = 1, to = 3),
AutoMigration(from = 2, to = 3)
AutoMigration(from = 1, to = 2),
AutoMigration(from = 2, to = 3),
AutoMigration(from = 3, to = 4),
AutoMigration(from = 4, to = 5)
]
)
internal abstract class AnalyticsDatabase : RoomDatabase() {
Original file line number Diff line number Diff line change
@@ -20,7 +20,13 @@ open class AnalyticsEvent internal constructor(
@ColumnInfo(name = "link_type")
open val linkType: String? = null,

open val timestamp: Long = System.currentTimeMillis()
open val timestamp: Long = System.currentTimeMillis(),

@ColumnInfo(name = "venmo_installed", defaultValue = "0")
open val venmoInstalled: Boolean = false,

@ColumnInfo(name = "is_vault", defaultValue = "0")
open val isVaultRequest: Boolean = false
) {
@JvmField
@PrimaryKey(autoGenerate = true)
Original file line number Diff line number Diff line change
@@ -33,17 +33,18 @@ class ApiClient(private val braintreeClient: BraintreeClient) {
paymentMethod.setSessionId(braintreeClient.sessionId)

sendAnalyticsEvent("card.rest.tokenization.started")
sendPOST(url, paymentMethod.buildJSON().toString(), object : HttpResponseCallback {
override fun onResult(responseBody: String?, httpError: Exception?) {
parseResponseToJSON(responseBody)?.let { json ->
sendAnalyticsEvent("card.rest.tokenization.success")
callback.onResult(json, null)
} ?: httpError?.let { error ->
sendAnalyticsEvent("card.rest.tokenization.failure")
callback.onResult(null, error)
}
sendPOST(
url = url,
data = paymentMethod.buildJSON().toString(),
) { responseBody, httpError ->
parseResponseToJSON(responseBody)?.let { json ->
sendAnalyticsEvent("card.rest.tokenization.success")
callback.onResult(json, null)
} ?: httpError?.let { error ->
sendAnalyticsEvent("card.rest.tokenization.failure")
callback.onResult(null, error)
}
})
}
}

private fun parseResponseToJSON(responseBody: String?): JSONObject? =
Loading

0 comments on commit 83a8eba

Please sign in to comment.