paysera / lib-wallet-transfer-rest-client
PHP REST client for Paysera.com Wallet Transfers
Installs: 140 092
Dependents: 2
Suggesters: 0
Security: 0
Stars: 3
Watchers: 11
Forks: 4
Open Issues: 1
Requires
- php: >=5.5
- fig/http-message-util: ^1.0
- paysera/lib-rest-client-common: ^1.0 | ^2.1
README
Provides methods to manipulate Transfers
API.
It automatically authenticates all requests and maps required data structure for you.
Usage
This library provides ClientFactory
class, which you should use to get the API client itself:
use Paysera\Client\TransfersClient\ClientFactory; $clientFactory = new ClientFactory([ 'base_url' => 'https://wallet.paysera.com/transfer/rest/v1/', // optional, in case you need a custom one. 'basic' => [ // use this, it API requires Basic authentication. 'username' => 'username', 'password' => 'password', ], 'oauth' => [ // use this, it API requires OAuth v2 authentication. 'token' => [ 'access_token' => 'my-access-token', 'refresh_token' => 'my-refresh-token', ], ], // other configuration options, if needed ]); $transfersClient = $clientFactory->getTransfersClient();
Please use only one authentication mechanism, provided by Paysera
.
Now, that you have instance of TransfersClient
, you can use following methods
Methods
It reserves funds for transfer and makes it "reserved". It's enough for transfer to be processed. If there are not enough funds, any limits are reached etc., transfer will be still "new" and no action will take place. Returns error if no funds available.
use Paysera\Client\TransfersClient\Entity as Entities; $transferRegistrationParameters = new Entities\TransferRegistrationParameters(); $transferRegistrationParameters->setConvertCurrency($convertCurrency); $transferRegistrationParameters->setUserIp($userIp); $result = $transfersClient->reserveTransfer($id, $transferRegistrationParameters);
Provide password for transfer with status waiting_password
. If operation is successful, transfer status becomes done
. Available only for internal transfers. Returns error if password provided is invalid.
use Paysera\Client\TransfersClient\Entity as Entities; $transferPassword = new Entities\TransferPassword(); $transferPassword->setValue($value); $result = $transfersClient->provideTransferPassword($id, $transferPassword);
Make transfer visible in frontend for signing. If currency convert operations are related to transfer, they are done when transfer becomes reserved
. If there are expectations in currency convert requests, transfer becomes failed
together with related conversion request(s) if those expectations fails. This only makes transfer "reserved", so it's visible in our Web UI for signing
use Paysera\Client\TransfersClient\Entity as Entities; $transferRegistrationParameters = new Entities\TransferRegistrationParameters(); $transferRegistrationParameters->setConvertCurrency($convertCurrency); $transferRegistrationParameters->setUserIp($userIp); $result = $transfersClient->registerTransfer($id, $transferRegistrationParameters);
Signs the transfer
use Paysera\Client\TransfersClient\Entity as Entities; $transferRegistrationParameters = new Entities\TransferRegistrationParameters(); $transferRegistrationParameters->setConvertCurrency($convertCurrency); $transferRegistrationParameters->setUserIp($userIp); $result = $transfersClient->signTransfer($id, $transferRegistrationParameters);
Get transfer.
$result = $transfersClient->getTransfer($id);
Revoke transfer.
$result = $transfersClient->deleteTransfer($id);
Create transfer in the system. Created transfer is invisible and will be deleted if no more actions are performed.
use Paysera\Client\TransfersClient\Entity as Entities; $transferInput = new Entities\TransferInput(); $transferInput->setAmount($amount); $transferInput->setBeneficiary($beneficiary); $transferInput->setPayer($payer); $transferInput->setFinalBeneficiary($finalBeneficiary); $transferInput->setPerformAt($performAt); $transferInput->setChargeType($chargeType); $transferInput->setUrgency($urgency); $transferInput->setNotifications($notifications); $transferInput->setPurpose($purpose); $transferInput->setPassword($password); $transferInput->setCancelable($cancelable); $transferInput->setAutoCurrencyConvert($autoCurrencyConvert); $transferInput->setAutoChargeRelatedCard($autoChargeRelatedCard); $transferInput->setAutoProcessToDone($autoProcessToDone); $transferInput->setReserveUntil($reserveUntil); $transferInput->setCallback($callback); $result = $transfersClient->createTransfer($transferInput);
Standard SQL-style Result filtering
use Paysera\Client\TransfersClient\Entity as Entities; $transfersFilter = new Entities\TransfersFilter(); $transfersFilter->setCreatedDateFrom($createdDateFrom); $transfersFilter->setCreatedDateTo($createdDateTo); $transfersFilter->setCreditAccountNumber($creditAccountNumber); $transfersFilter->setDebitAccountNumber($debitAccountNumber); $transfersFilter->setStatuses($statuses); $result = $transfersClient->getTransfers($transfersFilter);