Search in sources :

Example 6 with Configuration

use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.

the class PayPalRequestUnitTest method getBillingAgreementRequest_buildsWithOfflineStageUrl.

@Test
public void getBillingAgreementRequest_buildsWithOfflineStageUrl() throws JSONException {
    Configuration configuration = Configuration.fromJson(stringFromFixture("configuration/with_offline_paypal.json"));
    BraintreeFragment fragment = mMockFragmentBuilder.configuration(configuration).build();
    Request request = PayPal.getBillingAgreementRequest(fragment, null);
    assertEquals(EnvironmentManager.MOCK, request.getEnvironment());
}
Also used : Configuration(com.braintreepayments.api.models.Configuration) Request(com.paypal.android.sdk.onetouch.core.Request) BillingAgreementRequest(com.paypal.android.sdk.onetouch.core.BillingAgreementRequest) AuthorizationRequest(com.paypal.android.sdk.onetouch.core.AuthorizationRequest) CheckoutRequest(com.paypal.android.sdk.onetouch.core.CheckoutRequest) Test(org.junit.Test)

Example 7 with Configuration

use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.

the class PayPalRequestUnitTest method getCheckoutRequest_containsCorrectValues.

@Test
public void getCheckoutRequest_containsCorrectValues() throws JSONException {
    Configuration configuration = Configuration.fromJson(stringFromFixture("configuration/with_offline_paypal.json"));
    BraintreeFragment fragment = mMockFragmentBuilder.configuration(configuration).build();
    CheckoutRequest request = PayPal.getCheckoutRequest(fragment, "https://paypal.com/?token=pairingId");
    assertEquals(EnvironmentManager.MOCK, request.getEnvironment());
    assertEquals("com.braintreepayments.api.braintree://onetouch/v1/cancel", request.getCancelUrl());
    assertEquals("com.braintreepayments.api.braintree://onetouch/v1/success", request.getSuccessUrl());
    assertEquals("paypal_client_id", request.getClientId());
    assertEquals("pairingId", request.getPairingId());
}
Also used : Configuration(com.braintreepayments.api.models.Configuration) CheckoutRequest(com.paypal.android.sdk.onetouch.core.CheckoutRequest) Test(org.junit.Test)

Example 8 with Configuration

use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.

the class PayPalRequestUnitTest method getAuthorizationRequest_buildsWithCustomStageUrl.

@Test
public void getAuthorizationRequest_buildsWithCustomStageUrl() throws JSONException, InvalidArgumentException {
    Configuration configuration = Configuration.fromJson(stringFromFixture("configuration/with_custom_paypal.json"));
    BraintreeFragment fragment = mMockFragmentBuilder.authorization(Authorization.fromString(TOKENIZATION_KEY)).configuration(configuration).build();
    Request request = PayPal.getAuthorizationRequest(fragment);
    assertEquals("custom", request.getEnvironment());
}
Also used : Configuration(com.braintreepayments.api.models.Configuration) Request(com.paypal.android.sdk.onetouch.core.Request) BillingAgreementRequest(com.paypal.android.sdk.onetouch.core.BillingAgreementRequest) AuthorizationRequest(com.paypal.android.sdk.onetouch.core.AuthorizationRequest) CheckoutRequest(com.paypal.android.sdk.onetouch.core.CheckoutRequest) Test(org.junit.Test)

Example 9 with Configuration

use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.

the class PayPalRequestUnitTest method getBillingAgreement_containsCorrectValues.

@Test
public void getBillingAgreement_containsCorrectValues() throws JSONException {
    Configuration configuration = Configuration.fromJson(stringFromFixture("configuration/with_offline_paypal.json"));
    BraintreeFragment fragment = mMockFragmentBuilder.configuration(configuration).build();
    BillingAgreementRequest request = PayPal.getBillingAgreementRequest(fragment, "https://paypal.com/?ba_token=pairingId");
    assertEquals(EnvironmentManager.MOCK, request.getEnvironment());
    assertEquals("com.braintreepayments.api.braintree://onetouch/v1/cancel", request.getCancelUrl());
    assertEquals("com.braintreepayments.api.braintree://onetouch/v1/success", request.getSuccessUrl());
    assertEquals("paypal_client_id", request.getClientId());
    assertEquals("pairingId", request.getPairingId());
}
Also used : Configuration(com.braintreepayments.api.models.Configuration) BillingAgreementRequest(com.paypal.android.sdk.onetouch.core.BillingAgreementRequest) Test(org.junit.Test)

Example 10 with Configuration

use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.

the class VenmoUnitTest method performAppSwitch_persistsIfVaultTrue.

@Test
public void performAppSwitch_persistsIfVaultTrue() throws InvalidArgumentException {
    Configuration configuration = getConfigurationFromFixture();
    Authorization clientToken = Authorization.fromString(stringFromFixture("base_64_client_token.txt"));
    disableSignatureVerification();
    BraintreeFragment fragment = new MockFragmentBuilder().context(VenmoInstalledContextFactory.venmoInstalledContext(true, RuntimeEnvironment.application)).configuration(configuration).authorization(clientToken).build();
    Venmo.authorizeAccount(fragment, true);
    SharedPreferences prefs = SharedPreferencesHelper.getSharedPreferences(fragment.getApplicationContext());
    assertTrue(prefs.getBoolean("com.braintreepayments.api.Venmo.VAULT_VENMO_KEY", false));
}
Also used : Authorization(com.braintreepayments.api.models.Authorization) Configuration(com.braintreepayments.api.models.Configuration) SharedPreferencesHelper.clearSharedPreferences(com.braintreepayments.testutils.SharedPreferencesHelper.clearSharedPreferences) SharedPreferences(android.content.SharedPreferences) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

Configuration (com.braintreepayments.api.models.Configuration)84 Test (org.junit.Test)66 ConfigurationListener (com.braintreepayments.api.interfaces.ConfigurationListener)36 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)35 InvalidArgumentException (com.braintreepayments.api.exceptions.InvalidArgumentException)19 JSONException (org.json.JSONException)19 Authorization (com.braintreepayments.api.models.Authorization)14 Intent (android.content.Intent)13 HttpResponseCallback (com.braintreepayments.api.interfaces.HttpResponseCallback)13 TestConfigurationBuilder (com.braintreepayments.testutils.TestConfigurationBuilder)12 AuthorizationRequest (com.paypal.android.sdk.onetouch.core.AuthorizationRequest)11 BillingAgreementRequest (com.paypal.android.sdk.onetouch.core.BillingAgreementRequest)11 CheckoutRequest (com.paypal.android.sdk.onetouch.core.CheckoutRequest)11 JSONObject (org.json.JSONObject)11 UnexpectedException (com.braintreepayments.api.exceptions.UnexpectedException)10 SharedPreferencesHelper.writeMockConfiguration (com.braintreepayments.testutils.SharedPreferencesHelper.writeMockConfiguration)10 Request (com.paypal.android.sdk.onetouch.core.Request)10 Bundle (android.os.Bundle)9 BraintreeFragmentTestUtils.getMockFragmentWithConfiguration (com.braintreepayments.api.BraintreeFragmentTestUtils.getMockFragmentWithConfiguration)6 BraintreeFragmentTestUtils.getFragmentWithConfiguration (com.braintreepayments.api.BraintreeFragmentTestUtils.getFragmentWithConfiguration)5