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

Rename Venmo APIs #823

Merged
merged 7 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
* PayPalDataCollector
* Remove `paypal-data-collector` module (use `data-collector`)
* Venmo
* Remove `VenmoListener`, `VenmoTokenizeAccountCallback`
* Add `VenmoLauncher`, `VenmoAuthChallenge`, `VenmoAuthChallengeCallback`,
`VenmoAuthChallengeResult`, `VenmoResult`, and
`VenmoAuthChallengeResultCallback`
* Remove `VenmoListener`, `VenmoTokenizeAccountCallback`, and `VenmoResultCallback`
* Add `VenmoLauncher`, `VenmoPaymentAuthRequest`, `VenmoPaymentAuthRequestCallback`,
`VenmoPaymentAuthResult`, `VenmoResult`, `VenmoTokenizeCallback`, and
`VenmoLauncherCallback`
* Rename `VenmoOnActivityResultCallback` to `VenmoResultCallback`
* Remove overload constructors, `setListener`, and `onActivityResult` from `VenmoClient`
* Change `VenmoClient#tokenizeVenmoAccount` parameters
* Add `VenmoClient#requestAuthChallenge`
* Change `VenmoClient#tokenizeVenmoAccount` parameters and rename to
`VenmoClient#tokenize`
* Add `VenmoClient#createPaymentAuthRequest`
* GooglePay
* Remove `GooglePayListener` and `GooglePayRequestPaymentCallback`
* Add `GooglePayLauncher`, `GooglePayIntentData`, `GooglePayIntentDataCallback`, `GooglePayResult`, and `GooglePayResultCallback`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
venmoButton.setOnClickListener(this::launchVenmo);

venmoLauncher = new VenmoLauncher(this, venmoAuthChallengeResult ->
venmoClient.tokenizeVenmoAccount(venmoAuthChallengeResult, this::handleVenmoResult));
venmoClient.tokenize(venmoAuthChallengeResult, this::handleVenmoResult));

return view;
}
Expand Down Expand Up @@ -86,7 +86,7 @@ public void launchVenmo(View v) {
lineItems.add(new VenmoLineItem(VenmoLineItem.KIND_DEBIT, "Two Items", 2, "10"));
venmoRequest.setLineItems(lineItems);

venmoClient.requestAuthChallenge(requireActivity(), venmoRequest, (venmoAuthChallenge, authError) -> {
venmoClient.createPaymentAuthRequest(requireActivity(), venmoRequest, (venmoAuthChallenge, authError) -> {
if (authError != null) {
handleError(authError);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.json.JSONObject;

class VenmoActivityResultContract
extends ActivityResultContract<VenmoAuthChallenge, VenmoAuthChallengeResult> {
extends ActivityResultContract<VenmoPaymentAuthRequest, VenmoPaymentAuthResult> {

static final String VENMO_PACKAGE_NAME = "com.venmo";
static final String APP_SWITCH_ACTIVITY = "controller.SetupMerchantActivity";
Expand All @@ -33,7 +33,7 @@ class VenmoActivityResultContract

@NonNull
@Override
public Intent createIntent(@NonNull Context context, VenmoAuthChallenge input) {
public Intent createIntent(@NonNull Context context, VenmoPaymentAuthRequest input) {
Intent venmoIntent = getVenmoIntent()
.putExtra(EXTRA_MERCHANT_ID, input.getProfileId())
.putExtra(EXTRA_ACCESS_TOKEN, input.getConfiguration().getVenmoAccessToken())
Expand Down Expand Up @@ -62,18 +62,18 @@ public Intent createIntent(@NonNull Context context, VenmoAuthChallenge input) {
}

@Override
public VenmoAuthChallengeResult parseResult(int resultCode, @Nullable Intent intent) {
public VenmoPaymentAuthResult parseResult(int resultCode, @Nullable Intent intent) {
if (resultCode == AppCompatActivity.RESULT_OK) {
if (intent == null) {
return new VenmoAuthChallengeResult(null, null, null, new BraintreeException(
return new VenmoPaymentAuthResult(null, null, null, new BraintreeException(
"An unknown Android error occurred with the activity result API."));
}
String paymentContextId = intent.getStringExtra(EXTRA_RESOURCE_ID);
String nonce = intent.getStringExtra(EXTRA_PAYMENT_METHOD_NONCE);
String venmoUsername = intent.getStringExtra(EXTRA_USERNAME);
return new VenmoAuthChallengeResult(paymentContextId, nonce, venmoUsername, null);
return new VenmoPaymentAuthResult(paymentContextId, nonce, venmoUsername, null);
} else if (resultCode == AppCompatActivity.RESULT_CANCELED) {
return new VenmoAuthChallengeResult(null, null, null,
return new VenmoPaymentAuthResult(null, null, null,
new UserCanceledException("User canceled Venmo."));
}
return null;
Expand Down
4 changes: 2 additions & 2 deletions Venmo/src/main/java/com/braintreepayments/api/VenmoApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void createPaymentContext(@NonNull final VenmoRequest request, String venmoProfi
}

void createNonceFromPaymentContext(String paymentContextId,
final VenmoResultCallback callback) {
final VenmoTokenizeCallback callback) {
JSONObject params = new JSONObject();
try {
params.put("query",
Expand Down Expand Up @@ -115,7 +115,7 @@ void createNonceFromPaymentContext(String paymentContextId,
}
}

void vaultVenmoAccountNonce(String nonce, final VenmoResultCallback callback) {
void vaultVenmoAccountNonce(String nonce, final VenmoTokenizeCallback callback) {
VenmoAccount venmoAccount = new VenmoAccount();
venmoAccount.setNonce(nonce);

Expand Down

This file was deleted.

This file was deleted.

Loading