Search in sources :

Example 16 with Request

use of com.paypal.android.sdk.onetouch.core.Request in project braintree_android by braintree.

the class AppSwitchHelperUnitTest method buildAppSwitchIntent_buildsIntentForProtocolV3.

@Test
public void buildAppSwitchIntent_buildsIntentForProtocolV3() {
    Request request = mock(CheckoutRequest.class);
    when(request.getEnvironment()).thenReturn("test");
    Intent intent = AppSwitchHelper.getAppSwitchIntent(mContextInspector, mConfigManager, request, getMockRecipe(3));
    assertEquals("com.paypal.android.lib.authenticator.activity.v3.TouchActivity", intent.getAction());
    assertEquals("com.paypal.android.p2pmobile", intent.getPackage());
    assertEquals("3.0", intent.getStringExtra("version"));
}
Also used : Request(com.paypal.android.sdk.onetouch.core.Request) AuthorizationRequest(com.paypal.android.sdk.onetouch.core.AuthorizationRequest) CheckoutRequest(com.paypal.android.sdk.onetouch.core.CheckoutRequest) Intent(android.content.Intent) Test(org.junit.Test)

Example 17 with Request

use of com.paypal.android.sdk.onetouch.core.Request in project braintree_android by braintree.

the class AppSwitchHelperUnitTest method buildAppSwitchIntent_buildsIntentForProtocolV2.

@Test
public void buildAppSwitchIntent_buildsIntentForProtocolV2() {
    Request request = mock(CheckoutRequest.class);
    when(request.getEnvironment()).thenReturn("test");
    Intent intent = AppSwitchHelper.getAppSwitchIntent(mContextInspector, mConfigManager, request, getMockRecipe(2));
    assertEquals("com.paypal.android.lib.authenticator.activity.v2.TouchActivity", intent.getAction());
    assertEquals("com.paypal.android.p2pmobile", intent.getPackage());
    assertEquals("2.0", intent.getStringExtra("version"));
}
Also used : Request(com.paypal.android.sdk.onetouch.core.Request) AuthorizationRequest(com.paypal.android.sdk.onetouch.core.AuthorizationRequest) CheckoutRequest(com.paypal.android.sdk.onetouch.core.CheckoutRequest) Intent(android.content.Intent) Test(org.junit.Test)

Example 18 with Request

use of com.paypal.android.sdk.onetouch.core.Request in project braintree_android by braintree.

the class AppSwitchHelperUnitTest method parseAppSwitchResponse_parsesWebResponseAndReturnsResult.

@Test
public void parseAppSwitchResponse_parsesWebResponseAndReturnsResult() throws JSONException {
    Request request = mock(AuthorizationRequest.class);
    when(request.validateV1V2Response(any(ContextInspector.class), any(Bundle.class))).thenReturn(true);
    Intent intent = new Intent().putExtra("environment", "test").putExtra("response_type", "web").putExtra("webURL", "web-url");
    Result result = AppSwitchHelper.parseAppSwitchResponse(mContextInspector, request, intent);
    verify(request).trackFpti(any(Context.class), eq(TrackingPoint.Return), isNull(Protocol.class));
    assertEquals(ResultType.Success, result.getResultType());
    assertEquals(ResponseType.web.name(), result.getResponse().getString("response_type"));
    JSONObject client = result.getResponse().getJSONObject("client");
    assertEquals("test", client.getString("environment"));
    assertEquals("web-url", result.getResponse().getJSONObject("response").getString("webURL"));
}
Also used : Context(android.content.Context) ContextInspector(com.paypal.android.sdk.onetouch.core.base.ContextInspector) TestSetupHelper.getMockContextInspector(com.paypal.android.sdk.onetouch.core.test.TestSetupHelper.getMockContextInspector) JSONObject(org.json.JSONObject) Bundle(android.os.Bundle) Request(com.paypal.android.sdk.onetouch.core.Request) AuthorizationRequest(com.paypal.android.sdk.onetouch.core.AuthorizationRequest) CheckoutRequest(com.paypal.android.sdk.onetouch.core.CheckoutRequest) Intent(android.content.Intent) Protocol(com.paypal.android.sdk.onetouch.core.enums.Protocol) Result(com.paypal.android.sdk.onetouch.core.Result) Test(org.junit.Test)

Example 19 with Request

use of com.paypal.android.sdk.onetouch.core.Request in project braintree_android by braintree.

