@Test
    public void testPreAuthorization() {

        Gateway beanstream = new Gateway("v1", 300200578,
                "4BaD82D9197b4cc4b70a221911eE9f70");

        CardPaymentRequest paymentRequest = new CardPaymentRequest();
        paymentRequest.setAmount(90.00);
        paymentRequest.setOrderNumber(getRandomOrderId("GAS"));
        paymentRequest.getCard()
                .setName("John Doe")
                .setNumber("5100000010001004")
                .setExpiryMonth("12")
                .setExpiryYear("18")
                .setCvd("123");

        try {
            PaymentResponse response = beanstream.payments().preAuth(paymentRequest);
            PaymentResponse authResp = beanstream.payments().preAuthCompletion(response.id, 43.50);
            if (!authResp.isApproved()) {
                Assert.fail("This auth completion should be approved because a greater amount has been pre authorized");
            }
        } catch (BeanstreamApiException ex) {
            System.out.println(BeanstreamResponse.fromException(ex));
            Assert.fail(ex.getMessage());
        }
        
        // Pre-auth and complete again but supply PaymentRequest details in the complete
        CardPaymentRequest paymentRequest2 = new CardPaymentRequest();
        paymentRequest2.setAmount(30.00);
        paymentRequest2.setOrderNumber(getRandomOrderId("Pumpkins"));
        paymentRequest2.getCard()
                .setName("John Doe")
                .setNumber("5100000010001004")
                .setExpiryMonth("12")
                .setExpiryYear("18")
                .setCvd("123");

        try {
            PaymentResponse response = beanstream.payments().preAuth(paymentRequest2);
            paymentRequest2.setAmount(4.00);
            PaymentResponse authResp = beanstream.payments().preAuthCompletion(response.id, paymentRequest2);
            if (!authResp.isApproved()) {
                Assert.fail("This auth completion should be approved because a greater amount has been pre authorized");
            }
            
        } catch (BeanstreamApiException ex) {
            System.out.println(BeanstreamResponse.fromException(ex));
            Assert.fail(ex.getMessage());
        }
    }