/** * Launch the {@link PaymentMethodsActivity} to allow the user to select a payment method, * or to add a new one. */ public void presentPaymentMethodSelection() { Intent paymentMethodsIntent = PaymentMethodsActivity.newIntent(mHostActivity); paymentMethodsIntent.putExtra(EXTRA_PAYMENT_SESSION_ACTIVE, true); mHostActivity.startActivityForResult(paymentMethodsIntent, PAYMENT_METHOD_REQUEST); }
private void launchWithCustomer() { Intent payIntent = PaymentMethodsActivity.newIntent(this); startActivityForResult(payIntent, REQUEST_CODE_SELECT_SOURCE); }
@Before public void setup() { MockitoAnnotations.initMocks(this); Intent intent = PaymentMethodsActivity.newIntent(ApplicationProvider.getApplicationContext()) .putExtra(EXTRA_PROXY_DELAY, true); mPaymentMethodsActivity = createActivity(intent); mPaymentMethodsActivity.setCustomerSessionProxy(mCustomerSessionProxy); mShadowActivity = Shadows.shadowOf(mPaymentMethodsActivity); mProgressBar = mPaymentMethodsActivity.findViewById(R.id.payment_methods_progress_bar); mRecyclerView = mPaymentMethodsActivity.findViewById(R.id.payment_methods_recycler); mAddCardView = mPaymentMethodsActivity.findViewById(R.id.payment_methods_add_payment_container); }
@Test public void onClickAddSourceView_whenStartedFromPaymentSession_launchesActivityWithLog() { Intent intent = PaymentMethodsActivity .newIntent(ApplicationProvider.getApplicationContext()) .putExtra(EXTRA_PROXY_DELAY, true) .putExtra(EXTRA_PAYMENT_SESSION_ACTIVE, true); mPaymentMethodsActivity = createActivity(intent); mPaymentMethodsActivity.setCustomerSessionProxy(mCustomerSessionProxy); mShadowActivity = Shadows.shadowOf(mPaymentMethodsActivity); mAddCardView = mPaymentMethodsActivity.findViewById(R.id.payment_methods_add_payment_container); Customer customer = Customer.fromString(CustomerSessionTest.FIRST_TEST_CUSTOMER_OBJECT); when(mCustomerSessionProxy.getCachedCustomer()).thenReturn(customer); mPaymentMethodsActivity.initializeCustomerSourceData(); mAddCardView.performClick(); ShadowActivity.IntentForResult intentForResult = mShadowActivity.getNextStartedActivityForResult(); assertNotNull(intentForResult); assertEquals(AddSourceActivity.class.getName(), intentForResult.intent.getComponent().getClassName()); assertTrue(intentForResult.intent.hasExtra(EXTRA_PAYMENT_SESSION_ACTIVE)); }