the class AppSwitchHelperUnitTest method parseAppSwitchResponse_parsesAuthorizationCodeResponseAndReturnsResult.

@Test
public void parseAppSwitchResponse_parsesAuthorizationCodeResponseAndReturnsResult() throws JSONException {
    Request request = mock(AuthorizationRequest.class);
    when(request.validateV1V2Response(any(ContextInspector.class), any(Bundle.class))).thenReturn(true);
    Intent intent = new Intent().putExtra("environment", "test").putExtra("response_type", "code").putExtra("authorization_code", "auth-code").putExtra("email", "test@paypal.com");
    Result result = AppSwitchHelper.parseAppSwitchResponse(mContextInspector, request, intent);
    verify(request).trackFpti(any(Context.class), eq(TrackingPoint.Return), isNull(Protocol.class));
    assertEquals(ResultType.Success, result.getResultType());
    assertEquals(ResponseType.authorization_code.name(), result.getResponse().getString("response_type"));
    JSONObject client = result.getResponse().getJSONObject("client");
    assertEquals("test", client.getString("environment"));
    assertEquals("auth-code", result.getResponse().getJSONObject("response").getString("code"));
    assertEquals("test@paypal.com", result.getResponse().getJSONObject("user").getString("display_string"));
}
Also used : Context(android.content.Context) ContextInspector(com.paypal.android.sdk.onetouch.core.base.ContextInspector) TestSetupHelper.getMockContextInspector(com.paypal.android.sdk.onetouch.core.test.TestSetupHelper.getMockContextInspector) JSONObject(org.json.JSONObject) Bundle(android.os.Bundle) Request(com.paypal.android.sdk.onetouch.core.Request) AuthorizationRequest(com.paypal.android.sdk.onetouch.core.AuthorizationRequest) CheckoutRequest(com.paypal.android.sdk.onetouch.core.CheckoutRequest) Intent(android.content.Intent) Protocol(com.paypal.android.sdk.onetouch.core.enums.Protocol) Result(com.paypal.android.sdk.onetouch.core.Result) Test(org.junit.Test)

Example 20 with Request

use of com.paypal.android.sdk.onetouch.core.Request in project braintree_android by braintree.

the class PayPalRequestUnitTest method getBillingAgreementRequest_buildsWithLiveStageUrl.

@Test
public void getBillingAgreementRequest_buildsWithLiveStageUrl() throws JSONException {
    Configuration configuration = Configuration.fromJson(stringFromFixture("configuration/with_live_paypal.json"));
    BraintreeFragment fragment = mMockFragmentBuilder.configuration(configuration).build();
    Request request = PayPal.getBillingAgreementRequest(fragment, null);
    assertEquals(EnvironmentManager.LIVE, 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)

Aggregations

AuthorizationRequest (com.paypal.android.sdk.onetouch.core.AuthorizationRequest)26 Request (com.paypal.android.sdk.onetouch.core.Request)26 Test (org.junit.Test)23 CheckoutRequest (com.paypal.android.sdk.onetouch.core.CheckoutRequest)21 Intent (android.content.Intent)12 BillingAgreementRequest (com.paypal.android.sdk.onetouch.core.BillingAgreementRequest)12 Configuration (com.braintreepayments.api.models.Configuration)10 PayPalRequest (com.braintreepayments.api.models.PayPalRequest)8 PayPalApprovalCallback (com.braintreepayments.api.interfaces.PayPalApprovalCallback)6 PayPalApprovalHandler (com.braintreepayments.api.interfaces.PayPalApprovalHandler)6 Result (com.paypal.android.sdk.onetouch.core.Result)6 Context (android.content.Context)5 Bundle (android.os.Bundle)5 ContextInspector (com.paypal.android.sdk.onetouch.core.base.ContextInspector)5 Protocol (com.paypal.android.sdk.onetouch.core.enums.Protocol)5 TestSetupHelper.getMockContextInspector (com.paypal.android.sdk.onetouch.core.test.TestSetupHelper.getMockContextInspector)5 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 PaymentMethodNonceCallback (com.braintreepayments.api.interfaces.PaymentMethodNonceCallback)3 PayPalAccountNonce (com.braintreepayments.api.models.PayPalAccountNonce)3 PaymentMethodBuilder (com.braintreepayments.api.models.PaymentMethodBuilder)3