@Override public void onReceive(Context context, Intent intent) { ShippingInformation shippingInformation = intent.getParcelableExtra(EXTRA_SHIPPING_INFO_DATA); Intent shippingInfoProcessedIntent = new Intent(EVENT_SHIPPING_INFO_PROCESSED); if (shippingInformation.getAddress() == null || !shippingInformation.getAddress().getCountry().equals(Locale.US.getCountry())) { shippingInfoProcessedIntent.putExtra(EXTRA_IS_SHIPPING_INFO_VALID, false); } else { ArrayList<ShippingMethod> shippingMethods = createSampleShippingMethods(); shippingInfoProcessedIntent.putExtra(EXTRA_IS_SHIPPING_INFO_VALID, true); shippingInfoProcessedIntent.putParcelableArrayListExtra(EXTRA_VALID_SHIPPING_METHODS, shippingMethods); shippingInfoProcessedIntent.putExtra(EXTRA_DEFAULT_SHIPPING_METHOD, shippingMethods.get(1)); } LocalBroadcastManager.getInstance(PaymentSessionActivity.this).sendBroadcast(shippingInfoProcessedIntent); } };
@Override public void onReceive(Context context, Intent intent) { ShippingInformation shippingInformation = intent.getParcelableExtra(EXTRA_SHIPPING_INFO_DATA); Intent shippingInfoProcessedIntent = new Intent(EVENT_SHIPPING_INFO_PROCESSED); if (shippingInformation.getAddress() == null || !shippingInformation.getAddress().getCountry().equals(Locale.US.getCountry())) { shippingInfoProcessedIntent.putExtra(EXTRA_IS_SHIPPING_INFO_VALID, false); } else { ArrayList<ShippingMethod> shippingMethods = getValidShippingMethods(shippingInformation); shippingInfoProcessedIntent.putExtra(EXTRA_IS_SHIPPING_INFO_VALID, true); shippingInfoProcessedIntent.putParcelableArrayListExtra(EXTRA_VALID_SHIPPING_METHODS, shippingMethods); shippingInfoProcessedIntent.putExtra(EXTRA_DEFAULT_SHIPPING_METHOD, shippingMethods.get(0)); } LocalBroadcastManager.getInstance(PaymentActivity.this).sendBroadcast(shippingInfoProcessedIntent); } };
/** * @param shippingInformation shippingInformation to populated into the widget input fields. */ public void populateShippingInfo(@Nullable ShippingInformation shippingInformation) { if (shippingInformation == null) { return; } Address address = shippingInformation.getAddress(); if (address != null) { mCityEditText.setText(address.getCity()); if (address.getCountry() != null && !address.getCountry().isEmpty()) { mCountryAutoCompleteTextView.setCountrySelected(address.getCountry()); } mAddressEditText.setText(address.getLine1()); mAddressEditText2.setText(address.getLine2()); mPostalCodeEditText.setText(address.getPostalCode()); mStateEditText.setText(address.getState()); } mNameEditText.setText(shippingInformation.getName()); mPhoneNumberEditText.setText(shippingInformation.getPhone()); }
assertEquals("Eureka", sepaDebitSource.getOwner().getAddress().getCity()); assertEquals("90210", sepaDebitSource.getOwner().getAddress().getPostalCode()); assertEquals("EI", sepaDebitSource.getOwner().getAddress().getCountry()); assertEquals("Sepa Account Holder", sepaDebitSource.getOwner().getName()); } catch (StripeException stripeEx) {
assertEquals("90210", sepaDebitSource.getOwner().getAddress().getPostalCode()); assertEquals("123 Main St", sepaDebitSource.getOwner().getAddress().getLine1()); assertEquals("EI", sepaDebitSource.getOwner().getAddress().getCountry()); assertEquals("Sepa Account Holder", sepaDebitSource.getOwner().getName()); JsonTestUtils.assertMapEquals(metamap ,sepaDebitSource.getMetaData());
assertEquals("90210", sepaDebitSource.getOwner().getAddress().getPostalCode()); assertEquals("123 Main St", sepaDebitSource.getOwner().getAddress().getLine1()); assertEquals("EI", sepaDebitSource.getOwner().getAddress().getCountry()); assertEquals("Sepa Account Holder", sepaDebitSource.getOwner().getName()); JsonTestUtils.assertMapEquals(metamap ,sepaDebitSource.getMetaData());
assertEquals("123 Main St", cardSource.getOwner().getAddress().getLine1()); assertEquals("#456", cardSource.getOwner().getAddress().getLine2()); assertEquals("US", cardSource.getOwner().getAddress().getCountry()); assertEquals("Winnie Hoop", cardSource.getOwner().getName()); JsonTestUtils.assertMapEquals(metamap, cardSource.getMetaData());