# SEPA Direct Debit R-Transaction (MD01/MS02) pain.002 Decoder

**Use case:** 

Decode SEPA Direct Debit returns and mandate rejections (MD01 No Mandate, MD06 Refund Request, MS02 Refused by Debtor) from bank pain.002 XML for SaaS dunning flows.

## Input

```json
{
  "xmlContent": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Document xmlns=\"urn:iso:std:iso:20022:tech:xsd:pain.002.001.10\">\n  <CstmrPmtStsRpt>\n    <GrpHdr><MsgId>STS-20261116-99201</MsgId><CreDtTm>2026-11-16T09:15:00Z</CreDtTm><InitgPty><Nm>DEUTSCHE BANK AG</Nm></InitgPty></GrpHdr>\n    <OrgnlGrpInfAndSts><OrgnlMsgId>BATCH-2026-NOV-01</OrgnlMsgId><OrgnlMsgNmId>pain.001.001.09</OrgnlMsgNmId><GrpSts>PART</GrpSts></OrgnlGrpInfAndSts>\n    <OrgnlPmtInfAndSts>\n      <OrgnlPmtInfId>PMT-SUPPLIERS-01</OrgnlPmtInfId>\n      <PmtInfSts>PART</PmtInfSts>\n      <TxInfAndSts>\n        <OrgnlInstrId>INSTR-002</OrgnlInstrId><OrgnlEndToEndId>INV-2026-8802</OrgnlEndToEndId><TxSts>RJCT</TxSts>\n        <StsRsnInf><Rsn><Cd>AC04</Cd></Rsn><AddtlInf>Beneficiary IBAN closed</AddtlInf></StsRsnInf>\n        <OrgnlTxRef><Amt><InstdAmt Ccy=\"EUR\">849.95</InstdAmt></Amt><Cdtr><Nm>Elodie Lefevre SARL</Nm></Cdtr><CdtrAcct><Id><IBAN>FR7630006000011234567890189</IBAN></Id></CdtrAcct></OrgnlTxRef>\n      </TxInfAndSts>\n      <TxInfAndSts>\n        <OrgnlInstrId>INSTR-003</OrgnlInstrId><OrgnlEndToEndId>INV-2026-8803</OrgnlEndToEndId><TxSts>RJCT</TxSts>\n        <StsRsnInf><Rsn><Cd>BE04</Cd></Rsn><AddtlInf>Missing structured TownName and Country</AddtlInf></StsRsnInf>\n        <OrgnlTxRef><Amt><InstdAmt Ccy=\"EUR\">3400.00</InstdAmt></Amt><Cdtr><Nm>Alpine Advisory AG</Nm></Cdtr><CdtrAcct><Id><IBAN>CH9300762011623852957</IBAN></Id></CdtrAcct></OrgnlTxRef>\n      </TxInfAndSts>\n    </OrgnlPmtInfAndSts>\n  </CstmrPmtStsRpt>\n</Document>",
  "onlyRejectedOrExceptions": true,
  "includeInlineCsv": true
}
```

## Output

```json
{
  "status": {
    "label": "Status",
    "format": "string"
  },
  "schemaDetected": {
    "label": "Schema detected",
    "format": "string"
  },
  "originalMessageId": {
    "label": "Original message id",
    "format": "string"
  },
  "groupStatus": {
    "label": "Group status",
    "format": "string"
  },
  "totalTransactions": {
    "label": "Total transactions",
    "format": "integer"
  },
  "rejectedCount": {
    "label": "Rejected count",
    "format": "integer"
  },
  "acceptedCount": {
    "label": "Accepted count",
    "format": "integer"
  },
  "csvReportDownloadUrl": {
    "label": "Csv report download url",
    "format": "string"
  }
}
```

## How it works

### 1. Sign up on Apify or log in

The ISO 20022 pain.002 Bank Payment Status & Rejection Decoder Actor is ready to run with the inputs already set for "SEPA Direct Debit R-Transaction (MD01/MS02) pain.002 Decoder". [Sign up or log in](https://console.apify.com/create-task-from-example/EqKd5iyUszmzp29KE) and you'll land in Apify Console with a copy of this exact task.

### 2. Start the "SEPA Direct Debit R-Transaction (MD01/MS02) pain.002 Decoder" task

The ISO 20022 pain.002 Bank Payment Status & Rejection Decoder Actor will start running based on the input automatically. You can also change all the input fields, like ISO 20022 pain.002 XML Content, return only rejected / warning items, and more, to match your specific use case.

### 3. Receive the "SEPA Direct Debit R-Transaction (MD01/MS02) pain.002 Decoder" output

Monitor the progress in real time. You will be notified as soon as your dataset is complete and ready for review. Each result includes data such as status, schema detected, original message id, and more.

### 4. Integrate into your workflow

The final output is delivered in JSON, CSV, or Excel format, ready to be plugged into your workflow. You can also [run the "SEPA Direct Debit R-Transaction (MD01/MS02) pain.002 Decoder" task via API](https://apify.com/finops_studio/iso20022-pain002-status-parser.md).

## FAQ

### How does this help SaaS billing recovery?

It flags whether an R-transaction is a closed account AC04, insufficient funds AM04, or mandate cancellation MD01.

### Can I download a CSV report of returned debits?

Yes, PAIN002_STATUS_REPORT.csv is saved automatically in the run Key-Value Store.

## About this Actor

This example demonstrates how to use [ISO 20022 pain.002 Bank Payment Status & Rejection Decoder](https://apify.com/finops_studio/iso20022-pain002-status-parser.md) with a specific input configuration. Visit the [Actor detail page](https://apify.com/finops_studio/iso20022-pain002-status-parser.md) to learn more, explore other use cases, and run it yourself.


## How to integrate an Actor?

This Task's input is already configured above. Use it as-is rather than inventing a new one.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For full API examples (JavaScript, Python, CLI, MCP, OpenAPI), see this Task's Actor page: https://apify.com/finops_studio/iso20022-pain002-status-parser.md

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).
