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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations