use of uk.gov.pay.api.model.links.PaymentWithAllLinks in project pay-publicapi by alphagov.
the class PaymentsResource method getPayment.
@GET
@Timed
@Path("/v1/payments/{paymentId}")
@Produces(APPLICATION_JSON)
@Operation(security = { @SecurityRequirement(name = "BearerAuth") }, operationId = "Get a payment", summary = "Find payment by ID", description = "Return information about the payment " + "The Authorisation token needs to be specified in the 'authorization' header " + "as 'authorization: Bearer YOUR_API_KEY_HERE'", responses = { @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = GetPaymentResult.class))), @ApiResponse(responseCode = "401", description = "Credentials are required to access this resource"), @ApiResponse(responseCode = "404", description = "Not found", content = @Content(schema = @Schema(implementation = PaymentError.class))), @ApiResponse(responseCode = "429", description = "Too many requests", content = @Content(schema = @Schema(implementation = ApiErrorResponse.class))), @ApiResponse(responseCode = "500", description = "Downstream system error", content = @Content(schema = @Schema(implementation = PaymentError.class))) })
public Response getPayment(@Parameter(hidden = true) @Auth Account account, @PathParam("paymentId") @Parameter(name = "paymentId", description = "Payment identifier", example = "hu20sqlact5260q2nanm0q8u93") String paymentId, @Parameter(hidden = true) @HeaderParam("X-Ledger") String strategyName) {
logger.info("Payment request - paymentId={}", paymentId);
var strategy = new GetOnePaymentStrategy(strategyName, account, paymentId, getPaymentService);
PaymentWithAllLinks payment = strategy.validateAndExecute();
logger.info("Payment returned - [ {} ]", payment);
return Response.ok(payment).build();
}
use of uk.gov.pay.api.model.links.PaymentWithAllLinks in project pay-publicapi by alphagov.
the class PaymentsResource method createNewPayment.
@POST
@Timed
@Path("/v1/payments")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Operation(security = { @SecurityRequirement(name = "BearerAuth") }, operationId = "Create a payment", summary = "Create new payment", description = "Create a new payment for the account associated to the Authorisation token. " + "The Authorisation token needs to be specified in the 'authorization' header " + "as 'authorization: Bearer YOUR_API_KEY_HERE'", responses = { @ApiResponse(responseCode = "201", description = "Created", content = @Content(schema = @Schema(implementation = CreatePaymentResult.class))), @ApiResponse(responseCode = "400", description = "Bad request", content = @Content(schema = @Schema(implementation = PaymentError.class))), @ApiResponse(responseCode = "401", description = "Credentials are required to access this resource"), @ApiResponse(responseCode = "422", description = "Invalid attribute value: description. Must be less than or equal to 255 characters length", content = @Content(schema = @Schema(implementation = PaymentError.class))), @ApiResponse(responseCode = "429", description = "Too many requests", content = @Content(schema = @Schema(implementation = ApiErrorResponse.class))), @ApiResponse(responseCode = "500", description = "Downstream system error", content = @Content(schema = @Schema(implementation = PaymentError.class))) })
public Response createNewPayment(@Parameter(hidden = true) @Auth Account account, @Parameter(required = true, description = "requestPayload") @Valid CreateCardPaymentRequest createCardPaymentRequest) {
logger.info("Payment create request parsed to {}", createCardPaymentRequest);
PaymentWithAllLinks createdPayment = createPaymentService.create(account, createCardPaymentRequest);
Response response = Response.created(publicApiUriGenerator.getPaymentURI(createdPayment.getPayment().getPaymentId())).entity(createdPayment).build();
logger.info("Payment returned (created): [ {} ]", createdPayment);
return response;
}
use of uk.gov.pay.api.model.links.PaymentWithAllLinks in project pay-publicapi by alphagov.
the class GetPaymentServiceLedgerTest method testGetPaymentWithSettledDate.
@Test
@PactVerification({ "ledger" })
@Pacts(pacts = { "publicapi-ledger-get-payment-with-settled-date" })
public void testGetPaymentWithSettledDate() {
Account account = new Account(ACCOUNT_ID, TokenPaymentType.CARD, tokenLink);
PaymentWithAllLinks paymentResponse = getPaymentService.getPayment(account, "ch_123abc456settlement");
CardPayment payment = (CardPayment) paymentResponse.getPayment();
assertThat(payment.getSettlementSummary().isPresent(), is(true));
assertThat(payment.getSettlementSummary().get().getSettledDate(), is("2020-09-19"));
}
use of uk.gov.pay.api.model.links.PaymentWithAllLinks in project pay-publicapi by alphagov.
the class GetPaymentServiceLedgerTest method providerIdIsAvailableWhenPaymentIsSubmitted_Ledger.
@Test
@PactVerification({ "ledger" })
@Pacts(pacts = { "publicapi-ledger-get-payment-with-gateway-transaction-id" })
public void providerIdIsAvailableWhenPaymentIsSubmitted_Ledger() {
Account account = new Account(ACCOUNT_ID, TokenPaymentType.CARD, tokenLink);
PaymentWithAllLinks paymentResponse = getPaymentService.getPayment(account, CHARGE_ID_NON_EXISTENT_IN_CONNECTOR);
CardPayment payment = (CardPayment) paymentResponse.getPayment();
assertThat(payment.getProviderId(), is("gateway-tx-123456"));
}
use of uk.gov.pay.api.model.links.PaymentWithAllLinks in project pay-publicapi by alphagov.
the class GetPaymentServiceLedgerTest method testGetPaymentWithFeeAndNetAmountFromLedger.
@Test
@PactVerification({ "ledger" })
@Pacts(pacts = { "publicapi-ledger-get-payment-with-fee-and-net-amount" })
public void testGetPaymentWithFeeAndNetAmountFromLedger() {
Account account = new Account(ACCOUNT_ID, TokenPaymentType.CARD, tokenLink);
PaymentWithAllLinks paymentResponse = getPaymentService.getPayment(account, CHARGE_ID_NON_EXISTENT_IN_CONNECTOR);
CardPayment payment = (CardPayment) paymentResponse.getPayment();
assertThat(payment.getPaymentId(), is(CHARGE_ID_NON_EXISTENT_IN_CONNECTOR));
assertThat(payment.getPaymentProvider(), is("sandbox"));
assertThat(payment.getAmount(), is(100L));
assertThat(payment.getFee().get(), is(5L));
assertThat(payment.getNetAmount().get(), is(95L));
}
Aggregations