Search in sources :

Example 6 with UnionPayListener

use of com.braintreepayments.api.interfaces.UnionPayListener in project braintree_android by braintree.

the class UnionPayTest method tokenize_unionPayCredit_withExpirationMonthAndYear.

@Test(timeout = 30000)
public void tokenize_unionPayCredit_withExpirationMonthAndYear() throws InvalidArgumentException, InterruptedException {
    final UnionPayCardBuilder cardBuilder = new UnionPayCardBuilder().cardNumber(CardNumber.UNIONPAY_CREDIT).expirationMonth("08").expirationYear("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 7 with UnionPayListener

use of com.braintreepayments.api.interfaces.UnionPayListener in project braintree_android by braintree.

the class UnionPayTest method fetchCapabilities_whenDebit_isDebitIsTrue.

@Test(timeout = 10000)
public void fetchCapabilities_whenDebit_isDebitIsTrue() throws InterruptedException {
    mBraintreeFragment.addListener(new UnionPayListener() {

        @Override
        public void onCapabilitiesFetched(UnionPayCapabilities unionPayCapabilities) {
            assertTrue(unionPayCapabilities.supportsTwoStepAuthAndCapture());
            assertTrue(unionPayCapabilities.isDebit());
            assertTrue(unionPayCapabilities.isUnionPay());
            mCountDownLatch.countDown();
        }

        @Override
        public void onSmsCodeSent(String enrollmentId, boolean smsCodeRequired) {
            fail("Not expecting onSmsCodeSent");
        }
    });
    UnionPay.fetchCapabilities(mBraintreeFragment, UNIONPAY_DEBIT);
    mCountDownLatch.await();
}
Also used : UnionPayListener(com.braintreepayments.api.interfaces.UnionPayListener) UnionPayCapabilities(com.braintreepayments.api.models.UnionPayCapabilities) Test(org.junit.Test)

Example 8 with UnionPayListener

use of com.braintreepayments.api.interfaces.UnionPayListener in project braintree_android by braintree.

the class UnionPayTest method fetchCapabilities_whenSingleStepSale_twoStepAuthAndCaptureIsFalse.

@Test(timeout = 10000)
public void fetchCapabilities_whenSingleStepSale_twoStepAuthAndCaptureIsFalse() throws InterruptedException {
    mBraintreeFragment.addListener(new UnionPayListener() {

        @Override
        public void onCapabilitiesFetched(UnionPayCapabilities unionPayCapabilities) {
            assertTrue(unionPayCapabilities.isSupported());
            assertFalse(unionPayCapabilities.supportsTwoStepAuthAndCapture());
            assertTrue(unionPayCapabilities.isDebit());
            assertTrue(unionPayCapabilities.isUnionPay());
            mCountDownLatch.countDown();
        }

        @Override
        public void onSmsCodeSent(String enrollmentId, boolean smsCodeRequired) {
            fail("Not expecting onSmsCodeSent");
        }
    });
    UnionPay.fetchCapabilities(mBraintreeFragment, UNIONPAY_SINGLE_STEP_SALE);
    mCountDownLatch.await();
}
Also used : UnionPayListener(com.braintreepayments.api.interfaces.UnionPayListener) UnionPayCapabilities(com.braintreepayments.api.models.UnionPayCapabilities) Test(org.junit.Test)

Example 9 with UnionPayListener

use of com.braintreepayments.api.interfaces.UnionPayListener 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 10 with UnionPayListener

use of com.braintreepayments.api.interfaces.UnionPayListener in project braintree_android by braintree.

the class UnionPayTest method fetchCapabilities_whenCredit_isDebitIsFalse.

@Test(timeout = 10000)
public void fetchCapabilities_whenCredit_isDebitIsFalse() throws InterruptedException {
    mBraintreeFragment.addListener(new UnionPayListener() {

        @Override
        public void onCapabilitiesFetched(UnionPayCapabilities unionPayCapabilities) {
            assertTrue(unionPayCapabilities.supportsTwoStepAuthAndCapture());
            assertFalse(unionPayCapabilities.isDebit());
            assertTrue(unionPayCapabilities.isUnionPay());
            mCountDownLatch.countDown();
        }

        @Override
        public void onSmsCodeSent(String enrollmentId, boolean smsCodeRequired) {
            fail("Not expecting onSmsCodeSent");
        }
    });
    UnionPay.fetchCapabilities(mBraintreeFragment, UNIONPAY_CREDIT);
    mCountDownLatch.await();
}
Also used : UnionPayListener(com.braintreepayments.api.interfaces.UnionPayListener) UnionPayCapabilities(com.braintreepayments.api.models.UnionPayCapabilities) Test(org.junit.Test)

Aggregations

UnionPayListener (com.braintreepayments.api.interfaces.UnionPayListener)10 UnionPayCapabilities (com.braintreepayments.api.models.UnionPayCapabilities)10 Test (org.junit.Test)9 UnionPayCardBuilder (com.braintreepayments.api.models.UnionPayCardBuilder)5 InvalidArgumentException (com.braintreepayments.api.exceptions.InvalidArgumentException)3 BraintreeErrorListener (com.braintreepayments.api.interfaces.BraintreeErrorListener)3 PaymentMethodNonceCreatedListener (com.braintreepayments.api.interfaces.PaymentMethodNonceCreatedListener)3 PaymentMethodNonce (com.braintreepayments.api.models.PaymentMethodNonce)3 CardNonce (com.braintreepayments.api.models.CardNonce)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 ErrorWithResponse (com.braintreepayments.api.exceptions.ErrorWithResponse)1 AmericanExpressListener (com.braintreepayments.api.interfaces.AmericanExpressListener)1 BraintreeCancelListener (com.braintreepayments.api.interfaces.BraintreeCancelListener)1 BraintreePaymentResultListener (com.braintreepayments.api.interfaces.BraintreePaymentResultListener)1 ConfigurationListener (com.braintreepayments.api.interfaces.ConfigurationListener)1 PaymentMethodNoncesUpdatedListener (com.braintreepayments.api.interfaces.PaymentMethodNoncesUpdatedListener)1 AmericanExpressRewardsBalance (com.braintreepayments.api.models.AmericanExpressRewardsBalance)1 BraintreePaymentResult (com.braintreepayments.api.models.BraintreePaymentResult)1 Configuration (com.braintreepayments.api.models.Configuration)1 ArrayList (java.util.ArrayList)1