vragovr / safecrow-api
SafeCrow API v3 Client
Installs: 8 432
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 1
Open Issues: 0
Requires
- php: >=7.0.0
- php-http/client-common: ^1.0
- php-http/client-implementation: ^1.0
- php-http/discovery: ^1.0
- php-http/httplug: ^1.0
- php-http/message: ^1.0
- psr/http-message: ^1.0
- symfony/options-resolver: ^3.0 || ^4.0
Requires (Dev)
- guzzlehttp/psr7: ^1.0
- php-http/curl-client: ^1.0
- php-http/mock-client: ^1.0
- phpunit/phpunit: 6.0.*
README
A PHP wrapper to be used with SafeCrow API v3.
Installation
1: Download
$ composer require vragovr/safecrow-api "^1.0"
2: Configure
$config = new \SafeCrow\Config('key', 'secret'); $client = new \SafeCrow\Client(); $client->authenticate($config);
3.1: Usage User Api
# Add user $user = $client->getUserApi()->add([ 'name' => 'Ivan Ivanov', 'phone' => '79009996666', 'email' => 'email@example.org', ]); # Edit user $user = $client->getUserApi()->edit([ 'name' => 'Ivan Ivanov', 'phone' => '79009996666', 'email' => 'email@example.org', ]); # All users $users = $client->getUserApi()->all(); # Show user $user = $client->getUserApi()->show(1); # All user orders $orders = $client->getUserApi()->orders(1); # Bind user card $url = $client->getUserApi()->bind(1, [ 'callback_url' => 'https://example.org/success-card', ]); # All users cards $cards = $client->getUserApi()->cards([ 'all' => true, ]);
3.2: Usage Order Api
# Add order $order = $client->getOrderApi()->add([ 'consumer_id' => 1, 'supplier_id' => 2, 'price' => 10000, 'description' => 'description...', 'service_cost_payer' => Order::PAYER_HALF, // or Order::PAYER_CONSUMER or Order::PAYER_SUPPLIER ]); # All order $orders = $client->getOrderApi()->all(); # Show order $order = $client->getOrderApi()->show(1); # Pay order $url = $client->getOrderApi()->pay([ 'callback_url' => 'https://example.org/success-order', ]); # Annul order $order = $client->getOrderApi()->annul([ 'reason' => 'reason...', ]); # Cancel order $order = $client->getOrderApi()->cancel([ 'reason' => 'reason...', ]); # Close order $order = $client->getOrderApi()->close(1, [ 'reason' => 'reason...', ]); # Escalate order $order = $client->getOrderApi()->escalate(1, [ 'reason' => 'reason...', ]); # Bind card to order $order = $client->getOrderApi()->bind(1, 1, [ 'supplier_payout_card_id' => 1, ]);
3.3: Usage Setting Api
# Show setting $setting = $client->getSettingApi()->show(); # Edit setting $setting = $client->getSettingApi()->edit([ 'callback_url' => 'https://example.org/callback-order', ]);
3.4: Usage Calculate Api
# Calculate $calculate = $client->getCalculateApi()->calculate([ 'price' => 1000, 'service_cost_payer' => Order::PAYER_HALF, // or Order::PAYER_CONSUMER or Order::PAYER_SUPPLIER ]);