Skip to content

Commit

Permalink
Throwing error if nxo response is null (#682)
Browse files Browse the repository at this point in the history
* -Throwing error if response is null

* -Updating changelog

* -Adding in exception

* -Adding test

* Update CHANGELOG.md

Co-authored-by: Jax DesMarais-Leder <[email protected]>

---------

Co-authored-by: Jax DesMarais-Leder <[email protected]>
  • Loading branch information
kelay858 and jaxdesmarais authored Feb 10, 2023
1 parent 6cc26cb commit 6fa5189
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Braintree Android SDK Release Notes

## unreleased
* PayPalNativeCheckout (BETA)

* Fixes a bug where an error was not thrown inside `PayPalNativeCheckoutClient` when no PayPal response was received from the API

* SharedUtils
* Replace EncryptedSharedPreferences with SharedPreferences for internal persistent data storage for all payment flows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ private void sendPayPalRequest(
braintreeClient.sendAnalyticsEvent("paypal-native.billing-agreement.succeeded");
}
});
} else {
listener.onPayPalFailure(new Exception(error));
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,27 @@ public void requestBillingAgreement_launchNativeCheckout_sendsAnalyticsEvents()
verify(braintreeClient).sendAnalyticsEvent("paypal-native.billing-agreement.started");
}

@Test
public void requestNativeCheckout_returnsErrorFromFailedResponse() {
PayPalNativeCheckoutVaultRequest payPalVaultRequest = new PayPalNativeCheckoutVaultRequest();
payPalVaultRequest.setMerchantAccountId("sample-merchant-account-id");
payPalVaultRequest.setReturnUrl("returnUrl://paypalpay");

PayPalNativeCheckoutInternalClient payPalInternalClient = new MockPayPalInternalClientBuilder()
.sendRequestError(new Exception())
.build();

BraintreeClient braintreeClient = new MockBraintreeClientBuilder()
.configuration(payPalEnabledConfig)
.build();

PayPalNativeCheckoutClient sut = new PayPalNativeCheckoutClient(braintreeClient, payPalInternalClient);
sut.setListener(listener);
sut.launchNativeCheckout(activity, payPalVaultRequest);

verify(listener).onPayPalFailure(any());
}

@Test
public void requestOneTimePayment_launchNativeCheckout_sendsAnalyticsEvents() {
PayPalNativeCheckoutRequest payPalCheckoutRequest = new PayPalNativeCheckoutRequest("1.00");
Expand Down

0 comments on commit 6fa5189

Please sign in to comment.