Skip to content

Commit

Permalink
Merge pull request #36 from xsolla/payment_accounts
Browse files Browse the repository at this point in the history
Added support for Saved Payment Accounts API methods to `XsollaClient`.
  • Loading branch information
ipanyukov committed May 25, 2016
2 parents a000633 + 3341350 commit 2168058
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.
## [Unreleased](https://github.com/xsolla/xsolla-sdk-php/compare/v2.5.0...master)
### Added
* Added public user id processing for [User Search](http://developers.xsolla.com/api.html#user-search) webhook method.
* Added support for [Saved Payment Accounts](http://developers.xsolla.com/api.html#direct-payments) API methods to `XsollaClient`.

## [v2.5.0](https://github.com/xsolla/xsolla-sdk-php/compare/v2.4.1...v2.5.0) - 2016-05-18
### Added
Expand Down
80 changes: 80 additions & 0 deletions src/API/Resources/xsolla-2015-07-23.php
Original file line number Diff line number Diff line change
Expand Up @@ -1889,5 +1889,85 @@
),
),
),
//Payment Accounts
'ListPaymentAccounts' => array(
'httpMethod' => 'GET',
'uri' => '/merchant/projects/{project_id}/users/{user_id}/payment_accounts',
'summary' => 'List of the saved payment accounts',
'parameters' => array(
'project_id' => array(
'location' => 'uri',
'type' => 'integer',
'required' => true,
),
'user_id' => array(
'location' => 'uri',
'type' => 'string',
'required' => true,
),
),
),
'ChargePaymentAccount' => array(
'httpMethod' => 'POST',
'uri' => '/merchant/projects/{project_id}/users/{user_id}/payments/{type}/{account_id}',
'summary' => 'Charge using the saved payment account',
'parameters' => array(
'project_id' => array(
'location' => 'uri',
'type' => 'integer',
'required' => true,
),
'user_id' => array(
'location' => 'uri',
'type' => 'string',
'required' => true,
),
'type' => array(
'location' => 'uri',
'type' => 'string',
'required' => true,
),
'account_id' => array(
'location' => 'uri',
'type' => 'integer',
'required' => true,
),
'request' => array(
'location' => 'body',
'type' => 'array',
'required' => true,
'filters' => array(
'\Xsolla\SDK\API\XsollaClient::jsonEncode',
),
),
),
),
'DeletePaymentAccount' => array(
'httpMethod' => 'DELETE',
'uri' => '/merchant/projects/{project_id}/users/{user_id}/payments/{type}/{account_id}',
'summary' => 'Delete the saved payment account',
'parameters' => array(
'project_id' => array(
'location' => 'uri',
'type' => 'integer',
'required' => true,
),
'user_id' => array(
'location' => 'uri',
'type' => 'string',
'required' => true,
),
'type' => array(
'location' => 'uri',
'type' => 'string',
'required' => true,
),
'account_id' => array(
'location' => 'uri',
'type' => 'integer',
'required' => true,
),
),
),
),
);
4 changes: 4 additions & 0 deletions src/API/XsollaClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@
* @method array GetProject(array $args = array()) Get a project http://developers.xsolla.com/api.html#get-a-project
* @method array UpdateProject(array $args = array()) Update a project http://developers.xsolla.com/api.html#update-a-project
* @method array ListProjects(array $args = array()) List all projects http://developers.xsolla.com/api.html#list-all-projects
*
* @method array ListPaymentAccounts(array $args = array()) List of the saved payment accounts http://developers.xsolla.com/api.html#list-saved-payment-accounts
* @method array ChargePaymentAccount(array $args = array()) Charge using the saved payment account http://developers.xsolla.com/api.html#charge-using-saved-payment-account
* @method array DeletePaymentAccount(array $args = array()) Delete the saved payment account http://developers.xsolla.com/api.html#delete-a-saved-payment-account
*/
class XsollaClient extends Client
{
Expand Down
38 changes: 38 additions & 0 deletions tests/Integration/API/PaymentAccountsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Xsolla\SDK\Tests\Integration\API;

/**
* @group api
*/
class PaymentAccountsTest extends AbstractAPITest
{
protected static $userId;

public function setUp()
{
parent::setUp();
if (!static::$userId) {
static::$userId = 'Game User';
}
}

public function testListPaymentAccounts()
{
$response = $this->xsollaClient->ListPaymentAccounts(array(
'project_id' => $this->projectId,
'user_id' => static::$userId,
));
static::assertInternalType('array', $response);
}

public function testChargePaymentAccount()
{
static::markTestIncomplete('TODO: 404');
}

public function testDeletePaymentAccount()
{
static::markTestIncomplete('TODO: 404');
}
}

0 comments on commit 2168058

Please sign in to comment.