Skip to content

Commit 36f9f80

Browse files
committed
Add payment source and resource request method
1 parent b385444 commit 36f9f80

7 files changed

Lines changed: 62 additions & 9 deletions

File tree

lib/OAuth/Client.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ class Client extends Resource
1313
public static function grantClientCredentials()
1414
{
1515
list($response, $opts) = static::_staticRequest(
16-
'post', '/oauth/token',
16+
'post',
17+
'/oauth/token',
1718
[
1819
'grant_type' => 'client_credentials',
1920
'client_id' => FedaPay::getOauthClientId(),

lib/PaymentSource.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace FedaPay;
4+
5+
/**
6+
* Class PhoneNumber
7+
*
8+
* @property int $id
9+
* @property string product
10+
* @property string channel
11+
* @property string referrer
12+
* @property string lib
13+
* @property string lib_version
14+
* @property string api_version
15+
* @property string ip
16+
* @property string device
17+
* @property string os
18+
* @property string browser
19+
* @property string country
20+
* @property string city
21+
* @property string region
22+
* @property string latitude
23+
* @property string longitude
24+
* @property string account_id
25+
* @property string sourceable_type
26+
* @property string sourceable_id
27+
* @property string os_version
28+
* @property string browser_version
29+
* @property string device_vendor
30+
* @property string created_at
31+
* @property string updated_at
32+
*
33+
* @package FedaPay
34+
*/
35+
class PaymentSource extends Resource
36+
{
37+
38+
}

lib/Requestor.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,12 @@ protected function defaultHeaders()
125125
$accountId = FedaPay::getAccountId();
126126

127127
$default = [
128-
'X-Version' => FedaPay::VERSION,
129-
'X-Api-Version' => $apiVersion,
130-
'X-Source' => 'FedaPay PhpLib',
128+
// Deprecated 'X-Version' => FedaPay::VERSION,
129+
'X-FedaPay-Lib-Version' => FedaPay::VERSION,
130+
// Deprecated 'X-Api-Version' => $apiVersion,
131+
'X-FedaPay-Api-Version' => $apiVersion,
132+
// Deprecated 'X-Source' => 'FedaPay PhpLib',
133+
'X-FedaPay-Lib' => 'FedaPay PhpLib',
131134
'Authorization' => "Bearer $auth"
132135
];
133136

lib/Resource.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
* @package FedaPay
1212
*/
13-
abstract class Resource extends FedaPayObject
13+
class Resource extends FedaPayObject
1414
{
1515
use ApiOperations\Request;
1616

@@ -103,4 +103,14 @@ public function instanceUrl()
103103
{
104104
return static::resourcePath($this['id']);
105105
}
106+
107+
/**
108+
* Send any request
109+
* @return FedaPay\FedaPayObject
110+
*/
111+
public static function request($method, $url, $params = [], $headers = [])
112+
{
113+
list($response, $opts) = static::_staticRequest($method, $url, $params, $headers);
114+
return Util::arrayToFedaPayObject($response, $opts);
115+
}
106116
}

lib/Util/Util.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public static function convertToFedaPayObject($resp, $opts)
5858
'v1/page' => 'FedaPay\\Page',
5959
'v1/invoice' => 'FedaPay\\Invoice',
6060
'v1/balance' => 'FedaPay\\Balance',
61+
'v1/payment_source' => 'FedaPay\\PaymentSource',
6162
];
6263

6364
if (self::isList($resp)) {

tests/BaseTestCase.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ protected function setUpConfig()
2121

2222
\FedaPay\Requestor::setHttpClient(\FedaPay\HttpClient\CurlClient::instance());
2323
$this->defaultHeaders = [
24-
'X-Version' => \FedaPay\FedaPay::VERSION,
25-
'X-Api-Version' => \FedaPay\FedaPay::getApiVersion(),
26-
'X-Source' => 'FedaPay PhpLib',
24+
'X-FedaPay-Lib-Version' => \FedaPay\FedaPay::VERSION,
25+
'X-FedaPay-Api-Version' => \FedaPay\FedaPay::getApiVersion(),
26+
'X-FedaPay-Lib' => 'FedaPay PhpLib',
2727
'Authorization' => 'Bearer '. (self::API_KEY ?: self::OAUTH_TOKEN)
2828
];
2929
}

tests/RequestorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function testRequestSetParams()
5757
[
5858
'Authorization' => 'Bearer mytoken',
5959
'FedaPay-Account' => 898,
60-
'X-Api-Version' => 'v3',
60+
'X-FedaPay-Api-Version' => 'v3',
6161
'X-Custom' => 'foo'
6262
]
6363
);

0 commit comments

Comments
 (0)