Download the PHP package onpayio/php-sdk without Composer

On this page you can find all versions of the php package onpayio/php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-sdk

OnPay PHP SDK

Latest Stable Version Total Downloads License

PHP SDK for the OnPay payment platform.

Requirements

Installation

Replace guzzlehttp/guzzle with the PSR-18 client you use. Composer may ask whether to allow the php-http/discovery plugin; either answer works, discovery needs no plugin at runtime.

Getting started

1. Store the access token

The SDK hands you the OAuth token as a string and asks for it back on every request. Implement OnPay\TokenStorageInterface to keep it somewhere durable and private: the token gives full API access, so treat it like a database password.

2. Store the authorization state

The OAuth flow spans two requests: one that redirects the merchant to OnPay and one that receives the authorization code. Implement OnPay\AuthStateStorageInterface to carry the CSRF state and PKCE verifier between them, scoped to the current visitor. A PHP session is the simplest place:

3. Authorize

After that the token is refreshed and re-saved automatically. isAuthorized() makes a ping request to check that the stored token still works.

A static API token created in the OnPay management panel skips the flow entirely:

4. Create a payment

Describe the payment with a PaymentWindow, create it through the API and send the shopper to the returned payment window link. Amounts are in minor units.

Every field the API accepts has a setter on PaymentWindow and PaymentInfo; the API reference describes them. Some payment methods need a cart. Its total, items plus shipping and handling minus discount, must equal the payment amount:

To store the card for later charges, create a subscription (see Stored cards) instead of a one-off payment. It should charge its first transaction as part of the signup, so the shopper authenticates the real amount and liability shifts to the issuer. Create one without a transaction only for a trial period or when replacing a stored card.

5. Verify the result

OnPay signs the onpay_* parameters it appends to the accept URL and sends to the callback URL (a GET request). Check the signature with your payment window secret before trusting them. Declines sent to the decline URL are not signed.

Transactions

Stored cards (COF)

OnPay stores a card as a subscription, the card on file (COF) of the card-scheme rules, and that is the name the API and these methods use. Charging it later, without the shopper present, is a merchant-initiated transaction (MIT).

Gateway

Configuration-time lookups. Cache the results; do not call these while processing a payment.

Errors

Every error the SDK raises extends OnPay\API\Exception\OnPayException:

Exception Meaning
TokenException No usable token, or OnPay rejected it. Re-authorize.
ConnectionException The HTTP request never got a response.
ApiException OnPay answered with an error, or with a response the SDK could not read.
MissingDataException, InvalidFormatException, InvalidCartException The PaymentWindow you built is incomplete or invalid.

Invalid constructor options throw a plain \InvalidArgumentException.

Logging

Failed requests are logged at warning (4xx) or error (5xx, transport failure), successful ones at debug. Tokens and secrets are redacted first. Pass any PSR-3 logger; without one, warnings and errors go to PHP's error_log().

Pass a Psr\Log\NullLogger to silence the SDK.

Using your own HTTP client

Any PSR-18 client works. When you inject one, timeouts, proxies and TLS settings are whatever you configured on it. When the SDK discovers Guzzle itself it creates the client with a 30-second timeout and a 5-second connect timeout; any other discovered client runs with its own defaults.

Factories you leave out are discovered from the installed packages.

Payment window as an HTML form

The payment window can also be opened by posting a signed form directly from the browser, without an API call. It needs the gateway id and payment window secret from the OnPay management panel, plus an accept URL. Prefer creating the payment through the API when you can.

The result is verified exactly as in Verify the result.


All versions of php-sdk with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
ext-json Version *
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^1.1 || ^2.0
php-http/discovery Version ^1.19
psr/log Version ^1.0.2 || ^2.0 || ^3.0
league/oauth2-client Version ^2.9
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package onpayio/php-sdk contains the following files

Loading the files please wait ...