Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference id mixup fix #147

Merged
merged 5 commits into from
Jul 19, 2024

Conversation

pedronveloso
Copy link
Collaborator

@pedronveloso pedronveloso commented Jul 18, 2024

What are you trying to accomplish?

account_reference_id is a unique field of on-file payments, and reference_id is a top-level field across both on-file and one-time payments. This PR addresses that distinction, by exposing and using the correct field.

How did you accomplish this?

Because reference_id is a top-level field, it is therefore NOT part of the request Actions, and we had to add 1 extra parameter to a few of our public functions.

Visual:

Testing both field, and correctly assessing that they're being sent and recognized correctly by the backend:

Screen_recording_20240718_211137.mp4

@@ -235,7 +226,6 @@ internal class PayKitAnalyticsEventDispatcherImpl(
createActions = apiActionsAsJson,
createChannel = CHANNEL_IN_APP,
createRedirectUrl = redirectUri?.let { PiiString(redirectUri) },
createReferenceId = possibleReferenceId?.let { PiiString(possibleReferenceId) },
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this field his hidden from ES2, there's no point even sending it to begin with.

@@ -188,7 +206,12 @@ internal class CashAppPayImpl(
currentState = UpdatingCustomerRequest

// Network request.
val networkResult = networkManager.updateCustomerRequest(clientId, requestId, paymentActions)
val networkResult = networkManager.updateCustomerRequest(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made some of these functions have named parameters to increase readability, and also because several of these params share the same type, so this makes it less likely we pass the wrong thing into the wrong field without it being caught in a review.

@@ -20,7 +20,7 @@ import app.cash.paykit.core.CashAppPay
/**
* This class holds the information necessary for [CashAppPay.createCustomerRequest] to be executed.
*/
sealed class CashAppPayPaymentAction(scopeId: String?) {
sealed class CashAppPayPaymentAction(open val scopeId: String?, open val referenceId: String?) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scopeId was supposed to be an open val, so I'm sort of piggybacking this fix. This doesn't affect anything for us yet - but its the right thing if in the future we need to loop trough a collection of CashAppPayPaymentAction for whatever reason.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a breaking change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope. merchants shouldn't be using the top class definition at all (and the field previously wasn't accessible that way)

Copy link
Collaborator

@BrianGardnerAtl BrianGardnerAtl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@pedronveloso pedronveloso merged commit 67845e0 into develop Jul 19, 2024
1 check passed
@pedronveloso pedronveloso deleted the pedro/jul-18-2024/reference_id_mixup_fix branch July 19, 2024 17:07
pedronveloso added a commit that referenced this pull request Jul 19, 2024
* Fix Retrieve Existing request ID behavior for PROCESSING state (#95)

* Fix Retrieve Existing request ID behavior for PENDING state

* Add distinction between Pending & Processing

* Code cleanup (and research on proguard rules being handed to consumers) (#98)

* Add proguard rules to project for automatic client consumption

* Fix constant name after renaming class

* Concrete R8 rules are actually not needed

* Add enum for GrantType (#99)

* Update Robolectric dependency (#102)

* Update changelog

* Use Epoch usec for Analytics timestamp (#107)

* Add UT for Analytics (#108)

* Refresh Auth Token for Customer Request (#109)

* Initial support for Unauthorized Customer Request refresh

* Add useful docs about token refresh window

* Improve logging for CashAppCashAppPayImpl

* Use Duration instead of Long for better time handling

* Remove not needed call to interrupt

* Schedule auth token refresh on `startWithExistingCustomerRequest` when status is "pending"

* Support deferred auth token refresh upon authorize call

* Better thread safety and handling

* Update comment

* Add new Refreshing state (#110)

* Add Refreshing state

* Use better explicit tag for logging

* Abstract thread managment away from main class (#113)

* Redact PII for logs and metrics (#112)

* Redact PII for logs and metrics

* Add UTs for PiiString

* Swap redact with unredacted defaults

* Redact more fields; move redaction step to encoding

* Simplify internal class names (#115)

* Modify CashAppPayButton to allow for dynamic styles (#116)

* Modify CashAppPayButton to allow for dynamic styles

* Update CHANGELOG

* Update testing frameworks and link baseline

* Add PR template (#120)

* Logging abstraction (#119)

* Create new module for logging

* CashPayLogger implementation, and apply it to Analytics module

* Add CAP logger to Core module

* Create lint baseline file for logging module

* Fix tests

* Change Analytics implementation to log only Warn level or above

* Add support to observe logging changes

* Add some UT for logging module

* Add UTs for CashAppLoggerImpl

* Add some useful documentation to tests

* Set default PR template (#121)

* Make Initializer open to modification (#123)

* Update Spotless Plugin and Ktlint version (#124)

* Add minify rules (#125)

* Add consumer-rules for minify

* Bump release version; update release notes

* Add more minify rules

* Update Core dependency on OkHttp (#126)

* Add consumer-rules for minify

* Bump release version; update release notes

* Add more minify rules

* Update Core dependency on OkHttp

* Update Android target version (#133)

* Increase compile version to API 33

* Update CHANGELOG

* Update AGP to 8.1.2 (#134)

* Update AGP to 8.1.2

* Update Java version for CI to 17

* Update AGP & Gradle (#138)

* Update AGP and Gradle

* Update Robolectric dependency

* Pedro/sdk kotlin 1.8 (#139)

* Update AGP version

* Update Kotlin to 1.8.x, along with various library dependencies

* Update Dev App versions and baseline lint files

* Update AGP and dev app version

* Use reference_id param correctly (#145)

* Add Start Screen to split different playgrouds within Dev App

* Improve webview logs display

* Increase log history size

* Fix accountReferenceId param missing from network call

* Update some of the project libraries

* Fix test related to size of log history

* Minor changes based on PR feedback

* Reference id mixup fix (#147)

* Correct distinction between reference_id and account_reference_id

* Spotless apply

* Make function changes be backwards compatible

* Update CHANGELOG

* Fix UTs

* Prepare release 2.5.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants