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"));
}
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"));
}
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"));
}
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"));
}
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());
}
Aggregations