# # File Payments - v4.0-draft1

- Overview
- Endpoints
  - POST /file-payments
  - GET /file-payments/{FilePaymentId}
    - StatusCode
  - GET /file-payments/{FilePaymentId}/report-file
  - GET /file-payments/{FilePaymentId}/payment-details
    - StatusCode
  - State Model
    - Payment Order
    - Multiple Authorisation
- Data Model
  - Reused Classes
    - OBFile2
  - File Payment - Request
    - UML Diagram
    - Notes
    - Data Dictionary
  - File Payment - Response
    - UML Diagram
    - Notes
    - Data Dictionary
  - File Payment - Payment Details - Response
    - UML Diagram
    - Data Dictionary
- Usage Examples
  - POST /file-payments
    - Request
    - Response

## # Overview

The File Payment resource is used by a PISP to initiate a File Payment.

This resource description should be read in conjunction with a compatible Payment Initiation API Profile.

## # Endpoints

Resource | HTTP Operation | Endpoint | Mandatory ? | Scope | Grant Type | Message Signing | Idempotency Key | Request Object | Response Object
--- | --- | --- | --- | --- | --- | --- | --- | --- | ---
file-payments | POST | POST /file-payments | Conditional | payments | Authorization Code | Signed Request Signed Response | Yes | OBWriteFile2 | OBWriteFileResponse3
file-payments | GET | GET /file-payments/{FilePaymentId} | Mandatory (if resource POST implemented) | payments | Client Credentials | Signed Response | No | NA | OBWriteFileResponse3
file-payments | GET | GET /file-payments/{FilePaymentId}/report-file | Conditional | payments | Client Credentials | Signed Response | No | NA | File
payment-details | GET | GET /file-payments/{FilePaymentId}/payment-details | Optional | payments | Client Credentials | Signed Response | No | NA | OBWritePaymentDetailsResponse1

### # POST /file-payments

Once the file-payment-consent has been authorised by the PSU, the PISP can proceed to submit the file-payment for processing:

- This is done by making a POST request to the file-payments endpoint.

#### # StatusCode

The file-payments resource must have one of the following initial StatusCodes:

StatusCode
RCVD
RJCT

### # GET /file-payments/{FilePaymentId}

A PISP can retrieve the file-payment to check its status.

#### # StatusCode

The file-payments resource must have one of the following initial StatusCodes:

StatusCode
RCVD
RJCT

### # GET /file-payments/{FilePaymentId}/report-file

The API endpoint allows the PISP to download a payment report file from an ASPSP.

- This endpoint enables ASPSP to return a report on the processing results of Payments in the file
- The file is sent in the HTTP response body.
- The file structure may match a payment execution report for the corresponding FileType in the file-payment-consent request.
- HTTP headers (e.g. Content-Type) are used to describe the file.

### # GET /file-payments/{FilePaymentId}/payment-details

A PISP can retrieve the Details of the underlying payment transaction(s) via this endpoint. This resource allows ASPSPs to return richer list of Payment Statuses, and if available payment scheme related statuses.

#### # StatusCode

The file-payments - payment-details must have one of the following ExternalPaymentGroupStatus1Code code-set enumerations (for more information see `ExternalPaymentGroupStatus1Code` here
(opens new window)) :

StatusCode
RCVD
PDNG
ACTC
PART
ACCP
ACFC
ACSP
ACWC
ACSC
ACCC
RJCT

Refer to External_Internal_CodeSets
(opens new window) -> ISO_External_CodeSet -> `ExternalPaymentGroupStatus1Code`.

### # State Model

#### # Payment Order

The state model for the file-payments resource describes the initiation status and the subsequent execution of the file-payments.

Payment order state model key:

Colour (Style) | Description
--- | ---
Green (Bold) | Mandatory
Orange (Italic) | Optional, but recommended

##### # Multiple Authorisation

If the payment-order requires multiple authorisations the status of the multiple authorisations will be updated in the MultiAuthorisation object.

Once the payment is RCVD, the file-payments StatusCode must be set to PATC and the MultiAuthorisation object status updated with the AWAF status. Once all authorisations have been successfully completed the MultiAuthorisation status must be set to AUTH and file-payments StatusCode updated to ACSP if any intermediate status are not supported.

Any rejections in the multiple authorisation process should result in the MultiAuthorisation status and StatusCode being set to RJCT.

| StatusCode | Status Description
--- | --- | ---
1 | AWAU | The payment-order resource is awaiting further authorisation.
2 | RJCT | The payment-order resource has been rejected by an authoriser.
3 | AUTH | The payment-order resource has been successfully authorised by all required authorisers.

