use of uk.gov.pay.connector.gateway.CaptureResponse in project pay-connector by alphagov.
the class CardCaptureService method doCapture.
public CaptureResponse doCapture(String externalId) {
ChargeEntity charge;
try {
charge = prepareChargeForCapture(externalId);
} catch (OptimisticLockException e) {
LOG.info("OptimisticLockException in doCapture for charge external_id={}", externalId);
throw new ConflictRuntimeException(externalId);
}
CaptureResponse operationResponse = capture(charge);
processGatewayCaptureResponse(externalId, charge.getStatus(), operationResponse);
return operationResponse;
}
use of uk.gov.pay.connector.gateway.CaptureResponse in project pay-connector by alphagov.
the class EpdqPaymentProviderTest method shouldCaptureSuccessfully.
@Test
public void shouldCaptureSuccessfully() throws Exception {
setUpAndCheckThatEpdqIsUp();
var request = new CardAuthorisationGatewayRequest(chargeEntity, authCardDetailsFixture().build());
GatewayResponse<BaseAuthoriseResponse> response = paymentProvider.authorise(request);
assertThat(response.isSuccessful(), is(true));
String transactionId = response.getBaseResponse().get().getTransactionId();
assertThat(transactionId, is(not(nullValue())));
CaptureGatewayRequest captureRequest = buildCaptureRequest(chargeEntity, transactionId);
CaptureResponse captureResponse = paymentProvider.capture(captureRequest);
assertThat(captureResponse.isSuccessful(), is(true));
assertThat(captureResponse.state(), Is.is(CaptureResponse.ChargeState.PENDING));
}
use of uk.gov.pay.connector.gateway.CaptureResponse in project pay-connector by alphagov.
the class SmartpayPaymentProviderTest method shouldSuccessfullySendACaptureRequest.
@Test
public void shouldSuccessfullySendACaptureRequest() throws Exception {
PaymentProvider paymentProvider = getSmartpayPaymentProvider();
CardAuthorisationGatewayRequest request = getCardAuthorisationRequest(chargeEntity);
GatewayResponse<BaseAuthoriseResponse> response = paymentProvider.authorise(request);
assertTrue(response.isSuccessful());
assertThat(response.getBaseResponse().isPresent(), is(true));
SmartpayAuthorisationResponse smartpayAuthorisationResponse = (SmartpayAuthorisationResponse) response.getBaseResponse().get();
String transactionId = smartpayAuthorisationResponse.getPspReference();
assertThat(transactionId, is(not(nullValue())));
chargeEntity.setGatewayTransactionId(transactionId);
CaptureResponse captureGatewayResponse = paymentProvider.capture(CaptureGatewayRequest.valueOf(chargeEntity));
assertTrue(captureGatewayResponse.isSuccessful());
assertThat(captureGatewayResponse.state(), is(CaptureResponse.ChargeState.PENDING));
}
use of uk.gov.pay.connector.gateway.CaptureResponse in project pay-connector by alphagov.
the class WorldpayPaymentProviderTest method shouldBeAbleToSendCaptureRequestForMerchant.
/**
* Worldpay does not care about a successful authorization reference to make a capture request.
* It simply accepts anything as long as the request is well formed. (And ignores it silently)
*/
@Test
public void shouldBeAbleToSendCaptureRequestForMerchant() {
WorldpayPaymentProvider paymentProvider = getValidWorldpayPaymentProvider();
CaptureResponse response = paymentProvider.capture(CaptureGatewayRequest.valueOf(chargeEntity));
assertTrue(response.isSuccessful());
}
use of uk.gov.pay.connector.gateway.CaptureResponse in project pay-connector by alphagov.
the class WorldpayPaymentProviderTest method shouldBeAbleToSubmitAPartialRefundAfterACaptureHasBeenSubmitted.
@Test
public void shouldBeAbleToSubmitAPartialRefundAfterACaptureHasBeenSubmitted() {
WorldpayPaymentProvider paymentProvider = getValidWorldpayPaymentProvider();
AuthCardDetails authCardDetails = anAuthCardDetails().build();
CardAuthorisationGatewayRequest request = getCardAuthorisationRequest(authCardDetails);
GatewayResponse<WorldpayOrderStatusResponse> response = paymentProvider.authorise(request);
String transactionId = response.getBaseResponse().get().getTransactionId();
assertThat(response.getBaseResponse().isPresent(), is(true));
assertThat(response.getBaseResponse().isPresent(), is(true));
assertThat(transactionId, is(not(nullValue())));
chargeEntity.setGatewayTransactionId(transactionId);
CaptureResponse captureResponse = paymentProvider.capture(CaptureGatewayRequest.valueOf(chargeEntity));
assertThat(captureResponse.isSuccessful(), is(true));
RefundEntity refundEntity = new RefundEntity(1L, userExternalId, userEmail, chargeEntity.getExternalId());
GatewayRefundResponse refundResponse = paymentProvider.refund(RefundGatewayRequest.valueOf(Charge.from(chargeEntity), refundEntity, validGatewayAccount, validGatewayAccountCredentialsEntity));
assertTrue(refundResponse.isSuccessful());
}
Aggregations