Search in sources :

Example 1 with Recipe

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

the class AppSwitchHelperUnitTest method getMockRecipe.

private Recipe getMockRecipe(int version) {
    Recipe recipe = mock(Recipe.class);
    when(recipe.getTargetIntentAction()).thenReturn("com.paypal.android.lib.authenticator.activity.v" + version + ".TouchActivity");
    switch(version) {
        case 0:
            when(recipe.getProtocol()).thenReturn(Protocol.v0);
            break;
        case 1:
            when(recipe.getProtocol()).thenReturn(Protocol.v1);
            break;
        case 2:
            when(recipe.getProtocol()).thenReturn(Protocol.v2);
            break;
        case 3:
            when(recipe.getProtocol()).thenReturn(Protocol.v3);
            break;
    }
    return recipe;
}
Also used : Recipe(com.paypal.android.sdk.onetouch.core.config.Recipe)

Example 2 with Recipe

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

the class PayPalOneTouchCore method getStartIntent.

/**
 * Get a {@link PendingRequest} containing an {@link Intent} used to start a PayPal
 * authentication request using the best possible authentication mechanism: wallet or browser.
 *
 * @param context
 * @param request the {@link Request} used to build the {@link Intent}.
 * @return {@link PendingRequest}. {@link PendingRequest#isSuccess()} should be
 *         checked before attempting to use the {@link Intent} it contains. If {@code true} an
 *         {@link Intent} was created and can be used to start a PayPal authentication request.
 *         If {@code false} it is not possible to authenticate given the current environment
 *         and request.
 */
public static PendingRequest getStartIntent(Context context, Request request) {
    initService(context);
    // calling this method functionally does nothing, but ensures that we send off FPTI data about wallet installs.
    isWalletAppInstalled(context);
    Recipe recipe = request.getRecipeToExecute(context, sConfigManager.getConfig());
    if (recipe == null) {
        return new PendingRequest(false, null, null, null);
    }
    if (RequestTarget.wallet == recipe.getTarget()) {
        request.trackFpti(context, TrackingPoint.SwitchToWallet, recipe.getProtocol());
        return new PendingRequest(true, RequestTarget.wallet, request.getClientMetadataId(), AppSwitchHelper.getAppSwitchIntent(sContextInspector, sConfigManager, request, recipe));
    } else {
        Intent intent = BrowserSwitchHelper.getBrowserSwitchIntent(sContextInspector, sConfigManager, request);
        if (intent != null) {
            return new PendingRequest(true, RequestTarget.browser, request.getClientMetadataId(), intent);
        } else {
            return new PendingRequest(false, RequestTarget.browser, request.getClientMetadataId(), null);
        }
    }
}
Also used : OAuth2Recipe(com.paypal.android.sdk.onetouch.core.config.OAuth2Recipe) Recipe(com.paypal.android.sdk.onetouch.core.config.Recipe) Intent(android.content.Intent) PendingRequest(com.paypal.android.sdk.onetouch.core.sdk.PendingRequest)

Aggregations

Recipe (com.paypal.android.sdk.onetouch.core.config.Recipe)2 Intent (android.content.Intent)1 OAuth2Recipe (com.paypal.android.sdk.onetouch.core.config.OAuth2Recipe)1 PendingRequest (com.paypal.android.sdk.onetouch.core.sdk.PendingRequest)1