## # Data Model

The data dictionary section gives the detail on the payload content for the File Payment API flows.

### # Reused Classes

#### # OBFile2

The OBFile2 class is defined in the file-payment-consents page.

### # File Payment - Request

The OBWriteFile2 object will be used for a call to:

- POST /file-payments

#### # UML Diagram

#### # Notes

The file-payment request object contains the:

- ConsentId.
- The full Initiation object from the file-payment-consent request.

The Initiation section of the file-payment request must match the Initiation section of the corresponding file-payment-consent request.

#### # Data Dictionary

Name | Occurrence | XPath | EnhancedDefinition | Class | Codes | Pattern
--- | --- | --- | --- | --- | --- | ---
OBWriteFile2 |  | OBWriteFile2 |  | OBWriteFile2 |  |
Data | 1..1 | OBWriteFile2/Data |  | OBWriteDataFile2 |  |
ConsentId | 1..1 | OBWriteFile2/Data/ConsentId | OB: Unique identification as assigned by the ASPSP to uniquely identify the consent resource. | Max128Text |  |
Initiation | 1..1 | OBWriteFile2/Data/Initiation | The Initiation payload is sent by the initiating party to the ASPSP. It is used to request movement of funds using a payment file. | OBFile2 |  |

### # File Payment - Response

The OBWriteFileResponse3 object will be used for a response to a call to:

- POST /file-payments
- GET /file-payments/{FilePaymentId}

#### # UML Diagram

#### # Notes

The file-payment response object contains the:

- FilePaymentId.
- ConsentId.
- CreationDateTime the file-payment resource was created.
- StatusCode and StatusUpdateDateTime of the file-payment resource.
- Charges array is used for the breakdown of applicable ASPSP charges.
- The Initiation object from the file-payment-consent.
- The MultiAuthorisation object if the file-payment resource requires multiple authorisations.
- An ASPSP should conditionally provide `Debtor/Name` in the Payment Order Response, even when the Payer didn't provide the Debtor Account via PISP.

#### # Data Dictionary

Name | Occurrence | XPath | EnhancedDefinition | Class | Codes | Pattern
--- | --- | --- | --- | --- | --- | ---
OBWriteFileResponse3 |  | OBWriteFileResponse3 |  | OBWriteFileResponse3 |  |
Data | 1..1 | OBWriteFileResponse3/Data |  | OBWriteDataFileResponse3 |  |
FilePaymentId | 1..1 | OBWriteFileResponse3/Data/FilePaymentId | OB: Unique identification as assigned by the ASPSP to uniquely identify the file payment resource. | Max40Text |  |
ConsentId | 1..1 | OBWriteFileResponse3/Data/ConsentId | OB: Unique identification as assigned by the ASPSP to uniquely identify the consent resource. | Max128Text |  |
CreationDateTime | 1..1 | OBWriteFileResponse3/Data/CreationDateTime | Date and time at which the resource was created. | ISODateTime |  |
StatusCode | 1..1 | OBWriteFileResponse3/Data/StatusCode | Specifies the status of the payment order resource. | OBExternalStatus1Code | RCVD RJCT ASCP |
StatusUpdateDateTime | 1..1 | OBWriteFileResponse3/Data/StatusUpdateDateTime | Date and time at which the resource status was updated. | ISODateTime |  |
StatusReason | 0..* | OBWriteFileResponse3/Data/StatusReason | Specifies the status reason. | OBStatusReason |  |
StatusReasonCode | 0..1 | OBWriteFileResponse3/Data/StatusReason/StatusReasonCode | Specifies the status reason in a code form. For a full description see `ExternalStatusReason1Code` here (opens new window). | ExternalStatusReason1Code |  |
StatusReasonDescription | 0..1 | OBWriteFileResponse3/Data/StatusReason/StatusReasonDescription | Description supporting the StatusReasonCode. | Max500Text |  |
Path | 0..1 | OBWriteFileResponse3/Data/StatusReason/Path | Path is optional but relevant when the status reason refers to an object/field and hence conditional to provide JSON path | Max500Text |  |
Charges | 0..n | OBWriteFileResponse3/Data/Charges | Set of elements used to provide details of a charge for the payment initiation. | OBCharge2 |  |
Initiation | 1..1 | OBWriteFileResponse3/Data/Initiation | The Initiation payload is sent by the initiating party to the ASPSP. It is used to request movement of funds using a payment file. | OBFile2 |  |
MultiAuthorisation | 0..1 | OBWriteFileResponse3/Data/MultiAuthorisation | The multiple authorisation flow response from the ASPSP. | OBMultiAuthorisation1 |  |
Debtor | 0..1 | OBWriteFileResponse3/Data/Debtor | Set of elements used to identify a person or an organisation. | OBCashAccountDebtor4 |  |

