Skip to content

Commit

Permalink
Merge branch 'v5' into update-local-payment-to-fpti-events
Browse files Browse the repository at this point in the history
* v5:
  Remove LocalPaymentBrowserSwitchRequest (#900)
  Remove SEPADirectDebitBrowserSwitchRequest and Kotlin Conversion (#901)
  Remove PayPalBrowserSwitchRequest and Kotlin Conversion (#899)
  Update LocalPaymentLauncher for Browser Switch v3 (#897)
  Drop -m drop FPTI v1/tracking/batch/events URL (#896)
  PayPalLauncher with v3 BrowserSwitchClient (#883)
  SEPADirectDebitLauncher with v3 BrowserSwitchClient (#893)
  Prepare for development
  Release 4.41.0
  Update Venmo demo to send MULTI_USE when vault is enabled (#890)
  BraintreeClient Method Cleanup (#887)
  Update PULL_REQUEST_TEMPLATE.MD
  Adding imageUrl, upcType, upcCode to PayPalLineItem (#871)
  Update mxo 1.2.1 (#881)
  Update README.md

# Conflicts:
#	LocalPayment/src/main/java/com/braintreepayments/api/LocalPaymentClient.java
  • Loading branch information
tdchow committed Feb 5, 2024
2 parents a8ac2b4 + f4ad879 commit a4d6d73
Show file tree
Hide file tree
Showing 1,050 changed files with 5,028 additions and 3,160 deletions.
11 changes: 9 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.MD
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@ Thank you for your contribution to Braintree.

-

### Checklist
### Checklist

- [ ] Added a changelog entry
- [ ] Relevant test coverage

### Authors
> List GitHub usernames for everyone who contributed to this pull request.
-
### PayPal and Braintree engineering requirements
> If you're an engineer for PayPal or Braintree, complete this section. For PRs from the community, please ignore!
**When do these changes need to be released?**
[ ] ASAP (let's discuss outside this PR)
[ ] Soon, here's our target release date: <DD/MM/YYYY>
[ ] Whenever, no rush
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ 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 FPTI_ANALYTICS_URL = "https://api.paypal.com/v1/tracking/batch/events"

private const val EVENTS_CONTAINER_KEY = "events"
private const val BATCH_PARAMS_KEY = "batch_params"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package com.braintreepayments.api

import android.content.Context
import android.content.Intent
import android.content.pm.ActivityInfo
import android.net.Uri
import androidx.annotation.RestrictTo
import androidx.annotation.VisibleForTesting
import androidx.fragment.app.FragmentActivity
import com.braintreepayments.api.IntegrationType.Integration

/**
Expand Down Expand Up @@ -217,72 +214,6 @@ open class BraintreeClient @VisibleForTesting internal constructor(
}
}

/**
* @suppress
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@Throws(BrowserSwitchException::class)
fun startBrowserSwitch(
activity: FragmentActivity?,
browserSwitchOptions: BrowserSwitchOptions?
) {
if (activity != null && browserSwitchOptions != null) {
browserSwitchClient.start(activity, browserSwitchOptions)
}
}

/**
* @suppress
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
fun getBrowserSwitchResult(activity: FragmentActivity): BrowserSwitchResult? =
browserSwitchClient.getResult(activity)

/**
* Deliver a browser switch result from an Activity's pending deep link intent url.
* If [BraintreeClient.launchesBrowserSwitchAsNewTask] is set to true,
* use [BraintreeClient.deliverBrowserSwitchResultFromNewTask] instead.
*
* @param activity
* @return [BrowserSwitchResult]
*/
open fun deliverBrowserSwitchResult(activity: FragmentActivity): BrowserSwitchResult? {
return browserSwitchClient.deliverResult(activity)
}

/**
* @suppress
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
fun getBrowserSwitchResultFromNewTask(context: Context): BrowserSwitchResult? {
return browserSwitchClient.getResultFromCache(context)
}

/**
* Deliver pending browser switch result received by [BraintreeDeepLinkActivity] when
* [BraintreeClient.launchesBrowserSwitchAsNewTask] is set to true.
*
* @param context
* @return [BrowserSwitchResult]
*/
open fun deliverBrowserSwitchResultFromNewTask(context: Context): BrowserSwitchResult? {
return browserSwitchClient.deliverResultFromCache(context)
}

/**
* @suppress
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
fun parseBrowserSwitchResult(context: Context, requestCode: Int, intent: Intent?) =
browserSwitchClient.parseResult(context, requestCode, intent)

/**
* @suppress
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
fun clearActiveBrowserSwitchRequests(context: Context) =
browserSwitchClient.clearActiveRequests(context)

/**
* @suppress
*/
Expand All @@ -295,25 +226,6 @@ open class BraintreeClient @VisibleForTesting internal constructor(
}
}

/**
* @suppress
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@Throws(BrowserSwitchException::class)
fun assertCanPerformBrowserSwitch(
activity: FragmentActivity?,
@BraintreeRequestCodes requestCode: Int
) {
// url used to see if the application is able to open an https url e.g. web browser
val url = Uri.parse("https://braintreepayments.com")
val returnUrlScheme = getReturnUrlScheme()
val browserSwitchOptions = BrowserSwitchOptions()
.url(url)
.returnUrlScheme(returnUrlScheme)
.requestCode(requestCode)
browserSwitchClient.assertCanPerformBrowserSwitch(activity, browserSwitchOptions)
}

/**
* @suppress
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import androidx.appcompat.app.AppCompatActivity
* This Activity is used by the SDK Activity to handle deep links on behalf of the merchant
* It should not be used directly.
*/
// NEXT_MAJOR_VERSION : remove this class
class BraintreeDeepLinkActivity : AppCompatActivity() {
private val browserSwitchClient = BrowserSwitchClient()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
browserSwitchClient.captureResult(this)
finish()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class AnalyticsClientUnitTest {
val analyticsJSONSlot = slot<String>()
every {
httpClient.post(
"https://api-m.paypal.com/v1/tracking/batch/events",
"https://api.paypal.com/v1/tracking/batch/events",
capture(analyticsJSONSlot),
any(),
any()
Expand Down Expand Up @@ -381,7 +381,7 @@ class AnalyticsClientUnitTest {
val analyticsJSONSlot = slot<String>()
every {
httpClient.post(
"https://api-m.paypal.com/v1/tracking/batch/events",
"https://api.paypal.com/v1/tracking/batch/events",
capture(analyticsJSONSlot),
any(),
authorization,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
package com.braintreepayments.api

import android.content.Context
import android.content.Intent
import android.content.pm.ActivityInfo
import android.net.Uri
import androidx.fragment.app.FragmentActivity
import androidx.test.core.app.ApplicationProvider
import androidx.work.testing.WorkManagerTestInitHelper
import io.mockk.*
import org.json.JSONException
import org.json.JSONObject
import org.junit.Assert.*
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mockito.mock
import org.robolectric.RobolectricTestRunner

@RunWith(RobolectricTestRunner::class)
Expand Down Expand Up @@ -300,135 +296,6 @@ class BraintreeClientUnitTest {
verify { analyticsClient wasNot Called }
}

@Test
@Throws(BrowserSwitchException::class)
fun startBrowserSwitch_forwardsInvocationToBrowserSwitchClient() {
val activity = mockk<FragmentActivity>(relaxed = true)
val browserSwitchOptions = BrowserSwitchOptions()

val params = createDefaultParams(configurationLoader)
val sut = BraintreeClient(params)

sut.startBrowserSwitch(activity, browserSwitchOptions)
verify { browserSwitchClient.start(activity, browserSwitchOptions) }
}

@Test
fun browserSwitchResult_forwardsInvocationToBrowserSwitchClient() {
val activity = mockk<FragmentActivity>(relaxed = true)
val browserSwitchResult = createSuccessfulBrowserSwitchResult()
every { browserSwitchClient.getResult(activity) } returns browserSwitchResult

val params = createDefaultParams(configurationLoader)
val sut = BraintreeClient(params)
assertSame(browserSwitchResult, sut.getBrowserSwitchResult(activity))
}

@Test
fun deliverBrowserSwitchResult_forwardsInvocationToBrowserSwitchClient() {
val activity = mockk<FragmentActivity>(relaxed = true)
val params = createDefaultParams(configurationLoader)

val sut = BraintreeClient(params)
sut.deliverBrowserSwitchResult(activity)

verify { browserSwitchClient.deliverResult(activity) }
}

@Test
fun deliverBrowserSwitchResultFromNewTask_forwardsInvocationToBrowserSwitchClient() {
val context = mockk<Context>(relaxed = true)
val params = createDefaultParams(configurationLoader)

val sut = BraintreeClient(params)
sut.deliverBrowserSwitchResultFromNewTask(context)

verify { browserSwitchClient.deliverResultFromCache(context) }
}

@Test
fun parseBrowserSwitchResult_forwardsInvocationToBrowserSwitchClient() {
val context = mockk<Context>(relaxed = true)
val params = createDefaultParams(configurationLoader)

val expected = mock<BrowserSwitchResult>()
val intent = Intent()
every { browserSwitchClient.parseResult(context, 123, intent) } returns expected

val sut = BraintreeClient(params)
val actual = sut.parseBrowserSwitchResult(context, 123, intent)
assertSame(expected, actual)
}

@Test
fun clearActiveBrowserSwitchRequests_forwardsInvocationToBrowserSwitchClient() {
val context = mockk<Context>(relaxed = true)
val params = createDefaultParams(configurationLoader)

val sut = BraintreeClient(params)
sut.clearActiveBrowserSwitchRequests(context)

verify { browserSwitchClient.clearActiveRequests(context) }
}

@Test
@Throws(BrowserSwitchException::class)
fun assertCanPerformBrowserSwitch_assertsBrowserSwitchIsPossible() {
val params = createDefaultParams(configurationLoader)
val activity = mockk<FragmentActivity>(relaxed = true)

val sut = BraintreeClient(params)
sut.assertCanPerformBrowserSwitch(activity, 123)

val browserSwitchOptionsSlot = slot<BrowserSwitchOptions>()
verify {
browserSwitchClient.assertCanPerformBrowserSwitch(
activity,
capture(browserSwitchOptionsSlot)
)
}

val browserSwitchOptions = browserSwitchOptionsSlot.captured
assertEquals(123, browserSwitchOptions.requestCode.toLong())
assertEquals(Uri.parse("https://braintreepayments.com"), browserSwitchOptions.url)
}

@Test
@Throws(BrowserSwitchException::class)
@Suppress("SwallowedException")
fun assertCanPerformBrowserSwitch_onSuccess_doesNotThrow() {
val activity = mockk<FragmentActivity>(relaxed = true)
every { browserSwitchClient.assertCanPerformBrowserSwitch(activity, any()) } returns Unit

val params = createDefaultParams(configurationLoader)
val sut = BraintreeClient(params)
try {
sut.assertCanPerformBrowserSwitch(activity, 123)
} catch (e: BrowserSwitchException) {
fail("shouldn't get here")
}
}

@Test
@Throws(BrowserSwitchException::class)
fun assertCanPerformBrowserSwitch_onError_throws() {
val activity = mockk<FragmentActivity>(relaxed = true)
val browserSwitchException = BrowserSwitchException("error")

every {
browserSwitchClient.assertCanPerformBrowserSwitch(activity, any())
} throws browserSwitchException

val params = createDefaultParams(configurationLoader)
val sut = BraintreeClient(params)
try {
sut.assertCanPerformBrowserSwitch(activity, 123)
fail("shouldn't get here")
} catch (e: BrowserSwitchException) {
assertSame(browserSwitchException, e)
}
}

@Test
fun isUrlSchemeDeclaredInAndroidManifest_forwardsInvocationToManifestValidator() {
every {
Expand Down Expand Up @@ -553,16 +420,4 @@ class BraintreeClientUnitTest {
configurationLoader = configurationLoader,
integrationType = IntegrationType.CUSTOM
)

companion object {
private fun createSuccessfulBrowserSwitchResult(): BrowserSwitchResult {
val requestCode = 123
val url = Uri.parse("www.example.com")
val returnUrlScheme = "sample-scheme"
val browserSwitchRequest = BrowserSwitchRequest(
requestCode, url, JSONObject(), returnUrlScheme, true
)
return BrowserSwitchResult(BrowserSwitchStatus.SUCCESS, browserSwitchRequest)
}
}
}
15 changes: 12 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Upgrade to Android Gradle Plugin 8
* BraintreeCore
* Remove `BraintreeClient` public constructors
* Remove `deliverBrowserSwitchResult` and `deliverBrowserSwitchResultFromNewTask` from `BraintreeClient`
* Remove `ClientTokenProvider`
* Update payment method constructor parameters from `braintreeClient` to `context` and
`authorization`
Expand Down Expand Up @@ -72,7 +73,7 @@
* Make empty `ThreeDSecureLookup` constructor package-private
* PayPal
* Remove `PayPalListener`
* Add `PayPalLauncher`, `PayPalPaymentAuthRequest`, `PayPalPaymentAuthResult`,
* Add `PayPalLauncher`, `PayPalPaymentAuthRequest`, `PayPalPendingRequest`, `PayPalPaymentAuthResult`,
`PayPalPaymentAuthCallback`, `PayPalTokenizeCallback`, and `PayPalResult`
* Remove`PayPalFlowStartedCallback`
* Remove overload constructors, `setListener`, `parseBrowserSwitchResult`,
Expand All @@ -83,7 +84,7 @@
* Rename `PayPalClient#onBrowserSwitchResult` to `PayPalCient#tokenize` and change parameters
* LocalPayment
* Remove `LocalPaymentListener`
* Add `LocalPaymentLauncher`, `LocalPaymentLauncherCallback`, `LocalPaymentTokenizeCallback`,
* Add `LocalPaymentLauncher`, `LocalPaymentPendingRequest`, `LocalPaymentTokenizeCallback`,
`LocalPaymentAuthRequest`, `LocalPaymentAuthRequestCallback` and `LocalPaymentAuthResult`
* Change `LocalPaymentResult` type
* Remove overload constructors, `setListener`, `parseBrowserSwitchResult`,
Expand All @@ -100,7 +101,7 @@
* Change `CardTokenizeCallback` parameters
* SEPA Direct Debit
* Remove `SEPADirectDebitLifecycleObserver` and `SEPADirectDebitListener`
* Add `SEPADirectDebitLauncher`, `SEPADirectDebitLauncherCallback`,
* Add `SEPADirectDebitLauncher`, `SEPADirectDebitPendingRequest`,
`SEPADirectDebitPaymentAuthRequestCallback`, `SEPADirectDebitPaymentAuthRequest`,
`SEPADirectDebitResult`, `SEPADirectDebitPaymentAuthRequestParams` and
`SEPADirectDebitTokenizeCallback`
Expand All @@ -121,6 +122,14 @@
* PayPal Native Checkout
* Remove entire PayPal Native Checkout module

## 4.41.0 (2024-01-18)

* PayPal
* Add imageUrl, upcCode, and upcType to PayPalLineItem
* PayPalNativeCheckout
* Bump native-checkout version to release `1.2.1`
* Upgraded the data-collector SDK to version 3.21.0 which made updates to Device Data collection related to Google Play's User Data Policy. For more info read the [release notes](https://github.com/paypal/android-checkout-sdk/releases/tag/v1.2.1)

## 4.40.1 (2023-12-13)

* BraintreeCore
Expand Down
Loading

0 comments on commit a4d6d73

Please sign in to comment.