Search in sources :

Example 1 with CheckoutRequest

use of com.paypal.android.sdk.onetouch.core.CheckoutRequest 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 2 with CheckoutRequest

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

the class BrowserSwitchHelperUnitTest method handleBrowserResponse_sendsEventForReturn.

@Test
public void handleBrowserResponse_sendsEventForReturn() {
    Result expectedResult = new Result("test", ResponseType.web, new JSONObject(), "");
    CheckoutRequest request = mock(CheckoutRequest.class);
    when(request.parseBrowserResponse(any(ContextInspector.class), any(Uri.class))).thenReturn(expectedResult);
    BrowserSwitchHelper.parseBrowserSwitchResponse(mContextInspector, request, mock(Uri.class));
    verify(request).trackFpti(any(Context.class), eq(TrackingPoint.Return), isNull(Protocol.class));
}
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) CheckoutRequest(com.paypal.android.sdk.onetouch.core.CheckoutRequest) Protocol(com.paypal.android.sdk.onetouch.core.enums.Protocol) Uri(android.net.Uri) Result(com.paypal.android.sdk.onetouch.core.Result) Test(org.junit.Test)

Example 3 with CheckoutRequest

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

the class BrowserSwitchHelperUnitTest method handleBrowserResponse_parsesResponse.

@Test
public void handleBrowserResponse_parsesResponse() {
    Result expectedResult = new Result();
    CheckoutRequest request = mock(CheckoutRequest.class);
    when(request.parseBrowserResponse(any(ContextInspector.class), any(Uri.class))).thenReturn(expectedResult);
    Result result = BrowserSwitchHelper.parseBrowserSwitchResponse(mContextInspector, request, mock(Uri.class));
    assertEquals(expectedResult, result);
}
Also used : ContextInspector(com.paypal.android.sdk.onetouch.core.base.ContextInspector) TestSetupHelper.getMockContextInspector(com.paypal.android.sdk.onetouch.core.test.TestSetupHelper.getMockContextInspector) CheckoutRequest(com.paypal.android.sdk.onetouch.core.CheckoutRequest) Uri(android.net.Uri) Result(com.paypal.android.sdk.onetouch.core.Result) Test(org.junit.Test)

Example 4 with CheckoutRequest

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

the class BrowserSwitchHelperUnitTest method handleBrowserResponse_sendsEventForError.

@Test
public void handleBrowserResponse_sendsEventForError() {
    Result expectedResult = new Result(new Exception());
    CheckoutRequest request = mock(CheckoutRequest.class);
    when(request.parseBrowserResponse(any(ContextInspector.class), any(Uri.class))).thenReturn(expectedResult);
    BrowserSwitchHelper.parseBrowserSwitchResponse(mContextInspector, request, mock(Uri.class));
    verify(request).trackFpti(any(Context.class), eq(TrackingPoint.Error), isNull(Protocol.class));
}
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) CheckoutRequest(com.paypal.android.sdk.onetouch.core.CheckoutRequest) Protocol(com.paypal.android.sdk.onetouch.core.enums.Protocol) Uri(android.net.Uri) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) Result(com.paypal.android.sdk.onetouch.core.Result) Test(org.junit.Test)

Example 5 with CheckoutRequest

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

the class BrowserSwitchHelperUnitTest method getBrowserIntent_returnsIntent.

@Test
public void getBrowserIntent_returnsIntent() throws Exception {
    CheckoutRequest request = spy(new CheckoutRequest());
    doNothing().when(request).trackFpti(any(Context.class), any(TrackingPoint.class), any(Protocol.class));
    request.approvalURL("https://paypal.com/?token=test-token-key");
    Intent intent = BrowserSwitchHelper.getBrowserSwitchIntent(mContextInspector, mConfigManager, request);
    verify(request).trackFpti(any(Context.class), eq(TrackingPoint.SwitchToBrowser), any(Protocol.class));
    assertEquals(Intent.ACTION_VIEW, intent.getAction());
    assertEquals("https://paypal.com/?token=test-token-key", intent.getData().toString());
    assertEquals("com.android.chrome", intent.getPackage());
}
Also used : Context(android.content.Context) TrackingPoint(com.paypal.android.sdk.onetouch.core.fpti.TrackingPoint) CheckoutRequest(com.paypal.android.sdk.onetouch.core.CheckoutRequest) Intent(android.content.Intent) Protocol(com.paypal.android.sdk.onetouch.core.enums.Protocol) Test(org.junit.Test)

Aggregations

CheckoutRequest (com.paypal.android.sdk.onetouch.core.CheckoutRequest)10 Test (org.junit.Test)7 Context (android.content.Context)5 Uri (android.net.Uri)4 Result (com.paypal.android.sdk.onetouch.core.Result)4 ContextInspector (com.paypal.android.sdk.onetouch.core.base.ContextInspector)4 Protocol (com.paypal.android.sdk.onetouch.core.enums.Protocol)4 TestSetupHelper.getMockContextInspector (com.paypal.android.sdk.onetouch.core.test.TestSetupHelper.getMockContextInspector)4 Intent (android.content.Intent)3 JSONObject (org.json.JSONObject)3 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)1 ClientToken (com.braintreepayments.api.models.ClientToken)1 Configuration (com.braintreepayments.api.models.Configuration)1 PayPalAccountBuilder (com.braintreepayments.api.models.PayPalAccountBuilder)1 PostalAddress (com.braintreepayments.api.models.PostalAddress)1 AuthorizationRequest (com.paypal.android.sdk.onetouch.core.AuthorizationRequest)1 OtcConfiguration (com.paypal.android.sdk.onetouch.core.config.OtcConfiguration)1 TrackingPoint (com.paypal.android.sdk.onetouch.core.fpti.TrackingPoint)1 JSONException (org.json.JSONException)1