Download the PHP package zkelo/unitpay-sdk without Composer
On this page you can find all versions of the php package zkelo/unitpay-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package unitpay-sdk
Unitpay PHP SDK
This SDK allows you to work with Unitpay payment system on PHP.
Manual
Requirements
- PHP 7.1 or newer;
- Composer.
Installation
Initial configuration
SDK constructor requires at least two arguments to be passed in - it's your secret and public key. Optional third argument is domain name that will be used to interact with.
Quick start
Creating payment form link
Following example creates payment form link and redirects user to it immediately.
Hanling incoming request
Next example handles incoming Unitpay request using SDK and returns correspond response (even if request is bad).
Be aware! SDK method returns array you must encode to JSON so you need to use
json_encode()
function.
If you need to do something on success or fail request you can use third argument passed to method which reference to variable that will be used to store boolean value about request status.
As you can see in example above we passed $success
variable as third argument to method so we can easy check request status.
Creating payment by API request
Sometimes you need to init payment through request to API instead of using Unitpay form.
In example above payment method written as is, e.g. "raw". But instead of writing payment method by hand you can use constants from models. Please refer to models section for more information.
Retrieving information about payment
To retrieve payment information you should use getPayment()
method that returns information in comfortable way using model.
Localization
- ToDo.
Reference
This section will be written soon.
Exceptions
- ToDo.
Interfaces
- ToDo.
Available methods
- ToDo.
Locales
- ToDo.
Models
- ToDo.
Extending
Localization
If you need to translate currency names, payment methods or response messages to your language you can do it simply by making new locale class which extending base abstract Locale
class.
Example below shows how looks locale class.
Now, when you have class for your locale, you need to make it available for usage by adding it to Locale
model by Locale::use()
method.
After adding locale you can use it in SDK. You can set it as default or just specify it in places where needed.