Download the PHP package payriff/payriff-php without Composer
On this page you can find all versions of the php package payriff/payriff-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download payriff/payriff-php
More information about payriff/payriff-php
Files in payriff/payriff-php
Package payriff-php
Short Description PHP client for the Payriff merchant API
License MIT
Homepage https://github.com/PayRiff/payriff-php
Informations about the package payriff-php
Payriff PHP SDK
PHP client for the Payriff merchant API: orders, saved-card payments, saved cards, transactions, payouts and invoices.
- PHP 8.1 or newer, with the
curlandjsonextensions - No other dependencies
- Talks to
https://api.payriff.com(Azerbaijan) orhttps://api.gccpay.sa(Saudi Arabia)
Installation
Quick start
Requests take associative arrays and responses are returned as associative arrays with the field
names of the Payriff API. Create one Payriff instance and reuse it.
Configuration
| Argument | Required | Default | Notes |
|---|---|---|---|
appKey |
yes | — | Application key from the Payriff dashboard. |
merchantId |
for payouts and invoices | — | Merchant ID (e.g. ES1000000). |
timeout |
no | 60.0 |
Total request timeout in seconds. Bank operations can take tens of seconds. |
connectTimeout |
no | 10.0 |
Connection timeout in seconds. |
region |
no | Region::AZERBAIJAN |
API region. Sets the base URL and the default currency. |
baseUrl |
no | from region |
Override the API URL, e.g. for testing. The currency still comes from region. |
Keep the app key in an environment variable or secret store. Never commit it.
Saudi Arabia
| Region | API | Default currency |
|---|---|---|
Region::AZERBAIJAN |
https://api.payriff.com |
AZN |
Region::SAUDI |
https://api.gccpay.sa |
SAR |
Use the app key from the dashboard of the same region (dashboard.gccpay.sa for Saudi Arabia).
A currency passed on a request always wins over the region default.
Orders
paymentStatus is a string such as APPROVED, DECLINED, PREAUTH_APPROVED or REFUNDED.
Amounts can be passed as numeric strings ('10.50'), integers or floats.
Charging a saved card
Saved cards
Transactions
Payouts
Payouts require merchantId on the client.
Invoices
Invoices require merchantId on the client.
Callbacks
When an order changes state, Payriff POSTs JSON to the callbackUrl you set on the order.
Errors
Every SDK exception extends Payriff\Exception\PayriffException, which provides getHttpStatus(),
getResultCode() (Payriff result code) and getResponseId() (quote it when contacting support).
| Exception | When |
|---|---|
AuthenticationException |
App key rejected (14010, 14013, 14014, 14015) |
ValidationException |
Invalid request (15400 or HTTP 400) |
RequestRejectedException |
Business refusal (01000), e.g. application under review |
InsufficientBalanceException |
Not enough wallet balance for a payout (01200) |
PayoutLimitException |
Payout limit reached (01300, 01400, 01500) |
ApiException |
Any other failure reported by Payriff |
PayriffConnectionException |
No response: network error or timeout |
Payriff can report a failure with HTTP 200. The SDK checks the result code in the body, so you
only need to catch exceptions. Invalid arguments throw InvalidArgumentException before any
request is sent.
Retries
The SDK never retries on its own, because payment calls are not safe to repeat blindly. After a
PayriffConnectionException, look the operation up first (orders->getByRequestRrn(...),
payouts->getByRequestRrn(...)) and retry only if it does not exist. Set requestRrn /
idempotencyKey on every request so that this lookup is possible.
Development
License
MIT
All versions of payriff-php with dependencies
ext-curl Version *
ext-json Version *