diff --git a/api.planx.uk/docs/index.ts b/api.planx.uk/docs/index.ts index f12939a0b6..734fb58606 100644 --- a/api.planx.uk/docs/index.ts +++ b/api.planx.uk/docs/index.ts @@ -36,7 +36,7 @@ const parameters = { type: "string", required: true, description: - "Name of the Local Authority, usually the same as Planx `team`", + "Name of the Local Authority, usually the same as PlanX `team`", }, hasuraAuth: { name: "authorization", diff --git a/api.planx.uk/modules/pay/docs.yaml b/api.planx.uk/modules/pay/docs.yaml index e69de29bb2..f4cddbfe95 100644 --- a/api.planx.uk/modules/pay/docs.yaml +++ b/api.planx.uk/modules/pay/docs.yaml @@ -0,0 +1,452 @@ +openapi: 3.1.0 +info: + title: Planâś• API + version: 0.1.0 +tags: + - name: pay + description: Endpoints for interacting with the GovPay API + externalDocs: + url: https://docs.payments.service.gov.uk/ +components: + parameters: + paymentId: + in: path + name: paymentId + type: string + format: uuid + required: true +paths: + /pay/{localAuthority}: + post: + summary: Initiate a new payment + description: | + Initiate a GovPay payment via proxy. This will return a GovPay URL which we can forward the user to in order for them to make a payment. + + Docs: [https://docs.payments.service.gov.uk/api_reference/create_a_payment_reference/](https://docs.payments.service.gov.uk/api_reference/create_a_payment_reference/) + tags: + - pay + consumes: + - application/json + produces: + - application/json + parameters: + - $ref: "#/components/parameters/localAuthority" + - in: body + name: paymentRequest + description: | + Payment details required by GovPay API + + Docs: [https://docs.payments.service.gov.uk/api_reference/create_a_payment_reference/#example-request-for-39-create-a-payment-39](https://docs.payments.service.gov.uk/api_reference/create_a_payment_reference/#example-request-for-39-create-a-payment-39) + required: true + schema: + type: object + properties: + amount: + type: integer + format: int32 + example: 14500 + reference: + type: string + example: "12345" + description: + type: string + example: "Pay your council tax" + return_url: + type: string + format: uri + example: "https://your.service.gov.uk/completed" + delayed_capture: + type: boolean + example: false + metadata: + type: object + properties: + ledger_code: + type: string + example: "AB100" + internal_reference_number: + type: integer + example: 200 + email: + type: string + format: email + example: "sherlock.holmes@example.com" + prefilled_cardholder_details: + type: object + properties: + cardholder_name: + type: string + example: "Sherlock Holmes" + billing_address: + type: object + properties: + line1: + type: string + example: "221 Baker Street" + line2: + type: string + example: "Flat b" + postcode: + type: string + example: "NW1 6XE" + city: + type: string + example: "London" + country: + type: string + example: "GB" + language: + type: string + example: "en" + responses: + "200": + content: + application/json: + description: | + Successful payment response + + Docs: [https://docs.payments.service.gov.uk/api_reference/create_a_payment_reference/#example-response-for-39-create-a-payment-39](https://docs.payments.service.gov.uk/api_reference/create_a_payment_reference/#example-response-for-39-create-a-payment-39) + schema: + type: object + properties: + amount: + type: integer + format: int32 + example: 14500 + description: + type: string + example: "Pay your council tax." + reference: + type: string + example: "12345" + language: + type: string + example: "en" + state: + type: object + properties: + status: + type: string + example: "created" + finished: + type: boolean + example: false + payment_id: + type: string + example: "hu20sqlact5260q2nanm0q8u93" + payment_provider: + type: string + example: "stripe" + created_date: + type: string + format: date-time + example: "2022-03-25T13:11:29.019Z" + refund_summary: + type: object + properties: + status: + type: string + example: "pending" + amount_available: + type: integer + format: int32 + example: 14500 + amount_submitted: + type: integer + format: int32 + example: 0 + settlement_summary: + type: object + properties: {} + delayed_capture: + type: boolean + example: false + moto: + type: boolean + example: false + return_url: + type: string + format: uri + example: "https://your.service.gov.uk/completed" + _links: + type: object + properties: + self: + type: object + properties: + href: + type: string + format: uri + example: "https://publicapi.payments.service.gov.uk/v1/payments/hu20sqlact5260q2nanm0q8u93" + method: + type: string + example: "GET" + next_url: + type: object + properties: + href: + type: string + format: uri + example: "https://www.payments.service.gov.uk/secure/ef1b6ff1-db34-4c62-b854-3ed4ba3c4049" + method: + type: string + example: "GET" + next_url_post: + type: object + properties: + type: + type: string + example: "application/x-www-form-urlencoded" + params: + type: object + properties: + chargeTokenId: + type: string + example: "ef1b6ff1-db34-4c62-b854-3ed4ba3c4049" + href: + type: string + format: uri + example: "https://www.payments.service.gov.uk/secure" + method: + type: string + example: "POST" + events: + type: object + properties: + href: + type: string + format: uri + example: "https://publicapi.payments.service.gov.uk/v1/payments/hu20sqlact5260q2nanm0q8u93/events" + method: + type: string + example: "GET" + refunds: + type: object + properties: + href: + type: string + format: uri + example: "https://publicapi.payments.service.gov.uk/v1/payments/hu20sqlact5260q2nanm0q8u93/refunds" + method: + type: string + example: "GET" + cancel: + type: object + properties: + href: + type: string + format: uri + example: "https://publicapi.payments.service.gov.uk/v1/payments/hu20sqlact5260q2nanm0q8u93/cancel" + method: + type: string + example: "POST" + /pay/{localAuthority}/{paymentId}: + get: + summary: Get payment status + description: | + Get the status of a payment via a proxied request to the GovPay API + + Docs: [https://docs.payments.service.gov.uk/api_reference/single_payment_reference/#get-information-about-a-single-payment-api-reference](https://docs.payments.service.gov.uk/api_reference/single_payment_reference/#get-information-about-a-single-payment-api-reference) + tags: + - pay + parameters: + - $ref: "#/components/parameters/localAuthority" + - $ref: "#/components/parameters/paymentId" + responses: + "200": + content: + application/json: + description: | + Payment response for the GovPay API + + Docs: [https://docs.payments.service.gov.uk/api_reference/single_payment_reference/#example-response-for-get-information-about-a-single-payment](https://docs.payments.service.gov.uk/api_reference/single_payment_reference/#example-response-for-get-information-about-a-single-payment) + schema: + type: object + properties: + created_date: + type: string + format: date-time + example: "2019-07-11T10:36:26.988Z" + amount: + type: integer + format: int32 + example: 3750 + state: + type: object + properties: + status: + type: string + example: "success" + finished: + type: boolean + example: true + description: + type: string + example: "Pay your council tax" + reference: + type: string + example: "12345" + language: + type: string + example: "en" + metadata: + type: object + properties: + ledger_code: + type: string + example: "AB100" + internal_reference_number: + type: integer + example: 200 + email: + type: string + format: email + example: "sherlock.holmes@example.com" + card_details: + type: object + properties: + card_brand: + type: string + example: "Visa" + card_type: + type: string + example: "debit" + last_digits_card_number: + type: string + example: "1234" + first_digits_card_number: + type: string + example: "123456" + expiry_date: + type: string + example: "04/24" + cardholder_name: + type: string + example: "Sherlock Holmes" + billing_address: + type: object + properties: + line1: + type: string + example: "221 Baker Street" + line2: + type: string + example: "Flat b" + postcode: + type: string + example: "NW1 6XE" + city: + type: string + example: "London" + country: + type: string + example: "GB" + payment_id: + type: string + example: "hu20sqlact5260q2nanm0q8u93" + authorisation_mode: + type: string + example: "web" + authorisation_summary: + type: object + properties: + three_d_secure: + type: object + properties: + required: + type: boolean + example: true + refund_summary: + type: object + properties: + status: + type: string + example: "available" + amount_available: + type: integer + format: int32 + example: 3500 + amount_submitted: + type: integer + format: int32 + example: 500 + settlement_summary: + type: object + properties: + capture_submit_time: + type: string + format: date-time + example: "2019-07-12T17:15:000Z" + captured_date: + type: string + format: date + example: "2019-07-12" + settled_date: + type: string + format: date + example: "2019-07-12" + delayed_capture: + type: boolean + example: false + moto: + type: boolean + example: false + corporate_card_surcharge: + type: integer + format: int32 + example: 250 + total_amount: + type: integer + format: int32 + example: 4000 + fee: + type: integer + format: int32 + example: 200 + net_amount: + type: integer + format: int32 + example: 3800 + payment_provider: + type: string + example: "worldpay" + provider_id: + type: string + example: "10987654321" + return_url: + type: string + format: uri + example: "https://your.service.gov.uk/completed" + _links: + type: object + properties: + self: + type: object + properties: + href: + type: string + format: uri + example: "https://publicapi.payments.service.gov.uk/v1/payments/hu20sqlact5260q2nanm0q8u93" + method: + type: string + example: "GET" + events: + type: object + properties: + href: + type: string + format: uri + example: "https://publicapi.payments.service.gov.uk/v1/payments/hu20sqlact5260q2nanm0q8u93/events" + method: + type: string + example: "GET" + refunds: + type: object + properties: + href: + type: string + format: uri + example: "https://publicapi.payments.service.gov.uk/v1/payments/hu20sqlact5260q2nanm0q8u93/refunds" + method: + type: string + example: "GET" diff --git a/api.planx.uk/modules/pay/routes.ts b/api.planx.uk/modules/pay/routes.ts index 45c461828b..74148351d4 100644 --- a/api.planx.uk/modules/pay/routes.ts +++ b/api.planx.uk/modules/pay/routes.ts @@ -6,7 +6,6 @@ import { validate } from "../../shared/middleware/validate"; const router = Router(); -// used by startNewPayment() in @planx/components/Pay/Public/Pay.tsx router.post( "/pay/:localAuthority", isTeamUsingGovPay, @@ -14,7 +13,6 @@ router.post( makePaymentViaProxy, ); -// used by refetchPayment() in @planx/components/Pay/Public/Pay.tsx router.get( "/pay/:localAuthority/:paymentId", isTeamUsingGovPay,