{
  "openapi": "3.0.4",
  "info": {
    "title": "External Payment API v1",
    "description": "The External Payment API provides one endpoint for handling operations\r\n                                    sent from Future Ordering. After processing an operation, events are delivered\r\n                                    by the Partner to the Notifications endpoint.",
    "contact": {
      "name": "Future Ordering Sweden AB",
      "url": "https://futureordering.com"
    },
    "version": "v1"
  },
  "paths": {
    "/external/operations": {
      "post": {
        "tags": [
          "External Payment API"
        ],
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/PaymentTransactionAnnulmentOperation"
                  },
                  {
                    "$ref": "#/components/schemas/PaymentTransactionAuthorizationOperation"
                  },
                  {
                    "$ref": "#/components/schemas/PaymentTransactionCaptureOperation"
                  },
                  {
                    "$ref": "#/components/schemas/PaymentTransactionRegistrationOperation"
                  }
                ]
              },
              "example": {
                "type": "payment.external.transaction.registration",
                "merchantId": "eb621215-9ee9-4715-941c-fd6cd2235d63",
                "currency": "EUR",
                "amount": 1000,
                "revenueCenterId": "example-revenue-center-id",
                "orderId": "example-order-id",
                "customerReference": "example-customer-reference",
                "transactionId": "6c1245b4-cdae-4110-8598-9b13a91258d5",
                "deviceId": "example-device-id"
              }
            },
            "text/json": {
              "schema": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/PaymentTransactionAnnulmentOperation"
                  },
                  {
                    "$ref": "#/components/schemas/PaymentTransactionAuthorizationOperation"
                  },
                  {
                    "$ref": "#/components/schemas/PaymentTransactionCaptureOperation"
                  },
                  {
                    "$ref": "#/components/schemas/PaymentTransactionRegistrationOperation"
                  }
                ]
              },
              "example": {
                "type": "payment.external.transaction.registration",
                "merchantId": "eb621215-9ee9-4715-941c-fd6cd2235d63",
                "currency": "EUR",
                "amount": 1000,
                "revenueCenterId": "example-revenue-center-id",
                "orderId": "example-order-id",
                "customerReference": "example-customer-reference",
                "transactionId": "6c1245b4-cdae-4110-8598-9b13a91258d5",
                "deviceId": "example-device-id"
              }
            },
            "application/*+json": {
              "schema": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/PaymentTransactionAnnulmentOperation"
                  },
                  {
                    "$ref": "#/components/schemas/PaymentTransactionAuthorizationOperation"
                  },
                  {
                    "$ref": "#/components/schemas/PaymentTransactionCaptureOperation"
                  },
                  {
                    "$ref": "#/components/schemas/PaymentTransactionRegistrationOperation"
                  }
                ]
              },
              "example": {
                "type": "payment.external.transaction.registration",
                "merchantId": "eb621215-9ee9-4715-941c-fd6cd2235d63",
                "currency": "EUR",
                "amount": 1000,
                "revenueCenterId": "example-revenue-center-id",
                "orderId": "example-order-id",
                "customerReference": "example-customer-reference",
                "transactionId": "6c1245b4-cdae-4110-8598-9b13a91258d5",
                "deviceId": "example-device-id"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentErrorResponse"
                },
                "examples": {
                  "Missing required field": {
                    "summary": "The request omits a field that must be present.",
                    "value": {
                      "type": "https://developer.futureordering.com/docs/external-payment-provider/error-responses/validation-error",
                      "title": "Request validation failed.",
                      "status": 400,
                      "detail": "One or more fields failed validation.",
                      "instance": "/v1/payments/3fa85f64-5717-4562-b3fc-2c963f66afa6",
                      "errors": [
                        {
                          "code": "validation.error",
                          "detail": "The Example field is required.",
                          "target": "example"
                        }
                      ]
                    }
                  },
                  "Missing field required for resolving type": {
                    "summary": "The request omits the type discriminator field.",
                    "value": {
                      "type": "https://developer.futureordering.com/docs/external-payment-provider/error-responses/validation-error",
                      "title": "Request validation failed.",
                      "status": 400,
                      "detail": "One or more fields failed validation.",
                      "instance": "/v1/payments/3fa85f64-5717-4562-b3fc-2c963f66afa6",
                      "errors": [
                        {
                          "code": "validation.error",
                          "detail": "Missing required property 'type', type cannot be resolved",
                          "target": "type"
                        }
                      ]
                    }
                  },
                  "Invalid field value": {
                    "summary": "The request contains a field value that violates the validation rules.",
                    "value": {
                      "type": "https://developer.futureordering.com/docs/external-payment-provider/error-responses/validation-error",
                      "title": "Request validation failed.",
                      "status": 400,
                      "detail": "One or more fields failed validation.",
                      "instance": "/v1/payments/3fa85f64-5717-4562-b3fc-2c963f66afa6",
                      "errors": [
                        {
                          "code": "validation.error",
                          "detail": "The field Amount must be between 1 and 9.223372036854776E+18.",
                          "target": "data.amount"
                        }
                      ]
                    }
                  },
                  "Invalid string length": {
                    "summary": "The request contains a string field that does not meet the length requirements.",
                    "value": {
                      "type": "https://developer.futureordering.com/docs/external-payment-provider/error-responses/validation-error",
                      "title": "Request validation failed.",
                      "status": 400,
                      "detail": "One or more fields failed validation.",
                      "instance": "/v1/payments/3fa85f64-5717-4562-b3fc-2c963f66afa6",
                      "errors": [
                        {
                          "code": "validation.error",
                          "detail": "The field Currency must be a string with a minimum length of 3 and a maximum length of 3.",
                          "target": "data.currency"
                        }
                      ]
                    }
                  }
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentErrorResponse"
                },
                "examples": {
                  "Missing required field": {
                    "summary": "The request omits a field that must be present.",
                    "value": {
                      "type": "https://developer.futureordering.com/docs/external-payment-provider/error-responses/validation-error",
                      "title": "Request validation failed.",
                      "status": 400,
                      "detail": "One or more fields failed validation.",
                      "instance": "/v1/payments/3fa85f64-5717-4562-b3fc-2c963f66afa6",
                      "errors": [
                        {
                          "code": "validation.error",
                          "detail": "The Example field is required.",
                          "target": "example"
                        }
                      ]
                    }
                  },
                  "Missing field required for resolving type": {
                    "summary": "The request omits the type discriminator field.",
                    "value": {
                      "type": "https://developer.futureordering.com/docs/external-payment-provider/error-responses/validation-error",
                      "title": "Request validation failed.",
                      "status": 400,
                      "detail": "One or more fields failed validation.",
                      "instance": "/v1/payments/3fa85f64-5717-4562-b3fc-2c963f66afa6",
                      "errors": [
                        {
                          "code": "validation.error",
                          "detail": "Missing required property 'type', type cannot be resolved",
                          "target": "type"
                        }
                      ]
                    }
                  },
                  "Invalid field value": {
                    "summary": "The request contains a field value that violates the validation rules.",
                    "value": {
                      "type": "https://developer.futureordering.com/docs/external-payment-provider/error-responses/validation-error",
                      "title": "Request validation failed.",
                      "status": 400,
                      "detail": "One or more fields failed validation.",
                      "instance": "/v1/payments/3fa85f64-5717-4562-b3fc-2c963f66afa6",
                      "errors": [
                        {
                          "code": "validation.error",
                          "detail": "The field Amount must be between 1 and 9.223372036854776E+18.",
                          "target": "data.amount"
                        }
                      ]
                    }
                  },
                  "Invalid string length": {
                    "summary": "The request contains a string field that does not meet the length requirements.",
                    "value": {
                      "type": "https://developer.futureordering.com/docs/external-payment-provider/error-responses/validation-error",
                      "title": "Request validation failed.",
                      "status": 400,
                      "detail": "One or more fields failed validation.",
                      "instance": "/v1/payments/3fa85f64-5717-4562-b3fc-2c963f66afa6",
                      "errors": [
                        {
                          "code": "validation.error",
                          "detail": "The field Currency must be a string with a minimum length of 3 and a maximum length of 3.",
                          "target": "data.currency"
                        }
                      ]
                    }
                  }
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentErrorResponse"
                },
                "examples": {
                  "Missing required field": {
                    "summary": "The request omits a field that must be present.",
                    "value": {
                      "type": "https://developer.futureordering.com/docs/external-payment-provider/error-responses/validation-error",
                      "title": "Request validation failed.",
                      "status": 400,
                      "detail": "One or more fields failed validation.",
                      "instance": "/v1/payments/3fa85f64-5717-4562-b3fc-2c963f66afa6",
                      "errors": [
                        {
                          "code": "validation.error",
                          "detail": "The Example field is required.",
                          "target": "example"
                        }
                      ]
                    }
                  },
                  "Missing field required for resolving type": {
                    "summary": "The request omits the type discriminator field.",
                    "value": {
                      "type": "https://developer.futureordering.com/docs/external-payment-provider/error-responses/validation-error",
                      "title": "Request validation failed.",
                      "status": 400,
                      "detail": "One or more fields failed validation.",
                      "instance": "/v1/payments/3fa85f64-5717-4562-b3fc-2c963f66afa6",
                      "errors": [
                        {
                          "code": "validation.error",
                          "detail": "Missing required property 'type', type cannot be resolved",
                          "target": "type"
                        }
                      ]
                    }
                  },
                  "Invalid field value": {
                    "summary": "The request contains a field value that violates the validation rules.",
                    "value": {
                      "type": "https://developer.futureordering.com/docs/external-payment-provider/error-responses/validation-error",
                      "title": "Request validation failed.",
                      "status": 400,
                      "detail": "One or more fields failed validation.",
                      "instance": "/v1/payments/3fa85f64-5717-4562-b3fc-2c963f66afa6",
                      "errors": [
                        {
                          "code": "validation.error",
                          "detail": "The field Amount must be between 1 and 9.223372036854776E+18.",
                          "target": "data.amount"
                        }
                      ]
                    }
                  },
                  "Invalid string length": {
                    "summary": "The request contains a string field that does not meet the length requirements.",
                    "value": {
                      "type": "https://developer.futureordering.com/docs/external-payment-provider/error-responses/validation-error",
                      "title": "Request validation failed.",
                      "status": 400,
                      "detail": "One or more fields failed validation.",
                      "instance": "/v1/payments/3fa85f64-5717-4562-b3fc-2c963f66afa6",
                      "errors": [
                        {
                          "code": "validation.error",
                          "detail": "The field Currency must be a string with a minimum length of 3 and a maximum length of 3.",
                          "target": "data.currency"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden"
          },
          "408": {
            "description": "Request Timeout"
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentErrorResponse"
                },
                "example": {
                  "type": "https://developer.futureordering.com/docs/external-payment-provider/error-responses/rate-limit-exceeded",
                  "title": "Rate limit exceeded.",
                  "status": 429,
                  "detail": "Too many requests were sent in a given amount of time. Retry later.",
                  "instance": "/v1/payments/3fa85f64-5717-4562-b3fc-2c963f66afa6",
                  "errors": []
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentErrorResponse"
                },
                "example": {
                  "type": "https://developer.futureordering.com/docs/external-payment-provider/error-responses/rate-limit-exceeded",
                  "title": "Rate limit exceeded.",
                  "status": 429,
                  "detail": "Too many requests were sent in a given amount of time. Retry later.",
                  "instance": "/v1/payments/3fa85f64-5717-4562-b3fc-2c963f66afa6",
                  "errors": []
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentErrorResponse"
                },
                "example": {
                  "type": "https://developer.futureordering.com/docs/external-payment-provider/error-responses/rate-limit-exceeded",
                  "title": "Rate limit exceeded.",
                  "status": 429,
                  "detail": "Too many requests were sent in a given amount of time. Retry later.",
                  "instance": "/v1/payments/3fa85f64-5717-4562-b3fc-2c963f66afa6",
                  "errors": []
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentErrorResponse"
                },
                "example": {
                  "type": "https://developer.futureordering.com/docs/external-payment-provider/error-responses/internal-server-error",
                  "title": "An unexpected error occurred.",
                  "status": 500,
                  "detail": "The server encountered an unexpected condition and could not complete the request.",
                  "instance": "/v1/payments/3fa85f64-5717-4562-b3fc-2c963f66afa6",
                  "errors": []
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentErrorResponse"
                },
                "example": {
                  "type": "https://developer.futureordering.com/docs/external-payment-provider/error-responses/internal-server-error",
                  "title": "An unexpected error occurred.",
                  "status": 500,
                  "detail": "The server encountered an unexpected condition and could not complete the request.",
                  "instance": "/v1/payments/3fa85f64-5717-4562-b3fc-2c963f66afa6",
                  "errors": []
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentErrorResponse"
                },
                "example": {
                  "type": "https://developer.futureordering.com/docs/external-payment-provider/error-responses/internal-server-error",
                  "title": "An unexpected error occurred.",
                  "status": 500,
                  "detail": "The server encountered an unexpected condition and could not complete the request.",
                  "instance": "/v1/payments/3fa85f64-5717-4562-b3fc-2c963f66afa6",
                  "errors": []
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": []
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "PaymentTransactionAnnulmentOperation": {
        "required": [
          "transactionId",
          "type"
        ],
        "properties": {
          "type": {
            "enum": [
              "payment.external.transaction.annulment"
            ],
            "type": "string"
          },
          "transactionId": {
            "minLength": 1,
            "type": "string"
          },
          "deviceId": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "PaymentTransactionAuthorizationOperation": {
        "required": [
          "transactionId",
          "type"
        ],
        "properties": {
          "type": {
            "enum": [
              "payment.external.transaction.authorization"
            ],
            "type": "string"
          },
          "transactionId": {
            "minLength": 1,
            "type": "string"
          },
          "deviceId": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "PaymentTransactionCaptureOperation": {
        "required": [
          "transactionId",
          "type",
          "amount",
          "currency"
        ],
        "properties": {
          "type": {
            "enum": [
              "payment.external.transaction.capture"
            ],
            "type": "string"
          },
          "transactionId": {
            "minLength": 1,
            "type": "string"
          },
          "deviceId": {
            "type": "string",
            "nullable": true
          },
          "currency": {
            "maxLength": 3,
            "minLength": 3,
            "type": "string"
          },
          "amount": {
            "maximum": 9223372036854776000,
            "minimum": 1,
            "type": "integer",
            "format": "int64"
          }
        }
      },
      "PaymentTransactionRegistrationOperation": {
        "required": [
          "transactionId",
          "type",
          "amount",
          "currency",
          "merchantId"
        ],
        "properties": {
          "type": {
            "enum": [
              "payment.external.transaction.registration"
            ],
            "type": "string"
          },
          "transactionId": {
            "minLength": 1,
            "type": "string"
          },
          "deviceId": {
            "type": "string",
            "nullable": true
          },
          "merchantId": {
            "minLength": 1,
            "type": "string"
          },
          "currency": {
            "maxLength": 3,
            "minLength": 3,
            "type": "string"
          },
          "amount": {
            "maximum": 9223372036854776000,
            "minimum": 1,
            "type": "integer",
            "format": "int64"
          },
          "revenueCenterId": {
            "type": "string",
            "nullable": true
          },
          "orderId": {
            "type": "string",
            "nullable": true
          },
          "customerReference": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "PaymentErrorResponse": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "detail": {
            "type": "string",
            "nullable": true
          },
          "instance": {
            "type": "string",
            "nullable": true
          },
          "errors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PaymentErrorDetail"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PaymentErrorDetail": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "nullable": true
          },
          "detail": {
            "type": "string",
            "nullable": true
          },
          "target": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      }
    }
  }
}