use of uk.gov.pay.connector.gateway.model.request.RefundGatewayRequest in project pay-connector by alphagov.
the class StripeTransferInRequestTest method setUp.
@Before
public void setUp() {
gatewayAccount = aGatewayAccountEntity().withGatewayName("stripe").build();
gatewayAccountCredentialsEntity = aGatewayAccountCredentialsEntity().withCredentials(Map.of("stripe_account_id", stripeConnectAccountId)).withGatewayAccountEntity(gatewayAccount).withPaymentProvider(STRIPE.getName()).withState(ACTIVE).build();
gatewayAccount.setGatewayAccountCredentials(List.of(gatewayAccountCredentialsEntity));
when(charge.getExternalId()).thenReturn(chargeExternalId);
when(refundEntity.getAmount()).thenReturn(refundAmount);
when(refundEntity.getExternalId()).thenReturn(refundExternalId);
when(stripeGatewayConfig.getUrl()).thenReturn(stripeBaseUrl);
when(stripeGatewayConfig.getAuthTokens()).thenReturn(stripeAuthTokens);
when(stripeGatewayConfig.getPlatformAccountId()).thenReturn(stripePlatformAccountId);
final RefundGatewayRequest refundGatewayRequest = RefundGatewayRequest.valueOf(charge, refundEntity, gatewayAccount, gatewayAccountCredentialsEntity);
refundTransferInRequest = StripeTransferInRequest.of(refundGatewayRequest, stripeChargeId, stripeGatewayConfig);
feeTransferInRequest = StripeTransferInRequest.of(feeAmount, gatewayAccount, gatewayAccountCredentialsEntity, stripeChargeId, chargeExternalId, stripeGatewayConfig);
}
use of uk.gov.pay.connector.gateway.model.request.RefundGatewayRequest in project pay-connector by alphagov.
the class StripeRequestTest method setUp.
@BeforeEach
void setUp() {
gatewayAccount = aGatewayAccountEntity().withGatewayName(STRIPE.getName()).build();
var gatewayAccountCredentialsEntity = aGatewayAccountCredentialsEntity().withCredentials(Map.of("stripe_account_id", "stripe_connect_account_id")).withGatewayAccountEntity(gatewayAccount).withPaymentProvider(STRIPE.getName()).withState(ACTIVE).build();
gatewayAccount.setGatewayAccountCredentials(List.of(gatewayAccountCredentialsEntity));
when(charge.getGatewayTransactionId()).thenReturn("gatewayTransactionId");
when(stripeGatewayConfig.getAuthTokens()).thenReturn(stripeAuthTokens);
final RefundGatewayRequest refundGatewayRequest = RefundGatewayRequest.valueOf(charge, refundEntity, gatewayAccount, gatewayAccountCredentialsEntity);
stripeRefundRequest = StripeRefundRequest.of(refundGatewayRequest, "charge_id", stripeGatewayConfig);
}
use of uk.gov.pay.connector.gateway.model.request.RefundGatewayRequest in project pay-connector by alphagov.
the class StripeRefundRequestTest method setUp.
@Before
public void setUp() {
gatewayAccount = aGatewayAccountEntity().withGatewayName("stripe").build();
var gatewayAccountCredentialsEntity = aGatewayAccountCredentialsEntity().withCredentials(Map.of("stripe_account_id", "stripe_account_id")).withGatewayAccountEntity(gatewayAccount).withPaymentProvider(STRIPE.getName()).withState(ACTIVE).build();
gatewayAccount.setGatewayAccountCredentials(List.of(gatewayAccountCredentialsEntity));
when(refundEntity.getAmount()).thenReturn(refundAmount);
when(refundEntity.getExternalId()).thenReturn(refundExternalId);
when(stripeGatewayConfig.getUrl()).thenReturn(stripeBaseUrl);
when(stripeGatewayConfig.getAuthTokens()).thenReturn(stripeAuthTokens);
final RefundGatewayRequest refundGatewayRequest = RefundGatewayRequest.valueOf(charge, refundEntity, gatewayAccount, gatewayAccountCredentialsEntity);
stripeRefundRequest = StripeRefundRequest.of(refundGatewayRequest, stripeChargeId, stripeGatewayConfig);
}
use of uk.gov.pay.connector.gateway.model.request.RefundGatewayRequest in project pay-connector by alphagov.
the class EpdqPaymentProviderTest method shouldRefundSuccessfully.
@Test
public void shouldRefundSuccessfully() 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));
RefundGatewayRequest refundGatewayRequest = buildRefundRequest(chargeEntity, (chargeEntity.getAmount() - 100));
GatewayRefundResponse refundResponse = paymentProvider.refund(refundGatewayRequest);
assertThat(refundResponse.isSuccessful(), is(true));
}
use of uk.gov.pay.connector.gateway.model.request.RefundGatewayRequest in project pay-connector by alphagov.
the class SmartpayPaymentProviderTest method shouldRefundToAnExistingPaymentSuccessfully.
@Test
public void shouldRefundToAnExistingPaymentSuccessfully() throws Exception {
CardAuthorisationGatewayRequest request = getCardAuthorisationRequest(chargeEntity);
PaymentProvider smartpay = getSmartpayPaymentProvider();
GatewayResponse<BaseAuthoriseResponse> authoriseResponse = smartpay.authorise(request);
assertTrue(authoriseResponse.isSuccessful());
SmartpayAuthorisationResponse smartpayAuthorisationResponse = (SmartpayAuthorisationResponse) authoriseResponse.getBaseResponse().get();
chargeEntity.setGatewayTransactionId(smartpayAuthorisationResponse.getPspReference());
CaptureResponse captureGatewayResponse = smartpay.capture(CaptureGatewayRequest.valueOf(chargeEntity));
assertTrue(captureGatewayResponse.isSuccessful());
RefundEntity refundEntity = new RefundEntity(1L, userExternalId, userEmail, chargeEntity.getExternalId());
RefundGatewayRequest refundRequest = RefundGatewayRequest.valueOf(Charge.from(chargeEntity), refundEntity, gatewayAccountEntity, gatewayAccountCredentialsEntity);
GatewayRefundResponse refundResponse = smartpay.refund(refundRequest);
assertThat(refundResponse.isSuccessful(), is(true));
}
Aggregations