Skip to content

Commit

Permalink
[AppSwitch] Update PayPal Classes (#1102)
Browse files Browse the repository at this point in the history
* Remove publishing javadocs from maven publish (#1082)

* Remove appLinkEnabled property (#1085)

* Remove appLinkEnabled property from PayPalRequest - app link is now required for PayPal

* Remove unused import

* Add breaking changes section to changelog

* Update 3DS and GraphQL Endpoint Sent to FPTI (v5) (#1080)

* update endpoint logic for 3DS and graphQL
* update constants
* add CHANGELOG entry
* simplify cleanedPath logic for 3DS
* remove analytics path check since that post request uses a different http client

* Parcelize Nonce Classes (#1087)

* Convert Nonce classes to Kotlin and implement Parcelable using the Parcelize annotation

* Restrict constructor scopes

* Convert nonce classes to data classes and remove detekt rule

* Remove unused type property in LocalPaymentNonce

* Paypal Module Kotlin Conversion (#1088)

* Convert PayPalPaymentResource to Kotlin

* Convert PayPalPaymentAuthResultInfo to Kotlin

* Convert PayPalBrowserSwitchException to Kotlin

* Convert PayPal internal callbacks to Kotlin

* Convert PayPalPaymentAuthRequestParams to Kotlin

* Convert PayPalCreditFinancingAmount to Kotlin

* Convert PayPalCreditFinancing to Kotlin

* Convert PayPalPaymentIntent to Kotlin

* Delete Java PayPalPaymentIntent file

* Add PayPalPaymentIntent to changelog

* Rename payerAcceptance to hasPayerAcceptance

* Convert PayPal Classes to Kotlin (#1089)

* Convert PayPalPaymentResource to Kotlin

* Convert PayPalPaymentAuthResultInfo to Kotlin

* Convert PayPalBrowserSwitchException to Kotlin

* Convert PayPal internal callbacks to Kotlin

* Convert PayPalPaymentAuthRequestParams to Kotlin

* Convert PayPalCreditFinancingAmount to Kotlin

* Convert PayPalCreditFinancing to Kotlin

* Convert PayPalPaymentIntent to Kotlin

* Delete Java PayPalPaymentIntent file

* Convert PayPalAccount to Kotlin

* Convert PayPalRequest, PayPalVaultRequest, and PayPalCheckoutRequest to Kotlin

* Update changelog wording

* Changelog updates

* Move enums to separate files

* Convert PayPal module classes to Kotlin (#1091)

* Convert PayPalLineItem to Kotlin

* Delete PayPalAccount.java

* Convert PayPalClient to Kotlin

* Convert PayPalInternalClient to Kotlin

* Rename PayPalLineItemKind enums

* Update unitAmount to non null

* Remove old analytic events lingering from v4 (#1093)

* Drop android prefix from each analytics event name (#1095)

* Merge branch 'main' into update-paypal-classes

* Update PayPal classes with Java App Switch logic

* Override VaultRequest parameter if venice app is installed or not

* Fix lint issues

* Remove unnecessary access modifier

* Fix lint issue

---------

Co-authored-by: Tim Chow <[email protected]>
Co-authored-by: Jax DesMarais-Leder <[email protected]>
Co-authored-by: scannillo <[email protected]>
  • Loading branch information
4 people authored Aug 7, 2024
1 parent ee52cee commit 133f46b
Show file tree
Hide file tree
Showing 85 changed files with 2,614 additions and 3,988 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ internal class AnalyticsClient constructor(

private fun mapAnalyticsEventToFPTIEventJSON(event: AnalyticsEvent): String {
val json = JSONObject()
.put(FPTI_KEY_EVENT_NAME, "android.${event.name}")
.put(FPTI_KEY_EVENT_NAME, event.name)
.put(FPTI_KEY_TIMESTAMP, event.timestamp)
.put(FPTI_KEY_VENMO_INSTALLED, event.venmoInstalled)
.put(FPTI_KEY_IS_VAULT, event.isVaultRequest)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,14 @@ class BraintreeClient @VisibleForTesting internal constructor(
) { response, httpError ->
response?.let {
try {
json?.optString(GraphQLConstants.Keys.OPERATION_NAME)
json?.optString(GraphQLConstants.Keys.QUERY)
?.let { query ->
val queryDiscardHolder = query.replace(Regex("^[^\\(]*"), "")
val finalQuery = query.replace(queryDiscardHolder, "")
val params = AnalyticsEventParams(
startTime = it.timing.startTime,
endTime = it.timing.endTime,
endpoint = query
endpoint = finalQuery
)
sendAnalyticsEvent(
CoreAnalytics.apiRequestLatency,
Expand Down Expand Up @@ -355,7 +357,11 @@ class BraintreeClient @VisibleForTesting internal constructor(
}

private fun sendAnalyticsTimingEvent(endpoint: String, timing: HttpResponseTiming) {
val cleanedPath = endpoint.replace(Regex("/merchants/([A-Za-z0-9]+)/client_api"), "")
var cleanedPath = endpoint.replace(Regex("/merchants/([A-Za-z0-9]+)/client_api"), "")
cleanedPath = cleanedPath.replace(
Regex("payment_methods/.*/three_d_secure"), "payment_methods/three_d_secure"
)

sendAnalyticsEvent(
CoreAnalytics.apiRequestLatency,
AnalyticsEventParams(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ object GraphQLConstants {
const val LEGACY_CODE = "legacyCode"
const val URL = "url"
const val FEATURES = "features"
const val OPERATION_NAME = "operationName"
}

object ErrorTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import androidx.annotation.RestrictTo
* It is not covered by Semantic Versioning and may change or be removed at any time.
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public enum class LinkType(val stringValue: String) {
enum class LinkType(val stringValue: String) {
UNIVERSAL("universal"),
DEEPLINK("deeplink")
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.braintreepayments.api.core

import android.os.Parcel
import android.os.Parcelable
import androidx.annotation.RestrictTo
import androidx.annotation.VisibleForTesting

/**
* Base class representing a method of payment for a customer. [PaymentMethodNonce] represents the
Expand All @@ -14,40 +12,9 @@ import androidx.annotation.VisibleForTesting
* actions.
* @property isDefault `true` if this payment method is the default for the current customer, `false` otherwise
*/
open class PaymentMethodNonce : Parcelable {

companion object {
@JvmField
val CREATOR = object : Parcelable.Creator<PaymentMethodNonce> {
override fun createFromParcel(`in`: Parcel) = PaymentMethodNonce(`in`)
override fun newArray(size: Int) = arrayOfNulls<PaymentMethodNonce>(size)
}
}

open val string: String
abstract class PaymentMethodNonce
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
constructor(
open val string: String,
open val isDefault: Boolean

/**
* @suppress
*/
@VisibleForTesting
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
constructor(nonce: String, isDefault: Boolean) {
string = nonce
this.isDefault = isDefault
}

override fun describeContents(): Int {
return 0
}

override fun writeToParcel(dest: Parcel, flags: Int) {
dest.writeString(string)
dest.writeByte(if (isDefault) 1.toByte() else 0.toByte())
}

protected constructor(inParcel: Parcel) {
string = inParcel.readString() ?: ""
isDefault = inParcel.readByte() > 0
}
}
) : Parcelable
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class AnalyticsClientUnitTest {
// language=JSON
val expectedJSON = """
{
"event_name": "android.sample-event-name",
"event_name": "sample-event-name",
"t": 123,
"venmo_installed": false,
"is_vault": false,
Expand Down Expand Up @@ -127,7 +127,7 @@ class AnalyticsClientUnitTest {
// language=JSON
val expectedJSON = """
{
"event_name": "android.sample-event-name",
"event_name": "sample-event-name",
"paypal_context_id": "fake-paypal-context-id",
"link_type": "fake-link-type",
"t": 456,
Expand Down Expand Up @@ -470,7 +470,7 @@ class AnalyticsClientUnitTest {
},
"event_params": [
{
"event_name": "android.crash",
"event_name": "crash",
"t": 123,
"tenant_name": "Braintree",
"venmo_installed": false,
Expand Down

This file was deleted.

16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Braintree Android SDK Release Notes

## unreleased
* BraintreeCore
* Update `endpoint` syntax sent to FPTI for 3D Secure and Venmo flows
* Breaking Changes
* PayPal
* Remove `appLinkEnabled` from `PayPalRequest` as Android app links are now required
* Update `PayPalCreditFinancing.hasPayerAcceptance()` to `getHasPayerAcceptance()` (Java)
* Change `PayPalPaymentIntent` to an enum
* Change `PayPalLandingPageType` to an enum
* Change `PayPalPaymentUserAction` to an enum
* Update `PayPalRequest.hasUserLocationConsent()` to `getHasUserLocationConsent()` (Java)
* Change `PayPalLineItem.desc()` to `setDescription()`
* Change `PayPalLineItemKind` to an enum
* Rename `PayPalLineItemKind.KIND_CREDIT` to `CREDIT`
* Rename `PayPalLineItemKind.KIND_DEBIT` to `DEBIT`

## 5.0.0-beta1 (2024-07-23)

* Breaking Changes
Expand Down
1 change: 1 addition & 0 deletions Card/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id 'com.android.library'
id 'kotlin-android'
id 'org.jetbrains.dokka'
id 'kotlin-parcelize'
}

android {
Expand Down
Loading

0 comments on commit 133f46b

Please sign in to comment.