> ## Documentation Index
> Fetch the complete documentation index at: https://docs.localpayment.com/llms.txt
> Use this file to discover all available pages before exploring further.

# QR (Peru)

> Localpayment enables merchants to process instant payments through Peru's standardized QR payment system. This guide outlines the process for initiating QR-based payments through Localpayment's API, detailing required parameters, handling responses, and interpreting status codes for seamless integration with Peru's interoperable payment network.

## Before You Begin

Ensure you have:

* Valid [API credentials ](https://docs.localpayment.com/docs/api-keys-and-environments.md) (access token).

***

## Supported Wallets

* Valid [API credentials ](https://docs.localpayment.com/docs/api-keys-and-environments.md)(access token).

***

## Step 1. Create QR Payment

To generate a QR code for payment collection, send a `POST` request to the [Create Payin](https://docs.localpayment.com/reference/payins.md) endpoint with QR-specific parameters.

> [!NOTE]
>
> **Expiration**
>
> By default, a QR Bank Transfer payment order expires **1 day after creation**. To customize the expiration period (**1-7 days**) for your business needs, contact your account manager for configuration.

### Key Request Parameters

The request requires several key objects specific to QR payments:

| Object | Description | Required |
| - | - | - |
| `paymentMethod.type` | Must be `BankTransfer`. | ✅ |
| `paymentMethod.code` | Use `6080` for Peru QR. | ✅ |
| `sender` | Sender information for compliance. | ✅ |
| `merchant` | Merchant/business details. | ✅ |
| `paymentMethod` | Payment method configuration. | ✅ |
| `amount` | Transaction amount. | ✅ |
| `currency` | Transaction currency code. | ✅ |
| `country` | Must be `PER`. | ✅ |

See all [available parameters](https://docs.localpayment.com/reference/payins.md) in the request.

> [!WARNING]
>
> **Amount limits for Peru:** QR payments require a minimum of 1 PEN and cannot exceed 500 PEN per transaction. Each user has a daily limit of 2000 PEN across all transactions.

### Example Request

Below is an example using `curl`:

```curl theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
curl --request POST \
     --url https://api.stage.localpayment.com/api/payin/ \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --header 'Authorization: Bearer <your_access_token>' \
     --data '
{
    "externalId": "96989760-c262-4607-b99c-dfbf8af42f52",
    "paymentMethod": {
        "type": "Banktransfer",
        "code": "6080",
        "flow": "DIRECT"
    },
    "country": "PER",
    "currency": "PEN",
    "amount": 1001,
    "accountNumber": "{{accountNumber}}",
    "conceptCode": "0001",
    "comment": "QR Payment",
    "merchant": {
        "type": "COMPANY",
        "document": {
            "id": "12345678",
            "type": "DNI"
        },
        "name": "Test Company"
    },
    "payer": {
        "type": "INDIVIDUAL",
        "document": {
            "id": "87654321",
            "type": "DNI"
        },
        "name": "John",
        "lastname": "Doe",
        "email": "john.doe@example.com",
        "userReference": "{{$randomUserName}}"
    }
}
'
```

***

## Step 2. Handle the Response

### Successful Response

A successful QR payment creation includes the QR code data and payment details:

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
  "transactionType": "PayIn",
  "externalId": "96989760-c262-4607-b99c-dfbf8af42f52",
  "internalId": "bd3c82a3-7b97-4e43-bcce-f59eb31ef5ef",
  "paymentMethod": {
    "type": "BankTransfer",
    "code": "6080",
    "flow": "DIRECT"
  },
  "country": "PER",
  "currency": "PEN",
  "amount": 1001,
  "accountNumber": "{{accountNumber}}",
  "confirmed": {
    "currency": "PEN",
    "fxQuote": 1,
    "amount": 1001
  },
  "payment": {
    "currency": "PEN",
    "fxQuote": 1,
    "financingFee": 0,
    "amount": 1001
  },
  "localTaxes": [],
  "withHoldings": [],
  "fees": {
    "description": "Fee",
    "currency": "PEN",
    "fxSource": 6.812851,
    "fxQuote": 1,
    "amount": 1,
    "account": "{{accountNumber}}"
  },
  "status": {
    "code": "100",
    "description": "INPROGRESS",
    "detail": "The payin is pending the confirmation"
  },
  "qr": {
        "image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAAEsAQAAAABRBrPYAAADRUlEQVR4Xu2XbY7bMAxEeQPe/5a8Acs3dBaxdoH2TzsBaiF1Hek5ED9m5I3+k1Fxzvw4HuwYD3aMBzvGgx3jf8MqIjoyMruq5y6LT6QWzFizXHzLiOyoIbMH1ZoXq6ie9dm04Lmt1/UTsFmevTc5DuYnhP4UjL2TWPbepDZI7wdgkAM1WQaf5dSDWvNiU+b6cXxT1gns+IuYBllFwWycuk8UX2tGbHaqG7KaSCXJNZaDqr0Y2wdIbLBWOI0TTiO4sZKKm9wWaNKjfImNxYrNJNDAE0yR38amCejKvw1rloMGaFD8L/YuFYETUw75F9dpJpducstDVmymr5M2VsvF6Tup3YCsWHFWkN0irynV8NxkWw5txuQyazVFAAQip7mHYMCYZvOIBHsBURuQcDdGJoNuhJTTFCPoTy/GKx7+MhrZJgBuqduOlY4zHCbJMiQfWc299P8e0wmWePR26Kyp5vNEXL9jw4oZXWbDQEVDgq6arZg2r2/IebugOEEQkxfbHpxpNSTVVn9S+HovvQVT2TEXVEyW6c9E45tfJ1akkdzSlUEsBIKS7pEasFlsGpEpsjyx8MejQnBjFH4deRKrBLPKe0LRB1bsldGJBQXLAzHq7xZtwCj93HGmBXfYs5rgXnoHpk0jGAJRvWciddytZpwYrajyr6JBCKOurnRieg9GMjCq+2B8aE031myewwKAYBA0qsl3G/RgxfY5LBolA8kNg3DcmKLozSdmGLKYYe6ld2Aa8jx1IjtP9MLNW+k9WJFOAsFjSPDAaFoHixlLmhJ32RPjKr2u+zNWrPakDUqu+aQVetVsxbgiYKymYAYvgqJjvdhan0KA4pM8kvSnGZv/k87EAy/N6OHzaHNgyqgMkGl2/VILGTdjVyB6SVGquRYJvlXBgnH8hyY4Rnjni+tY82O82dGTgWbUooXh6IXPjHFDF8pq1v+Qsm7v+bdguntZjSybcBScFyuOjUsq0nPJZJLbr99wYfr0vq6wb4im7kRkxuTO1Jl19egqmi74CEzbxakLTaOXvNbtGAJWpdWcs39yK7vxYpCw64LklzQTzy0EC7aSIZRELLxBYYbQ76V3YL8dD3aMBzvGgx3jwY7xYMeoX9xXVTGl7tqkAAAAAElFTkSuQmCC",
        "expirationDate": "2025-04-21T16:14:26.0596069",
        "paymentInstructions": "<b><i>From Yape, Plin or other entity aplications, scan the QR code and complete the payment process</i></b>"

  },
  "merchant": {
    "type": "COMPANY",
    "name": "Company ",
    "document": {
      "id": "12345678",
      "type": "DNI"
    }
  },
  "payer": {
    "type": "INDIVIDUAL",
    "name": "John",
    "lastname": "Doe",
    "document": {
      "id": "87654321",
      "type": "DNI"
    },
    "email": "john.doe@example.com",
    "fullName": "John Doe"
  },
  "date": {
    "creationDate": "2024-11-15T17:05:11.772+00:00",
    "processedDate": "2024-11-15T17:05:13.656446231",
    "expirationDate": "2024-11-15 23:59"
  },
  "errors": []
}
```

### Key Response Fields

| Parameter | Description | Use Case |
| - | - | - |
| `qr.image` | Base64 encoded PNG image of the QR code. | Direct display without additional generation. |
| `qr.expirationDate` | Timestamp when QR becomes invalid. | Display countdown timer and handle expiration logic. |
| `qr.paymentInstructions` | Payment instructions. | Display user-friendly payment guidance. |
| `externalId` | Your original reference number. | Internal reconciliation and order matching. |
| `status.code` | Current transaction state (`100` = `INPROGRESS`) | Determine next steps in payment flow. |
| `date.creationDate` | When transaction was created. | Analytics and performance tracking. |

### Error Response

When QR generation fails, you'll receive detailed error information:

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
  "externalId": "96989760-c262-4607-b99c-dfbf8af42f52",
  "status": {
    "code": "812",
    "description": "REJECTED"
  },
  "errors": [
    {
      "code": "812",
      "detail": "External Id already used - duplication"
    }
  ]
}
```

***

## Step 3. Display QR Code and Handle Payment

1. **QR Display**: Present QR code to customer through chosen channel.
2. **Bank App Scan**: Customer scans QR with their bank mobile app.
3. **Payment Authorization**: Customer confirms payment in their banking environment.
4. **Real-time Confirmation**: Localpayment receives instant payment notification.
5. **Status Update**: Your system receives webhook with payment confirmation.

![](https://mintcdn.com/localpayment-1fee3d41/R2R5JIQRe6pRQ97b/images/docs/c5341035dc1e7605024222eba3a99022db6774a16999a6a057264070aa1af9b6-qr-per.png?fit=max\&auto=format\&n=R2R5JIQRe6pRQ97b\&q=85\&s=429ca765d3d65ead8fde562bdea86a40)

### Best Practices for QR Display

* Minimum display size: 250x250 pixels for mobile scanning.
* Maintain 1:1 aspect ratio without distortion.
* Ensure high contrast (dark on light background).
* Add quiet zone (white border) around QR code.
* Include alt text (e.g. "QR Code Payment").
* Show Clear Payment Instructions.
* Handle Time-to-Live (TTL) and Expiration.

***

## Step 4. Track Transaction Status

Monitor QR payment progress through these methods:

> [card] [Webhooks (Recommended)](https://docs.localpayment.com/docs/webhooks.md)
>
> Receive real-time notifications when transaction status changes. Most efficient for production environments.

> [card] [Status API Endpoint](https://docs.localpayment.com/reference/get-transaction-status.md)
>
> Query transaction status programmatically. Useful for polling or recovering lost webhook notifications.

> [card] [Business Portal View](https://docs.localpayment.com/docs/dashboard-overview.md)
>
> Visual interface for monitoring transactions. Great for manual oversight and detailed transaction analysis.

### Common Status Codes

The Localpayment API provides various status codes to indicate the progress and outcome of the payment in the response.

| Code | Status | Description |
| :- | :- | :- |
| `103` | `APPROVED` | The payin was confirmed but not credited yet. |
| `200` | `Completed` | The payin was completed. |
| `811` | `Rejected` | Requested amount is higher or lower than allowed max/min values. |

> [!NOTE]
>
> **Complete Reference**
>
> View all status codes in our [Transaction Status Documentation](https://docs.localpayment.com/reference/transaction-status-error-codes).

***

## Testing Your Integration

### Sandbox Environment

Use the staging environment for testing:

```
https://api.stage.localpayment.com/api/payin/
```

### Test QR Scenarios

Verify your integration handles these scenarios:

1. **Successful Payment**: Complete QR scan and payment flow.
2. **QR Expiration**: Handle expired QR codes gracefully.
3. **Multiple Payment Attempts**: Same QR scanned multiple times.
4. **Status Updates**: Webhook handling and status polling.

***

## Next Steps

After implementing QR payments, consider these additional capabilities:

> [card] [Refund the transaction](https://docs.localpayment.com/docs/refund-apm-payment.md)
>
> If necessary, you can refund the payment to the customer. Refer to the documentation for details.

> [card] [Review transaction details](https://docs.localpayment.com/reference/get-transaction-status.md)
>
> You can retrieve transaction information using the Localpayment API for detailed insights.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.