-
Notifications
You must be signed in to change notification settings - Fork 237
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
Single Result Objects for Public Methods #857
Closed
Closed
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
3de208b
Rename internal callback
sarahkoop b7c9db0
Merge branch 'v5' into sepa_single_result
sarahkoop 5cf8f90
Add SEPADirectDebitResult
sarahkoop b34314c
Add SEPADirectDebitTokenizeCallback
sarahkoop 82e7560
Fix unit tests for tokenize
sarahkoop 6865291
Rename params
sarahkoop 6064a04
Add SEPADirectDebitPaymentAuthRequest
sarahkoop 5186ff5
Use SEPADirectDebitPaymentAuthRequest
sarahkoop f60a3f5
Fix unit tests
sarahkoop 3ceef14
Fix unit tests
sarahkoop d957fb0
Update demo integration
sarahkoop 94aa2d4
Update CHANGELOG and migration guid
sarahkoop 1f5ad10
Fix unit tests
sarahkoop 898ccbc
Update American Express single result
sarahkoop e577cf3
Update American Express single result
sarahkoop d512339
Update DataCollector result
sarahkoop ca3f172
Fix lint and unit tests
sarahkoop c1eb9ee
Update VisaCheckout
sarahkoop d814dc3
Finish refactor Visa Checkout
sarahkoop bfb7b59
Update CHANGELOG and migration guide
sarahkoop baa70a7
Update Google Pay
sarahkoop b1ee900
Fix nullability
sarahkoop b60d775
Rename callback
sarahkoop 42f3377
merge v5
sarahkoop File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 0 additions & 18 deletions
18
...ess/src/main/java/com/braintreepayments/api/AmericanExpressGetRewardsBalanceCallback.java
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
...press/src/main/java/com/braintreepayments/api/AmericanExpressGetRewardsBalanceCallback.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.braintreepayments.api | ||
|
||
/** | ||
* Callback for receiving result of | ||
* [AmericanExpressClient.getRewardsBalance]. | ||
*/ | ||
fun interface AmericanExpressGetRewardsBalanceCallback { | ||
/** | ||
* @param americanExpressResult the [AmericanExpressResult] | ||
*/ | ||
fun onAmericanExpressResult(americanExpressResult: AmericanExpressResult) | ||
} |
17 changes: 17 additions & 0 deletions
17
AmericanExpress/src/main/java/com/braintreepayments/api/AmericanExpressResult.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.braintreepayments.api | ||
|
||
/** | ||
* Result of fetching American Express rewards balance | ||
*/ | ||
sealed class AmericanExpressResult { | ||
|
||
/** | ||
* The [rewardsBalance] was successfully fetched | ||
*/ | ||
class Success(val rewardsBalance: AmericanExpressRewardsBalance) : AmericanExpressResult() | ||
|
||
/** | ||
* There was an [error] fetching rewards balance | ||
*/ | ||
class Failure(val error: Exception) : AmericanExpressResult() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,30 +112,27 @@ public void collectDeviceData(@NonNull final Context context, @NonNull final Dat | |
* @param callback {@link DataCollectorCallback} | ||
*/ | ||
public void collectDeviceData(@NonNull final Context context, @Nullable final String riskCorrelationId, @NonNull final DataCollectorCallback callback) { | ||
braintreeClient.getConfiguration(new ConfigurationCallback() { | ||
@Override | ||
public void onResult(@Nullable Configuration configuration, @Nullable Exception error) { | ||
if (configuration != null) { | ||
final JSONObject deviceData = new JSONObject(); | ||
try { | ||
DataCollectorRequest request = new DataCollectorRequest() | ||
.setApplicationGuid(getPayPalInstallationGUID(context)); | ||
if (riskCorrelationId != null) { | ||
request.setRiskCorrelationId(riskCorrelationId); | ||
} | ||
|
||
String correlationId = | ||
magnesInternalClient.getClientMetadataId(context, configuration, request); | ||
if (!TextUtils.isEmpty(correlationId)) { | ||
deviceData.put(CORRELATION_ID_KEY, correlationId); | ||
} | ||
} catch (JSONException ignored) { | ||
braintreeClient.getConfiguration((configuration, error) -> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this work need to be in the CHANGELOG? |
||
if (configuration != null) { | ||
final JSONObject deviceData = new JSONObject(); | ||
try { | ||
DataCollectorRequest request = new DataCollectorRequest() | ||
.setApplicationGuid(getPayPalInstallationGUID(context)); | ||
if (riskCorrelationId != null) { | ||
request.setRiskCorrelationId(riskCorrelationId); | ||
} | ||
callback.onResult(deviceData.toString(), null); | ||
|
||
} else { | ||
callback.onResult(null, error); | ||
String correlationId = | ||
magnesInternalClient.getClientMetadataId(context, configuration, request); | ||
if (!TextUtils.isEmpty(correlationId)) { | ||
deviceData.put(CORRELATION_ID_KEY, correlationId); | ||
} | ||
} catch (JSONException ignored) { | ||
} | ||
callback.onDataCollectorResult(new DataCollectorResult.Success(deviceData.toString())); | ||
|
||
} else if (error != null) { | ||
callback.onDataCollectorResult(new DataCollectorResult.Failure(error)); | ||
} | ||
}); | ||
} | ||
|
18 changes: 0 additions & 18 deletions
18
DataCollector/src/main/java/com/braintreepayments/api/DataCollectorCallback.java
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
DataCollector/src/main/java/com/braintreepayments/api/DataCollectorCallback.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.braintreepayments.api | ||
|
||
/** | ||
* Callback for receiving result of [DataCollector.collectDeviceData] | ||
*/ | ||
fun interface DataCollectorCallback { | ||
/** | ||
* @param dataCollectorResult the [DataCollectorResult] of collecting device data | ||
*/ | ||
fun onDataCollectorResult(dataCollectorResult: DataCollectorResult) | ||
} |
17 changes: 17 additions & 0 deletions
17
DataCollector/src/main/java/com/braintreepayments/api/DataCollectorResult.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.braintreepayments.api | ||
|
||
/** | ||
* Result of collecting device data for fraud detection | ||
*/ | ||
sealed class DataCollectorResult { | ||
|
||
/** | ||
* The device information was collected for fraud detection. Send [deviceData] to your server | ||
*/ | ||
class Success(val deviceData: String) : DataCollectorResult() | ||
|
||
/** | ||
* There was an [error] during device data collection | ||
*/ | ||
class Failure(val error: Exception) : DataCollectorResult() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
love that we're adding this test coverage. Question: do we have testing around analytic events being sent?