API Reference

MED

The MED (Special Refund Mechanism) is a procedure from Brazil's Central Bank designed to protect Pix users in cases of fraud, scams, or unauthorized transactions.

It functions as a "safety net" of the arrangement: when suspicious activity is identified, the payer's institution can open a formal process requesting the amount to be returned.

How it works at PayZu

The MED flow at PayZu is delivered through a webhook that reuses the same callbackUrl from the transaction, always updating the status of the original operation and inserting the infraction object into the payload.


Conceptual Flow of MED

┌─────────────────────────────────────────┐
│  Pix transaction performed              │
└─────────────┬───────────────────────────┘
              │
              ▼
┌─────────────────────────────────────────────────────┐
│  Problem identified                                 │
│  (fraud / error / unauthorized charge)              │
└─────────────┬───────────────────────────────────────┘
              │
              ▼
┌─────────────────────────────────────────────────────┐
│  Payer's institution opens MED in arrangement      │
│     Webhook: status = OPEN                          │
└─────────────┬───────────────────────────────────────┘
              │
              ▼
┌─────────────────────────────────────────────────────┐
│  Receiver's bank is notified                        │
│     May block the amount during analysis            │
└─────────────┬───────────────────────────────────────┘
              │
              ▼
┌─────────────────────────────────────────────────────┐
│  Dispute analysis                                   │
│  (institutions + Central Bank rules)                │
└────────┬────────────────────────┬────────────────────┘
         │                        │
         ▼                        ▼
    ACCEPTED                  REJECTED
    status = CLOSED         status = CLOSED
    result = AGREED         result = DISAGREED
         │                        │
         ▼                        ▼
   Amount returned          Transaction
      to payer              remains valid

Webhook Example with Infraction (MED)

Below is a real example of the payload you receive when a Pix transaction suffers an infraction:

{
  "id": "PAYZU20251123104518DF75D20A8F",
  "type": "DEPOSIT",
  "status": "COMPLETED",
  "serviceFeeCharged": 1,
  "amount": 30,
  "clientReference": "d2b2a5ed-f1a4-477e-81da-9",
  "qrCodeText": "00020101021226870014br.gov.bcb.pix...",
  "payerName": "John Doe",
  "payerDocument": "12345678901",
  "payerInstitutionName": "PAYZU IP",
  "receiverName": "PAYZU LTDA",
  "receiverDocument": "123456789010110",
  "endToEndId": "E18236120202511231046s1235ee7",
  "paidAt": "2025-11-23T10:46:26.986Z",
  "createdAt": "2025-11-23T10:45:18.403Z",
  "updatedAt": "2025-11-23T10:46:27.346Z",
  "callbackUrl": "https://yourwebhook.com",
  
  "infraction": {
    "id": "cmide759mb9i3s601bhwf6e",
    "protocol": "4dd32924-9b53-4408-af4b-6d3b4d7ac",
    "status": "OPEN",
    "type": "REFUND_REQUEST",
    "reportDetails": "Fraud report: transaction was formally contested by payer",
    "reportedBy": "DEBITED_PARTICIPANT",
    "analysisResult": null,
    "analysisDetails": null,
    "reportedAt": "2025-11-24T16:52:15.808Z",
    "createdAt": "2025-11-24T17:00:00.490Z",
    "updatedAt": "2025-11-24T17:00:00.490Z"
  }
}

Webhook Integration

When an infraction occurs, your webhook receives the complete transaction object with an infraction field containing:

Infraction Fields

FieldTypeDescription
idstringUnique infraction identifier
protocolstringPayment provider protocol number
statusInfractionStatusCurrent infraction status
typeInfractionTypeType of infraction
reportDetailsstringDescription of dispute reason
reportedByReportedByWho reported the infraction
analysisResultAnalysisResult | nullFinal decision (null while pending)
analysisDetailsstring | nullJustification of decision
reportedAtstringWhen it was reported
expiresAtstring | nullResolution deadline
createdAtstringCreation timestamp
updatedAtstringLast update timestamp

InfractionStatus

ValueDescription
WAITING_PSPWaiting for payment provider response
OPENActive and under analysis
ACKNOWLEDGEDAcknowledged by institution
DEFENDEDDefense has been submitted
ANSWEREDAdditional information provided
WAITING_ADJUSTMENTSPending documentation
CLOSEDResolved with final decision
CANCELLEDCancelled before resolution

InfractionType

ValueDescription
REFUND_REQUESTStandard refund request
FRAUDSecurity-related claim
REFUND_CANCELLEDCancellation of previous refund

ReportedBy

ValueDescription
DEBITED_PARTICIPANTReported by payer's institution
CREDITED_PARTICIPANTReported by payee's institution

AnalysisResult

ValueDescription
AGREEDInfraction accepted - refund will be processed
DISAGREEDInfraction rejected - no refund

Complete Lifecycle of an Infraction

                          ┌──────────────────┐
                          │  INFRACTION OPEN │
                          │  status: OPEN    │
                          └────────┬─────────┘
                                   │
                 ┌─────────────────────────────────────┐
                 │                                     │
                 ▼                                     ▼
          ┌────────────────┐              ┌──────────────────┐
          │ ACKNOWLEDGED   │              │ DEFENDED         │
          │ (default)      │              │ (if defense sent)│
          └────────┬───────┘              └────────┬─────────┘
                   │                               │
                   └───────────────┬───────────────┘
                                   │
                                   ▼
                          ┌──────────────────┐
                          │  CENTRAL BANK    │
                          │    ANALYSIS      │
                          │  Possible status:│
                          │  • ANSWERED      │
                          │  • WAITING_ADJ...│
                          └────────┬─────────┘
                                   │
                    ┌──────────────────────────────┐
                    │                              │
                    ▼                              ▼
          ┌──────────────────┐        ┌──────────────────┐
          │ CLOSED / AGREED  │        │CLOSED / DISAGREED│
          │ Automatic        │        │ No financial     │
          │    refund        │        │    impact        │
          └──────────────────┘        └──────────────────┘

Financial Impact

When Infraction is Agreed (AGREED)

Original transaction: COMPLETED
            │
            ▼
Infraction: status CLOSED, result AGREED
            │
            ▼
┌──────────────────────────────────────────┐
│ Transaction changes to: WAITING_FOR_REFUND│
└──────────────────────────────────────────┘
            │
            ▼
┌──────────────────────────────────────────┐
│ Refund initiated AUTOMATICALLY           │
│ • Amount debited from your balance       │
│ • Fee calculation applied if applicable  │
└──────────────────────────────────────────┘
            │
            ▼
┌──────────────────────────────────────────┐
│ Final transaction status: REFUNDED       │
│ Completion webhook sent                  │
└──────────────────────────────────────────┘

When Infraction is Disagreed (DISAGREED)

Transaction: COMPLETED (remains unchanged)
            │
            ▼
Infraction: status CLOSED, result DISAGREED
            │
            ▼
┌──────────────────────────────────────────┐
│ NO FINANCIAL IMPACT                      │
│ • No refund is processed                 │
│ • Balance remains the same               │
│ • Transaction remains valid              │
└──────────────────────────────────────────┘