Search in sources :

Example 16 with UnionPayCardBuilder

use of com.braintreepayments.api.models.UnionPayCardBuilder in project braintree_android by braintree.

the class UnionPayTest method tokenize_unionPayCredit_withExpirationDate.

@Test(timeout = 10000)
public void tokenize_unionPayCredit_withExpirationDate() throws InvalidArgumentException, InterruptedException {
    final UnionPayCardBuilder cardBuilder = new UnionPayCardBuilder().cardNumber(CardNumber.UNIONPAY_CREDIT).expirationDate("08/20").cvv("123").mobileCountryCode("62").mobilePhoneNumber("1111111111");
    mBraintreeFragment.addListener(new UnionPayListener() {

        @Override
        public void onCapabilitiesFetched(UnionPayCapabilities capabilities) {
        }

        @Override
        public void onSmsCodeSent(String enrollmentId, boolean smsCodeRequired) {
            assertTrue(smsCodeRequired);
            cardBuilder.enrollmentId(enrollmentId);
            cardBuilder.smsCode("12345");
            UnionPay.tokenize(mBraintreeFragment, cardBuilder);
        }
    });
    mBraintreeFragment.addListener(new PaymentMethodNonceCreatedListener() {

        @Override
        public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
            assertIsANonce(paymentMethodNonce.getNonce());
            assertEquals("32", ((CardNonce) paymentMethodNonce).getLastTwo());
            mCountDownLatch.countDown();
        }
    });
    UnionPay.enroll(mBraintreeFragment, cardBuilder);
    mCountDownLatch.await();
}
Also used : UnionPayListener(com.braintreepayments.api.interfaces.UnionPayListener) UnionPayCardBuilder(com.braintreepayments.api.models.UnionPayCardBuilder) UnionPayCapabilities(com.braintreepayments.api.models.UnionPayCapabilities) CardNonce(com.braintreepayments.api.models.CardNonce) PaymentMethodNonceCreatedListener(com.braintreepayments.api.interfaces.PaymentMethodNonceCreatedListener) PaymentMethodNonce(com.braintreepayments.api.models.PaymentMethodNonce) Test(org.junit.Test)

Example 17 with UnionPayCardBuilder

use of com.braintreepayments.api.models.UnionPayCardBuilder in project braintree_android by braintree.

the class CardActivity method onPurchase.

public void onPurchase(View v) {
    setProgressBarIndeterminateVisibility(true);
    if (mIsUnionPay) {
        UnionPayCardBuilder unionPayCardBuilder = new UnionPayCardBuilder().cardNumber(mCardForm.getCardNumber()).expirationMonth(mCardForm.getExpirationMonth()).expirationYear(mCardForm.getExpirationYear()).cvv(mCardForm.getCvv()).postalCode(mCardForm.getPostalCode()).mobileCountryCode(mCardForm.getCountryCode()).mobilePhoneNumber(mCardForm.getMobileNumber()).smsCode(mSmsCode.getText().toString()).enrollmentId(mEnrollmentId);
        UnionPay.tokenize(mBraintreeFragment, unionPayCardBuilder);
    } else {
        CardBuilder cardBuilder = new CardBuilder().cardNumber(mCardForm.getCardNumber()).expirationMonth(mCardForm.getExpirationMonth()).expirationYear(mCardForm.getExpirationYear()).cvv(mCardForm.getCvv()).postalCode(mCardForm.getPostalCode());
        Card.tokenize(mBraintreeFragment, cardBuilder);
    }
}
Also used : UnionPayCardBuilder(com.braintreepayments.api.models.UnionPayCardBuilder) CardBuilder(com.braintreepayments.api.models.CardBuilder) UnionPayCardBuilder(com.braintreepayments.api.models.UnionPayCardBuilder)

Example 18 with UnionPayCardBuilder

use of com.braintreepayments.api.models.UnionPayCardBuilder in project braintree_android by braintree.

the class CardActivity method sendSms.

public void sendSms(View v) {
    UnionPayCardBuilder unionPayCardBuilder = new UnionPayCardBuilder().cardNumber(mCardForm.getCardNumber()).expirationMonth(mCardForm.getExpirationMonth()).expirationYear(mCardForm.getExpirationYear()).cvv(mCardForm.getCvv()).postalCode(mCardForm.getPostalCode()).mobileCountryCode(mCardForm.getCountryCode()).mobilePhoneNumber(mCardForm.getMobileNumber());
    UnionPay.enroll(mBraintreeFragment, unionPayCardBuilder);
}
Also used : UnionPayCardBuilder(com.braintreepayments.api.models.UnionPayCardBuilder)

Aggregations

UnionPayCardBuilder (com.braintreepayments.api.models.UnionPayCardBuilder)18 Test (org.junit.Test)15 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)9 JSONObject (org.json.JSONObject)7 UnionPayListener (com.braintreepayments.api.interfaces.UnionPayListener)5 UnionPayCapabilities (com.braintreepayments.api.models.UnionPayCapabilities)5 Matchers.anyString (org.mockito.Matchers.anyString)5 HttpResponseCallback (com.braintreepayments.api.interfaces.HttpResponseCallback)4 BraintreeHttpClient (com.braintreepayments.api.internal.BraintreeHttpClient)4 CardNonce (com.braintreepayments.api.models.CardNonce)3 InvalidArgumentException (com.braintreepayments.api.exceptions.InvalidArgumentException)2 BraintreeErrorListener (com.braintreepayments.api.interfaces.BraintreeErrorListener)2 PaymentMethodNonceCreatedListener (com.braintreepayments.api.interfaces.PaymentMethodNonceCreatedListener)2 PaymentMethodNonce (com.braintreepayments.api.models.PaymentMethodNonce)2 BraintreeException (com.braintreepayments.api.exceptions.BraintreeException)1 ConfigurationException (com.braintreepayments.api.exceptions.ConfigurationException)1 ErrorWithResponse (com.braintreepayments.api.exceptions.ErrorWithResponse)1 PaymentMethodNonceCallback (com.braintreepayments.api.interfaces.PaymentMethodNonceCallback)1 CardBuilder (com.braintreepayments.api.models.CardBuilder)1 PayPalAccountBuilder (com.braintreepayments.api.models.PayPalAccountBuilder)1