Download the PHP package capusta/php-sdk without Composer
On this page you can find all versions of the php package capusta/php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-sdk
Capusta.Space PHP SDK
Latest version is v1.14.0
Documentation: https://dev.capusta.space/
Requirements
PHP 7.2 and later.
Dependencies
The bindings require the following extensions in order to work properly:
curl
, although you can use your own non-cURL client if you prefer.json
mbstring
(Multibyte String)php-fig/log
guzzlehttp/psr7
Optionally
guzzlehttp/guzzle
for use guzzle instead of cURL.
Composer
First, you need to install Composer to your system. (https://getcomposer.org/doc/00-intro.md#installation-linux-unix-macos)
After Composer is installed to your system you need to run the following command:
To use the bindings, use Composer's autoload:
If you use Composer, these dependencies should be handled automatically.
Getting Started
We recommend using the GuzzleHttp Client
Init client
All requests are processed in similar steps:
- Create request instance of
Capusta\SDK\Model\Request\AbstractRequest
- Request serialization
- Sending a request to the server
- You have a response object instance of
Capusta\SDK\Model\Response\AbstractResponse
or throws exception if request fail
All requests are creating by suitable objects or can be created on the basis of arrays, integers and strings
Create payment
Creating request with object
or you can create request with array
if you have got $createPaymentResponse->getStatus() == 'CREATED'
,
then you need to redirect user to URL: $createPaymentResponse->getPayUrl()
Create bill
Creating request with object
or you can create request with array
If you have got $createBillResponse->getStatus() == 'CREATED'
,
then you need to redirect user to URL: $createBillResponse->getPayUrl()
Create payout
Creating request with object
or you can create request with array
Getting payment status
Creating request with object
or you can create request with array
Getting BILL status (status v2)
(with array of successfull payments inside of 'transactions' property)
Creating request with object
or you can create request with array
If you want to get array of successfull transactions of bill or payment you need to call method $getStatusResponse->getTransactions().
Getting payments registry
Array of successfull payments.
- NOTE: Difference between from and to dates not be more than 24 hours.
or you can get payments registry with array request
Create project
(this method is disabled by default, you need to ask support to switch this on)
Creating request with object
or you can create request with array
returned object $createProjectResponse contains properties within the 'status' property. If 'status' is "NEW" - the project is successfully created.
Exceptions
Capusta\SDK\Exception\TransportException
- throws in the case of an api transport error. For example, when authorization data is not provided.Capusta\SDK\Exception\JsonParseException
- the server response doesn't contain a valid json.Capusta\SDK\Exception\ServerResponse\ResponseException
- 4xx and 5xx server errors.Capusta\SDK\Exception\Response\ResponseParseException
- create response errors.Capusta\SDK\Exception\Request\RequestParseException
- create request errors.
Processing notification from server
This code is responsible for processing the payment result. You need to create handler, make it available on URL in your application and specify the URL in the project settings in my.capusta.space. This handler will be called after the user makes a payment using the form on capusta.space
$responseNotification contains object with notification parameters. For example, you can get main parameters like this:
For example, you can get main parameters like this:
You can use manual response to server:
If you use a proxy server, you can skip the IP check
Custom Api Transport
You can create your own api transport by extending Capusta\SDK\Transport\AbstractApiTransport
All versions of php-sdk with dependencies
ext-curl Version *
ext-json Version *
ext-mbstring Version *
psr/log Version >=1.1
guzzlehttp/psr7 Version ^1.6
guzzlehttp/guzzle Version ~7.0