{
  "openapi": "3.0.0",
  "info": {
    "title": "B4bit Pay API",
    "description": "<img alt=\"Logo\" style=\"width:200px\" src=\"https://dev-payments.b4bit.com/media/crytocurrencies/image_2.png\" /> \n\n <p><span style=\"font-size:11pt\"><span style=\"font-family:Arial\"><span style=\"color:#000000\"><p>DOCUMENTACIÓN <a href=\"https://b4bit.gitbook.io/pay-es\" target=\"_blank\">GitbookES</a>.</p></span></span></span></p>\n\nDocumentación completa: https://docs.b4bit.com/pay/api/",
    "version": "1.0.0"
  },
  "security": [
    {
      "DeviceIdAuth": []
    }
  ],
  "paths": {
    "/currencies": {
      "get": {
        "operationId": "currencies_list",
        "description": "● Description: Returns a list of all cryptocurrencies available for payments.\n\n● Header: The ‘X-Device-Id’ (Api Key) from the Merchant. You will find it on B4bit Pay Dashboard.\n\n● VERY IMPORTANT: There are currencies such as XRP, XLM and ALGO that use TAG/MEMO, in the case of using Api-Gateway,\n        it is very important to show this information to the client to make the payment. Otherwise, if the customer does not\n        enter the TAG/MEMO along with the address and amount, the customer's funds will be lost.",
        "responses": {
          "200": {
            "description": "Successful operation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Currency"
                }
              }
            }
          },
          "403": {
            "description": "The authentication credentials where not provided."
          },
          "500": {
            "description": "Some internal error happened. Try again or, if the problem persists, contact us."
          }
        },
        "tags": [
          "currencies"
        ]
      },
      "parameters": []
    },
    "/device/": {
      "post": {
        "operationId": "device_create",
        "description": "● Description: Create Device for Merchant.\n\n● Header: The ‘X-Device-Id’ (Api Key) from the Device. You will find it on B4bit Pay Dashboard.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDevice"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful operation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateDeviceResponse"
                }
              }
            }
          },
          "403": {
            "description": "The authentication credentials where not provided."
          },
          "500": {
            "description": "Some internal error happened. Try again or, if the problem persists, contact us."
          }
        },
        "tags": [
          "device"
        ]
      },
      "parameters": []
    },
    "/orders/": {
      "get": {
        "operationId": "orders_list",
        "description": "● Description: Returns a list of all Device payments in a specific time period.\n\n● Header: The ‘X-Device-Id’ (Api Key) from the Merchant. You will find it on B4bit Pay Dashboard.\n\n● Input data: There are optional arguments in the url, ‘start’ y ‘end’. With the format YYYY/MM/DD.\n        Example url: https://pos.b4bit.com/api/v1/orders/?start=2021/01/01&end=2022/01/04\n\n● Output data: If it doesn't receive arguments in the url, it will return the payments of the last 7 days.\n        The other option is to return the payments between the two dates given.",
        "responses": {
          "200": {
            "description": "Successful operation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payment"
                }
              }
            }
          },
          "403": {
            "description": "The authentication credentials where not provided."
          },
          "500": {
            "description": "Some internal error happened. Try again or, if the problem persists, contact us."
          }
        },
        "tags": [
          "orders"
        ]
      },
      "post": {
        "operationId": "orders_create",
        "description": "● Description: Create a payment for a Merchant. Depending on the merchant and the fiat amount, front_dni and\n        back_dni images will be required.\n\n● Header: The ‘X-Device-Id’ (Api Key) from the Device. You will find it on B4bit Pay Dashboard.\n\n● Output data: If it doesn't receive 'input_currency' all the nullable fields won't be returned.\n\n● VERY IMPORTANT: There are currencies such as XRP, XLM and ALGO that use TAG/MEMO, in the case of using Api-Gateway,\n        it is very important to show this information to the client to make the payment. Otherwise, if the customer does not\n        enter the TAG/MEMO along with the address and amount, the customer's funds will be lost.",
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "expected_output_amount": {
                    "description": "Payment amount in fiat (MXN).",
                    "type": "number"
                  },
                  "input_currency": {
                    "description": "The cryptocurrency that will be use to make the payment.",
                    "type": "string"
                  },
                  "merchant_urlko": {
                    "description": "The redirection url for not completed or expired payments.",
                    "type": "string",
                    "format": "uri"
                  },
                  "merchant_urlok": {
                    "description": "The redirection url for completed payments.",
                    "type": "string",
                    "format": "uri"
                  },
                  "merchant_url_standby": {
                    "description": "The redirection url to wait for payment confirmation.",
                    "type": "string",
                    "format": "uri",
                    "x-nullable": true
                  },
                  "notes": {
                    "description": "Product or service description of the payment.",
                    "type": "string",
                    "maxLength": 512
                  },
                  "reference": {
                    "description": "Payment reference.",
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "fiat": {
                    "description": "Fiat available.",
                    "type": "string",
                    "enum": [
                      "EUR",
                      "USD",
                      "GBP",
                      "ARS",
                      "AUD",
                      "BGN",
                      "BOB",
                      "BRL",
                      "CAD",
                      "CHF",
                      "CLP",
                      "COP",
                      "DKK",
                      "DOP",
                      "GEL",
                      "HUF",
                      "ISK",
                      "JPY",
                      "KRW",
                      "MXN",
                      "NOK",
                      "NZD",
                      "PEN",
                      "PLN",
                      "PYG",
                      "RON",
                      "SEK",
                      "SGD",
                      "SVC",
                      "UYU"
                    ],
                    "default": "MXN"
                  },
                  "language": {
                    "description": "Language.",
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 6,
                    "default": "ES"
                  },
                  "home_address": {
                    "description": "Home address",
                    "type": "string",
                    "maxLength": 256
                  },
                  "address_additional": {
                    "description": "Address additional info.",
                    "type": "string",
                    "maxLength": 64
                  },
                  "email_client": {
                    "description": "Email",
                    "type": "string",
                    "format": "email",
                    "maxLength": 128
                  },
                  "full_name": {
                    "description": "Full name",
                    "type": "string",
                    "maxLength": 48
                  },
                  "address_number": {
                    "description": "Address number",
                    "type": "string",
                    "maxLength": 56
                  },
                  "zip_code": {
                    "description": "Zipcode",
                    "type": "string",
                    "maxLength": 12
                  },
                  "city": {
                    "description": "City",
                    "type": "string",
                    "maxLength": 28
                  },
                  "province": {
                    "description": "Province",
                    "type": "string",
                    "maxLength": 28
                  },
                  "country": {
                    "description": "Example: \"ES\". ISO 3166 in Alpha-2 code.",
                    "type": "string",
                    "maxLength": 2
                  },
                  "phone_number": {
                    "description": "Mobile phone",
                    "type": "string",
                    "maxLength": 15
                  },
                  "nif": {
                    "description": "Personal ID",
                    "type": "string",
                    "maxLength": 12
                  },
                  "internal_data": {
                    "description": "Internal data stored by the merchant.",
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1024
                  }
                },
                "required": [
                  "expected_output_amount"
                ]
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful operation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResponseCreatePayment"
                }
              }
            }
          },
          "403": {
            "description": "The authentication credentials where not provided."
          },
          "404": {
            "description": "Invalid currency or minimum amount not reached. \n\nUrl redirections or symbol missed.\n\nDNI Image is missed."
          },
          "500": {
            "description": "Some internal error happened. Try again or, if the problem persists, contact us."
          }
        },
        "tags": [
          "orders"
        ]
      },
      "parameters": []
    },
    "/orders/info/{identifier}": {
      "get": {
        "operationId": "orders_info_read",
        "description": "● Description: Check the information of a specific payment.\n\n● Header: The ‘X-Device-Id’ (Api Key) from the Merchant. You will find it on B4bit Pay Dashboard.\n\n● Input data: It is required in the url, the \"indentifier\" of the payment you want to receive the information.\n\n● Output data: Returns all the information and transactions of a payment.",
        "responses": {
          "200": {
            "description": "Successful operation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payment"
                }
              }
            }
          },
          "403": {
            "description": "The authentication credentials where not provided."
          },
          "500": {
            "description": "Some internal error happened. Try again or, if the problem persists, contact us."
          }
        },
        "tags": [
          "orders"
        ]
      },
      "parameters": [
        {
          "name": "identifier",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ]
    }
  },
  "servers": [
    {
      "url": "https://pos.b4bit.com/api/v1",
      "description": "Producción"
    }
  ],
  "components": {
    "securitySchemes": {
      "DeviceIdAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Device-Id",
        "description": "API Key del dispositivo. Se obtiene desde el dashboard: Configuración → Comercio → Dispositivos. UUID v4."
      }
    },
    "schemas": {
      "Currency": {
        "type": "object",
        "properties": {
          "symbol": {
            "title": "Symbol",
            "description": "Cryptocurrency symbol.",
            "type": "string",
            "maxLength": 24,
            "minLength": 1
          },
          "name": {
            "title": "Name",
            "description": "Cryptocurrency name.",
            "type": "string",
            "maxLength": 32,
            "minLength": 1
          },
          "min_amount": {
            "title": "Min amount",
            "description": "Payment minimum amount.",
            "type": "string",
            "format": "decimal"
          },
          "max_amount": {
            "title": "Max amount",
            "description": "Payment maximum amount.",
            "type": "string",
            "format": "decimal"
          },
          "image": {
            "title": "Image",
            "type": "string",
            "readOnly": true
          },
          "blockchain": {
            "title": "Blockchain",
            "description": "Cryptocurrency blockchain.",
            "type": "string",
            "minLength": 1
          }
        }
      },
      "CreateDevice": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "title": "Name",
            "description": "Device name.",
            "type": "string",
            "maxLength": 128,
            "minLength": 1
          }
        }
      },
      "CreateDeviceResponse": {
        "type": "object",
        "properties": {
          "name": {
            "title": "Name",
            "description": "Device name.",
            "type": "string",
            "maxLength": 128,
            "minLength": 1
          },
          "identifier": {
            "title": "Identifier",
            "description": "Device Api-Key.",
            "type": "string",
            "minLength": 1
          }
        }
      },
      "Transaction": {
        "description": "List of payment's transactions.",
        "type": "object",
        "properties": {
          "confirmed": {
            "title": "Confirmed",
            "description": "Indicates if there is any block confirmation in the blockchain.",
            "type": "boolean"
          },
          "currency": {
            "title": "Currency",
            "type": "string"
          },
          "amount": {
            "title": "Amount",
            "description": "Cryptocurrency amount for the payment.",
            "type": "number"
          },
          "tx_hash": {
            "title": "Tx hash",
            "type": "string",
            "readOnly": true
          },
          "block": {
            "title": "Block",
            "description": "Transaction Block.",
            "type": "integer",
            "nullable": true
          },
          "created_at": {
            "title": "Created at",
            "description": "Payment creation date.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Payment": {
        "type": "object",
        "properties": {
          "identifier": {
            "title": "Identifier",
            "description": "The uuid4 identifier of the payment.",
            "type": "string",
            "format": "uuid"
          },
          "reference": {
            "title": "Reference",
            "description": "Payment reference.",
            "type": "string",
            "maxLength": 256,
            "minLength": 1,
            "nullable": true
          },
          "created_at": {
            "title": "Created at",
            "description": "Payment creation date.",
            "type": "string",
            "format": "date-time"
          },
          "edited_at": {
            "title": "Edited at",
            "description": "Payment last edited date.",
            "type": "string",
            "format": "date-time"
          },
          "status": {
            "title": "Status",
            "description": "Payment status.",
            "type": "string",
            "enum": [
              "NR",
              "PE",
              "AC",
              "IA",
              "CO",
              "CA",
              "EX",
              "OC",
              "FA",
              "DE",
              "CM"
            ]
          },
          "fiat_amount": {
            "title": "Fiat amount",
            "description": "Payment amount in USDC.",
            "type": "number"
          },
          "crypto_amount": {
            "title": "Crypto amount",
            "description": "Cryptocurrency amount for the payment.",
            "type": "number",
            "nullable": true
          },
          "unconfirmed_amount": {
            "title": "Unconfirmed amount",
            "description": "Amount shown on the mem-pool but not confirmed.",
            "type": "number"
          },
          "confirmed_amount": {
            "title": "Confirmed amount",
            "description": "Amount with at least 1 confirmation on the blockchain",
            "type": "number"
          },
          "currency_id": {
            "title": "Currency id",
            "description": "Symbol of the cryptocurrency for the payment.",
            "type": "string"
          },
          "merchant_device_id": {
            "title": "Merchant device id",
            "description": "Merchant Id.",
            "type": "integer"
          },
          "merchant_device": {
            "title": "Merchant device",
            "description": "Merchant name.",
            "type": "string",
            "minLength": 1
          },
          "address": {
            "title": "Address",
            "description": "Address that will receive the payment.",
            "type": "string",
            "maxLength": 64,
            "minLength": 1,
            "nullable": true
          },
          "tag_memo": {
            "title": "Tag memo",
            "description": "Destination tag or MEMO.",
            "type": "string",
            "nullable": true
          },
          "url_ko": {
            "title": "Url ko",
            "description": "The redirection url for not completed or expired payments.",
            "type": "string",
            "format": "uri",
            "nullable": true
          },
          "url_ok": {
            "title": "Url ok",
            "description": "The redirection url for completed payments.",
            "type": "string",
            "format": "uri",
            "nullable": true
          },
          "url_standby": {
            "title": "Url standby",
            "description": "The redirection url to wait for payment confirmation.",
            "type": "string",
            "format": "uri",
            "nullable": true
          },
          "expired_time": {
            "title": "Expired time",
            "description": "Payment expiration date.",
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "good_fee": {
            "title": "Good fee",
            "description": "Indicates if the fee for the transaction is adequate.",
            "type": "boolean"
          },
          "notes": {
            "title": "Notes",
            "description": "Product or service description of the payment.",
            "type": "string",
            "maxLength": 512,
            "minLength": 1
          },
          "rbf": {
            "title": "Rbf",
            "description": "Indicates if a payment can be “Replace by Fee”. Just can be True on BTC.",
            "type": "boolean"
          },
          "safe": {
            "title": "Safe",
            "description": "Indicates if the payment is safe.",
            "type": "boolean"
          },
          "fiat": {
            "title": "Fiat",
            "description": "Fiat available.",
            "type": "string",
            "enum": [
              "EUR",
              "USD",
              "GBP",
              "ARS",
              "AUD",
              "BGN",
              "BOB",
              "BRL",
              "CAD",
              "CHF",
              "CLP",
              "COP",
              "DKK",
              "DOP",
              "GEL",
              "HUF",
              "ISK",
              "JPY",
              "KRW",
              "MXN",
              "NOK",
              "NZD",
              "PEN",
              "PLN",
              "PYG",
              "RON",
              "SEK",
              "SGD",
              "SVC",
              "UYU"
            ],
            "default": "MXN"
          },
          "language": {
            "title": "Language",
            "description": "Language.",
            "type": "string",
            "default": "ES",
            "maxLength": 6,
            "minLength": 1
          },
          "percentage": {
            "title": "Percentage",
            "description": "Percentage of payment received (%)",
            "type": "number"
          },
          "received_amount": {
            "title": "Received amount",
            "description": "Payment received amount in USDC.",
            "type": "number"
          },
          "balance_based": {
            "title": "Balance based",
            "description": "Indicate if the transaction is balance based.",
            "type": "string",
            "minLength": 1
          },
          "internal_data": {
            "title": "Internal data",
            "description": "Internal data stored by the merchant.",
            "type": "string",
            "maxLength": 1024,
            "minLength": 1
          },
          "transactions": {
            "description": "List of payment's transactions.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Transaction"
            }
          }
        }
      },
      "ResponseCreatePayment": {
        "type": "object",
        "properties": {
          "identifier": {
            "title": "Identifier",
            "description": "The uuid4 identifier of the payment.",
            "type": "string"
          },
          "reference": {
            "title": "Reference",
            "description": "Payment reference.",
            "type": "string",
            "maxLength": 256,
            "minLength": 1,
            "nullable": true
          },
          "payment_uri": {
            "title": "Payment uri",
            "description": "Address and amount of the cryptocurrency in order to create de QR code.",
            "type": "string",
            "nullable": true
          },
          "web_url": {
            "title": "Web url",
            "description": "The url of the virtual gateway. (No necessary for physical POS)",
            "type": "string",
            "format": "uri"
          },
          "address": {
            "title": "Address",
            "description": "Address that will receive the payment.",
            "type": "string",
            "nullable": true
          },
          "tag_memo": {
            "title": "Tag memo",
            "description": "Destination tag or MEMO.",
            "type": "string",
            "nullable": true
          },
          "input_currency": {
            "title": "Input currency",
            "description": "Payment's cryptocurrency symbol.",
            "type": "string",
            "nullable": true
          },
          "expected_input_amount": {
            "title": "Expected input amount",
            "description": "Payment's cryptocurrency amount.",
            "type": "number",
            "nullable": true
          },
          "rate": {
            "title": "Rate",
            "description": "Price of the cryptocurrency USDC.",
            "type": "number",
            "nullable": true
          },
          "notes": {
            "title": "Notes",
            "description": "Product or service description of the payment.",
            "type": "string"
          },
          "fiat": {
            "title": "Fiat",
            "description": "Fiat available.",
            "type": "string",
            "enum": [
              "EUR",
              "USD",
              "GBP",
              "ARS",
              "AUD",
              "BGN",
              "BOB",
              "BRL",
              "CAD",
              "CHF",
              "CLP",
              "COP",
              "DKK",
              "DOP",
              "GEL",
              "HUF",
              "ISK",
              "JPY",
              "KRW",
              "MXN",
              "NOK",
              "NZD",
              "PEN",
              "PLN",
              "PYG",
              "RON",
              "SEK",
              "SGD",
              "SVC",
              "UYU"
            ],
            "default": "MXN"
          },
          "language": {
            "title": "Language",
            "description": "Language.",
            "type": "string",
            "default": "ES",
            "maxLength": 6,
            "minLength": 1
          }
        }
      }
    }
  }
}
