{"info":{"_postman_id":"2b5bd0bc-0697-48b1-b166-9ba85793a555","name":"SmartDebit API Programmer's Guide","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","toc":[],"description":"<html><head></head><body></body></html>","owner":"6207449","collectionId":"2b5bd0bc-0697-48b1-b166-9ba85793a555","publishedId":"S1TPcgzt","public":true,"customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"EF5B25"},"publishDate":"2021-03-11T08:24:32.000Z"},"item":[{"name":"1 Introduction","item":[{"name":"    1.1 About this document","item":[],"id":"3a5f145d-55ac-4f06-b015-d8f8ec60bac7","description":"<p>This online document provides a full and detailed description of the SmartDebit API®, its capabilities and how it can be used. The SmartDebit API® provides direct access to the core of the SmartDebit Direct Debit processing systems, giving seamless integration with greater control.</p>\n<p>SmartDebit is part of Access Paysuite, the UK’s leading Direct Debit service provider. SmartDebit combines superior customer service, enterprise security and compliance, with a suite of powerful tools to automate payment collections while reducing customer churn and improving financial reporting.</p>\n<p>The API is just one element of our advanced systems for the collection of recurring payments. SmartDebit customers can also utilise:</p>\n<ul>\n<li><p>SmartDebit Pulse® - A powerful and comprehensive Direct Debit collection portal offering full Direct Debit management and reporting</p>\n</li>\n<li><p>SmartDebit Online® - A hosted or custom-branded webpage to sign up customers on your own website</p>\n</li>\n<li><p>SmartDebit SFTP® - Quick and simple data exchange, either manual or automated to suit your requirements</p>\n</li>\n<li><p>SmartDebit Direct® - Simple-to-use, secure and powerful Direct Debit and Direct Credit Bacs file submission solution.</p>\n</li>\n</ul>\n<p>This document helps you to get started, gives tips and advice on how to use the calls and what the responses mean. The reference section includes call syntax, code snippets and sample responses. You can change the client language to suit your requirements.</p>\n","event":[{"listen":"prerequest","script":{"id":"18efce3e-8aa3-441f-b8b1-b356eb1bc73c","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"1f99ba4f-291c-4a7a-8574-3f4ed64cce14","type":"text/javascript","exec":[""]}}],"_postman_id":"3a5f145d-55ac-4f06-b015-d8f8ec60bac7"},{"name":"1.2 About Direct Debits","item":[],"id":"f1ed3971-75ea-4278-9595-c1c5e824b4a1","description":"<p>Direct Debit is the simplest way for organisations to collect regular or occasional payments from their customers, donors (if the organisation is a charity), or members (if the organisation is a club or association).</p>\n<p>A Direct Debit is an instruction from a customer to their bank or building society authorising an organisation, or <strong>service user</strong>, to collect varying amounts from their account, as long as the customer has been given advance notice of the collection amounts and dates.</p>\n<p>This instruction is known as a <strong>Direct Debit Instruction</strong> or <strong>DDI</strong>. The customer is referred to simply as a <strong>payer</strong>. The terms <em>DDI</em> and <em>payer</em> are largely synonymous in the context of the API.</p>\n<p>The instruction must be sent to the payer's bank before any funds can be collected. This process is referred to as <strong>lodgement</strong>. Because the payer must be given advance notice and because time must be allowed for lodgement, payments cannot be collected immediately when a new payer gives their authority (or signs up).</p>\n<p>SmartDebit can issue advance notice (and other notifications) by email on behalf of the service user.</p>\n<p>SmartDebit submits payment instructions, as well as new payers and cancellations, to the paying banks electronically via a secure connection to Bacs, the organisation that administers the Direct Debit scheme.</p>\n<p>A customer may cancel their instruction at any time. They may transfer it to a different bank account. They have the right to claim back payments that were taken in error.</p>\n<p>SmartDebit receives notifications from the paying banks in the form of <strong>Bacs reports</strong>, such as:</p>\n<ul>\n<li>instructions that fail to lodge (AUDDIS)</li>\n<li>amendments and cancellations (ADDACS)</li>\n<li>payments that could not be collected (ARUDD)</li>\n<li>indemnity claims (DDICA)</li>\n</ul>\n<p>SmartDebit makes these notifications available through the API and also applies any changes to its records.</p>\n","event":[{"listen":"prerequest","script":{"id":"13aae07b-bbdd-4970-8d8e-679af97790fb","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"69972930-3cf1-4b59-9c3d-ad899997b3f6","type":"text/javascript","exec":[""]}}],"_postman_id":"f1ed3971-75ea-4278-9595-c1c5e824b4a1"},{"name":"1.3 About the API","item":[],"id":"8b4401cd-a04b-4ea5-940a-ddfbebeba6a4","description":"<p>The SmartDebit API® is a web-based API that allows authorised partners to integrate the SmartDebit Direct Debit sign-up and management functionality into their own applications. The main purpose is to extend CRM systems to support Direct Debit payments, but any system can benefit from use of this API. \nUsing the API isn’t always necessary though. We have created simpler options. If you just need to sign up payers, you can use <a href=\"https://www.smartdebit.co.uk/services/our-products-and-services/smartdebit-online/\">SmartDebit Online®</a> instead, as this will display branded web-pages that we host to remove the sign-up from your own systems completely. </p>\n<h4 id=\"what-does-it-do\">What does it do?</h4>\n<p>The API can be used to manage all aspects of the Direct Debit process, or you can use it to deal with some aspects and control others manually with SmartDebit Pulse®. You can upload payers you’ve signed up, manage their payments, check statuses and download responses from Bacs. In fact, you can do nearly everything you can do with SmartDebit Pulse®, other than manage system user settings and passwords.</p>\n<h4 id=\"how-does-it-work\">How does it work?</h4>\n<p>The API is an HTTPS interface, authenticated with basic HTTP authentication. Connections attempted that don't use HTTPS (i.e. that use basic HTTP) are rejected. The freedom and flexibility inherent in the API design allow you to build an application that meets all your needs. We encourage partners to provide specific IP addresses we can whitelist for added security. The SmartDebit API includes GET, PUT and POST methods.  The API allows passing of parameters for POST and PUT methods as query parameters, form parameters, or as an XML body. All responses are XML documents.</p>\n<p>SmartDebit API allows:</p>\n<ol>\n<li>collections of any value to be collected as and when required (the \"adhoc\" model), or</li>\n<li>recurring collections to be generated and collected on a schedule (the \"variable\" model), and</li>\n<li>payment schedules to be altered, overridden and also extended with one-off collections.\n</li></ol>\n\n<p>The best model for your business will be discussed with your SmartDebit sales representative. Each model has its own advantages and the choice of model will depend mainly on the type of business the service user operates.</p>\n","event":[{"listen":"prerequest","script":{"id":"37042608-4cec-4fc1-b025-629071f6168d","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"4547702a-e2ba-4435-8898-ad321f014168","type":"text/javascript","exec":[""]}}],"_postman_id":"8b4401cd-a04b-4ea5-940a-ddfbebeba6a4"},{"name":"1.4 Versioning","item":[],"id":"ee198f43-267f-4e45-abe0-608df541b318","description":"<p>API versioning allows for the roll-out of functional enhancements and interface changes without breaking existing client implementations. The <a href=\"#605af7a4-5a20-41e1-8ff2-ff26f1b7d94a\">latest API version</a> is given by the <a href=\"#7e74d88c-7f36-43d8-9229-deb16e50bf2a\">system_status</a> call. Clients can upgrade independently by changing the base URL in their API calls.</p>\n<p>API versioning is introduced in document version 2.0, API version 1.1. Changes prior to document version 2.0 are unversioned.</p>\n<p>For example, these two versions of <a href=\"#efceb3f7-3bb8-4af9-b126-f8f912bb5fc7\">get_successful_collection_report</a> present indemnity-claimed collections differently:</p>\n<p><code>https://secure.ddprocessing.co.uk/api/v1.1/get_successful_collection_report</code></p>\n<p><code>https://secure.ddprocessing.co.uk/api/get_successful_collection_report</code></p>\n<p><strong>Note:</strong></p>\n<ul>\n<li>All calls accept a version number in the URL.</li>\n<li>You cannot use a URL which includes .../api/v1.0/...</li>\n<li>Some system changes may be impossible to restrict to a new API version.</li>\n<li>Backward-compatible changes may be introduced, unversioned, at any point (e.g. new optional parameters or new calls). They will be accompanied by a new <a href=\"#0953b9f0-283a-492d-8d16-7184a038ab9a\">document version</a>.</li>\n</ul>\n<p>This document includes change histories for both the <a href=\"#605af7a4-5a20-41e1-8ff2-ff26f1b7d94a\">API</a> and the <a href=\"#0953b9f0-283a-492d-8d16-7184a038ab9a\">document</a> itself.</p>\n","event":[{"listen":"prerequest","script":{"id":"33e19bb5-bff2-4e83-9982-a00a4f87fd2a","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"42233a18-65db-4b88-b9b0-8255df961fab","type":"text/javascript","exec":[""]}}],"_postman_id":"ee198f43-267f-4e45-abe0-608df541b318"},{"name":"1.5 Authentication and authorisation","item":[],"id":"250ca8fe-d1bb-464d-9e12-c7bc8aad169b","description":"<p>SmartDebit issues API users with a username, password and also a PSLID value. The PSLID value is the service user designation. Different credentials are normally used for the sandbox and live environments. Where connectivity to multiple service users is required, multiple sets of credentials are usually issued.</p>\n<p>Only API users can use the API – other types of SmartDebit user are not authorised. API users have restricted use of the Pulse portal, whereas other users have full use of the portal.</p>\n<p>API users can change their password via the Pulse portal (<a href=\"https://online.smartdebit.co.uk/Account/Login\">live</a> or <a href=\"https://sandbox.smartdebit.co.uk/Account/Login\">sandbox</a> as appropriate).</p>\n<p>IP whitelisting can be applied and, particularly for the live environment, is encouraged. \nAll calls must include a username and password using <a href=\"https://en.wikipedia.org/wiki/Basic_access_authentication\">HTTP basic authentication</a>.</p>\n<p>Authentication failures present as a \"401 Unauthorized\" HTTP status. For further details, see <a href=\"#7e74d88c-7f36-43d8-9229-deb16e50bf2a\">system_status</a>.</p>\n","event":[{"listen":"prerequest","script":{"id":"c3772f99-d9d5-4838-8d66-9d81866ea4f5","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"f53269d0-7146-4e65-87be-b3fb6cd2bd70","type":"text/javascript","exec":[""]}}],"_postman_id":"250ca8fe-d1bb-464d-9e12-c7bc8aad169b"}],"id":"3eccade2-50c2-4090-ab83-5f40de12f02a","event":[{"listen":"prerequest","script":{"id":"10956eaa-dde5-4c85-917e-81a7dc0350db","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"4cdc5785-3b11-40b6-a5d6-574684e224fa","type":"text/javascript","exec":[""]}}],"_postman_id":"3eccade2-50c2-4090-ab83-5f40de12f02a","description":""},{"name":"2 Concepts and features","item":[],"id":"e61b1ac9-6b42-4188-a2db-3c74bba7018c","description":"<h4 id=\"parameterised-urls\">Parameterised URLs</h4>\n<p>API calls for specific resources have the identifier of the resource embedded in the URL. For example the PUT call <a href=\"#42d76121-1dd6-4e0a-ab9b-6454d618b1b5\">ddi/variable/{{reference_number}}</a> is used to update a payer, where {{reference_number}} must be replaced with the reference number of the DDI to be updated, e.g.  PUT ddi/variable/ABC123456.</p>\n<h4 id=\"extended-parameters\">Extended parameters</h4>\n<p>A number of methods in the SmartDebit API allow repeating parameters. These parameters can be set using query or form parameters, indeed HTML forms support repeating parameters, however it is recommended that an XML body is used for extended parameters. </p>\n<p>The following code sample demonstrates how to create a set of debits for an Adhoc DDI using form parameters. </p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>form_data = []\nform_data &lt;&lt; \"adhoc_ddi[service_user][pslid]=su_pslid\" \nform_data &lt;&lt; \"adhoc_ddi[first_name]=John\"\nform_data &lt;&lt; \"adhoc_ddi[start_date]=2019-05-23\" \n...\nform_data &lt;&lt; \"adhoc_ddi[debits][debit][][amount]=500\" \nform_data &lt;&lt; \"adhoc_ddi[debits][debit][][date]=2019-05-23\" \n\nform_data &lt;&lt; \"adhoc_ddi[debits][debit][][amount]=1500\" \nform_data &lt;&lt; \"adhoc_ddi[debits][debit][][date]=2019-06-01\" \n\nform_data &lt;&lt; \"adhoc_ddi[debits][debit][][amount]=1500\" \nform_data &lt;&lt; \"adhoc_ddi[debits][debit][][date]=2019-07-01\" \n\nreq.body = form_data.join(\"&amp;\")\n</code></pre><p>The pairs of <code>adhoc_ddi[debits][debit][][amount]</code> and <code>adhoc_ddi[debits][debit][][date]</code> parameters specify the debits to be created. As the names of these parameters are identical, the ordering matters. </p>\n<p><b>Note:</b></p>\n<ol>\n<li> Amounts are given in pence. </li>\n<li>The syntax: <code>adhoc_ddi[debits][debit][][amount]</code> (including empty square brackets) is mandatory.</li>\n</ol>\n\n<p>Using an XML body clarifies the nesting being emulated by the form parameter names. The nesting of the <code>&lt;debits&gt;</code> and <code>&lt;debit&gt;</code> tags removes any ambiguity of which amounts and dates belong together. For example:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>XML_body = \"\"\nXML_body &lt;&lt; \"&lt;?XML version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?&gt;\\n\"\nXML_body &lt;&lt; \"&lt;adhoc_ddi&gt;\\n\"\nXML_body &lt;&lt; \"&lt;service_user&gt;&lt;pslid&gt; su_pslid &lt;/pslid&gt;&lt;/service_user&gt;\\n\"  \nXML_body &lt;&lt; \"&lt;first_name&gt; John &lt;/first_name&gt;\\n\"\nXML_body &lt;&lt; \"&lt;start_date&gt; 2019-05-23 &lt;/start_date&gt;\\n\" \n...\nXML_body &lt;&lt; \"&lt;debits&gt;\\n\"   \n\nXML_body &lt;&lt; \"  &lt;debit&gt;\\n\"  \nXML_body &lt;&lt; \"    &lt;amount&gt; 500 &lt;/amount&gt;&lt;date&gt; 2019-05-23 &lt;/date&gt;\"  \nXML_body &lt;&lt; \"  &lt;/debit&gt;\\n\"\n\nXML_body &lt;&lt; \"  &lt;debit&gt;\\n\"   \nXML_body &lt;&lt; \"    &lt;amount&gt; 1500 &lt;/amount&gt;&lt;date&gt; 2019-06-01 &lt;/date&gt;\\n\"  \nXML_body &lt;&lt; \"  &lt;/debit&gt;\\n\"\n\nXML_body &lt;&lt; \"  &lt;debit&gt;\\n\"\nXML_body &lt;&lt; \"    &lt;amount&gt; 1500 &lt;/amount&gt;&lt;date&gt; 2019-07-01 &lt;/date&gt;\\n\"\nXML_body &lt;&lt; \"  &lt;/debit&gt;\\n\"\n\nXML_body &lt;&lt; \"&lt;/debits&gt;\\n\"  \nXML_body &lt;&lt; \"&lt;/adhoc_ddi&gt;\" \nreq.body = XML_body \n</code></pre><h4 id=\"conditional-parameters\">Conditional parameters</h4>\n<p>As the requirements of service users differ, there are numerous configuration options, some of which affect the use of the SmartDebit API. The most significant is the <em>processing model</em>; others affect the parameters required to call API methods. Any such parameters are explicitly stated, with the circumstances of their use listed.</p>\n<h4 id=\"valid-characters\">Valid characters</h4>\n<p>The SmartDebit API supports a <a href=\"#86a42735-f1f4-4bb2-a135-81860b0f1313\">restricted character set</a>. All fields relating to payer details are subject to these character restrictions and also length restrictions as detailed. <a href=\"#4d8a7173-5301-41e1-b171-7d4fde1fef6b\">Further restrictions</a> apply to reference numbers.</p>\n<h4 id=\"processing-models\">Processing models</h4>\n<p>SmartDebit offers two processing models and it is important that the correct one is chosen because it cannot subsequently be changed and because the calls used to manage payers are different. The <em>variable</em> model supports automated payment schedules, whereas the <em>adhoc</em> model requires every collection to be created or imported by the client application. Significantly, if SmartDebit is sending advance notice emails to payers, then it sends an email in advance of every collection under the <em>adhoc</em> model but only sends one if the collection amount is different from the previous collection amount under the <em>variable</em> model.</p>\n<ul>\n<li>Where regular payments are made, each of the same amount, the <em>variable</em> model is likely to be appropriate.</li>\n<li>Where regular payments are made, of varying amounts, the <em>variable</em> model is likely to be appropriate, though without automated scheduling.</li>\n<li>Where irregular payments are made, either model can be used.</li>\n<li>Where collection schedules are controlled entirely by the client application, either model can be used.</li>\n</ul>\n\n\n<h4 id=\"collection-schedules\">Collection schedules</h4>\n<p>The <em>variable</em> model supports collection schedules. There are two aspects to this feature.</p>\n<ol>\n<li><p>Where payer notifications are issued by the SmartDebit system, the initial confirmation includes the payer's collection schedule. Unless the schedule is altered, no further emails are issued.</p>\n</li>\n<li><p>The schedule can be defined at the point of payer creation. No further action is required.</p>\n</li>\n</ol>\n<p>Refer to <a href=\"#1b2343bd-e19a-4d5a-8fce-1ba5866dd358\">section 3.3</a> for further details.</p>\n<h4 id=\"lead-times\">Lead times</h4>\n<p>You cannot collect from a new payer immediately. You must allow time for the DDI to be sent to and set up (“lodged”) by the payer’s bank. This time is referred to as the <em>payer lead time</em>. The <em>collection lead time</em> is the greater of the time allowed for collections to be sent to the payer’s bank and the service user's advance notice period (as stipulated by their sponsoring bank). Collection details must be provided to SmartDebit by the end of the day prior to submission and cannot be altered after that time.</p>\n<p>Lead times may be calculated on a calendar or working day basis.</p>\n<p><strong>Example</strong>: A service user has a <em>payer lead time</em> of five working days. If there are no date restrictions placed on the service user and the service user does not specify a start date, the DDI is sent to Bacs on the working day after creation of the payer and the service user may collect five working days after that. If the service user wishes to specify a start date for the payer, they cannot set a date earlier than five working days after submission.</p>\n<p><strong>Example:</strong> In a normal week with no bank holidays a service user with a <em>collection lead time</em> of three working days can import collections up to the end of Sunday for collection on the following Thursday. Collections due on a Saturday, Sunday or Monday must be imported by the end of the previous Tuesday.</p>\n<p>Further examples are given <a href=\"https://smartdebithelp.zendesk.com/hc/en-us/articles/207145889-How-do-Working-Day-Lead-Times-work-\">here</a>.</p>\n<h4 id=\"email-notifications\">Email notifications</h4>\n<p>The SmartDebit system can be configured to send Bacs-compliant notifications to payers. The following email types can be activated:</p>\n<ul>\n<li>initial confirmation</li>\n<li>amendment</li>\n<li>advance notice</li>\n<li>re-present advance notice</li>\n<li>cancellation</li>\n<li>reinstatement</li>\n</ul>\n<p>The API does not expose endpoints to send emails. Instead, actions performed on a payer (either through the API or in the Pulse web portal) trigger an email.</p>\n","event":[{"listen":"prerequest","script":{"id":"6511290f-a15c-4bdc-8782-273857f16bb6","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"0da422c4-05c7-4609-8e9d-e3f3426ab362","type":"text/javascript","exec":[""]}}],"_postman_id":"e61b1ac9-6b42-4188-a2db-3c74bba7018c"},{"name":"3 How to use the API","item":[{"name":"3.1 Getting started","item":[],"id":"293d002b-9384-4530-90db-36aecbc4ca9b","description":"<p>Start with the <a href=\"#7e74d88c-7f36-43d8-9229-deb16e50bf2a\">system_status</a> call. Either</p>\n<ul>\n<li><code>https://sandbox.ddprocessing.co.uk/api/system_status</code> for a test account, or</li>\n<li><code>https://secure.ddprocessing.co.uk/api/system_status</code> for a live account on the production environment.</li>\n</ul>\n<p>You can make this call from your code, from a REST client or simply directly from your browser. This verifies your credentials and your associated service user(s). These values are likely to be constants within your application.</p>\n<p>Contact <a href=\"mailto:support@smartdebit.com?Subject=API%20authentication%20error\">support@smartdebit.com</a> if you encounter any error responses at this stage.</p>\n<p>Develop against the latest <a href=\"#605af7a4-5a20-41e1-8ff2-ff26f1b7d94a\">API version</a>. The base URL is likely to be a constant within your application.</p>\n<p>Decide which processing model suits your business. Service user configuration affects how the API behaves, so it is important that your sandbox environment is an accurate representation from the outset. Consult with your SmartDebit representative. It is useful to be clear about:</p>\n<ul>\n<li>your advance notice period (as stipulated by your sponsoring bank)</li>\n<li>whether you require regular collections to be generated by the SmartDebit system</li>\n<li>whether you are restricting collections to specific days of the month</li>\n<li>how email notifications are to be issued</li>\n</ul>\n<p>If you intend to construct public-facing sign-up pages, read the <a href=\"#c544fa20-2554-4bec-b25d-98af50f3b64f\">sign-up screens</a> section. Either the variable or adhoc versions of the validate and create calls will be used behind these pages. Allow for the pages to be reviewed by your sponsoring bank. </p>\n","event":[{"listen":"prerequest","script":{"id":"b8be0f68-1913-41bd-9a19-379c46c63bd9","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"e621c74f-bc0c-487e-85ca-86394a290e02","type":"text/javascript","exec":[""]}}],"_postman_id":"293d002b-9384-4530-90db-36aecbc4ca9b"},{"name":"3.2 Building your application","item":[],"id":"d7d56cec-89dc-4fb8-96ec-c1f7cd17281c","description":"<h4 id=\"during-development\">During development</h4>\n<p>If you experience any difficulty in making a call through your application code, consider using an external REST API testing tool to build your call before integrating it into your application.</p>\n<p>Use SmartDebit Pulse® to confirm the outcomes of your API calls. If there are issues with parameter values, viewing a screen in SmartDebit Pulse® may reveal them quicker than eyeballing a parameter list.</p>\n<p>If you cannot determine why a call has failed and you require further assistance, <a href=\"#2bbace77-f8e7-40f1-9d9b-593df776f4fc\">contact SmartDebit</a> with details of the call and the response.</p>\n<p>Explore how the API - and your application - handles data that is obviously wrong, such as strings that exceed their maximum length, collection dates in the past or missing parameters. </p>\n<h4 id=\"designing-your-application\">Designing your application</h4>\n<p>Consider how your application should behave if it does not receive a response.</p>\n<p>Be aware that some calls such as a file upload or a data dump call can take several minutes. Code your application to handle long response times, especially if you plan to handle large volumes of data. Avoid making repeated calls with the same parameters.</p>\n<p>Some calls can fail, or at least generate errors, yet still return an HTTP status of 200. The XML response should always be parsed.</p>\n<p>This document does not provide sufficient detail for comprehensive automated error handling. Nevertheless, a robust, lightweight application can be developed with little effort by concentrating on the success cases and ensuring that errors are reported to a user. Over time the application can be refined as necessary to increase automation.</p>\n<h4 id=\"in-production\">In production</h4>\n<p>There can be teething problems when switching from the sandbox to the live environment. Be prepared for them and monitor your application closely to begin with. SmartDebit support teams are on hand and most issues can be ironed out quickly without any business impact.</p>\n<p>Collection reports are issued by email on the day of submission. <a href=\"#2bbace77-f8e7-40f1-9d9b-593df776f4fc\">Contact SmartDebit</a> immediately if this report is not as expected.</p>\n<p><strong>Example:</strong> Failure to import a collection file</p>\n<ul>\n<li>Provided the problem is identified at the time of the failure, SmartDebit can quickly diagnose and provide advice on manual intervention. The file can be imported manually with no business impact.</li>\n<li>If the problem is not discovered until the due date, the business disruption could be considerable.</li>\n</ul>\n<p><strong>Example:</strong> Sign-up screens</p>\n<ul>\n<li>A problem here means a loss of business. Don't rely on users reporting problems.</li>\n</ul>\n<h4 id=\"risks\">Risks</h4>\n<ul>\n<li>Service user configurations can differ between environments.</li>\n<li>Unexpected scenarios or data can arise which were not considered during testing.</li>\n<li>Sample Bacs reports provided for the sandbox environment cannot be expected to cover all scenarios.</li>\n<li>The relatively long time period inherent in the Bacs cycle - several days between performing an action and achieving a result - makes real-time testing cumbersome.</li>\n</ul>\n","event":[{"listen":"prerequest","script":{"id":"1155b411-0579-4d1f-b478-c9f0342de1d6","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"7508ca27-e8ce-4c34-808c-cc85ef3ea360","type":"text/javascript","exec":[""]}}],"_postman_id":"d7d56cec-89dc-4fb8-96ec-c1f7cd17281c"},{"name":"3.3 Creating, updating and listing payers","item":[{"name":"3.3.1 Collection schedules","item":[],"id":"00289dbb-14a9-44e3-bd86-0e7ea4bdd4cd","description":"<p>The <em>variable</em> model supports collection schedules, whereby the collections are generated by SmartDebit. A payer's collection schedule can be specified when the payer is created and can be changed by updating the payer. </p>\n<p>Collection schedules are based on a frequency of collection defined as W (weekly), M (monthly), Q (quarterly) or Y (yearly). Service users with their own SUN are able to specify a frequency_factor between 1 and 4 inclusive. E.g. To collect once every two months, specify a frequency_factor of 2 and a frequency of M (monthly).</p>\n<p>The following parameters can be used to control the collection schedule:</p>\n<ol>\n<li>start date\n</li><li>frequency type (typically M, monthly)\n</li><li>frequency factor (optional, with certain restrictions)\n</li><li>regular amount\n</li><li>first amount (optional)\n</li><li>end date (optional)\n</li></ol>\n\n<p>A change may cause an amendment notification to be issued to the payer, giving them notice of the new schedule.</p>\n<p>Scheduled payments can be stopped or paused by setting the regular amount to zero or by setting an end date. Note that if a collection is due on the end date then it will take place. This does not cancel the payer. </p>\n<p>The end date can be used effectively to control seasonal memberships or payments spread over, say, 10 months. Just before the beginning of each season you can move the end date by one year and the collection schedule will start again. You may or may not need to move the start date as well.</p>\n<p><strong>Example:</strong> For 10 monthly payments, set the end date to (start date + 9 months). The first amount, if specified, will be collected on the start date.</p>\n<p><strong>Tip:</strong> If you change the start date, you may collect the first amount again.</p>\n<p><strong>Tip:</strong> Avoid setting a first amount of zero. Do not specify a first amount unless it is specifically required.</p>\n<p>A collection schedule can be interrupted by creating overriding collections. Refer to \"<a href=\"#5b338616-059a-46ec-a4bd-59cc7edae35a\">Creating and updating collections</a>\".</p>\n<p>SmartDebit supports collections on any day. Collections with a due date that falls on a non-working day take place on the next working day. Where a regular collection is due on a date that does not exist, the collection will take place on the 1st of the following month. </p>\n<p><strong>Example:</strong> A payer with frequency type Y (yearly) and a start date of 29 February 2016 will pay on 1 March in non-leap years.</p>\n<p><strong>Tip:</strong> For simplicity, avoid regular collections on 29th - 31st of the month if possible.</p>\n","event":[{"listen":"prerequest","script":{"id":"3280aff0-fc81-40b4-87b1-e0f079411c0f","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"ee910c24-9887-4af8-bcac-d385fbd4bfe5","type":"text/javascript","exec":[""]}}],"_postman_id":"00289dbb-14a9-44e3-bd86-0e7ea4bdd4cd"},{"name":"3.3.2 Creating payers","item":[],"id":"bd107dc8-c659-408f-96f1-1695a61cac38","description":"<p>There are two ways to create payers:</p>\n<ol>\n<li><a href=\"#fa3a7bfa-8f69-4244-ab51-0e2e121595ff\">ddi/variable/validate</a> followed by <a href=\"#d2e3ace6-4817-472e-a61c-991761e4b76d\">ddi/variable/create</a> (or <a href=\"#9050bf7f-c5c8-4c49-a192-8ae878151db2\">ddi/adhoc/validate</a> followed by <a href=\"#864f7242-2c0c-4021-86da-254e7b530930\">ddi/adhoc/create</a> as appropriate)</li>\n<li><a href=\"#ada59f4f-9f29-4c87-ba37-5db8e2d8adda\">importing a payer file</a></li>\n</ol>\n<p>If you are developing online sign-up screens then the first method is better suited.</p>\n<p>If creating payers individually, always make the validate call before making the create call. Only proceed with the create if the response from the validate indicates that Direct Debits can be collected from the account.</p>\n<p>If so configured, an email notification is issued to the payer upon creation.</p>\n<h4 id=\"reference-number\">Reference number</h4>\n<p>Bacs-compliant references can be generated by the client system or by SmartDebit. Where the API is being used to build online sign-up pages, the reference number must be generated by the client system so that it can be displayed on screen before the payer has been created. </p>\n<p>Refer to the <a href=\"#4d8a7173-5301-41e1-b171-7d4fde1fef6b\">reference number rules</a>. A simple reference numbering scheme of the format ABC12345 is effective. Excessive padding such as 000000011 is best avoided. Spaces within the reference number are best avoided.</p>\n<h4 id=\"customer-id\">Customer ID</h4>\n<p>A second reference may be specified, often referred to as \"Customer ID\". Typical use would be to link to another system such as a CRM.</p>\n<p>Customer ID can be specified in the validate/create/update calls as \"payer_reference\". In a payer file it can be specified at creation as \"reference number\" but only if the Bacs reference is generated by SmartDebit.</p>\n<p>Customer ID, which is not part of the DDI, is not subject to the same rules as the reference number. In most cases the field name is payer-reference or payer_reference (and payerReference in the data/dump response) but the collection reports present it as customer_id.</p>\n<h4 id=\"start-date\">Start date</h4>\n<p>Consider how you wish to use this parameter. It serves a number of purposes. It can be specified by the client or calculated by SmartDebit.</p>\n<ol>\n<li>It approximates to the date of lodgement for a new payer. Hence it represents the earliest possible collection date for a new payer.</li>\n<li>It plays a part in the generation of regular collections for a <em>variable</em> payer. See <a href=\"#00289dbb-14a9-44e3-bd86-0e7ea4bdd4cd\">Collection schedules</a>.</li>\n<li>If a first amount is specified for a <em>variable</em> payer, then this amount, rather than the regular amount, is collected on the payer’s start date.</li>\n<li>Because of the above, you can change a payer’s start date. Note that changing the start date of an <em>adhoc</em> payer serves no purpose.</li>\n<li>It can be used to control submission costs. Restrictions can be applied to a service user to allow only certain collection dates, which controls when new payers are submitted.<br />  <strong>Example:</strong> A service user wishes to reduce submission costs and simplify Direct Debit processing (at the expense of convenience for its payers and also the time to first collection) by allowing collections on only one day every month.<br />  Solution: The service user is configured to collect only on the first day of the month. The service user need not specify a start date; SmartDebit will calculate the earliest possible date, which will always be the 1st. New payers will all be submitted on the same day of the month (typically around the 21st), regardless of when they were created, and all collections will be submitted on the same day (typically around the 27th). Note that other submissions resulting from cancellations and account changes may take place at any time.</li>\n</ol>\n<h4 id=\"bank-details\">Bank details</h4>\n<p>The test service user accounts only accept a sort code of 000000. For a success response, choose any non-zero account number.</p>\n\n\n<p><strong>Note:</strong> The API does not support the migration of existing payers. Contact SmartDebit support for assistance.</p>\n","event":[{"listen":"prerequest","script":{"id":"24661ec1-3683-4ea3-bde9-a82fb42b6153","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"adb1bc75-5204-4347-952e-790e9a21d2cc","type":"text/javascript","exec":[""]}}],"_postman_id":"bd107dc8-c659-408f-96f1-1695a61cac38"},{"name":"3.3.3 Updating payers","item":[],"id":"b9b47f99-fe39-435d-8a3f-531c2f413d06","description":"<p>Updates to payers can be performed in two ways:</p>\n<ol>\n<li>the relevant update call (<a href=\"#42d76121-1dd6-4e0a-ab9b-6454d618b1b5\">ddi/variable/{{reference_number}}</a> or <a href=\"#5bae7530-c86e-4e23-8616-1f05708cf16e\">ddi/adhoc/{{reference_number}}</a>)</li>\n<li><a href=\"#ada59f4f-9f29-4c87-ba37-5db8e2d8adda\">importing a payer file</a></li>\n</ol>\n<p>Reference numbers cannot be changed. The update calls allow any other attribute to be changed, though restrictions may apply. Payer files cannot update bank details or frequency types. Sort code and account number are optional when using payer files to update payers; best practice is to omit them because if they do not match then the update will be rejected.</p>\n<p>The update may result in an email notification being issued to the payer.</p>\n","event":[{"listen":"prerequest","script":{"id":"cb7309a3-84ac-4f23-8d91-c606e0dc51f3","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"cc2e0d61-15cf-4fbb-8897-4abbf76d383c","type":"text/javascript","exec":[""]}}],"_postman_id":"b9b47f99-fe39-435d-8a3f-531c2f413d06"},{"name":"3.3.4 Cancelling payers","item":[],"id":"dd916b51-a4b1-4b78-a977-5b29fa4135cf","description":"<p>Payers can be cancelled in two ways:</p>\n<ol>\n<li>the relevant cancel call (<a href=\"#7795898c-fbb6-4fee-9a2b-2c9ad65c0818\">ddi/variable/{{reference_number}}/cancel</a> or <a href=\"#2920cee3-c966-4690-921d-4fcd2d5d2253\">ddi/adhoc/{{reference_number}}/cancel</a>)</li>\n<li>importing a payer file with the value \"3\" in the final column</li>\n</ol>\n<p>Cancellation may result in an email notification being issued to the payer. The cancellation will be submitted to Bacs, usually the following day.</p>\n","event":[{"listen":"prerequest","script":{"id":"6aa93780-e5dc-42c3-b2c7-81e2044806af","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"a5e12680-e922-4328-890d-5bcae336c148","type":"text/javascript","exec":[""]}}],"_postman_id":"dd916b51-a4b1-4b78-a977-5b29fa4135cf"},{"name":"3.3.5 Reinstating payers","item":[],"id":"482ab614-6d84-48cf-8515-c5daf24a3537","description":"<p>Payers can be reinstated in two ways:</p>\n<ol>\n<li>the relevant reinstate call (<a href=\"#e0acea5c-f440-40ab-9867-84b65c05f3bb\">ddi/variable/{{reference_number}}/reinstate</a> or <a href=\"#2a323a26-9acc-4f9e-8900-65e846eefd63\">ddi/adhoc/{{reference_number}}/reinstate</a>)</li>\n<li>importing a payer file with the value \"0\" in the final column</li>\n</ol>\n<p>The first method is usually preferable as the scope of the call is restricted to reinstatement and no additional fields are required.</p>\n<p>A service user may wish to reinstate a DDI in order to resume collections under the existing reference. If it is not necessary to use the same reference, it may be simpler to create a new DDI for the payer rather than reinstating.</p>\n<p>If the payer has cancelled the DDI, the service user must obtain new authorisation from the payer before reinstating.</p>\n<p>A DDI cancelled by reason codes 0 or K cannot be reinstated.</p>\n<p>If the DDI has been cancelled by SmartDebit in response to an AUDDIS advice, the DDI can be reactivated once valid bank details have been obtained from the payer. Ensure that the update follows immediately after the reinstate.</p>\n<p>Reinstatement may result in an email notification being issued to the payer. The reinstatement will be submitted to Bacs, usually the following day. The DDI cannot be collected on until 4 working days after the reinstatement is submitted.</p>\n","event":[{"listen":"prerequest","script":{"id":"5512dd9f-a3dd-44c4-973a-951b5bd7475d","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"89e906f7-8d6d-4115-8fcf-cdf34de4f0c9","type":"text/javascript","exec":[""]}}],"_postman_id":"482ab614-6d84-48cf-8515-c5daf24a3537"},{"name":"3.3.6 Listing payer information","item":[],"id":"e2b8a0c8-eb18-4ab4-977a-12b11e8ce3a6","description":"<p>There are two ways to retrieve payer details:</p>\n<ol>\n<li><a href=\"#2b78be39-712e-407c-ab49-0dc19e43e322\">data/dump</a>, either for a specified payer or for all payers </li>\n<li>the appropriate update call, but without updating anything (e.g. variable/{{reference_number}}?variable[dummy]=null)</li>\n</ol>\n<p>data/dump can be used to retrieve a listing of all payers but it can be slow to respond if you have a large number of payers, so use it with care. It can be used with a reference number parameter to return the details of a single payer. </p>\n<p>There are some differences between the format and type of information brought back by data/dump and update, which can be seen in the table below. Note that the data is only present in the returned XML if it is populated.</p>\n<table>\n<tbody>\n<tr>\n<th>Attribute</th><th>data/dump</th><th>update</th>\n</tr>\n<tr>\n<td>Title</td><td>✅</td><td>✅</td>\n</tr>\n<td>First name</td><td>✅</td><td>✅</td>\n\n<tr>\n<td>Last name</td><td>✅</td><td>✅</td>\n</tr>\n<tr>\n<td>Address 1</td><td>✅</td><td>✅</td>\n</tr>\n<tr>\n<td>Address 2</td><td>✅</td><td>✅</td>\n</tr>\n<tr>\n<td>Address 3</td><td>✅</td><td>✅</td>\n</tr>\n<tr>\n<td>Town</td><td>✅</td><td>✅</td>\n</tr>\n<tr>\n<td>County</td><td>✅</td><td>✅</td>\n</tr>\n<tr>\n<td>Post code</td><td>✅</td><td>✅</td>\n</tr>\n<tr>\n<td>Country</td><td>❌</td><td>✅</td>\n</tr>\n<tr>\n<td>Frequency type</td><td>✅</td><td>✅</td>\n</tr>\n<tr>\n<td>Frequency factor</td><td>✅</td><td>✅</td>\n</tr>\n<tr>\n<td>Regular/default amount</td><td>✅</td><td>✅</td>\n</tr>\n<tr>\n<td>First amount</td><td>✅</td><td>✅</td>\n</tr>\n<tr>\n<td>Reference number</td><td>✅</td><td>✅</td>\n</tr>\n<tr>\n<td>Payer reference</td><td>✅</td><td>✅</td>\n</tr>\n<tr>\n<td>Start date</td><td>✅</td><td>✅</td>\n</tr>\n<tr>\n<td>End date</td><td>❌</td><td>✅</td>\n</tr>\n<tr>\n<td>Email address</td><td>✅</td><td>✅</td>\n</tr>\n<tr>\n<td>Support gift aid</td><td>✅</td><td>✅</td>\n</tr>\n<tr>\n<td>Promotion</td><td>❌</td><td>✅</td>\n</tr>\n<tr>\n<td>Company name</td><td>❌</td><td>✅</td>\n</tr>\n<tr>\n<td>Current state</td><td>✅</td><td>❌</td>\n</tr>\n<tr>\n<td>Date/time of cancellation</td><td>❌</td><td>✅</td>\n</tr>\n<tr>\n<td>List of collections</td><td>❌</td><td>✅</td>\n</tr>\n<tr>\n<td>In addition the following details may be provided when a single payer dump is requested, subject to service user configuration.</td>\n</tr>\n<tr>\n<td>Account name</td><td>✅</td><td>❌</td>\n</tr>\n<tr>\n<td>Account number</td><td>✅</td><td>❌</td>\n</tr>\n<tr>\n<td>Sort code</td><td>✅</td><td>❌</td>\n</tr>\n</tbody>\n</table>\n\n<p>A payer's audit history can be retrieved with the <a href=\"#5bdf8c47-d604-4a15-95b5-8c2da05899aa\">data/auditlog</a> call.</p>\n","event":[{"listen":"prerequest","script":{"id":"4b13037a-46a8-4909-b99a-73fe1c2ecb08","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"68ca1791-f742-40a3-8fad-092a68386a48","type":"text/javascript","exec":[""]}}],"_postman_id":"e2b8a0c8-eb18-4ab4-977a-12b11e8ce3a6"}],"id":"1b2343bd-e19a-4d5a-8fce-1ba5866dd358","description":"","event":[{"listen":"prerequest","script":{"id":"8cc7dd27-6898-42f9-93cd-0acf75b16b2e","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"383dfda8-c4e1-4242-8083-ca8f99743f99","type":"text/javascript","exec":[""]}}],"_postman_id":"1b2343bd-e19a-4d5a-8fce-1ba5866dd358"},{"name":"3.4 Creating and updating collections","item":[],"id":"5b338616-059a-46ec-a4bd-59cc7edae35a","description":"<h4 id=\"methods\">Methods</h4>\n<ul>\n<li>Scheduling payments for <em>variable</em> payers is described <a href=\"#00289dbb-14a9-44e3-bd86-0e7ea4bdd4cd\">above</a>.</li>\n<li>The create and update calls (both <em>variable</em> and <em>adhoc</em>) can be used with extended parameters to create collections or to change the amounts of existing collections.</li>\n<li>Collection files can be imported.</li>\n<li>Some failed collections can be re-presented, as described below.</li>\n<li>The Pulse web portal offers similar functionality.</li>\n</ul>\n<h4 id=\"time-constraints\">Time constraints</h4>\n<p>Collections can be created or updated from the moment the payer is created up until the day prior to submission. Submission takes place a few days before the due date (the exact interval is configurable for the service user - the \"collection lead time\" - and is usually determined by the service user's advance notice period, as stipulated by their sponsoring bank). Allow for this lead time and for the submission day when creating collections.</p>\n<p><strong>Example:</strong> For a service user with a 3 working-day lead time, a collection due on a Monday must be in the SmartDebit system by the end of the previous Tuesday on a normal working week.</p>\n<h4 id=\"restrictions\">Restrictions</h4>\n<p>Collections cannot be due before the payer's start date or after their end date (if one has been specified). These restrictions may be lifted in a future release. Otherwise there is no limit to how far in the future a collection may be due.</p>\n<p>Restrictions on due dates can be applied and are configurable, specifically:</p>\n<ul>\n<li>they can be restricted to certain days of the month</li>\n<li>they can be restricted to the payer's scheduled dates only</li>\n</ul>\n<p>Collections cannot be for an amount greater than a maximum configured for the service user.</p>\n<p>SmartDebit supports only one collection per payer per day (except for re-presents). Importing multiple collections due on the same day for the same payer will cause subsequent collection imports to overwrite previous ones. </p>\n<p>The API does not have a method to add to an existing collection. </p>\n<p>Collections cannot be deleted. They can, though, be changed so the amount is zero.</p>\n<h4 id=\"payment-schedules\">Payment schedules</h4>\n<p>If a collection is added that coincides with the payer's schedule then it overrides the schedule: it is collected instead of, not as well as, the regular payment. An overriding collection with an amount of zero suppresses the regular payment. </p>\n<h4 id=\"collection-references\">Collection references</h4>\n<p>If you use collection files to import collections then you can specify a unique identifier for each collection. Note that the full reference (core reference plus hyphen plus collection reference) must be a maximum of 18 characters. If the collection fails then the ARUDD advice contains this full reference, making it easier to match the failed payment in the client system.</p>\n<p><strong>Example:</strong> Mr Smith has an account with a local business and pays by Direct Debit. His account number, SMIT05, is also the reference number of his DDI. Invoice number INV6789, for £123.45 is due on 1 September. This could be denoted by the following collection file entry:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>,SMIT05,123.45,2019/09/01,,SMIT05-INV6789,\n</code></pre><p>This would then would be reported by the following reconciliation report entry:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>    &lt;Success account_name=\"Mr Smith\" customer_id=\"\" amount=\"123.45\" transaction_ref=\"SMIT05-INV6789\" reference_number=\"SMIT05\" debit_date=\"01/09/2019 00:00\"/&gt;\n</code></pre><h4 id=\"failures\">Failures</h4>\n<p>Common reasons why collection(s) fail to be created:</p>\n<ul>\n<li>Not allowing enough time for submission (i.e. too late)</li>\n<li>The payer is in a cancelled state</li>\n<li>The date of the debit does not conform to the configured allowable dates for the service user</li>\n<li>You cannot create a debit that is due before the payer's start date (or after the payer's end date).</li>\n</ul>\n","event":[{"listen":"prerequest","script":{"id":"c3782909-5d96-4d09-b6d7-f94466c9e82a","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"432d8ca2-4710-44fa-a231-e5e69d2da589","type":"text/javascript","exec":[""]}}],"_postman_id":"5b338616-059a-46ec-a4bd-59cc7edae35a"},{"name":"3.5 Reconciling payments","item":[],"id":"db95498a-da4c-4a3f-b426-611299eac96f","description":"\n\n<p>On the day of submission, SmartDebit notifies the service user by email, supplying a list of collections being submitted. <a href=\"#2f6356dc-6e65-41fd-ad5f-7ef61521b2f3\">get_collection_report</a> provides a similar list, however it may also include some collections that are not submitted. This report:</p>\n<ul>\n<li>is available prior to the collection date</li>\n<li>lists what will be or has been submitted for collection</li>\n<li>does not include collections generated by the system (i.e. <em>variable</em> payers with regular amounts) until the day of submission</li>\n<li>may include rejections, though these may not be apparent until after the day of submission (e.g. where a transaction was rejected by Bacs, before reaching the payer’s bank)</li>\n<li>may also list some collections that have not been submitted</li>\n</ul>\n<p>In general, where a payer cancels before submission, the collection is not reported. This behaviour may change.</p>\n<p>Submission does not guarantee payment. Failed collections are reported as ARUDD advices in the days following the due date. ARUDD advices originate from the paying banks and are made available by the API and in the Pulse web portal. For further guidance on handling ARUDDs, see <a href=\"#52a32c1d-df44-4c1e-ae60-45d9e8094058\">below</a>.</p>\n<p>Alternatively, <a href=\"#efceb3f7-3bb8-4af9-b126-f8f912bb5fc7\">get_successful_collection_report</a> lists collections for a given date together with their status. This report:</p>\n<ul>\n<li>is effectively the collection report which has had ARUDD notifications applied to it</li>\n<li>is available from the third working day after the collection date</li>\n<li>includes (as failed) some collections that were not submitted or failed to reach the paying bank</li>\n<li>does not (currently) provide the reason for a failed payment but that information is provided by the ARUDD</li>\n</ul>\n<p>The three-day delay allows for ARUDD advices. In rare, exceptional cases (occasionally around Christmas or Easter or with an obscure paying bank) an ARUDD may be received late, even after three working days. get_successful_collection_report gives an up-to-date result so you may wish to consider calling it again, say a week later.</p>\n<p>Rather than work out when the reconciliation report will be available, you could simply ask for it every day after the collection date until it is available. You’ll get an error response if you are too early.</p>\n<p>Whilst this report gives a fairly definitive list of successful collections, it does not give a complete list of failures because collections are not reported if the payer cancelled prior to submission (or if the import into SmartDebit failed).</p>\n","event":[{"listen":"prerequest","script":{"id":"3d7bc6d1-acd8-454a-9915-1b9b484e7131","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"fa7511ec-8aba-4b0e-bcbf-c6a52b5a2572","type":"text/javascript","exec":[""]}}],"_postman_id":"db95498a-da4c-4a3f-b426-611299eac96f"},{"name":"3.6 Handling Bacs reports","item":[{"name":"3.6.1 AUDDIS advices","item":[],"id":"494b728c-29e8-415e-bf0d-8a79f645923e","description":"<p>There are two principal AUDDIS transactions:</p>\n<ol>\n<li>a \"0N\" transaction, which is an instruction to the payer's bank to set up or \"lodge\" a DDI</li>\n<li>a \"0C\" transaction, which is an instruction to the payer's bank to cancel a DDI</li>\n</ol>\n<p>When a payer changes their bank account the DDI is simply cancelled at one bank and lodged at the other.</p>\n<p>An AUDDIS advice is a notification from Bacs or from a bank that an AUDDIS transaction has failed or has been amended. Appropriate handling depends firstly on the service user's business processes, secondly on the type of transaction that caused the advice to be issued and thirdly on the <a href=\"#4855180e-d792-4547-bf87-667881b138bb\">reason code</a>. Some general principles apply:</p>\n<ul>\n<li>advices arising from cancellations can be ignored</li>\n<li>advices from the old bank can be ignored</li>\n<li>advices where new account details are provided are handled by SmartDebit and can be ignored (unless you need to update your record of the account details)</li>\n<li>otherwise, AUDDIS advices generally indicate that a DDI is uncollectible</li>\n</ul>\n<p>The <a href=\"#81d043f2-55ef-42cd-a32a-e2f06bc843bc\">auddis/{{id}}</a> response does not currently include the transaction type so it can be difficult to follow these principles but looking to see whether the DDI is still live may help. The DDI may have been cancelled by SmartDebit to prevent any submissions against a DDI that is known to be invalid. If this is the case, valid bank details will be required from the payer. The DDI can be reinstated and then updated, or a new DDI can be set up with a different reference number (depending on what has been agreed with the payer).</p>\n","event":[{"listen":"prerequest","script":{"id":"7b7ff90c-f9eb-4a2c-bb23-3f68fcd7866b","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"87f877ee-43a0-44f3-8e0a-1d1e60265ecd","type":"text/javascript","exec":[""]}}],"_postman_id":"494b728c-29e8-415e-bf0d-8a79f645923e"},{"name":"3.6.2 ADDACS advices","item":[],"id":"3bf549dc-98cb-4b94-b56c-0c837e68afe7","description":"<p>An ADDACS advice is a notification from a bank of an amendment to or cancellation of a DDI. Such advices may be received at any time.</p>\n<p>Appropriate handling depends firstly on the service user's business processes and secondly on the reason code. Some general principles apply:</p>\n<ul>\n<li>advices from another bank can be ignored</li>\n<li>advices where new account details are provided are handled by SmartDebit and can be ignored (unless you need to update your record of the account details)</li>\n</ul>\n<p>SmartDebit updates its record of the DDI, marking it as cancelled where appropriate.</p>\n","event":[{"listen":"prerequest","script":{"id":"693fed01-f1ec-48b7-9058-de87c8897f11","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"53110870-4998-4c6c-bb21-bf2ad538f7a0","type":"text/javascript","exec":[""]}}],"_postman_id":"3bf549dc-98cb-4b94-b56c-0c837e68afe7"},{"name":"3.6.3 ARUDD advices","item":[],"id":"52a32c1d-df44-4c1e-ae60-45d9e8094058","description":"<p>An ARUDD advice is a notification from a bank of a failed collection. The advice gives the reason for the failure.</p>\n<p>The majority of ARUDD advices are received the working day after the collection takes place (which may itself be the working day after the due date if the due date falls on a non-working day). Some may be received a day later. In rare, exceptional cases (occasionally around Christmas or Easter or with an obscure paying bank) an ARUDD may be received late, even after three working days.</p>\n<p>Advices can be matched to collections by the \"ref\", \"valueOf\" and \"originalProcessingDate\" values. If unique collection references are used then these are returned as the \"ref\", otherwise the reference number of the DDI is given. The \"valueOf\" matches the collection amount exactly and the \"originalProcessingDate\" should be the working day before the collection's due date. Occasionally the \"originalProcessingDate\" might be later than expected.</p>\n<p>Occasionally SmartDebit receives ARUDD advices where, due to bank error, the \"ref\" value does not match a DDI. SmartDebit performs routine data integrity checks to catch such anomalies.</p>\n<p>The two most common reasons for a failed collection are:</p>\n<ol>\n<li>the payer has insufficient funds, or</li>\n<li>the payer has cancelled the DDI</li>\n</ol>\n<p>A complete list of failure reasons is given <a href=\"#4855180e-d792-4547-bf87-667881b138bb\">below</a> and more information can be found <a href=\"https://smartdebithelp.zendesk.com/hc/en-us/articles/208257275-All-you-need-to-know-about-Bacs-Reports\">here</a>.</p>\n","event":[{"listen":"prerequest","script":{"id":"a103dc5e-7dfa-4a93-b816-35e375586699","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"6d91e829-c2a7-473b-bc87-a936c23ec51e","type":"text/javascript","exec":[""]}}],"_postman_id":"52a32c1d-df44-4c1e-ae60-45d9e8094058"},{"name":"3.6.4 DDICA advices","item":[],"id":"0afc58a1-08d9-4ea5-88e9-53250cb90c03","description":"<p>A DDICA advice is a notification from a bank that a payer is claiming back one or more collections that have previously been paid.</p>\n<p>The claimed funds are returned automatically three weeks after the advice is issued.</p>\n<p>A DDICA may be cancelled before the funds are returned. DDICA cancellations are made available in the Pulse web portal but not by the API.</p>\n","event":[{"listen":"prerequest","script":{"id":"818938a5-1b7d-4883-8ed2-86adeda2703a","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"6116cceb-9bf7-4a30-9043-05de3032b2c8","type":"text/javascript","exec":[""]}}],"_postman_id":"0afc58a1-08d9-4ea5-88e9-53250cb90c03"}],"id":"d43dbd15-0e03-4120-b93e-d62ab74d78ec","description":"<p>Bacs reports are issued by Bacs to notify service users of changes or errors with their payers. They advise of failed and claimed collections, cancellations and amendments. They work on the exception principle: successful transactions and unchanged DDIs are not reported.</p>\n<p>Bacs reports contain one or more advices.</p>\n<p>The API supports only the Direct Debit report types. Should you also require Direct Credit reports, SmartDebit can supply all report types by SFTP.</p>\n<p>The SmartDebit system retrieves reports, making them available to API clients. The following changes are applied to payers:</p>\n<ul>\n<li>bank details may be updated</li>\n<li>payers may be cancelled in response to cancellation notifications</li>\n<li>payers may be cancelled where a DDI failed to lodge and is therefore uncollectible</li>\n<li>payers may be reinstated</li>\n</ul>\n<p><strong>Sandbox environment</strong>: Test service users do not receive reports as they are isolated from Bacs but Bacs reports can be simulated. Contact <a href=\"mailto:support@smartdebit.com?Subject=Test%20Bacs%20reports\">support@smartdebit.com</a> with your requirements once you have a suitable set of payers and collections.</p>\n<p>Broadly, one of three approaches may be taken to Bacs reports:</p>\n<ol>\n<li>Leave the SmartDebit system to handle them</li>\n</ol>\n<ul>\n<li>in most cases this is not the most suitable approach<br /></li>\n</ul>\n<ol>\n<li>Manage them manually, via the Pulse web portal</li>\n</ol>\n<ul>\n<li>if you have a small number of payers and/or collect infrequently</li>\n<li>if you intend to integrate quickly and develop your application as the business develops<br /></li>\n</ul>\n<ol>\n<li>Automate the download and processing</li>\n</ol>\n<ul>\n<li>the approach most suited to API users, your exact requirements will depend on your business</li>\n</ul>\n<p><strong>Automated processing:</strong>\nThe recommended method is to check daily (though SmartDebit processes new reports only on business days) and to query by ID rather than by date. The report ID values are different for each report type and are not contiguous but always increase. Note that when more than one report is returned, they are listed in reverse order. Therefore, for each report type:</p>\n<ul>\n<li>keep a record of the last report ID </li>\n<li>add one to the last report ID and use this as the \"query[id_from]\" value</li>\n<li>retrieve and process all the reports returned by the list call</li>\n<li>retain the maximum ID value of the retrieved reports for use next time</li>\n</ul>\n<p>This method ensures that all new reports are processed once only. Querying by date can be unreliable.</p>\n<p>Further detail of the different types is given below. </p>\n","event":[{"listen":"prerequest","script":{"id":"34d57e32-e82a-49b3-881a-472d13ad11fe","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"d602e594-82ee-4f99-b36a-de01421da5ab","type":"text/javascript","exec":[""]}}],"_postman_id":"d43dbd15-0e03-4120-b93e-d62ab74d78ec"},{"name":"3.7 Re-presenting failed collections","item":[],"id":"48a6cabb-7bea-4d97-8989-c2e21906ddbd","description":"<p>Failed collections can, under some circumstances, be re-presented.</p>\n<ul>\n<li>You can only re-present collections that failed with reason code 0 (\"refer to payer\").</li>\n<li>The re-present must be within one calendar month of the original failed collection.</li>\n<li>The API only allows a single re-presentation.</li>\n</ul>\n<p>You can identify failed collections either by the rejects node of the <a href=\"#efceb3f7-3bb8-4af9-b126-f8f912bb5fc7\">reconciliation report</a> or directly from the ARUDDs. The reconciliation report gives you the reference number, debit date and amount of the failed debit that you need for the <a href=\"#b1f50b7f-9a04-4400-b435-5efb8210123d\">re-present call</a> but does not provide the failure reason. The ARUDD gives reference number, amount and the failure reason but does not give the debit date, which can be awkward to find because a debit scheduled for Saturday, Sunday and Monday all have the same ARUDD original processing date. Assuming you process your ARUDDs on the day they are issued, you could try with yesterday's date and if that fails, try again with the previous day, up to a maximum of six attempts to accommodate Easter and Christmas and late ARUDDs.</p>\n<p>SmartDebit allows a re-presentation to take place on the same day as a normal collection. This helps to keep submission costs down.</p>\n<p>A specific advance notice email may be issued to the payer. </p>\n","event":[{"listen":"prerequest","script":{"id":"cacca151-f457-4185-9e40-e1a347ea5dc1","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"4d6a7420-897a-4c2c-a4fa-2b0ccfcbd602","type":"text/javascript","exec":[""]}}],"_postman_id":"48a6cabb-7bea-4d97-8989-c2e21906ddbd"}],"id":"e373ec84-e3d1-4f95-8618-2b2711eeccef","event":[{"listen":"prerequest","script":{"id":"e6be6c24-3454-4447-8fbf-eb06e5ff3fa2","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"bc88bf1c-eab6-485e-8fcb-310e392bc8ca","type":"text/javascript","exec":[""]}}],"_postman_id":"e373ec84-e3d1-4f95-8618-2b2711eeccef","description":""},{"name":"4 API call reference","item":[{"name":"4.1 System status","item":[{"name":"system_status","event":[{"listen":"test","script":{"id":"e4b284a4-afcb-4b93-b93e-09972521b132","exec":["let api_user = pm.environment.get(\"api_user\");","let api_login_line = \"<login>\" + api_user +\"</login>\";","","pm.test(\"Body contains User Name\", function () {","    pm.expect(pm.response.text()).to.include(\"<api_version>1.1</api_version>\");","    pm.expect(pm.response.text()).to.include(api_login_line);","    var jsonObject = xml2Json(responseBody);","    if(jsonObject.assigned_service_users !== undefined && jsonObject.assigned_service_users.length === 1)","    {return true;}","    else{","        return 'no service user has been assigned to this api user';","    }","});","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","pm.test(\"Response time is less than 200ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(200);","});","","","","pm.environment.set(\"new_api_system_status\", pm.response.text());","","","pm.globals.set('object_comparer',\"function CompareObject(a,b,iteration){    if(iteration === undefined || iteration === null)    {iteration = 0;}    console.log(iteration+'. iteration');    var aKeys = Object.keys(a);    for(var key in aKeys)    {        var theKey = aKeys[key];        console.log(aKeys[key]);        console.log(theKey);        console.log(a[theKey]);        console.log(typeof(a[theKey]));        if(typeof(a[theKey]) === 'object')        {            var innerResult = CompareObject(a[theKey],b[theKey], iteration + 1);            if (!innerResult)            {return false;}        }        else{            if(a[theKey] !== b[theKey])            {                console.log('Value in CompareObject does not match! Property name: '+theKey+ ' values: a: '+a[theKey] + ' b: ' +b[theKey]);                return false;            }        }    }    return true;}\");"],"type":"text/javascript"}}],"id":"00d989b0-dc35-4a14-89a2-8db6d0c5bdf6","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"GET","header":[],"url":"{{base_url}}/system_status","description":"","urlObject":{"path":["system_status"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"eeabc44a-3695-49be-b5e0-37b9ce31343a","name":"GET system_status","originalRequest":{"method":"GET","header":[],"url":"{{base_url}}/system_status"},"status":"OK","code":200,"_postman_previewlanguage":"xml","header":[{"key":"Date","value":"Tue, 12 Feb 2019 09:44:05 GMT"},{"key":"Server","value":"Apache"},{"key":"X-Runtime","value":"0.03424"},{"key":"Cache-Control","value":"private, max-age=0, must-revalidate"},{"key":"Strict-Transport-Security","value":"max-age=63072000; includeSubdomains; preload"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Set-Cookie","value":"auth_token=; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"_PSLLite_session_id=59c10b241683faff8f68dab95c0ecf7c; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"incap_ses_454_1416256=a; Max-Age=0; path=/; expires=Sun, 10 Feb 2019 12:32:10 GMT; Domain=.ddprocessing.co.uk"},{"key":"Set-Cookie","value":"visid_incap_1416256=4h7evyKJTXSSsaQGR66ZrXVk9VsAAAAAQUIPAAAAAACBaPf/JRsV9YGl7yOZH4ea; expires=Tue, 11 Feb 2020 12:34:45 GMT; path=/; Domain=.ddprocessing.co.uk"},{"key":"Set-Cookie","value":"incap_ses_368_1416256=T8syeFh8EGdHAdXkmmYbBX2VYlwAAAAArzUpwTPxQZ8WWDABQUwucw==; path=/; Domain=.ddprocessing.co.uk"},{"key":"Set-Cookie","value":"___utmvboNuBZVNB=a; Max-Age=0; path=/; expires=Sun, 10 Feb 2019 12:32:10 GMT"},{"key":"Set-Cookie","value":"___utmvmoNuBZVNB=a; Max-Age=0; path=/; expires=Sun, 10 Feb 2019 12:32:10 GMT"},{"key":"Content-Length","value":"285"},{"key":"Status","value":"200 OK"},{"key":"X-XSS-Protection","value":"1; mode=block"},{"key":"Keep-Alive","value":"timeout=5, max=99"},{"key":"Connection","value":"Keep-Alive"},{"key":"Content-Type","value":"application/xml; charset=utf-8"},{"key":"X-Iinfo","value":"7-4609959-4609970 SNNN RT(1549964669619 3341) q(0 0 0 -1) r(1 1) U5"},{"key":"X-CDN","value":"Incapsula"}],"cookie":[],"responseTime":null,"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<successful>\n    <api_version>1.1</api_version>\n    <user>\n        <login>documentationapi</login>\n        <assigned_service_users>\n            <service_user>\n                <pslid>apidocument</pslid>\n            </service_user>\n        </assigned_service_users>\n    </user>\n</successful>"}],"_postman_id":"00d989b0-dc35-4a14-89a2-8db6d0c5bdf6"}],"id":"7e74d88c-7f36-43d8-9229-deb16e50bf2a","description":"<p>The <a href=\"#00d989b0-dc35-4a14-89a2-8db6d0c5bdf6\">system_status</a> call allows an API user to query the latest version of the API and to obtain a listing of which service users are assigned to them. The call is a simple way to verify credentials.</p>\n<p>The call requires no parameters. All versions of the call return the same response.</p>\n<h4 id=\"response\">Response</h4>\n<p>A successful call to system_status returns an XML document containing:</p>\n<ul>\n<li>the latest available API version</li>\n<li>the user's login name</li>\n<li>a list of pslid values corresponding to the service users accessible to the user</li>\n</ul>\n<h4 id=\"errors\">Errors</h4>\n<ul>\n<li><h6>Invalid credentials:</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>401 Unauthorized\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Could not authenticate you&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<li><h6>User is not an API user:</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>401 Unauthorized\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Permission denied. You cannot access the requested resource.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<li><h6>Access denied due to IP restriction:</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>401 Unauthorized\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Attempted access from unknown IP address 'xxx.xxx.xxx.xxx'&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n</ul>\n\n<p>If the user is not assigned to any service users the &lt;assigned_service_users&gt; node is empty. If this is the case then no other functionality is available.</p>\n<p>Contact <a href=\"mailto:support@smartdebit.com?Subject=API%20authentication%20error\">support@smartdebit.com</a> if you encounter any of these responses.</p>\n<p>The above authorisation errors are common to all endpoints.</p>\n","event":[{"listen":"prerequest","script":{"id":"a262742b-eb8a-43aa-8a60-7069d5806099","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"052c55bb-eed4-4d7a-81ee-dd6c36236af8","type":"text/javascript","exec":[""]}}],"_postman_id":"7e74d88c-7f36-43d8-9229-deb16e50bf2a"},{"name":"4.2 Payer actions","item":[{"name":"4.2.1 Variable validate","item":[{"name":"ddi/variable/validate","event":[{"listen":"test","script":{"id":"7479e859-00c9-415f-a498-91eacef639b1","exec":["eval(pm.globals.get('jasmine'));","","pm.test(\"Response time is less than 800ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(800);","});","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","var jsonObject = xml2Json(responseBody);","console.log(JSON.stringify(jsonObject));","","","var schema = sd.api.schema.validateResponse;","","console.log(schema);","pm.test('Schema is valid', function() {","  pm.expect(tv4.validate(jsonObject, schema)).to.be.true;","});"],"type":"text/javascript"}},{"listen":"prerequest","script":{"id":"07c7f8ac-60eb-4064-889c-b57e0966a1c4","exec":["pm.sendRequest(\"https://sandbox.smartdebit.co.uk/Scripts/smartdebit.jasmine.js\", (err, res) => { pm.globals.set('jasmine' ,res.text() ) });","","eval(pm.globals.get('jasmine'));","","","var dataGen = sd.testing;","","var startDate = new Date();","startDate.setHours(0,0,0,0);","startDate = startDate.addMonths(2);","","var endDate = new Date();","endDate.setHours(0,0,0,0);","endDate = endDate.addMonths(6);","","var payer = dataGen.getJsonPayer(pm.environment.get('pslid'), dataGen.getReferenceNumber('SD1'), 3, false, false, true);","","console.log(payer);","","pm.environment.set('validate_reference_number','API-Test-0123');  //should not exist","pm.environment.set('validate_adhoc_title', payer.title);","pm.environment.set('validate_first_name', payer.first_name);","pm.environment.set('validate_last_name', payer.last_name);","pm.environment.set('validate_adhoc_company_name', 'Acme Co.');","pm.environment.set('validate_address1', payer.address_1);","pm.environment.set('validate_adhoc_address2', payer.address_2);","pm.environment.set('validate_adhoc_address3', payer.address_3);","pm.environment.set('validate_town', payer.town);","pm.environment.set('validate_adhoc_county', payer.county);","pm.environment.set('validate_postcode', payer.postcode);","pm.environment.set('validate_country', payer.country);","pm.environment.set('validate_frequency_type', 'M');","pm.environment.set('validate_default_amount', '1000');","pm.environment.set('validate_first_amount', '2000');","","pm.environment.set('validate_adhoc_email_address', payer.email);","","pm.environment.set('validate_adhoc_start_date', dataGen.getISODate(startDate));","pm.environment.set('validate_adhoc_end_date', dataGen.getISODate(endDate));","pm.environment.set('validate_sort_code', '000000');","pm.environment.set('validate_account_number', '12345678');","pm.environment.set('validate_adhoc_promotion', 'PROMO');","","pm.environment.set('validate_adhoc_payer_reference', payer.account_number);","pm.environment.set('validate_account_name', payer.account_name);","","","console.log(dataGen.getISODate(startDate));","console.log(dataGen.getISODate(endDate));","","","","","","","",""],"type":"text/javascript"}}],"id":"232815a9-a9f8-4889-856a-12cdc5c83cb4","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"description":"<p><i>Required</i><br />\nService user identifier</p>\n","key":"variable_ddi[service_user][pslid]","type":"text","value":"{{pslid}}"},{"description":"<p><i>Conditional (usually required)</i><br />\nUnique identifier for the DDI<br />\n<b>Format:</b> 6 to 18 characters. See <a href=\"#4d8a7173-5301-41e1-b171-7d4fde1fef6b\">reference number rules</a>.</p>\n","key":"variable_ddi[reference_number]","type":"text","value":"{{validate_reference_number}}"},{"description":"<p><i>Required</i><br />\n<b>Format:</b> single character only (W, M, Q, Y)</p>\n","key":"variable_ddi[frequency_type]","type":"text","value":"{{validate_frequency_type}}"},{"description":"<p><i>Required</i><br />\n<b>Format:</b> either 111111 or 11-11-11</p>\n","key":"variable_ddi[sort_code]","type":"text","value":"{{validate_sort_code}}"},{"description":"<p><i>Required</i><br />\n<b>Format:</b> 8 digit number</p>\n","key":"variable_ddi[account_number]","type":"text","value":"{{validate_account_number}}"},{"description":"<p><i>Required</i><br />\n<b>Format:</b> 3 to 18 characters </p>\n","key":"variable_ddi[account_name]","type":"text","value":"{{validate_account_name}}"},{"description":"<p><i>Required</i><br />\n<b>Format:</b> 1 to 32 characters</p>\n","key":"variable_ddi[first_name]","type":"text","value":"{{validate_first_name}}"},{"description":"<p><i>Required</i><br />\n<b>Format:</b> 1 to 32 characters</p>\n","key":"variable_ddi[last_name]","type":"text","value":"{{validate_last_name}}"},{"key":"variable_ddi[start_date]","value":"{{validate_start_date}}","description":"<p><b>Format:</b> YYYY-MM-DD<br /><b>Default:</b> next valid start date</p>\n","type":"text"},{"description":"<p>If used, specifies the date after which no further collections will be made<br /><b>Format:</b> YYYY-MM-DD  <br /><b>Default:</b> none</p>\n","key":"variable_ddi[end_date]","type":"text","value":"{{validate_end_date}}"},{"description":"<p><b>Format:</b> integer, the value of the regular collection amount <i>in pence</i></p>\n","key":"variable_ddi[default_amount]","type":"text","value":"{{validate_default_amount}}"},{"description":"<p>If provided, this value is used on the start date only, in place of the default amount<br /><b>Format:</b> integer, the value of the first collection amount <i>in pence</i></p>\n","key":"variable_ddi[first_amount]","type":"text","value":"{{validate_first_amount}}"},{"key":"variable_ddi[frequency_factor]","value":"{{validate_frequency_factor}}","description":"<p>Frequency factors 2, 3 and 4 cannot be used with frequency type Y<br /><b>Format:</b> integer, 1 to 4<br /><b>Default:</b> 1</p>\n","type":"text"},{"description":"<p><b>Format:</b> 1 to 32 characters</p>\n","key":"variable_ddi[title]","type":"text","value":"{{validate_title}}"},{"description":"<p><b>Format:</b> 5 to 64 characters</p>\n","key":"variable_ddi[email_address]","type":"text","value":"{{validate_email_address}}"},{"description":"<p><b>Format:</b> 1 to 32 characters</p>\n","key":"variable_ddi[company_name]","type":"text","value":"{{validate_company_name}}"},{"description":"<p><b>Format:</b> 1 to 255 characters</p>\n","key":"variable_ddi[payer_reference]","type":"text","value":"{{validate_payer_reference}}"},{"description":"<p><b>Format:</b> 1 to 255 characters</p>\n","key":"variable_ddi[address_1]","type":"text","value":"{{validate_address1}}"},{"description":"<p><b>Format:</b> 1 to 32 characters</p>\n","key":"variable_ddi[address_2]","type":"text","value":"{{validate_address2}}"},{"description":"<p><b>Format:</b> 1 to 32 characters</p>\n","key":"variable_ddi[address_3]","type":"text","value":"{{validate_address3}}"},{"description":"<p><b>Format:</b> 1 to 255 characters</p>\n","key":"variable_ddi[town]","type":"text","value":"{{validate_town}}"},{"description":"<p><b>Format:</b> 1 to 255 characters</p>\n","key":"variable_ddi[county]","type":"text","value":"{{validate_county}}"},{"description":"<p><b>Format:</b> 1 to 255 characters</p>\n","key":"variable_ddi[postcode]","type":"text","value":"{{validate_postcode}}"},{"description":"<p><b>Format:</b> 1 to 255 characters</p>\n","key":"variable_ddi[country]","type":"text","value":"{{validate_country}}"},{"key":"variable_ddi[support_gift_aid]","value":"{{validate_support_gift_aid}}","description":"<p><b>Format:</b> boolean, accepts 'true', 'false', 1 or 0<br /><b>Default:</b> false</p>\n","type":"text"},{"description":"<p><b>Format:</b> 1 to 8 characters</p>\n","key":" variable_ddi[promotion]","type":"text","value":"{{validate_promotion}}"}]},"url":"{{base_url}}/ddi/variable/validate","urlObject":{"path":["ddi","variable","validate"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"9146cf5a-6d91-4b6f-a620-d3215d5b6965","name":"validate","originalRequest":{"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"description":"<b>Format: Sort Code – either 111111 or 11-11-11 format accepted.</b>","key":"variable_ddi[sort_code]","type":"text","value":"{{validate_sort_code}}"},{"description":"<b>Format: 8 digit number </b>","key":"variable_ddi[account_number]","type":"text","value":"{{validate_account_number}}"},{"description":"<b>A unique reference number must be passed.    <br>Format: plain text Restrictions: Unique, 6 to 18 characters May not contain solidus (/)  and further restrictions apply.</b>","key":"variable_ddi[reference_number]","type":"text","value":"{{validate_reference_number}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"variable_ddi[first_name]","type":"text","value":"{{validate_first_name}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"variable_ddi[last_name]","type":"text","value":"{{validate_last_name}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"variable_ddi[address_1]","type":"text","value":"{{validate_address1}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"variable_ddi[town]","type":"text","value":"{{validate_town}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"variable_ddi[postcode]","type":"text","value":"{{validate_postcode}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"variable_ddi[country]","type":"text","value":"{{validate_country}}"},{"description":"<b>Format: 8 digit number. <br>Typical sort code and account numbers to use from a test account are 000000 for the sort code and 12345678 for the account number. </b>","key":"variable_ddi[account_name]","type":"text","value":"{{validate_account_name}}"},{"description":"<b>Format: plain text   <br>Restrictions: 5 to 255 characters, must match existing SU's pslid </b>","key":"variable_ddi[service_user][pslid]","type":"text","value":"{{pslid}}"},{"description":"<b>Format: Single Character – (W, M, Q, Y)  Restrictions: Must be a frequency type configured on the SU </b>","key":"variable_ddi[frequency_type]","type":"text","value":"{{validate_frequency_type}}"},{"description":"<b>Format: Integer, the value of the default amount <i>in pence</i>.  <br>Restrictions: value between 0 and the SU's maximum_debit_amount </b>","key":"variable_ddi[default_amount]","type":"text","value":"{{validate_default_amount}}"},{"description":"<b>Format: Integer, the value of the first amount <i>in pence</i>.  <br>Restrictions: value between 0 and the SU‟s maximum_debit_amount </b>","key":"Variable_ddi[first_amount]","type":"text","value":"{{validate_first_amount}}"},{"description":"<b>Format: plain text <br>Restrictions: 0 to 18 characters  <br>Default: none </b>","key":"variable_ddi[payer_reference]","type":"text","value":"{{validate_adhoc_payer_reference}}"},{"description":"<b>Format: YYYY-MM-DD   <br>Restrictions: Must be far enough in the future to allow the SU's lead time.</b>","key":"variable_ddi[start_date]","type":"text","value":"{{validate_adhoc_start_date}}"},{"description":"<b>Format: YYYY-MM-DD  <br>Restrictions: Must be after the start time, not required to fall on a debit day.  <br>Default: none</b>","key":"variable_ddi[end_date]","type":"text","value":"{{validate_adhoc_end_date}}"},{"description":"<b>Format: plain text <br>Restrictions: 0 to 255 characters  <br>Default: none </b>","key":"variable_ddi[title]","type":"text","value":"{{validate_adhoc_title}}"},{"description":"<b>Format: plain text <br>Restrictions: 0 to 255 characters  <br>Default: none </b>","key":"variable_ddi[address_2]","type":"text","value":"{{validate_adhoc_address2}}"},{"description":"<b>Format: plain text <br>Restrictions: 0 to 255 characters  <br>Default: none </b>","key":"variable_ddi[address_3]","type":"text","value":"{{validate_adhoc_address3}}"},{"description":"<b>Format: plain text <br>Restrictions: 0 to 255 characters  <br>Default: none </b>","key":"variable_ddi[county]","type":"text","value":"{{validate_adhoc_county}}"},{"description":"<b>Format: must be a valid email format  <br>Restrictions: 0 to 64 characters  <br>Default: none </b>","key":"variable_ddi[email_address]","type":"text","value":"{{validate_adhoc_email_address}}"},{"description":"<b>Format: plain text <br>Restrictions: 0 to 8 characters  <br>Default: none </b>","key":"variable_ddi[promotion]","type":"text","value":"{{validate_adhoc_promotion}}"},{"description":"<b>Format: plain text <br>Restrictions: 0 to 32 characters </b>","key":"variable_ddi[company_name]","type":"text","value":"{{validate_adhoc_company_name}}"}]},"url":"{{base_url}}/api/ddi/variable/validate"},"status":"OK","code":200,"_postman_previewlanguage":"xml","header":[{"key":"Date","value":"Thu, 14 Feb 2019 08:31:38 GMT"},{"key":"Server","value":"Apache"},{"key":"Cache-Control","value":"private, max-age=0, must-revalidate"},{"key":"X-Runtime","value":"0.56609"},{"key":"Strict-Transport-Security","value":"max-age=63072000; includeSubdomains; preload"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Set-Cookie","value":"auth_token=; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"_PSLLite_session_id=59c10b241683faff8f68dab95c0ecf7c; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"incap_ses_454_1416256=a; Max-Age=0; path=/; expires=Mon, 11 Feb 2019 12:10:11 GMT; Domain=.ddprocessing.co.uk"},{"key":"Set-Cookie","value":"incap_ses_368_1416256=mhs9ZRWtdipkaJE5nWYbBY0nZVwAAAAAJiW66dhODcc6cpT7APalwQ==; path=/; Domain=.ddprocessing.co.uk"},{"key":"Set-Cookie","value":"___utmvmoNuBZVNB=SQdICqAkKWV; path=/; Max-Age=900"},{"key":"Set-Cookie","value":"___utmvaoNuBZVNB=OIR\u0001kfxS; path=/; Max-Age=900"},{"key":"Set-Cookie","value":"___utmvboNuBZVNB=iZd    XkmOTalR: mtN; path=/; Max-Age=900"},{"key":"Content-Length","value":"344"},{"key":"Status","value":"200 OK"},{"key":"X-XSS-Protection","value":"1; mode=block"},{"key":"Keep-Alive","value":"timeout=5, max=100"},{"key":"Connection","value":"Keep-Alive"},{"key":"Content-Type","value":"application/xml; charset=utf-8"},{"key":"X-Iinfo","value":"13-19628225-19628228 NNNN CT(4 14 0) RT(1550133131994 24) q(0 0 0 0) r(19 19) U5"},{"key":"X-CDN","value":"Incapsula"}],"cookie":[],"responseTime":null,"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<successful>\n    <success>DDI details valid</success>\n    <success>Bank Account supports Direct Debit Instructions</success>\n    <success bank_name='HSBBC BANK PLC' branch='Broadway' address1='32 Bridge St' address2='' address3='' address4='' town='Evesham' county='Worcs.' postcode='WR11 4RU' />\n</successful>"}],"_postman_id":"232815a9-a9f8-4889-856a-12cdc5c83cb4"},{"name":"ddi/variable/validate (with extended parameters)","id":"861c70f3-cc5a-4cf7-b6ca-e22c456bcb7a","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"key":"variable_ddi[debits][debit][][amount]","value":"{{collection_1_amount}}","type":"text","description":"<p><b>Format:</b> integer, the value of the debit amount <i>in pence</i></p>\n"},{"key":"variable_ddi[debits][debit][][date]","value":"{{collection_1_date}}","type":"text","description":"<p><b>Format:</b> YYYY-MM-DD</p>\n"},{"key":"variable_ddi[debits][debit][][amount]","value":"{{collection_2_amount}}","type":"text","description":"<p><b>Format:</b> integer, the value of the debit amount <i>in pence</i></p>\n"},{"key":"variable_ddi[debits][debit][][date]","value":"{{collection_2_date}}","type":"text","description":"<p><b>Format:</b> YYYY-MM-DD</p>\n"}]},"url":"{{base_url}}/ddi/variable/validate","description":"<p>When creating adhoc collections, or overriding an existing collection, pairs of amount and date values must be passed together.</p>\n","urlObject":{"path":["ddi","variable","validate"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"861c70f3-cc5a-4cf7-b6ca-e22c456bcb7a"}],"id":"fa3a7bfa-8f69-4244-ab51-0e2e121595ff","description":"<h4 id=\"description\">Description</h4>\n<p><a href=\"#232815a9-a9f8-4889-856a-12cdc5c83cb4\">ddi/variable/validate</a> allows an API user to check the details for a DDI without committing to creating it. It is intended to be used as part of the sign-up user journey so that when the payer confirms, the <a href=\"#d2e3ace6-4817-472e-a61c-991761e4b76d\">create</a> call completes successfully.</p>\n<p>The call validates that all supplied values are accepted by the SmartDebit system. The call also verifies that the payer's bank account accepts Direct Debits. If used with <a href=\"#861c70f3-cc5a-4cf7-b6ca-e22c456bcb7a\">extended parameters</a> the call can also validate an initial set of collections.</p>\n<p><strong>Note:</strong></p>\n<ul>\n<li>When validating in a sandbox environment, a sort code of six zeros should be used to return a successful response. Typically an account number of 12345678 would be used.</li>\n<li>Using eight zeros for the account number returns an error response (invalid account details).</li>\n</ul>\n<h4 id=\"parameters\">Parameters</h4>\n<p><strong>Mandatory parameters</strong> are:</p>\n<ul>\n<li>pslid</li>\n<li>sort code, account number, account name</li>\n<li>first name &amp; last name</li>\n<li>frequency type</li>\n</ul>\n<p><a href=\"#86a42735-f1f4-4bb2-a135-81860b0f1313\">Character restrictions</a> apply to parameters. Accented characters and apostrophes should be removed from name and address values, as should most non-alphanumerics.</p>\n<p><strong>Optional parameters</strong> are listed <a href=\"#232815a9-a9f8-4889-856a-12cdc5c83cb4\">below</a>.</p>\n<p><strong>Conditional parameters</strong> (those that depend on the service user configuration) include:</p>\n<ul>\n<li>reference number</li>\n<li>email address, which is required if SmartDebit is to issue email notifications on behalf of the service user</li>\n<li>frequency type, as restrictions can be placed on what frequencies are available</li>\n<li>start date (optional), which must allow sufficient time for the DDI to lodge and this interval is derived from the service user's advance notice period</li>\n<li>start date can also be restricted to configured days of the month</li>\n<li>debit amounts must not exceed a configured maximum</li>\n<li>debit dates can be restricted to the payer's schedule (as defined by his start_date, frequency_type and frequency_factor values)</li>\n</ul>\n<p>The reference number must be unique and must comply with the <a href=\"#4d8a7173-5301-41e1-b171-7d4fde1fef6b\"> reference number rules</a>. Although SmartDebit is able to generate compliant reference numbers, the validate call is usually used for the sign-up user journey in which the details of the DDI, including the reference number, are presented to the payer before they confirm. For this reason, the service user would normally generate the reference number.</p>\n<p>There is a practical upper limit of 19 months in the future for the start date. This exists because the DDI is submitted a maximum of 6 months after creation and expires after 13 months of inactivity.</p>\n<p><strong>Extended parameters</strong> may be used with this call to validate the values for an optional initial set of collections. Collections are specified by pairs of parameters:</p>\n<ul>\n<li><code>variable_ddi[debits][debit][][amount]</code> - the collection amount in pence</li>\n<li><code>variable_ddi[debits][debit][][date]</code> - the collection date in YYYY-MM-DD format, which must be on or after the start date</li>\n</ul>\n<p>It is recommended that the XML body method of parameter passing is used if multiple debits are to be validated.</p>\n<p>Care should be taken when using extended parameters together with a regular_amount. </p>\n<h4 id=\"response\">Response</h4>\n<p>A successful call to ddi/variable/validate returns an XML document with a root tag of &lt;successful&gt;, with three &lt;success&gt; entries, the third of which includes information about the bank branch. </p>\n<p>Note the single quotes in this response.</p>\n<h4 id=\"errors\">Errors</h4>\n<p>Errors are returned with an HTTP status other than \"200 OK\".</p>\n<p>Missing parameters result in appropriate errors. A missing or incorrect service user returns one of the errors <code>&lt;error&gt;No service user id supplied.&lt;/error&gt;</code>, <code>&lt;error&gt;Invalid Service User ID: 'su_pslid'&lt;/error&gt;</code> or in the case of calling ddi/variable/validate without any frequency types configured for the service user, <code>&lt;error&gt;Service User 'Example SU' does not support Variable DDIs&lt;/error&gt;</code>.  The error is contained in an <code>&lt;errors&gt;</code> root tag.</p>\n<p>Omitting any required parameters or supplying invalid values for any parameter may return a listing of all validation errors in one document. For example:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>422 Unprocessable Entity\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Frequency type must be supplied&lt;/error&gt;\n  &lt;error&gt;Sort code is invalid&lt;/error&gt;\n  &lt;error&gt;Account name can't be blank&lt;/error&gt;\n  &lt;error&gt;Account name is too short (minimum is 3 characters)&lt;/error&gt;\n  &lt;error&gt;Account name only letters, numbers, spaces, hyphens, forward slash, ampersand and full stops are   permitted in account name&lt;/error&gt;\n  &lt;error&gt;Last name can't be blank&lt;/error&gt;\n  &lt;error&gt;Last name only letters, numbers, spaces, hyphens, forward slash, ampersand and full stops are   permitted in last names&lt;/error&gt;\n  &lt;error&gt;Account number must not be empty&lt;/error&gt;\n  &lt;error&gt;First name can't be blank&lt;/error&gt;\n  &lt;error&gt;First name only letters, numbers, spaces, hyphens, forward slash, ampersand and full stops are   permitted in first names&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><p>If all parameters pass validation, it is still possible that the bank account details are invalid. For example:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>422 Unprocessable Entity\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Invalid bank account details (Sort code not found)&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><p>If extended parameters are used then the debits are validated and can generate errors.</p>\n","event":[{"listen":"prerequest","script":{"id":"0cd7d518-1807-417b-8999-cb54bb555936","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"c3d0834b-978e-43b7-b567-262b9df844af","type":"text/javascript","exec":[""]}}],"_postman_id":"fa3a7bfa-8f69-4244-ab51-0e2e121595ff"},{"name":"4.2.2 Variable create","item":[{"name":"ddi/variable/create","event":[{"listen":"prerequest","script":{"id":"9af24909-c4d1-4b5e-b3e8-2fc08fa72efa","exec":["","pm.sendRequest(\"https://sandbox.smartdebit.co.uk/Scripts/smartdebit.jasmine.js\", (err, res) => { pm.globals.set('jasmine' ,res.text() ) });","","eval(pm.globals.get('jasmine'));","","pm.environment.set(\"reference\", (sd.testing.getReferenceNumber('SD1')));","","","pm.environment.set('account_number','00000007');","pm.environment.set('sort_code', '111111');","","var d = new Date();","d.setHours(0,0,0,0);","d.setMonth(d.getMonth()+1);","","pm.environment.set('create_startdate', sd.testing.getISODate(d));"],"type":"text/javascript"}},{"listen":"test","script":{"id":"e5e9fc6b-a3c8-4d63-84e6-606e00a18666","exec":["pm.test(\"Response time is less than 1000ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(1000);","});","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","pm.test(\"Body matches string\", function () {","    pm.expect(pm.response.text()).to.include('<?xml version=\"1.0\" encoding=\"UTF-8\"?>');","    pm.expect(pm.response.text()).to.include(\"<variable_ddi>\");","    pm.expect(pm.response.text()).to.include(\"<variable_ddi>\");","});","","//Schema Validation","var jsonObject = xml2Json(responseBody);","console.log(JSON.stringify(jsonObject));","","var schema ={","  \"definitions\": {},","  \"$schema\": \"http://json-schema.org/draft-07/schema#\",","  \"$id\": \"http://example.com/root.json\",","  \"type\": \"object\",","  \"properties\": {","    \"variable_ddi\": {","      \"$id\": \"#/properties/variable_ddi\",","      \"type\": \"object\",","      \"properties\": {","        \"address_1\": {","          \"$id\": \"#/properties/variable_ddi/properties/address_1\",","          \"type\": \"string\"","        },","        \"country\": {","          \"$id\": \"#/properties/variable_ddi/properties/country\",","          \"type\": \"string\"","        },","        \"first_name\": {","          \"$id\": \"#/properties/variable_ddi/properties/first_name\",","          \"type\": \"string\"","        },","        \"frequency_type\": {","          \"$id\": \"#/properties/variable_ddi/properties/frequency_type\",","          \"type\": \"string\"","        },","        \"last_name\": {","          \"$id\": \"#/properties/variable_ddi/properties/last_name\",","          \"type\": \"string\"","        },","        \"postcode\": {","          \"$id\": \"#/properties/variable_ddi/properties/postcode\",","          \"type\": \"string\"","        },","        \"reference_number\": {","          \"$id\": \"#/properties/variable_ddi/properties/reference_number\",","          \"type\": \"string\"","        },","        \"start_date\": {","          \"$id\": \"#/properties/variable_ddi/properties/start_date\",","          \"type\": \"object\",","          \"properties\": {","            \"_\": {","              \"$id\": \"#/properties/variable_ddi/properties/start_date/properties/_\",","              \"type\": \"string\"","            },","            \"$\": {","              \"$id\": \"#/properties/variable_ddi/properties/start_date/properties/$\",","              \"type\": \"object\",","              \"properties\": {","                \"type\": {","                  \"$id\": \"#/properties/variable_ddi/properties/start_date/properties/$/properties/type\",","                  \"type\": \"string\"","                }","              }","            }","          }","        },","        \"town\": {","          \"$id\": \"#/properties/variable_ddi/properties/town\",","          \"type\": \"string\"","        },","        \"service_user\": {","          \"$id\": \"#/properties/variable_ddi/properties/service_user\",","          \"type\": \"object\",","          \"properties\": {","            \"pslid\": {","              \"$id\": \"#/properties/variable_ddi/properties/service_user/properties/pslid\",","              \"type\": \"string\"","            }","          }","        }","      }","    }","  }","};","","pm.test('Schema is valid', function() {","  pm.expect(tv4.validate(jsonObject, schema)).to.be.true;","});"],"type":"text/javascript"}}],"id":"45d15571-df93-4553-98c3-5dbea1993513","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"description":"<p><i>Required</i><br />Service user identifier</p>\n","key":"variable_ddi[service_user][pslid]","type":"text","value":"{{pslid}}"},{"key":"variable_ddi[reference_number]","value":"{{create_reference_number}}","description":"<p><i>Conditional (usually required)</i><br />\nUnique identifier for the DDI<br />\n<b>Format:</b> 6 to 18 characters. See <a href=\"#4d8a7173-5301-41e1-b171-7d4fde1fef6b\">reference number rules</a>.</p>\n","type":"text"},{"description":"<p><i>Required</i><br />\n<b>Format:</b> single character only (W, M, Q, Y)</p>\n","key":"variable_ddi[frequency_type]","type":"text","value":"{{create_frequency_type}}"},{"description":"<p><i>Required</i><br />\n<b>Format:</b> either 111111 or 11-11-11</p>\n","key":"variable_ddi[sort_code]","type":"text","value":"{{create_sort_code}}"},{"description":"<p><i>Required</i><br />\n<b>Format:</b> 8 digit number</p>\n","key":"variable_ddi[account_number]","type":"text","value":"{{create_account_number}}"},{"description":"<p><i>Required</i><br />\n<b>Format:</b> 3 to 18 characters </p>\n","key":"variable_ddi[account_name]","type":"text","value":"{{create_account_name}}"},{"key":"variable_ddi[first_name]","value":"{{create_first_name}}","description":"<p><i>Required</i><br />\n<b>Format:</b> 1 to 32 characters</p>\n","type":"text"},{"description":"<p><i>Required</i><br />\n<b>Format:</b> 1 to 32 characters</p>\n","key":"variable_ddi[last_name]","type":"text","value":"{{create_last_name}}"},{"key":"variable_ddi[start_date]","type":"text","value":"{{create_start_date}}","description":"<p><b>Format:</b> YYYY-MM-DD<br /><b>Default:</b> next valid start date</p>\n"},{"key":"variable_ddi[end_date]","value":"{{create_end_date}}","description":"<p>If used, specifies the date after which no further collections will be made<br /><b>Format:</b> YYYY-MM-DD  <br /><b>Default:</b> none</p>\n","type":"text"},{"key":"variable_ddi[default_amount]","type":"text","value":"{{create_default_amount}}","description":"<p><b>Format:</b> integer, the value of the regular collection amount <i>in pence</i></p>\n"},{"key":"variable_ddi[first_amount]","type":"text","value":"{{create_first_amount}}","description":"<p>If provided, this value is used on the start date only, in place of the default amount<br /><b>Format:</b> integer, the value of the first collection amount <i>in pence</i></p>\n"},{"key":"variable_ddi[frequency_factor]","type":"text","value":"{{create_frequency_factor}}","description":"<p>Frequency factors 2, 3 and 4 cannot be used with frequency type Y<br /><b>Format:</b> integer, 1 to 4<br /><b>Default:</b> 1</p>\n"},{"key":"variable_ddi[title]","type":"text","value":"{{create_title}}","description":"<p><b>Format:</b> 1 to 32 characters</p>\n"},{"key":"variable_ddi[email_address]","type":"text","value":"{{create_email_address}}","description":"<p><b>Format:</b> 5 to 64 characters</p>\n"},{"key":"variable_ddi[company_name]","type":"text","value":"{{create_company_name}}","description":"<p><b>Format:</b> 1 to 32 characters</p>\n"},{"key":"variable_ddi[payer_reference]","type":"text","value":"{{create_payer_reference}}","description":"<p><b>Format:</b> 1 to 255 characters</p>\n"},{"key":"variable_ddi[address_1]","value":"{{create_address1}}","description":"<p><b>Format:</b> 1 to 255 characters</p>\n","type":"text"},{"key":"variable_ddi[address_2]","type":"text","value":"{{create_address2}}","description":"<p><b>Format:</b> 1 to 32 characters</p>\n"},{"key":"variable_ddi[address_3]","type":"text","value":"{{create_address3}}","description":"<p><b>Format:</b> 1 to 32 characters</p>\n"},{"key":"variable_ddi[town]","value":"{{create_town}}","description":"<p><b>Format:</b> 1 to 255 characters</p>\n","type":"text"},{"key":"variable_ddi[county]","type":"text","value":"{{create_county}}","description":"<p><b>Format:</b> 1 to 255 characters</p>\n"},{"key":"variable_ddi[postcode]","value":"{{create_postcode}}","description":"<p><b>Format:</b> 1 to 255 characters</p>\n","type":"text"},{"key":"variable_ddi[country]","value":"{{create_country}}","description":"<p><b>Format:</b> 1 to 255 characters</p>\n","type":"text"},{"key":"variable_ddi[support_gift_aid]","type":"text","value":"{{create_support_gift_aid}}","description":"<p><b>Format:</b> boolean, accepts 'true', 'false', 1 or 0<br /><b>Default:</b> false</p>\n"},{"key":"variable_ddi[promotion]","type":"text","value":"{{create_promotion}}","description":"<p><b>Format:</b> 1 to 8 characters</p>\n"}]},"url":"{{base_url}}/ddi/variable/create","description":"","urlObject":{"path":["ddi","variable","create"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"02bf5706-8328-4ccf-84fe-eaaf61844cfb","name":"create","originalRequest":{"method":"POST","header":[{"key":"Content-Type","value":"application/x-www-form-urlencoded"}],"body":{"mode":"formdata","formdata":[{"description":"<b>A unique reference number must be passed.    <br>Format: plain text Restrictions: Unique, 6 to 18 characters May not contain solidus (/)  and further restrictions apply.</b>","key":"variable_ddi[reference_number]","type":"text","value":"{{reference}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"variable_ddi[first_name]","type":"text","value":"{{create_first_name}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"variable_ddi[last_name]","type":"text","value":"{{create_last_name}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"variable_ddi[address_1]","type":"text","value":"{{create_address1}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"variable_ddi[town]","type":"text","value":"{{create_town}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"variable_ddi[postcode]","type":"text","value":"{{create_postcode}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"variable_ddi[country]","type":"text","value":"{{create_country}}"},{"description":"<b>Format: plain text <br>Restrictions: 3 to 18 characters </b>","key":"variable_ddi[account_name]","type":"text","value":"{{create_account_name}}"},{"description":"<b>Format: Sort Code – either 111111 or 11-11-11 format accepted.</b>","key":"variable_ddi[sort_code]","type":"text","value":"{{sort_code}}"},{"description":"<b>Format: 8 digit number </b>","key":"variable_ddi[account_number]","type":"text","value":"{{account_number}}"},{"description":"<b>Format: Single Character – (W, M, Q, Y)  Restrictions: Must be a frequency type configured on the SU </b>","key":"variable_ddi[frequency_type]","type":"text","value":"{{crearte_frequency_type}}"},{"description":"<b>Format: plain text   <br>Restrictions: 5 to 255 characters, must match existing SU's pslid </b>","key":"variable_ddi[service_user][pslid]","type":"text","value":"{{pslid}}"},{"key":"variable_ddi[default_amount]","type":"text","value":"1001","disabled":true},{"key":"variable_ddi[first_amount]","type":"text","value":"99","disabled":true},{"key":"variable_ddi[payer_reference]","type":"text","value":"custom_api_test","disabled":true},{"key":"variable_ddi[start_date]","type":"text","value":"2018-09-15","disabled":true},{"key":"variable_ddi[title]","type":"text","value":"Mr","disabled":true},{"key":"variable_ddi[address_2]","type":"text","value":"--","disabled":true},{"key":"variable_ddi[address_3]","type":"text","value":"--","disabled":true},{"key":"variable_ddi[county]","type":"text","value":"Surrey","disabled":true},{"key":"variable_ddi[email_address]","type":"text","value":"test-ruby@smartdebit.com","disabled":true},{"key":"variable_ddi[promotion]","type":"text","value":"freeRUBY","disabled":true},{"key":"variable_ddi[support_gift_aid]","type":"text","value":"false","disabled":true},{"key":"variable_ddi[company_name]","type":"text","value":"Ruby API","disabled":true},{"key":"variable_ddi[frequency_factor]","type":"text","value":"1","disabled":true}]},"url":"{{base_url}}/api/ddi/variable/create"},"status":"OK","code":200,"_postman_previewlanguage":"xml","header":[{"key":"Date","value":"Tue, 12 Feb 2019 15:39:54 GMT"},{"key":"Server","value":"Apache"},{"key":"X-Runtime","value":"0.67634"},{"key":"Cache-Control","value":"private, max-age=0, must-revalidate"},{"key":"Strict-Transport-Security","value":"max-age=63072000; includeSubdomains; preload"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Set-Cookie","value":"auth_token=; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"_PSLLite_session_id=59c10b241683faff8f68dab95c0ecf7c; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"incap_ses_454_1416256=a; Max-Age=0; path=/; expires=Mon, 11 Feb 2019 12:10:11 GMT; Domain=.ddprocessing.co.uk"},{"key":"Set-Cookie","value":"incap_ses_368_1416256=kpn2NqKMpUnJRmI4nWYbBefoYlwAAAAAGnN3GtRmLkeIuO3xWvBfiQ==; path=/; Domain=.ddprocessing.co.uk"},{"key":"Set-Cookie","value":"___utmvmoNuBZVNB=ajnfsQmcNsa; path=/; Max-Age=900"},{"key":"Set-Cookie","value":"___utmvaoNuBZVNB=zFD\u0001qNJi; path=/; Max-Age=900"},{"key":"Set-Cookie","value":"___utmvboNuBZVNB=CZD    XbqOraln: LtN; path=/; Max-Age=900"},{"key":"Content-Length","value":"489"},{"key":"Status","value":"200 OK"},{"key":"X-XSS-Protection","value":"1; mode=block"},{"key":"Keep-Alive","value":"timeout=5, max=100"},{"key":"Connection","value":"Keep-Alive"},{"key":"Content-Type","value":"application/xml; charset=utf-8"},{"key":"X-Iinfo","value":"14-2709257-2709261 NNNN CT(16 28 0) RT(1549986022955 27) q(0 0 1 1) r(10 10) U5"},{"key":"X-CDN","value":"Incapsula"}],"cookie":[],"responseTime":null,"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<variable_ddi>\n    <address_1>1 ApiTest Road</address_1>\n    <country>United Kingdom</country>\n    <first_name>Test</first_name>\n    <frequency_type>M</frequency_type>\n    <last_name>Smith</last_name>\n    <postcode>RR23 3AP</postcode>\n    <reference_number>SD1190112153954270</reference_number>\n    <start_date type=\"datetime\">2019-03-01T00:00:00Z</start_date>\n    <town>Bagshot</town>\n    <service_user>\n        <pslid>apidocument</pslid>\n    </service_user>\n</variable_ddi>"}],"_postman_id":"45d15571-df93-4553-98c3-5dbea1993513"},{"name":"ddi/variable/create (with extended parameters)","id":"a9f24465-29e2-496d-bb3f-d0efcc342510","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"key":"variable_ddi[debits][debit][][amount]","value":"{{collection_1_amount}}","type":"text","description":"<p><b>Format:</b> integer, the value of the debit amount <i>in pence</i></p>\n"},{"key":"variable_ddi[debits][debit][][date]","value":"{{collection_1_date}}","type":"text","description":"<p><b>Format:</b> YYYY-MM-DD</p>\n"},{"key":"variable_ddi[debits][debit][][amount]","value":"{{collection_2_amount}}","type":"text","description":"<p><b>Format:</b> integer, the value of the debit amount <i>in pence</i></p>\n"},{"key":"variable_ddi[debits][debit][][date]","value":"{{collection_2_date}}","type":"text","description":"<p><b>Format:</b> YYYY-MM-DD</p>\n"}]},"url":"{{base_url}}/ddi/variable/create","description":"<p>When creating adhoc collections, or overriding an existing collection, pairs of amount and date values must be passed together.</p>\n","urlObject":{"path":["ddi","variable","create"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"a9f24465-29e2-496d-bb3f-d0efcc342510"}],"id":"d2e3ace6-4817-472e-a61c-991761e4b76d","description":"<h4 id=\"description\">Description</h4>\n<p><a href=\"#45d15571-df93-4553-98c3-5dbea1993513\">ddi/variable/create</a> is used to create a new payer. The call should be made only if the validate call has already returned a success result. ddi/variable/create takes the same parameters as <a href=\"#232815a9-a9f8-4889-856a-12cdc5c83cb4\">ddi/variable/validate</a>. An arbitrary number of debits can also be created.</p>\n<p>The new payer is created and is immediately accessible in the SmartDebit Pulse web portal. If email notifications are configured for the service user and the payer's email address was supplied, a confirmation email is sent to the payer. The details of the DDI are scheduled for submission to Bacs in time for the first collection to be taken.</p>\n<h4 id=\"parameters\">Parameters</h4>\n<p>Refer to the <a href=\"#fa3a7bfa-8f69-4244-ab51-0e2e121595ff\">validate</a> section for details of the accepted parameters.</p>\n<h4 id=\"response\">Response</h4>\n<p>A successful response from ddi/variable/create is an XML rendition of the payer with a root tag of variable_ddi. Any unpopulated optional fields on the DDI are omitted from the XML document. If extended parameters are passed, the response includes the debits. The &lt;frequency_factor&gt; node is included only if the factor is greater than 1.</p>\n<h4 id=\"errors\">Errors</h4>\n<p>Refer to the validate section for example error responses.</p>\n","event":[{"listen":"prerequest","script":{"id":"40336317-4900-42e9-bec1-573db0214597","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"a8da4a95-2fd4-4d3d-ab4a-5a107ca99660","type":"text/javascript","exec":[""]}}],"_postman_id":"d2e3ace6-4817-472e-a61c-991761e4b76d"},{"name":"4.2.3 Variable update","item":[{"name":"ddi/variable/{{reference_number}}","event":[{"listen":"test","script":{"id":"7143515e-d68d-493f-9177-ab5fcb4d4d39","exec":["","eval(pm.globals.get('jasmine'));","","pm.test(\"Response time is less than 400ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(400);","});","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","pm.test(\"Body matches string\", function () {","    pm.expect(pm.response.text()).to.include('<?xml version=\"1.0\" encoding=\"UTF-8\"?>');","    pm.expect(pm.response.text()).to.include('<variable_ddi>');","    pm.expect(pm.response.text()).to.include('<reference_number>' + pm.environment.get('reference_number') + '</reference_number>');","    pm.expect(pm.response.text()).to.include('</variable_ddi>');","});","","","//               SCHEMA Validation                       //","var result = xml2Json(responseBody);                    //     ","var schema =  sd.api.schema.updateVariableResponse;     //","                                                        //","//var schema =  sd.api.schema.dumpResponse;               //","                                                        //","  pm.test('Schema is valid', function() {               //","    pm.expect(tv4.validate(result, schema)).to.be.true; //","  });                                                   //","//               SCHEMA Validation                      //","",""],"type":"text/javascript"}},{"listen":"prerequest","script":{"id":"90ff0aab-4b57-4db7-93e7-330df5d43945","exec":["","pm.sendRequest(\"https://sandbox.smartdebit.co.uk/Scripts/smartdebit.jasmine.js\", (err, res) => { pm.globals.set('jasmine' ,res.text() ) });","","eval(pm.globals.get('jasmine'));","","var authHash = btoa(pm.environment.get('api_user') + \":\" + pm.environment.get('api_user_password'));","","var dataGen = sd.testing;","","var payer = dataGen.getJsonPayer(pm.environment.get('pslid'), dataGen.getReferenceNumber('SD1'), 3, false);","","//This needs only for variable payers","payer.frequency_type = 'M';","payer.email_address = 'test-ruby@smartdebt.com';","","","//var payerFormData = dataGen.json2formData(payer, 'adhoc_ddi');","var payerFormData = dataGen.json2formData(payer, 'variable_ddi');","","const createPayerRequest = {","  //url: pm.environment.get('base_url') + '/api/ddi/adhoc/create',","  url: pm.environment.get('base_url') + '/ddi/variable/create',","  method: 'POST',","  header: `Authorization:Basic ${authHash}`,","  body: {","    mode: 'formdata',","    formdata: payerFormData","  }","};","","pm.sendRequest(createPayerRequest, function (err, res) {","  console.log(err ? err : res.text());","  ","  pm.environment.set('reference_number', payer.reference_number);","  console.log('reference number for the payer we try to update is: ' + payer.reference_number);","});","","var debitDate = new Date();","debitDate.setHours(0,0,0,0);","debitDate = debitDate.addMonths(2);","","pm.environment.set('update_dd_amount', dataGen.randomInt(100, 10000));","pm.environment.set('update_dd_date', dataGen.getISODate(debitDate));","","pm.environment.set('update_dd_amount', dataGen.randomInt(100, 10000));","pm.environment.set('update_dd_date', dataGen.getISODate(debitDate));","","pm.environment.set('update_first_name', 'Updated-Bob');","pm.environment.set('update_last_name', 'Updated-Smith');","pm.environment.set('validate_adhoc_company_name', 'Acme Co.');","pm.environment.set('update_address1', '123 SandBox Street');","pm.environment.set('update_town', 'Alfold');","pm.environment.set('update_postcode', 'GU99 9ZZ');","pm.environment.set('update_country', 'United Kingdom');","",""],"type":"text/javascript"}}],"id":"b884aef1-0abc-4a93-863a-c5982db87043","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"PUT","header":[],"body":{"mode":"formdata","formdata":[{"key":"variable_ddi[frequency_type]","value":"{{frequency_type}}","description":"<p><b>Format:</b> single character only (W, M, Q, Y)</p>\n","type":"text"},{"key":"variable_ddi[sort_code]","value":"{{sort_code}}","description":"<p><b>Format:</b> either 111111 or 11-11-11</p>\n","type":"text"},{"key":"variable_ddi[account_number]","value":"{{account_number}}","description":"<p><b>Format:</b> 8 digit number</p>\n","type":"text"},{"key":"variable_ddi[account_name]","value":"{{account_name}}","description":"<p><b>Format:</b> 3 to 18 characters </p>\n","type":"text"},{"key":"variable_ddi[first_name]","value":"{{first_name}}","type":"text","description":"<p><b>Format:</b> 1 to 32 characters</p>\n"},{"key":"variable_ddi[last_name]","value":"{{last_name}}","type":"text","description":"<p><b>Format:</b> 1 to 32 characters</p>\n"},{"key":"variable_ddi[start_date]","value":"{{start_date}}","description":"<p><b>Format:</b> YYYY-MM-DD</p>\n","type":"text"},{"key":"variable_ddi[end_date]","value":"{{end_date}}","description":"<p>If used, specifies the date after which no further collections will be made<br /><b>Format:</b> YYYY-MM-DD</p>\n","type":"text"},{"key":"variable_ddi[default_amount]","value":"{{default_amount}}","description":"<p><b>Format:</b> integer, the value of the regular collection amount <i>in pence</i></p>\n","type":"text"},{"key":"variable_ddi[first_amount]","value":"{{first_amount}}","description":"<p>If provided, this value is used on the start date only, in place of the default amount<br /><b>Format:</b> integer, the value of the first collection amount <i>in pence</i></p>\n","type":"text"},{"key":"variable_ddi[frequency_factor]","value":"{{frequency_factor}}","description":"<p>Frequency factors 2, 3 and 4 cannot be used with frequency type Y<br /><b>Format:</b> integer, 1 to 4</p>\n","type":"text"},{"key":"variable_ddi[title]","value":"{{title}}","description":"<p><b>Format:</b> 1 to 32 characters</p>\n","type":"text"},{"key":"variable_ddi[email_address]","value":"{{email_address}}","type":"text","description":"<p><b>Format:</b> 1 to 64 characters</p>\n"},{"key":"variable_ddi[company_name]","value":"{{company_name}}","type":"text","description":"<p><b>Format:</b> 1 to 32 characters</p>\n"},{"key":"variable_ddi[payer_reference]","value":"{{payer_reference}}","description":"<p><b>Format:</b> 1 to 255 characters</p>\n","type":"text"},{"key":"variable_ddi[address_1]","value":"{{address_1}}","type":"text","description":"<p><b>Format:</b> 1 to 255 characters</p>\n"},{"key":"variable_ddi[address_2]","value":"{{address_2}}","description":"<p><b>Format:</b> 1 to 32 characters</p>\n","type":"text"},{"key":"variable_ddi[address_3]","value":"{{address_3}}","description":"<p><b>Format:</b> 1 to 32 characters</p>\n","type":"text"},{"key":"variable_ddi[town]","value":"{{town}}","type":"text","description":"<p><b>Format:</b> 1 to 255 characters</p>\n"},{"key":"variable_ddi[county]","value":"{{county}}","description":"<p><b>Format:</b> 1 to 255 characters</p>\n","type":"text"},{"key":"variable_ddi[postcode]","value":"{{postcode}}","type":"text","description":"<p><b>Format:</b> 1 to 255 characters</p>\n"},{"key":"variable_ddi[country]","value":"{{country}}","type":"text","description":"<p><b>Format:</b> 1 to 255 characters</p>\n"},{"key":"variable_ddi[support_gift_aid]","value":"{{support_gift_aid}}","description":"<p><b>Format:</b> boolean, accepts 'true', 'false', 1 or 0</p>\n","type":"text"},{"key":"variable_ddi[promotion]","value":"{{promotion}}","description":"<p><b>Format:</b> 1 to 8 characters</p>\n","type":"text"}]},"url":"{{base_url}}/ddi/variable/{{reference_number}}","description":"<p>All parameters are optional.</p>\n","urlObject":{"path":["ddi","variable","{{reference_number}}"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"0a93e95d-58dd-47f1-bb71-177ba6799f89","name":"update","originalRequest":{"method":"PUT","header":[],"body":{"mode":"formdata","formdata":[{"key":"variable_ddi[first_name]","value":"{{update_first_name}}","type":"text","description":"<b> Format: Integer, the value of the debit amount in pence.  Restrictions: value between 0 and the SU's maximum_debit_amount </b>"},{"key":"variable_ddi[last_name]","value":"{{update_last_name}}","type":"text","description":"<b> Format: YYYY-MM-DD  Restrictions: must be on or after the start date, and must fall on a whole number of periods after the start date</b>"},{"key":"variable_ddi[address_1]","value":"{{update_address1}}","type":"text","description":"<b>Format: Integer, the value of the debit amount in pence.  Restrictions: value between 0 and the SU's maximum_debit_amount </b>"},{"key":"variable_ddi[town]","value":"{{update_town}}","type":"text","description":"<b>Format: YYYY-MM-DD  Restrictions: must be on or after the start date, and must fall on a whole number of periods after the start date </b>"},{"key":"variable_ddi[postcode]","value":"{{update_postcode}}","type":"text"},{"key":"variable_ddi[country]","value":"{{update_country}}","type":"text"},{"key":"variable_ddi[debits][debit][][amount]","value":"{{update_dd_amount}}","type":"text"},{"key":"variable_ddi[debits][debit][][date]","value":"{{update_dd_date}}","type":"text"},{"key":"variable_ddi[debits][debit][][amount]","value":"1000","type":"text"},{"key":"variable_ddi[debits][debit][][date]","value":"2019-04-28","type":"text"}]},"url":"{{base_url}}/api/ddi/variable/{{reference_number}}"},"status":"OK","code":200,"_postman_previewlanguage":"xml","header":[{"key":"Date","value":"Thu, 14 Feb 2019 13:43:42 GMT"},{"key":"Server","value":"Apache"},{"key":"Cache-Control","value":"private, max-age=0, must-revalidate"},{"key":"X-Runtime","value":"0.19808"},{"key":"Strict-Transport-Security","value":"max-age=63072000; includeSubdomains; preload"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Set-Cookie","value":"auth_token=; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"_PSLLite_session_id=59c10b241683faff8f68dab95c0ecf7c; path=/; HttpOnly; secure"},{"key":"Content-Length","value":"904"},{"key":"Status","value":"200 OK"},{"key":"X-XSS-Protection","value":"1; mode=block"},{"key":"Keep-Alive","value":"timeout=5, max=99"},{"key":"Connection","value":"Keep-Alive"},{"key":"Content-Type","value":"application/xml; charset=utf-8"},{"key":"X-Iinfo","value":"12-16060495-16072749 SNNN RT(1550151770862 85369) q(0 0 0 -1) r(2 2) U5"},{"key":"X-CDN","value":"Incapsula"}],"cookie":[],"responseTime":null,"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<variable_ddi>\n    <address_1>123 SandBox Street</address_1>\n    <country>United Kingdom</country>\n    <email_address>test-ruby@smartdebt.com</email_address>\n    <first_name>Updated-Bob</first_name>\n    <frequency_type>M</frequency_type>\n    <last_name>Updated-Smith</last_name>\n    <postcode>GU99 9ZZ</postcode>\n    <reference_number>SD1190114134344789</reference_number>\n    <start_date type=\"datetime\">2019-03-01T00:00:00Z</start_date>\n    <town>Alfold</town>\n    <debits type=\"array\">\n        <debit type=\"DdaDebit\">\n            <amount type=\"integer\">6570</amount>\n            <debit_date type=\"datetime\">2019-04-14T00:00:00Z</debit_date>\n        </debit>\n        <debit type=\"DdaDebit\">\n            <amount type=\"integer\">1000</amount>\n            <debit_date type=\"datetime\">2019-04-28T00:00:00Z</debit_date>\n        </debit>\n    </debits>\n    <service_user>\n        <pslid>apidocument</pslid>\n    </service_user>\n</variable_ddi>"}],"_postman_id":"b884aef1-0abc-4a93-863a-c5982db87043"},{"name":"ddi/variable/{{reference_number}} (with extended parameters)","event":[{"listen":"test","script":{"id":"7143515e-d68d-493f-9177-ab5fcb4d4d39","exec":["","eval(pm.globals.get('jasmine'));","","pm.test(\"Response time is less than 400ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(400);","});","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","pm.test(\"Body matches string\", function () {","    pm.expect(pm.response.text()).to.include('<?xml version=\"1.0\" encoding=\"UTF-8\"?>');","    pm.expect(pm.response.text()).to.include('<variable_ddi>');","    pm.expect(pm.response.text()).to.include('<reference_number>' + pm.environment.get('reference_number') + '</reference_number>');","    pm.expect(pm.response.text()).to.include('</variable_ddi>');","});","","","//               SCHEMA Validation                       //","var result = xml2Json(responseBody);                    //     ","var schema =  sd.api.schema.updateVariableResponse;     //","                                                        //","//var schema =  sd.api.schema.dumpResponse;               //","                                                        //","  pm.test('Schema is valid', function() {               //","    pm.expect(tv4.validate(result, schema)).to.be.true; //","  });                                                   //","//               SCHEMA Validation                      //","",""],"type":"text/javascript"}},{"listen":"prerequest","script":{"id":"90ff0aab-4b57-4db7-93e7-330df5d43945","exec":["","pm.sendRequest(\"https://sandbox.smartdebit.co.uk/Scripts/smartdebit.jasmine.js\", (err, res) => { pm.globals.set('jasmine' ,res.text() ) });","","eval(pm.globals.get('jasmine'));","","var authHash = btoa(pm.environment.get('api_user') + \":\" + pm.environment.get('api_user_password'));","","var dataGen = sd.testing;","","var payer = dataGen.getJsonPayer(pm.environment.get('pslid'), dataGen.getReferenceNumber('SD1'), 3, false);","","//This needs only for variable payers","payer.frequency_type = 'M';","payer.email_address = 'test-ruby@smartdebt.com';","","","//var payerFormData = dataGen.json2formData(payer, 'adhoc_ddi');","var payerFormData = dataGen.json2formData(payer, 'variable_ddi');","","const createPayerRequest = {","  //url: pm.environment.get('base_url') + '/api/ddi/adhoc/create',","  url: pm.environment.get('base_url') + '/ddi/variable/create',","  method: 'POST',","  header: `Authorization:Basic ${authHash}`,","  body: {","    mode: 'formdata',","    formdata: payerFormData","  }","};","","pm.sendRequest(createPayerRequest, function (err, res) {","  console.log(err ? err : res.text());","  ","  pm.environment.set('reference_number', payer.reference_number);","  console.log('reference number for the payer we try to update is: ' + payer.reference_number);","});","","var debitDate = new Date();","debitDate.setHours(0,0,0,0);","debitDate = debitDate.addMonths(2);","","pm.environment.set('update_dd_amount', dataGen.randomInt(100, 10000));","pm.environment.set('update_dd_date', dataGen.getISODate(debitDate));","",""],"type":"text/javascript"}}],"id":"b3a0184a-a568-4105-9a01-b0971c2411e8","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"PUT","header":[],"body":{"mode":"formdata","formdata":[{"description":"<p><b>Format:</b> integer, the value of the debit amount <i>in pence</i></p>\n","key":"variable_ddi[debits][debit][][amount]","type":"text","value":"{{collection_1_amount}}"},{"description":"<p><b>Format:</b> YYYY-MM-DD</p>\n","key":"variable_ddi[debits][debit][][date]","type":"text","value":"{{collection_1_date}}"},{"description":"<p><b>Format:</b> integer, the value of the debit amount <i>in pence</i></p>\n","key":"variable_ddi[debits][debit][][amount]","type":"text","value":"{{collection_2_amount}}"},{"description":"<p><b>Format:</b> YYYY-MM-DD</p>\n","key":"variable_ddi[debits][debit][][date]","type":"text","value":"{{collection_2_date}}"}]},"url":"{{base_url}}/ddi/variable/{{reference_number}}","description":"<p>When creating adhoc collections, or overriding an existing collection, pairs of amount and date values must be passed together.</p>\n","urlObject":{"path":["ddi","variable","{{reference_number}}"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"801e6059-65d4-4aa1-92bf-e3d90a1054ca","name":"update","originalRequest":{"method":"PUT","header":[],"body":{"mode":"formdata","formdata":[{"description":"<b> Format: Integer, the value of the debit amount in pence.  Restrictions: value between 0 and the SU's maximum_debit_amount </b>","key":"variable_ddi[debits][debit][][amount]","type":"text","value":"{{update_dd_amount}}"},{"description":"<b> Format: YYYY-MM-DD  Restrictions: must be on or after the start date, and must fall on a whole number of periods after the start date</b>","key":"variable_ddi[debits][debit][][date]","type":"text","value":"{{update_dd_date}}"},{"description":"<b>Format: Integer, the value of the debit amount in pence.  Restrictions: value between 0 and the SU's maximum_debit_amount </b>","key":"variable_ddi[debits][debit][][amount]","type":"text","value":"1000"},{"description":"<b>Format: YYYY-MM-DD  Restrictions: must be on or after the start date, and must fall on a whole number of periods after the start date </b>","key":"variable_ddi[debits][debit][][date]","type":"text","value":"2019-04-28"}]},"url":"{{base_url}}/api/ddi/variable/{{reference_number}}"},"status":"OK","code":200,"_postman_previewlanguage":"xml","header":[{"key":"Date","value":"Wed, 13 Feb 2019 11:10:04 GMT"},{"key":"Server","value":"Apache"},{"key":"Cache-Control","value":"private, max-age=0, must-revalidate"},{"key":"X-Runtime","value":"0.27362"},{"key":"Strict-Transport-Security","value":"max-age=63072000; includeSubdomains; preload"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Set-Cookie","value":"auth_token=; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"_PSLLite_session_id=59c10b241683faff8f68dab95c0ecf7c; path=/; HttpOnly; secure"},{"key":"Content-Length","value":"885"},{"key":"Status","value":"200 OK"},{"key":"X-XSS-Protection","value":"1; mode=block"},{"key":"Keep-Alive","value":"timeout=5, max=99"},{"key":"Connection","value":"Keep-Alive"},{"key":"Content-Type","value":"application/xml; charset=utf-8"},{"key":"X-Iinfo","value":"13-10522462-10597743 SNNN RT(1550055876383 358922) q(0 0 0 -1) r(3 3) U5"},{"key":"X-CDN","value":"Incapsula"}],"cookie":[],"responseTime":null,"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<variable_ddi>\n    <address_1>82 Manor Road</address_1>\n    <country>United Kingdom</country>\n    <email_address>test-ruby@smartdebt.com</email_address>\n    <first_name>Isla</first_name>\n    <frequency_type>M</frequency_type>\n    <last_name>Grad</last_name>\n    <postcode>W1A 0AX</postcode>\n    <reference_number>SD119011311105464</reference_number>\n    <start_date type=\"datetime\">2019-03-01T00:00:00Z</start_date>\n    <town>Harrowgate</town>\n    <debits type=\"array\">\n        <debit type=\"DdaDebit\">\n            <amount type=\"integer\">8233</amount>\n            <debit_date type=\"datetime\">2019-04-13T00:00:00Z</debit_date>\n        </debit>\n        <debit type=\"DdaDebit\">\n            <amount type=\"integer\">1000</amount>\n            <debit_date type=\"datetime\">2019-04-28T00:00:00Z</debit_date>\n        </debit>\n    </debits>\n    <service_user>\n        <pslid>apidocument</pslid>\n    </service_user>\n</variable_ddi>"}],"_postman_id":"b3a0184a-a568-4105-9a01-b0971c2411e8"},{"name":"ddi/variable/{{reference_number}}/update","event":[{"listen":"test","script":{"id":"7143515e-d68d-493f-9177-ab5fcb4d4d39","exec":["","eval(pm.globals.get('jasmine'));","","pm.test(\"Response time is less than 400ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(400);","});","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","pm.test(\"Body matches string\", function () {","    pm.expect(pm.response.text()).to.include('<?xml version=\"1.0\" encoding=\"UTF-8\"?>');","    pm.expect(pm.response.text()).to.include('<variable_ddi>');","    pm.expect(pm.response.text()).to.include('<reference_number>' + pm.environment.get('reference_number') + '</reference_number>');","    pm.expect(pm.response.text()).to.include('</variable_ddi>');","});","","","//               SCHEMA Validation                       //","var result = xml2Json(responseBody);                    //     ","var schema =  sd.api.schema.updateVariableResponse;     //","                                                        //","//var schema =  sd.api.schema.dumpResponse;               //","                                                        //","  pm.test('Schema is valid', function() {               //","    pm.expect(tv4.validate(result, schema)).to.be.true; //","  });                                                   //","//               SCHEMA Validation                      //","",""],"type":"text/javascript"}},{"listen":"prerequest","script":{"id":"90ff0aab-4b57-4db7-93e7-330df5d43945","exec":["","pm.sendRequest(\"https://sandbox.smartdebit.co.uk/Scripts/smartdebit.jasmine.js\", (err, res) => { pm.globals.set('jasmine' ,res.text() ) });","","eval(pm.globals.get('jasmine'));","","var authHash = btoa(pm.environment.get('api_user') + \":\" + pm.environment.get('api_user_password'));","","var dataGen = sd.testing;","","var payer = dataGen.getJsonPayer(pm.environment.get('pslid'), dataGen.getReferenceNumber('SD1'), 3, false);","","//This needs only for variable payers","payer.frequency_type = 'M';","payer.email_address = 'test-ruby@smartdebt.com';","","","//var payerFormData = dataGen.json2formData(payer, 'adhoc_ddi');","var payerFormData = dataGen.json2formData(payer, 'variable_ddi');","","const createPayerRequest = {","  //url: pm.environment.get('base_url') + '/api/ddi/adhoc/create',","  url: pm.environment.get('base_url') + '/ddi/variable/create',","  method: 'POST',","  header: `Authorization:Basic ${authHash}`,","  body: {","    mode: 'formdata',","    formdata: payerFormData","  }","};","","pm.sendRequest(createPayerRequest, function (err, res) {","  console.log(err ? err : res.text());","  ","  pm.environment.set('reference_number', payer.reference_number);","  console.log('reference number for the payer we try to update is: ' + payer.reference_number);","});","","var debitDate = new Date();","debitDate.setHours(0,0,0,0);","debitDate = debitDate.addMonths(2);","","pm.environment.set('update_dd_amount', dataGen.randomInt(100, 10000));","pm.environment.set('update_dd_date', dataGen.getISODate(debitDate));","","","pm.environment.set('update_first_name', 'Updated-Bob');","pm.environment.set('update_last_name', 'Updated-Smith');","pm.environment.set('validate_adhoc_company_name', 'Acme Co.');","pm.environment.set('update_address1', '123 SandBox Street');","pm.environment.set('update_town', 'Alfold');","pm.environment.set('update_postcode', 'GU99 9ZZ');","pm.environment.set('update_country', 'United Kingdom');"],"type":"text/javascript"}}],"id":"78322665-5f76-45c8-896c-be3896079b5d","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"POST","header":[],"url":"{{base_url}}/ddi/variable/{{reference_number}}/update","description":"<p>This is an alias for the <a href=\"#b884aef1-0abc-4a93-863a-c5982db87043\">PUT update</a>  call. The same parameters as above can be used with this version.</p>\n","urlObject":{"path":["ddi","variable","{{reference_number}}","update"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"ca698202-78cb-4dcf-84d3-4cb5772bd7e8","name":"update","originalRequest":{"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"key":"variable_ddi[first_name]","value":"{{update_first_name}}","type":"text","description":"<b> Format: Integer, the value of the debit amount in pence.  Restrictions: value between 0 and the SU's maximum_debit_amount </b>"},{"key":"variable_ddi[last_name]","value":"{{update_last_name}}","type":"text","description":"<b> Format: YYYY-MM-DD  Restrictions: must be on or after the start date, and must fall on a whole number of periods after the start date</b>"},{"key":"variable_ddi[address_1]","value":"{{update_address1}}","type":"text","description":"<b>Format: Integer, the value of the debit amount in pence.  Restrictions: value between 0 and the SU's maximum_debit_amount </b>"},{"key":"variable_ddi[town]","value":"{{update_town}}","type":"text","description":"<b>Format: YYYY-MM-DD  Restrictions: must be on or after the start date, and must fall on a whole number of periods after the start date </b>"},{"key":"variable_ddi[postcode]","value":"{{update_postcode}}","type":"text"},{"key":"variable_ddi[country]","value":"{{update_country}}","type":"text"},{"key":"variable_ddi[debits][debit][][amount]","value":"{{update_dd_amount}}","type":"text"},{"key":"variable_ddi[debits][debit][][date]","value":"{{update_dd_date}}","type":"text"},{"key":"variable_ddi[debits][debit][][amount]","value":"1000","type":"text"},{"key":"variable_ddi[debits][debit][][date]","value":"2019-04-28","type":"text"}]},"url":"{{base_url}}/api/ddi/variable/{{reference_number}}/update"},"status":"OK","code":200,"_postman_previewlanguage":"xml","header":[{"key":"Date","value":"Thu, 14 Feb 2019 13:45:18 GMT"},{"key":"Server","value":"Apache"},{"key":"Cache-Control","value":"private, max-age=0, must-revalidate"},{"key":"X-Runtime","value":"0.26889"},{"key":"Strict-Transport-Security","value":"max-age=63072000; includeSubdomains; preload"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Set-Cookie","value":"auth_token=; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"_PSLLite_session_id=59c10b241683faff8f68dab95c0ecf7c; path=/; HttpOnly; secure"},{"key":"Content-Length","value":"904"},{"key":"Status","value":"200 OK"},{"key":"X-XSS-Protection","value":"1; mode=block"},{"key":"Keep-Alive","value":"timeout=5, max=99"},{"key":"Connection","value":"Keep-Alive"},{"key":"Content-Type","value":"application/xml; charset=utf-8"},{"key":"X-Iinfo","value":"12-16060495-16087082 SNNN RT(1550151770862 181115) q(0 0 0 -1) r(3 3) U5"},{"key":"X-CDN","value":"Incapsula"}],"cookie":[],"responseTime":null,"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<variable_ddi>\n    <address_1>123 SandBox Street</address_1>\n    <country>United Kingdom</country>\n    <email_address>test-ruby@smartdebt.com</email_address>\n    <first_name>Updated-Bob</first_name>\n    <frequency_type>M</frequency_type>\n    <last_name>Updated-Smith</last_name>\n    <postcode>GU99 9ZZ</postcode>\n    <reference_number>SD1190114134520545</reference_number>\n    <start_date type=\"datetime\">2019-03-01T00:00:00Z</start_date>\n    <town>Alfold</town>\n    <debits type=\"array\">\n        <debit type=\"DdaDebit\">\n            <amount type=\"integer\">5438</amount>\n            <debit_date type=\"datetime\">2019-04-14T00:00:00Z</debit_date>\n        </debit>\n        <debit type=\"DdaDebit\">\n            <amount type=\"integer\">1000</amount>\n            <debit_date type=\"datetime\">2019-04-28T00:00:00Z</debit_date>\n        </debit>\n    </debits>\n    <service_user>\n        <pslid>apidocument</pslid>\n    </service_user>\n</variable_ddi>"}],"_postman_id":"78322665-5f76-45c8-896c-be3896079b5d"}],"id":"42d76121-1dd6-4e0a-ab9b-6454d618b1b5","description":"<h4 id=\"syntax\">Syntax</h4>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>PUT {{base_url}}/ddi/variable/{{reference_number}}\n</code></pre><p>aliased as</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>POST {{base_url}}/ddi/variable/{{reference_number}}/update\n</code></pre><h4 id=\"description\">Description</h4>\n<p>The <a href=\"#b884aef1-0abc-4a93-863a-c5982db87043\">update</a> method allows the attributes of a payer to be amended, their payment schedule to be changed, and collections to be created and updated. The update may result in an amendment email being sent to the payer.</p>\n<p>The DDI reference number cannot be changed. Cancelled DDIs cannot be updated.</p>\n<p>If the reference number contains solidus, it must be urlencoded.</p>\n<p><strong>Updating bank details:</strong> Simple validation of account number and sort code takes place but full validation does not. This behaviour may change in a future release. Thus, a five-digit sort code would not be accepted but an invalid six-digit sort code would.</p>\n<p><strong>Updating cancelled payers:</strong> Attempting to update a cancelled payer results in a \"200 OK\" status and an XML response as if the update was accepted <em>but the update does not take place</em>. The XML response includes the \"cancelled_on\" node. This behaviour may change in a future release.</p>\n<p><strong>Updating collection dates:</strong> A payer's collection date is determined by their start date, which can be changed by this call. When doing so, consider the following:</p>\n<ul>\n<li>If the start date is moved into the future and the payer has a first amount, that amount will be collected again.</li>\n<li>Changing the start date at or near a submission date may have unintended consequences. Consider a payer who collects on the 10th of the month: if, around the 10th of the month, the start date is changed to the 15th then two payments will be collected that month; if, around the 5th of the month, the start date is changed to the 5th, then no payments will be collected that month.</li>\n</ul>\n<p><strong>Deleting an end date:</strong> It may be useful to remove a payer's end date. Whilst some optional values can be deleted with empty form data, such as:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>    variable_ddi[payer_reference] = \n</code></pre><p>trying to remove an end date with form data results in an error:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>422 Unprocessable Entity\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Unable to parse end date '' expected format is YYYY-MM-DD&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><p>However an end date can be removed with an XML body containing an empty end_date tag:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;variable_ddi&gt;\n  &lt;end_date&gt;&lt;/end_date&gt;\n&lt;/variable_ddi&gt;\n</code></pre><p>The content-type must be application/xml.</p>\n<p><strong>Updating collections:</strong> Extended parameters can be used to add a collection or to change the amount of a collection. They cannot be used to change the date of a collection or to delete a collection. If a collection is added that coincides with the payer's schedule then it overrides the schedule: it is collected instead of, not as well as, the regular payment. An overriding collection with an amount of zero suppresses the regular payment.  Collections cannot be edited on or after the date of submission.</p>\n<h4 id=\"parameters\">Parameters</h4>\n<p>Optional parameters define the attribute or attributes to be updated. Extended parameters can be specified in order to create or update collections. It is recommended that the XML body method of parameter passing is used if multiple collections are to be created or edited.</p>\n<p>A dummy parameter, e.g. variable_ddi[dummy], may be used to simply return the payer details without performing an update.</p>\n<h4 id=\"response\">Response</h4>\n<p>A successful response from <a href=\"#b884aef1-0abc-4a93-863a-c5982db87043\">ddi/variable/{{reference_number}}</a> is an XML rendition of the payer with a root tag of variable_ddi.  Any unpopulated optional fields on the payer are omitted from the XML document. The entire payer and any collections are always returned regardless of the number of attributes updated. For instance, </p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>PUT /api/ddi/variable/ABC106093 \n&lt;?XML version=\"1.0\" encoding=\"UTF-8\"?&gt; \n&lt;variable_ddi&gt;\n  &lt;first_name&gt;John&lt;/first_name&gt;\n&lt;/variable_ddi&gt;\n</code></pre><p>could return:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>200 OK\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;variable_ddi&gt;\n  &lt;reference_number&gt;ABC106093&lt;/reference_number&gt;\n  &lt;first_name&gt;John&lt;/first_name&gt;\n  &lt;last_name&gt;Smith&lt;/last_name&gt;\n  &lt;frequency_type&gt;M&lt;/frequency_type&gt;\n  &lt;default_amount type=\"integer\"&gt;2000&lt;/default_amount&gt;\n  &lt;start_date type=\"datetime\"&gt;2018-07-01T00:00:00Z&lt;/start_date&gt;\n  &lt;address_1&gt;123 Fake St&lt;/address_1&gt;\n  &lt;town&gt;London&lt;/town&gt;\n  &lt;postcode&gt;sw2 3ed&lt;/postcode&gt;\n  &lt;country&gt;United Kingdom&lt;/country&gt;\n  &lt;service_user&gt;\n    &lt;pslid&gt;su_pslid&lt;/pslid&gt;\n  &lt;/service_user&gt;\n&lt;/variable_ddi&gt; \n</code></pre><p>The same is true of updating the debits on a DDI. For instance, </p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>PUT /api/ddi/variable/ABC106093 \n&lt;?XML version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;variable_ddi&gt;\n  &lt;debits&gt; \n    &lt;debit&gt;\n      &lt;amount&gt;500&lt;/amount&gt;&lt;date&gt;2019-08-01&lt;/date&gt;\n    &lt;/debit&gt;\n  &lt;/debits&gt;\n&lt;/variable_ddi&gt;\n</code></pre><p>could return</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>200 OK\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;variable_ddi&gt;\n  &lt;reference_number&gt;ABC106093&lt;/reference_number&gt;\n  &lt;first_name&gt;John&lt;/first_name&gt;\n  &lt;last_name&gt;Smith&lt;/last_name&gt;\n  &lt;frequency_type&gt;M&lt;/frequency_type&gt;\n  &lt;default_amount type=\"integer\"&gt;2000&lt;/default_amount&gt;\n  &lt;start_date type=\"datetime\"&gt;2018-07-01T00:00:00Z&lt;/start_date&gt;\n  &lt;address_1&gt;123 Fake St&lt;/address_1&gt;\n  &lt;town&gt;London&lt;/town&gt;\n  &lt;postcode&gt;sw2 3ed&lt;/postcode&gt; \n  &lt;country&gt;United Kingdom&lt;/country&gt;\n  &lt;debits type=\"array\"&gt; \n    &lt;debit type=\"DdaDebit\"&gt;\n      &lt;amount type=\"integer\"&gt;1500&lt;/amount&gt;\n      &lt;debit_date type=\"datetime\"&gt;2019-07-01T00:00:00Z&lt;/debit_date&gt;\n    &lt;/debit&gt; \n    &lt;debit&gt;\n      &lt;amount type=\"integer\"&gt;500&lt;/amount&gt;\n      &lt;debit_date type=\"datetime\"&gt;2019-08-01T00:00:00Z&lt;/debit_date&gt;\n    &lt;/debit&gt;\n  &lt;/debits&gt;\n  &lt;service_user&gt;\n    &lt;pslid&gt;su_pslid&lt;/pslid&gt;\n  &lt;/service_user&gt;\n&lt;/variable_ddi&gt;\n</code></pre><p>A cancelled DDI is identified by the presence of <strong>cancelled_on</strong> in the response, indicating the date and time of cancellation. Where the cancellation is by Bacs advice, the value of cancelled_on may be taken from the advice.</p>\n<p>Amounts are given in pence.</p>\n<p>Collection statuses are not provided. The presence of a collection does not mean that it was paid, nor even that it was submitted.</p>\n<h4 id=\"errors\">Errors</h4>\n<p>Error responses are similar to the error responses for <a href=\"#232815a9-a9f8-4889-856a-12cdc5c83cb4\">ddi/variable/validate</a> and <a href=\"#45d15571-df93-4553-98c3-5dbea1993513\">ddi/variable/create</a>. Missing parameters result in appropriate errors. Passing no parameters at all returns: </p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>400 Bad Request \n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Direct Debit parameters not supplied.&lt;/error&gt;\n&lt;/errors&gt; \n</code></pre><p>Attempting to update with an incorrect reference number returns:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>400 Bad Request\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Variable Direct Debit 'AAAAAA' not found.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><p>Attempting to update an 'adhoc' DDI returns the same response.</p>\n<p>Supplying invalid values for any parameter may return a listing of all validation errors in one document. For example: </p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>422 Unprocessable Entity \n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Account name is too short (minimum is 3 characters)&lt;/error&gt;\n  &lt;error&gt;First name is too long (maximum is 32 characters)&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><p>Supplying invalid debit values returns a listing of all validation errors in one document. This example shows an invalid date and an amount that exceeds the maximum allowed for the service user. Note the HTML encoding in this response. </p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>422 Unprocessable Entity\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Amount must be less than &amp;#163;250.00&lt;/error&gt;\n  &lt;error&gt;Debit date must not be before the start of the DDI: 2018/07/01 00:00&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre>","event":[{"listen":"prerequest","script":{"id":"e8efa11b-7873-4a9c-a88f-faff81dc7032","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"10d17560-3171-43f7-8a92-b9da403f2e15","type":"text/javascript","exec":[""]}}],"_postman_id":"42d76121-1dd6-4e0a-ab9b-6454d618b1b5"},{"name":"4.2.4 Variable cancel","item":[{"name":"ddi/variable/{{reference_number}}/cancel","event":[{"listen":"test","script":{"id":"c0292e00-f624-4837-845e-fd52dadadd98","exec":["eval(pm.globals.get('jasmine'));","","pm.test(\"Response time is less than 200ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(200);","});","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","pm.test(\"Body matches string\", function () {","    pm.expect(pm.response.text()).to.include('<?xml version=\"1.0\" encoding=\"UTF-8\"?>');","    pm.expect(pm.response.text()).to.include('<variable_ddi>');","    pm.expect(pm.response.text()).to.include('<reference_number>' + pm.environment.get('reference_number_to_cancel') + '</reference_number>');","    pm.expect(pm.response.text()).to.include('</variable_ddi>');","});","","//               SCHEMA Validation                          //","var result = xml2Json(responseBody);                        //     ","var schema =  sd.api.schema.updateVariableResponse;                  //","//                                                          //","  pm.test('Schema is valid', function() {                   //","    pm.expect(tv4.validate(result, schema)).to.be.true;     //","  });                                                       //","//               SCHEMA Validation                          //","","","//pm.environment.set(\"api_cancel_adhoc_response_2\", pm.response.text());"],"type":"text/javascript"}},{"listen":"prerequest","script":{"id":"f68927c4-6304-4373-8a8f-90956c01555a","exec":["pm.sendRequest(\"https://sandbox.smartdebit.co.uk/Scripts/smartdebit.jasmine.js\", (err, res) => { pm.globals.set('jasmine' ,res.text() ) });","","eval(pm.globals.get('jasmine'));","","var authHash = btoa(pm.environment.get('api_user') + \":\" + pm.environment.get('api_user_password'));","","var dataGen = sd.testing;","","var payer = dataGen.getJsonPayer(pm.environment.get('pslid'), dataGen.getReferenceNumber('SD1'), 3, false);","","//This needs only for variable payers","payer.frequency_type = 'M';","payer.email_address = 'test-ruby@smartdebt.com';","","","//var payerFormData = dataGen.json2formData(payer, 'adhoc_ddi');","var payerFormData = dataGen.json2formData(payer, 'variable_ddi');","","const createPayerRequest = {","  //url: pm.environment.get('base_url') + '/api/ddi/adhoc/create',","  url: pm.environment.get('base_url') + '/ddi/variable/create',","  method: 'POST',","  header: `Authorization:Basic ${authHash}`,","  body: {","    mode: 'formdata',","    formdata: payerFormData","  }","};","","pm.sendRequest(createPayerRequest, function (err, res) {","  console.log(err ? err : res.text());","  ","  pm.environment.set('reference_number_to_cancel',payer.reference_number);","  console.log('reference number for the payer we will cancel is: ' + payer.reference_number);","});","","","",""],"type":"text/javascript"}}],"id":"aabd97e8-ca8c-470d-a411-525400abe441","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"POST","header":[],"url":"{{base_url}}/ddi/variable/{{reference_number_to_cancel}}/cancel","urlObject":{"path":["ddi","variable","{{reference_number_to_cancel}}","cancel"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"bf15eb75-bf1d-428f-951b-235338b5b437","name":"cancel","originalRequest":{"method":"POST","header":[],"body":{"mode":"formdata","formdata":[]},"url":"{{base_url}}/api/ddi/variable/{{reference_number_to_cancel}}/cancel"},"status":"OK","code":200,"_postman_previewlanguage":"xml","header":[{"key":"Date","value":"Thu, 14 Feb 2019 11:11:10 GMT"},{"key":"Server","value":"Apache"},{"key":"Cache-Control","value":"private, max-age=0, must-revalidate"},{"key":"X-Runtime","value":"0.09400"},{"key":"Strict-Transport-Security","value":"max-age=63072000; includeSubdomains; preload"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Set-Cookie","value":"auth_token=; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"_PSLLite_session_id=59c10b241683faff8f68dab95c0ecf7c; path=/; HttpOnly; secure"},{"key":"Content-Length","value":"619"},{"key":"Status","value":"200 OK"},{"key":"X-XSS-Protection","value":"1; mode=block"},{"key":"Keep-Alive","value":"timeout=5, max=99"},{"key":"Connection","value":"Keep-Alive"},{"key":"Content-Type","value":"application/xml; charset=utf-8"},{"key":"X-Iinfo","value":"13-21068860-21087126 SNNN RT(1550142591588 112642) q(0 0 0 -1) r(1 1) U5"},{"key":"X-CDN","value":"Incapsula"}],"cookie":[],"responseTime":null,"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<variable_ddi>\n    <address_1>16 Victoria Road</address_1>\n    <cancelled_on type=\"datetime\">2019-02-14T11:11:10Z</cancelled_on>\n    <country>United Kingdom</country>\n    <email_address>test-ruby@smartdebt.com</email_address>\n    <first_name>Lenin</first_name>\n    <frequency_type>M</frequency_type>\n    <last_name>Bella</last_name>\n    <postcode>CR2 6XH</postcode>\n    <reference_number>SD1190114111113172</reference_number>\n    <start_date type=\"datetime\">2019-03-01T00:00:00Z</start_date>\n    <town>Harrowgate</town>\n    <service_user>\n        <pslid>apidocument</pslid>\n    </service_user>\n</variable_ddi>"}],"_postman_id":"aabd97e8-ca8c-470d-a411-525400abe441"}],"id":"7795898c-fbb6-4fee-9a2b-2c9ad65c0818","description":"<p>The <a href=\"#aabd97e8-ca8c-470d-a411-525400abe441\">cancel</a> method allows a DDI to be cancelled. Cancelling a DDI may result in a cancellation email being sent to the payer.</p>\n<p>If the reference number contains solidus, it must be urlencoded.</p>\n<h4 id=\"response\">Response</h4>\n<p>A successful response is an XML rendition of the DDI with a root tag of variable_ddi. The cancellation time is included as <strong>cancelled_on</strong>. Any unpopulated optional fields on the DDI are omitted from the XML document. </p>\n<p>Cancelling an already-cancelled DDI returns a success response but performs no action.</p>\n<h4 id=\"errors\">Errors</h4>\n<p>Attempting to cancel with an incorrect reference number returns:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>400 Bad Request\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Variable Direct Debit 'AAAAAA' not found.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><p>Attempting to cancel an <em>adhoc</em> DDI returns the same response.</p>\n","event":[{"listen":"prerequest","script":{"id":"84dca9c0-ae28-4c16-8ba6-d9eaa6309cc0","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"6941e157-a8bf-4d73-a22d-4b7c89757350","type":"text/javascript","exec":[""]}}],"_postman_id":"7795898c-fbb6-4fee-9a2b-2c9ad65c0818"},{"name":"4.2.5 Variable reinstate","item":[{"name":"ddi/variable/{{reference_number}}/reinstate","id":"9ba4f071-605a-47fc-b6a0-a38252efea1f","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"url":"{{base_url}}/ddi/variable/{{reference_number}}/reinstate","urlObject":{"path":["ddi","variable","{{reference_number}}","reinstate"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"9ba4f071-605a-47fc-b6a0-a38252efea1f"}],"id":"e0acea5c-f440-40ab-9867-84b65c05f3bb","description":"<p>The <a href=\"#9ba4f071-605a-47fc-b6a0-a38252efea1f\">reinstate</a> method allows a cancelled DDI to be made live again. Reinstating a DDI may result in a reinstatement email being sent to the payer.</p>\n<p>If the reference number contains solidus, it must be urlencoded.</p>\n<h4 id=\"response\">Response</h4>\n<p>A successful response is an XML rendition of the DDI with a root tag of variable_ddi. Any unpopulated optional fields on the DDI are omitted from the XML document. The fact that the response does not include a cancelled_on field indicates that the DDI is live.</p>\n<p>Reinstating a DDI that is already live returns a success response but performs no action.</p>\n<h4 id=\"errors\">Errors</h4>\n<p>Attempting to reinstate with an incorrect reference number returns:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>400 Bad Request\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\" ?&gt;\n&lt;errors&gt;\n    &lt;error&gt;Variable Direct Debit 'AAAAAA' not found.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><p>Attempting to reinstate an <em>adhoc</em> DDI returns the same response.</p>\n","event":[{"listen":"prerequest","script":{"id":"119356b7-231c-4a90-8be7-2bf512a3870e","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"395147e4-419b-4ae5-a237-1bd0d4c6639f","type":"text/javascript","exec":[""]}}],"_postman_id":"e0acea5c-f440-40ab-9867-84b65c05f3bb"},{"name":"4.2.6 Adhoc validate","item":[{"name":"ddi/adhoc/validate","event":[{"listen":"test","script":{"id":"a0f7c137-6100-446b-8405-61412f663605","exec":["eval(pm.globals.get('jasmine'));","","pm.test(\"Response time is less than 200ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(200);","});","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","var jsonObject = xml2Json(responseBody);","console.log(JSON.stringify(jsonObject));","","","var schema = sd.api.schema.validateResponse;","","console.log(schema);","pm.test('Schema is valid', function() {","  pm.expect(tv4.validate(jsonObject, schema)).to.be.true;","});"],"type":"text/javascript"}},{"listen":"prerequest","script":{"id":"1f3c829c-3be1-4237-a572-83e54e1c01c8","exec":["pm.sendRequest(\"https://sandbox.smartdebit.co.uk/Scripts/smartdebit.jasmine.js\", (err, res) => { pm.globals.set('jasmine' ,res.text() ) });","","eval(pm.globals.get('jasmine'));","","var dataGen = sd.testing;","","var startDate = new Date();","startDate.setHours(0,0,0,0);","startDate = startDate.addMonths(2);","","var endDate = new Date();","endDate.setHours(0,0,0,0);","endDate = endDate.addMonths(6);","","var payer = dataGen.getJsonPayer(pm.environment.get('pslid'), dataGen.getReferenceNumber('SD1'), 3, false, false, true);","","console.log(payer);","console.log(dataGen.getISODate(startDate));","console.log(dataGen.getISODate(endDate));","","console.log(payer.last_name);","","pm.environment.set('validate_reference_number','API-Test-0123');  //should not exist","pm.environment.set('validate_adhoc_title', payer.title);","pm.environment.set('validate_first_name', payer.first_name);","pm.environment.set('validate_last_name', payer.last_name);","pm.environment.set('validate_adhoc_company_name', 'Acme Co.');","pm.environment.set('validate_address1', payer.address_1);","pm.environment.set('validate_adhoc_address2', payer.address_2);","pm.environment.set('validate_adhoc_address3', payer.address_3);","pm.environment.set('validate_town', payer.town);","pm.environment.set('validate_adhoc_county', payer.county);","pm.environment.set('validate_postcode', payer.postcode);","pm.environment.set('validate_country', payer.country);","","pm.environment.set('validate_adhoc_email_address', payer.email);","","pm.environment.set('validate_adhoc_start_date', dataGen.getISODate(startDate));","pm.environment.set('validate_adhoc_end_date', dataGen.getISODate(endDate));","pm.environment.set('validate_sort_code', '000000');","pm.environment.set('validate_account_number', '12345678');","pm.environment.set('validate_adhoc_promotion', 'PROMO');","","","pm.environment.set('validate_adhoc_payer_reference', payer.account_number);","pm.environment.set('validate_account_name', payer.account_name);","","","var debitDate = new Date();","debitDate.setHours(0,0,0,0);","debitDate = debitDate.addMonths(2);","","pm.environment.set('validate_adhoc_dd_amount', dataGen.randomInt(100, 10000));","pm.environment.set('validate_adhoc_dd_date', dataGen.getISODate(debitDate));"],"type":"text/javascript"}}],"id":"23d97a1a-b71d-4bfc-8632-550235f92a8e","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"key":"adhoc_ddi[service_user][pslid]","value":"{{pslid}}","type":"text","description":"<p><i>Required</i><br />\nService user identifier</p>\n"},{"key":"adhoc_ddi[reference_number]","value":"{{validate_reference_number}}","type":"text","description":"<p><i>Conditional (usually required)</i><br />\nUnique identifier for the DDI<br />\n<b>Format:</b> 6 to 18 characters. See <a href=\"#4d8a7173-5301-41e1-b171-7d4fde1fef6b\">reference number rules</a>.</p>\n"},{"key":"adhoc_ddi[sort_code]","value":"{{validate_sort_code}}","type":"text","description":"<p><i>Required</i><br />\n<b>Format:</b> either 111111 or 11-11-11</p>\n"},{"key":"adhoc_ddi[account_number]","value":"{{validate_account_number}}","type":"text","description":"<p><i>Required</i><br />\n<b>Format:</b> 8 digit number</p>\n"},{"key":"adhoc_ddi[account_name]","value":"{{validate_account_name}}","type":"text","description":"<p><i>Required</i><br />\n<b>Format:</b> 3 to 18 characters </p>\n"},{"key":"adhoc_ddi[first_name]","value":"{{validate_first_name}}","type":"text","description":"<p><i>Required</i><br />\n<b>Format:</b> 1 to 32 characters</p>\n"},{"key":"adhoc_ddi[last_name]","value":"{{validate_last_name}}","type":"text","description":"<p><i>Required</i><br />\n<b>Format:</b> 1 to 32 characters</p>\n"},{"key":"adhoc_ddi[start_date]","value":"{{validate_adhoc_start_date}}","type":"text","description":"<p><b>Format:</b> YYYY-MM-DD<br /><b>Default:</b> next valid start date</p>\n"},{"key":"adhoc_ddi[end_date]","value":"{{validate_adhoc_end_date}}","type":"text","description":"<p><i>Deprecated</i><br /><b>Format:</b> YYYY-MM-DD  <br /><b>Default:</b> none</p>\n"},{"key":"adhoc_ddi[title]","value":"{{validate_adhoc_title}}","type":"text","description":"<p><b>Format:</b> 1 to 32 characters</p>\n"},{"key":"adhoc_ddi[email_address]","value":"{{validate_adhoc_email_address}}","type":"text","description":"<p><b>Format:</b> 5 to 64 characters</p>\n"},{"key":"adhoc_ddi[company_name]","value":"{{validate_adhoc_company_name}}","type":"text","description":"<p><b>Format:</b> 1 to 32 characters</p>\n"},{"key":"adhoc_ddi[payer_reference]","value":"{{validate_adhoc_payer_reference}}","type":"text","description":"<p><b>Format:</b> 1 to 255 characters</p>\n"},{"key":"adhoc_ddi[address_1]","value":"{{validate_address1}}","type":"text","description":"<p><b>Format:</b> 1 to 255 characters</p>\n"},{"key":"adhoc_ddi[address_2]","value":"{{validate_adhoc_address2}}","type":"text","description":"<p><b>Format:</b> 1 to 32 characters</p>\n"},{"key":"adhoc_ddi[address_3]","value":"{{validate_adhoc_address3}}","type":"text","description":"<p><b>Format:</b> 1 to 32 characters</p>\n"},{"key":"adhoc_ddi[town]","value":"{{validate_town}}","type":"text","description":"<p><b>Format:</b> 1 to 255 characters</p>\n"},{"key":"adhoc_ddi[county]","value":"{{validate_adhoc_county}}","type":"text","description":"<p><b>Format:</b> 1 to 255 characters</p>\n"},{"key":"adhoc_ddi[postcode]","value":"{{validate_postcode}}","type":"text","description":"<p><b>Format:</b> 1 to 255 characters</p>\n"},{"key":"adhoc_ddi[country]","value":"{{validate_country}}","type":"text","description":"<p><b>Format:</b> 1 to 255 characters</p>\n"},{"key":"adhoc_ddi[support_gift_aid]","value":"{{validate_support_gift_aid}}","description":"<p><b>Format:</b> boolean, accepts 'true', 'false', 1 or 0<br /><b>Default:</b> false</p>\n","type":"text"},{"key":"adhoc_ddi[promotion]","value":"{{validate_adhoc_promotion}}","type":"text","description":"<p><b>Format:</b> 1 to 8 characters</p>\n"}]},"url":"{{base_url}}/ddi/adhoc/validate","urlObject":{"path":["ddi","adhoc","validate"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"ba6b25af-3b6f-4119-b3c9-11b31fcf43a7","name":"validate","originalRequest":{"method":"POST","header":[{"key":"Content-Type","value":"application/x-www-form-urlencoded"}],"body":{"mode":"formdata","formdata":[{"key":"adhoc_ddi[sort_code]","value":"{{validate_sort_code}}","type":"text","description":"<b>Format: Sort Code – either 111111 or 11-11-11 format accepted.</b>"},{"key":"adhoc_ddi[account_number]","value":"{{validate_account_number}}","type":"text","description":"<b>Format: 8 digit number </b>"},{"key":"adhoc_ddi[reference_number]","value":"{{validate_reference_number}}","type":"text","description":"<b>A unique reference number must be passed.    \nFormat: plain text \nRestrictions: Unique, 6 to 18 characters May not contain solidus (/)  and further restrictions apply.</b>"},{"key":"adhoc_ddi[first_name]","value":"{{validate_first_name}}","type":"text","description":"<b>Format: plain text \nRestrictions: 1 to 32 characters</b>"},{"key":"adhoc_ddi[last_name]","value":"{{validate_last_name}}","type":"text","description":"<b>Format: plain text \nRestrictions: 1 to 32 characters</b>"},{"key":"adhoc_ddi[address_1]","value":"{{validate_address1}}","type":"text","description":"<b>Format: plain text \nRestrictions: 1 to 32 characters</b>"},{"key":"adhoc_ddi[town]","value":"{{validate_town}}","type":"text","description":"<b>Format: plain text \nRestrictions: 1 to 32 characters</b>"},{"key":"adhoc_ddi[postcode]","value":"{{validate_postcode}}","type":"text","description":"<b>Format: plain text \nRestrictions: 1 to 32 characters</b>"},{"key":"adhoc_ddi[country]","value":"{{validate_country}}","type":"text","description":"<b>Format: plain text \nRestrictions: 1 to 32 characters</b>"},{"key":"adhoc_ddi[account_name]","value":"{{validate_account_name}}","type":"text","description":"<b>Format: 8 digit number. <br>\nTypical sort code and account numbers to use from a test account are 000000 for the sort code and 12345678 for the account number. </b>"},{"key":"adhoc_ddi[service_user][pslid]","value":"{{pslid}}","type":"text","description":"<b>Format: plain text   \nRestrictions: 5 to 255 characters, must match existing SU's pslid </b>"},{"key":"adhoc_ddi[payer_reference]","value":"{{validate_adhoc_payer_reference}}","type":"text","description":"<b>Format: plain text \nRestrictions: 0 to 18 characters  <br>Default: none </b>","disabled":true},{"key":"adhoc_ddi[start_date]","value":"{{validate_adhoc_start_date}}","type":"text","description":"<b>Format: YYYY-MM-DD  \nRestrictions: Must be far enough in the future to allow the SU's lead time.</b>","disabled":true},{"key":"adhoc_ddi[end_date]","value":"{{validate_adhoc_end_date}}","type":"text","description":"<b>Format: YYYY-MM-DD \nRestrictions: Must be after the start time, not required to fall on a debit day.  \nDefault: none</b>","disabled":true},{"key":"adhoc_ddi[title]","value":"{{validate_adhoc_title}}","type":"text","description":"<b>Format: plain text \nRestrictions: 0 to 255 characters \nDefault: none </b>","disabled":true},{"key":"adhoc_ddi[address_2]","value":"{{validate_adhoc_address2}}","type":"text","description":"<b>Format: plain text\nRestrictions: 0 to 32 characters  \nDefault: none </b>","disabled":true},{"key":"adhoc_ddi[address_3]","value":"{{validate_adhoc_address3}}","type":"text","description":"<b>Format: plain text \nRestrictions: 0 to 32 characters \nDefault: none </b>","disabled":true},{"key":"adhoc_ddi[county]","value":"{{validate_adhoc_county}}","type":"text","description":"<b>Format: plain text \nRestrictions: 0 to 32 characters  \nDefault: none </b>","disabled":true},{"key":"adhoc_ddi[email_address]","value":"{{validate_adhoc_email_address}}","type":"text","description":"<b>Format: must be a valid email format  \nRestrictions: 0 to 64 characters \nDefault: none </b>","disabled":true},{"key":"adhoc_ddi[promotion]","value":"{{validate_adhoc_promotion}}","type":"text","description":"<b>Format: plain text \nRestrictions: 0 to 8 characters  \nDefault: none </b>","disabled":true},{"key":"adhoc_ddi[company_name]","value":"{{validate_adhoc_company_name}}","type":"text","description":"<b>Format: plain text \nRestrictions: 0 to 32 characters </b>","disabled":true},{"key":"adhoc_ddi[debits][debit][][amount]","value":"{{validate_adhoc_dd_amount}}","type":"text","description":"<b>Format: Integer, the value of the debit amount in pence.  \nRestrictions: value between 0 and the SU's maximum_debit_amount </b>","disabled":true},{"key":"adhoc_ddi[debits][debit][][date]","value":"{{validate_adhoc_dd_date}}","type":"text","description":"<b>Format: YYYY-MM-DD  \nRestrictions: must be on or after the start date, and must fall on a whole number of periods after the start date </b>","disabled":true},{"key":"adhoc_ddi[debits][debit][][amount]","value":"1300","type":"text","description":"<b>Format: Integer, the value of the debit amount in pence.  \nRestrictions: value between 0 and the SU's maximum_debit_amount </b>","disabled":true},{"key":"adhoc_ddi[debits][debit][][date]","value":"2019-01-27","type":"text","description":"<b>Format: YYYY-MM-DD  \nRestrictions: must be on or after the start date, and must fall on a whole number of periods after the start date </b>","disabled":true},{"key":"adhoc_ddi[debits][debit][][amount]","value":"1400","type":"text","description":"<b>Format: Integer, the value of the debit amount in pence.  \nRestrictions: value between 0 and the SU's maximum_debit_amount </b>","disabled":true},{"key":"adhoc_ddi[debits][debit][][date]","value":"2019-02-27","type":"text","description":"<b>Format: YYYY-MM-DD  \nRestrictions: must be on or after the start date, and must fall on a whole number of periods after the start date </b>","disabled":true}]},"url":"{{base_url}}/api/ddi/adhoc/validate"},"status":"OK","code":200,"_postman_previewlanguage":"xml","header":[{"key":"Date","value":"Fri, 22 Feb 2019 16:10:45 GMT"},{"key":"Server","value":"Apache"},{"key":"Cache-Control","value":"private, max-age=0, must-revalidate"},{"key":"X-Runtime","value":"0.71796"},{"key":"Strict-Transport-Security","value":"max-age=63072000; includeSubdomains; preload"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Set-Cookie","value":"auth_token=; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"_PSLLite_session_id=59c10b241683faff8f68dab95c0ecf7c; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"incap_ses_454_1416256=a; Max-Age=0; path=/; expires=Tue, 19 Feb 2019 10:15:09 GMT; Domain=.ddprocessing.co.uk"},{"key":"Content-Length","value":"344"},{"key":"Status","value":"200 OK"},{"key":"X-XSS-Protection","value":"1; mode=block"},{"key":"Keep-Alive","value":"timeout=5, max=100"},{"key":"Connection","value":"Keep-Alive"},{"key":"Content-Type","value":"application/xml; charset=utf-8"},{"key":"X-Iinfo","value":"10-5559133-5566320 NNNN CT(3 21 0) RT(1550851715073 183680) q(0 0 0 -1) r(9 9) U5"},{"key":"X-CDN","value":"Incapsula"}],"cookie":[],"responseTime":null,"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<successful>\n    <success>DDI details valid</success>\n    <success>Bank Account supports Direct Debit Instructions</success>\n    <success bank_name='HSBBC BANK PLC' branch='Broadway' address1='32 Bridge St' address2='' address3='' address4='' town='Evesham' county='Worcs.' postcode='WR11 4RU' />\n</successful>"}],"_postman_id":"23d97a1a-b71d-4bfc-8632-550235f92a8e"},{"name":"ddi/adhoc/validate (with extended parameters)","id":"25e5d8cc-7657-440a-9899-74e6feec067b","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"key":"adhoc_ddi[debits][debit][][amount]","value":"{{collection_1_amount}}","type":"text","description":"<p><b>Format:</b> integer, the value of the debit amount <i>in pence</i></p>\n"},{"key":"adhoc_ddi[debits][debit][][date]","value":"{{collection_1_date}}","type":"text","description":"<p><b>Format:</b> YYYY-MM-DD</p>\n"},{"key":"adhoc_ddi[debits][debit][][amount]","value":"{{collection_2_amount}}","type":"text","description":"<p><b>Format:</b> integer, the value of the debit amount <i>in pence</i></p>\n"},{"key":"adhoc_ddi[debits][debit][][date]","value":"{{collection_2_date}}","type":"text","description":"<p><b>Format:</b> YYYY-MM-DD</p>\n"}]},"url":"{{base_url}}/ddi/adhoc/validate","description":"<p>When creating adhoc collections, or overriding an existing collection, pairs of amount and date values must be passed together.</p>\n","urlObject":{"path":["ddi","adhoc","validate"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"25e5d8cc-7657-440a-9899-74e6feec067b"}],"id":"9050bf7f-c5c8-4c49-a192-8ae878151db2","description":"<h4 id=\"description\">Description</h4>\n<p><a href=\"#23d97a1a-b71d-4bfc-8632-550235f92a8e\">ddi/adhoc/validate</a> allows an API user to check the details for a DDI without committing to creating it. It is intended to be used as part of the sign-up user journey so that when the payer confirms, the <a href=\"#864f7242-2c0c-4021-86da-254e7b530930\">create</a> call completes successfully.</p>\n<p>The call validates that all supplied values are accepted by the SmartDebit system. The call also verifies that the payer's bank account accepts Direct Debits. If used with <a href=\"#25e5d8cc-7657-440a-9899-74e6feec067b\">extended parameters</a> the call can also validate an initial set of collections.</p>\n<p><strong>Note:</strong></p>\n<ul>\n<li>When validating in a sandbox environment, a sort code of six zeros should be used to return a successful response. Typically an account number of 12345678 would be used.</li>\n<li>Using eight zeros for the account number returns an error response (invalid account details).</li>\n</ul>\n<h4 id=\"parameters\">Parameters</h4>\n<p><strong>Mandatory parameters</strong> are:</p>\n<ul>\n<li>pslid</li>\n<li>sort code, account number, account name</li>\n<li>first name &amp; last name</li>\n</ul>\n<p><a href=\"#86a42735-f1f4-4bb2-a135-81860b0f1313\">Character restrictions</a> apply to parameters. Accented characters and apostrophes should be removed from name and address values, as should most non-alphanumerics.</p>\n<p><strong>Optional parameters</strong> are listed <a href=\"#23d97a1a-b71d-4bfc-8632-550235f92a8e\">below</a>.</p>\n<p><strong>Conditional parameters</strong> (those that depend on the service user configuration) include:</p>\n<ul>\n<li>reference number</li>\n<li>email address, which is required if SmartDebit is to issue email notifications on behalf of the service user</li>\n<li>start date (optional), which must allow sufficient time for the DDI to lodge and this interval is derived from the service user's advance notice period</li>\n<li>start date can also be restricted to configured days of the month</li>\n<li>debit amounts must not exceed a configured maximum</li>\n</ul>\n<p>The reference number must be unique and must comply with the <a href=\"#4d8a7173-5301-41e1-b171-7d4fde1fef6b\"> reference number rules</a>. Although SmartDebit is able to generate compliant reference numbers, the validate call is usually used for the sign-up user journey in which the details of the DDI, including the reference number, are presented to the payer before they confirm. For this reason, the service user would normally generate the reference number.</p>\n<p>There is a practical upper limit of 19 months in the future for the start date. This exists because the DDI is submitted a maximum of 6 months after creation and expires after 13 months of inactivity.</p>\n<p>The start_date parameter serves little purpose for adhoc payers, though it can be used to batch new payer submissions and therefore reduce submission costs.</p>\n<p><strong>Extended parameters</strong> may be used with this call to validate the values for an optional initial set of collections. Collections are specified by pairs of parameters:</p>\n<ul>\n<li><code>adhoc_ddi[debits][debit][][amount]</code> - the collection amount in pence</li>\n<li><code>adhoc_ddi[debits][debit][][date]</code> - the collection date in YYYY-MM-DD format, which must be on or after the start date</li>\n</ul>\n<p>It is recommended that the XML body method of parameter passing is used if multiple debits are to be validated.</p>\n<h4 id=\"response\">Response</h4>\n<p>A successful call to ddi/adhoc/validate returns an XML document with a root tag of &lt;successful&gt;, with three &lt;success&gt; entries, the third of which includes information about the bank branch. </p>\n<p>Note the single quotes in this response.</p>\n<h4 id=\"errors\">Errors</h4>\n<p>Errors are returned with an HTTP status other than \"200 OK\".</p>\n<p>Missing parameters result in appropriate errors. A missing or incorrect service user returns one of the errors <code>&lt;error&gt;No service user id supplied.&lt;/error&gt;</code>, <code>&lt;error&gt;Invalid Service User ID: 'su_pslid'&lt;/error&gt;</code> or in the case of calling ddi/adhoc/validate for a service user configured for <em>variable</em> DDIs, <code>&lt;error&gt;Service User 'Example SU' does not support Adhoc DDIs&lt;/error&gt;</code>.  The error is contained in an <code>&lt;errors&gt;</code> root tag.</p>\n<p>Omitting any required parameters or supplying invalid values for any parameter may return a listing of all validation errors in one document. For example:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>422 Unprocessable Entity\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Sort code is invalid&lt;/error&gt;\n  &lt;error&gt;Account name can't be blank&lt;/error&gt;\n  &lt;error&gt;Account name is too short (minimum is 3 characters)&lt;/error&gt;\n  &lt;error&gt;Account name only letters, numbers, spaces, hyphens, forward slash, ampersand and full stops are   permitted in account name&lt;/error&gt;\n  &lt;error&gt;Last name can't be blank&lt;/error&gt;\n  &lt;error&gt;Last name only letters, numbers, spaces, hyphens, forward slash, ampersand and full stops are   permitted in last names&lt;/error&gt;\n  &lt;error&gt;Account number must not be empty&lt;/error&gt;\n  &lt;error&gt;First name can't be blank&lt;/error&gt;\n  &lt;error&gt;First name only letters, numbers, spaces, hyphens, forward slash, ampersand and full stops are   permitted in first names&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><p>If all parameters pass validation, it is still possible that the bank account details are invalid. For example:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>422 Unprocessable Entity\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Invalid bank account details (Sort code not found)&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><p>If extended parameters are used then the debits are validated and can generate errors.</p>\n<h4 id=\"version-history\">Version history</h4>\n<table>\n<tr>\n<td></td>\n<td>The <i>adhoc_ddi[end_date]</i> parameter is deprecated because it is used to control payment schedules and the adhoc model does not support payment schedules.</td>\n</tr>\n</table>\n","event":[{"listen":"prerequest","script":{"id":"579ce3b7-7539-47e2-8669-a80ca65e0309","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"89a56697-d879-4cd6-a2ae-b06d9e3de418","type":"text/javascript","exec":[""]}}],"_postman_id":"9050bf7f-c5c8-4c49-a192-8ae878151db2"},{"name":"4.2.7 Adhoc create","item":[{"name":"ddi/adhoc/create","event":[{"listen":"test","script":{"id":"823d555b-1ac4-45cf-905a-9ed624fb03e1","exec":["pm.test(\"Response time is less than 1000ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(1000);","});","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","pm.test(\"Body matches string\", function () {","    pm.expect(pm.response.text()).to.include('<?xml version=\"1.0\" encoding=\"UTF-8\"?>');","    pm.expect(pm.response.text()).to.include(\"<adhoc_ddi>\");","    pm.expect(pm.response.text()).to.include(\"<adhoc_ddi>\");","});","","","//Schema Validation","var jsonObject = xml2Json(responseBody);","console.log(JSON.stringify(jsonObject));","","var schema = {","  \"definitions\": {},","  \"$schema\": \"http://json-schema.org/draft-07/schema#\",","  \"$id\": \"http://example.com/root.json\",","  \"type\": \"object\",","  \"properties\": {","    \"adhoc_ddi\": {","      \"$id\": \"#/properties/adhoc_ddi\",","      \"type\": \"object\",","      \"properties\": {","        \"address_1\": {","          \"$id\": \"#/properties/adhoc_ddi/properties/address_1\",","          \"type\": \"string\"","        },","        \"address_2\": {","          \"$id\": \"#/properties/adhoc_ddi/properties/address_2\",","          \"type\": \"string\"","        },","        \"address_3\": {","          \"$id\": \"#/properties/adhoc_ddi/properties/address_3\",","          \"type\": \"string\"","        },","        \"country\": {","          \"$id\": \"#/properties/adhoc_ddi/properties/country\",","          \"type\": \"string\"","        },","        \"county\": {","          \"$id\": \"#/properties/adhoc_ddi/properties/county\",","          \"type\": \"string\"","        },","        \"email_address\": {","          \"$id\": \"#/properties/adhoc_ddi/properties/email_address\",","          \"type\": \"string\"","        },","        \"end_date\": {","          \"$id\": \"#/properties/adhoc_ddi/properties/end_date\",","          \"type\": \"object\",","          \"properties\": {","            \"_\": {","              \"$id\": \"#/properties/adhoc_ddi/properties/end_date/properties/_\",","              \"type\": \"string\"","            },","            \"$\": {","              \"$id\": \"#/properties/adhoc_ddi/properties/end_date/properties/$\",","              \"type\": \"object\",","              \"properties\": {","                \"type\": {","                  \"$id\": \"#/properties/adhoc_ddi/properties/end_date/properties/$/properties/type\",","                  \"type\": \"string\"","                }","              }","            }","          }","        },","        \"first_name\": {","          \"$id\": \"#/properties/adhoc_ddi/properties/first_name\",","          \"type\": \"string\"","        },","        \"last_name\": {","          \"$id\": \"#/properties/adhoc_ddi/properties/last_name\",","          \"type\": \"string\"","        },","        \"payer_reference\": {","          \"$id\": \"#/properties/adhoc_ddi/properties/payer_reference\",","          \"type\": \"string\"","        },","        \"postcode\": {","          \"$id\": \"#/properties/adhoc_ddi/properties/postcode\",","          \"type\": \"string\"","        },","        \"promotion\": {","          \"$id\": \"#/properties/adhoc_ddi/properties/promotion\",","          \"type\": \"string\"","        },","        \"reference_number\": {","          \"$id\": \"#/properties/adhoc_ddi/properties/reference_number\",","          \"type\": \"string\"","        },","        \"start_date\": {","          \"$id\": \"#/properties/adhoc_ddi/properties/start_date\",","          \"type\": \"object\",","          \"properties\": {","            \"_\": {","              \"$id\": \"#/properties/adhoc_ddi/properties/start_date/properties/_\",","              \"type\": \"string\"","            },","            \"$\": {","              \"$id\": \"#/properties/adhoc_ddi/properties/start_date/properties/$\",","              \"type\": \"object\",","              \"properties\": {","                \"type\": {","                  \"$id\": \"#/properties/adhoc_ddi/properties/start_date/properties/$/properties/type\",","                  \"type\": \"string\"","                }","              }","            }","          }","        },","        \"title\": {","          \"$id\": \"#/properties/adhoc_ddi/properties/title\",","          \"type\": \"string\"","        },","        \"town\": {","          \"$id\": \"#/properties/adhoc_ddi/properties/town\",","          \"type\": \"string\"","        },","        \"service_user\": {","          \"$id\": \"#/properties/adhoc_ddi/properties/service_user\",","          \"type\": \"object\",","          \"properties\": {","            \"pslid\": {","              \"$id\": \"#/properties/adhoc_ddi/properties/service_user/properties/pslid\",","              \"type\": \"string\"","            }","          }","        }","      }","    }","  }","};","","","pm.test('Schema is valid', function() {","  pm.expect(tv4.validate(jsonObject, schema)).to.be.true;","  ","});","",""],"type":"text/javascript"}},{"listen":"prerequest","script":{"id":"fff635c3-7caf-4dda-aaa6-46b5cf988c7b","exec":["","pm.sendRequest(\"https://sandbox.smartdebit.co.uk/Scripts/smartdebit.jasmine.js\", (err, res) => { pm.globals.set('jasmine' ,res.text() ) });","","eval(pm.globals.get('jasmine'));","","pm.environment.set(\"reference\", (sd.testing.getReferenceNumber('SD1')));","","","pm.environment.set('account_number','00000007');","pm.environment.set('sort_code', '111111');","","var d = new Date();","d.setHours(0,0,0,0);","d.setMonth(d.getMonth()+1);","","pm.environment.set('create_startdate', sd.testing.getISODate(d));","//pm.globals.set('account_number','12345678');","//pm.globals.set('sort_code', '000000');","","",""],"type":"text/javascript"}}],"id":"a4835f2a-1911-4e32-b5aa-4386c916fa20","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"description":"<p><i>Required</i><br />\nService user identifier</p>\n","key":"adhoc_ddi[service_user][pslid]","type":"text","value":"{{pslid}}"},{"description":"<p><i>Conditional (usually required)</i><br />\nUnique identifier for the DDI<br />\n<b>Format:</b> 6 to 18 characters. See <a href=\"#4d8a7173-5301-41e1-b171-7d4fde1fef6b\">reference number rules</a>.</p>\n","key":"adhoc_ddi[reference_number]","type":"text","value":"{{reference}}"},{"description":"<p><i>Required</i><br />\n<b>Format:</b> either 111111 or 11-11-11</p>\n","key":"adhoc_ddi[sort_code]","type":"text","value":"{{sort_code}}"},{"description":"<p><i>Required</i><br />\n<b>Format:</b> 8 digit number</p>\n","key":"adhoc_ddi[account_number]","type":"text","value":"{{account_number}}"},{"description":"<p><i>Required</i><br />\n<b>Format:</b> 3 to 18 characters </p>\n","key":"adhoc_ddi[account_name]","type":"text","value":"{{account_name}}"},{"description":"<p><i>Required</i><br />\n<b>Format:</b> 1 to 32 characters</p>\n","key":"adhoc_ddi[first_name]","type":"text","value":"{{first_name}}"},{"description":"<p><i>Required</i><br />\n<b>Format:</b> 1 to 32 characters</p>\n","key":"adhoc_ddi[last_name]","type":"text","value":"{{last_name}}"},{"key":"adhoc_ddi[start_date]","type":"text","value":"{{start_date}}","description":"<p><b>Format:</b> YYYY-MM-DD<br /><b>Default:</b> next valid start date</p>\n"},{"key":"adhoc_ddi[end_date]","type":"text","value":"{{end_date}}","description":"<p><i>Deprecated</i><br /><b>Format:</b> YYYY-MM-DD  <br /><b>Default:</b> none</p>\n"},{"key":"adhoc_ddi[title]","type":"text","value":"{{title}}","description":"<p><b>Format:</b> 1 to 32 characters</p>\n"},{"key":"adhoc_ddi[email_address]","type":"text","value":"{{email_address}}","description":"<p><b>Format:</b> 5 to 64 characters</p>\n"},{"key":"adhoc_ddi[company_name]","type":"text","value":"{{company_name}}","description":"<p><b>Format:</b> 1 to 32 characters</p>\n"},{"key":"adhoc_ddi[payer_reference]","type":"text","value":"{{payer_reference}}","description":"<p><b>Format:</b> 1 to 255 characters</p>\n"},{"description":"<p><b>Format:</b> 1 to 255 characters</p>\n","key":"adhoc_ddi[address_1]","type":"text","value":"{{address1}}"},{"key":"adhoc_ddi[address_2]","type":"text","value":"{{address2}}","description":"<p><b>Format:</b> 1 to 32 characters</p>\n"},{"key":"adhoc_ddi[address_3]","type":"text","value":"{{address3}}","description":"<p><b>Format:</b> 1 to 32 characters</p>\n"},{"description":"<p><b>Format:</b> 1 to 255 characters</p>\n","key":"adhoc_ddi[town]","type":"text","value":"{{town}}"},{"key":"adhoc_ddi[county]","type":"text","value":"{{county}}","description":"<p><b>Format:</b> 1 to 255 characters</p>\n"},{"description":"<p><b>Format:</b> 1 to 255 characters</p>\n","key":"adhoc_ddi[postcode]","type":"text","value":"{{postcode}}"},{"description":"<p><b>Format:</b> 1 to 255 characters</p>\n","key":"adhoc_ddi[country]","type":"text","value":"{{country}}"},{"key":"adhoc_ddi[support_gift_aid]","value":"{{support_gift_aid}}","description":"<p><b>Format:</b> boolean, accepts 'true', 'false', 1 or 0<br /><b>Default:</b> false</p>\n","type":"text"},{"key":"adhoc_ddi[promotion]","type":"text","value":"{{promotion}}","description":"<p><b>Format:</b> 1 to 8 characters</p>\n"}]},"url":"{{base_url}}/ddi/adhoc/create","urlObject":{"path":["ddi","adhoc","create"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"0d6b44e6-fe2f-4107-bc03-a72fb8f1ea08","name":"create","originalRequest":{"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"description":"<b>A unique reference number must be passed.    <br>Format: plain text Restrictions: Unique, 6 to 18 characters May not contain solidus (/)  and further restrictions apply.</b>","key":"adhoc_ddi[reference_number]","type":"text","value":"{{reference}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"adhoc_ddi[first_name]","type":"text","value":"{{create_first_name}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"adhoc_ddi[last_name]","type":"text","value":"{{create_last_name}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"adhoc_ddi[address_1]","type":"text","value":"{{create_address1}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"adhoc_ddi[town]","type":"text","value":"{{create_town}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"adhoc_ddi[postcode]","type":"text","value":"{{create_postcode}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"adhoc_ddi[country]","type":"text","value":"{{create_country}}"},{"description":"<b>Format: plain text <br>Restrictions: 3 to 18 characters </b>","key":"adhoc_ddi[account_name]","type":"text","value":"{{create_account_name}}"},{"description":"<b>Format: Sort Code – either 111111 or 11-11-11 format accepted.</b>","key":"adhoc_ddi[sort_code]","type":"text","value":"{{sort_code}}"},{"description":"<b>Format: 8 digit number </b>","key":"adhoc_ddi[account_number]","type":"text","value":"{{account_number}}"},{"description":"<b>Format: plain text   <br>Restrictions: 5 to 255 characters, must match existing SU's pslid </b>","key":"adhoc_ddi[service_user][pslid]","type":"text","value":"{{pslid}}"},{"key":"adhoc_ddi[payer_reference]","type":"text","value":"--","disabled":true},{"key":"adhoc_ddi[start_date]","type":"text","value":"2018-10-20","disabled":true},{"key":"adhoc_ddi[end_date]","type":"text","value":"2020-01-01","disabled":true},{"key":"adhoc_ddi[title]","type":"text","value":"Mr","disabled":true},{"key":"adhoc_ddi[address_2]","type":"text","value":"--","disabled":true},{"key":"adhoc_ddi[address_3]","type":"text","value":"--","disabled":true},{"key":"adhoc_ddi[county]","type":"text","value":"Rails","disabled":true},{"key":"adhoc_ddi[email_address]","type":"text","value":"ruby_api@smartdebit.com","disabled":true},{"key":"adhoc_ddi[promotion]","type":"text","value":"12345678","disabled":true},{"key":"adhoc_ddi[company_name]","type":"text","value":"RUBY API","disabled":true}]},"url":"{{base_url}}/api/ddi/adhoc/create"},"status":"OK","code":200,"_postman_previewlanguage":"xml","header":[{"key":"Date","value":"Thu, 14 Feb 2019 12:04:54 GMT"},{"key":"Server","value":"Apache"},{"key":"Cache-Control","value":"private, max-age=0, must-revalidate"},{"key":"X-Runtime","value":"0.21920"},{"key":"Strict-Transport-Security","value":"max-age=63072000; includeSubdomains; preload"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Set-Cookie","value":"auth_token=; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"_PSLLite_session_id=59c10b241683faff8f68dab95c0ecf7c; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"incap_ses_454_1416256=a; Max-Age=0; path=/; expires=Mon, 11 Feb 2019 12:10:11 GMT; Domain=.ddprocessing.co.uk"},{"key":"Content-Length","value":"445"},{"key":"Status","value":"200 OK"},{"key":"X-XSS-Protection","value":"1; mode=block"},{"key":"Keep-Alive","value":"timeout=5, max=100"},{"key":"Connection","value":"Keep-Alive"},{"key":"Content-Type","value":"application/xml; charset=utf-8"},{"key":"X-Iinfo","value":"7-9605307-9605308 NNNN CT(3 7 0) RT(1550145927933 58) q(0 0 1 -1) r(3 3) U5"},{"key":"X-CDN","value":"Incapsula"}],"cookie":[],"responseTime":null,"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<adhoc_ddi>\n    <address_1>1 ApiTest Road</address_1>\n    <country>United Kingdom</country>\n    <first_name>Test</first_name>\n    <last_name>Smith</last_name>\n    <postcode>RR23 3AP</postcode>\n    <reference_number>SD119011412456372</reference_number>\n    <start_date type=\"datetime\">2019-03-01T00:00:00Z</start_date>\n    <town>Bagshot</town>\n    <service_user>\n        <pslid>apidocument</pslid>\n    </service_user>\n</adhoc_ddi>"}],"_postman_id":"a4835f2a-1911-4e32-b5aa-4386c916fa20"},{"name":"ddi/adhoc/create (with extended parameters)","id":"63f34aa5-6818-4da4-a1a5-7100ebf5d657","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"key":"adhoc_ddi[debits][debit][][amount]","value":"{{collection_1_amount}}","type":"text","description":"<p><b>Format:</b> integer, the value of the debit amount <i>in pence</i></p>\n"},{"key":"adhoc_ddi[debits][debit][][date]","value":"{{collection_1_date}}","type":"text","description":"<p><b>Format:</b> YYYY-MM-DD</p>\n"},{"key":"adhoc_ddi[debits][debit][][amount]","value":"{{collection_2_amount}}","type":"text","description":"<p><b>Format:</b> integer, the value of the debit amount <i>in pence</i></p>\n"},{"key":"adhoc_ddi[debits][debit][][date]","value":"{{collection_2_date}}","type":"text","description":"<p><b>Format:</b> YYYY-MM-DD</p>\n"}]},"url":"{{base_url}}/ddi/adhoc/create","description":"<p>When creating adhoc collections, or overriding an existing collection, pairs of amount and date values must be passed together.</p>\n","urlObject":{"path":["ddi","adhoc","create"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"63f34aa5-6818-4da4-a1a5-7100ebf5d657"}],"id":"864f7242-2c0c-4021-86da-254e7b530930","description":"<h4 id=\"description\">Description</h4>\n<p><a href=\"#a4835f2a-1911-4e32-b5aa-4386c916fa20\">ddi/adhoc/create</a> is used to create a new payer. The call should be made only if the validate call has already returned a success result. ddi/adhoc/create takes the same parameters as <a href=\"#23d97a1a-b71d-4bfc-8632-550235f92a8e\">ddi/adhoc/validate</a>. An arbitrary number of debits can also be created.</p>\n<p>The new payer is created and is immediately accessible in the SmartDebit Pulse web portal. If email notifications are configured for the service user and the payer's email address was supplied, a confirmation email is sent to the payer. The details of the DDI are scheduled for submission to Bacs in time for the first collection to be taken.</p>\n<h4 id=\"parameters\">Parameters</h4>\n<p>Refer to the <a href=\"#9050bf7f-c5c8-4c49-a192-8ae878151db2\">validate</a> section for details of the accepted parameters.</p>\n<h4 id=\"response\">Response</h4>\n<p>A successful response from ddi/adhoc/create is an XML rendition of the payer with a root tag of adhoc_ddi. Any unpopulated optional fields on the DDI are omitted from the XML document. If extended parameters are passed, the response includes the debits.</p>\n<h4 id=\"errors\">Errors</h4>\n<p>Refer to the validate section for example error responses.</p>\n","event":[{"listen":"prerequest","script":{"id":"4f445f7e-c1ac-4b3f-8283-79eaba4211ab","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"863f3b6f-48a5-4c42-a781-18b669b8138a","type":"text/javascript","exec":[""]}}],"_postman_id":"864f7242-2c0c-4021-86da-254e7b530930"},{"name":"4.2.8 Adhoc update","item":[{"name":"ddi/adhoc/{{reference_number}}","event":[{"listen":"test","script":{"id":"a636b107-dcf0-4ca9-9d34-e3270a511efd","exec":["eval(pm.globals.get('jasmine'));","","pm.test(\"Response time is less than 400ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(400);","});","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","pm.test(\"Body matches string\", function () {","    pm.expect(pm.response.text()).to.include('<?xml version=\"1.0\" encoding=\"UTF-8\"?>');","    pm.expect(pm.response.text()).to.include('<adhoc_ddi>');","    pm.expect(pm.response.text()).to.include('<reference_number>' + pm.environment.get('reference_number') + '</reference_number>');","    pm.expect(pm.response.text()).to.include('</adhoc_ddi>');","});","","","//               SCHEMA Validation                      //","var result = xml2Json(responseBody);                    //     ","var schema =  sd.api.schema.updateAdhocResponse;   //","                                                        //","//var schema =  sd.api.schema.dumpResponse;             //","                                                        //","  pm.test('Schema is valid', function() {               //","    pm.expect(tv4.validate(result, schema)).to.be.true; //","  });                                                   //","//               SCHEMA Validation                      //","",""],"type":"text/javascript"}},{"listen":"prerequest","script":{"id":"1c89a4a9-73f1-45e0-9047-d36e7f73ef58","exec":["","pm.sendRequest(\"https://sandbox.smartdebit.co.uk/Scripts/smartdebit.jasmine.js\", (err, res) => { pm.globals.set('jasmine' ,res.text() ) });","","eval(pm.globals.get('jasmine'));","","var authHash = btoa(pm.environment.get('api_user') + \":\" + pm.environment.get('api_user_password'));","","var dataGen = sd.testing;","","var payer = dataGen.getJsonPayer(pm.environment.get('pslid'), dataGen.getReferenceNumber('SD1'), 3, false);","","","var payerFormData = dataGen.json2formData(payer, 'adhoc_ddi');","//var payerFormData = dataGen.json2formData(payer, 'variable_ddi');","","const createPayerRequest = {","  url: pm.environment.get('base_url') + '/ddi/adhoc/create',","  //url: pm.environment.get('base_url') + '/api/ddi/variable/create',","  method: 'POST',","  header: `Authorization:Basic ${authHash}`,","  body: {","    mode: 'formdata',","    formdata: payerFormData","  }","};","","pm.sendRequest(createPayerRequest, function (err, res) {","  console.log(err ? err : res.text());","  ","  pm.environment.set('reference_number', payer.reference_number);","  console.log('reference number for the payer we try to update is: ' + payer.reference_number);","});","","var debitDate = new Date();","debitDate.setHours(0,0,0,0);","debitDate = debitDate.addMonths(3);","","var newStartDate = new Date();","newStartDate.setHours(0,0,0,0);","newStartDate = newStartDate.addMonths(2);","","pm.environment.set('update_dd_amount', dataGen.randomInt(100, 10000));","pm.environment.set('update_dd_date', dataGen.getISODate(debitDate));","","pm.environment.set('update_first_name', 'Updated-Bob');","pm.environment.set('update_last_name', 'Updated-Smith');","pm.environment.set('validate_adhoc_company_name', 'Acme Co.');","pm.environment.set('update_address1', '123 SandBox Street');","pm.environment.set('update_town', 'Alfold');","pm.environment.set('update_postcode', 'GU99 9ZZ');","pm.environment.set('update_country', 'United Kingdom');","pm.environment.set('update_startdate', newStartDate);"],"type":"text/javascript"}}],"id":"943211f6-8f5f-4ac4-9d64-afbfe6959896","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"PUT","header":[],"body":{"mode":"formdata","formdata":[{"key":"adhoc_ddi[sort_code]","value":"{{sort_code}}:","type":"text","description":"<p><b>Format:</b> either 111111 or 11-11-11</p>\n"},{"key":"adhoc_ddi[account_number]","value":"{{account_number}}","type":"text","description":"<p><b>Format:</b> 8 digit number</p>\n"},{"key":"adhoc_ddi[account_name]","value":"{{account_name}}","type":"text","description":"<p><b>Format:</b> 3 to 18 characters </p>\n"},{"key":"adhoc_ddi[first_name]","value":"{{first_name}}","type":"text","description":"<p><b>Format:</b> 1 to 32 characters</p>\n"},{"key":"adhoc_ddi[last_name]","value":"{{last_name}}","type":"text","description":"<p><b>Format:</b> 1 to 32 characters</p>\n"},{"key":"adhoc_ddi[start_date]","value":"{{start_date}}","type":"text","description":"<p><b>Format:</b> YYYY-MM-DD</p>\n"},{"key":"adhoc_ddi[end_date]","value":"{{end_date}}","type":"text","description":"<p><i>Deprecated</i><br /><b>Format:</b> YYYY-MM-DD</p>\n"},{"key":"adhoc_ddi[title]","value":"{{title}}","type":"text","description":"<p><b>Format:</b> 1 to 32 characters</p>\n"},{"key":"adhoc_ddi[email_address]","value":"{{email_address}}","type":"text","description":"<p><b>Format:</b> 1 to 64 characters</p>\n"},{"key":"adhoc_ddi[company_name]","value":"{{company_name}}","type":"text","description":"<p><b>Format:</b> 1 to 32 characters</p>\n"},{"key":"adhoc_ddi[payer_reference]","value":"{{payer_reference}}","type":"text","description":"<p><b>Format:</b> 1 to 255 characters</p>\n"},{"key":"adhoc_ddi[address_1]","value":"{{address_1}}","type":"text","description":"<p><b>Format:</b> 1 to 255 characters</p>\n"},{"key":"adhoc_ddi[address_2]","value":"{{address_2}}","type":"text","description":"<p><b>Format:</b> 1 to 32 characters</p>\n"},{"key":"adhoc_ddi[address_3]","value":"{{address_3}}","type":"text","description":"<p><b>Format:</b> 1 to 32 characters</p>\n"},{"key":"adhoc_ddi[town]","value":"{{town}}","type":"text","description":"<p><b>Format:</b> 1 to 255 characters</p>\n"},{"key":"adhoc_ddi[county]","value":"{{county}}","type":"text","description":"<p><b>Format:</b> 1 to 255 characters</p>\n"},{"key":"adhoc_ddi[postcode]","value":"{{postcode}}","type":"text","description":"<p><b>Format:</b> 1 to 255 characters</p>\n"},{"key":"adhoc_ddi[country]","value":"{{country}}","type":"text","description":"<p><b>Format:</b> 1 to 255 characters</p>\n"},{"key":"adhoc_ddi[support_gift_aid]","value":"{{support_gift_aid}}","type":"text","description":"<p><b>Format:</b> boolean, accepts 'true', 'false', 1 or 0</p>\n"},{"key":"adhoc_ddi[promotion]","value":"{{promotion}}","type":"text","description":"<p><b>Format:</b> 1 to 8 characters</p>\n"}]},"url":"{{base_url}}/ddi/adhoc/{{reference_number}}","description":"<p>All parameters are optional.</p>\n","urlObject":{"path":["ddi","adhoc","{{reference_number}}"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"3c463d1d-9dd7-4b77-a908-2530c515a12e","name":"update","originalRequest":{"method":"PUT","header":[],"body":{"mode":"formdata","formdata":[{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"adhoc_ddi[first_name]","type":"text","value":"{{update_first_name}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"adhoc_ddi[last_name]","type":"text","value":"{{update_last_name}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"adhoc_ddi[address_1]","type":"text","value":"{{update_address1}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"adhoc_ddi[town]","type":"text","value":"{{update_town}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"adhoc_ddi[postcode]","type":"text","value":"{{update_postcode}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"adhoc_ddi[country]","type":"text","value":"{{update_country}}"},{"description":"<b>Format: YYYY-MM-DD   <br>Restrictions: Must be far enough in the future to allow the SU's lead time.</b>","key":"adhoc_ddi[start_date]","type":"text","value":"{{update_startdate}}"}]},"url":"{{base_url}}/api/ddi/adhoc/{{reference_number}}"},"status":"OK","code":200,"_postman_previewlanguage":"xml","header":[{"key":"Date","value":"Thu, 14 Feb 2019 13:51:07 GMT"},{"key":"Server","value":"Apache"},{"key":"Cache-Control","value":"private, max-age=0, must-revalidate"},{"key":"X-Runtime","value":"0.13529"},{"key":"Strict-Transport-Security","value":"max-age=63072000; includeSubdomains; preload"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Set-Cookie","value":"auth_token=; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"_PSLLite_session_id=59c10b241683faff8f68dab95c0ecf7c; path=/; HttpOnly; secure"},{"key":"Content-Length","value":"463"},{"key":"Status","value":"200 OK"},{"key":"X-XSS-Protection","value":"1; mode=block"},{"key":"Keep-Alive","value":"timeout=5, max=99"},{"key":"Connection","value":"Keep-Alive"},{"key":"Content-Type","value":"application/xml; charset=utf-8"},{"key":"X-Iinfo","value":"14-28858955-28870981 SNNN RT(1550152240799 60054) q(0 0 0 -1) r(2 2) U5"},{"key":"X-CDN","value":"Incapsula"}],"cookie":[],"responseTime":null,"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<adhoc_ddi>\n    <address_1>123 SandBox Street</address_1>\n    <country>United Kingdom</country>\n    <first_name>Updated-Bob</first_name>\n    <last_name>Updated-Smith</last_name>\n    <postcode>GU99 9ZZ</postcode>\n    <reference_number>SD119011413519424</reference_number>\n    <start_date type=\"datetime\">2019-04-13T00:00:00Z</start_date>\n    <town>Alfold</town>\n    <service_user>\n        <pslid>apidocument</pslid>\n    </service_user>\n</adhoc_ddi>"}],"_postman_id":"943211f6-8f5f-4ac4-9d64-afbfe6959896"},{"name":"ddi/adhoc/{{reference_number}} (with extended parameters)","event":[{"listen":"test","script":{"id":"a636b107-dcf0-4ca9-9d34-e3270a511efd","exec":["eval(pm.globals.get('jasmine'));","","pm.test(\"Response time is less than 400ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(400);","});","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","pm.test(\"Body matches string\", function () {","    pm.expect(pm.response.text()).to.include('<?xml version=\"1.0\" encoding=\"UTF-8\"?>');","    pm.expect(pm.response.text()).to.include('<adhoc_ddi>');","    pm.expect(pm.response.text()).to.include('<reference_number>' + pm.environment.get('reference_number') + '</reference_number>');","    pm.expect(pm.response.text()).to.include('</adhoc_ddi>');","});","","","//               SCHEMA Validation                      //","var result = xml2Json(responseBody);                    //     ","var schema =  sd.api.schema.updateAdhocResponse;   //","                                                        //","//var schema =  sd.api.schema.dumpResponse;             //","                                                        //","  pm.test('Schema is valid', function() {               //","    pm.expect(tv4.validate(result, schema)).to.be.true; //","  });                                                   //","//               SCHEMA Validation                      //","",""],"type":"text/javascript"}},{"listen":"prerequest","script":{"id":"1c89a4a9-73f1-45e0-9047-d36e7f73ef58","exec":["","pm.sendRequest(\"https://sandbox.smartdebit.co.uk/Scripts/smartdebit.jasmine.js\", (err, res) => { pm.globals.set('jasmine' ,res.text() ) });","","eval(pm.globals.get('jasmine'));","","var authHash = btoa(pm.environment.get('api_user') + \":\" + pm.environment.get('api_user_password'));","","var dataGen = sd.testing;","","var payer = dataGen.getJsonPayer(pm.environment.get('pslid'), dataGen.getReferenceNumber('SD1'), 3, false);","","","var payerFormData = dataGen.json2formData(payer, 'adhoc_ddi');","//var payerFormData = dataGen.json2formData(payer, 'variable_ddi');","","const createPayerRequest = {","  url: pm.environment.get('base_url') + '/ddi/adhoc/create',","  //url: pm.environment.get('base_url') + '/api/ddi/variable/create',","  method: 'POST',","  header: `Authorization:Basic ${authHash}`,","  body: {","    mode: 'formdata',","    formdata: payerFormData","  }","};","","pm.sendRequest(createPayerRequest, function (err, res) {","  console.log(err ? err : res.text());","  ","  pm.environment.set('reference_number', payer.reference_number);","  console.log('reference number for the payer we try to update is: ' + payer.reference_number);","});","","var debitDate = new Date();","debitDate.setHours(0,0,0,0);","debitDate = debitDate.addMonths(3);","","var newStartDate = new Date();","newStartDate.setHours(0,0,0,0);","newStartDate = newStartDate.addMonths(2);","","pm.environment.set('update_dd_amount', dataGen.randomInt(100, 10000));","pm.environment.set('update_dd_date', dataGen.getISODate(debitDate));","","pm.environment.set('update_first_name', 'Updated-Bob');","pm.environment.set('update_last_name', 'Updated-Smith');","pm.environment.set('validate_adhoc_company_name', 'Acme Co.');","pm.environment.set('update_address1', '123 SandBox Street');","pm.environment.set('update_town', 'Alfold');","pm.environment.set('update_postcode', 'GU99 9ZZ');","pm.environment.set('update_country', 'United Kingdom');","pm.environment.set('update_startdate', newStartDate);","","","//var debitDate = new Date();","//debitDate.setHours(0,0,0,0);","//debitDate = debitDate.addMonths(4);","","pm.environment.set('update_dd_amount', dataGen.randomInt(100, 10000));","pm.environment.set('update_dd_date', dataGen.getISODate(debitDate));"],"type":"text/javascript"}}],"id":"ca334952-76f2-426f-bf8b-9063fe6735f3","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"PUT","header":[],"body":{"mode":"formdata","formdata":[{"key":"adhoc_ddi[debits][debit][][amount]","value":"{{collection_1_amount}}","type":"text","description":"<p><b>Format:</b> integer, the value of the debit amount <i>in pence</i></p>\n"},{"key":"adhoc_ddi[debits][debit][][date]","value":"{{collection_1_date}}","type":"text","description":"<p><b>Format:</b> YYYY-MM-DD</p>\n"},{"key":"adhoc_ddi[debits][debit][][amount]","value":"{{collection_2_amount}}","type":"text","description":"<p><b>Format:</b> integer, the value of the debit amount <i>in pence</i></p>\n"},{"key":"adhoc_ddi[debits][debit][][date]","value":"{{collection_2_date}}","type":"text","description":"<p><b>Format:</b> YYYY-MM-DD</p>\n"}]},"url":"{{base_url}}/ddi/adhoc/{{reference_number}}","description":"<p>When creating adhoc collections, or overriding an existing collection, pairs of amount and date values must be passed together.</p>\n","urlObject":{"path":["ddi","adhoc","{{reference_number}}"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"2be6d8fe-5b4e-4874-a1a1-3cdabcabf612","name":"update","originalRequest":{"method":"PUT","header":[],"body":{"mode":"formdata","formdata":[{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"adhoc_ddi[first_name]","type":"text","value":"{{update_first_name}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"adhoc_ddi[last_name]","type":"text","value":"{{update_last_name}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"adhoc_ddi[address_1]","type":"text","value":"{{update_address1}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"adhoc_ddi[town]","type":"text","value":"{{update_town}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"adhoc_ddi[postcode]","type":"text","value":"{{update_postcode}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"adhoc_ddi[country]","type":"text","value":"{{update_country}}"},{"description":"<b>Format: YYYY-MM-DD   <br>Restrictions: Must be far enough in the future to allow the SU's lead time.</b>","key":"adhoc_ddi[start_date]","type":"text","value":"{{update_startdate}}"}]},"url":"{{base_url}}/api/ddi/adhoc/{{reference_number}}"},"status":"OK","code":200,"_postman_previewlanguage":"xml","header":[{"key":"Date","value":"Thu, 14 Feb 2019 13:51:07 GMT"},{"key":"Server","value":"Apache"},{"key":"Cache-Control","value":"private, max-age=0, must-revalidate"},{"key":"X-Runtime","value":"0.13529"},{"key":"Strict-Transport-Security","value":"max-age=63072000; includeSubdomains; preload"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Set-Cookie","value":"auth_token=; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"_PSLLite_session_id=59c10b241683faff8f68dab95c0ecf7c; path=/; HttpOnly; secure"},{"key":"Content-Length","value":"463"},{"key":"Status","value":"200 OK"},{"key":"X-XSS-Protection","value":"1; mode=block"},{"key":"Keep-Alive","value":"timeout=5, max=99"},{"key":"Connection","value":"Keep-Alive"},{"key":"Content-Type","value":"application/xml; charset=utf-8"},{"key":"X-Iinfo","value":"14-28858955-28870981 SNNN RT(1550152240799 60054) q(0 0 0 -1) r(2 2) U5"},{"key":"X-CDN","value":"Incapsula"}],"cookie":[],"responseTime":null,"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<adhoc_ddi>\n    <address_1>123 SandBox Street</address_1>\n    <country>United Kingdom</country>\n    <first_name>Updated-Bob</first_name>\n    <last_name>Updated-Smith</last_name>\n    <postcode>GU99 9ZZ</postcode>\n    <reference_number>SD119011413519424</reference_number>\n    <start_date type=\"datetime\">2019-04-13T00:00:00Z</start_date>\n    <town>Alfold</town>\n    <service_user>\n        <pslid>apidocument</pslid>\n    </service_user>\n</adhoc_ddi>"}],"_postman_id":"ca334952-76f2-426f-bf8b-9063fe6735f3"},{"name":"ddi/adhoc/{{reference_number}}/update","event":[{"listen":"test","script":{"id":"a636b107-dcf0-4ca9-9d34-e3270a511efd","exec":["eval(pm.globals.get('jasmine'));","","pm.test(\"Response time is less than 400ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(400);","});","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","pm.test(\"Body matches string\", function () {","    pm.expect(pm.response.text()).to.include('<?xml version=\"1.0\" encoding=\"UTF-8\"?>');","    pm.expect(pm.response.text()).to.include('<adhoc_ddi>');","    pm.expect(pm.response.text()).to.include('<reference_number>' + pm.environment.get('reference_number') + '</reference_number>');","    pm.expect(pm.response.text()).to.include('</adhoc_ddi>');","});","","","//               SCHEMA Validation                      //","var result = xml2Json(responseBody);                    //     ","var schema =  sd.api.schema.updateAdhocResponse;   //","                                                        //","//var schema =  sd.api.schema.dumpResponse;             //","                                                        //","  pm.test('Schema is valid', function() {               //","    pm.expect(tv4.validate(result, schema)).to.be.true; //","  });                                                   //","//               SCHEMA Validation                      //","",""],"type":"text/javascript"}},{"listen":"prerequest","script":{"id":"1c89a4a9-73f1-45e0-9047-d36e7f73ef58","exec":["","pm.sendRequest(\"https://sandbox.smartdebit.co.uk/Scripts/smartdebit.jasmine.js\", (err, res) => { pm.globals.set('jasmine' ,res.text() ) });","","eval(pm.globals.get('jasmine'));","","var authHash = btoa(pm.environment.get('api_user') + \":\" + pm.environment.get('api_user_password'));","","var dataGen = sd.testing;","","var payer = dataGen.getJsonPayer(pm.environment.get('pslid'), dataGen.getReferenceNumber('SD1'), 3, false);","","","var payerFormData = dataGen.json2formData(payer, 'adhoc_ddi');","//var payerFormData = dataGen.json2formData(payer, 'variable_ddi');","","const createPayerRequest = {","  url: pm.environment.get('base_url') + '/ddi/adhoc/create',","  //url: pm.environment.get('base_url') + '/api/ddi/variable/create',","  method: 'POST',","  header: `Authorization:Basic ${authHash}`,","  body: {","    mode: 'formdata',","    formdata: payerFormData","  }","};","","pm.sendRequest(createPayerRequest, function (err, res) {","  console.log(err ? err : res.text());","  ","  pm.environment.set('reference_number', payer.reference_number);","  console.log('reference number for the payer we try to update is: ' + payer.reference_number);","});","","var debitDate = new Date();","debitDate.setHours(0,0,0,0);","debitDate = debitDate.addMonths(3);","","var newStartDate = new Date();","newStartDate.setHours(0,0,0,0);","newStartDate = newStartDate.addMonths(2);","","pm.environment.set('update_dd_amount', dataGen.randomInt(100, 10000));","pm.environment.set('update_dd_date', dataGen.getISODate(debitDate));","","pm.environment.set('update_first_name', 'Updated-Bob');","pm.environment.set('update_last_name', 'Updated-Smith');","pm.environment.set('validate_adhoc_company_name', 'Acme Co.');","pm.environment.set('update_address1', '123 SandBox Street');","pm.environment.set('update_town', 'Alfold');","pm.environment.set('update_postcode', 'GU99 9ZZ');","pm.environment.set('update_country', 'United Kingdom');","pm.environment.set('update_startdate', newStartDate);"],"type":"text/javascript"}}],"id":"cf1200ab-3490-4fd6-9686-b0f66a24b3e2","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"POST","header":[],"url":"{{base_url}}/ddi/adhoc/{{reference_number}}/update","description":"<p>This is an alias for the <a href=\"#943211f6-8f5f-4ac4-9d64-afbfe6959896\">PUT update</a>  call. The same parameters as above can be used with this version.</p>\n","urlObject":{"path":["ddi","adhoc","{{reference_number}}","update"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"d80e3f19-834a-476a-95b6-e72ff4d32557","name":"update","originalRequest":{"method":"PUT","header":[],"body":{"mode":"formdata","formdata":[{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"adhoc_ddi[first_name]","type":"text","value":"{{update_first_name}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"adhoc_ddi[last_name]","type":"text","value":"{{update_last_name}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"adhoc_ddi[address_1]","type":"text","value":"{{update_address1}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"adhoc_ddi[town]","type":"text","value":"{{update_town}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"adhoc_ddi[postcode]","type":"text","value":"{{update_postcode}}"},{"description":"<b>Format: plain text <br>Restrictions: 1 to 32 characters</b>","key":"adhoc_ddi[country]","type":"text","value":"{{update_country}}"},{"description":"<b>Format: YYYY-MM-DD   <br>Restrictions: Must be far enough in the future to allow the SU's lead time.</b>","key":"adhoc_ddi[start_date]","type":"text","value":"{{update_startdate}}"}]},"url":"{{base_url}}/api/ddi/adhoc/{{reference_number}}"},"status":"OK","code":200,"_postman_previewlanguage":"xml","header":[{"key":"Date","value":"Thu, 14 Feb 2019 13:51:07 GMT"},{"key":"Server","value":"Apache"},{"key":"Cache-Control","value":"private, max-age=0, must-revalidate"},{"key":"X-Runtime","value":"0.13529"},{"key":"Strict-Transport-Security","value":"max-age=63072000; includeSubdomains; preload"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Set-Cookie","value":"auth_token=; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"_PSLLite_session_id=59c10b241683faff8f68dab95c0ecf7c; path=/; HttpOnly; secure"},{"key":"Content-Length","value":"463"},{"key":"Status","value":"200 OK"},{"key":"X-XSS-Protection","value":"1; mode=block"},{"key":"Keep-Alive","value":"timeout=5, max=99"},{"key":"Connection","value":"Keep-Alive"},{"key":"Content-Type","value":"application/xml; charset=utf-8"},{"key":"X-Iinfo","value":"14-28858955-28870981 SNNN RT(1550152240799 60054) q(0 0 0 -1) r(2 2) U5"},{"key":"X-CDN","value":"Incapsula"}],"cookie":[],"responseTime":null,"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<adhoc_ddi>\n    <address_1>123 SandBox Street</address_1>\n    <country>United Kingdom</country>\n    <first_name>Updated-Bob</first_name>\n    <last_name>Updated-Smith</last_name>\n    <postcode>GU99 9ZZ</postcode>\n    <reference_number>SD119011413519424</reference_number>\n    <start_date type=\"datetime\">2019-04-13T00:00:00Z</start_date>\n    <town>Alfold</town>\n    <service_user>\n        <pslid>apidocument</pslid>\n    </service_user>\n</adhoc_ddi>"}],"_postman_id":"cf1200ab-3490-4fd6-9686-b0f66a24b3e2"}],"id":"5bae7530-c86e-4e23-8616-1f05708cf16e","description":"<h4 id=\"syntax\">Syntax</h4>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>PUT {{base_url}}/ddi/adhoc/{{reference_number}}\n</code></pre><p>aliased as</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>POST {{base_url}}/ddi/adhoc/{{reference_number}}/update\n</code></pre><h4 id=\"description\">Description</h4>\n<p>The <a href=\"#943211f6-8f5f-4ac4-9d64-afbfe6959896\">update</a> method allows the attributes of a payer to be amended and collections to be created and updated. The update may result in an amendment email being sent to the payer.</p>\n<p>The DDI reference number cannot be changed. Cancelled DDIs cannot be updated.</p>\n<p>If the reference number contains solidus, it must be urlencoded.</p>\n<p>This method should be used for 'adhoc' payers and does not support payment schedules.</p>\n<p><strong>Updating bank details:</strong> Simple validation of account number and sort code takes place but full validation does not. This behaviour may change in a future release. Thus, a five-digit sort code would not be accepted but an invalid six-digit sort code would.</p>\n<p><strong>Updating cancelled payers:</strong> Attempting to update a cancelled payer results in a \"200 OK\" status and an XML response as if the update was accepted <em>but the update does not take place</em>. The XML response includes the \"cancelled_on\" node. This behaviour may change in a future release.</p>\n<p><strong>Updating collections:</strong> Extended parameters can be used to add a collection or to change the amount of a collection. They cannot be used to change the date of a collection or to delete a collection. Collections cannot be edited on or after the date of submission.</p>\n<h4 id=\"parameters\">Parameters</h4>\n<p>Optional parameters define the attribute or attributes to be updated. Extended parameters can be specified in order to create or update collections. It is recommended that the XML body method of parameter passing is used if multiple collections are to be created or updated.</p>\n<p>The start_date parameter serves little purpose for adhoc payers. There is unlikely to be any reason to update it.</p>\n<p>A dummy parameter, e.g. adhoc_ddi[dummy], may be used to simply return the payer details without performing an update.</p>\n<h4 id=\"response\">Response</h4>\n<p>A successful response from <a href=\"#943211f6-8f5f-4ac4-9d64-afbfe6959896\">ddi/adhoc/{{reference_number}}</a> is an XML rendition of the payer with a root tag of adhoc_ddi.  Any unpopulated optional fields on the payer are omitted from the XML document. The entire payer and any debits are always returned regardless of the number of attributes updated. For instance, </p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>PUT /api/ddi/adhoc/ABC106093 \n&lt;?XML version=\"1.0\" encoding=\"UTF-8\"?&gt; \n&lt;adhoc_ddi&gt;\n  &lt;first_name&gt;John&lt;/first_name&gt;\n&lt;/adhoc_ddi&gt;\n</code></pre><p>could return:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>200 OK\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;adhoc_ddi&gt;\n  &lt;reference_number&gt;ABC106093&lt;/reference_number&gt;\n  &lt;first_name&gt;John&lt;/first_name&gt;\n  &lt;last_name&gt;Smith&lt;/last_name&gt;\n  &lt;start_date type=\"datetime\"&gt;2018-07-01T00:00:00Z&lt;/start_date&gt;\n  &lt;address_1&gt;123 Fake St&lt;/address_1&gt;\n  &lt;town&gt;London&lt;/town&gt;\n  &lt;postcode&gt;sw2 3ed&lt;/postcode&gt;\n  &lt;country&gt;United Kingdom&lt;/country&gt;\n  &lt;service_user&gt;\n    &lt;pslid&gt;su_pslid&lt;/pslid&gt;\n  &lt;/service_user&gt;\n&lt;/adhoc_ddi&gt; \n</code></pre><p>The same is true of updating the debits on a DDI. For instance, </p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>PUT /api/ddi/adhoc/ABC106093 \n&lt;?XML version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;adhoc_ddi&gt;\n  &lt;debits&gt; \n    &lt;debit&gt;\n      &lt;amount&gt;500&lt;/amount&gt;&lt;date&gt;2019-08-01&lt;/date&gt;\n    &lt;/debit&gt;\n  &lt;/debits&gt;\n&lt;/adhoc_ddi&gt;\n</code></pre><p>could return</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>200 OK\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;adhoc_ddi&gt;\n  &lt;reference_number&gt;ABC106093&lt;/reference_number&gt;\n  &lt;first_name&gt;John&lt;/first_name&gt;\n  &lt;last_name&gt;Smith&lt;/last_name&gt;\n  &lt;start_date type=\"datetime\"&gt;2018-07-01T00:00:00Z&lt;/start_date&gt;\n  &lt;address_1&gt;123 Fake St&lt;/address_1&gt;\n  &lt;town&gt;London&lt;/town&gt;\n  &lt;postcode&gt;sw2 3ed&lt;/postcode&gt; \n  &lt;country&gt;United Kingdom&lt;/country&gt;\n  &lt;debits type=\"array\"&gt; \n    &lt;debit type=\"DdaDebit\"&gt;\n      &lt;amount type=\"integer\"&gt;1500&lt;/amount&gt;\n      &lt;debit_date type=\"datetime\"&gt;2019-07-01T00:00:00Z&lt;/debit_date&gt;\n    &lt;/debit&gt; \n    &lt;debit&gt;\n      &lt;amount type=\"integer\"&gt;500&lt;/amount&gt;\n      &lt;debit_date type=\"datetime\"&gt;2019-08-01T00:00:00Z&lt;/debit_date&gt;\n    &lt;/debit&gt;\n  &lt;/debits&gt;\n  &lt;service_user&gt;\n    &lt;pslid&gt;su_pslid&lt;/pslid&gt;\n  &lt;/service_user&gt;\n&lt;/adhoc_ddi&gt;\n</code></pre><p>A cancelled DDI is identified by the presence of <strong>cancelled_on</strong> in the response, indicating the date and time of cancellation. Where the cancellation is by Bacs advice, the value of cancelled_on may be taken from the advice.</p>\n<p>Amounts are given in pence.</p>\n<p>Collection statuses are not provided. The presence of a collection does not mean that it was paid, nor even that it was submitted.</p>\n<h4 id=\"errors\">Errors</h4>\n<p>Error responses are similar to the error responses for <a href=\"#23d97a1a-b71d-4bfc-8632-550235f92a8e\">ddi/adhoc/validate</a> and <a href=\"#a4835f2a-1911-4e32-b5aa-4386c916fa20\">ddi/adhoc/create</a>. Missing parameters result in appropriate errors. Passing no parameters at all returns: </p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>400 Bad Request \n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Direct Debit parameters not supplied.&lt;/error&gt;\n&lt;/errors&gt; \n</code></pre><p>Attempting to update with an incorrect reference number returns:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>400 Bad Request\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Adhoc Direct Debit 'AAAAAA' not found.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><p>Attempting to update a 'variable' DDI returns the same response.</p>\n<p>Supplying invalid values for any parameter may return a listing of all validation errors in one document. For example: </p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>422 Unprocessable Entity \n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Last name only letters, numbers, spaces, hyphens, forward slash, ampersand and full stops are permitted in last names&lt;/error&gt;\n  &lt;error&gt;Start date must be in the future&lt;/error&gt;\n  &lt;error&gt;Start date must be on or after 01/03/2019&lt;/error&gt;\n  &lt;error&gt;First name only letters, numbers, spaces, hyphens, forward slash, ampersand and full stops are permitted in first names&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><p>Supplying invalid debit values returns a listing of all validation errors in one document. This example shows an invalid date and an amount that exceeds the maximum allowed for the service user. Note the HTML encoding in this response. </p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>422 Unprocessable Entity\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Amount must be less than &amp;#163;250.00&lt;/error&gt;\n  &lt;error&gt;Debit date must not be before the start of the DDI: 2018/07/01 00:00&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><h4 id=\"version-history\">Version history</h4>\n<table>\n<tr>\n<td></td>\n<td>The <i>adhoc_ddi[end_date]</i> parameter is deprecated because it is used to control payment schedules and the adhoc model does not support payment schedules.</td>\n</tr>\n</table>","event":[{"listen":"prerequest","script":{"id":"70a5c701-5281-4ed8-8dff-1f2d942da905","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"d271d5de-4456-450d-b597-b690f2330de5","type":"text/javascript","exec":[""]}}],"_postman_id":"5bae7530-c86e-4e23-8616-1f05708cf16e"},{"name":"4.2.9 Adhoc cancel","item":[{"name":"ddi/adhoc/{{reference_number}}/cancel","event":[{"listen":"test","script":{"id":"de3c41c3-7d83-4beb-a28f-2f7322fb16d4","exec":["eval(pm.globals.get('jasmine'));","","pm.test(\"Response time is less than 500ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(500);","});","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","pm.test(\"Body matches string\", function () {","    pm.expect(pm.response.text()).to.include('<?xml version=\"1.0\" encoding=\"UTF-8\"?>');","    pm.expect(pm.response.text()).to.include('<adhoc_ddi>');","    pm.expect(pm.response.text()).to.include('<reference_number>' + pm.environment.get('reference_number_to_cancel') + '</reference_number>');","    pm.expect(pm.response.text()).to.include('</adhoc_ddi>');","});","","","//               SCHEMA Validation                          //","var result = xml2Json(responseBody);                        //     ","var schema =  sd.api.schema.updateAdhocResponse;                  //","//                                                          //","  pm.test('Schema is valid', function() {                   //","    pm.expect(tv4.validate(result, schema)).to.be.true;     //","  });                                                       //","//               SCHEMA Validation                          //","","","//pm.environment.set(\"api_cancel_adhoc_response_2\", pm.response.text());"],"type":"text/javascript"}},{"listen":"prerequest","script":{"id":"f68927c4-6304-4373-8a8f-90956c01555a","exec":["pm.sendRequest(\"https://sandbox.smartdebit.co.uk/Scripts/smartdebit.jasmine.js\", (err, res) => { pm.globals.set('jasmine' ,res.text() ) });","","eval(pm.globals.get('jasmine'));","","var authHash = btoa(pm.environment.get('api_user') + \":\" + pm.environment.get('api_user_password'));","","var dataGen = sd.testing;","","var payer = dataGen.getJsonPayer(pm.environment.get('pslid'), dataGen.getReferenceNumber('SD1'), 3, false);","","//This needs only for variable payers","//payer.frequency_type = 'M';","//payer.email_address = 'test-ruby@smartdebt.com';","","","var payerFormData = dataGen.json2formData(payer, 'adhoc_ddi');","//var payerFormData = dataGen.json2formData(payer, 'variable_ddi');","","const createPayerRequest = {","  url: pm.environment.get('base_url') + '/ddi/adhoc/create',","  //url: pm.environment.get('base_url') + '/api/ddi/variable/create',","  method: 'POST',","  header: `Authorization:Basic ${authHash}`,","  body: {","    mode: 'formdata',","    formdata: payerFormData","  }","};","","pm.sendRequest(createPayerRequest, function (err, res) {","  console.log(err ? err : res.text());","  ","  pm.environment.set('reference_number_to_cancel',payer.reference_number);","  console.log('reference number for the payer we will cancel is: ' + payer.reference_number);","});"],"type":"text/javascript"}}],"id":"55d6aca6-64f1-4b38-a158-d7ca5897f2c0","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"POST","header":[],"url":"{{base_url}}/ddi/adhoc/{{reference_number_to_cancel}}/cancel","urlObject":{"path":["ddi","adhoc","{{reference_number_to_cancel}}","cancel"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"7820925a-427c-45dc-aae4-43e29226c42f","name":"cancel_adhoc","originalRequest":{"method":"POST","header":[],"body":{"mode":"formdata","formdata":[]},"url":"{{base_url}}/api/ddi/adhoc/{{reference_number_to_cancel}}/cancel"},"status":"OK","code":200,"_postman_previewlanguage":"xml","header":[{"key":"Date","value":"Fri, 22 Feb 2019 16:07:55 GMT"},{"key":"Server","value":"Apache"},{"key":"Cache-Control","value":"private, max-age=0, must-revalidate"},{"key":"X-Runtime","value":"0.54349"},{"key":"Strict-Transport-Security","value":"max-age=63072000; includeSubdomains; preload"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Set-Cookie","value":"auth_token=; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"_PSLLite_session_id=59c10b241683faff8f68dab95c0ecf7c; path=/; HttpOnly; secure"},{"key":"Content-Length","value":"516"},{"key":"Status","value":"200 OK"},{"key":"X-XSS-Protection","value":"1; mode=block"},{"key":"Keep-Alive","value":"timeout=5, max=93"},{"key":"Connection","value":"Keep-Alive"},{"key":"Content-Type","value":"application/xml; charset=utf-8"},{"key":"X-Iinfo","value":"10-5559133-5559134 SNNN RT(1550851715073 14432) q(0 0 0 -1) r(6 6) U5"},{"key":"X-CDN","value":"Incapsula"}],"cookie":[],"responseTime":null,"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<adhoc_ddi>\n    <address_1>2 Church Street</address_1>\n    <cancelled_on type=\"datetime\">2019-02-22T16:07:56Z</cancelled_on>\n    <country>United Kingdom</country>\n    <first_name>Donna</first_name>\n    <last_name>Hoffmann</last_name>\n    <postcode>W1A 0AX</postcode>\n    <reference_number>SD11901221687952</reference_number>\n    <start_date type=\"datetime\">2019-04-01T00:00:00Z</start_date>\n    <town>Bagshot</town>\n    <service_user>\n        <pslid>apidocument</pslid>\n    </service_user>\n</adhoc_ddi>"}],"_postman_id":"55d6aca6-64f1-4b38-a158-d7ca5897f2c0"}],"id":"2920cee3-c966-4690-921d-4fcd2d5d2253","description":"<p>The <a href=\"#55d6aca6-64f1-4b38-a158-d7ca5897f2c0\">cancel</a> method allows a DDI to be cancelled. Cancelling a DDI may result in a cancellation email being sent to the payer.</p>\n<p>If the reference number contains solidus, it must be urlencoded.</p>\n<h4 id=\"response\">Response</h4>\n<p>A successful response is an XML rendition of the DDI with a root tag of adhoc_ddi. The cancellation time is included as <strong>cancelled_on</strong>. Any unpopulated optional fields on the DDI are omitted from the XML document. </p>\n<p>Cancelling an already-cancelled DDI returns a success response but performs no action.</p>\n<h4 id=\"errors\">Errors</h4>\n<p>Attempting to cancel with an incorrect reference number returns:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>400 Bad Request\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Adhoc Direct Debit 'AAAAAA' not found.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><p>Attempting to cancel a <em>variable</em> DDI returns the same response.</p>\n","event":[{"listen":"prerequest","script":{"id":"18d0d118-a472-4963-9968-3b2c3171825f","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"68b458c0-2846-4bc5-a71a-14b1c4a51a82","type":"text/javascript","exec":[""]}}],"_postman_id":"2920cee3-c966-4690-921d-4fcd2d5d2253"},{"name":"4.2.10 Adhoc reinstate","item":[{"name":"ddi/adhoc/{{reference_number}}/reinstate","id":"7c75f31a-9b5d-4dc0-b709-084cfb336146","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"url":"{{base_url}}/ddi/adhoc/{{reference_number}}/reinstate","urlObject":{"path":["ddi","adhoc","{{reference_number}}","reinstate"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"7c75f31a-9b5d-4dc0-b709-084cfb336146"}],"id":"2a323a26-9acc-4f9e-8900-65e846eefd63","description":"<p>The <a href=\"#7c75f31a-9b5d-4dc0-b709-084cfb336146\">reinstate</a> method allows a cancelled DDI to be made live again. Reinstating a DDI may result in a reinstatement email being sent to the payer.</p>\n<p>If the reference number contains solidus, it must be urlencoded.</p>\n<h4 id=\"response\">Response</h4>\n<p>A successful response is an XML rendition of the DDI with a root tag of adhoc_ddi. Any unpopulated optional fields on the DDI are omitted from the XML document. The fact that the response does not include a cancelled_on field indicates that the DDI is live.</p>\n<p>Reinstating a DDI that is already live returns a success response but performs no action.</p>\n<h4 id=\"errors\">Errors</h4>\n<p>Attempting to reinstate with an incorrect reference number returns:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>400 Bad Request\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\" ?&gt;\n&lt;errors&gt;\n    &lt;error&gt;Adhoc Direct Debit 'AAAAAA' not found.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><p>Attempting to reinstate a <em>variable</em> DDI returns the same response.</p>\n","event":[{"listen":"prerequest","script":{"id":"73195b47-db07-484a-831b-11810ff12221","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"6dd077fb-dd91-464c-a99a-ad7f241ffd46","type":"text/javascript","exec":[""]}}],"_postman_id":"2a323a26-9acc-4f9e-8900-65e846eefd63"}],"id":"93ecfda9-5948-4a05-a753-683e5711afb2","description":"<p>Twin sets of endpoints are available. The endpoint that you use depends on the chosen processing model (<em>variable</em> or <em>adhoc</em>).</p>\n","event":[{"listen":"prerequest","script":{"id":"0f8bb343-da60-4d14-87e7-d9a1922bd8ff","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"ebd45d1d-13d2-420f-8ee5-f735a32bbefa","type":"text/javascript","exec":[""]}}],"_postman_id":"93ecfda9-5948-4a05-a753-683e5711afb2"},{"name":"4.3 Retrieve payer","item":[{"name":"data/dump","event":[{"listen":"prerequest","script":{"id":"f8e9ea1b-34f4-44f5-bbdb-a19c10aac01a","exec":["pm.sendRequest(\"https://sandbox.smartdebit.co.uk/Scripts/smartdebit.jasmine.js\", (err, res) => { pm.globals.set('jasmine' ,res.text() ) });","","eval(pm.globals.get('jasmine'));","","var authHash = btoa(pm.environment.get('api_user') + \":\" + pm.environment.get('api_user_password'));","","var searchFilter = {};","searchFilter.service_user = {};","searchFilter.service_user.pslid = pm.environment.get('pslid');","searchFilter.report_format = 'XML';","searchFilter.include_header = 'true';","console.log(searchFilter);","","var postData = sd.testing.json2formData(searchFilter, 'query');","","console.log(postData);","","const dataDumpRequest = {","  url: pm.environment.get('base_url') + '/data/dump',","  method: 'POST',","  header: `Authorization:Basic ${authHash}`,","  body: {","    mode: 'formdata',","    formdata: postData","  }","};","","","pm.sendRequest(dataDumpRequest, function (err, res) {","  //console.log(err ? err : res.text());","  var dataDump = xml2Json(res.text());","  ","  //console.log(dataDump.DataDump.Data.PayerDetails[0].$.reference_number);","  pm.environment.set('datadump_reference_number', dataDump.DataDump.Data.PayerDetails[0].$.reference_number);","  //console.log('reference number for the payer we try to update is: ' + payer.reference_number);","});",""],"type":"text/javascript"}},{"listen":"test","script":{"id":"baef55a6-878a-48e1-9441-7d829a5ed515","exec":["// Documentation refers to a POST request in this case","","eval(pm.globals.get('object_comparer'));","eval(pm.globals.get('jasmine'));","","pm.test(\"Response time is less than 800ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(800);","});","","pm.test(\"Body matches string\", function () {","    pm.expect(pm.response.text()).to.include('<DataDump xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"');","    pm.expect(pm.response.text()).to.include('</Data>');","    pm.expect(pm.response.text()).to.include('</DataDump>');","    ","});","","","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","","//               SCHEMA Validation                       //","/*var result = xml2Json(responseBody);                    //                                            ","                                                        //","var schema =  sd.api.schema.dumpResponse;               //","                                                        //","  pm.test('Schema is valid', function() {               //","    pm.expect(tv4.validate(result, schema)).to.be.true; //","  });                                                   //","//               SCHEMA Validation                      //","","// pull the first record returned nd store for later","pm.environment.set(\"reference_number\",  result.DataDump.Data.PayerDetails[0].$.reference_number);","","var apiDataDampOriginal = xml2Json(responseBody);","var newApiDataDamp = xml2Json(pm.environment.get(\"api_data_dump_response\"));","","///////////////////////////////////WARNING/////////////////////////////////////////////////////","//This will print a massive object into the console which tend to breack the Postman Console.//","//console.log(CompareObject(apiDataDampOriginal,newApiDataDamp,0));                          //","///////////////////////////////////WARNING/////////////////////////////////////////////////////","","pm.test(\"Json objects are matching\", function () {","    pm.expect(CompareObject(apiDataDampOriginal,newApiDataDamp,0)).to.be.true;","});","*/"],"type":"text/javascript"}}],"id":"55dcb194-1e80-4f6c-a3d5-bcbd2c228f46","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"description":"<p><i>Required</i><br />\nService user identifier</p>\n","key":"query[service_user][pslid]","type":"text","value":"{{pslid}}"},{"description":"<p><b>Format:</b> 'CSV' or 'XML'<br /><b>Default:</b> XML</p>\n","key":"query[report_format] ","type":"text","value":"{{report_format}}"},{"description":"<p>Bacs reference as payer identifier</p>\n","key":"query[reference_number]","type":"text","value":"{{reference_number}}"},{"description":"<p><i>Deprecated</i><br /><b>Format:</b> 'true' or 'false'<br /><b>Default:</b> false </p>\n","key":"query[include_header] ","type":"text","value":"{{include_header}}"}]},"url":"{{base_url}}/data/dump","urlObject":{"path":["data","dump"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"55dcb194-1e80-4f6c-a3d5-bcbd2c228f46"}],"id":"2b78be39-712e-407c-ab49-0dc19e43e322","description":"<p>The <a href=\"#55dcb194-1e80-4f6c-a3d5-bcbd2c228f46\">data/dump</a> call is used to retrieve details of a payer or of all payers for a service user.</p>\n<p><strong>Caution</strong>: When used without a reference_number parameter the call takes a long time to respond. Avoid excessive use of this call to list all payers and do not re-try.</p>\n<p>Note: A single payer's details can also be obtained from an update call. The two methods are slightly different and are compared in <a href=\"#e2b8a0c8-eb18-4ab4-977a-12b11e8ce3a6\">section 3.3.4</a>.</p>\n<h4 id=\"parameters\">Parameters</h4>\n<ul>\n<li>query[service_user][pslid] is mandatory and specifies the service user</li>\n<li>query[reference_number] specifies a single payer</li>\n<li>query[report_format]=CSV can be used to specify a response in CSV format (the default is XML)</li>\n<li>query[include_header]=true can be used to specify a header row (deprecated)</li>\n</ul>\n<h4 id=\"response\">Response</h4>\n<p>A successful call to data/dump returns a document in the specified format.</p>\n<p>The following values are returned. If CSV format, they are returned in this order.</p>\n<ul>\n<li>payerReference (XML) / payer_reference (CSV)</li>\n<li>reference_number</li>\n<li>frequency_type</li>\n<li>frequency_factor</li>\n<li>start_date</li>\n<li>title</li>\n<li>first_name</li>\n<li>last_name</li>\n<li>email_address</li>\n<li>address_1</li>\n<li>address_2</li>\n<li>address_3</li>\n<li>town</li>\n<li>county</li>\n<li>postcode</li>\n<li>regular_amount</li>\n<li>first_amount</li>\n<li>current_state</li>\n<li>support_gift_aid</li>\n</ul>\n<p>Notes:</p>\n<ul>\n<li>payer_reference is an alias for customer_id</li>\n<li>reference_number is the unique reference for the payer</li>\n<li>start_date is returned in YYYY-MM-DD format (XML) or YYYY/MM/DD format (CSV)</li>\n<li>account details are, by default, not returned</li>\n<li>amounts are given in pounds and pence - with a currency symbol (&amp;#163;) or without a currency symbol (CSV)</li>\n<li>support_gift_aid may take the value \"true\" or \"false\"</li>\n<li>blank fields in CSV format may or may not be quoted</li>\n<li>end date is not returned</li>\n</ul>\n<p>The values for current_state and their meanings are as follows:</p>\n<p>0 or 1 = draft<br />\n10 = live<br />\n11 = cancelled</p>\n<p>Service users with their own SUN are able to retrieve the payer's account details – account name, account number and sort code - subject to a setting held against the service user in SmartDebit. This applies only to the retrieval of individual payer details (passing a reference number in the call). To enable the setting, please make a request to <a href=\"mailto:support@smartdebit.com?Subject=Account%20details%20setting\">support@smartdebit.com</a>.</p>\n<p>Adhoc payers do not have values for frequency_type, first_amount or regular_amount.</p>\n<p>If query[report_format]=CSV and query[include_header]=true are specified then the first line of output is:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>\"payer_reference,reference_number,frequency_type,frequency_factor, start_date,title,first_name,last_name,email_address,address_1,address_2,address_3,town,county,postcode,regular_amount,first_amount,current_state,support_gift_aid\"\n</code></pre><h4 id=\"errors\">Errors</h4>\n<ul>\n<li><h6>Invalid service user</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;No service user id supplied.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><br />\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Invalid Service User ID: 'su_pslid'&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><br />\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Permission denied. You cannot access the requested resource.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<br />\n<li><h6>Reference number does not exist</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Database is empty.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n</ul>\n\n\n<h4 id=\"version-history\">Version history</h4>\n<table>\n<tr>\n<td></td>\n<td>The <i>query[include_header]</i> parameter is deprecated because the header is incorrectly formatted.</td>\n</tr>\n</table>\n","event":[{"listen":"prerequest","script":{"id":"846e8487-5f7f-4332-ae4c-ed4108b2c507","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"cec5899b-e847-41d7-ad4f-1c5842fbe7eb","type":"text/javascript","exec":[""]}}],"_postman_id":"2b78be39-712e-407c-ab49-0dc19e43e322"},{"name":"4.4 Data file import","item":[{"name":"4.4.1 Payer file - asynchronous import","item":[{"name":"payer_file/async_import","event":[{"listen":"test","script":{"id":"3228d4d5-ffa8-49fa-accf-837f53e2ba77","exec":["eval(pm.globals.get('jasmine'));","","pm.test(\"Response time is less than 600ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(600);","});","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","","pm.test(\"Body matches string\", function () {","    pm.expect(pm.response.text()).to.include('<?xml version=\"1.0\" encoding=\"UTF-8\"?>');","    //pm.expect(pm.response.text()).to.include(`<payer_file_import uri=\"${pm.environment.get('url_original')}/api/payer_file/`);","    pm.expect(pm.response.text()).to.include('<file_name>'+pm.environment.get('updatedPayerFile_Name') +'</file_name>')","    pm.expect(pm.response.text()).to.include('<pslid>'+pm.environment.get('pslid')+'</pslid>')","});","","","//               SHEMA Validation                      //","var result = xml2Json(responseBody);                   //","                                                       //","  var schema =  sd.api.schema.payerFileResponse;       //","                                                       //","  pm.test('Schema is valid', function() {              //","    pm.expect(tv4.validate(result, schema)).to.be.true;//","  });                                                  //","//               SHEMA Validation                      //","","var res = result.payer_file_import.$.uri.split('/');","pm.environment.set('payer_file_import_id',res[res.length-1]);"],"type":"text/javascript"}},{"listen":"prerequest","script":{"id":"8c2df2e4-952d-4010-bf6b-0f3e176f0213","exec":["pm.sendRequest(\"https://sandbox.smartdebit.co.uk/Scripts/smartdebit.jasmine.js\", (err, res) => { pm.globals.set('jasmine' ,res.text() ) });","","eval(pm.globals.get('jasmine'));","","pm.environment.set('payer_file_name',sd.testing.getPayerFile.fileName() );","","var payerFile = sd.testing.getPayerFile.file(6, true,true, 6, 'SD1', true);","","pm.environment.set('file', payerFile);","pm.environment.set('fileNotBase64',atob(payerFile));","","pm.environment.set('emptyFile', '');","","var updatedPayerFile = \"\";","console.log(payerFile);","console.log(atob(payerFile));","","var lines = atob(payerFile).split('\\r\\n');","","console.log(lines);","//console.log(lines);","for (var line in lines)","{","    if(lines[line] ===\"\") {continue;}","    //console.log(lines[line]);","    var elements = lines[line].split(',');","    //console.log (elements[15]);","    var newName =  elements[15] + ' Wilde';","    elements[15] =newName;","    console.log (elements[15]);","    elements[30] = sd.testing.randomInt(1,99) + '.' + sd.testing.randomInt(1,99);","    elements[36] = sd.testing.randomInt(1,28).pad(2);","    var newLine = elements.join(',');","    console.log(newLine);","    updatedPayerFile += newLine;","}","","console.log(updatedPayerFile);","pm.environment.set('updatedPayerFile_Name',sd.testing.getPayerFile.fileName() );","pm.environment.set('updatedPayerFile',btoa(updatedPayerFile) );"],"type":"text/javascript"}}],"id":"f87ce3d9-f04a-4877-9a36-6bd7b42b7357","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"description":"<p>Service user identifier</p>\n","key":"payer_file_import[service_user][pslid]","type":"text","value":"{{pslid}}"},{"description":"<p><b>Format:</b> 1 to 255 characters</p>\n","key":"payer_file_import[file_name]","type":"text","value":"{{file_name}}"},{"description":"<p><b>Format:</b> <a href=\"https://en.wikipedia.org/wiki/Base64\">Base64</a> encoded multiline comma separated values. See <a href=\"#af952adc-d8b5-412c-96e6-e1064bd7a70d\">payer file format</a>.</p>\n","key":"payer_file_import[file]","type":"text","value":"{{file}}"},{"description":"<p><b>Format:</b> 'CREATE' or 'UPDATE'</p>\n","key":"payer_file_import[action]","type":"text","value":"{{action}}"}]},"url":"{{base_url}}/payer_file/async_import","description":"<p>All parameters are required.</p>\n","urlObject":{"path":["payer_file","async_import"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"90e568d8-a57f-44fb-bb1e-692edaae56fc","name":"import payer file (UPDATE)","originalRequest":{"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"key":"payer_file_import[action]","value":"UPDATE","type":"text","description":"<b>Format:</b> plain text <br><b>Restrictions:</b> <b>'CREATE'</b> or <b>'UPDATE'</b>"},{"key":"payer_file_import[file_name]","value":"{{updatedPayerFile_Name}}","type":"text","description":"<b>Format:</b> plain text"},{"key":"payer_file_import[file]","value":"{{updatedPayerFile}}","type":"text","description":"<b>Format:</b> <a href=\"https://en.wikipedia.org/wiki/Base64\" target=\"_blank\">Base64</a> encoded multi line comma separated value (46 fields per entry) TODO: link for 46 field explanation"},{"key":"payer_file_import[service_user][pslid]","value":"{{pslid}}","type":"text","description":"<b>Format:</b> plain text   <br><b>Restrictions:</b> 5 to 255 characters, must match existing SU's pslid"}]},"url":"{{base_url}}/api/payer_file/async_import"},"status":"OK","code":200,"_postman_previewlanguage":"xml","header":[{"key":"Date","value":"Tue, 26 Feb 2019 14:31:21 GMT"},{"key":"Server","value":"Apache"},{"key":"X-Runtime","value":"0.19998"},{"key":"Cache-Control","value":"private, max-age=0, must-revalidate"},{"key":"Strict-Transport-Security","value":"max-age=63072000; includeSubdomains; preload"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Set-Cookie","value":"auth_token=; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"_PSLLite_session_id=59c10b241683faff8f68dab95c0ecf7c; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"incap_ses_454_1416256=a; Max-Age=0; path=/; expires=Sun, 24 Feb 2019 13:13:15 GMT; Domain=.ddprocessing.co.uk"},{"key":"Content-Length","value":"425"},{"key":"Status","value":"200 OK"},{"key":"X-XSS-Protection","value":"1; mode=block"},{"key":"Keep-Alive","value":"timeout=5, max=100"},{"key":"Connection","value":"Keep-Alive"},{"key":"Content-Type","value":"application/xml; charset=utf-8"},{"key":"X-Iinfo","value":"5-14159042-14159065 NNNN CT(4 8 0) RT(1551191544745 76) q(0 0 0 -1) r(2 2) U5"},{"key":"X-CDN","value":"Incapsula"}],"cookie":[],"responseTime":null,"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<payer_file_import uri=\"https://sandbox.ddprocessing.co.uk/api/payer_file/131\">\n    <action>UPDATE</action>\n    <file_name>test_file_name_2019-02-26T14_31_35.727Z</file_name>\n    <service_user>\n        <pslid>apidocument</pslid>\n    </service_user>\n    <file_chunks>\n        <file_chunk to_line=\"1\" status=\"In process - please wait\" from_line=\"1\">\n    </file_chunk>\n    </file_chunks>\n</payer_file_import>"}],"_postman_id":"f87ce3d9-f04a-4877-9a36-6bd7b42b7357"}],"id":"ada59f4f-9f29-4c87-ba37-5db8e2d8adda","description":"<h4 id=\"description\">Description</h4>\n<p>Payer file import is an asynchronous service. A payer file can be enqueued for import via the <a href=\"#f87ce3d9-f04a-4877-9a36-6bd7b42b7357\">payer_file/async_import</a> call and the status of the import, and results on completion, can be queried via the <a href=\"#7922b1e8-bc71-4def-b8c6-68ae846ec606\">payer_file/<em>{{import_id}}</em></a> call.</p>\n<p>A payer file can be used to create new DDIs or update existing DDIs. The file must be Base64 encoded. Files are broken into 100-line chunks for parallel processing. </p>\n<ul>\n<li>The service user is specified using the payer_file_import[service_user][pslid] parameter.</li>\n<li>The file name is specified using the payer_file_import[file_name] parameter.</li>\n<li>The file content is supplied, base64-encoded, as the payer_file_import[file] parameter. Refer to the <a href=\"#af952adc-d8b5-412c-96e6-e1064bd7a70d\">file format specification</a>.</li>\n<li>The payer_file_import[action] parameter indicates whether the file represents CREATE or UPDATE actions.</li>\n</ul>\n<h4 id=\"response\">Response</h4>\n<p>A successful call to payer_file/async_import returns an XML version of the enqueued import.  The root tag of &lt;payer_file_import&gt; includes a URI attribute that identifies this import, and can be used to poll for the progress of the import. Each of the queued payer file chunks is listed in the &lt;file_chunks&gt; grouping tag.  Each &lt;file_chunk&gt; tag includes the lines included in the chunk, and the current status of the chunk – the response from payer_file/async_import always has the status \"In process - please wait\".</p>\n<h4 id=\"errors\">Errors</h4>\n<ul>\n<li><h6>No parameters supplied</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>400 Bad Request \n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Payer File parameters not supplied.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<br />\n<li><h6>Missing or invalid service user</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>400 Bad Request \n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;No service user id supplied.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><br />\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>400 Bad Request \n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Invalid Service User ID: 'su_pslid'&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<br />\n<li><h6>File name not supplied</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>400 Bad Request\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;File name not supplied.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<br />\n<li><h6>Missing or invalid action</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>400 Bad Request\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;An import action of 'CREATE' or 'UPDATE' must be supplied&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n</ul>","event":[{"listen":"prerequest","script":{"id":"314498d1-3b7e-4b3b-bc07-323b66ee4e54","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"7d28afd6-c546-4d38-b343-898e899d432b","type":"text/javascript","exec":[""]}}],"_postman_id":"ada59f4f-9f29-4c87-ba37-5db8e2d8adda"},{"name":"4.4.2 Payer file import status","item":[{"name":"payer_file/{{import_id}}","event":[{"listen":"test","script":{"id":"f6c13798-d6cf-406c-be08-2b55320dbcb5","exec":["eval(pm.globals.get('jasmine'));","","pm.test(\"Response time is less than 200ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(200);","});","","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","","pm.test(\"Body matches string\", function () {","    pm.expect(pm.response.text()).to.include('<?xml version=\"1.0\" encoding=\"UTF-8\"?>');","    pm.expect(pm.response.text()).to.include(`<payer_file_import uri=\"${pm.environment.get('base_url')}/api/payer_file/${pm.environment.get('payer_file_import_id')}`);","});","","","//               SCHEMA Validation                     //","var result = xml2Json(responseBody);                   //","                                                       //","  var schema =  sd.api.schema.payerFileResponse;       //","                                                       //","  pm.test('Schema is valid', function() {              //","    pm.expect(tv4.validate(result, schema)).to.be.true;//","  });                                                  //","//               SHEMA Validation                      //"],"type":"text/javascript"}}],"id":"7922b1e8-bc71-4def-b8c6-68ae846ec606","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"GET","header":[],"url":"{{base_url}}/payer_file/{{payer_file_import_id}}","urlObject":{"path":["payer_file","{{payer_file_import_id}}"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"ac187511-6de0-4746-b794-c6921fc88ef6","name":"get_import_payer_file","originalRequest":{"method":"GET","header":[],"url":"{{base_url}}/api/payer_file/{{payer_file_import_id}}"},"status":"OK","code":200,"_postman_previewlanguage":"xml","header":[{"key":"Date","value":"Tue, 26 Feb 2019 14:42:06 GMT"},{"key":"Server","value":"Apache"},{"key":"X-Runtime","value":"0.07946"},{"key":"Cache-Control","value":"private, max-age=0, must-revalidate"},{"key":"Strict-Transport-Security","value":"max-age=63072000; includeSubdomains; preload"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Set-Cookie","value":"auth_token=; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"_PSLLite_session_id=59c10b241683faff8f68dab95c0ecf7c; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"incap_ses_454_1416256=a; Max-Age=0; path=/; expires=Sun, 24 Feb 2019 13:13:15 GMT; Domain=.ddprocessing.co.uk"},{"key":"Content-Length","value":"1173"},{"key":"Status","value":"200 OK"},{"key":"X-XSS-Protection","value":"1; mode=block"},{"key":"Keep-Alive","value":"timeout=5, max=100"},{"key":"Connection","value":"Keep-Alive"},{"key":"Content-Type","value":"application/xml; charset=utf-8"},{"key":"X-Iinfo","value":"11-8673356-8675917 NNNN CT(0 0 0) RT(1551192170085 19512) q(0 0 0 -1) r(2 2) U5"},{"key":"X-CDN","value":"Incapsula"}],"cookie":[],"responseTime":null,"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<payer_file_import uri=\"https://sandbox.ddprocessing.co.uk/api/payer_file/132\">\n    <action>CREATE</action>\n    <completed_on>2019-02-26T14:41:51Z</completed_on>\n    <file_name>test_file_name_2019-02-26T14_42_01.144Z</file_name>\n    <service_user>\n        <pslid>apidocument</pslid>\n    </service_user>\n    <file_chunks>\n        <file_chunk to_line=\"6\" status=\"Import complete, click here for result\" from_line=\"1\">\n            <successes total=\"0\">\n      </successes>\n            <errors total=\"6\">\n                <error>Line 1: Not imported: frequency_type: must be in list, start_date: must be on or after 30/03/2019</error>\n                <error>Line 2: Not imported: start_date: must be on or after 30/03/2019</error>\n                <error>Line 3: Not imported: frequency_type: must be in list, start_date: must be on or after 30/03/2019</error>\n                <error>Line 4: Not imported: start_date: must be on or after 30/03/2019</error>\n                <error>Line 5: Not imported: start_date: must be on or after 30/03/2019</error>\n                <error>Line 6: Not imported: start_date: must be on or after 30/03/2019</error>\n            </errors>\n        </file_chunk>\n    </file_chunks>\n</payer_file_import>"}],"_postman_id":"7922b1e8-bc71-4def-b8c6-68ae846ec606"}],"id":"e0803f58-543a-49c9-afae-f35f0252b00b","description":"<h4 id=\"description\">Description</h4>\n<p><a href=\"#7922b1e8-bc71-4def-b8c6-68ae846ec606\">payer_file/<em>{{import_id}}</em></a> can be used to query the status of a payer file import and to get the results on completion.</p>\n<h4 id=\"response\">Response</h4>\n<p>A successful call to payer_file/<em>{{import_id}}</em> returns an XML document containing the status of the enqueued import. Each of the queued payer file chunks is listed in the &lt;file_chunks&gt; grouping tag. Each &lt;file_chunk&gt; tag includes the lines included in the chunk and the current status of the chunk. As each chunk is processed, its status moves through the following values:</p>\n<ul>\n<li><code>In process - please wait</code></li>\n<li><code>allocated</code></li>\n<li><code>started</code></li>\n<li><code>Import complete, click here for result</code></li>\n</ul>\n<p>Once a chunk has completed, a listing of the changes made is included in the &lt;file_chunk&gt; in a &lt;successes&gt; group tag. Similarly, any failed lines or errors are listed in an &lt;errors&gt; group tag:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>200 OK\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;payer_file_import uri=\"https://sandbox.ddprocessing.co.uk/api/payer_file/123\"&gt;\n  &lt;action&gt;CREATE&lt;/action&gt;\n  &lt;completed_on&gt;2019-05-12T12:04:21Z&lt;/completed_on&gt;\n  &lt;file_name&gt;payer_file.csv&lt;/file_name&gt;\n  &lt;service_user&gt;\n    &lt;pslid&gt;su_pslid&lt;/pslid&gt;\n  &lt;/service_user&gt;\n  &lt;file_chunks&gt;\n    &lt;file_chunk to_line=\"10\" status=\"Import complete, click here for result\" from_line=\"1\"&gt;\n      &lt;successes total=\"8\"&gt;\n        &lt;success&gt;Line 1: VariableDdi ABC153242 created.&lt;/success&gt;\n        &lt;success&gt;Line 3: VariableDdi ABC153243 created.&lt;/success&gt;\n        &lt;success&gt;Line 5: VariableDdi ABC153244 created.&lt;/success&gt;\n        &lt;success&gt;Line 6: VariableDdi ABC153245 created.&lt;/success&gt;\n        &lt;success&gt;Line 7: VariableDdi ABC153246 created.&lt;/success&gt;\n        &lt;success&gt;Line 8: VariableDdi ABC153247 created.&lt;/success&gt;\n        &lt;success&gt;Line 9: VariableDdi ABC153248 created.&lt;/success&gt;\n        &lt;success&gt;Line 10: VariableDdi ABC153249 created.&lt;/success&gt;\n      &lt;/successes&gt;\n      &lt;errors total=\"2\"&gt;\n        &lt;error&gt;Line 2: Too few fields, expected 46 but found 45.&lt;/error&gt;\n        &lt;error&gt;Line 4: Too few fields, expected 46 but found 45.&lt;/error&gt;\n      &lt;/errors&gt;\n    &lt;/file_chunk&gt;\n  &lt;/file_chunks&gt;\n&lt;/payer_file_import&gt;\n</code></pre><p><strong>Note:</strong></p>\n<ul>\n<li>The line number reported in each &lt;success&gt; or &lt;error&gt; tag is relative to the chunk and not necessarily the whole file.</li>\n<li>&lt;error&gt; tags indicate that a payer was not imported. They are significant.</li>\n<li>The HTTP status relates to the call and not to the import. A line, a chunk or the whole file may fail to import, despite an HTTP status of \"200 OK\".</li>\n</ul>\n<h4 id=\"errors\">Errors</h4>\n<ul>\n\n<li><h6>Querying the status of an invalid file results in one of these two errors:</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Couldn't find ParallelTask with ID=1524&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><br />\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>401 Unauthorized\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Permission denied. You cannot access the requested resource.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<br />\n\n<li><h6>An example data format error</h6>\nThis example response is from a two-line file in which the first line is a header and the second has a comma in address line 1. The data are not enclosed in double quotes.\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>200 OK\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;payer_file_import uri=\"https://sandbox.ddprocessing.co.uk/api/payer_file/737\"&gt;\n  &lt;action&gt;CREATE&lt;/action&gt;\n  &lt;completed_on&gt;2019-05-07T10:20:48Z&lt;/completed_on&gt;\n  &lt;file_name&gt;payer.csv&lt;/file_name&gt;\n  &lt;service_user&gt;\n    &lt;pslid&gt;apidocument&lt;/pslid&gt;\n  &lt;/service_user&gt;\n  &lt;file_chunks&gt;\n    &lt;file_chunk status=\"Import complete, click here for result\" from_line=\"1\" to_line=\"2\"&gt;\n      &lt;successes total=\"0\"&gt;\n      &lt;/successes&gt;\n      &lt;errors total=\"2\"&gt;\n        &lt;error&gt;Line 1: Not imported: start_date: unable to parse date: 'StartYear,StartMonth,StartDate'&lt;/error&gt;\n        &lt;error&gt;Line 2: Too many fields, expected 46 but found 47.&lt;/error&gt;\n      &lt;/errors&gt;\n    &lt;/file_chunk&gt;\n  &lt;/file_chunks&gt;\n&lt;/payer_file_import&gt;\n</code></pre>\n<p>Had the data been quoted, the line 2 error would have been different:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>        &lt;error&gt;Line 2: Not imported: address_1: only letters, numbers, spaces, hyphens, forward slash, ampersand and full stops are permitted in address 1, address_1: only letters, numbers, spaces, hyphens, forward slash, ampersand and full stops are permitted in address 2&lt;/error&gt;\n</code></pre></li>\n<br />\n\n<li><h6>A formatting error may cause the whole file or chunk to fail:</h6>\nIn this case there is no &lt;success&gt; node and only one &lt;error&gt;.\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;file_chunk status=\"failed\" from_line=\"1\" to_line=\"3\"&gt;\n</code></pre><p>For example, an email address of the form <code>joe.bloggs\"at\"gmail.com</code>.</p>\n</li>\n<br />\n\n<li><h6>Contact SmartDebit support if a file or chunk remains stuck at</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>In process - please wait\n</code></pre></li>\n</ul>","event":[{"listen":"prerequest","script":{"id":"3b2524a2-dcf9-446a-ba58-ef1e06f083d0","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"d441df5d-ba86-4f47-9721-7a57efef42c7","type":"text/javascript","exec":[""]}}],"_postman_id":"e0803f58-543a-49c9-afae-f35f0252b00b"},{"name":"4.4.3 Collection file - synchronous import","item":[{"name":"charge_file/import","event":[{"listen":"test","script":{"id":"ea3f55fa-b8cc-4960-ad57-6f9d10ee7c97","exec":["eval(pm.globals.get('jasmine'));","","pm.test(\"Response time is less than 400ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(400);","});","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","","var response = xml2Json(responseBody);","","//console.log(response);","//console.log(JSON.stringify(response));","","var schema = sd.api.schema.collectionFile;","","pm.test('Schema is valid', function() {","  pm.expect(tv4.validate(response, schema)).to.be.true;","});","","var newResponse = pm.environment.get('new_collectionFile_response');","","console.log('new API collectionFile response: ');","console.log(newResponse);"],"type":"text/javascript"}},{"listen":"prerequest","script":{"id":"a8018d84-592c-4584-b209-fa761cf99df5","exec":["pm.sendRequest(\"https://sandbox.smartdebit.co.uk/Scripts/smartdebit.jasmine.js\", (err, res) => { pm.globals.set('jasmine' ,res.text() ) });","","eval(pm.globals.get('jasmine'));","","var authHash = btoa(pm.environment.get('api_user') + \":\" + pm.environment.get('api_user_password'));","","var dataGen = sd.testing;","","pm.environment.set('collection_file_name_date', sd.testing.getPayerFile.fileName());","","console.log(pm.environment.get('collection_file_name_date'));","","console.log(sd.testing.getCollectionFile(2, [{ start_date: new Date().addDays(5), reference_number: 'ABSDER155415' }]));","","var searchFilters = {};","searchFilters.service_user = {};","searchFilters.service_user.pslid = pm.environment.get('pslid');","searchFilters.report_format = 'XML';","searchFilters.include_header = 'true';","","","var dataDumpPostData = dataGen.json2formData(searchFilters, 'query');","","console.log(dataDumpPostData);","","const createDataDumpRequest = {","  url: pm.environment.get('base_url') + '/data/dump',","  method: 'POST',","  header: `Authorization:Basic ${authHash}`,","  body: {","    mode: 'formdata',","    formdata: dataDumpPostData","  }","};","","pm.sendRequest(createDataDumpRequest, function (err, res) {","  //console.log(err ? err : res.text());","  var payersXml = res.text();","  //console.log(payersXml);","  ","  var payers = xml2Json(payersXml);","","//console.log(payers);","  //pm.environment.set('reference_number', payer.reference_number);","  //console.log('reference number for the payer we try to update is: ' + payer.reference_number);","  ","  var lastPayer=payers.DataDump.Data.PayerDetails[payers.DataDump.Data.PayerDetails.length-1].$;","var lastPayer2=payers.DataDump.Data.PayerDetails[payers.DataDump.Data.PayerDetails.length-2].$;","","console.log(lastPayer);","console.log(lastPayer2);","","var collectionFile = sd.testing.getCollectionFile(6, [{ start_date: lastPayer.start_date, reference_number: lastPayer.reference_number, last_collection: new Date().addDays(-2) },{ start_date: lastPayer2.start_date, reference_number: lastPayer2.reference_number, last_collection: new Date().addDays(-2) }],true);","console.log('Collection File Start.........');","console.log(collectionFile);","console.log('Collection File Finish.........');","","pm.environment.set(\"collectionFile\", collectionFile);","});","","//var payersXml = pm.environment.get(\"api_data_dump_response\", pm.response.text());","","","","//console.log(payers.DataDump.Data.PayerDetails[payers.DataDump.Data.PayerDetails.length-1].$.reference_number);","","var lastPayer=payers.DataDump.Data.PayerDetails[payers.DataDump.Data.PayerDetails.length-1].$;","var lastPayer2=payers.DataDump.Data.PayerDetails[payers.DataDump.Data.PayerDetails.length-2].$;","","//console.log(lastPayer);","//console.log(new Date().addDays(-2));","","","","//pm.environment.set('collection_file_name_date', sd.testing.getCollectionFile.fileName())"],"type":"text/javascript"}}],"id":"090d73a7-97d4-4655-8b78-dbdf27e0beff","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"key":"charge_file[service_user][pslid]","value":"{{pslid}}","type":"text","description":"<p>Service user identifier</p>\n"},{"key":"charge_file[file_name]","value":"{{file_name}}","type":"text","description":"<p><b>Format:</b> 1 to 255 characters</p>\n"},{"key":"charge_file[file]","value":"{{collectionFile}}","type":"text","description":"<p><b>Format:</b> multiline comma separated values. See <a href=\"#7c167ef6-c64a-4f88-a592-4e422b2bc719\">collection file format</a>.</p>\n"}]},"url":"{{base_url}}/charge_file/import","description":"<p>All parameters are required.</p>\n","urlObject":{"path":["charge_file","import"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"c1a30c36-2f44-4592-9715-c21814ab728b","name":"import_collections","originalRequest":{"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"key":"charge_file[file_name]","value":"{{collection_file_name_date}}","type":"text","description":"<b>Format:</b> plain text "},{"key":"charge_file[file]","value":"{{collectionFile}}","type":"text","description":"<b>Format:</b> multi line comma separated value (7 fields per entry)\n"},{"key":"charge_file[service_user][pslid]","value":"{{pslid}}","type":"text","description":"Service user identifier"}]},"url":"{{base_url}}/charge_file/import"},"status":"OK","code":200,"_postman_previewlanguage":"xml","header":[{"key":"Date","value":"Wed, 27 Feb 2019 15:49:04 GMT"},{"key":"Server","value":"Apache"},{"key":"X-Runtime","value":"0.17645"},{"key":"Cache-Control","value":"private, max-age=0, must-revalidate"},{"key":"Strict-Transport-Security","value":"max-age=63072000; includeSubdomains; preload"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Set-Cookie","value":"auth_token=; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"_PSLLite_session_id=59c10b241683faff8f68dab95c0ecf7c; path=/; HttpOnly; secure"},{"key":"Content-Length","value":"1501"},{"key":"Status","value":"200 OK"},{"key":"X-XSS-Protection","value":"1; mode=block"},{"key":"Keep-Alive","value":"timeout=5, max=99"},{"key":"Connection","value":"Keep-Alive"},{"key":"Content-Type","value":"application/xml; charset=utf-8"},{"key":"X-Iinfo","value":"11-18583466-18717321 SNNN RT(1551281736218 874452) q(0 0 0 -1) r(3 3) U5"},{"key":"X-CDN","value":"Incapsula"}],"cookie":[],"responseTime":null,"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<charge_file>\n    <file_name>test_file_name_2019-02-27T15_49_20.292Z</file_name>\n    <file>,SD11901221682,19.23,2019/03/25,,SD11901221682-1039,\n,SD11901221682,21.74,2019/04/25,,SD11901221682-1039,\n,SD11901221687952,4.63,2019/03/25,,SD11901221687952,\n,SD11901221687952,3.86,2019/04/25,,SD11901221687952,\n,SD11901221687952,23.54,2019/05/25,,SD11901221687952,\n,SD11901221687952,22.17,2019/06/25,,SD11901221687952,\n</file>\n    <service_user>\n        <pslid>apidocument</pslid>\n    </service_user>\n    <import_successful>false</import_successful>\n    <errors>\n        <error>Line 1: Not Imported: The DDI was cancelled on 22 February 2019 and cannot be debited.</error>\n        <error>Line 2: Not Imported: The DDI was cancelled on 22 February 2019 and cannot be debited.</error>\n        <error>Line 3: User format debit reference 'SD11901221687952' invalid - it should be begin with SD11901221687952- followed by the user format debit reference.</error>\n        <error>Line 4: User format debit reference 'SD11901221687952' invalid - it should be begin with SD11901221687952- followed by the user format debit reference.</error>\n        <error>Line 5: User format debit reference 'SD11901221687952' invalid - it should be begin with SD11901221687952- followed by the user format debit reference.</error>\n        <error>Line 6: User format debit reference 'SD11901221687952' invalid - it should be begin with SD11901221687952- followed by the user format debit reference.</error>\n    </errors>\n</charge_file>"}],"_postman_id":"090d73a7-97d4-4655-8b78-dbdf27e0beff"}],"id":"abc76044-4f83-4bfa-b640-86018235fc5e","description":"<h4 id=\"description\">Description</h4>\n<p><a href=\"#090d73a7-97d4-4655-8b78-dbdf27e0beff\">charge_file/import</a> can be used to create or update collections, or both at the same time. </p>\n<p>This call can be used to import small collection files up to a maximum of 5000 lines. Use <a href=\"#c3d2067b-a49a-4933-88d7-91faa2b10350\">charge_file/async_import</a> instead for larger files.</p>\n<ul>\n<li>The service user is specified using the charge_file[service_user][pslid] parameter.</li>\n<li>The file name is specified using the charge_file[file_name] parameter.</li>\n<li>The file content is supplied as the charge_file[file] parameter. Refer to the <a href=\"#7c167ef6-c64a-4f88-a592-4e422b2bc719\">file format specification</a>.</li>\n</ul>\n<p><strong>IMPORTANT NOTE:</strong>\nA collection file entry with a reference number and date that matches an existing collection updates the existing collection. You cannot specify two separate collections on the same date. Instead, either specify the sum or use a different collection date.</p>\n<h4 id=\"response\">Response</h4>\n<p>A successful call to charge_file/import returns an XML document with a root tag of &lt;charge_file&gt;. An &lt;import_successful&gt; tag contains 'true' if any entries in the collection file were imported successfully. A listing of the change caused by each entry is listed in the group tag  &lt;successful&gt;. </p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>200 OK\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?XML version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;charge_file&gt;\n &lt;file_name&gt;collection_file.csv&lt;/file_name&gt;\n &lt;file&gt;\n  ,ABC123456,49.95,2019/06/15,,,\n  ,”ABC123456”,”15”,”19/07/03”,,,\n &lt;/file&gt;\n &lt;service_user&gt;\n  &lt;pslid&gt;su_pslid&lt;/pslid&gt;\n &lt;/service_user&gt;\n &lt;import_successful&gt;true&lt;/import_successful&gt;\n &lt;successful&gt; \n  &lt;success&gt;Line 1: Debit for 15 June 2019 updated.&lt;/success&gt;\n  &lt;success&gt;Line 2: Debit for 3 July 2019 created.&lt;/success&gt;\n &lt;/successful&gt;\n&lt;/charge_file&gt;\n</code></pre><p>In the case that one or more entries cannot be imported, each failure is listed in the group tag &lt;errors&gt;.  If no entries in the file can be imported then the &lt;import_successful&gt; tag contains 'false'.  It is worth noting that this is one of the few instances where an API call can fail, and return an HTTP status of 200 OK. </p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>200 OK \n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?XML version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;charge_file&gt;\n &lt;file_name&gt;collection_file.csv&lt;/file_name&gt; \n  ... \n &lt;import_successful&gt;false&lt;/import_successful&gt;\n &lt;errors&gt;\n  &lt;error&gt;Line 1: Not imported: Could not find DDI 'ABC123456'&lt;/error&gt;\n  &lt;error&gt;Line 2: Not imported: Could not find DDI 'ABC123456'&lt;/error&gt;\n &lt;/errors&gt;\n&lt;/charge_file&gt;\n</code></pre><h4 id=\"errors\">Errors</h4>\n<ul>\n<li><h6>Passing no parameters returns:</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>400 Bad Request\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Collection File parameters not supplied.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<br />\n<li><h6>A missing or incorrect service user ID returns one of:</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>400 Bad Request\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;No service user id supplied.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><br />\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>400 Bad Request\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Invalid Service User ID: 'su_pslid'&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<br />\n<li><h6>Omitting the file or filename returns one of:</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>400 Bad Request\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;File data not supplied.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><br />\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>400 Bad Request\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;File name not supplied.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n</ul>","event":[{"listen":"prerequest","script":{"id":"3c83187d-5634-4481-a148-11c5192abf6d","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"006098dd-475f-4771-8b9f-ac6755284a8c","type":"text/javascript","exec":[""]}}],"_postman_id":"abc76044-4f83-4bfa-b640-86018235fc5e"},{"name":"4.4.4 Collection file - asynchronous import","item":[{"name":"charge_file/async_import","id":"c3d2067b-a49a-4933-88d7-91faa2b10350","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"key":"charge_file_import[service_user][pslid]","value":"{{pslid}}","description":"<p>Service user identifier</p>\n","type":"text"},{"key":"charge_file_import[file_name]","value":"{{file_name}}","description":"<p><b>Format:</b> 1 to 255 characters</p>\n","type":"text"},{"key":"charge_file_import[file]","value":"{{file}}","description":"<p><b>Format:</b> multiline comma separated values. See <a href=\"#7c167ef6-c64a-4f88-a592-4e422b2bc719\">collection file format</a>.</p>\n","type":"text"}]},"url":"{{base_url}}/charge_file/async_import","description":"<p>All parameters are required.</p>\n","urlObject":{"path":["charge_file","async_import"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"c3d2067b-a49a-4933-88d7-91faa2b10350"}],"id":"9c5741cd-3976-4537-becf-30909a3d36ce","description":"<h4 id=\"description\">Description</h4>\n<p><a href=\"#c3d2067b-a49a-4933-88d7-91faa2b10350\">charge_file/async_import</a> can be used to create or update collections, or both at the same time. </p>\n<p>This call can be used to import collection files that are too large for <a href=\"#090d73a7-97d4-4655-8b78-dbdf27e0beff\">charge_file/import</a>. Files are broken into 1000-line chunks for parallel processing. Files are imported asynchronously and you must use <a href=\"#a4ca0d94-fd06-4e5c-b6ae-e9fddcbf7151\">charge_file/<em>{{charge_file_import_id}}</em></a> to obtain the result. </p>\n<ul>\n<li>The service user is specified using the charge_file_import[service_user][pslid] parameter.</li>\n<li>The file name is specified using the charge_file_import[file_name] parameter.</li>\n<li>The file content is supplied as the charge_file_import[file] parameter. Refer to the <a href=\"#7c167ef6-c64a-4f88-a592-4e422b2bc719\">file format specification</a>.</li>\n</ul>\n<p><strong>IMPORTANT NOTE:</strong>\nA collection file entry with a reference number and date that matches an existing collection updates the existing collection. You cannot specify two separate collections on the same date. Instead, either specify the sum or use a different collection date.</p>\n<h4 id=\"response\">Response</h4>\n<p>A successful call to charge_file/async_import returns an XML version of the enqueued import. The root tag of &lt;charge_file_import&gt; includes a URI attribute that identifies this import, and can be used to poll for the progress of the import. Each of the queued charge file chunks is listed in the  grouping tag. Each  tag includes the lines included in the chunk and the current status of the chunk – the response from charge_file/async_import always has the status \"In process - please wait\".</p>\n<h4 id=\"errors\">Errors</h4>\n<ul>\n<li><h6>No parameters supplied</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>400 Bad Request \n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Charge File parameters not supplied.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<br />\n<li><h6>Missing or invalid service user</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>400 Bad Request \n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;No service user id supplied.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><br />\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>400 Bad Request \n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Invalid Service User ID: 'su_pslid'&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<br />\n<li><h6>File name not supplied</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>400 Bad Request\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;File name not supplied.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<li><h6>File not supplied</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>400 Bad Request \n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;File data not supplied.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n</ul>","event":[{"listen":"prerequest","script":{"id":"a29616fa-0ca9-4ca9-b2d6-2936f62972b9","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"0e772984-b6a0-4df8-a44d-02146eba48bb","type":"text/javascript","exec":[""]}}],"_postman_id":"9c5741cd-3976-4537-becf-30909a3d36ce"},{"name":"4.4.5 Collection file import status","item":[{"name":"charge_file/{{import_id}}","id":"a4ca0d94-fd06-4e5c-b6ae-e9fddcbf7151","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"{{base_url}}/charge_file/{{collection_file_import_id}}","urlObject":{"path":["charge_file","{{collection_file_import_id}}"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"a4ca0d94-fd06-4e5c-b6ae-e9fddcbf7151"}],"id":"84af45d3-15bc-44cc-84d7-f0f16152dcc2","description":"<h4 id=\"description\">Description</h4>\n<p><a href=\"#a4ca0d94-fd06-4e5c-b6ae-e9fddcbf7151\">charge_file/<em>{{import_id}}</em></a> can be used to query the status of a collection file import and to get the results on completion.</p>\n<h4 id=\"response\">Response</h4>\n<p>A successful call to charge_file/<em>{{import_id}}</em> returns an XML document containing the status of the enqueued import. Each of the queued collection file chunks is listed in the &lt;file_chunks&gt; grouping tag. Each &lt;file_chunk&gt; tag includes the lines included in the chunk and the current status of the chunk. As each chunk is processed, its status moves through the following values:</p>\n<ul>\n<li><code>In process - please wait</code></li>\n<li><code>allocated</code></li>\n<li><code>started</code></li>\n<li><code>Import complete, click here for result</code></li>\n</ul>\n<p>Once a chunk has completed, a listing of the changes made is included in the &lt;file_chunk&gt; in a &lt;successes&gt; group tag. Similarly, any failed lines or errors are listed in an &lt;errors&gt; group tag:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>200 OK\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;charge_file_import uri=\"https://sandbox.ddprocessing.co.uk/api/charge_file/123\"&gt;\n  &lt;action&gt;CREATE&lt;/action&gt;\n  &lt;file_name&gt;collection_file.csv&lt;/file_name&gt;\n  &lt;completed_on&gt;2019-05-12T12:04:21Z&lt;/completed_on&gt;\n  &lt;service_user&gt;\n    &lt;pslid&gt;su_pslid&lt;/pslid&gt;\n  &lt;/service_user&gt;\n  &lt;file_chunks&gt;\n    &lt;file_chunk to_line=\"2\" status=\"Import complete, click here for result\" from_line=\"1\"&gt;\n      &lt;successes total=\"1\"&gt;\n        &lt;success&gt;Line 2: Debit for 15 June 2019 created&lt;/success&gt;\n        &lt;/successes&gt;\n      &lt;errors total=\"1\"&gt;\n        &lt;error&gt;Line 1: Not Imported: the date 2019/05/15 00:00 is before today plus the charge file lead time of 3 days.&lt;/error&gt;\n      &lt;/errors&gt;\n    &lt;/file_chunk&gt;\n  &lt;/file_chunks&gt;\n&lt;/charge_file_import&gt;\n</code></pre><p><strong>Note:</strong></p>\n<ul>\n<li>The line number reported in each &lt;success&gt; or &lt;error&gt; tag is relative to the chunk and not necessarily the whole file.</li>\n<li>&lt;error&gt; tags indicate that a collection was not imported. They are significant.</li>\n<li>The HTTP status relates to the call and not to the import. A line, a chunk or the whole file may fail to import, despite an HTTP status of \"200 OK\". </li>\n<li>The &lt;action&gt; node is not significant.</li>\n</ul>\n<h4 id=\"errors\">Errors</h4>\n<ul>\n\n<li><h6>Querying the status of an invalid file results in one of these two errors:</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Couldn't find ParallelTask with ID=1524&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><br />\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>401 Unauthorized\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Permission denied. You cannot access the requested resource.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<br />\n\n<li><h6>Contact SmartDebit support if a file or chunk remains stuck at</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>In process - please wait\n</code></pre></li>\n</ul>","event":[{"listen":"prerequest","script":{"id":"32364913-3d4d-4db6-8d3e-9d55ce16cb4e","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"e2e87969-0f83-47e3-8f2f-80fc76a25c4d","type":"text/javascript","exec":[""]}}],"_postman_id":"84af45d3-15bc-44cc-84d7-f0f16152dcc2"}],"id":"e2e50faf-3e40-43ea-9792-3ff7a28f0aea","description":"<p>Direct Debit Instructions (DDIs, payers) and individual debits (collections) can be created and updated via imported data files.  </p>\n<p><strong>Note:</strong></p>\n<ul>\n<li>both file types are CSV formats</li>\n<li>date formats are as given in the specification, and</li>\n<li>amounts are in pounds and pence</li>\n</ul>\n<p><a href=\"#af952adc-d8b5-412c-96e6-e1064bd7a70d\">Payer files</a> can be used to:</p>\n<ul>\n<li>create either variable or adhoc DDIs</li>\n<li>update DDIs</li>\n<li>cancel DDIs</li>\n<li>re-instate cancelled DDIs</li>\n</ul>\n<p><a href=\"#7c167ef6-c64a-4f88-a592-4e422b2bc719\">Collection files</a> can be used to:</p>\n<ul>\n<li>create or update collections for one or more payers</li>\n<li>suppress or modify payment schedules if the imported collections coincide with those schedules</li>\n</ul>\n<p>Collection files cannot be used to delete collections, though a value of zero can be used.</p>\n","event":[{"listen":"prerequest","script":{"id":"f6ef5a42-d80a-4819-952b-5f03ac6b1896","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"60e6e02e-184d-471e-999d-fdbd13eddfc1","type":"text/javascript","exec":[""]}}],"_postman_id":"e2e50faf-3e40-43ea-9792-3ff7a28f0aea"},{"name":"4.5 Audit log","item":[{"name":"data/auditlog (XML example)","event":[{"listen":"test","script":{"id":"e90c48b1-e3f9-4807-8f95-6e563fabbcb3","exec":["// Documentation refers to a POST request in this case","","eval(pm.globals.get('jasmine'));","","pm.test(\"Response time is less than 300ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(300);","});","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","pm.test(\"Body matches string\", function () {","    pm.expect(pm.response.text()).to.include('<AuditLog xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"nonamesp.xsd\">');","    pm.expect(pm.response.text()).to.include('<Data>');","    pm.expect(pm.response.text()).to.include('<AuditDetails');","    pm.expect(pm.response.text()).to.include('</Data>');","    pm.expect(pm.response.text()).to.include('</AuditLog>');","    ","});","","//               SCHEMA Validation                      //","var result = xml2Json(responseBody);                    //                                            ","                                                        //","var schema =  sd.api.schema.auditLog;           //","                                                        //","  pm.test('Schema is valid', function() {               //","    pm.expect(tv4.validate(result, schema)).to.be.true; //","  });                                                   //","//               SCHEMA Validation                      //"],"type":"text/javascript"}}],"id":"59fdc403-98bf-4985-b23b-6d35dbe79470","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"key":"query[service_user][pslid]","value":"{{pslid}}","description":"<p><i>Required</i><br />\nService user identifier</p>\n","type":"text"},{"key":"query[report_format]","value":"{{report_format}}","description":"<p><i>Required</i><br /><b>Format:</b> 'CSV' or 'XML'<br /><b>Default:</b> XML</p>\n","type":"text"},{"key":"query[reference_number]","value":"{{reference_number}}","description":"<p><i>Required</i><br />Bacs reference as payer identifier</p>\n","type":"text"},{"key":"query[include_header] ","value":"{{include_header}}","description":"<p><b>Format:</b> 'true' or 'false'<br /><b>Default:</b> false </p>\n","type":"text"},{"key":"query[from_date]","value":"{{from_date}}","description":"<p><b>Format:</b> YYYY-MM-DD</p>\n","type":"text"},{"key":"query[to_date]","value":"{{to_date}}","description":"<p><b>Format:</b> YYYY-MM-DD</p>\n","type":"text"}]},"url":"{{base_url}}/data/auditlog","urlObject":{"path":["data","auditlog"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"078dc37f-b581-4dd7-93f5-79f7d5d577da","name":"audit_log (XML)","originalRequest":{"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"key":"query[service_user][pslid]","value":"{{pslid}}","description":"<b>Format:</b> plain text   <br><b>Restrictions:</b> 5 to 255 characters, must match existing SU's pslid","type":"text"},{"key":"query[report_format]","value":"XML","description":"<b>Restrictions:</b> <b>'CSV'</b> or <b>'XML'</b> <br> <b>Default:</b> is  'XML'","type":"text"},{"key":"query[reference_number]","value":"{{reference_number}}","description":"A unique reference number must be passed.<br>\n<b>Format:</b> plain text <br>\n<b>Restrictions:</b> Unique, 6 to 18 characters May not contain solidus (/)  and further restrictions apply.","type":"text"},{"key":"query[include_header] ","value":"","description":"<b>Format:</b> plain text <br><b>Restrictions:</b> <b>'true'</b> or <b>'false'</b> <br><b>Default:</b> is false ","type":"text","disabled":true},{"key":"query[from_date]","value":"","description":"<b>Optional</b><br> <b>Format:</b> YYYY-MM-DD <br>\n<b>Restrictions:</b> Must be far enough in the past before the to_date parameter]","type":"text","disabled":true},{"key":"query[to_date]","value":"","description":"<b>Optional</b><br> <b>Format:</b> YYYY-MM-DD <br>\n<b>Restrictions:</b> Must be after the from_date parameter","type":"text","disabled":true}]},"url":"{{base_url}}/data/auditlog"},"status":"OK","code":200,"_postman_previewlanguage":"xml","header":[{"key":"Date","value":"Thu, 28 Feb 2019 09:05:21 GMT"},{"key":"Server","value":"Apache"},{"key":"X-Runtime","value":"0.09595"},{"key":"Content-Disposition","value":"attachment; filename=audit_log.xml"},{"key":"Content-Transfer-Encoding","value":"binary"},{"key":"Cache-Control","value":"private"},{"key":"Strict-Transport-Security","value":"max-age=63072000; includeSubdomains; preload"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Set-Cookie","value":"auth_token=; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"_PSLLite_session_id=59c10b241683faff8f68dab95c0ecf7c; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"incap_ses_454_1416256=a; Max-Age=0; path=/; expires=Sun, 24 Feb 2019 13:13:15 GMT; Domain=.ddprocessing.co.uk"},{"key":"Status","value":"200 OK"},{"key":"X-XSS-Protection","value":"1; mode=block"},{"key":"Keep-Alive","value":"timeout=5, max=100"},{"key":"Connection","value":"Keep-Alive"},{"key":"Content-Type","value":"text/xml; charset=iso-8859-1"},{"key":"X-Iinfo","value":"14-63845015-63883178 NNNN CT(76 9 0) RT(1551344670888 117709) q(0 0 1 -1) r(3 3) U5"},{"key":"X-CDN","value":"Incapsula"},{"key":"Content-Encoding","value":"gzip"},{"key":"Transfer-Encoding","value":"chunked"}],"cookie":[],"responseTime":null,"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<AuditLog xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"nonamesp.xsd\">\r\n  <Data>\r\n    <AuditDetails User=\"serviceuserapi\" description=\"Direct Debit Instruction Created via API\" reference_number=\"ABC123456\" timestamp=\"2019/02/13 13:51\"/>\r\n    <AuditDetails User=\"serviceuserapi\" description=\"Confirmation Email Sent Ruby 4\" reference_number=\"ABC123456\" timestamp=\"2019/02/13 13:51\"/>\r\n    <AuditDetails User=\"davidp\" description=\"Direct Debit Instruction updated\" reference_number=\"ABC123456\" timestamp=\"2019/02/14 09:05\"/>\r\n    <AuditDetails User=\"umara\" description=\"Debit added for 01 March 2019\" reference_number=\"ABC123456\" timestamp=\"2019/02/16 12:28\"/>\r\n    <AuditDetails User=\"umara\" description=\"Debit added for 01 March 2019 by umara\" reference_number=\"ABC123456\" timestamp=\"2019/02/16 12:28\"/>\r\n    <AuditDetails User=\"davidb\" description=\"Debit for 01 Mar 2019 marked as processed\" reference_number=\"AVR1291956\" timestamp=\"2019/02/27 10:46\"/>\r\n    <AuditDetails User=\"davidp\" description=\"Cancelled by ADDACS import (ADDACS file 0, reason &quot;Instruction cancelled by Payer&quot;)\" reference_number=\"ABC123456\" timestamp=\"2019/04/18 03:24\"/>\r\n    <AuditDetails User=\"davidp\" description=\"DirectDebitController.view\" reference_number=\"ABC123456\" timestamp=\"2019/04/18 14:48\"/>\r\n    <AuditDetails User=\"davidp\" description=\"Direct Debit Instruction restored manually by David Prosser\" reference_number=\"ABC123456\" timestamp=\"2019/04/18 14:48\"/>\r\n  </Data>\r\n</AuditLog>"}],"_postman_id":"59fdc403-98bf-4985-b23b-6d35dbe79470"}],"id":"5bdf8c47-d604-4a15-95b5-8c2da05899aa","description":"<h4 id=\"description\">Description</h4>\n<p><a href=\"#59fdc403-98bf-4985-b23b-6d35dbe79470\">data/auditlog</a> may be called as a GET or a POST. It may be used to retrieve a list of audit records for a specified payer. </p>\n<ul>\n<li>The service user is specified using the query[service_user][pslid] parameter.</li>\n<li>The payer is specified using the query[reference_number] parameter. If the payer is not found, the call returns successfully with no records.</li>\n<li>A date range can be specified with the query[from_date] and query[to_date] parameters. Note that query[to_date] is exclusive - any records from that day are not returned.</li>\n</ul>\n<h4 id=\"response\">Response</h4>\n<p>The audit records can be returned in XML or CSV format. The default format is XML.</p>\n<ul>\n<li><p>XML response:\nThe returned document contains an AuditDetails element for each audit record. This element has the following attributes:</p>\n<ul>\n<li>timestamp (in \"YYYY/MM/DD hh:mm\" format)</li>\n<li>reference_number </li>\n<li>description</li>\n<li>User</li>\n</ul>\n</li>\n<li><p>CSV response:\nThe following columns are returned, left to right: </p>\n<ul>\n<li>timestamp (in \"YYYY/MM/DD hh:mm\" format)</li>\n<li>reference number</li>\n<li>description</li>\n<li>user</li>\n</ul>\n</li>\n</ul>\n<h4 id=\"errors\">Errors</h4>\n<ul>\n<li>\n<h6>If no service user is specified:</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>200 OK\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;AuditLog xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"nonamesp.xsd\"&gt;\n  &lt;Errors&gt;\n    &lt;ErrorDetail&gt;No service user id supplied.&lt;/ErrorDetail&gt;\n  &lt;/Errors&gt;\n&lt;/AuditLog&gt;\n</code></pre></li>\n\n<li>\n<h6>If an invalid service user is specified (example):</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>200 OK\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;AuditLog xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"nonamesp.xsd\"&gt;\n  &lt;Errors&gt;\n    &lt;ErrorDetail&gt;Invalid Service User ID: 'invalid'&lt;/ErrorDetail&gt;\n  &lt;/Errors&gt;\n&lt;/AuditLog&gt;\n</code></pre></li>\n\n<li>\n<h6>If no reference number is specified:</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>200 OK\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;AuditLog xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"nonamesp.xsd\"&gt;\n  &lt;Errors&gt;\n    &lt;ErrorDetail&gt;No reference number supplied.&lt;/ErrorDetail&gt;\n  &lt;/Errors&gt;\n&lt;/AuditLog&gt;\n</code></pre></li>\n\n<li>\n<h6>If an invalid reference number is specified (example):</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>200 OK\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;AuditLog xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"nonamesp.xsd\"&gt;\n  &lt;Errors&gt;\n    &lt;ErrorDetail&gt;Invalid reference number supplied. 12345&lt;/ErrorDetail&gt;\n  &lt;/Errors&gt;\n&lt;/AuditLog&gt;\n</code></pre></li>\n\n<li>\n<h6>If a non-existent reference number is supplied:</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>200 OK\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;AuditLog xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"nonamesp.xsd\"&gt;\n  &lt;Data&gt;\n  &lt;/Data&gt;\n&lt;/AuditLog&gt;\n</code></pre><p>... or, if CSV format is specified, an empty document is returned.</p>\n</li>\n\n<li>\n<h6>If a date parameter is given with a month or day of zero, or a month greater than 12, or a day greater than 31:</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;argument out of range&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n\n</ul>\n\n<h4 id=\"version-history\">Version history</h4>\n<table>\n<tr>\n<td></td>\n<td>The <i>query[include_header]</i> parameter is deprecated because the header is incorrectly formatted: <code>\"Timestamp,Reference No,Description,User\"</code>.</td>\n</tr>\n</table>","event":[{"listen":"prerequest","script":{"id":"a4ac0981-9f33-427a-8940-f2729018a76f","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"7fdf2be8-d98c-4cd3-b562-9daf4e5c300b","type":"text/javascript","exec":[""]}}],"_postman_id":"5bdf8c47-d604-4a15-95b5-8c2da05899aa"},{"name":"4.6 Collection report","item":[{"name":"get_collection_report","event":[{"listen":"test","script":{"id":"0c00135f-ed85-40a4-a668-0fea72fb666d","exec":["eval(pm.globals.get('jasmine'));","","","pm.test(\"Response time is less than 200ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(200);","});","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","pm.test(\"Body matches string\", function () {","     pm.expect(pm.response.text()).to.include(\"<CollectionReport xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\">\");","    pm.expect(pm.response.text()).to.include(\"<Successes>\");","    pm.expect(pm.response.text()).to.include(\"</Successes>\");","    pm.expect(pm.response.text()).to.include(\"<Rejects>\");","    pm.expect(pm.response.text()).to.include(\"</Rejects>\");","    pm.expect(pm.response.text()).to.include(\"<Summary>\");","    pm.expect(pm.response.text()).to.include(\"<CollectionDate>\");","    pm.expect(pm.response.text()).to.include(\"</Summary>\");","    pm.expect(pm.response.text()).to.include(\"</CollectionReport>\");","    var jsonObject = xml2Json(responseBody);","    if(jsonObject.assigned_service_users !== undefined && jsonObject.assigned_service_users.length === 1)","    {return true;}","    else{","        return 'no service user has been assigned to this api user';","    }","});","","","","","var jsonObject = xml2Json(responseBody);","console.log(JSON.stringify(jsonObject));","","","var schema =  sd.api.schema.collectionReport;","","console.log(schema);","pm.test('Schema is valid', function() {","  pm.expect(tv4.validate(jsonObject, schema)).to.be.true;","});",""],"type":"text/javascript"}},{"listen":"prerequest","script":{"id":"67a033e8-b011-40a9-80bc-5263db9b2148","exec":["","pm.environment.set('collection_date','2019-03-06');"],"type":"text/javascript"}}],"id":"9c7048af-9192-420d-b2d7-adfe30ea3385","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"GET","header":[],"url":"{{base_url}}/get_collection_report?query[service_user][pslid]={{pslid}}&query[debit_date]={{collection_date}}","urlObject":{"path":["get_collection_report"],"host":["{{base_url}}"],"query":[{"description":{"content":"<p><i>Required</i><br />\nService user identifier</p>\n","type":"text/plain"},"key":"query[service_user][pslid]","value":"{{pslid}}"},{"description":{"content":"<p><i>Recommended</i><br /><b>Format:</b> YYYY-MM-DD</p>\n","type":"text/plain"},"key":"query[debit_date]","value":"{{collection_date}}"}],"variable":[]}},"response":[{"id":"11ec859b-777f-4684-bc24-df18b728dce5","name":"get_collection_report","originalRequest":{"method":"GET","header":[],"url":{"raw":"{{base_url}}/get_collection_report?query[service_user][pslid]={{pslid}}&query[debit_date]={{collection_date}}","host":["{{base_url}}"],"path":["get_collection_report"],"query":[{"key":"query[service_user][pslid]","value":"{{pslid}}","description":"<b>Format:</b> plain text   <br><b>Restrictions:</b> 5 to 255 characters, must match existing SU's pslid"},{"key":"query[debit_date]","value":"{{collection_date}}","description":"<b>Format:</b> YYYY-MM-DD"}]}},"status":"OK","code":200,"_postman_previewlanguage":"xml","header":[{"key":"Date","value":"Mon, 04 Mar 2019 09:33:12 GMT"},{"key":"Server","value":"Apache"},{"key":"Content-Transfer-Encoding","value":"binary"},{"key":"Cache-Control","value":"private"},{"key":"X-Runtime","value":"0.03869"},{"key":"Content-Disposition","value":"attachment; filename=\"collection_report.xml\""},{"key":"Strict-Transport-Security","value":"max-age=63072000; includeSubdomains; preload"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Set-Cookie","value":"auth_token=; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"_PSLLite_session_id=59c10b241683faff8f68dab95c0ecf7c; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"incap_ses_373_1416256=a; Max-Age=0; path=/; expires=Sun, 24 Feb 2019 13:13:15 GMT; Domain=.ddprocessing.co.uk"},{"key":"Set-Cookie","value":"incap_ses_454_1416256=a; Max-Age=0; path=/; expires=Sun, 24 Feb 2019 13:13:15 GMT; Domain=.ddprocessing.co.uk"},{"key":"Status","value":"200 OK"},{"key":"X-XSS-Protection","value":"1; mode=block"},{"key":"Keep-Alive","value":"timeout=5, max=100"},{"key":"Connection","value":"Keep-Alive"},{"key":"Content-Type","value":"text/xml"},{"key":"X-Iinfo","value":"5-90065521-90067091 NNNN CT(0 0 0) RT(1551692061300 8868) q(0 0 0 -1) r(1 1) U5"},{"key":"X-CDN","value":"Incapsula"},{"key":"Content-Encoding","value":"gzip"},{"key":"Transfer-Encoding","value":"chunked"}],"cookie":[],"responseTime":null,"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<CollectionReport xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n    <Successes>\n        <Success amount=\"199.95\" transaction_ref=\"\" reference_number=\"SD119011412456372\" debit_date=\"06/03/2019 00:00\" account_name=\"test-account\" customer_id=\"\"/>\n        <Success amount=\"20.00\" transaction_ref=\"\" reference_number=\"SD1190114121415638\" debit_date=\"06/03/2019 00:00\" account_name=\"Charlie\" customer_id=\"\"/>\n        <Success amount=\"12.00\" transaction_ref=\"\" reference_number=\"SD1190122121722832\" debit_date=\"06/03/2019 00:00\" account_name=\"Mia\" customer_id=\"\"/>\n        <Success amount=\"5.00\" transaction_ref=\"\" reference_number=\"SD119011316162862\" debit_date=\"06/03/2019 00:00\" account_name=\"Ava\" customer_id=\"\"/>\n    </Successes>\n    <Rejects>\n  </Rejects>\n    <Summary>\n        <CollectionDate>06/03/2019</CollectionDate>\n        <Succesful number_submitted=\"4\" amount_submitted=\"236.95\"/>\n        <Rejected number_rejected=\"0\" amount_rejected=\"0.00\"/>\n    </Summary>\n</CollectionReport>"}],"_postman_id":"9c7048af-9192-420d-b2d7-adfe30ea3385"}],"id":"2f6356dc-6e65-41fd-ad5f-7ef61521b2f3","description":"<h4 id=\"description\">Description</h4>\n<p><a href=\"#9c7048af-9192-420d-b2d7-adfe30ea3385\">get_collection_report</a> provides a summary and a list of collections due on the specified date.</p>\n<h4 id=\"response\">Response</h4>\n<p>A successful call to get_collection_report returns an XML document containing a list of collections due on a specified date.</p>\n<p>An XML collection report file consists of a Successes tag, a Rejects tag and a Summary tag within a CollectionReport wrapper.</p>\n<p>Within the Successes tag there may be a list of Success tags, each of which has the following attributes:</p>\n<ul>\n<li>debit_date: the due date (which may be a non-working day) in the format \"DD/MM/YYYY 00:00\"</li>\n<li>account_name: the payer's account name</li>\n<li>amount: in pounds and pence without the £ symbol</li>\n<li>reference_number: the unique identifier for the DDI</li>\n<li>customer_id: if used, a further label given to the DDI (equivalent to \"payer_reference\" in other calls)</li>\n<li>transaction_ref: if used, an identifier for the collection (comprising the reference_number followed by a hyphen followed by another label)</li>\n</ul>\n<p>Within the Rejects tag there may be a list of Reject tags, each of which has the same attributes as the Success tag with an additional error_message tag which gives the rejection reason or may be empty.</p>\n<p>The Summary tag contains a CollectionDate tag (where the date is in the format DD/MM/YYYY), a Succesful (sic) tag with attributes number_submitted and amount_submitted, and a Rejected tag with attributes number_rejected and amount_rejected. Amounts are in pounds and pence without the £ sign.</p>\n<p>Understanding the response:</p>\n<ul>\n<li>Collections that have been imported into the system are reported as soon as they have been imported (whether they have been submitted to Bacs or not).</li>\n<li>Collections that are generated by the system (for variable DDIs with regular amounts) are reported as soon as they have been generated, which is early on the day of submission. Collections are submitted ahead of the due date, depending on the service user's advance notice period.</li>\n<li>When a DDI is cancelled, pending collections are usually deleted. Such collections are not currently reported. The deletion of collections is subject to design review, therefore this behaviour may change.</li>\n<li>Under some circumstances the collections may remain for a cancelled DDI. These are reported as successes.</li>\n<li>Under some circumstances a collection may be rejected by Bacs. Such collections are reported as successes until the working day following submission, when they become rejects.</li>\n</ul>\n<p>Thus, get_collection_report does not indicate the success of a collection (for that, see <a href=\"#f1e498d3-1a90-42b0-85f1-8cbbda55898e\">get_successful_collection_report</a>) and does not give a reliable indication that a collection was submitted.</p>\n<p>Note the spelling of \"Succesful\" in the &lt;Summary&gt; section.</p>\n<p>If there are no collections for the specified date the returned XML is as this example:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>200 OK\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt;\n&lt;CollectionReport xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'&gt;\n  &lt;Summary&gt;No collection report for 2019-04-01&lt;/Summary&gt;\n&lt;/CollectionReport&gt;\n</code></pre><p>Note the single quotes in this response.</p>\n<h4 id=\"version-history\">Version history</h4>\n<table>\n<tr>\n<td></td>\n<td>Use of this call without a date parameter is deprecated. This usage was designed to return a list of collections being submitted today. However the call calculates the due date as {today} + {collection file lead time} and can only return collections due on a single date. Most service users' lead times are calculated in working days. For such service users the call may return an unexpected date and may not report some collections.</td>\n</tr>\n</table>\n\n\n<h4 id=\"errors\">Errors</h4>\n<ul>\n<li><h6>Service user not specified</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;No service user id supplied.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n</ul>","event":[{"listen":"prerequest","script":{"id":"95a3e85e-f9ba-40b8-bf24-4da752b7f5eb","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"4bfaa4c4-44b0-4abc-bdaf-ff9024028e9e","type":"text/javascript","exec":[""]}}],"_postman_id":"2f6356dc-6e65-41fd-ad5f-7ef61521b2f3"},{"name":"4.7 Reconciliation report","item":[{"name":"get_successful_collection_report","event":[{"listen":"test","script":{"id":"ed913c8b-7b0f-4564-bb92-4567452e9426","exec":["eval(pm.globals.get('jasmine'));","","pm.test(\"Response time is less than 300ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(300);","});","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","////////////////////////////////////","//Prepare for next call parameters//","////////////////////////////////////","var d = new Date().toISOString().replace(/:/g,'').replace(/-/g,'').slice(9, 15);","console.log(d);","","//let no = (d.getHours()+d.getMinutes()+d.getSeconds()).toString().replace(/_/g,'_').slice(0, 6);","//console.log(((d.getHours()+d.getMinutes()+d.getSeconds()).toString()).toString());","//console.log((d.getHours()+d.getMinutes()+d.getSeconds()).toString().replace(/_/g,'_'));","//console.log(no);","var ref_no = new Date().toISOString().replace(/:/g,'_').replace(/-/g,'').slice(0, 8);","var reference_number = 'API-'+ref_no+d;","","console.log(reference_number);","","pm.environment.set(\"ref_number\", reference_number);","","","var jsonObject = xml2Json(responseBody);","console.log(JSON.stringify(jsonObject));","","","var schema =  sd.api.schema.collectionReport;","","console.log(schema);","pm.test('Schema is valid', function() {","  pm.expect(tv4.validate(jsonObject, schema)).to.be.true;","});",""],"type":"text/javascript"}},{"listen":"prerequest","script":{"id":"e56d986e-41c5-45ef-8ae8-ec84e5f92e35","exec":["pm.environment.set('successful_collection_date','2019-03-06');"],"type":"text/javascript"}}],"id":"f1e498d3-1a90-42b0-85f1-8cbbda55898e","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"GET","header":[],"url":"{{base_url}}/get_successful_collection_report?query[service_user][pslid]={{pslid}}&query[collection_date]={{collection_date}}","description":"<p>All parameters are required.</p>\n","urlObject":{"path":["get_successful_collection_report"],"host":["{{base_url}}"],"query":[{"description":{"content":"<p>Service user identifier</p>\n","type":"text/plain"},"key":"query[service_user][pslid]","value":"{{pslid}}"},{"description":{"content":"<p><b>Format:</b> YYYY-MM-DD</p>\n","type":"text/plain"},"key":"query[collection_date]","value":"{{collection_date}}"}],"variable":[]}},"response":[{"id":"afcace9d-44d4-4c1f-b8eb-e6c93e0553ae","name":"get_successful_collection_report","originalRequest":{"method":"GET","header":[],"url":{"raw":"{{base_url}}/get_successful_collection_report?query[service_user][pslid]={{pslid}}&query[collection_date]={{collection_date}}","host":["{{base_url}}"],"path":["get_successful_collection_report"],"query":[{"key":"query[service_user][pslid]","value":"{{pslid}}","description":"Service user identifier"},{"key":"query[collection_date]","value":"{{collection_date}}","description":"<b>Format:</b> YYYY-MM-DD"}]}},"status":"OK","code":200,"_postman_previewlanguage":null,"header":null,"cookie":[],"responseTime":null,"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<CollectionReport xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n  <Successes>\n    <Success customer_id=\"1668701\" account_name=\"MRS A R PAYER\" amount=\"4.99\" transaction_ref=\"\" reference_number=\"ABC133184\" debit_date=\"16/01/2019 00:00\"/>\n  </Successes>\n  <Rejects>\n    <Rejected customer_id=\"1765852\" account_name=\"MS M PAYER\" error_message=\"\" amount=\"4.99\" transaction_ref=\"\" reference_number=\"ABC163640\" debit_date=\"16/01/2019 00:00\"/>\n  </Rejects>\n  <Summary>\n    <CollectionDate>16/01/2019</CollectionDate>\n    <Succesful amount_submitted=\"4.99\" number_submitted=\"1\"/>\n    <Rejected amount_rejected=\"4.99\" number_rejected=\"1\"/>\n  </Summary>\n</CollectionReport>"}],"_postman_id":"f1e498d3-1a90-42b0-85f1-8cbbda55898e"}],"id":"efceb3f7-3bb8-4af9-b126-f8f912bb5fc7","description":"<p><a href=\"#f1e498d3-1a90-42b0-85f1-8cbbda55898e\">get_successful_collection_report</a> provides a summary and a breakdown of collections that were taken on a specified date.</p>\n<p>This report reflects any unpaid collections and is made available on the third working day after the collection date to allow for any unpaid collections (ARUDDs) to be reported.</p>\n<p>This report differs from <a href=\"#9c7048af-9192-420d-b2d7-adfe30ea3385\">get_collection_report</a> as follows:</p>\n<ul>\n<li>the report is available only after the collection date</li>\n<li>the date parameter is query[collection_date] rather than query[debit_date]</li>\n<li>the Rejects section has a different meaning</li>\n</ul>\n<h4 id=\"response\">Response</h4>\n<p>A successful call to <a href=\"#f1e498d3-1a90-42b0-85f1-8cbbda55898e\">get_successful_collection_report</a> returns an XML document containing a list of collections due on a specified date.</p>\n<p>An XML collection report file consists of a Successes tag, a Rejects tag and a Summary tag within a CollectionReport wrapper.</p>\n<p>Within the Successes tag there may be a list of Success tags, each of which has the following attributes:</p>\n<ul>\n<li>debit_date: the due date (which may be a non-working day) in the format \"DD/MM/YYYY 00:00\"</li>\n<li>account_name: the payer's account name</li>\n<li>amount: in pounds and pence without the £ symbol</li>\n<li>reference_number: the unique identifier for the DDI</li>\n<li>customer_id: if used, a further label given to the DDI (equivalent to \"payer_reference\" in other calls)</li>\n<li>transaction_ref: if used, an identifier for the collection (comprising the reference_number followed by a hyphen followed by another label)</li>\n</ul>\n<p>Within the Rejects tag there may be a list of Reject tags, each of which has the same attributes as the Success tag with an additional error_message tag which may give the reason or may be empty.</p>\n<p>The Summary tag contains a CollectionDate tag (where the date is in the format DD/MM/YYYY), a Succesful (sic) tag with attributes number_submitted and amount_submitted, and a Rejected tag with attributes number_rejected and amount_rejected. Amounts are in pounds and pence without the £ sign.</p>\n<p>Understanding the response:</p>\n<ul>\n<li>In all but the most exceptional cases the ARUDDs will have been received within the 3 working days.</li>\n<li>The Successes node contains all collections that are believed to have been paid.</li>\n<li>Collections that failed with an ARUDD are listed as Rejects.</li>\n<li>Collections that were rejected by Bacs are listed as Rejects.</li>\n<li>Collections that were not submitted (and have not been deleted) are listed as Rejects - typically those with an amount of 0.00.</li>\n<li>Collections that have been indemnity claimed by the payer are listed as Successes in v1.1 onward, otherwise as Rejects.</li>\n<li>Where the DDI was cancelled prior to submission of the collection, the collection is not currently reported. The deletion of collections is subject to design review, therefore this behaviour may change.</li>\n</ul>\n<p>Note the spelling of \"Succesful\" in the &lt;Summary&gt; section.</p>\n<p>If 3 working days have not elapsed since the collection date the following XML is returned:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>200 OK\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt;\n&lt;SuccessfulCollectionReport xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'&gt;\n  &lt;Summary&gt;A successful collection report can only be issued 3 working days after the collection date to allow for ARUDD returns.\n &lt;/Summary&gt;\n&lt;/SuccessfulCollectionReport&gt;\n</code></pre><p>If there are no collections for the specified date the following XML is returned:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>200 OK\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt;\n&lt;CollectionReport xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'&gt;\n  &lt;Summary&gt;No collection report for 2019-04-01&lt;/Summary&gt;\n&lt;/CollectionReport&gt;\n</code></pre><p>Note the single quotes in this response.</p>\n<h4 id=\"version-history\">Version history</h4>\n<table>\n<tr>\n<td>v1.1</td>\n<td>Collections that have been indemnity claimed are presented as \"Successes\".</td>\n</tr>\n<tr>\n<td></td>\n<td>Collections that have been indemnity claimed are presented as \"Rejects\".</td>\n</tr>\n</table>\n\n\n<h4 id=\"errors\">Errors</h4>\n<ul>\n<li><h6>Service user not specified</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;No service user id supplied.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n</ul>","event":[{"listen":"prerequest","script":{"id":"20e1cfcb-65dc-412f-837d-7d7f6da2ef4f","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"6eceb9f3-2201-4483-b5c5-3b92eff3efaf","type":"text/javascript","exec":[""]}}],"_postman_id":"efceb3f7-3bb8-4af9-b126-f8f912bb5fc7"},{"name":"4.8 Bacs reports","item":[{"name":"4.8.1 List AUDDIS","item":[{"name":"auddis/list","event":[{"listen":"test","script":{"id":"f304f9d0-01be-4c53-b0b4-476e956421d6","exec":["pm.test(\"Response time is less than 200ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(200);","});","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","","pm.test(\"Body matches string\", function () {","    pm.expect(pm.response.text()).to.include('<?xml version=\\'1.0\\' encoding=\\'UTF-8\\'?>');","    ","    var response = pm.response.text();","    var pattern = /<auddiss results=\\'(\\d+)\\' total_results=\\'(\\d+)\\' start_index=\\'(\\d+)\\'>/g;","    ","    //pm.expect(pattern.test(response)).to.eql(true);","    pm.expect(pm.response.text()).to.include('</auddis>');","});","","//pm.test(\"Body is correct\", function () {","//    pm.response.to.have.body(pm.environment.get(\"new_auddis_list_response\"));","//});","","pm.test('Schema is valid', function() {","  var jsonObject = xml2Json(pm.response.text()); ","  console.log(jsonObject);","  ","  var jsonSchema =   sd.api.schema.auddisList;  ","    ","  pm.expect(tv4.validate(jsonObject, jsonSchema)).to.be.true;","  ","});","","pm.globals.unset(\"new_auddis_list_response\");","","var regEx = new RegExp('<auddis_id>([0-9]+)<\\/auddis_id>', 'gm');","var knownAuddisId = regEx.exec(responseBody)[1];","pm.globals.set(\"known_auddis_id\", knownAuddisId);","",""],"type":"text/javascript"}}],"id":"db62fb9b-fd63-4e21-bdd8-b7fa333189dd","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"key":"query[service_user][pslid]","value":"{{pslid}}","type":"text","description":"<p><i>Required</i><br />\nService user identifier</p>\n"},{"key":"query[max_results]","value":"{{max_results}}","type":"text","description":"<p><b>Format:</b> integer, 1 to 1000<br /><b>Default:</b> 100</p>\n"},{"key":"query[start_index]","value":"{{start_index}}","type":"text","description":"<p><b>Format:</b> integer<br /><b>Default:</b> 0</p>\n"},{"key":"query[id_from]","value":"{{id_from}}","type":"text","description":"<p><b>Format:</b> integer</p>\n"},{"key":"query[from_date]","value":"{{from_date}}","type":"text","description":"<p><i>Conditional (required if till_date is used)</i><br /><b>Format:</b> YYYY-MM-DD</p>\n"},{"key":"query[till_date]","value":"{{till_date}}","type":"text","description":"<p><b>Format:</b> YYYY-MM-DD</p>\n"}]},"url":"{{base_url}}/auddis/list","urlObject":{"path":["auddis","list"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"476fb697-877c-4dce-ab45-bc41aed05506","name":"auddis/list","originalRequest":{"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"key":"query[service_user][pslid]","value":"{{pslid}}","type":"text","description":"<b>Format:</b> plain text<br><b>Restrictions:</b> 5 to 255 characters, must match existing SU's pslid"},{"key":"query[max_results]","value":"","description":"<b>Format:</b> integer <br><b>Restrictions:</b> 1 to 1000<br><b>Default:</b> is 100</b>","type":"text"},{"key":"query[start_index]","value":"","description":"<b>Format:</b> integer<br><b>Restrictions:</b> 0 or greater<br><b>Default: </b>0</b>","type":"text"},{"key":"query[id_from]","value":"","description":"<b>Format:</b> integer<br><b>Restrictions:</b> 0 or greater</b>","type":"text"},{"key":"query[from_date]","value":"","description":"<b>Format:</b> date YYYY-MM-DD","type":"text"},{"key":"query[till_date]","value":"","description":"<b>Format:</b> date YYYY-MM-DD","type":"text"}]},"url":"{{base_url}}/auddis/list"},"status":"OK","code":200,"_postman_previewlanguage":"xml","header":[{"key":"Date","value":"Mon, 04 Mar 2019 15:09:27 GMT"},{"key":"Server","value":"Apache"},{"key":"Cache-Control","value":"private, max-age=0, must-revalidate"},{"key":"X-Runtime","value":"0.04437"},{"key":"Strict-Transport-Security","value":"max-age=63072000; includeSubdomains; preload"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Set-Cookie","value":"auth_token=; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"_PSLLite_session_id=59c10b241683faff8f68dab95c0ecf7c; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"incap_ses_874_1416256=a; Max-Age=0; path=/; expires=Sun, 24 Feb 2019 13:13:15 GMT; Domain=.ddprocessing.co.uk"},{"key":"Set-Cookie","value":"incap_ses_373_1416256=a; Max-Age=0; path=/; expires=Sun, 24 Feb 2019 13:13:15 GMT; Domain=.ddprocessing.co.uk"},{"key":"Set-Cookie","value":"incap_ses_454_1416256=a; Max-Age=0; path=/; expires=Sun, 24 Feb 2019 13:13:15 GMT; Domain=.ddprocessing.co.uk"},{"key":"Content-Length","value":"400"},{"key":"Status","value":"200 OK"},{"key":"X-XSS-Protection","value":"1; mode=block"},{"key":"Keep-Alive","value":"timeout=5, max=100"},{"key":"Connection","value":"Keep-Alive"},{"key":"Content-Type","value":"application/xml; charset=utf-8"},{"key":"X-Iinfo","value":"13-114222854-114392497 NNNN CT(3 7 0) RT(1551711491196 753886) q(0 0 0 -1) r(1 1) U5"},{"key":"X-CDN","value":"Incapsula"}],"cookie":[],"responseTime":null,"body":"<?xml version='1.0' encoding='UTF-8'?>\n<auddises results='1' total_results='1' start_index='0'>\n    <auddis summary='true' uri='https://sandbox.ddprocessing.co.uk/api/v1.1/auddis/81'>\n        <file_name>_DOWNLOADED_445566_AUDDIS_269836580.xml</file_name>\n        <report_generation_date>2019-03-04T00:00:00Z</report_generation_date>\n        <advices>1</advices>\n        <auddis_id>81</auddis_id>\n    </auddis>\n</auddises>"}],"_postman_id":"db62fb9b-fd63-4e21-bdd8-b7fa333189dd"}],"id":"4bb69dc2-f890-4ee7-a498-c808dc13d83d","description":"<h4 id=\"description\">Description</h4>\n<p><a href=\"#db62fb9b-fd63-4e21-bdd8-b7fa333189dd\">auddis/list</a> provides a paginated summary of all AUDDIS reports for a specified service user. By default the first 100 reports are returned. Reports are listed in reverse order, most recent first. Each AUDDIS file summary includes the URI to retrieve the full file.</p>\n<h4 id=\"usage\">Usage</h4>\n<p>This call must be made as a POST. If made as a GET the <em>uri</em> attribute is incorrect.</p>\n<p>Typically a client application would make this call once a day to list new reports.</p>\n<p>&lt;auddis_id&gt; values are not contiguous but always increase. To list reports once only, keep a record of the maximum &lt;auddis_id&gt; value. When making the call, add one to the maximum and use this as the <em>query[id_from]</em> parameter.</p>\n<p>Listing reports by date range can be unreliable.</p>\n<h4 id=\"response\">Response</h4>\n<p>A successful response from auddis/list is an XML list of AUDDIS file summaries. The root &lt;auddises&gt; tag includes the number of results returned, the start index for the results returned, and the total number of results.</p>\n<p>In the case that there are no AUDDIS files the root element is empty:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>200 OK\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt;&lt;auddises results='0' total_results='0' start_index='0'&gt;&lt;/auddises&gt;\n</code></pre><p>Note the single quotes in this response.</p>\n<h4 id=\"errors\">Errors</h4>\n<ul>\n<li><h6>Missing or invalid service user</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;No service user id supplied.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><br />\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Invalid Service User ID: 'su_pslid'&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<br />\n<li><h6>Invalid date value</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Unable to parse date 'tomorrow' expected format is YYYY-MM-DD&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<br />\n<li><h6>Value out of range</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Mysql::Error: #42000You have an error in your SQL syntax  [...]  &lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li></ul>","event":[{"listen":"prerequest","script":{"id":"98ff7fc0-9715-4f32-b92b-1159329154d0","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"3af3a085-3c84-4be0-a3a2-1f2f6783cf6f","type":"text/javascript","exec":[""]}}],"_postman_id":"4bb69dc2-f890-4ee7-a498-c808dc13d83d"},{"name":"4.8.2 Retrieve AUDDIS file","item":[{"name":"auddis/{{id}}","event":[{"listen":"test","script":{"id":"f304f9d0-01be-4c53-b0b4-476e956421d6","exec":["pm.test(\"Response time is less than 200ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(200);","});","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","","pm.test(\"Body matches string\", function () {","    //pm.expect(pm.response.text()).to.include('<?xml version=\\'1.0\\' encoding=\\'UTF-8\\'?>');","    ","    //var response = pm.response.text();","   // var pattern = /<auddiss results=\\'(\\d+)\\' total_results=\\'(\\d+)\\' start_index=\\'(\\d+)\\'>/g;","    ","    //pm.expect(pattern.test(response)).to.eql(true);","    pm.expect(pm.response.text()).to.include('<file_name>'+pm.environment.get('auddis_file_name')+'</file_name>'); //Mia_new_account_449165_AUDDIS_269836580.xml","    pm.expect(pm.response.text()).to.include('</auddis>');","});","","//pm.test(\"Body is correct\", function () {","//    pm.response.to.have.body(pm.environment.get(\"new_auddis_list_response\"));","//});","","pm.test('Schema is valid', function() {","  var jsonObject = xml2Json(pm.response.text());        ","  var jsonSchema =   sd.api.schema.auddisList;  ","    ","  pm.expect(tv4.validate(jsonObject, jsonSchema)).to.be.true;","  ","});","",""],"type":"text/javascript"}},{"listen":"prerequest","script":{"id":"f07b83ad-4f3e-4dbe-9bf5-1bb15403ead1","exec":["pm.sendRequest(\"https://sandbox.smartdebit.co.uk/Scripts/smartdebit.jasmine.js\", (err, res) => { pm.globals.set('jasmine' ,res.text() ) });","","eval(pm.globals.get('jasmine'));","","var authHash = btoa(pm.environment.get('api_user') + \":\" + pm.environment.get('api_user_password'));","","console.log(authHash);","","var dataGen = sd.testing;","","//var postData = {};","var query = {};","query.service_user = {};","query.service_user.pslid = pm.environment.get('pslid');","","","var postFormData = dataGen.json2formData(query, 'query');","","console.log(postFormData);","","const postDataRequest = {","  url: pm.environment.get('base_url') + '/auddis/list',","  method: 'POST',","  header: `Authorization:Basic ${authHash}`,","  body: {","    mode: 'formdata',","    formdata: postFormData","  }","};","","pm.sendRequest(postDataRequest, function (err, res) {","  console.log('RESPONSE START');","  console.log(res.text());","  console.log('RESPONSE END');","  ","  var jsonObject = xml2Json(res.text());","  ","  pm.environment.set('auddis_file_id',jsonObject.auddises.auddis.auddis_id);","  pm.environment.set('auddis_file_name', jsonObject.auddises.auddis.file_name);","});"],"type":"text/javascript"}}],"id":"d45bab5f-a369-4abb-ab1d-31d838621655","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"GET","header":[],"url":"{{base_url}}/auddis/{{auddis_file_id}}","urlObject":{"path":["auddis","{{auddis_file_id}}"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"3344ece5-85e2-4c79-8857-124b22969abd","name":"auddis file","originalRequest":{"method":"GET","header":[],"body":{"mode":"formdata","formdata":[{"description":"<b>Format: plain text<br />Restrictions: 5 to 255 characters, must match existing SU's pslid</b>","key":"query[service_user][pslid]","type":"text","value":"{{pslid}}"},{"description":"<b>Format: integer Restrictions: 1 to 1000<br/>Default: 100</b>","key":"query[max_results]","type":"text","value":""},{"description":"<b>Format: integer<br />Restrictions: 0 or greater<br/>Default: 0</b>","key":"query[start_index]","type":"text","value":""},{"description":"<b>Format: integer<br />Restrictions: 0 or greater</b>","key":"query[id_from]","type":"text","value":""},{"description":"<b>Format: date YYYY-MM-DD</b>","key":"query[from_date]","type":"text","value":""},{"description":"<b>Format: date YYYY-MM-DD</b>","key":"query[till_date]","type":"text","value":""}]},"url":{"raw":"{{base_url}}/auddis/{{auddis_file_id}}","host":["{{base_url}}"],"path":["auddis","{{auddis_file_id}}"],"query":[{"key":"file_id","type":"text","value":"{{auddis_file_id}}","disabled":true}]}},"status":"OK","code":200,"_postman_previewlanguage":"xml","header":[{"key":"Date","value":"Mon, 04 Mar 2019 15:11:19 GMT"},{"key":"Server","value":"Apache"},{"key":"Cache-Control","value":"private, max-age=0, must-revalidate"},{"key":"X-Runtime","value":"0.05223"},{"key":"Strict-Transport-Security","value":"max-age=63072000; includeSubdomains; preload"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Set-Cookie","value":"auth_token=; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"_PSLLite_session_id=59c10b241683faff8f68dab95c0ecf7c; path=/; HttpOnly; secure"},{"key":"Content-Length","value":"1303"},{"key":"Status","value":"200 OK"},{"key":"X-XSS-Protection","value":"1; mode=block"},{"key":"Keep-Alive","value":"timeout=5, max=99"},{"key":"Connection","value":"Keep-Alive"},{"key":"Content-Type","value":"application/xml; charset=utf-8"},{"key":"X-Iinfo","value":"13-114222854-114420341 SNNN RT(1551711491196 866658) q(0 0 0 -1) r(1 1) U5"},{"key":"X-CDN","value":"Incapsula"}],"cookie":[],"responseTime":null,"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<auddis uri=\"https://sandbox.ddprocessing.co.uk/api/v1.1/auddis/81\">\n    <file_name>_DOWNLOADED_445566_AUDDIS_269836580.xml</file_name>\n    <report_generation_date>2019-03-04T00:00:00Z</report_generation_date>\n    <advices>1</advices>\n    <file>PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPEJBQ1NE\nb2N1bWVudD4KICA8RGF0YT4KICAgIDxNZXNzYWdpbmdBZHZpY2VzPgogICAg\nICA8SGVhZGVyIGRvY3VtZW50LW51bWJlcj0iMCIgc3ViamVjdC1maXJzdC1h\nb3NuPSIwMDEwMTQ3NCIgc3ViamVjdC1sYXN0LWFvc249IjAwMTAxNDc0IiB1\nc2VyLW51bWJlcj0iNTAwMDE3IiBhZHZpY2UtdHlwZT0iQVVERElTIiByZXBv\ncnQtZ2VuZXJhdGlvbi1kYXRlPSIyMDE5LTAzLTA0IiB1c2VyLW5hbWU9IkFQ\nSSBEb2N1bWVudGF0aW9uIiByZXBvcnQtdHlwZT0iNzAwMiIgc3RyZWFtLWlk\nZW50aWZpZXI9IjAiIGVudmVsb3BlLXNlcXVlbmNlLW51bWJlcj0iMDAwMDA1\nMTciPgogICAgICA8L0hlYWRlcj4KICAgICAgPEFkZHJlc3NlZUluZm9ybWF0\naW9uPgogICAgICA8L0FkZHJlc3NlZUluZm9ybWF0aW9uPgogICAgICA8TWVz\nc2FnaW5nQWR2aWNlIHBheWVyLW5ldy1zb3J0LWNvZGU9IioqKioqKiIgcmVm\nZXJlbmNlPSJTRDExOTAxMjIxMjE3MjI4MzIiIHBheWVyLW5hbWU9Ik1pYSIg\ncGF5ZXItYWNjb3VudC1udW1iZXI9IioqKiowMDciIGVmZmVjdGl2ZS1kYXRl\nPSIyMDE5LTAzLTA2IiBwYXllci1zb3J0LWNvZGU9IioqKioqKiIgcmVhc29u\nLWNvZGU9IjYiIHBheWVyLW5ldy1hY2NvdW50LW51bWJlcj0iKioqKjAwOCIg\nYW9zbj0iMTAxNDc0Ii8+CiAgICA8L01lc3NhZ2luZ0FkdmljZXM+CiAgPC9E\nYXRhPgo8L0JBQ1NEb2N1bWVudD4K\n</file>\n</auddis>"}],"_postman_id":"d45bab5f-a369-4abb-ab1d-31d838621655"}],"id":"81d043f2-55ef-42cd-a32a-e2f06bc843bc","description":"<h4 id=\"description\">Description</h4>\n<p>Individual AUDDIS files can be retrieved from the SmartDebit API in XML format. The files are returned as base64 encoded strings.</p>\n<h4 id=\"response\">Response</h4>\n<p>The example response shows the base64 encoded file within the file node.</p>\n<p>The XML version of the AUDDIS file is a filtered version of the original Bacs file. In the case that the referenced DDI has a Customer Id in SmartDebit the Customer Id is included in the MessagingAdvice as the payer-reference attribute.</p>\n<p>An XML AUDDIS file consists of a Header, an AddresseeInformation and a number of MessagingAdvice tags within a  BACSDocument &gt; Data &gt; MessagingAdvices wrapper. The data formats in the AUDDIS file are preserved – dates are presented in the format YYYY-MM-DD. </p>\n<p>The Header tag can contain the following attributes:</p>\n<ul>\n<li>document-number</li>\n<li>advice-type (which may take the value \"AUDDIS\" or \"AUDACC\")</li>\n<li>subject-first-aosn (the serial number of the first advice in the report)</li>\n<li>subject-last-aosn (the serial number of the last advice in the report)</li>\n<li>user-number (the service user's SUN)</li>\n<li>stream-identifier </li>\n<li>envelope-sequence-number </li>\n<li>report-generation-date </li>\n<li>user-name (the service user's bank account name)</li>\n<li>report-type (which may take the value \"7002\" or \"7003\")</li>\n</ul>\n<p>The AddresseeInformation tag is usually empty but can contain the following attributes: </p>\n<ul>\n<li>name</li>\n<li>address1</li>\n<li>address2</li>\n<li>address3</li>\n<li>address4</li>\n<li>address5</li>\n</ul>\n<p>The MessagingAdvice tag can contain the following attributes:</p>\n<ul>\n<li>reference (the reference number of the DDI)</li>\n<li>payer-reference (the Customer Id of the payer)</li>\n<li>user-number (the service user's SUN)</li>\n<li>record-type</li>\n<li>effective-date</li>\n<li>payer-name</li>\n<li>payer-sort-code</li>\n<li>payer-account-number</li>\n<li>payer-new-sort-code</li>\n<li>payer-new-account-number</li>\n<li>reason-code (refer to the <a href=\"#4855180e-d792-4547-bf87-667881b138bb\">list of reason codes</a>)</li>\n<li>aosn (the serial number of the advice)</li>\n</ul>\n<p>Depending on the service user configuration, account details may be obscured.</p>\n<p>An example XML AUDDIS file, including payer-reference, would look like: </p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?XML version=\"1.0\" encoding=\"UTF-8\"?&gt;\n  &lt;BACSDocument&gt;\n    &lt;Data&gt;\n      &lt;MessagingAdvices&gt;\n        &lt;Header advice-type=\"AUDDIS\" document-number=\"0\" report-generation-date=\"2019-03-28\" subject-last-aosn=\"00000020\" user-name=\"SERVICE USER LTD\" user-number=\"250050\" report-type=\"7002\" subject-first-aosn=\"00000020\" stream-identifier=\"0\" envelope-sequence-number=\"00000008\"&gt;\n        &lt;/Header&gt;\n        &lt;AddresseeInformation&gt;\n        &lt;/AddresseeInformation&gt;\n        &lt;MessagingAdvice reason-code=\"B\" reference=\"ABC1234567\" payer-reference=\"65880\" aosn=\"20\" effective-date=\"2019-03-27\" payer-account-number=\"12345678\" payer-name=\"R SMITH\" payer-sort-code=\"000000\"/&gt;\n      &lt;/MessagingAdvices&gt;\n    &lt;/Data&gt;\n  &lt;/BACSDocument&gt; \n</code></pre><h4 id=\"errors\">Errors</h4>\n<p>Errors can be avoided by retrieving only reports listed by <a href=\"#db62fb9b-fd63-4e21-bdd8-b7fa333189dd\">auddis/list</a>.</p>\n<ul>\n<li><h6>If the report cannot be found:</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Couldn't find AddacsImport with ID=1235545&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<br />\n<li><h6>If no report has been specified - {{base_url}}/auddis/</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Couldn't find AddacsImport without an ID&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<br />\n<li><h6>If you do not have permission to view the report:</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Permission Denied.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n</ul>","event":[{"listen":"prerequest","script":{"id":"2ac20792-6019-4ae8-a8d2-b86f4f182b7a","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"d1628307-95b7-4e55-9e97-ef62ef76e04f","type":"text/javascript","exec":[""]}}],"_postman_id":"81d043f2-55ef-42cd-a32a-e2f06bc843bc"},{"name":"4.8.3 List ADDACS","item":[{"name":"addac/list","event":[{"listen":"test","script":{"id":"c3275e63-138a-48ee-91a0-284442eac16b","exec":["eval(pm.globals.get('jasmine'));","","pm.test(\"Response time is less than 300ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(300);","});","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","","pm.test(\"Body matches string\", function () {","    pm.expect(pm.response.text()).to.include('<?xml version=\\'1.0\\' encoding=\\'UTF-8\\'?>');","    ","    var response = pm.response.text();","    var pattern = /<addacs results=\\'(\\d+)\\' total_results=\\'(\\d+)\\' start_index=\\'(\\d+)\\'>/g;","    ","    pm.expect(pattern.test(response)).to.eql(true);","    pm.expect(pm.response.text()).to.include('</addacs>');","});","","","pm.test('Schema is valid', function() {","  var jsonObject = xml2Json(pm.response.text());        ","  var jsonSchema =   sd.api.schema.addacsList;  ","    ","  pm.expect(tv4.validate(jsonObject, jsonSchema)).to.be.true;","  ","});","","pm.globals.unset(\"new_addac_list_response\");","","var regEx = new RegExp('<addac_id>([0-9]+)<\\/addac_id>', 'gm');","var knownAddacsId = regEx.exec(responseBody)[1];","pm.globals.set(\"known_addacs_id\", knownAddacsId);",""],"type":"text/javascript"}}],"id":"cfbd051c-2c14-4102-830e-539c096a6554","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"key":"query[service_user][pslid]","value":"{{pslid}}","type":"text","description":"<p><i>Required</i><br />\nService user identifier</p>\n"},{"key":"query[max_results]","value":"{{max_results}}","description":"<p><b>Format:</b> integer, 1 to 1000<br /><b>Default:</b> 100</p>\n","type":"text"},{"key":"query[start_index]","value":"{{start_index}}","description":"<p><b>Format:</b> integer<br /><b>Default:</b> 0</p>\n","type":"text"},{"key":"query[id_from]","value":"{{id_from}}","description":"<p><b>Format:</b> integer</p>\n","type":"text"},{"key":"query[from_date]","value":"{{from_date}}","description":"<p><i>Conditional (required if till_date is used)</i><br /><b>Format:</b> YYYY-MM-DD</p>\n","type":"text"},{"key":"query[till_date]","value":"{{till_date}}","description":"<p><b>Format:</b> YYYY-MM-DD</p>\n","type":"text"}]},"url":"{{base_url}}/addac/list","urlObject":{"path":["addac","list"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"94f17664-a07b-4190-9d41-80fe9f445a03","name":"addac/list ","originalRequest":{"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"key":"query[service_user][pslid]","value":"{{pslid}}","type":"text","description":"<b>Format: plain text<br />Restrictions: 5 to 255 characters, must match existing SU's pslid</b>"},{"key":"query[max_results]","value":"","description":"<b>Format: integer Restrictions: 1 to 1000<br/>Default: 100</b>","type":"text"},{"key":"query[start_index]","value":"","description":"<b>Format: integer<br />Restrictions: 0 or greater<br/>Default: 0</b>","type":"text"},{"key":"query[id_from]","value":"","description":"<b>Format: integer<br />Restrictions: 0 or greater</b>","type":"text"},{"key":"query[from_date]","value":"","description":"<b>Format: date YYYY-MM-DD</b>","type":"text"},{"key":"query[till_date]","value":"","description":"<b>Format: date YYYY-MM-DD</b>","type":"text"}]},"url":"{{base_url}}/addac/list"},"status":"OK","code":200,"_postman_previewlanguage":"xml","header":[{"key":"Date","value":"Mon, 04 Mar 2019 15:38:30 GMT"},{"key":"Server","value":"Apache"},{"key":"Cache-Control","value":"private, max-age=0, must-revalidate"},{"key":"X-Runtime","value":"0.05625"},{"key":"Strict-Transport-Security","value":"max-age=63072000; includeSubdomains; preload"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Set-Cookie","value":"auth_token=; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"_PSLLite_session_id=59c10b241683faff8f68dab95c0ecf7c; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"incap_ses_874_1416256=a; Max-Age=0; path=/; expires=Sun, 24 Feb 2019 13:13:15 GMT; Domain=.ddprocessing.co.uk"},{"key":"Set-Cookie","value":"incap_ses_373_1416256=a; Max-Age=0; path=/; expires=Sun, 24 Feb 2019 13:13:15 GMT; Domain=.ddprocessing.co.uk"},{"key":"Set-Cookie","value":"incap_ses_454_1416256=a; Max-Age=0; path=/; expires=Sun, 24 Feb 2019 13:13:15 GMT; Domain=.ddprocessing.co.uk"},{"key":"Set-Cookie","value":"incap_ses_368_1416256=zjPdSZUVIWco047loWYbBcRGfVwAAAAA8ctqWNQ+gM0AoFAfTlLW5w==; path=/; Domain=.ddprocessing.co.uk"},{"key":"Set-Cookie","value":"___utmvmoNuBZVNB=PshzlbKfAIo; path=/; Max-Age=900"},{"key":"Set-Cookie","value":"___utmvaoNuBZVNB=wuT\u0001kadd; path=/; Max-Age=900"},{"key":"Set-Cookie","value":"___utmvboNuBZVNB=mZJ    XQeOqalE: GtJ; path=/; Max-Age=900"},{"key":"Content-Length","value":"395"},{"key":"Status","value":"200 OK"},{"key":"X-XSS-Protection","value":"1; mode=block"},{"key":"Keep-Alive","value":"timeout=5, max=100"},{"key":"Connection","value":"Keep-Alive"},{"key":"Content-Type","value":"application/xml; charset=utf-8"},{"key":"X-Iinfo","value":"2-31315336-31315338 NNNN CT(2 10 0) RT(1551713988376 24) q(0 1 1 1) r(2 2) U5"},{"key":"X-CDN","value":"Incapsula"}],"cookie":[],"responseTime":null,"body":"<?xml version='1.0' encoding='UTF-8'?>\n<addacs results='1' total_results='1' start_index='0'>\n    <addac summary='true' uri='https://sandbox.ddprocessing.co.uk/api/v1.1/addac/82'>\n        <file_name>_DOWNLOADED_445566_ADDACS_269843831.xml</file_name>\n        <report_generation_date>2019-03-04T00:00:00Z</report_generation_date>\n        <advices>1</advices>\n        <addac_id>82</addac_id>\n    </addac>\n</addacs>"}],"_postman_id":"cfbd051c-2c14-4102-830e-539c096a6554"}],"id":"e55ab879-f272-48da-93b5-ef8922d9848a","description":"<h4 id=\"description\">Description</h4>\n<p><a href=\"#cfbd051c-2c14-4102-830e-539c096a6554\">addac/list</a> provides a paginated summary of all ADDACS reports for a specified service user. By default the first 100 reports are returned. Reports are listed in reverse order, most recent first. Each ADDACS file summary includes the URI to retrieve the full file.</p>\n<h4 id=\"usage\">Usage</h4>\n<p>This call must be made as a POST. If made as a GET the <em>uri</em> attribute is incorrect.</p>\n<p>Typically a client application would make this call once a day to list new reports.</p>\n<p>&lt;addac_id&gt; values are not contiguous but always increase. To list reports once only, keep a record of the maximum &lt;addac_id&gt; value. When making the call, add one to the maximum and use this as the <em>query[id_from]</em> parameter.</p>\n<p>Listing reports by date range can be unreliable.</p>\n<h4 id=\"response\">Response</h4>\n<p>A successful response from addac/list is an XML list of ADDACS file summaries. The root &lt;addacs&gt; tag includes the number of results returned, the start index for the results returned, and the total number of results.</p>\n<p>In the case that there are no ADDACS files the root element is empty:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>200 OK\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt;&lt;addacs results='0' total_results='0' start_index='0'&gt;&lt;/addacs&gt;\n</code></pre><p>Note the single quotes in this response.</p>\n<h4 id=\"errors\">Errors</h4>\n<ul>\n<li><h6>Missing or invalid service user</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;No service user id supplied.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><br />\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Invalid Service User ID: 'su_pslid'&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<br />\n<li><h6>Invalid date value</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Unable to parse date 'tomorrow' expected format is YYYY-MM-DD&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<br />\n<li><h6>Value out of range</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Mysql::Error: #42000You have an error in your SQL syntax  [...]  &lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li></ul>","event":[{"listen":"prerequest","script":{"id":"f726fae6-bed5-4726-9092-3df20090b18b","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"4147ea0c-1f80-47d9-90f5-d01b5fc20290","type":"text/javascript","exec":[""]}}],"_postman_id":"e55ab879-f272-48da-93b5-ef8922d9848a"},{"name":"4.8.4 Retrieve ADDACS file","item":[{"name":"addac/{{id}}","event":[{"listen":"test","script":{"id":"30e9deb0-1b3d-47eb-bb50-3cc513d4053d","exec":["pm.test(\"Response time is less than 300ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(300);","});","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","","pm.test(\"Body matches string\", function () {","    pm.expect(pm.response.text()).to.include('<?xml version=\"1.0\" encoding=\"UTF-8\"?>');","    pm.expect(pm.response.text()).to.include('<file_name>'+ pm.environment.get('addac_file_name') +'</file_name>');","    ","    var response = pm.response.text();","    //var pattern = /<addacs results=\\'(\\d+)\\' total_results=\\'(\\d+)\\' start_index=\\'(\\d+)\\'>/g;","    ","    //pm.expect(pattern.test(response)).to.eql(true);","    pm.expect(pm.response.text()).to.include('</addac>');","});","","pm.test(\"Body is correct\", function () {","    pm.response.to.have.body(pm.environment.get(\"new_addac_list_response\"));","});","","pm.globals.unset(\"new_addac_list_response\");"],"type":"text/javascript"}},{"listen":"prerequest","script":{"id":"5e2508d8-083b-4e45-acb1-83525fc7dfca","exec":["pm.sendRequest(\"https://sandbox.smartdebit.co.uk/Scripts/smartdebit.jasmine.js\", (err, res) => { pm.globals.set('jasmine' ,res.text() ) });","","eval(pm.globals.get('jasmine'));","","var authHash = btoa(pm.environment.get('api_user') + \":\" + pm.environment.get('api_user_password'));","","console.log(authHash);","","var dataGen = sd.testing;","","//var postData = {};","var query = {};","query.service_user = {};","query.service_user.pslid = pm.environment.get('pslid');","","","var postFormData = dataGen.json2formData(query, 'query');","","console.log(postFormData);","","const postDataRequest = {","  url: pm.environment.get('base_url') + '/addac/list',","  method: 'POST',","  header: `Authorization:Basic ${authHash}`,","  body: {","    mode: 'formdata',","    formdata: postFormData","  }","};","","pm.sendRequest(postDataRequest, function (err, res) {","  console.log('RESPONSE START');","  console.log(res.text());","  console.log('RESPONSE END');","  ","  var jsonObject = xml2Json(res.text());","  ","  pm.environment.set('addac_file_id',jsonObject.addacs.addac.addac_id);","  pm.environment.set('addac_file_name', jsonObject.addacs.addac.file_name);","});"],"type":"text/javascript"}}],"id":"335a37fe-7b74-41e2-be69-7b25f1050b75","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"GET","header":[],"url":"{{base_url}}/addac/{{addac_file_id}}","urlObject":{"path":["addac","{{addac_file_id}}"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"db086b29-9df8-4417-a3da-c238ab5bc617","name":"addac file","originalRequest":{"method":"GET","header":[],"url":"{{base_url}}/addac/{{addac_file_id}}"},"status":"OK","code":200,"_postman_previewlanguage":"xml","header":[{"key":"Date","value":"Mon, 04 Mar 2019 16:17:19 GMT"},{"key":"Server","value":"Apache"},{"key":"Cache-Control","value":"private, max-age=0, must-revalidate"},{"key":"X-Runtime","value":"0.05340"},{"key":"Strict-Transport-Security","value":"max-age=63072000; includeSubdomains; preload"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Set-Cookie","value":"auth_token=; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"_PSLLite_session_id=59c10b241683faff8f68dab95c0ecf7c; path=/; HttpOnly; secure"},{"key":"Content-Length","value":"1219"},{"key":"Status","value":"200 OK"},{"key":"X-XSS-Protection","value":"1; mode=block"},{"key":"Keep-Alive","value":"timeout=5, max=99"},{"key":"Connection","value":"Keep-Alive"},{"key":"Content-Type","value":"application/xml; charset=utf-8"},{"key":"X-Iinfo","value":"8-7847393-7852469 SNNN RT(1551715975677 342231) q(0 0 0 -1) r(0 0) U5"},{"key":"X-CDN","value":"Incapsula"}],"cookie":[],"responseTime":null,"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<addac uri=\"https://sandbox.ddprocessing.co.uk/api/v1.1/addac/82\">\n    <file_name>_DOWNLOADED_445566_ADDACS_269778437.xml</file_name>\n    <report_generation_date>2019-03-04T00:00:00Z</report_generation_date>\n    <advices>1</advices>\n    <file>PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPEJBQ1NE\nb2N1bWVudD4KICA8RGF0YT4KICAgIDxNZXNzYWdpbmdBZHZpY2VzPgogICAg\nICA8SGVhZGVyIGRvY3VtZW50LW51bWJlcj0iMCIgc3ViamVjdC1maXJzdC1h\nb3NuPSIwMDEwNDI2MSIgc3ViamVjdC1sYXN0LWFvc249IjAwMTA0MjYxIiB1\nc2VyLW51bWJlcj0iNTAwMDE3IiBhZHZpY2UtdHlwZT0iQUREQUNTIiByZXBv\ncnQtZ2VuZXJhdGlvbi1kYXRlPSIyMDE5LTAzLTA0IiB1c2VyLW5hbWU9IkFQ\nSSBEb2N1bWVudGF0aW9uIiByZXBvcnQtdHlwZT0iNzAwMSIgc3RyZWFtLWlk\nZW50aWZpZXI9IjAiIGVudmVsb3BlLXNlcXVlbmNlLW51bWJlcj0iMDAwMDEx\nMzIiPgogICAgICA8L0hlYWRlcj4KICAgICAgPEFkZHJlc3NlZUluZm9ybWF0\naW9uPgogICAgICA8L0FkZHJlc3NlZUluZm9ybWF0aW9uPgogICAgICA8TWVz\nc2FnaW5nQWR2aWNlIHJlZmVyZW5jZT0iU0QxMTkwMTIyMTIxNzIyODMyIiBw\nYXllci1uYW1lPSJNaWEiIHBheWVyLWFjY291bnQtbnVtYmVyPSIqKioqMDAw\nNyIgZWZmZWN0aXZlLWRhdGU9IjIwMTktMDMtMDQiIHBheWVyLXNvcnQtY29k\nZT0iKioqKioqIiByZWFzb24tY29kZT0iMCIgYW9zbj0iMTA0MjYxIi8+CiAg\nICA8L01lc3NhZ2luZ0FkdmljZXM+CiAgPC9EYXRhPgo8L0JBQ1NEb2N1bWVu\ndD4K\n</file>\n</addac>"}],"_postman_id":"335a37fe-7b74-41e2-be69-7b25f1050b75"}],"id":"1b98a12a-365d-478b-9735-ce98f56fb437","description":"<h4 id=\"description\">Description</h4>\n<p>Individual ADDACS files can be retrieved from the SmartDebit API in XML format. The files are returned as base64 encoded strings.</p>\n<h4 id=\"response\">Response</h4>\n<p>The example response shows the base64 encoded file within the file node.</p>\n<p>The XML version of the ADDACS file is a filtered version of the original Bacs file. In the case that the referenced DDI has a Customer Id in SmartDebit the Customer Id is included in the MessagingAdvice as the payer-reference attribute.</p>\n<p>An XML ADDACS file consists of a Header, an AddresseeInformation and a number of MessagingAdvice tags within a  BACSDocument &gt; Data &gt; MessagingAdvices wrapper. The data formats in the ADDACS file are preserved – dates are presented in the format YYYY-MM-DD. </p>\n<p>The Header tag can contain the following attributes:</p>\n<ul>\n<li>document-number</li>\n<li>advice-type (which takes the value \"ADDACS\")</li>\n<li>subject-first-aosn (the serial number of the first advice in the report)</li>\n<li>subject-last-aosn (the serial number of the last advice in the report)</li>\n<li>user-number (the service user's SUN)</li>\n<li>stream-identifier </li>\n<li>envelope-sequence-number </li>\n<li>report-generation-date </li>\n<li>user-name (the service user's bank account name)</li>\n<li>report-type (which takes the value \"7001\")</li>\n</ul>\n<p>The AddresseeInformation tag is usually empty but can contain the following attributes: </p>\n<ul>\n<li>name</li>\n<li>address1</li>\n<li>address2</li>\n<li>address3</li>\n<li>address4</li>\n<li>address5</li>\n</ul>\n<p>The MessagingAdvice tag can contain the following attributes:</p>\n<ul>\n<li>reference (the reference number of the DDI or the last-used collection reference)</li>\n<li>payer-reference (the Customer Id of the payer)</li>\n<li>reason-code (refer to the <a href=\"#4855180e-d792-4547-bf87-667881b138bb\">list of reason codes</a>)</li>\n<li>user-number (the service user's SUN)</li>\n<li>record-type</li>\n<li>effective-date</li>\n<li>payer-name</li>\n<li>payer-sort-code</li>\n<li>payer-account-number</li>\n<li>payer-new-sort-code</li>\n<li>payer-new-account-number</li>\n<li>payer-new-name</li>\n<li>aosn (the serial number of the advice)</li>\n</ul>\n<p>Depending on the service user configuration, account details may be obscured.</p>\n<p>An example XML ADDACS file, including payer-reference, would look like: </p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?XML version=\"1.0\" encoding=\"UTF-8\"?&gt;\n  &lt;BACSDocument&gt;\n    &lt;Data&gt;\n      &lt;MessagingAdvices&gt;\n        &lt;Header advice-type=\"ADDACS\" document-number=\"0\" report-generation-date=\"2019-03-28\" subject-last-aosn=\"00000020\" user-name=\"SERVICE USER LTD\" user-number=\"250050\" report-type=\"7001\" subject-first-aosn=\"00000020\" stream-identifier=\"0\" envelope-sequence-number=\"00000008\"&gt;\n        &lt;/Header&gt;\n        &lt;AddresseeInformation&gt;\n        &lt;/AddresseeInformation&gt;\n        &lt;MessagingAdvice reason-code=\"B\" reference=\"ABC1234567\" payer-reference=\"65880\" aosn=\"20\" effective-date=\"2019-03-28\" payer-account-number=\"12345678\" payer-name=\"R SMITH\" payer-sort-code=\"000000\"/&gt;\n      &lt;/MessagingAdvices&gt;\n    &lt;/Data&gt;\n  &lt;/BACSDocument&gt; \n</code></pre><h4 id=\"errors\">Errors</h4>\n<p>Errors can be avoided by retrieving only reports listed by <a href=\"#cfbd051c-2c14-4102-830e-539c096a6554\">addac/list</a>.</p>\n<ul>\n<li><h6>If the report cannot be found:</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Couldn't find AddacsImport with ID=1235545&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<br />\n<li><h6>If no report has been specified - {{base_url}}/addac/</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Couldn't find AddacsImport without an ID&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<br />\n<li><h6>If you do not have permission to view the report:</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Permission Denied.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n</ul>","event":[{"listen":"prerequest","script":{"id":"d65269fa-f1dd-4e00-805a-c384e3d707d0","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"6afe1571-1189-4e88-986a-6c938c19c277","type":"text/javascript","exec":[""]}}],"_postman_id":"1b98a12a-365d-478b-9735-ce98f56fb437"},{"name":"4.8.5 List ARUDD files","item":[{"name":"arudd/list","event":[{"listen":"test","script":{"id":"b96004a1-4227-4d35-a14f-d35afba43b44","exec":["eval(pm.globals.get('jasmine'));","","pm.test(\"Response time is less than 300ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(300);","});","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","","pm.test(\"Body matches string\", function () {","    pm.expect(pm.response.text()).to.include(\"<?xml version='1.0' encoding='UTF-8'?>\");","    ","    var response = pm.response.text();","","    pm.expect(pm.response.text()).to.include('</arudd>');","    pm.expect(pm.response.text()).to.include('</arudds>');","});","","pm.test('Schema is valid', function() {","  var jsonObject = xml2Json(pm.response.text());        ","  var jsonSchema =   sd.api.schema.aruddList;  ","    ","  pm.expect(tv4.validate(jsonObject, jsonSchema)).to.be.true;","  ","});"],"type":"text/javascript"}}],"id":"b0d4815e-100f-4779-ba39-57be75466244","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"key":"query[service_user][pslid]","value":"{{pslid}}","type":"text","description":"<p><i>Required</i><br />\nService user identifier</p>\n"},{"key":"query[max_results]","value":"{{max_results}}","type":"text","description":"<p><b>Format:</b> integer, 1 to 1000<br /><b>Default:</b> 100</p>\n"},{"key":"query[start_index]","value":"{{start_index}}","type":"text","description":"<p><b>Format:</b> integer<br /><b>Default:</b> 0</p>\n"},{"key":"query[id_from]","value":"{{id_from}}","type":"text","description":"<p><b>Format:</b> integer</p>\n"},{"key":"query[from_date]","value":"{{from_date}}","type":"text","description":"<p><i>Conditional (required if till_date is used)</i><br /><b>Format:</b> YYYY-MM-DD</p>\n"},{"key":"query[till_date]","value":"{{till_date}}","type":"text","description":"<p><b>Format:</b> YYYY-MM-DD</p>\n"}]},"url":"{{base_url}}/arudd/list","urlObject":{"path":["arudd","list"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"748857b6-0609-4f08-923a-c0f5d98f1e0c","name":"arudd/list","originalRequest":{"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"key":"query[service_user][pslid]","value":"{{pslid}}","type":"text","description":"<i>Required</i><br>\nService user identifier"},{"key":"query[max_results]","value":"{{max_results}}","type":"text","description":"<b>Format:</b> integer, 1 to 1000<br><b>Default:</b> 100"},{"key":"query[start_index]","value":"{{start_index}}","type":"text","description":"<b>Format:</b> integer<br><b>Default:</b> 0"},{"key":"query[id_from]","value":"{{id_from}}","type":"text","description":"<b>Format:</b> integer"},{"key":"query[from_date]","value":"{{from_date}}","type":"text","description":"<i>Conditional (required if till_date is used)</i><br><b>Format:</b> YYYY-MM-DD"},{"key":"query[till_date]","value":"{{till_date}}","type":"text","description":"<b>Format:</b> YYYY-MM-DD"}]},"url":"{{base_url}}/arudd/list"},"status":"OK","code":200,"_postman_previewlanguage":"xml","header":null,"cookie":[],"responseTime":null,"body":"<?xml version='1.0' encoding='UTF-8'?><arudds results='2' total_results='2' start_index='0'>\n<arudd summary='true' uri='https://sandbox.ddprocessing.co.uk/api/v1.1/arudd/33'>\n    <file_name>_DOWNLOADED_445566_ARUDD_280646574.xml</file_name>\n    <current_processing_date>2019-03-20T00:00:00Z</current_processing_date>\n    <report_type>REFT1019</report_type>\n    <advice_number>999</advice_number>\n    <arudd_id>33</arudd_id>\n    <failed_debits>3</failed_debits>\n    <failed_debits_value>15184</failed_debits_value>\n  </arudd><arudd summary='true' uri='https://sandbox.ddprocessing.co.uk/api/v1.1/arudd/28'>\n    <file_name>_DOWNLOADED_445566_ARUDD_280540919.xml</file_name>\n    <current_processing_date>2019-03-19T00:00:00Z</current_processing_date>\n    <report_type>REFT1019</report_type>\n    <advice_number>999</advice_number>\n    <arudd_id>28</arudd_id>\n    <failed_debits>4</failed_debits>\n    <failed_debits_value>33960</failed_debits_value>\n  </arudd></arudds>"}],"_postman_id":"b0d4815e-100f-4779-ba39-57be75466244"}],"id":"50da72c5-432c-4e3f-9640-22be989fee95","description":"<h4 id=\"description\">Description</h4>\n<p><a href=\"#b0d4815e-100f-4779-ba39-57be75466244\">arudd/list</a> provides a paginated summary of all ARUDD reports for a specified service user. By default the first 100 reports are returned. Reports are listed in reverse order, most recent first. Each ARUDD file summary includes the URI to retrieve the full file.</p>\n<h4 id=\"usage\">Usage</h4>\n<p>This call must be made as a POST. If made as a GET the <em>uri</em> attribute is incorrect.</p>\n<p>Typically a client application would make this call once a day to list new reports.</p>\n<p>&lt;arudd_id&gt; values are not contiguous but always increase. To list reports once only, keep a record of the maximum &lt;arudd_id&gt; value. When making the call, add one to the maximum and use this as the <em>query[id_from]</em> parameter.</p>\n<p>Listing reports by date range can be unreliable.</p>\n<h4 id=\"response\">Response</h4>\n<p>A successful response from arudd/list is an XML list of ARUDD file summaries. The root &lt;arudds&gt; tag includes the number of results returned, the start index for the results returned, and the total number of results.</p>\n<p>In the case that there are no ARUDD files the root element is empty:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>200 OK\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt;&lt;arudds results='0' total_results='0' start_index='0'&gt;\n&lt;/arudds&gt;\n</code></pre><p>Note the single quotes in this response.</p>\n<h4 id=\"errors\">Errors</h4>\n<ul>\n<li><h6>Missing or invalid service user</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;No service user id supplied.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><br />\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Invalid Service User ID: 'su_pslid'&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<br />\n<li><h6>Invalid date value</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Unable to parse date 'tomorrow' expected format is YYYY-MM-DD&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<br />\n<li><h6>Value out of range</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Mysql::Error: #42000You have an error in your SQL syntax  [...]  &lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li></ul>","event":[{"listen":"prerequest","script":{"id":"dffdd5bf-b393-411f-8514-6c61a0744de4","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"25956be1-d4e6-4bc5-827e-2c73766ee08a","type":"text/javascript","exec":[""]}}],"_postman_id":"50da72c5-432c-4e3f-9640-22be989fee95"},{"name":"4.8.6 Retrieve ARUDD file","item":[{"name":"arudd/{{id}}","event":[{"listen":"test","script":{"id":"68e9b89b-34a9-4ac1-ae1b-f298c0b834fb","exec":["pm.test(\"Response time is less than 300ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(300);","});","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","","pm.test(\"Body matches string\", function () {","    pm.expect(pm.response.text()).to.include('<?xml version=\"1.0\" encoding=\"UTF-8\"?>'); //Pay attention on different reports the XML uses single quotes and on others uses double quotes","    ","    var response = pm.response.text();","    ","    //var pattern = /<arudds results=\\'(\\d+)\\' total_results=\\'(\\d+)\\' start_index=\\'(\\d+)\\'>/g;","    ","    //pm.expect(pattern.test(response)).to.eql(true);","    //pm.expect(pm.response.text()).to.include('</arudds>');","});","","","//MISSING SCHEMA CHECK"],"type":"text/javascript"}},{"listen":"prerequest","script":{"id":"9bf8b351-dc78-42cf-bf2a-2dcd3d484d71","exec":["pm.sendRequest(\"https://sandbox.smartdebit.co.uk/Scripts/smartdebit.jasmine.js\", (err, res) => { pm.globals.set('jasmine' ,res.text() ) });","","eval(pm.globals.get('jasmine'));","","var authHash = btoa(pm.environment.get('api_user') + \":\" + pm.environment.get('api_user_password'));","","console.log(authHash);","","var dataGen = sd.testing;","","//var postData = {};","var query = {};","query.service_user = {};","query.service_user.pslid = pm.environment.get('pslid');","","","var postFormData = dataGen.json2formData(query, 'query');","","console.log(postFormData);","","const postDataRequest = {","  url: pm.environment.get('base_url') + '/arudd/list',","  method: 'POST',","  header: `Authorization:Basic ${authHash}`,","  body: {","    mode: 'formdata',","    formdata: postFormData","  }","};","","pm.sendRequest(postDataRequest, function (err, res) {","  console.log('RESPONSE START');","  console.log(res.text());","  console.log('RESPONSE END');","  ","  var jsonObject = xml2Json(res.text());","  ","  pm.environment.set('arudd_file_id',jsonObject.arudds.arudd.arudd_id);","  pm.environment.set('arudd_file_name', jsonObject.arudds.arudd.file_name);","});"],"type":"text/javascript"}}],"id":"cc430d18-83b9-4d92-be33-334959c95356","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"GET","header":[],"url":"{{base_url}}/arudd/{{arudd_file_id}}","urlObject":{"path":["arudd","{{arudd_file_id}}"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"5ca1b925-6c2c-4cc4-951c-7691f442a1ed","name":"arudd file","originalRequest":{"method":"GET","header":[],"url":"{{base_url}}/arudd/{{arudd_file_id}}"},"status":"OK","code":200,"_postman_previewlanguage":"xml","header":[{"key":"Date","value":"Tue, 05 Mar 2019 10:11:14 GMT"},{"key":"Server","value":"Apache"},{"key":"Cache-Control","value":"private, max-age=0, must-revalidate"},{"key":"X-Runtime","value":"0.06216"},{"key":"Strict-Transport-Security","value":"max-age=63072000; includeSubdomains; preload"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Set-Cookie","value":"auth_token=; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"_PSLLite_session_id=59c10b241683faff8f68dab95c0ecf7c; path=/; HttpOnly; secure"},{"key":"Content-Length","value":"2297"},{"key":"Status","value":"200 OK"},{"key":"X-XSS-Protection","value":"1; mode=block"},{"key":"Keep-Alive","value":"timeout=5, max=99"},{"key":"Connection","value":"Keep-Alive"},{"key":"Content-Type","value":"application/xml; charset=utf-8"},{"key":"X-Iinfo","value":"6-254871-259131 SNNN RT(1551780638679 115786) q(0 0 0 -1) r(1 1) U5"},{"key":"X-CDN","value":"Incapsula"}],"cookie":[],"responseTime":null,"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<arudd uri=\"https://sandbox.ddprocessing.co.uk/api/v1.1/arudd/196907\">\n    <file_name>test_account_TestArudd.xml</file_name>\n    <current_processing_date>2019-03-05T00:00:00Z</current_processing_date>\n    <report_type>REFT1019</report_type>\n    <advice_number>999</advice_number>\n    <failed_debits>1</failed_debits>\n    <failed_debits_value>19995</failed_debits_value>\n    <file>PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPEJBQ1NE\nb2N1bWVudCB4bWxuczp4c2k9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvWE1M\nU2NoZW1hLWluc3RhbmNlIiB4c2k6bm9OYW1lc3BhY2VTY2hlbWFMb2NhdGlv\nbj0ibmV3YmFjcy1hZHZpY2VzLnhzZCI+CiAgPERhdGE+CiAgICA8QVJVREQ+\nCiAgICAgIDxIZWFkZXIgcmVwb3J0VHlwZT0iUkVGVDEwMTkiIGFkdmljZU51\nbWJlcj0iOTk5IiBjdXJyZW50UHJvY2Vzc2luZ0RhdGU9IjIwMTktMDMtMDUi\nPgogICAgICA8L0hlYWRlcj4KICAgICAgPEFkZHJlc3NlZUluZm9ybWF0aW9u\nIG5hbWU9IkFQSSBEb2N1bWVudGF0aW9uIj4KICAgICAgPC9BZGRyZXNzZWVJ\nbmZvcm1hdGlvbj4KICAgICAgPFNlcnZpY2VMaWNlbnNlSW5mb3JtYXRpb24g\ndXNlck5hbWU9IkFQSSBEb2N1bWVudGF0aW9uIiB1c2VyTnVtYmVyPSI1MDAw\nMTciPgogICAgICA8L1NlcnZpY2VMaWNlbnNlSW5mb3JtYXRpb24+CiAgICAg\nIDxBZHZpY2U+CiAgICAgICAgPE9yaWdpbmF0aW5nQWNjb3VudFJlY29yZHM+\nCiAgICAgICAgICA8T3JpZ2luYXRpbmdBY2NvdW50UmVjb3JkPgogICAgICAg\nICAgICA8T3JpZ2luYXRpbmdBY2NvdW50IHR5cGU9IjAiIHNvcnRDb2RlPSIq\nKioqKioiIGJhbmtOYW1lPSJBUEkgRG9jdW1lbnRhdGlvbiIgYnJhbmNoTmFt\nZT0iQ0lUWSBPRkZJQ0UiIG5hbWU9IkFQSSBEb2N1bWVudGF0aW9uIiBudW1i\nZXI9IioqKio1Njc4Ij4KICAgICAgICAgICAgPC9PcmlnaW5hdGluZ0FjY291\nbnQ+CiAgICAgICAgICAgIDxSZXR1cm5lZERlYml0SXRlbSByZXR1cm5Db2Rl\nPSIwIiByZXR1cm5EZXNjcmlwdGlvbj0iUkVGRVIgVE8gUEFZRVIiIGN1cnJl\nbmN5PSJHQlAiIG9yaWdpbmFsUHJvY2Vzc2luZ0RhdGU9IjIwMTktMDMtMDUi\nIHJlZj0iU0QxMTkwMTEyMTY1MTM5MzMiIHZhbHVlT2Y9IjE5OS45NSIgdHJh\nbnNDb2RlPSIxNyI+CiAgICAgICAgICAgICAgPFBheWVyQWNjb3VudCBzb3J0\nQ29kZT0iKioqKioqIiBiYW5rTmFtZT0iQmFyY2xheXMiIHJlZj0iU0QxMTkw\nMTEyMTY1MTM5MzMiIGJyYW5jaE5hbWU9IkNpdHkiIG51bWJlcj0iMDAwNyIg\nbmFtZT0idGVzdC1hY2NvdW50Ij4KICAgICAgICAgICAgICA8L1BheWVyQWNj\nb3VudD4KICAgICAgICAgICAgPC9SZXR1cm5lZERlYml0SXRlbT4KICAgICAg\nICAgICAgPFRvdGFscyBjdXJyZW5jeT0iR0JQIiBudW1iZXJPZj0iMSIgdmFs\ndWVPZj0iMTk5Ljk1Ij4KICAgICAgICAgICAgPC9Ub3RhbHM+CiAgICAgICAg\nICA8L09yaWdpbmF0aW5nQWNjb3VudFJlY29yZD4KICAgICAgICA8L09yaWdp\nbmF0aW5nQWNjb3VudFJlY29yZHM+CiAgICAgIDwvQWR2aWNlPgogICAgPC9B\nUlVERD4KICA8L0RhdGE+CjwvQkFDU0RvY3VtZW50Pgo=\n</file>\n</arudd>"}],"_postman_id":"cc430d18-83b9-4d92-be33-334959c95356"}],"id":"15ff914d-ec65-435b-9b6b-0d7d3d257212","description":"<h4 id=\"description\">Description</h4>\n<p>Individual ARUDD files can be retrieved from the SmartDebit API in XML format. The files are returned as base64 encoded strings.</p>\n<h4 id=\"response\">Response</h4>\n<p>The example response shows the ARUDD summary including the base64 encoded file within the file node.</p>\n<p>The XML version of the ARUDD file is a filtered version of the original Bacs file. In the case that the referenced DDI has a Customer Id in SmartDebit the Customer Id is included in the ReturnedDebitItem as the payerReference attribute.</p>\n<p>An XML ARUDD file consists of an OriginatingAccount tag, a number of ReturnedDebitItem tags, and a Totals tag within a BACSDocument &gt; Data &gt; ARUDD &gt; Advice &gt; OriginatingAccountRecords &gt; OriginatingAccountRecord wrapper. The ARUDD tag also contains a Header tag, an AddresseeInformation tag, and a ServiceLicenseInformation tag. The data formats in the ARUDD file are preserved – dates are presented in the format YYYY-MM-DD.</p>\n<p>All ReturnedDebitItems within an OriginatingAccountRecord have the same originalProcessingDate. Some ARUDD advices are received late. This can result in an ARUDD containing more than one OriginatingAccountRecord.</p>\n<p>The Header tag can contain the following attributes:</p>\n<ul>\n<li>reportType</li>\n<li>adviceNumber</li>\n<li>currentProcessingDate</li>\n</ul>\n<p>The AddresseeInformation tag can contain the following attributes: </p>\n<ul>\n<li>name</li>\n<li>address1</li>\n<li>address2</li>\n<li>address3</li>\n<li>address4</li>\n<li>address5</li>\n</ul>\n<p>The ServiceLicenseInformation tag identifies the service user and can contain the following attributes: </p>\n<ul>\n<li>userName</li>\n<li>userNumber</li>\n</ul>\n<p>The OriginatingAccount tag details the service user's account. The OriginatingAccount tag can contain the following attributes:</p>\n<ul>\n<li>name</li>\n<li>number</li>\n<li>sortCode</li>\n<li>type</li>\n<li>bankName</li>\n<li>branchName</li>\n</ul>\n<p>The ReturnedDebitItem tag can contain the following attributes: </p>\n<ul>\n<li>ref (the reference number of the DDI or the collection reference)</li>\n<li>payerReference (the Customer Id of the payer)</li>\n<li>transCode</li>\n<li>returnCode (refer to the <a href=\"#4855180e-d792-4547-bf87-667881b138bb\">list of reason codes</a>)</li>\n<li>returnDescription (refer to the list of reason codes)</li>\n<li>originalProcessingDate (the expected value of which is the working day prior to the collection date)</li>\n<li>valueOf</li>\n<li>currency</li>\n</ul>\n<p>Depending on the service user configuration, account details may be obscured.</p>\n<p>An example XML ARUDD file, including payer-reference, would look like: </p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;BACSDocument xsi:noNamespaceSchemaLocation=\"newbacs-advices.xsd\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"&gt;\n  &lt;Data&gt;\n    &lt;ARUDD&gt;\n      &lt;Header reportType=\"REFT1019\" adviceNumber=\"999\" currentProcessingDate=\"2019-03-19\"&gt;\n      &lt;/Header&gt;\n      &lt;AddresseeInformation name=\"SERVICE USER LTD\"&gt;\n      &lt;/AddresseeInformation&gt;\n      &lt;ServiceLicenseInformation userName=\"SERVICE USER LTD\" userNumber=\"555666\"&gt;\n      &lt;/ServiceLicenseInformation&gt;\n      &lt;Advice&gt;\n        &lt;OriginatingAccountRecords&gt;\n          &lt;OriginatingAccountRecord&gt;\n            &lt;OriginatingAccount type=\"0\" branchName=\"WOKING\" sortCode=\"20-21-22\" name=\"SERVICE USER\" bankName=\"BARCLAYS BANK UK PLC\" number=\"87654321\"&gt;\n            &lt;/OriginatingAccount&gt;\n            &lt;ReturnedDebitItem originalProcessingDate=\"2019-03-14\" valueOf=\"100.00\" payerReference=\"7890\" currency=\"GBP\" transCode=\"17\" ref=\"ABC123456\" returnCode=\"0\" returnDescription=\"REFER TO PAYER\"&gt;\n              &lt;PayerAccount branchName=\"BANK ACCOUNT 3\" ref=\"ABC123456\" sortCode=\"00-00-00\" name=\"R SMITH           \" bankName=\"Santander\" number=\"12345678\"&gt;\n              &lt;/PayerAccount&gt;\n            &lt;/ReturnedDebitItem&gt;\n            &lt;Totals numberOf=\"1\" valueOf=\"100.00\" currency=\"GBP\"&gt;\n            &lt;/Totals&gt;\n          &lt;/OriginatingAccountRecord&gt;\n        &lt;/OriginatingAccountRecords&gt;\n      &lt;/Advice&gt;\n    &lt;/ARUDD&gt;\n  &lt;/Data&gt;\n&lt;/BACSDocument&gt;\n</code></pre><h4 id=\"errors\">Errors</h4>\n<p>Errors can be avoided by retrieving only reports listed by <a href=\"#b0d4815e-100f-4779-ba39-57be75466244\">arudd/list</a>.</p>\n<ul>\n<li><h6>If the report cannot be found:</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Couldn't find AruddImport with ID=1235545&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<br />\n<li><h6>If no report has been specified - {{base_url}}/arudd/</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Couldn't find AruddImport without an ID&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<br />\n<li><h6>If you do not have permission to view the report:</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Permission Denied.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n</ul>","event":[{"listen":"prerequest","script":{"id":"45f38fb1-6269-45df-b86b-e76bf3b40742","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"69da1e0c-307a-4f57-a53a-921555eaf45a","type":"text/javascript","exec":[""]}}],"_postman_id":"15ff914d-ec65-435b-9b6b-0d7d3d257212"},{"name":"4.8.7 List DDICA files","item":[{"name":"indemnity/list","event":[{"listen":"test","script":{"id":"ca4c6424-7ec5-4709-9dea-6b4deb3a2f4a","exec":["eval(pm.globals.get('jasmine'));","","pm.test(\"Response time is less than 300ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(300);","});","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","","pm.test(\"Body matches string\", function () {","    pm.expect(pm.response.text()).to.include('<indemnities results=\\'1\\' total_results=\\'1\\' start_index=\\'0\\'>');","    pm.expect(pm.response.text()).to.include('</indemnity>');","    pm.expect(pm.response.text()).to.include('</indemnities>');","});","","","pm.test('Schema is valid', function() {","  var jsonObject = xml2Json(pm.response.text());        ","  var jsonSchema =   sd.api.schema.ddicaList;  ","    ","  pm.expect(tv4.validate(jsonObject, jsonSchema)).to.be.true;","  ","});",""],"type":"text/javascript"}}],"id":"0f347b16-4e38-483f-a4cd-6ede1c2a5982","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"key":"query[service_user][pslid]","value":"{{pslid}}","type":"text","description":"<p><i>Required</i><br />\nService user identifier</p>\n"},{"key":"query[max_results]","value":"{{max_results}}","type":"text","description":"<p><b>Format:</b> integer, 1 to 1000<br /><b>Default:</b> 100</p>\n"},{"key":"query[start_index]","value":"{{start_index}}","type":"text","description":"<p><b>Format:</b> integer<br /><b>Default:</b> 0</p>\n"},{"key":"query[id_from]","value":"{{id_from}}","type":"text","description":"<p><b>Format:</b> integer</p>\n"},{"key":"query[from_date]","value":"{{from_date}}","type":"text","description":"<p><i>Conditional (required if till_date is used)</i><br /><b>Format:</b> YYYY-MM-DD</p>\n"},{"key":"query[till_date]","value":"{{till_date}}","type":"text","description":"<p><b>Format:</b> YYYY-MM-DD</p>\n"}]},"url":"{{base_url}}/indemnity/list","urlObject":{"path":["indemnity","list"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"4bbcff92-ae4a-4281-999c-30cee51ec1cd","name":"indemnity list","originalRequest":{"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"description":"<b>Format:</b> plain text<br><b>Restrictions:</b> 5 to 255 characters, must match existing SU's pslid","key":"query[service_user][pslid]","type":"text","value":"{{pslid}}"},{"description":"<b>Format:</b> integer <br> <b>Restrictions:</b> 1 to 1000<br><b>Default:</b> is 100","key":"query[max_results]","type":"text","value":""},{"description":"<b>Format:</b> integer<br><b>Restrictions:</b> 0 or greater<br><b>Default:</b> is 0</b>","key":"query[start_index]","type":"text","value":""},{"description":"<b>Format:</b> integer<br><b>Restrictions:</b> 0 or greater","key":"query[id_from]","type":"text","value":""},{"description":"<b>Format:</b> date YYYY-MM-DD","key":"query[from_date]","type":"text","value":""},{"description":"<b>Format:</b> date YYYY-MM-DD","key":"query[till_date]","type":"text","value":""}]},"url":"{{base_url}}/indemnity/list"},"status":"OK","code":200,"_postman_previewlanguage":"xml","header":[{"key":"Date","value":"Tue, 05 Mar 2019 12:21:05 GMT"},{"key":"Server","value":"Apache"},{"key":"Cache-Control","value":"private, max-age=0, must-revalidate"},{"key":"X-Runtime","value":"0.16024"},{"key":"Strict-Transport-Security","value":"max-age=63072000; includeSubdomains; preload"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Set-Cookie","value":"auth_token=; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"_PSLLite_session_id=59c10b241683faff8f68dab95c0ecf7c; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"incap_ses_874_1416256=a; Max-Age=0; path=/; expires=Mon, 04 Mar 2019 08:33:16 GMT; Domain=.ddprocessing.co.uk"},{"key":"Set-Cookie","value":"incap_ses_373_1416256=a; Max-Age=0; path=/; expires=Mon, 04 Mar 2019 08:33:16 GMT; Domain=.ddprocessing.co.uk"},{"key":"Set-Cookie","value":"incap_ses_454_1416256=a; Max-Age=0; path=/; expires=Mon, 04 Mar 2019 08:33:16 GMT; Domain=.ddprocessing.co.uk"},{"key":"Content-Length","value":"505"},{"key":"Status","value":"200 OK"},{"key":"X-XSS-Protection","value":"1; mode=block"},{"key":"Keep-Alive","value":"timeout=5, max=100"},{"key":"Connection","value":"Keep-Alive"},{"key":"Content-Type","value":"application/xml; charset=utf-8"},{"key":"X-Iinfo","value":"13-3320918-3323758 NNNN CT(0 0 0) RT(1551788533343 12327) q(0 0 0 -1) r(2 2) U5"},{"key":"X-CDN","value":"Incapsula"}],"cookie":[],"responseTime":null,"body":"<indemnities results='1' total_results='1' start_index='0'>\n    <indemnity summary='true' uri='https://sandbox.ddprocessing.co.uk/api/v1.1/indemnity/44'>\n        <file_name>_DOWNLOADED_445566_DDICA_280539217.xml</file_name>\n        <report_production_date>2019-03-05 00:13:18</report_production_date>\n        <report_title>DIRECT DEBIT INDEMNITY CLAIM ADVICE REPORT FOR 05/03/2019</report_title>\n        <total_value_of_debits>199.95</total_value_of_debits>\n        <import_id>44</import_id>\n    </indemnity>\n</indemnities>"}],"_postman_id":"0f347b16-4e38-483f-a4cd-6ede1c2a5982"}],"id":"f97a3125-9987-4582-93d7-a9617cfac0b4","description":"<h4 id=\"description\">Description</h4>\n<p><a href=\"#0f347b16-4e38-483f-a4cd-6ede1c2a5982\">indemnity/list</a> provides a paginated summary of all Direct Debit Indemnity Claim Advice (DDICA) files for a specified service user. By default the first 100 DDICA summaries are returned. Reports are listed in reverse order, most recent first. Each DDICA file summary includes the URI to retrieve the full file.</p>\n<h4 id=\"usage\">Usage</h4>\n<p>This call must be made as a POST. If made as a GET the <em>uri</em> attribute is incorrect.</p>\n<p>Typically a client application would make this call once a day to list new reports.</p>\n<p>&lt;import_id&gt; values are not contiguous but always increase. To list reports once only, keep a record of the maximum &lt;import_id&gt; value. When making the call, add one to the maximum and use this as the <em>query[id_from]</em> parameter.</p>\n<p>Listing reports by date range can be unreliable.</p>\n<h4 id=\"response\">Response</h4>\n<p>A successful response from indemnity/list is an XML list of DDICA file summaries. The root &lt;indemnities&gt; tag includes the number of results returned, the start index for the results returned, and the total number of results.</p>\n<p>Note that the response does not have an XML header.</p>\n<p>In the case that there are no DDICA files the root element is empty:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>200 OK\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;indemnities results='0' total_results='0' start_index='0'&gt;&lt;/indemnities&gt;\n</code></pre><p>Note the single quotes in this response.</p>\n<h4 id=\"errors\">Errors</h4>\n<ul>\n<li><h6>Missing or invalid service user</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;No service user id supplied.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><br />\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Invalid Service User ID: 'su_pslid'&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<br />\n<li><h6>Invalid date value</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Unable to parse date 'yesterday' expected format is YYYY-MM-DD&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<br />\n<li><h6>Value out of range</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Mysql::Error: #42000You have an error in your SQL syntax  [...]  &lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li></ul>","event":[{"listen":"prerequest","script":{"id":"c6cf2075-d8cb-43c5-8fea-9a3155eac566","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"51c0cc31-13ea-49ce-9c1e-a3099c47e055","type":"text/javascript","exec":[""]}}],"_postman_id":"f97a3125-9987-4582-93d7-a9617cfac0b4"},{"name":"4.8.8 Retrieve DDICA file","item":[{"name":"indemnity/{{id}}","event":[{"listen":"test","script":{"id":"43e57f10-16ed-4d7c-a842-d444e7f98fcd","exec":["pm.test(\"Response time is less than 300ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(300);","});","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});","","","pm.test(\"Body matches string\", function () {","    pm.expect(pm.response.text()).to.include('<indemnity uri=\"https://sandbox.ddprocessing.co.uk/api/v1.1/indemnity/'+pm.environment.get('indemnity_file_id')+'\">');","    ","    //var response = pm.response.text();","    //var pattern = /<indemnities results=\\'(\\d+)\\' total_results=\\'(\\d+)\\' start_index=\\'(\\d+)\\'>/g;","    ","    //pm.expect(pattern.test(response)).to.eql(true);","    pm.expect(pm.response.text()).to.include('<file_name>'+ pm.environment.get('indemnity_file_name') +'</file_name>');","    pm.expect(pm.response.text()).to.include('</file>');","    pm.expect(pm.response.text()).to.include('</indemnity>');","});","","pm.test('Schema is valid', function() {","  var jsonObject = xml2Json(responseBody);        ","  var jsonSchema =   sd.api.schema.ddicaList;  ","    ","  pm.expect(tv4.validate(jsonObject, jsonSchema)).to.be.true;","  ","});"],"type":"text/javascript"}},{"listen":"prerequest","script":{"id":"6a859b2d-e3d1-4a7d-ad51-aeef03eb0ed1","exec":["pm.sendRequest(\"https://sandbox.smartdebit.co.uk/Scripts/smartdebit.jasmine.js\", (err, res) => { pm.globals.set('jasmine' ,res.text() ) });","","eval(pm.globals.get('jasmine'));","","var authHash = btoa(pm.environment.get('api_user') + \":\" + pm.environment.get('api_user_password'));","","console.log(authHash);","","var dataGen = sd.testing;","","//var postData = {};","var query = {};","query.service_user = {};","query.service_user.pslid = pm.environment.get('pslid');","","","var postFormData = dataGen.json2formData(query, 'query');","","console.log(postFormData);","","const postDataRequest = {","  url: pm.environment.get('base_url') + '/indemnity/list',","  method: 'POST',","  header: `Authorization:Basic ${authHash}`,","  body: {","    mode: 'formdata',","    formdata: postFormData","  }","};","","pm.sendRequest(postDataRequest, function (err, res) {","  console.log('RESPONSE START');","  console.log(res.text());","  console.log('RESPONSE END');","  ","  var jsonObject = xml2Json(res.text());","  ","  pm.environment.set('indemnity_file_id',jsonObject.indemnities.indemnity.import_id);","  pm.environment.set('indemnity_file_name', jsonObject.indemnities.indemnity.file_name);","});"],"type":"text/javascript"}}],"id":"ebec5c28-3427-4f53-9887-c0ab817a9574","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"GET","header":[],"url":"{{base_url}}/indemnity/{{indemnity_file_id}}","urlObject":{"path":["indemnity","{{indemnity_file_id}}"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"ec7a3cf0-67f7-499a-acab-5934b0d5d9e4","name":"indemnity file","originalRequest":{"method":"GET","header":[],"url":"{{base_url}}/indemnity/{{indemnity_file_id}}"},"status":"OK","code":200,"_postman_previewlanguage":"xml","header":[{"key":"Date","value":"Tue, 05 Mar 2019 13:54:42 GMT"},{"key":"Server","value":"Apache"},{"key":"Cache-Control","value":"private, max-age=0, must-revalidate"},{"key":"X-Runtime","value":"0.19030"},{"key":"Strict-Transport-Security","value":"max-age=63072000; includeSubdomains; preload"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Set-Cookie","value":"auth_token=; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"_PSLLite_session_id=59c10b241683faff8f68dab95c0ecf7c; path=/; HttpOnly; secure"},{"key":"Content-Length","value":"3331"},{"key":"Status","value":"200 OK"},{"key":"X-XSS-Protection","value":"1; mode=block"},{"key":"Keep-Alive","value":"timeout=5, max=99"},{"key":"Connection","value":"Keep-Alive"},{"key":"Content-Type","value":"application/xml; charset=utf-8"},{"key":"X-Iinfo","value":"14-5406204-5406216 SNNN RT(1551794162663 368) q(0 0 0 -1) r(2 2) U5"},{"key":"X-CDN","value":"Incapsula"}],"cookie":[],"responseTime":null,"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<indemnity uri=\"https://sandbox.ddprocessing.co.uk/api/v1.1/indemnity/44\">\n    <file_name>_DOWNLOADED_445566_DDICA_280539217.xml</file_name>\n    <report_production_date>2019-03-05  00:13:18</report_production_date>\n    <file>PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPFZvY2FE\nb2N1bWVudD4KICA8RGF0YT4KICAgIDxEb2N1bWVudCB0eXBlPSJESVJFQ1Qg\nREVCSVQgSU5ERU1OSVRZIENMQUlNIEFEVklDRSBSRVBPUlQiIHNjaGVtYVZl\ncnNpb249IjEuMCIgY3JlYXRlZD0iMjAxOS0wMy0wNSAgMDA6MTM6MTgiPgog\nICAgICA8Q29tcGFueU5hbWU+QmFjcyBQYXltZW50IFNjaGVtZXMgTGltaXRl\nZDwvQ29tcGFueU5hbWU+CiAgICAgIDxSZXBvcnRUaXRsZT5ESVJFQ1QgREVC\nSVQgSU5ERU1OSVRZIENMQUlNIEFEVklDRSBSRVBPUlQgRk9SIDA1LzAzLzIw\nMTk8L1JlcG9ydFRpdGxlPgogICAgICA8UmVwb3J0UHJvZHVjdGlvbkRhdGU+\nMjAxOS0wMy0wNSAgMDA6MTM6MTg8L1JlcG9ydFByb2R1Y3Rpb25EYXRlPgog\nICAgICA8U2VydmljZVVzZXJOdW1iZXI+NTAwMDE3PC9TZXJ2aWNlVXNlck51\nbWJlcj4KICAgICAgPFNlcnZpY2VVc2VyTmFtZT5BUEkgRG9jdW1lbnRhdGlv\nbjwvU2VydmljZVVzZXJOYW1lPgogICAgICA8TnVtYmVyT2ZBZHZpY2VzPjE8\nL051bWJlck9mQWR2aWNlcz4KICAgICAgPE5ld0FkdmljZXM+CiAgICAgICAg\nPERESUNBZHZpY2U+CiAgICAgICAgICA8U2VxTm8+MjAxOTAzMDUwM0E4NTYy\nNDI3MzI8L1NlcU5vPgogICAgICAgICAgPFBheWluZ0JhbmtSZWZlcmVuY2U+\nRERJQzA1MjUyNDAzPC9QYXlpbmdCYW5rUmVmZXJlbmNlPgogICAgICAgICAg\nPFNVTnVtYmVyPjAwMDAwMDwvU1VOdW1iZXI+CiAgICAgICAgICA8UGF5aW5n\nQmFua05hbWU+SFNCQyBCQU5LIFBMQzwvUGF5aW5nQmFua05hbWU+CiAgICAg\nICAgICA8U1VSZWZlcmVuY2U+U0QxMTkwMTE0MTM0MzEzMjc3PC9TVVJlZmVy\nZW5jZT4KICAgICAgICAgIDxSZWFzb25Db2RlPjQ8L1JlYXNvbkNvZGU+CiAg\nICAgICAgICA8UGF5ZXJTb3J0Q29kZT4qKioqKio8L1BheWVyU29ydENvZGU+\nCiAgICAgICAgICA8UGF5ZXJBY2NvdW50PioqKiowMDA3PC9QYXllckFjY291\nbnQ+CiAgICAgICAgICA8UGF5ZXJOYW1lPk1pYTwvUGF5ZXJOYW1lPgogICAg\nICAgICAgPE5vT2ZBZHZGb3JDbGFpbT4xPC9Ob09mQWR2Rm9yQ2xhaW0+CiAg\nICAgICAgICA8VG90YWxBbW91bnQ+MTk5Ljk1PC9Ub3RhbEFtb3VudD4KICAg\nICAgICAgIDxERENvbGxlY3Rpb25zPgogICAgICAgICAgICA8RERDb2xsZWN0\naW9uPgogICAgICAgICAgICAgIDxEYXRlT2ZEaXJlY3REZWJpdD4yMDE5LTAz\nLTA1PC9EYXRlT2ZEaXJlY3REZWJpdD4KICAgICAgICAgICAgICA8QW1vdW50\nPjE5OS45NTwvQW1vdW50PgogICAgICAgICAgICA8L0REQ29sbGVjdGlvbj4K\nICAgICAgICAgIDwvRERDb2xsZWN0aW9ucz4KICAgICAgICA8L0RESUNBZHZp\nY2U+CiAgICAgICAgPFRvdGFsTnVtYmVyT2ZOZXdBZHZpY2VzPjE8L1RvdGFs\nTnVtYmVyT2ZOZXdBZHZpY2VzPgogICAgICAgIDxUb3RhbFZhbHVlT2ZEZWJp\ndHM+MTk5Ljk1PC9Ub3RhbFZhbHVlT2ZEZWJpdHM+CiAgICAgICAgPERhdGVP\nZkRlYml0PjIwMTktMDMtMDU8L0RhdGVPZkRlYml0PgogICAgICA8L05ld0Fk\ndmljZXM+CiAgICAgIDxSZWFzb25Db2RlTWVhbmluZz4xID0gQW1vdW50IGFu\nZCAvIG9yIGRhdGUgb2YgRGlyZWN0IERlYml0IGRpZmZlciBmcm9tIEFkdmFu\nY2UgTm90aWNlLjIgPSBObyBBZHZhbmNlIE5vdGljZSByZWNlaXZlZCBieSBQ\nYXllci9vciB0aGUgYW1vdW50IHF1b3RlZCBpcyBkaXNwdXRlZC4zID0gRERJ\nIGNhbmNlbGxlZCBieSBwYXlpbmcgYmFuay40ID0gUGF5ZXIgaGFzIGNhbmNl\nbGxlZCBEREkgZGlyZWN0IHdpdGggc2VydmljZSB1c2VyLjUgPSBBVURESVMg\nc2VydmljZSB1c2VycyBvbmx5IC0gTm8gSW5zdHJ1Y3Rpb24gaGVsZC4gUGF5\nZXIgZGlzcHV0ZXMgaGF2aW5nIGdpdmVuIGF1dGhvcml0eS42ID0gQVVERElT\nIHNlcnZpY2UgdXNlcnMgb25seSAtIFNpZ25hdHVyZSBvbiBEREkgaXMgZnJh\ndWR1bGVudCBvciBub3QgaW4gYWNjb3JkYW5jZSB3aXRoIGFjY291bnQgYXV0\naG9yaXNlZCBzaWduYXR1cmUocykuNyA9IENsYWltIHJhaXNlZCBhdCBzZXJ2\naWNlIHVzZXJzIHJlcXVlc3QgYWZ0ZXIgRGlyZWN0IERlYml0IGFwcGxpZWQg\ndG8gcGF5ZXJzIGFjY291bnQuOCA9IFNlcnZpY2UgdXNlciBuYW1lIGRpc3B1\ndGVkLiBQYXllciBkb2VzIG5vdCByZWNvZ25pc2Ugc2VydmljZSB1c2VyIGNv\nbGxlY3RpbmcgRGlyZWN0IERlYml0LjwvUmVhc29uQ29kZU1lYW5pbmc+CiAg\nICA8L0RvY3VtZW50PgogIDwvRGF0YT4KPC9Wb2NhRG9jdW1lbnQ+Cg==\n</file>\n</indemnity>"}],"_postman_id":"ebec5c28-3427-4f53-9887-c0ab817a9574"}],"id":"30a21318-9d4c-4551-b1b5-0ff0fdf3d71c","description":"<h4 id=\"description\">Description</h4>\n<p>Individual DDICA files can be retrieved from the SmartDebit API in XML format. The files are returned as base64 encoded strings.</p>\n<h4 id=\"usage\">Usage</h4>\n<p>You can match each collection in a claim to the original by the &lt;SUReference&gt;, the &lt;DateOfDirectDebit&gt; and &lt;Amount&gt;. The date may differ by a few days. Very occasionally the reference may differ slightly.</p>\n<p>Where a claim is for more than one collection, this can appear either as a single &lt;DDICAdvice&gt; containing more than one &lt;DDCollection&gt;, or as more than one &lt;DDICAdvice&gt;, each containing a single &lt;DDCollection&gt;.</p>\n<p>The &lt;DateOfDebit&gt; is the date on which the claims will be debited from the service user's bank account.</p>\n<p>Note:</p>\n<ul>\n<li>Indemnity claims may be cancelled before they are paid. Cancelled claims are reported to SmartDebit as DDICA cancellations. The API does not currently support DDICA cancellations.</li>\n</ul>\n<h4 id=\"response\">Response</h4>\n<p>The example response shows the base64 encoded file within the file node.</p>\n<p>The XML version of the DDICA file is a filtered version of the original Bacs file.</p>\n<p>An XML DDICA file consists of a Document, NewAdvices and a number of DDICAdvice tags within a VocaDocument &gt; Data wrapper.  Within the DDICAdvice tag there is a DDCollections tag with one or more DDCollection child nodes. Each DDCollection node contains two nodes, DateOfDirectDebit and Amount. The data formats in the DDICA file are preserved – dates are presented in the format YYYY-MM-DD.</p>\n<p>The Document tag can contain the following attributes: </p>\n<ul>\n<li>type </li>\n<li>schemaVersion </li>\n<li>created</li>\n</ul>\n<p>The Document tag can contain the following child nodes:</p>\n<ul>\n<li>CompanyName</li>\n<li>ReportTitle</li>\n<li>ReportProductionDate</li>\n<li>ServiceUserNumber</li>\n<li>ServiceUserName</li>\n<li>NumberOfAdvices</li>\n</ul>\n<p>The DDICAdvice tag found under the NewAdvices tag can contain the following child nodes:</p>\n<ul>\n<li>SeqNo </li>\n<li>PayingBankReference </li>\n<li>SUNumber </li>\n<li>PayingBankName </li>\n<li>SUReference </li>\n<li>ReasonCode </li>\n<li>PayerSortCode </li>\n<li>PayerAccount  </li>\n<li>PayerName </li>\n<li>NoOfAdvForClaim </li>\n<li>TotalAmount</li>\n</ul>\n<p>Depending on the service user configuration, account details may be obscured.</p>\n<p>The DDCollection tag found under the DDCollections node contains the following child nodes: </p>\n<ul>\n<li>DateOfDirectDebit </li>\n<li>Amount</li>\n</ul>\n<p>A successful response from <a href=\"#ebec5c28-3427-4f53-9887-c0ab817a9574\">indemnity/<em>{{id}}</em></a> is an XML summary of the DDICA file. </p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>200 OK\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt; \n&lt;VocaDocument&gt;\n  &lt;Data&gt;  \n    &lt;Document type=\"DIRECT DEBIT INDEMNITY CLAIM ADVICE REPORT\" created=\"2019-01-04 00:32:40\" schemaVersion=\"1.0\"&gt;\n      &lt;CompanyName&gt;Bacs Payment Schemes Limited&lt;/CompanyName&gt;\n      &lt;ReportTitle&gt;DIRECT DEBIT INDEMNITY CLAIM ADVICE REPORT FOR 03/01/2019&lt;/ReportTitle&gt;\n      &lt;ReportProductionDate&gt;2019-01-04 00:32:40&lt;/ReportProductionDate&gt;\n      &lt;ServiceUserNumber&gt;…&lt;/ServiceUserNumber&gt;\n      &lt;ServiceUserName&gt;…&lt;/ServiceUserName&gt;\n      &lt;NumberOfAdvices&gt;…&lt;/NumberOfAdvices&gt;\n      &lt;NewAdvices&gt; \n        &lt;DDICAdvice&gt;  \n          &lt;SeqNo&gt;…&lt;/SeqNo&gt;\n          &lt;PayingBankReference&gt;…&lt;/PayingBankReference&gt;\n          &lt;SUNumber&gt;…&lt;/SUNumber&gt;\n          &lt;PayingBankName&gt;…&lt;/PayingBankName&gt;\n          &lt;SUReference&gt;…&lt;/SUReference&gt;\n          &lt;ReasonCode&gt;…&lt;/ReasonCode&gt;\n          &lt;PayerSortCode&gt;…&lt;/PayerSortCode&gt;\n          &lt;PayerAccount&gt;…&lt;/PayerAccount&gt;\n          &lt;PayerName&gt;…&lt;/PayerName&gt;\n          &lt;NoOfAdvForClaim&gt;…&lt;/NoOfAdvForClaim&gt;\n          &lt;TotalAmount&gt;…&lt;/TotalAmount&gt;\n          &lt;DDCollections&gt;\n            &lt;DDCollection&gt;\n              &lt;DateOfDirectDebit&gt;…&lt;/DateOfDirectDebit&gt;\n              &lt;Amount&gt;…&lt;/Amount&gt;\n            &lt;/DDCollection&gt;\n          &lt;/DDCollections&gt;\n        &lt;/DDICAdvice&gt;\n        &lt;TotalNumberOfNewAdvices&gt;…&lt;/TotalNumberOfNewAdvices&gt;\n        &lt;TotalValueOfDebits&gt;…&lt;/TotalValueOfDebits&gt;\n        &lt;DateOfDebit&gt;…&lt;/DateOfDebit&gt;\n      &lt;/NewAdvices&gt; \n      &lt;ReasonCodeMeaning&gt;…list of all reason codes…&lt;/ReasonCodeMeaning&gt;\n    &lt;/Document&gt;\n  &lt;/Data&gt;\n&lt;/VocaDocument&gt; \n</code></pre><h4 id=\"errors\">Errors</h4>\n<p>Errors can be avoided by retrieving only reports listed by <a href=\"#0f347b16-4e38-483f-a4cd-6ede1c2a5982\">indemnity/list</a>.</p>\n<ul>\n<li><h6>If the report cannot be found:</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Couldn't find IndemnityImport with ID=123456789&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<br />\n<li><h6>If no report has been specified - {{base_url}}/indemnity/</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Couldn't find IndemnityImport without an ID&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n<br />\n<li><h6>If you do not have permission to view the report:</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Permission Denied.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n</ul>\n\n<h4 id=\"version-history\">Version history</h4>\n<table>\n<tr>\n<td>API v1.1</td>\n<td>Returns correctly-formatted XML.</td>\n</tr>\n<tr>\n<td></td><td>Returns malformed XML where there are multiple &lt;DDICAdvice&gt; nodes or where there are multiple &lt;DDCollections&gt; nodes within an advice.</td>\n</tr>\n</table>","event":[{"listen":"prerequest","script":{"id":"6d66d328-5e78-4d93-a7fe-a8f438922081","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"a31d3dde-9e76-4c62-84c5-5e9256de171a","type":"text/javascript","exec":[""]}}],"_postman_id":"30a21318-9d4c-4551-b1b5-0ff0fdf3d71c"}],"id":"93b2a4b7-3a24-43b8-b5e6-9f73952e247f","description":"<p>Bacs reports are notifications from the payers' banks via Bacs to the service user. The reports are XML documents containing one or more advices. SmartDebit processes these reports every working day, early in the morning, and makes them available to service users at the same time.</p>\n<p>The SmartDebit API allows the following report types to be listed for each service user, and for individual files to be retrieved in XML format.</p>\n<ul>\n<li>AUDDIS (Automated Direct Debit Instruction Service): failed or amended lodgement or cancellation transactions</li>\n<li>ADDACS (Automated Direct Debit Amendment and Cancellation): cancellations or amendments to DDIs</li>\n<li>ARUDD (Automated Return of Unpaid Direct Debit): failed collections</li>\n<li>DDICA (Direct Debit Indemnity Claim Advice): claims relating to disputed collections</li>\n</ul>\n<p>The files are filtered versions of the original Bacs files, returned as base64 encoded strings. Routines for decoding base64 are widely available.</p>\n<p>Sort code and account number are masked by default. Contact SmartDebit if you require these values in full.</p>\n<p>Some of the XML contains single quotation marks (') and some contains double quotation marks (\") due to different techniques used in generating the response.</p>\n","event":[{"listen":"prerequest","script":{"id":"a05fa44e-db33-42d1-be12-e097624d55c6","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"5f7f6a86-56db-4820-8679-51dde41a6342","type":"text/javascript","exec":[""]}}],"_postman_id":"93b2a4b7-3a24-43b8-b5e6-9f73952e247f"},{"name":"4.9 Re-present","item":[{"name":"represent_debit","event":[{"listen":"test","script":{"id":"f0fad740-017b-4229-9e36-d03ad3fe20ae","exec":["pm.test(\"Response time is less than 200ms\", function () {","    pm.expect(pm.response.responseTime).to.be.below(200);","});","","pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});",""],"type":"text/javascript"}}],"id":"f927e8c3-4ee5-4b4f-871e-8577fafffb7a","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{api_user}}"},{"key":"password","value":"{{api_user_password}}"}]},"isInherited":false},"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"key":"query[service_user][pslid]","value":"{{pslid}}","description":"<p><i>Required</i><br />\nService user identifier</p>\n","type":"text"},{"key":"query[reference_number]","value":"{{reference_number}}","description":"<p><i>Required</i><br />The reference number of the failed collection</p>\n","type":"text"},{"key":"query[original_debit_date]","value":"{{original_debit_date}}","description":"<p><i>Required</i><br />The date of the failed collection<br /><b>Format:</b> YYYY-MM-DD</p>\n","type":"text"},{"key":"query[original_debit_amount]","value":"{{original_debit_amount}}","description":"<p><i>Required</i><br />The amount of the failed collection <i>in pence</i></p>\n","type":"text"},{"key":"query[represent_debit_date]","value":"{{represent_debit_date}}","description":"<p><i>Optional</i><br />The date of the re-present, which must be a valid collection date, must allow time for submission and must be within one month of the failed collection<br /><b>Format:</b> YYYY-MM-DD</p>\n","type":"text"}]},"url":"{{base_url}}/represent_debit","urlObject":{"path":["represent_debit"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"d93f4cf7-59e3-4baf-acb0-7eb46b4aec03","name":"represent debit","originalRequest":{"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"key":"query[service_user][pslid]","value":"{{pslid}}","description":"<b>Format:</b> plain text<br><b>Restrictions:</b> 5 to 255 characters, must match existing SU's pslid","type":"text"},{"key":"query[reference_number]","value":"ABC123456","description":"<b>Format:</b> plain text<br><b>Restrictions:</b> must be the reference number of the failed debit","type":"text"},{"key":"query[original_debit_date]","value":"2019-04-01","description":"<b>Format:</b> date YYYY-MM-DD","type":"text"},{"key":"query[original_debit_amount]","value":"2000","description":"<b>Format:</b> Integer, the value of the debit amount in pence.<br> \n<b>Restrictions:</b> value has to match of the original setup","type":"text"},{"key":"query[represent_debit_date]","value":"","description":"<b>Optional</b><br><b>Format:</b> date YYYY-MM-DD<br><b>Restrictions:</b> must be a valid collection date, within 1 calendar month of failed debit","type":"text","disabled":true}]},"url":"{{base_url}}/represent_debit"},"status":"OK","code":200,"_postman_previewlanguage":"xml","header":[{"key":"Date","value":"Tue, 05 Mar 2019 15:17:34 GMT"},{"key":"Server","value":"Apache"},{"key":"Cache-Control","value":"private, max-age=0, must-revalidate"},{"key":"X-Runtime","value":"0.09922"},{"key":"Strict-Transport-Security","value":"max-age=63072000; includeSubdomains; preload"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Set-Cookie","value":"auth_token=; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"_PSLLite_session_id=59c10b241683faff8f68dab95c0ecf7c; path=/; HttpOnly; secure"},{"key":"Set-Cookie","value":"incap_ses_874_1416256=a; Max-Age=0; path=/; expires=Mon, 04 Mar 2019 08:33:16 GMT; Domain=.ddprocessing.co.uk"},{"key":"Set-Cookie","value":"incap_ses_373_1416256=a; Max-Age=0; path=/; expires=Mon, 04 Mar 2019 08:33:16 GMT; Domain=.ddprocessing.co.uk"},{"key":"Set-Cookie","value":"incap_ses_454_1416256=a; Max-Age=0; path=/; expires=Mon, 04 Mar 2019 08:33:16 GMT; Domain=.ddprocessing.co.uk"},{"key":"Content-Length","value":"198"},{"key":"Status","value":"200 OK"},{"key":"X-XSS-Protection","value":"1; mode=block"},{"key":"Keep-Alive","value":"timeout=5, max=100"},{"key":"Connection","value":"Keep-Alive"},{"key":"Content-Type","value":"application/xml; charset=utf-8"},{"key":"X-Iinfo","value":"5-3945949-3945962 NNNN CT(2 14 0) RT(1551799134218 22) q(0 0 0 -1) r(2 2) U5"},{"key":"X-CDN","value":"Incapsula"}],"cookie":[],"responseTime":null,"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<represent>\n    <success>true</success>\n    <reference_number>ABC123456</reference_number>\n    <date>2019/05/01</date>\n    <amount>2000</amount>\n</represent>"}],"_postman_id":"f927e8c3-4ee5-4b4f-871e-8577fafffb7a"}],"id":"b1f50b7f-9a04-4400-b435-5efb8210123d","description":"<h4 id=\"description\">Description</h4>\n<p>Collections that fail with ARUDD reason code 0 (\"refer to payer\") may be re-presented within one calendar month. Bacs recommends that the payer be contacted before the re-presentation to ensure the payer has sufficient funds in their account. To re-present a failed collection, the DDI reference number, amount and date of the failed collection must be supplied. Optionally, the date on which the re-presented collection should be made can be provided. If no date is provided, SmartDebit calculates the earliest date on which the re-present can be made. In either case, the response from SmartDebit, if the call is successful, contains the DDI reference number, the due date and amount of the re-present. If unsuccessful, the reason why the re-present cannot be made is returned. </p>\n<h4 id=\"response\">Response</h4>\n<p>A successful call to <a href=\"#f927e8c3-4ee5-4b4f-871e-8577fafffb7a\">represent_debit</a> returns an XML document with the status of the call, the reference number, the new collection date and the amount (in pence) to be collected.</p>\n<p>The XML document returned from a successful call has the following format: </p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>200 OK\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;represent&gt;\n  &lt;success&gt;true&lt;/success&gt;\n  &lt;reference_number&gt;ABC123456&lt;/reference_number&gt;\n  &lt;date&gt;2019/05/01&lt;/date&gt;\n  &lt;amount&gt;2000&lt;/amount&gt;\n&lt;/represent&gt;\n</code></pre><h4 id=\"errors\">Errors</h4>\n<ul>\n<li><h6>Missing parameters</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;No service user id supplied.&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><br />\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Missing required parameter(s) - Reference Number&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><br />\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Missing required parameter(s) - Debit date&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre><br />\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Missing required parameter(s) - Debit amount&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n\n<br />\n\n<li><h6>Reference number not found</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Unable to find the reference number for the pslid provided&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n\n<br />\n\n<li><h6>Debit not found (example)</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;Original failed debit: Reference ABC123456 Date tomorrow Amount 1000 not found&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n\n<br />\n\n<li><h6>Collection cannot be re-presented</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;The original debit cannot be represented&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n\n<br />\n\n<li><h6>Trying to re-present an already re-presented collection (example)</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;An uncollected represent for Bacs reference ABC123456, has already been generated for collection on 2019-05-01&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n\n<br />\n\n<li><h6>Not allowing enough time for submission when specifying query[represent_debit_date] (example)</h6>\n\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>500 Internal Server Error\n</code></pre><pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;errors&gt;\n  &lt;error&gt;The supplied represent date of 2019-05-29 is too soon or in the past&lt;/error&gt;\n&lt;/errors&gt;\n</code></pre></li>\n</ul>","event":[{"listen":"prerequest","script":{"id":"27ffdb8d-1a86-410d-a534-aa5c3c3de3d9","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"80889a35-05d6-4303-816a-cf6cf409dab6","type":"text/javascript","exec":[""]}}],"_postman_id":"b1f50b7f-9a04-4400-b435-5efb8210123d"}],"id":"12a04988-ee1f-47e1-b285-c9779bd017d2","event":[{"listen":"prerequest","script":{"id":"760c4cdc-89ce-4aff-83e7-f513657ed3c0","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"232a2ca8-b55e-40b7-af58-54856ff31881","type":"text/javascript","exec":[""]}}],"_postman_id":"12a04988-ee1f-47e1-b285-c9779bd017d2","description":""},{"name":"5 Input file formats & reference number rules","item":[{"name":"5.1 Payer file format","item":[],"id":"af952adc-d8b5-412c-96e6-e1064bd7a70d","description":"<p>A payer file is a CSV file containing 46 fields, many of which are not used. Values may be wrapped in double quotes.</p>\n<p>The CSV fields are as follows:</p>\n<table>\n    <tr>\n        <th>Field</th>\n        <th>Field name</th>\n        <th>Restrictions</th>\n        <th>Comments</th>\n    </tr>\n    <tr>\n        <td>1</td>\n        <td></td>\n        <td>Leave blank</td>\n        <td></td>\n    </tr>\n    <tr>\n        <td>2</td>\n        <td>Reference number</td>\n        <td>Length: 6 – 18 characters (<a href=\"#4d8a7173-5301-41e1-b171-7d4fde1fef6b\">rules</a>)</td>\n        <td>Not required for creation if generated by the system; otherwise required</td>\n    </tr>\n    <tr>\n        <td>3</td>\n        <td>Account name</td>\n        <td>Length: 3 – 18 characters</td>\n        <td>Required for creation</td>\n    </tr>\n    <tr>\n        <td>4</td>\n        <td>Sort code</td>\n        <td>Length: 6 digits</td>\n        <td>Required for creation</td>\n    </tr>\n    <tr>\n        <td>5</td>\n        <td>Account number</td>\n        <td>Length: 8 digits</td>\n        <td>Required for creation</td>\n    </tr>\n    <tr>\n        <td>6-14</td>\n        <td></td>\n        <td>Leave blank</td>\n        <td></td>\n    </tr>\n    <tr>\n        <td>15</td>\n        <td>Title</td>\n        <td>Optional. Length: 0 – 32 characters</td>\n        <td></td>\n    </tr>\n    <tr>\n        <td>16</td>\n        <td>Forename</td>\n        <td>Required. Length: 1 – 32 characters</td>\n        <td></td>\n    </tr>\n    <tr>\n        <td>17</td>\n        <td>Surname</td>\n        <td>Required. Length: 1 – 32 characters</td>\n        <td></td>\n    </tr>\n    <tr>\n        <td>18</td>\n        <td>Company name</td>\n        <td>Optional. Length: 0 – 32 characters</td>\n        <td></td>\n    </tr>\n    <tr>\n        <td>19</td>\n        <td>Address line 1</td>\n        <td>Optional. Length: 0 – 255 characters</td>\n        <td></td>\n    </tr>\n    <tr>\n        <td>20</td>\n        <td>Address line 2</td>\n        <td>Optional. Length: 0 – 32 characters</td>\n        <td></td>\n    </tr>\n    <tr>\n        <td>21</td>\n        <td>Address line 3</td>\n        <td>Optional. Length: 0 – 32 characters</td>\n        <td></td>\n    </tr>\n    <tr>\n        <td>22</td>\n        <td>City/town</td>\n        <td>Optional. Length: 0 – 32 characters</td>\n        <td></td>\n    </tr>\n    <tr>\n        <td>23</td>\n        <td>County</td>\n        <td>Optional. Length: 0 – 32 characters</td>\n        <td></td>\n    </tr>\n    <tr>\n        <td>24</td>\n        <td>Post code</td>\n        <td>Optional. Length: 0 – 32 characters</td>\n        <td></td>\n    </tr>\n    <tr>\n        <td>25</td>\n        <td>Country</td>\n        <td>Optional. Length: 0 – 32 characters</td>\n        <td>The value 'United Kingdom' is assumed on creation if blank</td>\n    </tr>\n    <tr>\n        <td>26</td>\n        <td></td>\n        <td>Leave blank</td>\n        <td></td>\n    </tr>\n    <tr>\n        <td>27</td>\n        <td></td>\n        <td>Leave blank</td>\n        <td></td>\n    </tr>\n    <tr>\n        <td>28</td>\n        <td>Email</td>\n        <td>Optional. Length: 0 – 64 characters</td>\n        <td></td>\n    </tr>\n    <tr>\n        <td>29</td>\n        <td></td>\n        <td>Leave blank</td>\n        <td></td>\n    </tr>\n    <tr>\n        <td>30</td>\n        <td>Frequency type</td>\n        <td>Variable DDIs: required. Values: 'W', 'M', 'Q', 'Y'<br />Adhoc DDIs: must be blank</td>\n        <td>Permitted values depend on service user configuration</td>\n    </tr>\n    <tr>\n        <td>31</td>\n        <td>Regular amount</td>\n        <td>Variable DDIs: optional. Decimal number with two decimal point precision<br />Adhoc DDIs: must be blank</td>\n        <td>Amount is in pounds. Maximum depends on service user configuration.</td>\n    </tr>\n    <tr>\n        <td>33</td>\n        <td></td>\n        <td>Leave blank</td>\n        <td></td>\n    </tr>\n    <tr>\n        <td>34</td>\n        <td></td>\n        <td>Leave blank</td>\n        <td></td>\n    </tr>\n    <tr>\n        <td>35</td>\n        <td>Start year</td>\n        <td>Optional. Format: YYYY</td>\n        <td></td>\n    </tr>\n    <tr>\n        <td>36</td>\n        <td>Start month</td>\n        <td>Optional. Format: MM</td>\n        <td></td>\n    </tr>\n    <tr>\n        <td>37</td>\n        <td>Start day</td>\n        <td>Optional. Format: DD</td>\n        <td></td>\n    </tr>\n    <tr>\n        <td>38</td>\n        <td>End year</td>\n        <td>Optional. Format: YYYY</td>\n        <td>End date is the last regular collection. The DDI remains live.<br />If specified, the end date must be on or after the start date.</td>\n    </tr>\n    <tr>\n        <td>39</td>\n        <td>End month</td>\n        <td>Optional. Format: MM</td>\n        <td></td>\n    </tr>\n    <tr>\n        <td>40</td>\n        <td>End day</td>\n        <td>Optional. Format: DD</td>\n        <td></td>\n    </tr>\n    <tr>\n        <td>41-43</td>\n        <td></td>\n        <td>Leave blank</td>\n        <td></td>\n    </tr>\n    <tr>\n        <td>44</td>\n        <td>Frequency factor</td>\n        <td>Variable DDIs: valid values are blank, 1, 2 ,3, 4.<br />Adhoc DDIs: leave blank</td>\n        <td>Leave blank unless required. Values of 2, 3, 4 are not permitted for Y. Permitted values depend on service user configuration.</td>\n    </tr>\n    <tr>\n        <td>45</td>\n        <td></td>\n        <td>Leave blank</td>\n        <td></td>\n    </tr>\n    <tr>\n        <td>46</td>\n        <td>Status</td>\n        <td>Optional. Values: 0, 3</td>\n        <td>Blank or 0 for creation, 3 to cancel, 0 to reinstate</td>\n    </tr>\n</table>\n\n<p>If SmartDebit is configured to generate the Bacs reference and a value is supplied in field 2 for creation then this value is stored as \"Customer ID\".</p>\n<p>An example of some well formatted payer file CREATE entries: </p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>,ABC123456,Ms Jones,123456,12345678,,,,,,,,,,Ms,Jane,Jones,,123 fake st,,,london,,nw6 4ed,UK,,,,,M,10.00,,,,,,,,,,,,,,,0 \n,ABC123457,MR SMITH,123456,12345678,,,,,,,,,,,Pete,Smith,,123 piper st,,,Plymouth,,po8 8ij,UK,,,,,M,10.00,,,,2019,06,15,,,,,,,,,\n</code></pre><p>Two new DDIs are created with the properties supplied.</p>\n<p>An example of some well formatted payer file UPDATE entries: </p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>,ABC123456,,,,,,,,,,,,,,James,Smith,,123 piper st,,,Plymouth,,\"po8 8ij\",UK,,,,,M,10.00,15.95,,,2019,06,15,,,,,,,,,\n,\"ABC123457\",,,,,,,,,,,,,,\"J\",\"Smith\",,\"Central sqr\",\"\",,\"Dover\",,\"dv1 8ij\",\"UK\",,,,,\"M\",\"10.00\",,,,2019,06,15,,,,,,,,3\n</code></pre><p>These two entries update the DDIs 'ABC123456' and 'ABC123457' respectively, overwriting any existing values.  The second entry cancels DDI 'ABC123457' as the status has the value '3'.</p>\n","event":[{"listen":"prerequest","script":{"id":"b0f30723-ce41-4897-8416-5e5197704e4e","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"34e6b07b-72bd-46b4-a796-fd79c5f9af3d","type":"text/javascript","exec":[""]}}],"_postman_id":"af952adc-d8b5-412c-96e6-e1064bd7a70d"},{"name":"5.2 Collection file format","item":[],"id":"7c167ef6-c64a-4f88-a592-4e422b2bc719","description":"<p>A collection file is a CSV file containing seven fields, though only three values are required. Values may be wrapped in double quotes.</p>\n<p>The CSV fields are as follows:</p>\n<table>\n    <tr>\n        <th>Field</th>\n        <th>Field name</th>\n        <th>Restrictions</th>\n        <th>Comments</th>\n    </tr>\n    <tr>\n        <td>1</td>\n        <td></td>\n        <td>Leave blank</td>\n        <td></td>\n    </tr>\n    <tr>\n        <td>2</td>\n        <td>Reference number</td>\n        <td>Required. Length: 6 - 18 characters.</td>\n        <td>Must match the reference number of an existing DDI</td>\n    </tr>\n    <tr>\n        <td>3</td>\n        <td>Amount</td>\n        <td>Required. Decimal number with two decimal point precision (or integer for whole pounds).</td>\n        <td>Amount is in pounds. No currency symbol. No thousands separator.</td>\n    </tr>\n    <tr>\n        <td>4</td>\n        <td>Due date</td>\n        <td>Required. Format: YYYY/MM/DD or YY/MM/DD or YYYYMMDD or YYMMDD.</td>\n        <td></td>\n    </tr>\n    <tr>\n        <td>5</td>\n        <td>Comments</td>\n        <td>Length: 0 – 64 characters</td>\n        <td></td>\n    </tr>\n    <tr>\n        <td>6</td>\n        <td>Collection reference</td>\n        <td>Length: 0 – 18 characters</td>\n        <td>Format: reference number (field 2) followed by hyphen (-) followed by payment identifier e.g. ABC123456-AUG</td>\n    </tr>\n    <tr>\n        <td>7</td>\n        <td></td>\n        <td>Leave blank</td>\n        <td></td>\n    </tr>\n</table>\n\n<p><strong>IMPORTANT NOTE:</strong><br />A collection file entry with a reference number and date that matches an existing collection updates the existing collection. You cannot specify two separate collections on the same date. Instead, either specify the sum or use a different collection date. If a collection file contains two collections for the same payer for the same date, the result is only one collection which in most cases will be the second one.</p>\n<p>The <strong>comments</strong> field is not submitted to Bacs and is not reported by either collection report. </p>\n<p>Where used, the <strong>collection reference</strong> is submitted to Bacs. Thus, it must adhere to the <a href=\"#4d8a7173-5301-41e1-b171-7d4fde1fef6b\">reference number rules</a>. This field was formerly known as \"user format debit reference\". It is reported by <a href=\"#9c7048af-9192-420d-b2d7-adfe30ea3385\">get_collection_report</a> and <a href=\"#f1e498d3-1a90-42b0-85f1-8cbbda55898e\">get_successful_collection_report</a> as \"transaction_ref\". If the collection fails, the ARUDD reports the collection reference in place of the DDI's reference number. ADDACS advices may also report the last-used collection reference in place of the DDI's reference number.</p>\n<p>The <strong>collection reference</strong> allows a collection to be identified uniquely if the amount and date are not sufficient. For example, it could identify an invoice number where the DDI's reference number denotes the customer account.</p>\n<p>Where several services are supplied to a customer, use of the <strong>collection reference</strong> to distinguish between those services is discouraged because it is not possible to cancel one service without cancelling them all.</p>\n<p>If a collection is re-presented, the <strong>collection reference</strong> does not carry across to the re-present.</p>\n<p>Examples of some well-formatted collection file entries: </p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>,ABC123456,49.95,2019/06/15,,,\n,”ABC123457”,”15”,”19/06/15”,,,\n</code></pre><p>These examples show that the format can be thought of as a reference, amount and date (where the year precedes the month and day) preceded by a comma and followed by three commas. Despite this simplicity, problems frequently occur when the data are derived from an Excel spreadsheet:</p>\n<ul>\n<li>the first and last columns are easily lost</li>\n<li>leading zeros may be lost from reference numbers</li>\n<li>long reference numbers consisting only of numerals may be converted to scientific notation</li>\n<li>the date format may be transposed</li>\n</ul>\n","event":[{"listen":"prerequest","script":{"id":"5e9a5f6c-cfe1-4c71-8cb8-d67165ab9430","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"069012f7-96f7-4bc5-9995-a69f2c5dea5c","type":"text/javascript","exec":[""]}}],"_postman_id":"7c167ef6-c64a-4f88-a592-4e422b2bc719"},{"name":"5.3 Reference number rules","item":[],"id":"4d8a7173-5301-41e1-b171-7d4fde1fef6b","description":"<p>The reference number is used to identify a DDI within the SmartDebit system and within the wider banking system. A valid reference number must:</p>\n<ul>\n<li>comprise only <a href=\"#86a42735-f1f4-4bb2-a135-81860b0f1313\">valid characters</a></li>\n<li>be between 6 and 18 characters long (only alphanumeric characters are considered in checking the minimum length)</li>\n<li>be unique for the service user and SUN - the uniqueness test is case-insensitive and includes cancelled payers</li>\n<li>begin with an alpahnumeric</li>\n<li>not begin \"DDIC\"</li>\n<li>not begin or end with a space</li>\n<li>not consist of all the same character (e.g. all zeros)</li>\n<li>not match another reference for the same service user and the same payer’s bank account in whole or in part</li>\n<li>(in the case of a signed DDI) exactly match that on the signed DDI</li>\n</ul>\n<p>These rules are not all rigorously enforced by SmartDebit. Non-compliant references are likely to result in an AUDDIS advice and an uncollectible DDI.</p>\n<p>References cannot be re-used.</p>\n<p>The character and length restrictions also apply to the collection reference.</p>\n<p>Ampersands in reference numbers must be URL encoded when they form part of a call's URL.</p>\n<p>Because this reference is submitted to Bacs, it is often referred to as the \"Bacs reference\".</p>\n","event":[{"listen":"prerequest","script":{"id":"ccc53059-5251-4f34-9abc-a917f3b10172","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"2c40c864-a599-472b-ae45-b9996d1f51d0","type":"text/javascript","exec":[""]}}],"_postman_id":"4d8a7173-5301-41e1-b171-7d4fde1fef6b"},{"name":"5.4 Valid characters","item":[],"id":"86a42735-f1f4-4bb2-a135-81860b0f1313","description":"<p>Valid characters include all letters (aA to zZ), numbers and the following:</p>\n<ul>\n<li>space ( )</li>\n<li>ampersand (&amp;)</li>\n<li>hyphen (-)</li>\n<li>solidus (/)</li>\n<li>full stop (.)</li>\n</ul>\n<p>If reference numbers contain solidus then they must be urlencoded in the <em>update</em> and <em>cancel</em> calls. This is because the reference number forms part of the URI.</p>\n<p>All valid email characters are allowed in the email address field.</p>\n","event":[{"listen":"prerequest","script":{"id":"099f2b7a-d26b-47f0-b02c-e2f651b60b18","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"220bab23-fa5d-495f-9858-fa000f243c9d","type":"text/javascript","exec":[""]}}],"_postman_id":"86a42735-f1f4-4bb2-a135-81860b0f1313"}],"id":"d5a84235-9fa6-460e-aef3-df07145fc47f","_postman_id":"d5a84235-9fa6-460e-aef3-df07145fc47f","description":""},{"name":"6 Client code examples","item":[{"name":"6.1 Ruby client","item":[],"id":"220a488f-4682-4dce-b51c-8cd91c3689de","description":"<p>The following Ruby example uses core ruby classes. As the details of the SmartDebit API are modelled on the Rails ActiveResource pattern future versions of the API should work with an appropriately configured ActiveResource model.</p>\n<p><strong>Creating a Variable DDI using form parameters</strong></p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>def create\n    parsed_uri = URI.parse(\n        \"https://secure.ddprocessing.co.uk/api/ddi/variable/create\"\n    )\n\n    req = Net::HTTP::Post.new(\n        parsed_uri.path.blank? ? \"/\" : parsed_uri.path, \n        {\n            \"accept\" =&gt; \"application/XML\",\n            \"User-Agent\" =&gt; \"XYZ Co's Ruby SmartDebit Client\"\n        }\n    )\n\n    req.set_form_data({\n        'variable_ddi[service_user][pslid]' =&gt; \"su_pslid\",\n        'variable_ddi[reference_number]'    =&gt; \"ABC123456\",\n        'variable_ddi[first_name]'          =&gt; \"John\",\n        'variable_ddi[last_name]'           =&gt; \"Smith\",\n        'variable_ddi[address_1]'           =&gt; \"123 Fake St\",\n        'variable_ddi[town]'                =&gt; \"London\",\n        'variable_ddi[postcode]'            =&gt; \"se3 3ed\",\n        'variable_ddi[country]'             =&gt; \"United Kingdom\",\n        'variable_ddi[account_name]'        =&gt; \"John Smith\",\n        'variable_ddi[sort_code]'           =&gt; \"401223\",\n        'variable_ddi[account_number]'      =&gt; \"12345678\",\n        'variable_ddi[payer_reference]'     =&gt; \"external54321\",\n        'variable_ddi[regular_amount]'      =&gt; 1000,\n        'variable_ddi[frequency_type]'      =&gt; \"M\"\n    }, '&amp;')\n\n    req.basic_auth \"apiuser\", \"api864\"\n\n    http = Net::HTTP.new(parsed_uri.host, parsed_uri.port)\n    http.use_ssl = true if parsed_uri.port == 443\n\n    response = http.start {|h| h.request(req) }\n    \n    case response\n    when Net::HTTPSuccess\n\n        puts \"Direct Debit Instruction created in SmartDebit\"\n    \n        idd_ref = \"\"\n        # extract ddi information\n        doc = REXML::Document.new(response.body)\n        doc.elements.each('variable_ddi/reference_number') do |ele|\n            idd_ref = ele.text\n        end\n\n        puts \"(iDD Reference #{idd_ref})\"\n\n    when Net::HTTPClientError\n\n        puts \"Unable to Create DDI:\\nHTTP Code #{response.code} #{response.message}\"\n    \n        doc = REXML::Document.new(response.body)\n        doc.elements.each('errors/error') do |ele|\n            puts \"  Error #{ele.text}\"\n        end\n\n    end\nend\n</code></pre><p><strong>Creating a Variable DDI using XML Body</strong></p>\n<p>The parameters to any SmartDebit API call can be passed in the form of an XML body. To use this feature the Content-Type of the request must be set to application/XML. This feature is of most use when initial debits are being set as it clearly groups the debit dates and amounts. An example of this is shown below under ‘Creating an Adhoc DDI w/ initial debits using XML Body’.</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>def create\n    parsed_uri = URI.parse(\n        \"https://secure.ddprocessing.co.uk/api/ddi/variable/create\"\n    )\n    \n    req = Net::HTTP::Post.new(\n        parsed_uri.path,\n        {\n            \"accept\" =&gt; \"application/XML\",\n            \"Content-Type\" =&gt; \"application/XML\",\n            \"User-Agent\" =&gt; \"XYZ Co's Ruby SmartDebit Client\"\n        }\n    )\n    \n    XML_body = \"\"\n    XML_body &lt;&lt; \"&lt;?XML version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?&gt;\\n\"\n    XML_body &lt;&lt; \"&lt;variable_ddi&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;reference_number&gt;ABC123456&lt;/reference_number&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;first_name&gt;John&lt;/first_name&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;last_name&gt;Smith&lt;/last_name&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;address_1&gt;123 Fake St&lt;/address_1&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;town&gt;London&lt;/town&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;postcode&gt;se3 3ed&lt;/postcode&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;country&gt;United Kingdom&lt;/country&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;account_name&gt;John Smith&lt;/account_name&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;sort_code&gt;401223&lt;/sort_code&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;account_number&gt;12345678&lt;/account_number&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;payer_reference&gt;external54321&lt;/payer_reference&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;default_amount&gt;1000&lt;/default_amount&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;frequency_type&gt;M&lt;/frequency_type&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;service_user&gt;&lt;pslid&gt;su_pslid&lt;/pslid&gt;&lt;/service_user&gt;\\n\"\n    XML_body &lt;&lt; \"&lt;/variable_ddi&gt;\"\n    \n    req.body = XML_body\n    req.basic_auth \"apiuser\", \"api864\"\n\n    http = Net::HTTP.new(parsed_uri.host, parsed_uri.port)\n    http.use_ssl = true if parsed_uri.port == 443\n    \n    response = http.start {|h| h.request(req) }\n    \n    case response\n    when Net::HTTPSuccess\n    \n        puts \"Direct Debit Instruction created in SmartDebit\"\n\n        ddi_reference_number = \"\"\n        # extract ddi information\n        doc = REXML::Document.new(response.body)\n        doc.elements.each('variable_ddi/reference_number') do |ele|\n            ddi_reference_number = ele.text\n        end\n\n        puts \"(iDD Reference Number #{ddi_reference_number})\"\n\n    when Net::HTTPClientError\n\n        puts \"Unable to Create DDI:\\nHTTP Code #{response.code} #{response.message}\"\n            \n        doc = REXML::Document.new(response.body)\n        doc.elements.each('errors/error') do |ele|\n            puts \"  Error #{ele.text}\"\n        end\n\n    end\nend\n</code></pre><p><strong>Creating an Adhoc DDI with initial debits using form parameters</strong></p>\n<p>To create an Adhoc DDI with initial debits using form parameters, repeated instances of the same parameters need to be passed. In Ruby 1.8.5 the Net::HTTP::Post.set_form_data method does not support arrays (and a Ruby hash does not support multiple identical keys) so the form data needs to be compiled manually.</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>def create\n    parsed_uri = URI.parse(\n        \"https://secure.ddprocessing.co.uk/api/ddi/adhoc/create\"\n    )\n\n    req = Net::HTTP::Post.new(\n        parsed_uri.path.blank? ? \"/\" : parsed_uri.path, \n        {\n            \"accept\" =&gt; \"application/XML\",\n            \"User-Agent\" =&gt; \"XYZ Co's Ruby SmartDebit Client\"\n        }\n    )\n    \n    # Net::HTTP::Post.set_form_data does not support arrays in Ruby 1.8.5\n    form_data = []\n    form_data &lt;&lt; \"adhoc_ddi[service_user][pslid]=su_pslid\"\n    form_data &lt;&lt; \"adhoc_ddi[reference_number] = ABC123456\"\n    form_data &lt;&lt; \"adhoc_ddi[first_name]=John\"\n    form_data &lt;&lt; \"adhoc_ddi[last_name]=Smith\"\n    form_data &lt;&lt; \"adhoc_ddi[address_1]=123 Fake St\"\n    form_data &lt;&lt; \"adhoc_ddi[town]=London\"\n    form_data &lt;&lt; \"adhoc_ddi[postcode]=se3 3ed\"\n    form_data &lt;&lt; \"adhoc_ddi[country]=United Kingdom\"\n    form_data &lt;&lt; \"adhoc_ddi[account_name]=John Smith\"\n    form_data &lt;&lt; \"adhoc_ddi[sort_code]=401223\"\n    form_data &lt;&lt; \"adhoc_ddi[account_number]=12345678\"\n    form_data &lt;&lt; \"adhoc_ddi[start_date]=2019-05-23\"\n    form_data &lt;&lt; \"adhoc_ddi[debits][debit][][amount]=500\"\n    form_data &lt;&lt; \"adhoc_ddi[debits][debit][][date]=2019-05-23\"\n    form_data &lt;&lt; \"adhoc_ddi[debits][debit][][amount]=1500\"\n    form_data &lt;&lt; \"adhoc_ddi[debits][debit][][date]=2019-06-01\"\n    form_data &lt;&lt; \"adhoc_ddi[debits][debit][][amount]=1500\"\n    form_data &lt;&lt; \"adhoc_ddi[debits][debit][][date]=2019-07-01\"\n    \n    req.body = form_data.join(\"&amp;\")\n\n    req.basic_auth \"apiuser\", \"api864\"\n\n    http = Net::HTTP.new(parsed_uri.host, parsed_uri.port)\n    http.use_ssl = true if parsed_uri.port == 443\n\n    response = http.start {|h| h.request(req) }\n    \n    case response\n\n    when Net::HTTPSuccess\n\n        puts \"Direct Debit Instruction created in SmartDebit\"\n\n        ddi_reference_number = \"\"\n        # extract ddi information\n        doc = REXML::Document.new(response.body)\n        doc.elements.each('adhoc_ddi/reference_number') do |ele|\n            ddi_reference_number = ele.text\n        end\n\n        puts \"(iDD Reference Number #{ddi_reference_number})\"\n\n    when Net::HTTPClientError\n\n        puts \"Unable to Create DDI:\\nHTTP Code #{response.code} #{response.message}\"\n            \n        doc = REXML::Document.new(response.body)\n        doc.elements.each('errors/error') do |ele|\n            puts \"  Error #{ele.text}\"\n        end\n        \n    end\nend\n</code></pre><p><strong>Creating an Adhoc DDI with initial debits using XML Body</strong></p>\n<p>The parameters to any SmartDebit API call can be passed in the form of an XML body. To use this feature the Content-Type of the request must be set to application/XML. This feature is of most use when initial debits are being set, as it clearly groups the debit dates and amounts.</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>def create\n    parsed_uri = URI.parse(\n        \"https://secure.ddprocessing.co.uk/api/ddi/adhoc/create\"\n    )\n    \n    req = Net::HTTP::Post.new(\n        parsed_uri.path, \n        {\n            \"accept\" =&gt; \"application/XML\",\n            \"Content-Type\" =&gt; \"application/XML\",\n            \"User-Agent\" =&gt; \"XYZ Co's Ruby SmartDebit Client\"\n        }\n    )\n    \n    XML_body = \"\"\n    XML_body &lt;&lt; \"&lt;?XML version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?&gt;\\n\"\n    XML_body &lt;&lt; \"&lt;adhoc_ddi&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;reference_number&gt;ABC123456&lt;/reference_number&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;first_name&gt;John&lt;/first_name&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;last_name&gt;Smith&lt;/last_name&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;address_1&gt;123 Fake St&lt;/address_1&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;town&gt;London&lt;/town&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;postcode&gt;se3 3ed&lt;/postcode&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;country&gt;United Kingdom&lt;/country&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;account_name&gt;John Smith&lt;/account_name&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;sort_code&gt;401223&lt;/sort_code&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;account_number&gt;12345678&lt;/account_number&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;payer_reference&gt;external54321&lt;/payer_reference&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;start_date&gt;2019-05-23&lt;/start_date&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;debits&gt;\\n\"\n    XML_body &lt;&lt; \"    &lt;debit&gt;\\n\"\n    XML_body &lt;&lt; \"      &lt;amount&gt;500&lt;/amount&gt;&lt;date&gt;2019-05-23&lt;/date&gt;\\n\"\n    XML_body &lt;&lt; \"    &lt;/debit&gt;\\n\"\n    XML_body &lt;&lt; \"    &lt;debit&gt;\\n\"\n    XML_body &lt;&lt; \"      &lt;amount&gt;1500&lt;/amount&gt;&lt;date&gt;2019-06-01&lt;/date&gt;\\n\"\n    XML_body &lt;&lt; \"    &lt;/debit&gt;\\n\"\n    XML_body &lt;&lt; \"    &lt;debit&gt;\\n\"\n    XML_body &lt;&lt; \"      &lt;amount&gt;1500&lt;/amount&gt;&lt;date&gt;2019-07-01&lt;/date&gt;\\n\"\n    XML_body &lt;&lt; \"    &lt;/debit&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;/debits&gt;\\n\"\n    XML_body &lt;&lt; \"  &lt;service_user&gt;&lt;pslid&gt;su_pslid&lt;/pslid&gt;&lt;/service_user&gt;\\n\"\n    XML_body &lt;&lt; \"&lt;/adhoc_ddi&gt;\"\n    \n    req.body = XML_body\n\n    req.basic_auth \"apiuser\", \"api864\"\n\n    http = Net::HTTP.new(parsed_uri.host, parsed_uri.port)\n    http.use_ssl = true if parsed_uri.port == 443\n    \n    response = http.start {|h| h.request(req) }\n    \n    case response\n    when Net::HTTPSuccess\n\n        puts \"Direct Debit Instruction created in SmartDebit\"\n        ddi_reference_number = \"\"\n        # extract ddi information\n        doc = REXML::Document.new(response.body)\n        doc.elements.each('adhoc_ddi/reference_number') do |ele|\n            ddi_reference_number = ele.text\n        end\n\n        puts \"(iDD Reference Number #{ddi_reference_number})\"\n\n    when Net::HTTPClientError\n\n        puts \"Unable to Create DDI:\\nHTTP Code #{response.code} #{response.message}\"\n            \n        doc = REXML::Document.new(response.body)\n        doc.elements.each('errors/error') do |ele|\n                puts \"  Error #{ele.text}\"\n        end\n\n    end\nend\n</code></pre>","event":[{"listen":"prerequest","script":{"id":"a9335a3f-d604-4dd5-9518-0b013ccfaa53","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"5aeac109-dc64-4e3b-9ef6-a5fd759b47dd","type":"text/javascript","exec":[""]}}],"_postman_id":"220a488f-4682-4dce-b51c-8cd91c3689de"},{"name":"6.2 PHP client","item":[],"id":"7692a8b5-0afa-4bb0-9f08-1818ca3ecc96","description":"<p>This example uses Curl to create a Direct Debit Instruction using request parameters.</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;?php\n\n    $request_host = 'https://secure.ddprocessing.co.uk';\n    $request_path = '/api/ddi/variable/create';\n    \n    $user         = \"apiuser\";\n    $password     = \"api864\";\n    \n    $options      = array(\n        CURLOPT_RETURNTRANSFER =&gt; true, // return web page\n        CURLOPT_HEADER =&gt; false, // don't return headers\n        CURLOPT_POST =&gt; true,\n        CURLOPT_USERPWD =&gt; $user . \":\" . $password,\n        CURLOPT_HTTPAUTH =&gt; CURLAUTH_BASIC,\n        CURLOPT_HTTPHEADER =&gt; array(\"Accept: application/XML\"),\n        CURLOPT_USERAGENT =&gt; \"XYZ Co's PHP iDD Client\" // Let SmartDebit see who we are\n    );\n    \n    $session      = curl_init($request_host . $request_path);\n    curl_setopt_array($session, $options);\n    \n    // tell cURL to accept an SSL certificate if presented\n    if (preg_match(\"/^https/\", $request_host)) {\n        curl_setopt($session, CURLOPT_SSL_VERIFYHOST, false);\n        curl_setopt($session, CURLOPT_SSL_VERIFYPEER, false);\n    }\n    \n    // The request parameters\n    $pslid            = 'testcustomer';\n    $reference_number = \"ABC123456\";\n    $payer_ref        = 'PHP-12345';\n    $first_name       = 'John';\n    $last_name        = 'Smith';\n    $address_1        = \"123 Fake St\";\n    $town             = \"London\";\n    $postcode         = \"se3 3ed\";\n    $country          = \"United Kingdom\";\n    $account_name     = \"John Smith\";\n    $sort_code        = \"401223\";\n    $account_number   = \"12345678\";\n    $regular_amount   = 1000;\n    $frequency_type   = \"M\";\n    \n    // urlencode and concatenate the POST arguments\n    $postargs = 'variable_ddi[service_user][pslid]=' . $pslid;\n    $postargs .= \"&amp;variable_ddi[reference_number]=\" . urlencode($reference_number);\n    $postargs .= '&amp;variable_ddi[payer_reference]=' . urlencode($payer_ref);\n    $postargs .= '&amp;variable_ddi[first_name]=' . urlencode($first_name);\n    $postargs .= '&amp;variable_ddi[last_name]=' . urlencode($last_name);\n    $postargs .= '&amp;variable_ddi[address_1]=' . urlencode($address_1);\n    $postargs .= '&amp;variable_ddi[town]=' . urlencode($town);\n    $postargs .= '&amp;variable_ddi[postcode]=' . urlencode($postcode);\n    $postargs .= '&amp;variable_ddi[country]=' . urlencode($country);\n    $postargs .= '&amp;variable_ddi[account_name]=' . urlencode($account_name);\n    $postargs .= '&amp;variable_ddi[sort_code]=' . urlencode($sort_code);\n    $postargs .= '&amp;variable_ddi[account_number]=' . urlencode($account_number);\n    $postargs .= '&amp;variable_ddi[regular_amount]=' . urlencode($regular_amount);\n    $postargs .= '&amp;variable_ddi[frequency_type]=' . urlencode($frequency_type);\n    \n    // Tell curl that this is the body of the POST\n    curl_setopt($session, CURLOPT_POSTFIELDS, $postargs);\n    \n    // $output contains the output string\n    $output = curl_exec($session);\n    $header = curl_getinfo($session);\n    \n    if (curl_errno($session)) {\n        echo 'Curl error: ' . curl_error($session);\n    } else {\n        switch ($header[\"http_code\"]) {\n            case 200:\n                echo \"Variable DDI created\";\n                break;\n            default:\n                echo \"HTTP Error: \" . $header[\"http_code\"];\n        }\n    }\n    \n    // close curl resource to free up system resources\n    curl_close($session);\n?&gt;\n</code></pre>","event":[{"listen":"prerequest","script":{"id":"ea40b343-5c80-495f-8d78-83d4e903dee4","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"92451797-e3bf-4225-b075-999dc317f045","type":"text/javascript","exec":[""]}}],"_postman_id":"7692a8b5-0afa-4bb0-9f08-1818ca3ecc96"},{"name":"6.3 .NET client","item":[],"id":"ebc741ea-b5ab-4255-8b98-aca5c9097cc4","description":"<p>This example validates a Variable DDI using either form data, an XML body or JSON body. Note that JSON is not supported at the time of writing.</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>const string user = \"apiuser\";\nconst string password = \"api864\";\nconst string pslid = \"su_pslid\";\n\n// Credentials will be added to the request header later using Basic authentication\nvar credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes($\"{user}:{password}\"));\n\nstring domain = \"https://sandbox.ddprocessing.co.uk/\";\nstring endPoint = \"api/ddi/variable/validate\"; // Consider versioning\nstring url = $\"{domain}{endPoint}\";\n\n// Set your form data - option 1\nvar formContent = new FormUrlEncodedContent(new[]\n{\n    new KeyValuePair&lt;string, string&gt;(\"variable_ddi[reference_number]\", \"ABC123456\"),\n    new KeyValuePair&lt;string, string&gt;(\"variable_ddi[first_name]\", \"John\"),\n    new KeyValuePair&lt;string, string&gt;(\"variable_ddi[last_name]\", \"Smith\"),\n    new KeyValuePair&lt;string, string&gt;(\"variable_ddi[address_1]\", \"123 Fake St\"),\n    new KeyValuePair&lt;string, string&gt;(\"variable_ddi[town]\", \"London\"),\n    new KeyValuePair&lt;string, string&gt;(\"variable_ddi[postcode]\", \"SE3 3ED\"),\n    new KeyValuePair&lt;string, string&gt;(\"variable_ddi[country]\", \"UK\"),\n    new KeyValuePair&lt;string, string&gt;(\"variable_ddi[account_name]\", \"John Smith\"),\n    new KeyValuePair&lt;string, string&gt;(\"variable_ddi[sort_code]\", \"000000\"),\n    new KeyValuePair&lt;string, string&gt;(\"variable_ddi[account_number]\", \"12345678\"),\n    new KeyValuePair&lt;string, string&gt;(\"variable_ddi[frequency_type]\", \"M\"),\n    new KeyValuePair&lt;string, string&gt;(\"variable_ddi[service_user][pslid]\", pslid)\n});\n\n// Set your XML body - option 2\nstring validatePayerXml = $@\"&lt;variable_ddi&gt;\n    &lt;reference_number&gt;ABC123456&lt;/reference_number&gt;\n    &lt;first_name&gt;John&lt;/first_name&gt;\n    &lt;last_name&gt;Smith&lt;/last_name&gt;\n    &lt;address_1&gt;123 Fake St&lt;/address_1&gt;\n    &lt;town&gt;London&lt;/town&gt;\n    &lt;postcode&gt;SE3 3ED&lt;/postcode&gt;\n    &lt;country&gt;UK&lt;/country&gt;\n    &lt;account_name&gt;John Smith&lt;/account_name&gt;\n    &lt;sort_code&gt;000000&lt;/sort_code&gt;\n    &lt;account_number&gt;12345678&lt;/account_number&gt;\n    &lt;frequency_type&gt;M&lt;/frequency_type&gt;\n    &lt;service_user&gt;\n        &lt;pslid&gt;{pslid}&lt;/pslid&gt;\n    &lt;/service_user&gt;\n&lt;/variable_ddi&gt;\";\n\n// Set your json body - option 3 (not currently supported)\nvar jsonValidate = new\n{\n    variable_ddi = new\n    {\n        first_name = \"John\",\n        last_name = \"Smith\",\n        address_1 = \"123 Fake St\",\n        town = \"London\",\n        postcode = \"SE3 3ED\",\n        country = \"UK\",\n        account_name = \"John Smith\",\n        sort_code = \"000000\",\n        account_number = \"12345678\",\n        frequency_type = \"M\",\n        service_user = new { pslid }\n    }\n};\n\nusing (var httpClientHandler = new HttpClientHandler())\n{\n    httpClientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) =&gt; { return true; };\n\n    using (HttpClient client = new HttpClient(httpClientHandler))\n    {\n        // Add credentials to the header\n        client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(\"Basic\", credentials);\n\n        // Option 1: form data\n        Task&lt;HttpResponseMessage&gt; getStringTask = client.PostAsync(url, formContent);\n\n        //// Option 2: content-type application/xml\n        //HttpContent httpContent = new StringContent(validatePayerXml, Encoding.UTF8, \"application/xml\"); \n        //Task&lt;HttpResponseMessage&gt; getStringTask = client.PostAsync(url, httpContent);\n\n        //// Option 3: content-type application/json (not currently available)\n        //string json = JsonConvert.SerializeObject(jsonValidate, Formatting.Indented);\n        //HttpContent httpContent = new StringContent(json, Encoding.UTF8, \"application/json\");\n        //Task&lt;HttpResponseMessage&gt; getStringTask = client.PostAsync(url, httpContent);\n\n        try\n        {\n            HttpResponseMessage response = await getStringTask;\n\n            string result;\n\n            using (var stream = await response.Content.ReadAsStreamAsync())\n            using (var reader = new StreamReader(stream))\n            {\n                result = reader.ReadToEnd();\n            }\n\n            if (response.StatusCode == HttpStatusCode.OK\n                || response.StatusCode == HttpStatusCode.Created\n                || response.StatusCode == HttpStatusCode.Accepted)\n            {\n                Console.WriteLine(result);\n            }\n\n            response.EnsureSuccessStatusCode();\n        }\n        catch (Exception e)\n        {\n            Console.WriteLine(e);\n            throw;\n            // log the exception appropriately \n        }\n    }\n}\n</code></pre>","event":[{"listen":"prerequest","script":{"id":"7c727015-e8ec-4208-b234-a21ae6180ab9","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"fc91728e-8ef1-4a81-a842-f2a1fcdb61d7","type":"text/javascript","exec":[""]}}],"_postman_id":"ebc741ea-b5ab-4255-8b98-aca5c9097cc4"}],"id":"ca31fecb-3593-4ea1-b874-5f88291ce75e","description":"<p>The SmartDebit API can be easily accessed from a number of languages. This section contains examples for Ruby, PHP and .NET. Note that these are very simplistic examples which would need to be adapted to your own coding standards for use.</p>\n","event":[{"listen":"prerequest","script":{"id":"4135b890-600d-4574-b1d9-59b825459667","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"2a10e8e9-3f8b-43d7-bfe4-33da55e234b8","type":"text/javascript","exec":[""]}}],"_postman_id":"ca31fecb-3593-4ea1-b874-5f88291ce75e"},{"name":"7 Public facing DDI sign-up","item":[{"name":"7.1 Internet sign-up screens","item":[],"id":"336500b5-c127-4594-83d1-5d3e14a0b060","description":"<p>In order to provide a public-facing internet Direct Debit script a number of mandatory requirements must be observed. The below is adapted from Bacs’ own guidelines. Visual examples are included in Section 8.2 and we would recommend that your own screens are based closely on these as any deviations might need further bank approval.</p>\n<p><strong>The following are suggested screen prompts for customers accessing an internet site or approved device for Direct Debit sign-up. Service users may be working with internet agencies or other experienced developers, but if not, they should use these scripts verbatim.</strong></p>\n<p><strong>Rule: All service users must include the following mandatory items within their screens hence these are the minimum requirements:</strong></p>\n<ul>\n<li>SSL server security must be present and must be a minimum of SHA-256 SSL supporting TLS 1.2.</li>\n<li>A postal and / or email address must be provided to the payer</li>\n<li>A general enquiries / customer service contact number and / or the provision of a live chat facility must be given to assist the payer with any urgent issues or complaints</li>\n<li>Verification that the customer is the account holder and therefore the payer. If the customer is not the account holder a paper DDI must be sent to the payer for completion or a copy must be available for printing.\nNote: The service user may, however, choose not to offer the option of a paper DDI. In such instances, customers would not be able to purchase the services offered using Direct Debit as a payment method. This is a service user’s business decision and is considered to be outside of the Direct Debit Scheme.</li>\n<li>Taking the payer’s bank or building society account number, sort code and account name</li>\n<li>Confirmation that the person entering into the transaction is the only person required to authorise debits from the account. If more than one person has to authorise debits from the account, a paper DDI must be sent to the payer for completion. Exceptions apply to service users using electronic signature as a method of sign-up. A copy complying with the mandatory format must be available for printing by the payer. Failure to obtain the correct authority could result in an increased risk of indemnity claims being received.</li>\n<li>Confirmation of bank details back to the payer</li>\n<li>A copy of the Direct Debit Guarantee including advice of the advance notice period and of the company name that will appear against the Direct Debit on the payer’s bank statement</li>\n</ul>\n<p><b>Guidance</b>: The information required to complete the DDI does not need to be captured directly onto an on-screen DDI, but once completed service users may wish to display a copy of the completed DDI.</p>\n<p>Assuming the payer has agreed to the setting up of a Direct Debit and the payment amount to be debited has been agreed:</p>\n<p><strong>Stage one: Opening</strong></p>\n<p>Direct Debits can be set up online or over the telephone in addition to the postal method.</p>\n<p>The Direct Debit safeguards and guarantees apply. No changes in the amount, date or frequency to be debited can be made without notifying you at least XX working days in advance of your account being debited. In the event of any error being made in the payment of your Direct Debit, you are entitled to an immediate refund from your bank or building society. You have the right to cancel a Direct Debit Instruction at any time simply by writing to your bank or building society, with a copy to us.</p>\n<p><strong>Stage two: Sign up of bank details</strong></p>\n<p>In order to set up your Direct Debit Instruction online you will need to provide the following information through the setting up procedure (your cheque book or your bank statement contain all the bank details that you require):</p>\n<ul>\n<li>Your account number and sort code</li>\n<li>If you are not the account holder, a paper Direct Debit Instruction will be sent for completion (optional, see * below). Please click to end.</li>\n<li>If this is a personal account, continue with the set-up procedure</li>\n<li>If it is a business account, or more than one person is required to authorise debits on this account, a paper Direct Debit Instruction will be sent to the payers for completion (optional, see * below). Please click to end.</li>\n</ul>\n<p>Alternatively, you can print off your on-screen Direct Debit Instruction and post it to us. If you are unable to print please contact us on XXXXXX (tel no) and we will post you a paper Direct Debit Instruction (optional see * below).</p>\n<p>If you do not wish to proceed any further, please click to END.</p>\n<p>The details of your Direct Debit Instruction will be confirmed to you within 3 working days or no later than 10 working days before the first collection. Click the mouse on YES or NO to confirm details:</p>\n<p>YES (onto next stage)</p>\n<p>NO (redo form)</p>\n<p>CANCEL to stop the set-up procedure (go back to start page).</p>\n<p>* The service user may, however, choose not to offer the option of a paper DDI. In such instances, customers would not be able to purchase the services offered using Direct Debit as a payment method. This is a service user’s business decision and is considered to be outside of the Direct Debit Scheme.</p>\n<p><strong>Stage three: Reconfirming the details to the customer</strong></p>\n<p>These are the details that you have entered to set up the Direct Debit Instruction:</p>\n<p>Name of account holder</p>\n<p>Branch sort code /__ __/__ __/__ __/</p>\n<p>Bank account number /__/__/__/__/__/__/__/__/</p>\n<p>Amount to be debited from bank account (if known)\n£__/__/__/__/__/__/__/__.__/__/</p>\n<p>Date each month for collection (or other collection frequency) /__/__/</p>\n<p>The company name which will appear on your bank statement against the Direct Debit will be XXXXXXXX.</p>\n<p>Click mouse on YES or NO to confirm details:</p>\n<p>YES (onto next stage)</p>\n<p>NO (redo form)</p>\n<p>CANCEL to stop the set-up procedure (go back to start page).</p>\n<p><strong>Stage four: Address for the letter of confirmation</strong></p>\n<p>Your Direct Debit Instruction will be confirmed to you by e-mail within 3 working days. Alternatively, confirmation incorporating your advance notice will be available to you no later than XX (number of working days in accordance with advance notice period) working days prior to the first collection date. If you prefer to receive this by post please indicate the address you would like this to be sent to.</p>\n<p>____________________________________________________________<br />____________________________________________________________<br />____________________________________________________________<br />____________________________________________________________  </p>\n<p>Click for next stage (stage five)</p>\n<p><strong>STAGE FIVE: COMPLETING THE SIGN-UP</strong></p>\n<p>That completes the setting up of your Direct Debit Instruction and the confirmation of the Instruction will be sent to you within 3 working days or be received by you no later than 10 working days before the first collection.</p>\n<p>Thank you very much for your Direct Debit Instruction details. Here is the Direct Debit Guarantee for your information. (Direct Debit Guarantee appears on-screen).</p>\n","event":[{"listen":"prerequest","script":{"id":"7915f228-fecb-4a15-9961-e5ef09097117","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"2a13e47a-a928-491b-87ca-2932422ad445","type":"text/javascript","exec":[""]}}],"_postman_id":"336500b5-c127-4594-83d1-5d3e14a0b060"},{"name":"7.2 Example screens","item":[],"id":"4015b9fe-8bd1-473e-9df8-406696652f63","description":"<br />\n<p>\n<b>Suggested layout of internet script - page 1</b>\n<br /><br /><br />\n<img src=\"http://www.smartdebit.co.uk/wp-content/uploads/2019/05/Image-1.jpg\" width=\"600\" />\n</p>\n<br />\n<br />\n<p>\n<b>Suggested layout of internet script - page 2</b>\n<br /><br />\nIf the payer answers no to the questions on the previous screen, this screen is presented and a Direct Debit Instruction is available for printing.\n<br /><br />\n<img src=\"http://www.smartdebit.co.uk/wp-content/uploads/2019/05/Image-2.jpg\" width=\"600\" />\n</p>\n<br />\n<br />\nIf the payer answers yes to the questions on the first screen and proceeds with the set-up, they are asked to review and confirm the account details they have entered. If they have requested a paper DDI to be sent to them, they are also asked to confirm the postal address.\n<br />\n<br />\n<p>\n<b>Suggested layout of internet script - page 3</b>\n<br /><br /><br />\n<img src=\"http://www.smartdebit.co.uk/wp-content/uploads/2019/05/Image-3.jpg\" width=\"600\" />\n</p>\n<br />\n<br />\n<p>\n<b>Suggested layout of internet script - page 4</b>\n<br /><br /><br />\n<img src=\"http://www.smartdebit.co.uk/wp-content/uploads/2019/05/Image-4.jpg\" width=\"600\" />\n</p>\n<br />\n<br />\n<p>\n<b>Suggested layout of internet script - page 5</b>\n<br /><br /><br />\n<img src=\"http://www.smartdebit.co.uk/wp-content/uploads/2019/05/Image-5.jpg\" width=\"600\" />\n</p>\n<br />\n<br />\n<p>\n<b>Suggested layout of internet script - page 6</b>\n<br /><br /><br />\n<img src=\"http://www.smartdebit.co.uk/wp-content/uploads/2019/05/Image-6.jpg\" width=\"600\" />\n</p>","event":[{"listen":"prerequest","script":{"id":"6dd00505-6418-49a6-b094-2a94cd02765b","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"9497a2d4-c813-4590-a788-ab6a573a70d4","type":"text/javascript","exec":[""]}}],"_postman_id":"4015b9fe-8bd1-473e-9df8-406696652f63"}],"id":"c544fa20-2554-4bec-b25d-98af50f3b64f","event":[{"listen":"prerequest","script":{"id":"c43e9bfe-b887-4a72-8b09-bb7abeded139","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"f7ec0622-64bd-46d4-9e6d-efc3e2f9a74b","type":"text/javascript","exec":[""]}}],"_postman_id":"c544fa20-2554-4bec-b25d-98af50f3b64f","description":""},{"name":"8 Bacs reason codes","item":[],"id":"4855180e-d792-4547-bf87-667881b138bb","description":"<h4 id=\"addacs-reason-codes\">ADDACS reason codes</h4>\n<p>0 - Instruction cancelled - refer to payer</p>\n<p>1 - Instruction cancelled by payer</p>\n<p>2 - Payer deceased</p>\n<p>3 - Account transferred to another bank/building society</p>\n<p>B - Account closed</p>\n<p>C - Account transferred to a different branch of bank/building society</p>\n<p>D - Advance notice disputed</p>\n<p>E - Instruction amended</p>\n<p>R - Instruction reinstated</p>\n<h4 id=\"auddis-reason-codes\">AUDDIS reason codes</h4>\n<p>1 - Instruction cancelled by payer</p>\n<p>2 - Payer deceased</p>\n<p>3 - Account transferred to another bank/building society</p>\n<p>5 - No account</p>\n<p>6 - No Instruction</p>\n<p>7 - DDI amount not zero</p>\n<p>B - Account closed</p>\n<p>C - Account transferred to a different branch of bank/building society</p>\n<p>F - Invalid account type</p>\n<p>G - Bank will not accept Direct Debits on account</p>\n<p>H - Instruction expired</p>\n<p>I - Payer reference is not unique</p>\n<p>K - Instruction cancelled by bank</p>\n<p>L - Incorrect payer's account details</p>\n<p>M - Transaction code/User status incompatible</p>\n<p>N - Transaction disallowed at payer's branch</p>\n<p>O - Invalid reference</p>\n<p>P - Payer's name not present</p>\n<p>Q - Service user's name blank</p>\n<p>Codes 7 and L to Q are generated by the Bacs service and occur as a result of its validation of DDI records.</p>\n<h4 id=\"arudd-reason-codes\">ARUDD reason codes</h4>\n<p>0 - Refer to payer </p>\n<p>1 - Instruction cancelled</p>\n<p>2 - Payer deceased</p>\n<p>3 - Account transferred</p>\n<p>4 - Advance notice disputed</p>\n<p>5 - No account (or wrong account type)</p>\n<p>6 - No Instruction</p>\n<p>7 - Amount differs</p>\n<p>8 - Amount not yet due</p>\n<p>9 - Presentation overdue</p>\n<p>A - Service user differs</p>\n<p>B - Account closed</p>\n<p>Further detail about ARUDD reason codes can be found on <a href=\"https://www.smartdebit.co.uk/direct-debit-guides-and-resources/arudd-reason-codes/\">SmartDebit's website</a>.</p>\n","event":[{"listen":"prerequest","script":{"id":"100e2f81-e4f5-499c-96af-3dc63b0c0f38","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"db04896b-01bc-4a70-8932-7f2c14c861ce","type":"text/javascript","exec":[""]}}],"_postman_id":"4855180e-d792-4547-bf87-667881b138bb"},{"name":"9 API version history","item":[],"id":"605af7a4-5a20-41e1-8ff2-ff26f1b7d94a","description":"<table>\n<tr>\n    <td>API version</td>\n    <td>Date</td>\n    <td>Change description (reference)</td>\n</tr>\n<tr>\n    <td>v1.1</td>\n    <td>Mar 2019</td>\n    <td><li><a href=\"#f1e498d3-1a90-42b0-85f1-8cbbda55898e\">get_successful_collection_report</a> shows claimed collections as \"paid\" (8853)\n        </li><li><a href=\"#ebec5c28-3427-4f53-9887-c0ab817a9574\">indemnity/<i>{{id}}</i></a> response includes the correct number of &lt;DDICAdvice&gt; nodes (410)</li></td>\n</tr>\n<tr>\n    <td></td>\n    <td>Jan 2015</td>\n    <td>All changes up to document version 1.21</td>\n</tr>\n</table>","event":[{"listen":"prerequest","script":{"id":"b6dbfd88-9e0a-48b3-baa2-3ec0aa38293a","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"bac6ba67-df62-4bc3-b813-8f4706db56e2","type":"text/javascript","exec":[""]}}],"_postman_id":"605af7a4-5a20-41e1-8ff2-ff26f1b7d94a"},{"name":"10 Document version history","item":[],"id":"0953b9f0-283a-492d-8d16-7184a038ab9a","description":"<table>\n<tr>\n<td>Version</td><td>Date</td><td>Author</td><td>Change description (reference)</td>\n</tr>\n<tr>\n<td>2.3</td><td>Sep 2022</td><td>DP</td><td>SmartDebit is part of <a href=\"https://www.accesspaysuite.com/\">Access Paysuite Ltd</a>\n</td>\n</tr>\n<tr>\n<td>2.2</td><td>Jul 2021</td><td>DP</td><td>Refresh the <a href=\"#ebc741ea-b5ab-4255-8b98-aca5c9097cc4\">.NET code example</a>. <br />New advice on removing an end date with <a href=\"#42d76121-1dd6-4e0a-ab9b-6454d618b1b5\">variable update</a>.<br />Remove reference to TLS 1.1.</td>\n</tr>\n<tr>\n<td>2.1</td><td>Aug 2019</td><td>DP</td><td>Adds <a href=\"#e0acea5c-f440-40ab-9867-84b65c05f3bb\">variable reinstate</a> and <a href=\"#2a323a26-9acc-4f9e-8900-65e846eefd63\">adhoc reinstate</a> calls (10051)</td>\n</tr>\n<tr>\n<td>2.0</td><td>Jun 2019</td><td>DP</td><td>Document re-write: new structure, new sections, numerous corrections and clarifications.<br />Introduces API versioning.<br />API version 1.1.<br />Address fields are optional, address_1 allows up to 255 characters.<br />Allows solidus in reference numbers.<br />Adds support for large collection files.<br />Successful collection report referred to as reconciliation report.<br />Deprecations: see the <a href=\"#5bdf8c47-d604-4a15-95b5-8c2da05899aa\">audit log</a>, <a href=\"#2f6356dc-6e65-41fd-ad5f-7ef61521b2f3\">collection report</a>, <a href=\"#9050bf7f-c5c8-4c49-a192-8ae878151db2\">ddi/adhoc/validate</a> and <a href=\"#2b78be39-712e-407c-ab49-0dc19e43e322\">data/dump</a> sections.</td>\n</tr>\n<tr>\n<td>1.21</td><td>22/01/15</td><td>ND</td><td>Included successful collection report</td>\n</tr>\n<tr>\n<td>1.20 </td><td>29/09/14 </td><td>ND</td><td>Charge files now known as Collection Files</td>\n</tr>\n<tr>\n<td>1.19</td><td>01/09/14</td><td>ND</td><td>Removed restriction on hyphens in reference number</td>\n</tr>\n<tr>\n<td>1.18 </td><td>14/05/14 </td><td>ND</td><td>Included call to represent failed collection</td>\n</tr>\n<tr>\n<td>1.17 </td><td>03/03/14 </td><td>ND</td><td>Included collection report retrieve</td>\n</tr>\n<tr>\n<td>1.16</td><td>27/11/2013 </td><td>ND</td><td>Included account details for retrieve payer contact details</td>\n</tr>\n<tr>\n<td>1.15</td><td>19/08/2013</td><td>ND</td><td>Included frequency factoring</td>\n</tr>\n<tr>\n<td>1.15 </td><td>21/06/13 </td><td>ND</td><td>Included retrieval of Bacs DDICA reports</td>\n</tr>\n<tr>\n<td>1.14</td><td>12/06/12</td><td>ND</td><td>Removed Fixed Frequency Fixed Amount section and corrected some errors</td>\n</tr>\n<tr>\n<td>1.13</td><td>30/04/12 </td><td>ND</td><td>Added AUDDIS collection details</td>\n</tr>\n<tr>\n<td>1.12 </td><td>14/02/11 </td><td>ND</td><td>Audit log retrieval</td>\n</tr>\n<tr>\n<td>1.11</td><td>22/02/11</td><td>ND</td><td>Reference number format restrictions</td>\n</tr>\n<tr>\n<td>1.10</td><td>03/12/10</td><td>ND</td><td>Added extra column to Data Dump</td>\n</tr>\n<tr>\n<td>1.9</td><td>28/09/10</td><td>RD</td><td>Branding update to SmartDebit. Section 11 Contents wording updated</td>\n</tr>\n<tr>\n<td>1.8</td><td>31/03/10</td><td>RD/ND</td><td>Update Sections 9&amp;10</td>\n</tr>\n<tr>\n<td>1.7</td><td>05/03/10</td><td>ND</td><td>Added list of valid characters allowed for payer details. Added API call to retrieve payer contact details and status. Included bank details (name and branch of bank that holds the account) in Validation response. Added 'Support Gift Aid' param to create and update of DDI's.</td>\n</tr>\n<tr>\n<td>1.6</td><td>18/01/10</td><td>ND</td><td>Added warning to Charge File Import page to clarify the use of duplicate entries.</td>\n</tr>\n<tr>\n<td>1.5</td><td>29 Oct 2009</td><td>RC</td><td>Added asynchronous payer file import and ddi cancellation calls</td>\n</tr>\n<tr>\n<td>1.4</td><td>22 Oct 2009</td><td>RC</td><td>Added conditional parameters for DDI verification and creation.</td>\n</tr>\n<tr>\n<td>1.3</td><td>20 Oct 2009</td><td>RC/ ND</td><td>Added BACS Report Retrieval and sample .NET code</td>\n</tr>\n<tr>\n<td>1.2</td><td>29 June 2009</td><td>RC/ND</td><td>Added Service User’s Guide extract and screenshots from the iDD payer site as a guide for public facing DDI sign-ups</td>\n</tr>\n<tr>\n<td>1.1</td><td>14 April 2009</td><td>RC</td><td>Added detail for v1.1: update DDIs, import new payer file, import charge file.</td>\n</tr>\n<tr>\n<td>1.0</td><td>24 Mar 2009</td><td>RC</td><td>Added detail for creating initial debits with DDI creation, http status codes on return examples</td>\n</tr>\n<tr>\n<td>0.3</td><td>2 Mar 2009</td><td>RC</td><td>Added create and validate for Variable and Adhoc DDIs</td>\n</tr>\n<tr>\n<td>0.2</td><td>9 Feb 2009</td><td>RC</td><td>Added detail, initial iDD styling.</td>\n</tr>\n<tr>\n<td>0.1</td><td>3 Feb 2009</td><td>RC</td><td>Initial Draft for guide w/ system status, validate fixed, and create fixed.</td>\n</tr>\n</table>","event":[{"listen":"prerequest","script":{"id":"33e19bb5-bff2-4e83-9982-a00a4f87fd2a","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"42233a18-65db-4b88-b9b0-8255df961fab","type":"text/javascript","exec":[""]}}],"_postman_id":"0953b9f0-283a-492d-8d16-7184a038ab9a"},{"name":"11 Glossary","item":[],"id":"f8e07a45-2eed-47e3-a70f-60f1fc14d69c","description":"<h4 id=\"addacs---automated-direct-debit-amendment-and-cancellation-service\">ADDACS - Automated Direct Debit Amendment and Cancellation Service</h4>\n<p>An ADDACS advice is a notification from a bank of an amendment to or cancellation of a DDI. An ADDACS report may contain one or more ADDACS advices.</p>\n<h4 id=\"adhoc\">Adhoc</h4>\n<p>Processing model that does not support scheduled collections. If enabled, advance notice is sent for each collection. See also Variable.</p>\n<h4 id=\"arudd---automated-return-of-unpaid-direct-debit\">ARUDD - Automated Return of Unpaid Direct Debit</h4>\n<p>An ARUDD advice is a notification from a bank of a failed collection. An ARUDD report may contain one or more ARUDD advices. A failed collection is \"returned unpaid\" - it is literally taken from, and then returned to, the payer's account.</p>\n<h4 id=\"auddis---automated-direct-debit-instruction-service\">AUDDIS - Automated Direct Debit Instruction Service</h4>\n<p>An AUDDIS advice is a notification from Bacs or from a bank that a new DDI has not been set up or has been amended, or that a cancellation has failed. An AUDDIS report may contain one or more AUDDIS advices.</p>\n<h4 id=\"collection\">Collection</h4>\n<p>A single payment, or debit, from a payer’s bank account on a specific date.</p>\n<h4 id=\"customer-id\">Customer ID</h4>\n<p>A free text field available for use as required. Example uses are:</p>\n<ul>\n<li>to link to another system such as a CRM</li>\n<li>customer account number</li>\n<li>membership number and/or type</li>\n<li>source or referrer</li>\n</ul>\n<p>Customer ID is not subject to the same rules as the reference number. In most cases the field name is payer-reference or payer_reference (and payerReference in the data/dump response) but the collection reports present it as customer_id.</p>\n<h4 id=\"ddica---direct-debit-indemnity-claim-automation\">DDICA - Direct Debit Indemnity Claim Automation</h4>\n<p>A DDICA advice is a notification of an indemnity claim raised against a service user. A DDICA report may contain one or more DDICA advices.</p>\n<h4 id=\"direct-debit-instruction-ddi\">Direct Debit Instruction (DDI)</h4>\n<p>The DDI represents the authority given by the payer to the service user to collect monies from their bank account. The DDI is defined within the Bacs scheme by the the reference number, the payer's bank details and the service user's SUN. Within SmartDebit, additional attributes such as name and address, email address, and possibly a collection schedule are attached. Hence within SmartDebit the term \"payer\" may be used instead.</p>\n<h4 id=\"lead-times\">Lead times</h4>\n<p>The number of days that must be allowed between setting up a new payer (\"payer lead time\") or creating a collection (\"collection lead time\") and a collection taking place. May be calculated on a calendar or working day basis.</p>\n<h4 id=\"payer\">Payer</h4>\n<p>An organisation's customer, subscriber, member or donor (depending on the organisation’s business) who pays by Direct Debit. See also Direct Debit Instruction.</p>\n<h4 id=\"payer-reference\">Payer reference</h4>\n<p>See Customer ID.</p>\n<h4 id=\"pslid\">PSLID</h4>\n<p>A parameter used throughout the API to identify the service user.</p>\n<h4 id=\"reference-number\">Reference number</h4>\n<p>Often referred to as a Bacs reference, the reference number is used to identify the DDI within SmartDebit and by the paying bank. It does not have to be numeric but must conform to <a href=\"#4d8a7173-5301-41e1-b171-7d4fde1fef6b\">rules</a> stipulated by Bacs. In some places it may be referred to as the payer reference.</p>\n<h4 id=\"service-user\">Service user</h4>\n<p>The organisation that collects payments from its payers, identified throughout the API by its PSLID and within the Bacs scheme by its service user number (SUN).</p>\n<h4 id=\"service-user-number-sun\">Service user number (SUN)</h4>\n<p>The SUN identifies the service user within the Bacs scheme. The SUN can be considered to be the service user's licence to use the scheme, issued by their sponsoring bank. SUNs may sometimes be shared. The SUN is not a feature of the API.</p>\n<h4 id=\"variable\">Variable</h4>\n<p>Processing model that supports scheduled collections. If enabled, advance notice is sent at creation and subsequently only if the amount differs from the previous collection. See also Adhoc.</p>\n","event":[{"listen":"prerequest","script":{"id":"f2356db5-8335-4bca-bf18-2df2d4497bf5","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"ebdf9f41-baaa-4ac9-b83e-376fd9a9b13d","type":"text/javascript","exec":[""]}}],"_postman_id":"f8e07a45-2eed-47e3-a70f-60f1fc14d69c"},{"name":"12 API support","item":[],"id":"2bbace77-f8e7-40f1-9d9b-593df776f4fc","description":"<p>Call during business hours or email us for support:</p>\n<ul>\n<li><a href=\"mailto:support@smartdebit.com?Subject=API%20support\">support@smartdebit.com</a></li>\n<li>Customer support: <strong>01276 851820</strong></li>\n<li>Sales: <strong>01276 819291</strong></li>\n</ul>\n<p><br /></p><hr /><br />\nSmartDebit: an Access company. Access PaySuite Ltd - The Old School, Stratford St Mary, Colchester, Essex CO7 6LZ. Regulated as a Payment Institution by the Financial Conduct Authority - FRN: 730815 Company Reg. No. 4595169<p></p>\n","event":[{"listen":"prerequest","script":{"id":"4753418e-6d3f-41f8-ab6e-eee86fba1343","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"eeb8ecbd-58b8-4a03-81f6-d927434c568c","type":"text/javascript","exec":[""]}}],"_postman_id":"2bbace77-f8e7-40f1-9d9b-593df776f4fc"}],"event":[{"listen":"prerequest","script":{"id":"2b152d4d-a701-4c6e-b278-95831ad21202","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"9fb78779-6ceb-4492-ba44-9bdad030352e","type":"text/javascript","exec":[""]}}]}