Search in sources :

Example 1 with AuthenticationException

use of com.stripe.exception.AuthenticationException in project alf.io by alfio-event.

the class StripeManagerTest method stripeError.

@Test
void stripeError() {
    BaseStripeManager baseStripeManager = new BaseStripeManager(configurationManager, configurationRepository, ticketRepository, mock(Environment.class)) {

        @Override
        protected Optional<Charge> charge(PaymentSpecification spec, Map<String, Object> chargeParams) throws StripeException {
            throw new AuthenticationException("401", "42", "401", 401);
        }
    };
    StripeCreditCardManager stripeCreditCardManager = new StripeCreditCardManager(transactionRepository, baseStripeManager, TestUtil.clockProvider());
    PaymentSpecification spec = new PaymentSpecification("", new StripeCreditCardToken(""), 100, event, "", customerName);
    PaymentResult result = stripeCreditCardManager.doPayment(spec);
    assertEquals(result, PaymentResult.failed("error.STEP2_STRIPE_abort"));
}
Also used : AuthenticationException(com.stripe.exception.AuthenticationException) PaymentResult(alfio.manager.support.PaymentResult) StripeCreditCardToken(alfio.model.transaction.token.StripeCreditCardToken) Charge(com.stripe.model.Charge) Environment(org.springframework.core.env.Environment) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Aggregations

PaymentResult (alfio.manager.support.PaymentResult)1 StripeCreditCardToken (alfio.model.transaction.token.StripeCreditCardToken)1 AuthenticationException (com.stripe.exception.AuthenticationException)1 Charge (com.stripe.model.Charge)1 Map (java.util.Map)1 Test (org.junit.jupiter.api.Test)1 Environment (org.springframework.core.env.Environment)1