use of uk.gov.pay.connector.gateway.GatewayClient in project pay-connector by alphagov.
the class SmartpayPaymentProviderTest method getSmartpayPaymentProvider.
private PaymentProvider getSmartpayPaymentProvider() {
Client client = TestClientFactory.createJerseyClient();
GatewayClient gatewayClient = new GatewayClient(client, mockMetricRegistry);
GatewayClientFactory gatewayClientFactory = mock(GatewayClientFactory.class);
when(gatewayClientFactory.createGatewayClient(any(PaymentGatewayName.class), any(MetricRegistry.class))).thenReturn(gatewayClient);
GatewayConfig gatewayConfig = mock(GatewayConfig.class);
when(gatewayConfig.getUrls()).thenReturn(Map.of(TEST.toString(), url));
ConnectorConfiguration configuration = mock(ConnectorConfiguration.class);
when(configuration.getGatewayConfigFor(SMARTPAY)).thenReturn(gatewayConfig);
return new SmartpayPaymentProvider(configuration, gatewayClientFactory, mockEnvironment);
}
use of uk.gov.pay.connector.gateway.GatewayClient in project pay-connector by alphagov.
the class GatewayClientTest method setup.
@BeforeEach
public void setup() {
gatewayClient = new GatewayClient(mockClient, mockMetricRegistry);
when(mockClient.target(WORLDPAY_API_ENDPOINT)).thenReturn(mockWebTarget);
}
use of uk.gov.pay.connector.gateway.GatewayClient in project pay-connector by alphagov.
the class WorldpayPaymentProviderTest method getValidWorldpayPaymentProvider.
private WorldpayPaymentProvider getValidWorldpayPaymentProvider() {
GatewayClient gatewayClient = new GatewayClient(ClientBuilder.newClient(), mockMetricRegistry);
GatewayClientFactory gatewayClientFactory = mock(GatewayClientFactory.class);
when(gatewayClientFactory.createGatewayClient(any(PaymentGatewayName.class), any(GatewayOperation.class), any(MetricRegistry.class))).thenReturn(gatewayClient);
return new WorldpayPaymentProvider(gatewayUrlMap(), gatewayClient, gatewayClient, gatewayClient, new WorldpayWalletAuthorisationHandler(gatewayClient, gatewayUrlMap()), new WorldpayAuthoriseHandler(gatewayClient, gatewayUrlMap()), new WorldpayCaptureHandler(gatewayClient, gatewayUrlMap()), new WorldpayRefundHandler(gatewayClient, gatewayUrlMap()), new AuthorisationService(mockCardExecutorService, mockEnvironment), new AuthorisationLogger(new AuthorisationRequestSummaryStringifier(), new AuthorisationRequestSummaryStructuredLogging()), mock(ChargeDao.class), mock(EventService.class));
}
use of uk.gov.pay.connector.gateway.GatewayClient in project pay-connector by alphagov.
the class EpdqPaymentProviderTest method setUp.
@Before
public void setUp() {
when(mockConnectorConfiguration.getLinks()).thenReturn(mockLinksConfig);
when(mockConnectorConfiguration.getGatewayConfigFor(EPDQ)).thenReturn(mockGatewayConfig);
when(mockLinksConfig.getFrontendUrl()).thenReturn("http://frontendUrl");
when(mockGatewayConfig.getUrls()).thenReturn(Map.of(TEST.toString(), url));
when(mockMetricRegistry.histogram(anyString())).thenReturn(mockHistogram);
when(mockEnvironment.metrics()).thenReturn(mockMetricRegistry);
Client client = TestClientFactory.createJerseyClient();
GatewayClient gatewayClient = new GatewayClient(client, mockMetricRegistry);
when(mockGatewayClientFactory.createGatewayClient(any(PaymentGatewayName.class), any(GatewayOperation.class), any())).thenReturn(gatewayClient);
paymentProvider = new EpdqPaymentProvider(mockConnectorConfiguration, mockGatewayClientFactory, mockEnvironment, Clock.fixed(Instant.parse("2020-01-01T10:10:10.100Z"), ZoneOffset.UTC));
}
use of uk.gov.pay.connector.gateway.GatewayClient in project pay-connector by alphagov.
the class GooglePayForWorldpayTest method sendPaymentToWorldpay.
@Test
public void sendPaymentToWorldpay() throws Exception {
GatewayAccountEntity gatewayAccount = new GatewayAccountEntity();
gatewayAccount.setType(GatewayAccountType.TEST);
gatewayAccount.setGatewayAccountCredentials(List.of(aGatewayAccountCredentialsEntity().withCredentials(Map.of(CREDENTIALS_USERNAME, worldpayUsername, CREDENTIALS_PASSWORD, worldpayPassword)).withGatewayAccountEntity(gatewayAccount).withPaymentProvider(WORLDPAY.getName()).build()));
String payload = load("templates/worldpay/WorldpayAuthoriseGooglePayOrderTemplate.xml").replace("${amount}", "100").replace("${merchantCode}", merchantCode).replace("${transactionId?xml}", Integer.toString(RandomUtils.nextInt())).replace("${walletAuthorisationData.encryptedPaymentData.signature?xml}", signature).replace("${walletAuthorisationData.encryptedPaymentData.protocolVersion?xml}", protocolVersion).replace("${walletAuthorisationData.encryptedPaymentData.signedMessage?xml}", signedMessage);
GatewayClient authoriseClient = getGatewayClient();
GatewayOrder gatewayOrder = new GatewayOrder(OrderRequestType.AUTHORISE, payload, APPLICATION_XML_TYPE);
GatewayClient.Response response = authoriseClient.postRequestFor(URI.create("https://secure-test.worldpay.com/jsp/merchant/xml/paymentService.jsp"), WORLDPAY, "test", gatewayOrder, getGatewayAccountCredentialsAsAuthHeader(gatewayAccount.getCredentials(WORLDPAY.getName())));
assertThat(response.getStatus(), is(HttpStatus.SC_OK));
String entity = response.getEntity();
System.out.println(entity);
WorldpayOrderStatusResponse worldpayOrderStatusResponse = XMLUnmarshaller.unmarshall(entity, WorldpayOrderStatusResponse.class);
assertTrue(worldpayOrderStatusResponse.getLastEvent().isPresent());
assertThat(worldpayOrderStatusResponse.getLastEvent(), is("AUTHORISED"));
}
Aggregations