com.braintreepayments.cardform.view.CardForm Java Examples
The following examples show how to use
com.braintreepayments.cardform.view.CardForm.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CardholderNameDropInTest.java From braintree-android-drop-in with MIT License | 6 votes |
@Test(timeout = 60000) public void cardholderName_whenRequired_mustBeFilled() { setCardholderNameStatus(CardForm.FIELD_REQUIRED); onDevice(withText("Add Payment Method")).waitForExists().waitForEnabled().perform(click()); onDevice(withText("Credit or Debit Card")).perform(click()); onDevice(withText("Card Number")).perform(setText(VISA)); onDevice(withText("Cardholder Name")).waitForExists(); performCardDetailsEntry(); onDevice(withText("Cardholder name is required")).waitForExists(); onDevice(withText("Cardholder Name")).perform(setText("Brian Tree")); onDevice(withText("Add Card")).perform(click()); getNonceDetails().check(text(containsString("Card Last Two: 11"))); onDevice(withText("Purchase")).perform(click()); onDevice(withTextStartingWith("created")).check(text(endsWith("authorized"))); }
Example #2
Source File: CardholderNameDropInTest.java From braintree-android-drop-in with MIT License | 6 votes |
@Test(timeout = 60000) public void cardholderName_whenOptional_isShownButCanRemainEmpty() { setCardholderNameStatus(CardForm.FIELD_OPTIONAL); onDevice(withText("Add Payment Method")).waitForExists().waitForEnabled().perform(click()); onDevice(withText("Credit or Debit Card")).perform(click()); onDevice(withText("Card Number")).perform(setText(VISA)); onDevice(withText("Cardholder Name")).waitForExists(); performCardDetailsEntry(); onDevice(withTextContaining("Add Card")).perform(click()); getNonceDetails().check(text(containsString("Card Last Two: 11"))); onDevice(withText("Purchase")).perform(click()); onDevice(withTextStartingWith("created")).check(text(endsWith("authorized"))); }
Example #3
Source File: TestHelper.java From braintree-android-drop-in with MIT License | 6 votes |
public void setCardholderNameStatus(int cardholderNameStatus) { String status; switch(cardholderNameStatus) { case CardForm.FIELD_REQUIRED: status = "Required"; break; case CardForm.FIELD_OPTIONAL: status = "Optional"; break; default: case CardForm.FIELD_DISABLED: status = "Disabled"; break; } PreferenceManager.getDefaultSharedPreferences(getTargetContext()) .edit() .putString("cardholder_name_status", status) .commit(); onDevice(withText("Reset")).perform(click()); SystemClock.sleep(2000); }
Example #4
Source File: CardScanningFragment.java From android-card-form with MIT License | 6 votes |
public static CardScanningFragment requestScan(AppCompatActivity activity, CardForm cardForm) { CardScanningFragment fragment = (CardScanningFragment) activity.getSupportFragmentManager() .findFragmentByTag(TAG); if (fragment != null) { activity.getSupportFragmentManager() .beginTransaction() .remove(fragment) .commit(); } fragment = new CardScanningFragment(); fragment.mCardForm = cardForm; activity.getSupportFragmentManager() .beginTransaction() .add(fragment, TAG) .commit(); return fragment; }
Example #5
Source File: AddCardActivityPowerMockTest.java From braintree-android-drop-in with MIT License | 6 votes |
@Before public void setup() throws NoSuchFieldException, IllegalAccessException { mFragment = mock(BraintreeFragment.class); mActivity = Robolectric.buildActivity(AddCardUnitTestActivity.class).get(); setField(BaseActivity.class, mActivity, "mBraintreeFragment", mFragment); EditCardView editCardView = mock(EditCardView.class); when(editCardView.getCardForm()).thenReturn(mock(CardForm.class)); setField(AddCardActivity.class, mActivity, "mEditCardView", editCardView); mockStatic(ThreeDSecure.class); doNothing().when(ThreeDSecure.class); ThreeDSecure.performVerification(any(BraintreeFragment.class), any(ThreeDSecureRequest.class)); }
Example #6
Source File: DropInRequestUnitTest.java From braintree-android-drop-in with MIT License | 6 votes |
@Test public void hasCorrectDefaults() { Intent intent = new DropInRequest() .getIntent(RuntimeEnvironment.application); DropInRequest dropInRequest = intent.getParcelableExtra(DropInRequest.EXTRA_CHECKOUT_REQUEST); assertEquals(DropInActivity.class.getName(), intent.getComponent().getClassName()); assertNull(dropInRequest.getAuthorization()); assertFalse(dropInRequest.shouldCollectDeviceData()); assertNull(dropInRequest.getAmount()); assertTrue(dropInRequest.isGooglePaymentEnabled()); assertNull(dropInRequest.getPayPalRequest()); assertTrue(dropInRequest.isPayPalEnabled()); assertTrue(dropInRequest.isVenmoEnabled()); assertTrue(dropInRequest.isCardEnabled()); assertFalse(dropInRequest.shouldRequestThreeDSecureVerification()); assertNull(dropInRequest.getThreeDSecureRequest()); assertFalse(dropInRequest.shouldMaskCardNumber()); assertFalse(dropInRequest.shouldMaskSecurityCode()); assertFalse(dropInRequest.isVaultManagerEnabled()); assertFalse(dropInRequest.isSaveCardCheckBoxShown()); assertTrue(dropInRequest.getDefaultVaultSetting()); assertEquals(CardForm.FIELD_DISABLED, dropInRequest.getCardholderNameStatus()); }
Example #7
Source File: CardholderNameDropInTest.java From braintree-android-drop-in with MIT License | 5 votes |
@Test(timeout = 60000) public void cardholderName_whenDisabled_isHidden() { setCardholderNameStatus(CardForm.FIELD_DISABLED); onDevice(withText("Add Payment Method")).waitForExists().waitForEnabled().perform(click()); onDevice(withText("Credit or Debit Card")).perform(click()); onDevice(withText("Card Number")).perform(setText(VISA)); onDevice(withText("Card Details")).waitForExists(); try { onDevice().check(text(containsString("Cardholder Name"))); fail("Cardholder Name was not supposed to exist when CardForm.FIELD_DISABLED is set" + "for Cardholder Name status"); } catch (RuntimeException ignored) {} }
Example #8
Source File: BaseCardFormActivity.java From android-card-form with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.card_form); mSupportedCardTypesView = findViewById(R.id.supported_card_types); mSupportedCardTypesView.setSupportedCardTypes(SUPPORTED_CARD_TYPES); mCardForm = findViewById(R.id.card_form); mCardForm.cardRequired(true) .maskCardNumber(true) .maskCvv(true) .expirationRequired(true) .cvvRequired(true) .postalCodeRequired(true) .mobileNumberRequired(true) .saveCardCheckBoxChecked(true) .saveCardCheckBoxVisible(true) .cardholderName(CardForm.FIELD_REQUIRED) .mobileNumberExplanation("Make sure SMS is enabled for this mobile number") .actionLabel(getString(R.string.purchase)) .setup(this); mCardForm.setOnCardFormSubmitListener(this); mCardForm.setOnCardTypeChangedListener(this); // Warning: this is for development purposes only and should never be done outside of this example app. // Failure to set FLAG_SECURE exposes your app to screenshots allowing other apps to steal card information. getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE); }
Example #9
Source File: TestActivity.java From android-card-form with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTheme(androidx.appcompat.R.style.Theme_AppCompat); CardForm cardForm = new CardForm(this); cardForm.setId(android.R.id.custom); ((FrameLayout) findViewById(android.R.id.content)).addView(cardForm); }
Example #10
Source File: AddCardActivityUnitTest.java From braintree-android-drop-in with MIT License | 5 votes |
@Test public void addingAUnionPayCard_whenCardholderNameRequired_tokenizesWithCardholderName() { BraintreeUnitTestHttpClient httpClient = new BraintreeUnitTestHttpClient() .configuration(new TestConfigurationBuilder() .creditCards(getSupportedCardConfiguration()) .unionPay(new TestUnionPayConfigurationBuilder() .enabled(true)) .build()) .successResponse(BraintreeUnitTestHttpClient.UNIONPAY_CAPABILITIES_PATH, stringFromFixture("responses/unionpay_capabilities_success_response.json")) .successResponse(BraintreeUnitTestHttpClient.UNIONPAY_ENROLLMENT_PATH, stringFromFixture("responses/unionpay_enrollment_sms_not_required.json")) .successResponse(BraintreeUnitTestHttpClient.TOKENIZE_CREDIT_CARD, stringFromFixture("payment_methods/unionpay_credit_card.json")) .verifyPostData(BraintreeUnitTestHttpClient.TOKENIZE_CREDIT_CARD, "cardholderName\":\"Brian Tree\""); mActivity.setDropInRequest(new DropInRequest() .cardholderNameStatus(CardForm.FIELD_REQUIRED) .clientToken(base64EncodedClientTokenFromFixture("client_token.json"))); setup(httpClient); setText(mAddCardView, R.id.bt_card_form_card_number, UNIONPAY_SMS_NOT_REQUIRED); mAddCardView.findViewById(R.id.bt_button).performClick(); setText(mEditCardView, R.id.bt_card_form_expiration, ExpirationDate.VALID_EXPIRATION); setText(mEditCardView, R.id.bt_card_form_cvv, "123"); setText(mEditCardView, R.id.bt_card_form_country_code, "86"); setText(mEditCardView, R.id.bt_card_form_mobile_number, "8888888888"); setText(mEditCardView, R.id.bt_card_form_cardholder_name, "Brian Tree"); mEditCardView.findViewById(R.id.bt_button).performClick(); assertTrue(mActivity.isFinishing()); DropInResult result = mShadowActivity.getResultIntent() .getParcelableExtra(DropInResult.EXTRA_DROP_IN_RESULT); assertEquals(RESULT_OK, mShadowActivity.getResultCode()); assertIsANonce(result.getPaymentMethodNonce().getNonce()); assertEquals("85", ((CardNonce) result.getPaymentMethodNonce()).getLastTwo()); }
Example #11
Source File: AddCardActivityUnitTest.java From braintree-android-drop-in with MIT License | 5 votes |
@Test public void addingAUnionPayCard_whenCardholderNameOptionalAndFilled_tokenizesWithCardholderName() { BraintreeUnitTestHttpClient httpClient = new BraintreeUnitTestHttpClient() .configuration(new TestConfigurationBuilder() .creditCards(getSupportedCardConfiguration()) .unionPay(new TestUnionPayConfigurationBuilder() .enabled(true)) .build()) .successResponse(BraintreeUnitTestHttpClient.UNIONPAY_CAPABILITIES_PATH, stringFromFixture("responses/unionpay_capabilities_success_response.json")) .successResponse(BraintreeUnitTestHttpClient.UNIONPAY_ENROLLMENT_PATH, stringFromFixture("responses/unionpay_enrollment_sms_not_required.json")) .successResponse(BraintreeUnitTestHttpClient.TOKENIZE_CREDIT_CARD, stringFromFixture("payment_methods/unionpay_credit_card.json")) .verifyPostData(BraintreeUnitTestHttpClient.TOKENIZE_CREDIT_CARD, "cardholderName\":\"Brian Tree\""); mActivity.setDropInRequest(new DropInRequest() .cardholderNameStatus(CardForm.FIELD_OPTIONAL) .clientToken(base64EncodedClientTokenFromFixture("client_token.json"))); setup(httpClient); setText(mAddCardView, R.id.bt_card_form_card_number, UNIONPAY_SMS_NOT_REQUIRED); mAddCardView.findViewById(R.id.bt_button).performClick(); setText(mEditCardView, R.id.bt_card_form_expiration, ExpirationDate.VALID_EXPIRATION); setText(mEditCardView, R.id.bt_card_form_cvv, "123"); setText(mEditCardView, R.id.bt_card_form_country_code, "86"); setText(mEditCardView, R.id.bt_card_form_mobile_number, "8888888888"); setText(mEditCardView, R.id.bt_card_form_cardholder_name, "Brian Tree"); mEditCardView.findViewById(R.id.bt_button).performClick(); assertTrue(mActivity.isFinishing()); DropInResult result = mShadowActivity.getResultIntent() .getParcelableExtra(DropInResult.EXTRA_DROP_IN_RESULT); assertEquals(RESULT_OK, mShadowActivity.getResultCode()); assertIsANonce(result.getPaymentMethodNonce().getNonce()); assertEquals("85", ((CardNonce) result.getPaymentMethodNonce()).getLastTwo()); }
Example #12
Source File: AddCardActivityUnitTest.java From braintree-android-drop-in with MIT License | 5 votes |
@Test public void addingAUnionPayCard_whenCardholderNameOptionalAndEmpty_tokenizesWithoutCardholderName() { BraintreeUnitTestHttpClient httpClient = new BraintreeUnitTestHttpClient() .configuration(new TestConfigurationBuilder() .creditCards(getSupportedCardConfiguration()) .unionPay(new TestUnionPayConfigurationBuilder() .enabled(true)) .build()) .successResponse(BraintreeUnitTestHttpClient.UNIONPAY_CAPABILITIES_PATH, stringFromFixture("responses/unionpay_capabilities_success_response.json")) .successResponse(BraintreeUnitTestHttpClient.UNIONPAY_ENROLLMENT_PATH, stringFromFixture("responses/unionpay_enrollment_sms_not_required.json")) .successResponse(BraintreeUnitTestHttpClient.TOKENIZE_CREDIT_CARD, stringFromFixture("payment_methods/unionpay_credit_card.json")) .verifyPostData(BraintreeUnitTestHttpClient.TOKENIZE_CREDIT_CARD, "^(?!cardholderName).*$"); mActivity.setDropInRequest(new DropInRequest() .cardholderNameStatus(CardForm.FIELD_OPTIONAL) .clientToken(base64EncodedClientTokenFromFixture("client_token.json"))); setup(httpClient); setText(mAddCardView, R.id.bt_card_form_card_number, UNIONPAY_SMS_NOT_REQUIRED); mAddCardView.findViewById(R.id.bt_button).performClick(); setText(mEditCardView, R.id.bt_card_form_expiration, ExpirationDate.VALID_EXPIRATION); setText(mEditCardView, R.id.bt_card_form_cvv, "123"); setText(mEditCardView, R.id.bt_card_form_country_code, "86"); setText(mEditCardView, R.id.bt_card_form_mobile_number, "8888888888"); mEditCardView.findViewById(R.id.bt_button).performClick(); assertTrue(mActivity.isFinishing()); DropInResult result = mShadowActivity.getResultIntent() .getParcelableExtra(DropInResult.EXTRA_DROP_IN_RESULT); assertEquals(RESULT_OK, mShadowActivity.getResultCode()); assertIsANonce(result.getPaymentMethodNonce().getNonce()); assertEquals("85", ((CardNonce) result.getPaymentMethodNonce()).getLastTwo()); }
Example #13
Source File: AddCardActivityUnitTest.java From braintree-android-drop-in with MIT License | 5 votes |
@Test public void addingACard_whenCardholderNameRequired_sendsCardholderNameToTokenize() { BraintreeUnitTestHttpClient httpClient = new BraintreeUnitTestHttpClient() .configuration(new TestConfigurationBuilder() .creditCards(getSupportedCardConfiguration()) .build()) .verifyPostData(BraintreeUnitTestHttpClient.TOKENIZE_CREDIT_CARD, "cardholderName\":\"Brian Tree\"") .successResponse(BraintreeUnitTestHttpClient.TOKENIZE_CREDIT_CARD, stringFromFixture("payment_methods/visa_credit_card.json")); mActivity.setDropInRequest(new DropInRequest() .cardholderNameStatus(CardForm.FIELD_REQUIRED) .clientToken(base64EncodedClientTokenFromFixture("client_token.json"))); setup(httpClient); setText(mAddCardView, R.id.bt_card_form_card_number, VISA); mAddCardView.findViewById(R.id.bt_button).performClick(); setText(mEditCardView, R.id.bt_card_form_expiration, ExpirationDate.VALID_EXPIRATION); setText(mEditCardView, R.id.bt_card_form_cardholder_name, "Brian Tree"); mEditCardView.findViewById(R.id.bt_button).performClick(); assertTrue(mActivity.isFinishing()); DropInResult result = mShadowActivity.getResultIntent() .getParcelableExtra(DropInResult.EXTRA_DROP_IN_RESULT); assertEquals(RESULT_OK, mShadowActivity.getResultCode()); assertIsANonce(result.getPaymentMethodNonce().getNonce()); assertEquals("11", ((CardNonce) result.getPaymentMethodNonce()).getLastTwo()); }
Example #14
Source File: AddCardActivityUnitTest.java From braintree-android-drop-in with MIT License | 5 votes |
@Test public void addingACard_whenCardholderNameOptionalAndFilled_sendsCardholderNameToTokenize() { BraintreeUnitTestHttpClient httpClient = new BraintreeUnitTestHttpClient() .configuration(new TestConfigurationBuilder() .creditCards(getSupportedCardConfiguration()) .build()) .verifyPostData(BraintreeUnitTestHttpClient.TOKENIZE_CREDIT_CARD, "cardholderName\":\"Brian Tree\"") .successResponse(BraintreeUnitTestHttpClient.TOKENIZE_CREDIT_CARD, stringFromFixture("payment_methods/visa_credit_card.json")); mActivity.setDropInRequest(new DropInRequest() .cardholderNameStatus(CardForm.FIELD_OPTIONAL) .clientToken(base64EncodedClientTokenFromFixture("client_token.json"))); setup(httpClient); setText(mAddCardView, R.id.bt_card_form_card_number, VISA); mAddCardView.findViewById(R.id.bt_button).performClick(); setText(mEditCardView, R.id.bt_card_form_expiration, ExpirationDate.VALID_EXPIRATION); setText(mEditCardView, R.id.bt_card_form_cardholder_name, "Brian Tree"); mEditCardView.findViewById(R.id.bt_button).performClick(); assertTrue(mActivity.isFinishing()); DropInResult result = mShadowActivity.getResultIntent() .getParcelableExtra(DropInResult.EXTRA_DROP_IN_RESULT); assertEquals(RESULT_OK, mShadowActivity.getResultCode()); assertIsANonce(result.getPaymentMethodNonce().getNonce()); assertEquals("11", ((CardNonce) result.getPaymentMethodNonce()).getLastTwo()); }
Example #15
Source File: AddCardActivityUnitTest.java From braintree-android-drop-in with MIT License | 5 votes |
@Test public void addingACard_whenCardholderNameOptionalAndEmpty_doesNotSendCardholderNameToTokenize() { BraintreeUnitTestHttpClient httpClient = new BraintreeUnitTestHttpClient() .configuration(new TestConfigurationBuilder() .creditCards(getSupportedCardConfiguration()) .build()) .verifyPostData(BraintreeUnitTestHttpClient.TOKENIZE_CREDIT_CARD, "^(?!cardholderName).*$") .successResponse(BraintreeUnitTestHttpClient.TOKENIZE_CREDIT_CARD, stringFromFixture("payment_methods/visa_credit_card.json")); mActivity.setDropInRequest(new DropInRequest() .cardholderNameStatus(CardForm.FIELD_OPTIONAL) .clientToken(base64EncodedClientTokenFromFixture("client_token.json"))); setup(httpClient); setText(mAddCardView, R.id.bt_card_form_card_number, VISA); mAddCardView.findViewById(R.id.bt_button).performClick(); setText(mEditCardView, R.id.bt_card_form_expiration, ExpirationDate.VALID_EXPIRATION); mEditCardView.findViewById(R.id.bt_button).performClick(); assertTrue(mActivity.isFinishing()); DropInResult result = mShadowActivity.getResultIntent() .getParcelableExtra(DropInResult.EXTRA_DROP_IN_RESULT); assertEquals(RESULT_OK, mShadowActivity.getResultCode()); assertIsANonce(result.getPaymentMethodNonce().getNonce()); assertEquals("11", ((CardNonce) result.getPaymentMethodNonce()).getLastTwo()); }
Example #16
Source File: DropInRequestUnitTest.java From braintree-android-drop-in with MIT License | 5 votes |
@Test public void getCardholderNameStatus_includesCardHolderNameStatus() { DropInRequest dropInRequest = new DropInRequest() .cardholderNameStatus(CardForm.FIELD_REQUIRED); assertEquals(CardForm.FIELD_REQUIRED, dropInRequest.getCardholderNameStatus()); }
Example #17
Source File: AddCardActivity.java From braintree-android-drop-in with MIT License | 5 votes |
protected void createCard() { CardForm cardForm = mEditCardView.getCardForm(); if (mUnionPayCard) { UnionPayCardBuilder unionPayCardBuilder = new UnionPayCardBuilder() .cardholderName(cardForm.getCardholderName()) .cardNumber(cardForm.getCardNumber()) .expirationMonth(cardForm.getExpirationMonth()) .expirationYear(cardForm.getExpirationYear()) .cvv(cardForm.getCvv()) .postalCode(cardForm.getPostalCode()) .mobileCountryCode(cardForm.getCountryCode()) .mobilePhoneNumber(cardForm.getMobileNumber()) .enrollmentId(mEnrollmentId) .smsCode(mEnrollmentCardView.getSmsCode()); UnionPay.tokenize(mBraintreeFragment, unionPayCardBuilder); } else { boolean shouldVault = mClientTokenPresent && cardForm.isSaveCardCheckBoxChecked(); CardBuilder cardBuilder = new CardBuilder() .cardholderName(cardForm.getCardholderName()) .cardNumber(cardForm.getCardNumber()) .expirationMonth(cardForm.getExpirationMonth()) .expirationYear(cardForm.getExpirationYear()) .cvv(cardForm.getCvv()) .postalCode(cardForm.getPostalCode()) .validate(shouldVault); Card.tokenize(mBraintreeFragment, cardBuilder); } }
Example #18
Source File: Settings.java From braintree-android-drop-in with MIT License | 5 votes |
public static int getCardholderNameStatus(Context context) { String status = getPreferences(context).getString("cardholder_name_status", "Disabled"); switch (status) { case "Optional": return CardForm.FIELD_OPTIONAL; case "Required": return CardForm.FIELD_REQUIRED; case "Disabled": default: return CardForm.FIELD_DISABLED; } }
Example #19
Source File: AddCardViewUnitTest.java From braintree-android-drop-in with MIT License | 4 votes |
@Test public void getCardForm_returnsCardForm() { CardForm cardForm = (CardForm) mView.findViewById(R.id.bt_card_form); assertEquals(cardForm, mView.getCardForm()); }
Example #20
Source File: EditCardViewUnitTest.java From braintree-android-drop-in with MIT License | 4 votes |
@Test public void getCardForm_returnsCardForm() { CardForm cardForm = mView.findViewById(R.id.bt_card_form); assertEquals(cardForm, mView.getCardForm()); }
Example #21
Source File: DropInRequestUnitTest.java From braintree-android-drop-in with MIT License | 4 votes |
@Test public void isParcelable() { Cart cart = Cart.newBuilder() .setTotalPrice("5.00") .build(); GooglePaymentRequest googlePaymentRequest = new GooglePaymentRequest() .transactionInfo(TransactionInfo.newBuilder() .setTotalPrice("10") .setCurrencyCode("USD") .setTotalPriceStatus(WalletConstants.TOTAL_PRICE_STATUS_FINAL) .build()) .emailRequired(true); PayPalRequest paypalRequest = new PayPalRequest("10") .currencyCode("USD"); ThreeDSecureRequest threeDSecureRequest = new ThreeDSecureRequest() .nonce("abc-123") .versionRequested(ThreeDSecureRequest.VERSION_2) .amount("10.00") .email("[email protected]") .mobilePhoneNumber("3125551234") .billingAddress(new ThreeDSecurePostalAddress() .givenName("Given") .surname("Surname") .streetAddress("555 Smith St.") .extendedAddress("#5") .locality("Chicago") .region("IL") .postalCode("54321") .countryCodeAlpha2("US") .phoneNumber("3125557890") ) .additionalInformation(new ThreeDSecureAdditionalInformation() .shippingMethodIndicator("GEN") ); DropInRequest dropInRequest = new DropInRequest() .tokenizationKey(TOKENIZATION_KEY) .collectDeviceData(true) .amount("1.00") .googlePaymentRequest(googlePaymentRequest) .disableGooglePayment() .paypalRequest(paypalRequest) .disablePayPal() .disableVenmo() .disableCard() .requestThreeDSecureVerification(true) .threeDSecureRequest(threeDSecureRequest) .maskCardNumber(true) .maskSecurityCode(true) .vaultManager(true) .vaultCard(true) .allowVaultCardOverride(true) .cardholderNameStatus(CardForm.FIELD_OPTIONAL); Parcel parcel = Parcel.obtain(); dropInRequest.writeToParcel(parcel, 0); parcel.setDataPosition(0); DropInRequest parceledDropInRequest = DropInRequest.CREATOR.createFromParcel(parcel); assertEquals(TOKENIZATION_KEY, parceledDropInRequest.getAuthorization()); assertTrue(parceledDropInRequest.shouldCollectDeviceData()); assertEquals("1.00", parceledDropInRequest.getAmount()); assertEquals("10", dropInRequest.getGooglePaymentRequest().getTransactionInfo().getTotalPrice()); assertEquals("USD", dropInRequest.getGooglePaymentRequest().getTransactionInfo().getCurrencyCode()); assertEquals(WalletConstants.TOTAL_PRICE_STATUS_FINAL, dropInRequest.getGooglePaymentRequest().getTransactionInfo().getTotalPriceStatus()); assertTrue(dropInRequest.getGooglePaymentRequest().isEmailRequired()); assertEquals("10", dropInRequest.getPayPalRequest().getAmount()); assertEquals("USD", dropInRequest.getPayPalRequest().getCurrencyCode()); assertFalse(dropInRequest.isGooglePaymentEnabled()); assertFalse(parceledDropInRequest.isPayPalEnabled()); assertFalse(parceledDropInRequest.isVenmoEnabled()); assertFalse(parceledDropInRequest.isCardEnabled()); assertTrue(parceledDropInRequest.shouldRequestThreeDSecureVerification()); assertEquals("abc-123", dropInRequest.getThreeDSecureRequest().getNonce()); assertEquals("2", dropInRequest.getThreeDSecureRequest().getVersionRequested()); assertEquals("10.00", dropInRequest.getThreeDSecureRequest().getAmount()); assertEquals("[email protected]", dropInRequest.getThreeDSecureRequest().getEmail()); assertEquals("3125551234", dropInRequest.getThreeDSecureRequest().getMobilePhoneNumber()); assertEquals("Given", dropInRequest.getThreeDSecureRequest().getBillingAddress().getGivenName()); assertEquals("Surname", dropInRequest.getThreeDSecureRequest().getBillingAddress().getSurname()); assertEquals("555 Smith St.", dropInRequest.getThreeDSecureRequest().getBillingAddress().getStreetAddress()); assertEquals("#5", dropInRequest.getThreeDSecureRequest().getBillingAddress().getExtendedAddress()); assertEquals("Chicago", dropInRequest.getThreeDSecureRequest().getBillingAddress().getLocality()); assertEquals("IL", dropInRequest.getThreeDSecureRequest().getBillingAddress().getRegion()); assertEquals("54321", dropInRequest.getThreeDSecureRequest().getBillingAddress().getPostalCode()); assertEquals("US", dropInRequest.getThreeDSecureRequest().getBillingAddress().getCountryCodeAlpha2()); assertEquals("3125557890", dropInRequest.getThreeDSecureRequest().getBillingAddress().getPhoneNumber()); assertEquals("GEN", dropInRequest.getThreeDSecureRequest().getAdditionalInformation().getShippingMethodIndicator()); assertTrue(parceledDropInRequest.shouldMaskCardNumber()); assertTrue(parceledDropInRequest.shouldMaskSecurityCode()); assertTrue(parceledDropInRequest.isVaultManagerEnabled()); assertTrue(parceledDropInRequest.getDefaultVaultSetting()); assertTrue(parceledDropInRequest.isSaveCardCheckBoxShown()); assertEquals(CardForm.FIELD_OPTIONAL, parceledDropInRequest.getCardholderNameStatus()); }
Example #22
Source File: DropInRequestUnitTest.java From braintree-android-drop-in with MIT License | 4 votes |
@Test public void includesAllOptions() { GooglePaymentRequest googlePaymentRequest = new GooglePaymentRequest() .transactionInfo(TransactionInfo.newBuilder() .setTotalPrice("10") .setCurrencyCode("USD") .setTotalPriceStatus(WalletConstants.TOTAL_PRICE_STATUS_FINAL) .build()) .emailRequired(true); PayPalRequest paypalRequest = new PayPalRequest("10") .currencyCode("USD"); ThreeDSecureRequest threeDSecureRequest = new ThreeDSecureRequest() .nonce("abc-123") .versionRequested(ThreeDSecureRequest.VERSION_2) .amount("10.00") .email("[email protected]") .mobilePhoneNumber("3125551234") .billingAddress(new ThreeDSecurePostalAddress() .givenName("Given") .surname("Surname") .streetAddress("555 Smith St.") .extendedAddress("#5") .locality("Chicago") .region("IL") .postalCode("54321") .countryCodeAlpha2("US") .phoneNumber("3125557890") ) .additionalInformation(new ThreeDSecureAdditionalInformation() .shippingMethodIndicator("GEN") ); Intent intent = new DropInRequest() .tokenizationKey(TOKENIZATION_KEY) .collectDeviceData(true) .amount("1.00") .googlePaymentRequest(googlePaymentRequest) .disableGooglePayment() .paypalRequest(paypalRequest) .disablePayPal() .disableVenmo() .disableCard() .requestThreeDSecureVerification(true) .threeDSecureRequest(threeDSecureRequest) .maskCardNumber(true) .maskSecurityCode(true) .vaultManager(true) .allowVaultCardOverride(true) .vaultCard(true) .cardholderNameStatus(CardForm.FIELD_OPTIONAL) .getIntent(RuntimeEnvironment.application); DropInRequest dropInRequest = intent.getParcelableExtra(DropInRequest.EXTRA_CHECKOUT_REQUEST); assertEquals(DropInActivity.class.getName(), intent.getComponent().getClassName()); assertEquals(TOKENIZATION_KEY, dropInRequest.getAuthorization()); assertTrue(dropInRequest.shouldCollectDeviceData()); assertEquals("1.00", dropInRequest.getAmount()); assertEquals("10", dropInRequest.getGooglePaymentRequest().getTransactionInfo().getTotalPrice()); assertEquals("USD", dropInRequest.getGooglePaymentRequest().getTransactionInfo().getCurrencyCode()); assertEquals(WalletConstants.TOTAL_PRICE_STATUS_FINAL, dropInRequest.getGooglePaymentRequest().getTransactionInfo().getTotalPriceStatus()); assertTrue(dropInRequest.getGooglePaymentRequest().isEmailRequired()); assertFalse(dropInRequest.isGooglePaymentEnabled()); assertEquals("10", dropInRequest.getPayPalRequest().getAmount()); assertEquals("USD", dropInRequest.getPayPalRequest().getCurrencyCode()); assertFalse(dropInRequest.isPayPalEnabled()); assertFalse(dropInRequest.isVenmoEnabled()); assertFalse(dropInRequest.isCardEnabled()); assertTrue(dropInRequest.shouldRequestThreeDSecureVerification()); assertEquals("abc-123", dropInRequest.getThreeDSecureRequest().getNonce()); assertEquals("2", dropInRequest.getThreeDSecureRequest().getVersionRequested()); assertEquals("10.00", dropInRequest.getThreeDSecureRequest().getAmount()); assertEquals("[email protected]", dropInRequest.getThreeDSecureRequest().getEmail()); assertEquals("3125551234", dropInRequest.getThreeDSecureRequest().getMobilePhoneNumber()); assertEquals("Given", dropInRequest.getThreeDSecureRequest().getBillingAddress().getGivenName()); assertEquals("Surname", dropInRequest.getThreeDSecureRequest().getBillingAddress().getSurname()); assertEquals("555 Smith St.", dropInRequest.getThreeDSecureRequest().getBillingAddress().getStreetAddress()); assertEquals("#5", dropInRequest.getThreeDSecureRequest().getBillingAddress().getExtendedAddress()); assertEquals("Chicago", dropInRequest.getThreeDSecureRequest().getBillingAddress().getLocality()); assertEquals("IL", dropInRequest.getThreeDSecureRequest().getBillingAddress().getRegion()); assertEquals("54321", dropInRequest.getThreeDSecureRequest().getBillingAddress().getPostalCode()); assertEquals("US", dropInRequest.getThreeDSecureRequest().getBillingAddress().getCountryCodeAlpha2()); assertEquals("3125557890", dropInRequest.getThreeDSecureRequest().getBillingAddress().getPhoneNumber()); assertEquals("GEN", dropInRequest.getThreeDSecureRequest().getAdditionalInformation().getShippingMethodIndicator()); assertTrue(dropInRequest.shouldMaskCardNumber()); assertTrue(dropInRequest.shouldMaskSecurityCode()); assertTrue(dropInRequest.isVaultManagerEnabled()); assertTrue(dropInRequest.getDefaultVaultSetting()); assertTrue(dropInRequest.isSaveCardCheckBoxShown()); assertEquals(CardForm.FIELD_OPTIONAL, dropInRequest.getCardholderNameStatus()); }
Example #23
Source File: EditCardView.java From braintree-android-drop-in with MIT License | 4 votes |
public CardForm getCardForm() { return mCardForm; }
Example #24
Source File: CardScanningFragment.java From android-card-form with MIT License | 4 votes |
public void setCardForm(CardForm cardForm) { mCardForm = cardForm; }
Example #25
Source File: AddCardView.java From braintree-android-drop-in with MIT License | 4 votes |
public CardForm getCardForm() { return mCardForm; }