SDKs
QPay provides official SDKs for 11 languages, plus a cURL reference collection. Each SDK is a standalone package with identical functionality, covering all QPay V2 API endpoints.
Common Features
Every SDK includes:
- Automatic token management — Access tokens are obtained, cached, and refreshed transparently. You never need to call auth endpoints manually.
- Type-safe models — Strongly typed request and response objects in every language.
- Structured error handling — Dedicated error types with HTTP status codes, QPay error codes, messages, and raw response bodies.
- Full API coverage — Invoices (create, simple, ebarimt, cancel), payments (get, check, list, cancel, refund), and ebarimt operations (create, cancel).
- Environment variable support — Load configuration from
QPAY_*environment variables with a single function call. - Custom HTTP client support — Bring your own HTTP client for timeouts, proxies, or testing.
Available SDKs
| Language | Package | Registry | Install Command |
|---|---|---|---|
| Go | qpay-go | pkg.go.dev | go get github.com/qpay-sdk/qpay-go |
| JavaScript / TypeScript | qpay-js | npm | npm install qpay-js |
| Python | qpay-py | PyPI | pip install qpay-py |
| PHP | usukhbayar/qpay-php | Packagist | composer require usukhbayar/qpay-php |
| Java | qpay-java | Maven Central | Maven / Gradle |
| Ruby | qpay-sdk | RubyGems | gem install qpay-sdk |
| .NET (C#) | QPay | NuGet | dotnet add package QPay |
| Dart / Flutter | qpay | pub.dev | dart pub add qpay |
| Swift | QPay | SPM | Swift Package Manager |
| Rust | qpay | crates.io | cargo add qpay |
| cURL | qpay-curl | GitHub | Shell scripts (no install) |
Environment Variables
All SDKs read the same set of environment variables:
| Variable | Required | Description |
|---|---|---|
QPAY_BASE_URL | Yes | QPay API base URL (e.g., https://merchant.qpay.mn) |
QPAY_USERNAME | Yes | QPay merchant username |
QPAY_PASSWORD | Yes | QPay merchant password |
QPAY_INVOICE_CODE | Yes | Default invoice code for your merchant |
QPAY_CALLBACK_URL | Yes | URL that QPay calls after a payment is completed |
API Coverage
All SDKs implement every operation in the QPay V2 API:
| Operation | Method | Endpoint | Description |
|---|---|---|---|
| Get Token | POST | /v2/auth/token | Authenticate with Basic Auth and get access/refresh tokens |
| Refresh Token | POST | /v2/auth/refresh | Refresh an expired access token using the refresh token |
| Create Invoice | POST | /v2/invoice | Create a detailed invoice with all available options |
| Create Simple Invoice | POST | /v2/invoice | Create an invoice with minimal required fields |
| Create Ebarimt Invoice | POST | /v2/invoice | Create an invoice with tax (ebarimt) information |
| Cancel Invoice | DELETE | /v2/invoice/{id} | Cancel an existing unpaid invoice |
| Get Payment | GET | /v2/payment/{id} | Retrieve full payment details by payment ID |
| Check Payment | POST | /v2/payment/check | Check if a payment has been made for an invoice |
| List Payments | POST | /v2/payment/list | List payments with date range and pagination |
| Cancel Payment | DELETE | /v2/payment/cancel/{id} | Cancel a card payment |
| Refund Payment | DELETE | /v2/payment/refund/{id} | Refund a card payment |
| Create Ebarimt | POST | /v2/ebarimt_v3/create | Create an electronic tax receipt for a payment |
| Cancel Ebarimt | DELETE | /v2/ebarimt_v3/{id} | Cancel an electronic tax receipt |
Typical Integration Flow
- Create an invoice — Call
createSimpleInvoicewith an amount and description. You get back a QR image and bank app deep links. - Display to the user — Show the QR code or open a bank app deep link on mobile.
- Poll for payment — Periodically call
checkPaymentwith the invoice ID to see if payment has been received. - Receive callback — QPay sends a POST request to your
callback_urlwhen payment completes. - Issue ebarimt — Optionally call
createEbarimtto generate an electronic tax receipt.
GitHub Organization
All SDK repositories are hosted under the qpay-sdk GitHub organization.
Last updated on