{
  "openapi": "3.0.4",
  "info": {
    "title": "Ivr Gateway",
    "description": "Provides a payments gateway for Ivr applications to process card payments for the specified account.",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.uat-newdaycards.com/ivr-gateway",
      "description": "NDC Staging"
    },
    {
      "url": "https://api.newdaycards.com/ivr-gateway",
      "description": "NDC Production"
    },
    {
      "url": "https://mtgw-a.stg-newdaytechnology.net/ivr-gateway/{tenant}",
      "description": "NDT Staging"
    },
    {
      "url": "https://mtgw-a.newdaytechnology.net/ivr-gateway/{tenant}",
      "description": "NDT Production"
    }
  ],
  "paths": {
    "/payments": {
      "post": {
        "tags": [
          "Payments"
        ],
        "summary": "Initiate a new payment from a source to a beneficiary.",
        "operationId": "InitiatePayment",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Identifier for idempotency.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "Details of the payment to be initiated.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InitiatePaymentRequest"
              },
              "examples": {
                "Pay by card": {
                  "value": {
                    "brand": "MyBrand",
                    "beneficiary": {
                      "accountNumber": "3925900000000001",
                      "accountStatus": null,
                      "lastName": "Bloggs",
                      "dateOfBirth": "2000-06-23",
                      "address": {
                        "addressLine1": null,
                        "addressLine2": null,
                        "city": null,
                        "houseName": null,
                        "houseNumber": null,
                        "postcode": "FE1 9BY",
                        "country": null,
                        "county": null
                      }
                    },
                    "amount": {
                      "currency": "GBP",
                      "value": 46.85
                    },
                    "source": {
                      "type": "card",
                      "cardDetails": {
                        "cardNumber": "4242424242424242",
                        "cvv": "123",
                        "expiryMonth": 10,
                        "expiryYear": 2027
                      },
                      "preferences": {
                        "saveCard": true,
                        "setAsDefaultCard": true
                      },
                      "billingAddress": {
                        "addressLine1": "44 Sage Road",
                        "addressLine2": null,
                        "city": null,
                        "houseName": null,
                        "houseNumber": null,
                        "postcode": "YR99 8MU",
                        "country": null,
                        "county": null
                      }
                    }
                  }
                },
                "Pay by saved card": {
                  "value": {
                    "brand": "MyBrand",
                    "beneficiary": {
                      "accountNumber": "3925900000000001",
                      "accountStatus": null,
                      "lastName": "Bloggs",
                      "dateOfBirth": "2000-06-23",
                      "address": {
                        "addressLine1": null,
                        "addressLine2": null,
                        "city": null,
                        "houseName": null,
                        "houseNumber": null,
                        "postcode": "FE1 9BY",
                        "country": null,
                        "county": null
                      }
                    },
                    "amount": {
                      "currency": "GBP",
                      "value": 46.85
                    },
                    "source": {
                      "type": "savedCard",
                      "cardId": "ABCD12345",
                      "cvv": "123"
                    }
                  }
                }
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/InitiatePaymentRequest"
              },
              "examples": {
                "Pay by card": {
                  "value": {
                    "brand": "MyBrand",
                    "beneficiary": {
                      "accountNumber": "3925900000000001",
                      "accountStatus": null,
                      "lastName": "Bloggs",
                      "dateOfBirth": "2000-06-23",
                      "address": {
                        "addressLine1": null,
                        "addressLine2": null,
                        "city": null,
                        "houseName": null,
                        "houseNumber": null,
                        "postcode": "FE1 9BY",
                        "country": null,
                        "county": null
                      }
                    },
                    "amount": {
                      "currency": "GBP",
                      "value": 46.85
                    },
                    "source": {
                      "type": "card",
                      "cardDetails": {
                        "cardNumber": "4242424242424242",
                        "cvv": "123",
                        "expiryMonth": 10,
                        "expiryYear": 2027
                      },
                      "preferences": {
                        "saveCard": true,
                        "setAsDefaultCard": true
                      },
                      "billingAddress": {
                        "addressLine1": "44 Sage Road",
                        "addressLine2": null,
                        "city": null,
                        "houseName": null,
                        "houseNumber": null,
                        "postcode": "YR99 8MU",
                        "country": null,
                        "county": null
                      }
                    }
                  }
                },
                "Pay by saved card": {
                  "value": {
                    "brand": "MyBrand",
                    "beneficiary": {
                      "accountNumber": "3925900000000001",
                      "accountStatus": null,
                      "lastName": "Bloggs",
                      "dateOfBirth": "2000-06-23",
                      "address": {
                        "addressLine1": null,
                        "addressLine2": null,
                        "city": null,
                        "houseName": null,
                        "houseNumber": null,
                        "postcode": "FE1 9BY",
                        "country": null,
                        "county": null
                      }
                    },
                    "amount": {
                      "currency": "GBP",
                      "value": 46.85
                    },
                    "source": {
                      "type": "savedCard",
                      "cardId": "ABCD12345",
                      "cvv": "123"
                    }
                  }
                }
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/InitiatePaymentRequest"
              },
              "examples": {
                "Pay by card": {
                  "value": {
                    "brand": "MyBrand",
                    "beneficiary": {
                      "accountNumber": "3925900000000001",
                      "accountStatus": null,
                      "lastName": "Bloggs",
                      "dateOfBirth": "2000-06-23",
                      "address": {
                        "addressLine1": null,
                        "addressLine2": null,
                        "city": null,
                        "houseName": null,
                        "houseNumber": null,
                        "postcode": "FE1 9BY",
                        "country": null,
                        "county": null
                      }
                    },
                    "amount": {
                      "currency": "GBP",
                      "value": 46.85
                    },
                    "source": {
                      "type": "card",
                      "cardDetails": {
                        "cardNumber": "4242424242424242",
                        "cvv": "123",
                        "expiryMonth": 10,
                        "expiryYear": 2027
                      },
                      "preferences": {
                        "saveCard": true,
                        "setAsDefaultCard": true
                      },
                      "billingAddress": {
                        "addressLine1": "44 Sage Road",
                        "addressLine2": null,
                        "city": null,
                        "houseName": null,
                        "houseNumber": null,
                        "postcode": "YR99 8MU",
                        "country": null,
                        "county": null
                      }
                    }
                  }
                },
                "Pay by saved card": {
                  "value": {
                    "brand": "MyBrand",
                    "beneficiary": {
                      "accountNumber": "3925900000000001",
                      "accountStatus": null,
                      "lastName": "Bloggs",
                      "dateOfBirth": "2000-06-23",
                      "address": {
                        "addressLine1": null,
                        "addressLine2": null,
                        "city": null,
                        "houseName": null,
                        "houseNumber": null,
                        "postcode": "FE1 9BY",
                        "country": null,
                        "county": null
                      }
                    },
                    "amount": {
                      "currency": "GBP",
                      "value": 46.85
                    },
                    "source": {
                      "type": "savedCard",
                      "cardId": "ABCD12345",
                      "cvv": "123"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InitiatePaymentResponse"
                },
                "examples": {
                  "Successful payment": {
                    "value": {
                      "paymentReference": "YEMVbQ2KfZXQQdemo2",
                      "savedCardErrorCode": "NotRequested"
                    }
                  },
                  "Successful payment w/ successful save card": {
                    "value": {
                      "paymentReference": "YEMVbQ2KfZXQQdemo2",
                      "savedCardErrorCode": "Successful"
                    }
                  },
                  "Successful payment with failed save card": {
                    "value": {
                      "paymentReference": "YEMVbQ2KfZXQQdemo2",
                      "savedCardErrorCode": "Unsuccessful"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ProblemDetails"
                    },
                    {
                      "$ref": "#/components/schemas/HttpValidationProblemDetails"
                    }
                  ]
                },
                "examples": {
                  "Card issuer error": {
                    "value": {
                      "type": "ndt:payments:error",
                      "title": "Declined Payment by Card Issuer",
                      "errorCode": "0013"
                    }
                  },
                  "Validation error": {
                    "value": {
                      "type": "ndt:generic:validation",
                      "title": "One or more validation errors occurred.",
                      "errors": {
                        "Idempotency-Key": [
                          "The idempotencyKey field is required."
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/problem+json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ProblemDetails"
                    },
                    {
                      "$ref": "#/components/schemas/HttpValidationProblemDetails"
                    }
                  ]
                },
                "examples": {
                  "Card issuer error": {
                    "value": {
                      "type": "ndt:payments:error",
                      "title": "Declined Payment by Card Issuer",
                      "errorCode": "0013"
                    }
                  },
                  "Validation error": {
                    "value": {
                      "type": "ndt:generic:validation",
                      "title": "One or more validation errors occurred.",
                      "errors": {
                        "Idempotency-Key": [
                          "The idempotencyKey field is required."
                        ]
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell + Curl",
            "source": "curl --request POST \\\n  --url https://api.uat-newdaycards.com/ivr-gateway/payments \\\n  --header 'Idempotency-Key: SOME_STRING_VALUE' \\\n  --header 'content-type: application/json' \\\n  --data '{\"brand\":\"MyBrand\",\"beneficiary\":{\"accountNumber\":\"string\",\"accountStatus\":\"string\",\"lastName\":\"Khan\",\"dateOfBirth\":\"string\",\"address\":{\"addressLine1\":\"\\r\\n            46 Bruno Place\\r\\n            \",\"addressLine2\":\"\\r\\n            Billberry Street\\r\\n            \",\"city\":\"\\r\\n            Wilmslow\\r\\n            \",\"houseName\":\"string\",\"houseNumber\":\"\\r\\n            46\\r\\n            \",\"postcode\":\"\\r\\n            BE7 6TJ\\r\\n            \",\"country\":\"\\r\\n            United Kingdom\\r\\n            \",\"county\":\"\\r\\n            Bedford\\r\\n            \"}},\"amount\":{\"currency\":\"string\",\"value\":0.1},\"source\":{}}'"
          },
          {
            "lang": "Csharp + Restsharp",
            "source": "var client = new RestClient(\"https://api.uat-newdaycards.com/ivr-gateway/payments\");\nvar request = new RestRequest(Method.POST);\nrequest.AddHeader(\"Idempotency-Key\", \"SOME_STRING_VALUE\");\nrequest.AddHeader(\"content-type\", \"application/json\");\nrequest.AddParameter(\"application/json\", \"{\\\"brand\\\":\\\"MyBrand\\\",\\\"beneficiary\\\":{\\\"accountNumber\\\":\\\"string\\\",\\\"accountStatus\\\":\\\"string\\\",\\\"lastName\\\":\\\"Khan\\\",\\\"dateOfBirth\\\":\\\"string\\\",\\\"address\\\":{\\\"addressLine1\\\":\\\"\\\\r\\\\n            46 Bruno Place\\\\r\\\\n            \\\",\\\"addressLine2\\\":\\\"\\\\r\\\\n            Billberry Street\\\\r\\\\n            \\\",\\\"city\\\":\\\"\\\\r\\\\n            Wilmslow\\\\r\\\\n            \\\",\\\"houseName\\\":\\\"string\\\",\\\"houseNumber\\\":\\\"\\\\r\\\\n            46\\\\r\\\\n            \\\",\\\"postcode\\\":\\\"\\\\r\\\\n            BE7 6TJ\\\\r\\\\n            \\\",\\\"country\\\":\\\"\\\\r\\\\n            United Kingdom\\\\r\\\\n            \\\",\\\"county\\\":\\\"\\\\r\\\\n            Bedford\\\\r\\\\n            \\\"}},\\\"amount\\\":{\\\"currency\\\":\\\"string\\\",\\\"value\\\":0.1},\\\"source\\\":{}}\", ParameterType.RequestBody);\nIRestResponse response = client.Execute(request);"
          },
          {
            "lang": "Javascript + Xhr",
            "source": "const data = JSON.stringify({\n  \"brand\": \"MyBrand\",\n  \"beneficiary\": {\n    \"accountNumber\": \"string\",\n    \"accountStatus\": \"string\",\n    \"lastName\": \"Khan\",\n    \"dateOfBirth\": \"string\",\n    \"address\": {\n      \"addressLine1\": \"\\r\\n            46 Bruno Place\\r\\n            \",\n      \"addressLine2\": \"\\r\\n            Billberry Street\\r\\n            \",\n      \"city\": \"\\r\\n            Wilmslow\\r\\n            \",\n      \"houseName\": \"string\",\n      \"houseNumber\": \"\\r\\n            46\\r\\n            \",\n      \"postcode\": \"\\r\\n            BE7 6TJ\\r\\n            \",\n      \"country\": \"\\r\\n            United Kingdom\\r\\n            \",\n      \"county\": \"\\r\\n            Bedford\\r\\n            \"\n    }\n  },\n  \"amount\": {\n    \"currency\": \"string\",\n    \"value\": 0.1\n  },\n  \"source\": {}\n});\n\nconst xhr = new XMLHttpRequest();\nxhr.withCredentials = true;\n\nxhr.addEventListener(\"readystatechange\", function () {\n  if (this.readyState === this.DONE) {\n    console.log(this.responseText);\n  }\n});\n\nxhr.open(\"POST\", \"https://api.uat-newdaycards.com/ivr-gateway/payments\");\nxhr.setRequestHeader(\"Idempotency-Key\", \"SOME_STRING_VALUE\");\nxhr.setRequestHeader(\"content-type\", \"application/json\");\n\nxhr.send(data);"
          },
          {
            "lang": "Node + Request",
            "source": "const request = require('request');\n\nconst options = {\n  method: 'POST',\n  url: 'https://api.uat-newdaycards.com/ivr-gateway/payments',\n  headers: {'Idempotency-Key': 'SOME_STRING_VALUE', 'content-type': 'application/json'},\n  body: {\n    brand: 'MyBrand',\n    beneficiary: {\n      accountNumber: 'string',\n      accountStatus: 'string',\n      lastName: 'Khan',\n      dateOfBirth: 'string',\n      address: {\n        addressLine1: '\\r\\n            46 Bruno Place\\r\\n            ',\n        addressLine2: '\\r\\n            Billberry Street\\r\\n            ',\n        city: '\\r\\n            Wilmslow\\r\\n            ',\n        houseName: 'string',\n        houseNumber: '\\r\\n            46\\r\\n            ',\n        postcode: '\\r\\n            BE7 6TJ\\r\\n            ',\n        country: '\\r\\n            United Kingdom\\r\\n            ',\n        county: '\\r\\n            Bedford\\r\\n            '\n      }\n    },\n    amount: {currency: 'string', value: 0.1},\n    source: {}\n  },\n  json: true\n};\n\nrequest(options, function (error, response, body) {\n  if (error) throw new Error(error);\n\n  console.log(body);\n});\n"
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "Address": {
        "required": [
          "postcode"
        ],
        "type": "object",
        "properties": {
          "addressLine1": {
            "type": "string",
            "nullable": true,
            "example": "\r\n            46 Bruno Place\r\n            "
          },
          "addressLine2": {
            "type": "string",
            "nullable": true,
            "example": "\r\n            Billberry Street\r\n            "
          },
          "city": {
            "type": "string",
            "nullable": true,
            "example": "\r\n            Wilmslow\r\n            "
          },
          "houseName": {
            "type": "string",
            "description": "Bruno Manor",
            "nullable": true
          },
          "houseNumber": {
            "type": "string",
            "nullable": true,
            "example": "\r\n            46\r\n            "
          },
          "postcode": {
            "minLength": 1,
            "type": "string",
            "example": "\r\n            BE7 6TJ\r\n            "
          },
          "country": {
            "type": "string",
            "nullable": true,
            "example": "\r\n            United Kingdom\r\n            "
          },
          "county": {
            "type": "string",
            "nullable": true,
            "example": "\r\n            Bedford\r\n            "
          }
        },
        "additionalProperties": false
      },
      "Amount": {
        "required": [
          "currency",
          "value"
        ],
        "type": "object",
        "properties": {
          "currency": {
            "minLength": 1,
            "type": "string",
            "description": "Currency code of the value (ISO 4217 alpha-3 format)."
          },
          "value": {
            "type": "number",
            "description": "Decimal payment amount.",
            "format": "double"
          }
        },
        "additionalProperties": false,
        "description": "Payment amount details"
      },
      "BillingAddress": {
        "required": [
          "addressLine1",
          "postcode"
        ],
        "type": "object",
        "properties": {
          "addressLine1": {
            "minLength": 1,
            "type": "string",
            "example": "46 Bruno Place"
          },
          "addressLine2": {
            "type": "string",
            "nullable": true,
            "example": "Billberry Street"
          },
          "city": {
            "type": "string",
            "nullable": true,
            "example": "\r\n            Wilmslow\r\n            "
          },
          "houseName": {
            "type": "string",
            "nullable": true
          },
          "houseNumber": {
            "type": "string",
            "nullable": true,
            "example": "46"
          },
          "postcode": {
            "minLength": 1,
            "type": "string",
            "example": "BE7 6TJ"
          },
          "country": {
            "type": "string",
            "nullable": true,
            "example": "\r\n            United Kingdom\r\n            "
          },
          "county": {
            "type": "string",
            "nullable": true,
            "example": "\r\n            Bedford\r\n            "
          }
        },
        "additionalProperties": false
      },
      "CardAccountBeneficiary": {
        "required": [
          "accountNumber",
          "address",
          "dateOfBirth",
          "lastName"
        ],
        "type": "object",
        "properties": {
          "accountNumber": {
            "minLength": 1,
            "type": "string",
            "description": "The friendly display account number."
          },
          "accountStatus": {
            "pattern": "Normal|Collections",
            "type": "string",
            "description": "The account status (\"Normal\" or \"Collections\").",
            "nullable": true
          },
          "lastName": {
            "minLength": 1,
            "type": "string",
            "description": "Last name of the account holder.",
            "example": "Khan"
          },
          "dateOfBirth": {
            "minLength": 1,
            "type": "string",
            "description": "Date of birth of the account holder as YYYY-MM-DD format e.g. 2000-05-25."
          },
          "address": {
            "$ref": "#/components/schemas/Address"
          }
        },
        "additionalProperties": false,
        "description": "Details of the card account being funded."
      },
      "CardDetails": {
        "required": [
          "cardNumber",
          "cvv",
          "expiryMonth",
          "expiryYear"
        ],
        "type": "object",
        "properties": {
          "cardNumber": {
            "minLength": 1,
            "type": "string",
            "description": "PAN for the card.",
            "example": "4659105569051157"
          },
          "cvv": {
            "minLength": 1,
            "type": "string",
            "description": "CVV for the card.",
            "example": "012"
          },
          "expiryMonth": {
            "type": "integer",
            "description": "Two digit expiry month.",
            "format": "int32",
            "example": 10
          },
          "expiryYear": {
            "type": "integer",
            "description": "Four digit expiry year.",
            "format": "int32",
            "example": 2027
          }
        },
        "additionalProperties": false,
        "description": "Details of the payment card."
      },
      "CardPreferences": {
        "type": "object",
        "properties": {
          "saveCard": {
            "type": "boolean",
            "description": "Whether the payment card should be added to customer's saved cards.",
            "nullable": true,
            "example": true
          },
          "setAsDefaultCard": {
            "type": "boolean",
            "description": "Whether payment card should be saved and set as customer's default payment card.",
            "nullable": true,
            "example": true
          }
        },
        "additionalProperties": false
      },
      "CardSource": {
        "allOf": [
          {
            "$ref": "#/components/schemas/PaymentSource"
          },
          {
            "required": [
              "billingAddress"
            ],
            "type": "object",
            "properties": {
              "cardDetails": {
                "$ref": "#/components/schemas/CardDetails"
              },
              "preferences": {
                "$ref": "#/components/schemas/CardPreferences"
              },
              "billingAddress": {
                "$ref": "#/components/schemas/BillingAddress"
              }
            },
            "additionalProperties": false
          }
        ],
        "description": "Payment card payment source."
      },
      "HttpValidationProblemDetails": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ProblemDetails"
          },
          {
            "type": "object",
            "properties": {
              "errors": {
                "type": "object",
                "additionalProperties": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "nullable": true
              }
            },
            "additionalProperties": {}
          }
        ]
      },
      "InitiatePaymentRequest": {
        "required": [
          "amount",
          "beneficiary",
          "brand",
          "source"
        ],
        "type": "object",
        "properties": {
          "brand": {
            "minLength": 1,
            "type": "string",
            "description": "Brand identifier.",
            "example": "MyBrand"
          },
          "beneficiary": {
            "$ref": "#/components/schemas/CardAccountBeneficiary"
          },
          "amount": {
            "$ref": "#/components/schemas/Amount"
          },
          "source": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PaymentSource"
              },
              {
                "$ref": "#/components/schemas/CardSource"
              },
              {
                "$ref": "#/components/schemas/SavedCardSource"
              }
            ],
            "description": "Source for the payments; where the funds are coming from."
          }
        },
        "additionalProperties": false
      },
      "InitiatePaymentResponse": {
        "required": [
          "paymentReference"
        ],
        "type": "object",
        "properties": {
          "paymentReference": {
            "type": "string",
            "description": "Alphanumeric reference for the payment.",
            "nullable": true,
            "example": "YEMVbQ2KfZXQQdemo2"
          },
          "savedCardErrorCode": {
            "type": "string",
            "description": "Result of the saved card operation, if requested.",
            "nullable": true,
            "example": "Successful"
          }
        },
        "additionalProperties": false
      },
      "PaymentSource": {
        "type": "object",
        "additionalProperties": false,
        "description": "Payment source."
      },
      "ProblemDetails": {
        "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
          }
        },
        "additionalProperties": {}
      },
      "SavedCardSource": {
        "allOf": [
          {
            "$ref": "#/components/schemas/PaymentSource"
          },
          {
            "required": [
              "cardId",
              "cvv"
            ],
            "type": "object",
            "properties": {
              "cardId": {
                "minLength": 1,
                "type": "string",
                "description": "Saved card identifier."
              },
              "cvv": {
                "minLength": 1,
                "type": "string",
                "description": "CVV associated with the saved card."
              }
            },
            "additionalProperties": false
          }
        ],
        "description": "Saved card payment source."
      }
    }
  },
  "tags": [
    {
      "name": "Payments"
    }
  ],
  "x-pub-settings": {
    "pub-ready": true,
    "tags": [
      "Payments",
      "Retailers",
      "NewPay"
    ],
    "team": "",
    "commitDate": 1792665535000
  }
}