系列: Go
go
307 行
· 更新于 2026-04-18
docs.go
Go/payment-gateway-challenge/docs/docs.go
// Package docs Code generated by swaggo/swag. DO NOT EDIT
package docs
import "github.com/swaggo/swag"
const docTemplate = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{escape .Description}}",
"title": "{{.Title}}",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"name": "Checkout.com Recruitment",
"url": "https://www.checkout.com/careers",
"email": "careers@checkout.com"
},
"license": {
"name": "MIT",
"url": "https://opensource.org/licenses/MIT"
},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/api/payments": {
"post": {
"description": "Validates the request, calls the acquiring-bank simulator, persists **Authorized** or **Declined** outcomes, and returns a payment id. **Rejected** (validation) returns 400 without calling the bank. PAN ending in ` + "`" + `0` + "`" + ` yields bank 503 → gateway 503 (no row stored).",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"payments"
],
"summary": "Process a card payment",
"parameters": [
{
"description": "Card and amount payload",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/payment-gateway-challenge_internal_validation.ProcessPaymentRequest"
}
}
],
"responses": {
"201": {
"description": "Payment created (Authorized or Declined)",
"schema": {
"$ref": "#/definitions/internal_handlers.ProcessPaymentResponse"
}
},
"400": {
"description": "Rejected — invalid input",
"schema": {
"$ref": "#/definitions/internal_handlers.PaymentRejectedResponse"
}
},
"500": {
"description": "Persistence failure",
"schema": {
"$ref": "#/definitions/internal_handlers.ErrorJSON"
}
},
"502": {
"description": "Bad gateway — bank unreachable or unexpected response",
"schema": {
"$ref": "#/definitions/internal_handlers.ErrorJSON"
}
},
"503": {
"description": "Bank unavailable (e.g. test PAN ending in 0)",
"schema": {
"$ref": "#/definitions/internal_handlers.ErrorJSON"
}
}
}
}
},
"/api/payments/{id}": {
"get": {
"description": "Returns masked PAN, last four digits, expiry, currency, amount, and status (**Authorized** or **Declined**).",
"produces": [
"application/json"
],
"tags": [
"payments"
],
"summary": "Get payment by id",
"parameters": [
{
"type": "string",
"description": "Payment UUID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/internal_handlers.PaymentDetailResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/internal_handlers.ErrorJSON"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/internal_handlers.ErrorJSON"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/internal_handlers.ErrorJSON"
}
}
}
}
},
"/ping": {
"get": {
"description": "Returns plain text ` + "`" + `pong` + "`" + ` for load balancers and smoke tests.",
"produces": [
"text/plain"
],
"tags": [
"system"
],
"summary": "Liveness probe",
"responses": {
"200": {
"description": "pong",
"schema": {
"type": "string"
}
}
}
}
}
},
"definitions": {
"internal_handlers.ErrorJSON": {
"type": "object",
"properties": {
"detail": {
"type": "string",
"example": "upstream body"
},
"message": {
"type": "string",
"example": "failed to reach acquiring bank"
},
"status": {
"type": "integer",
"example": 502
}
}
},
"internal_handlers.PaymentDetailResponse": {
"type": "object",
"properties": {
"amount": {
"type": "integer",
"example": 100
},
"currency": {
"type": "string",
"example": "GBP"
},
"expiry_month": {
"type": "integer",
"example": 4
},
"expiry_year": {
"type": "integer",
"example": 2028
},
"id": {
"type": "string"
},
"last_four_card_digits": {
"type": "string",
"example": "8877"
},
"masked_card_number": {
"type": "string",
"example": "************8877"
},
"status": {
"type": "string",
"example": "Authorized"
}
}
},
"internal_handlers.PaymentRejectedResponse": {
"type": "object",
"properties": {
"errors": {
"type": "array",
"items": {
"type": "string"
}
},
"message": {
"type": "string",
"example": "invalid payment information"
},
"status": {
"type": "string",
"example": "Rejected"
}
}
},
"internal_handlers.ProcessPaymentResponse": {
"type": "object",
"properties": {
"amount": {
"type": "integer",
"example": 100
},
"currency": {
"type": "string",
"example": "GBP"
},
"expiry_month": {
"type": "integer",
"example": 4
},
"expiry_year": {
"type": "integer",
"example": 2028
},
"id": {
"type": "string",
"example": "550e8400-e29b-41d4-a716-446655440000"
},
"last_four_card_digits": {
"type": "string",
"example": "8877"
},
"status": {
"type": "string",
"example": "Authorized"
}
}
},
"payment-gateway-challenge_internal_validation.ProcessPaymentRequest": {
"type": "object",
"properties": {
"amount": {
"type": "integer",
"example": 100
},
"card_number": {
"type": "string",
"example": "2222405343248877"
},
"currency": {
"type": "string",
"example": "GBP"
},
"cvv": {
"type": "string",
"example": "123"
},
"expiry_month": {
"type": "integer",
"example": 4
},
"expiry_year": {
"type": "integer",
"example": 2028
}
}
}
}
}`
// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
Version: "1.0",
Host: "localhost:8090",
BasePath: "/",
Schemes: []string{},
Title: "Payment Gateway Challenge (Go)",
Description: "Checkout.com offline coding interview — Payment Gateway API (Echo + PostgreSQL). Use **Swagger UI** at `/swagger/index.html`. Behaviour and assumptions: see `DESIGN.md`.",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
RightDelim: "}}",
}
func init() {
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
}
相关文章
Go
go
更新于 2026-04-18
main.go
main.go — go source code from the Go learning materials (Go/Baasid/cmd/hashpw/main.go).
阅读文章 →
Go
go
更新于 2026-04-18
main.go
main.go — go source code from the Go learning materials (Go/Baasid/cmd/server/main.go).
阅读文章 →
Go
go
更新于 2026-04-18
docs.go
docs.go — go source code from the Go learning materials (Go/Baasid/docs/docs.go).
阅读文章 →
Go
go
更新于 2026-04-18
jwt.go
jwt.go — go source code from the Go learning materials (Go/Baasid/internal/auth/jwt.go).
阅读文章 →
Go
go
更新于 2026-04-18
password.go
password.go — go source code from the Go learning materials (Go/Baasid/internal/auth/password.go).
阅读文章 →
Go
go
更新于 2026-04-18
password_test.go
password_test.go — go source code from the Go learning materials (Go/Baasid/internal/auth/password_test.go).
阅读文章 →