Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/igormukhingmailcom/privatbank-bundle
Symfony bundle to interact with Privatbank/Privat24 API
https://github.com/igormukhingmailcom/privatbank-bundle
Last synced: 12 days ago
JSON representation
Symfony bundle to interact with Privatbank/Privat24 API
- Host: GitHub
- URL: https://github.com/igormukhingmailcom/privatbank-bundle
- Owner: igormukhingmailcom
- Created: 2017-04-29T08:50:04.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-04-30T00:08:06.000Z (over 7 years ago)
- Last Synced: 2024-10-11T03:23:39.423Z (about 1 month ago)
- Language: PHP
- Homepage: https://api.privatbank.ua/
- Size: 16.6 KB
- Stars: 2
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MukhinPrivatbankBundle
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/igormukhingmailcom/privatbank-bundle/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/igormukhingmailcom/privatbank-bundle/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/igormukhingmailcom/privatbank-bundle/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/igormukhingmailcom/privatbank-bundle/?branch=master)
[![Build Status](https://scrutinizer-ci.com/g/igormukhingmailcom/privatbank-bundle/badges/build.png?b=master)](https://scrutinizer-ci.com/g/igormukhingmailcom/privatbank-bundle/build-status/master)This bundle provides ability to interact with Privatbank/Privat24 API (https://api.privatbank.ua/p24api).
Not all available methods implemented (only informational ones for personal accounts).
Fill free to contribute.## Installation
```bash
composer require igormukhingmailcom/privatbank-bundle
``````php
# app/AppKernel.php
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
...
new Mukhin\PrivatbankBundle\MukhinPrivatbankBundle(),
];
}
}
```## Configuration
```yaml
# app/config/parameters.yml
parameters:
...
privatbank_merchant_id: 12345
privatbank_merchant_secret: Xn3U9xm01DF4888LY1W2Zz5eDXwkMrBZ
privatbank_card_number: 4149437864339229
``````yaml
# app/config/parameters.yml.dist
parameters:
...
# Privatbank merchant
privatbank_merchant_id: ~
privatbank_merchant_secret: ~
privatbank_card_number: ~
``````yaml
# app/config/config.yml
mukhin_privatbank:
merchants:
my_merchant_name:
merchant_id: "%privatbank_merchant_id%"
merchant_secret: "%privatbank_merchant_secret%"
card_number: "%privatbank_card_number%"```
Regarding this configuration, merchant service `mukhin_privatbank.merchant.my_merchant_name`
will be created.# Usage
```php
$merchant = $this->get('mukhin_privatbank.merchant.my_merchant_name');# Balance
$balance = $merchant->getBalance();
echo sprintf(
'%s: Balance at card %s is %s %s',
$balance->getBalanceDate()->format('Y-m-d H:i:s'),
$balance->getCard()->getCardNumber(),
$balance->getBalance(),
$balance->getCard()->getCurrency()
);# History
$sinceDate = new \DateTime('1970-01-01');
$toDate = new \DateTime();
$history = $merchant->getHistory($sinceDate, $toDate);echo sprintf(
'Debit is %s, credit is %s for period %s-%s',
$history->getCredit(),
$history->getDebit(),
$sinceDate->format('Y-m-d H:i:s'),
$toDate->format('Y-m-d H:i:s')
);
foreach ($history->getStatements() as $statement)
echo sprintf(
'%s %s, balance is %s %s at %s (%s)',
$statement->getSignedAmount(),
$statement->getCurrency(),
$statement->getBalance(),
$statement->getCurrency(),
$statement->getTransactionDate()->format('Y-m-d H:i:s'),
$statement->getDescription()
);
}
```# To read
* https://api.privatbank.ua/#p24/balance
* https://api.privatbank.ua/#p24/orders