https://github.com/paysera/lib-wallet-php-client
PHP client for Paysera.com Wallet API
https://github.com/paysera/lib-wallet-php-client
Last synced: 2 months ago
JSON representation
PHP client for Paysera.com Wallet API
- Host: GitHub
- URL: https://github.com/paysera/lib-wallet-php-client
- Owner: paysera
- Created: 2013-07-01T07:02:34.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2025-04-08T07:03:14.000Z (2 months ago)
- Last Synced: 2025-04-09T20:08:59.850Z (2 months ago)
- Language: PHP
- Size: 541 KB
- Stars: 19
- Watchers: 16
- Forks: 34
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
PHP client for Paysera.com Wallet API 
=========
This is repository for PHP client, used with [Paysera.com Wallet API](https://developers.paysera.com/en/wallet).OAuth example
--------------
```php
setCertificatePath('/path/to/cert.crt')
// ->setPrivateKeyPath('/path/to/private.key');// create main object to use for all functionality
$api = new Paysera_WalletApi($clientId, $secret);// for sandbox environment, use the following code instead:
// $api = new Paysera_WalletApi($clientId, $secret, Paysera_WalletApi_Util_Router::createForSandbox());// get service, responsible for OAuth code grant type integration
$oauth = $api->oauthConsumer();// example how to get ask and get information about paysera.com user
session_start();
try {
if (!isset($_SESSION['token'])) { // no token in session - let's get the token
$token = $oauth->getOAuthAccessToken(); // this gets code query parameter if available and exchanges for token
if ($token === null) { // no code parameter - redirect user to authentication endpoint
$redirectUri = null; // URL of this file; it's optional parameter
header('Location: ' . $oauth->getAuthorizationUri(array( // scopes are optional, no scope allows to get user ID/wallet ID
Paysera_WalletApi_OAuth_Consumer::SCOPE_EMAIL, // to get user's main email address
// Paysera_WalletApi_OAuth_Consumer::SCOPE_IDENTITY, // this scope allows to get personal code, name and surname
// Paysera_WalletApi_OAuth_Consumer::SCOPE_FULL_NAME, // use this scope if only name and surname is needed
// Paysera_WalletApi_OAuth_Consumer::SCOPE_IDENTITY_OFFLINE, // this allows to get identity by user ID, after token has expired, using API, not related to token
), $redirectUri));
} else {
$_SESSION['token'] = $token;
}
}if (isset($_SESSION['token'])) {
$tokenRelatedClient = $api->walletClientWithToken($_SESSION['token']);
echo '';';
$user = $tokenRelatedClient->getUser();
var_dump($user);
// $user->getId(); // you can save user ID (on paysera.com), user's email etc.
// var_dump($api->walletClient()->getUserIdentity($userId)); // if you have offline scope, you can get info by user ID later
echo '
$_SESSION['token'] = $tokenRelatedClient->getCurrentAccessToken(); // this could be refreshed, re-save
}} catch (Exception $e) {
echo '', $e, '';
}
```## Contacts
If you have any further questions feel free to contact us:„Paysera LT“, UAB \
Pilaitės pr. 16 \
LT-04352 Vilnius \
Email: [email protected] \
Tel. +37052071558