### # File Payment - Payment Details - Response

The OBWritePaymentDetailsResponse1 object will be used for a response to a call to:

- GET /file-payments/{FilePaymentId}/payment-details

#### # UML Diagram

#### # Data Dictionary

Name | Occurrence | XPath | EnhancedDefinition | Class | Codes | Pattern
--- | --- | --- | --- | --- | --- | ---
OBWritePaymentDetailsResponse1 |  | OBWritePaymentDetailsResponse1 |  | OBWritePaymentDetailsResponse1 |  |
Data | 1..1 | OBWritePaymentDetailsResponse1/Data |  | OBWriteDataPaymentOrderStatusResponse1 |  |
StatusDetail | 0..unbounded | OBWritePaymentDetailsResponse1/Data/StatusDetail | An array of Payment status details. | OBWritePaymentDetails1 |  |

## # Usage Examples

### # POST /file-payments

#### # Request

    POST /file-payments HTTP/1.1
    Authorization: Bearer 2YotnFZFEjr1zCsicMWpAA
    x-idempotency-key: FRESCO.21302.GFX.20
    x-jws-signature: TGlmZSdzIGEgam91cm5leSBub3QgYSBkZXN0aW5hdGlvbiA=..T2ggZ29vZCBldmVuaW5nIG1yIHR5bGVyIGdvaW5nIGRvd24gPw==
    x-fapi-auth-date: Sun, 10 Sep 2017 19:43:31 UTC
    x-fapi-customer-ip-address: 104.25.212.99
    x-fapi-interaction-id: 93bac548-d2de-4546-b106-880a5018460d
    Content-Type: application/json
    Accept: application/json

    {
      "Data": {
        "ConsentId":"512345",
        "Initiation": {
          "FileType": "UK.OB.pain.001.001.08",
          "FileHash": "m5ah/h1UjLvJYMxqAoZmj9dKdjZnsGNm+yMkJp/KuqQ",
          "FileReference": "GB2OK238",
          "NumberOfTransactions": "100",
          "ControlSum": 3459.30
        }
      }
    }

#### # Response

    HTTP/1.1 201 Created
    x-jws-signature: V2hhdCB3ZSBnb3QgaGVyZQ0K..aXMgZmFpbHVyZSB0byBjb21tdW5pY2F0ZQ0K
    x-fapi-interaction-id: 93bac548-d2de-4546-b106-880a5018460d
    Content-Type: application/json

    {
      "Data": {
        "ConsentId" : "512345",
    	"FilePaymentId":"FP1-512345",
        "StatusCode": "RCVD",
        "CreationDateTime": "2018-06-05T15:15:13+00:00",
        "StatusUpdateDateTime": "2018-06-05T15:15:13+00:00",
        "Initiation": {
          "FileType": "UK.OB.pain.001.001.08",
          "FileHash": "m5ah/h1UjLvJYMxqAoZmj9dKdjZnsGNm+yMkJp/KuqQ",
          "FileReference": "GB2OK238",
          "NumberOfTransactions": "100",
          "ControlSum": 3459.30,
          "UltimateDebtor": {
            "SchemeName": "UK.OB.BICFI",
            "Identification": "2360549017905161589",
            "Name": "Ultimate Debtor",
            "LEI": "8200007YHFDMEODY1965",
            "PostalAddress": {
              "AddressType": "BIZZ",
              "StreetName": "Bank Street",
              "BuildingNumber": "11",
              "Floor": "6",
              "PostCode": "Z78 4TY",
              "TownName": "London",
              "Country": "UK"
              }
            },
    	    "RemittanceInformation": {
            "Structured": [
              {
                "ReferredDocumentInformation": [
                  {
                    "Code": "CINV",
                    "Issuer": "Issuer01",
                    "Number": "Number_01",
                    "RelatedDate": "2024-04-25T13:26:41.911Z",
                    "LineDetails": [
                      "string"
                    ]
                  }
                ],
                "ReferredDocumentAmount": 1,
                "CreditorReferenceInformation": {
                  "Code": "DISP",
                  "Issuer": "Issuer01",
                  "Reference": "REF_26518"
                },
                "Invoicer": "INVR51856",
                "Invoicee": "INVE5161856"
              }
            ]
       	  }
        }
      },
      "Links":{
         "Self":"https://api.alphabank.com/open-banking/v4.0/pisp/file-payments/FP1-512345"
      },
      "Meta":{}
    }