Java Code Examples for com.braintreepayments.api.models.CardNonce#getLastTwo()

The following examples show how to use com.braintreepayments.api.models.CardNonce#getLastTwo() . 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: CardActivity.java    From braintree_android with MIT License 5 votes vote down vote up
public static String getDisplayString(CardNonce nonce) {
    return "Card Last Two: " + nonce.getLastTwo() + "\n" +
            getDisplayString(nonce.getBinData()) + "\n" +
            "3DS: \n" +
            "         - isLiabilityShifted: " + nonce.getThreeDSecureInfo().isLiabilityShifted() + "\n" +
            "         - isLiabilityShiftPossible: " + nonce.getThreeDSecureInfo().isLiabilityShiftPossible() + "\n" +
            "         - wasVerified: " + nonce.getThreeDSecureInfo().wasVerified();
}
 
Example 2
Source File: MainActivity.java    From braintree-android-drop-in with MIT License 4 votes vote down vote up
private void displayResult(PaymentMethodNonce paymentMethodNonce, String deviceData) {
    mNonce = paymentMethodNonce;
    mPaymentMethodType = PaymentMethodType.forType(mNonce);

    mPaymentMethodIcon.setImageResource(PaymentMethodType.forType(mNonce).getDrawable());
    mPaymentMethodTitle.setText(paymentMethodNonce.getTypeLabel());
    mPaymentMethodDescription.setText(paymentMethodNonce.getDescription());
    mPaymentMethod.setVisibility(VISIBLE);

    mNonceString.setText(getString(R.string.nonce) + ": " + mNonce.getNonce());
    mNonceString.setVisibility(VISIBLE);

    String details = "";
    if (mNonce instanceof CardNonce) {
        CardNonce cardNonce = (CardNonce) mNonce;

        details = "Card Last Two: " + cardNonce.getLastTwo() + "\n";
        details += "3DS isLiabilityShifted: " + cardNonce.getThreeDSecureInfo().isLiabilityShifted() + "\n";
        details += "3DS isLiabilityShiftPossible: " + cardNonce.getThreeDSecureInfo().isLiabilityShiftPossible();
    } else if (mNonce instanceof PayPalAccountNonce) {
        PayPalAccountNonce paypalAccountNonce = (PayPalAccountNonce) mNonce;

        details = "First name: " + paypalAccountNonce.getFirstName() + "\n";
        details += "Last name: " + paypalAccountNonce.getLastName() + "\n";
        details += "Email: " + paypalAccountNonce.getEmail() + "\n";
        details += "Phone: " + paypalAccountNonce.getPhone() + "\n";
        details += "Payer id: " + paypalAccountNonce.getPayerId() + "\n";
        details += "Client metadata id: " + paypalAccountNonce.getClientMetadataId() + "\n";
        details += "Billing address: " + formatAddress(paypalAccountNonce.getBillingAddress()) + "\n";
        details += "Shipping address: " + formatAddress(paypalAccountNonce.getShippingAddress());
    } else if (mNonce instanceof VenmoAccountNonce) {
        VenmoAccountNonce venmoAccountNonce = (VenmoAccountNonce) mNonce;

        details = "Username: " + venmoAccountNonce.getUsername();
    } else if (mNonce instanceof GooglePaymentCardNonce) {
        GooglePaymentCardNonce googlePaymentCardNonce = (GooglePaymentCardNonce) mNonce;

        details = "Underlying Card Last Two: " + googlePaymentCardNonce.getLastTwo() + "\n";
        details += "Email: " + googlePaymentCardNonce.getEmail() + "\n";
        details += "Billing address: " + formatAddress(googlePaymentCardNonce.getBillingAddress()) + "\n";
        details += "Shipping address: " + formatAddress(googlePaymentCardNonce.getShippingAddress());
    }

    mNonceDetails.setText(details);
    mNonceDetails.setVisibility(VISIBLE);

    mDeviceData.setText("Device Data: " + deviceData);
    mDeviceData.setVisibility(VISIBLE);

    mAddPaymentMethodButton.setVisibility(GONE);
    mPurchaseButton.setEnabled(true);
}