Download the PHP package usukhbayar/qpay-php without Composer
On this page you can find all versions of the php package usukhbayar/qpay-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download usukhbayar/qpay-php
More information about usukhbayar/qpay-php
Files in usukhbayar/qpay-php
Package qpay-php
Short Description QPay V2 API PHP SDK with auto token management
License MIT
Informations about the package qpay-php
QPay PHP SDK
PHP SDK for the QPay V2 payment gateway API. Provides a clean, type-safe interface with automatic token management, Guzzle-based HTTP, and comprehensive error handling.
Requirements
- PHP 8.1+
- Guzzle HTTP 7.0+
Installation
Quick Start
Configuration
Environment Variables
| Variable | Description |
|---|---|
QPAY_BASE_URL |
QPay API base URL (e.g. https://merchant.qpay.mn) |
QPAY_USERNAME |
Merchant username |
QPAY_PASSWORD |
Merchant password |
QPAY_INVOICE_CODE |
Default invoice code |
QPAY_CALLBACK_URL |
Payment callback URL |
Loading from Environment
Manual Configuration
Token Management
The SDK handles authentication automatically. When you make any API call, the client will:
- Obtain an access token if none exists
- Reuse the token while it is valid
- Refresh the token using the refresh token when expired
- Re-authenticate with credentials if the refresh token is also expired
You can also manage tokens manually:
Usage
Create Invoice (Full Options)
Create Simple Invoice
Create Invoice with Ebarimt (Tax)
Cancel Invoice
Get Payment Details
Check Payment Status
List Payments
Cancel Payment (Card Only)
Refund Payment (Card Only)
Create Ebarimt (Tax Receipt)
Cancel Ebarimt
Error Handling
All API errors throw QPay\Exceptions\QPayException:
Error Code Constants
The QPayException class provides constants for all known QPay error codes:
Available error code constants:
| Constant | Value |
|---|---|
AUTHENTICATION_FAILED |
Authentication failed |
PERMISSION_DENIED |
Permission denied |
NO_CREDENDIALS |
Missing credentials |
INVOICE_NOTFOUND |
Invoice not found |
INVOICE_PAID |
Invoice already paid |
INVOICE_ALREADY_CANCELED |
Invoice already cancelled |
INVOICE_CODE_INVALID |
Invalid invoice code |
INVOICE_LINE_REQUIRED |
Invoice lines required |
PAYMENT_NOTFOUND |
Payment not found |
PAYMENT_NOT_PAID |
Payment not paid |
PAYMENT_ALREADY_CANCELED |
Payment already cancelled |
INVALID_AMOUNT |
Invalid amount |
MIN_AMOUNT_ERR |
Below minimum amount |
MAX_AMOUNT_ERR |
Exceeds maximum amount |
MERCHANT_NOTFOUND |
Merchant not found |
MERCHANT_INACTIVE |
Merchant inactive |
EBARIMT_NOT_REGISTERED |
Ebarimt not registered |
EBARIMT_CANCEL_NOTSUPPERDED |
Ebarimt cancel not supported |
CUSTOMER_NOTFOUND |
Customer not found |
CUSTOMER_DUPLICATE |
Duplicate customer |
See the QPayException class for the full list of constants.
API Reference
QPayClient Methods
| Method | Parameters | Returns | Description |
|---|---|---|---|
getToken() |
- | TokenResponse |
Authenticate and get token pair |
refreshTokenRequest() |
- | TokenResponse |
Refresh the access token |
createInvoice() |
CreateInvoiceRequest |
InvoiceResponse |
Create invoice with full options |
createSimpleInvoice() |
CreateSimpleInvoiceRequest |
InvoiceResponse |
Create invoice with minimal fields |
createEbarimtInvoice() |
CreateEbarimtInvoiceRequest |
InvoiceResponse |
Create invoice with tax info |
cancelInvoice() |
string $invoiceId |
void |
Cancel an invoice |
getPayment() |
string $paymentId |
PaymentDetail |
Get payment details |
checkPayment() |
PaymentCheckRequest |
PaymentCheckResponse |
Check payment status |
listPayments() |
PaymentListRequest |
PaymentListResponse |
List payments |
cancelPayment() |
string $paymentId, PaymentCancelRequest |
void |
Cancel a card payment |
refundPayment() |
string $paymentId, PaymentRefundRequest |
void |
Refund a card payment |
createEbarimt() |
CreateEbarimtRequest |
EbarimtResponse |
Create tax receipt |
cancelEbarimt() |
string $paymentId |
EbarimtResponse |
Cancel tax receipt |
Custom HTTP Client
You can inject a custom Guzzle client (useful for testing, proxies, or custom middleware):
Testing
License
MIT License. See LICENSE for details.