Skip to content

Commit c383b5a

Browse files
Refactoring of namespace ++; Added documentation & dynamic links
1 parent e3ade75 commit c383b5a

17 files changed

Lines changed: 195 additions & 103 deletions

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ Each resource (class) can be accessed via magic property on the Merchants API ob
4040
```php
4141
$merchant_api->api_keys->...;
4242
$merchant_api->balance->...;
43-
$merchant_api->dynamic_links->...;
4443
$merchant_api->payment_requests->...;
4544
$merchant_api->payment_sends->...;
4645
$merchant_api->pos->...;
@@ -66,7 +65,7 @@ Only `PaymentRequests` class has a few extra helper methods:
6665
$merchant_api->payment_requests->capture($payment_request_id,$currency,$amount)
6766
$merchant_api->payment_requests->refund($payment_request_id, $currency, $amount);
6867
$merchant_api->payment_requests->getPaymentLink($payment_request_id);
69-
$merchant_api->payment_requests->getMobilePaymentLink($payment_request_id);
68+
$merchant_api->payment_requests->getDynamicLink($payment_request_id);
7069
```
7170

7271

@@ -90,3 +89,10 @@ Here's an example for nginx:
9089
proxy_set_header Authorization $http_authorization;
9190
proxy_pass_header Authorization;
9291
```
92+
93+
Two methods on the `SettleApiClient` class can be used in relation to the callbacks:
94+
95+
```php
96+
// the following will return
97+
$settle_client->isValidCallback($callbackUrl, $body, $headers, $method);
98+
```

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
"ext-openssl": "*"
1818
},
1919
"require-dev": {
20-
"pestphp/pest": "^1.20",
21-
"php-coveralls/php-coveralls": "^2.4",
22-
"vlucas/phpdotenv": "^5.3"
20+
"pestphp/pest": "^1.21",
21+
"php-coveralls/php-coveralls": "^2.5",
22+
"vlucas/phpdotenv": "^5.4"
2323
},
2424
"autoload": {
2525
"psr-4": {
26-
"Danielz\\SettleApi\\": "src/"
26+
"SettleApi\\": "src/"
2727
}
2828
},
2929
"scripts": {

src/MerchantApi/ApiKeys.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<?php
22

3-
namespace Danielz\SettleApi\MerchantApi;
3+
namespace SettleApi\MerchantApi;
44

5-
use Danielz\SettleApi\SettleApi;
6-
use Danielz\SettleApi\SettleApiException;
5+
use SettleApi\SettleApi;
6+
use SettleApi\SettleApiException;
77

88
/**
99
* Class ApiKeys
10-
* @package Danielz\SettleApi\MerchantApi
10+
* @package SettleApi\MerchantApi
11+
* @link https://api.support.settle.eu/api/reference/rest/v1/merchant.apiKeys/
1112
*/
1213
class ApiKeys extends SettleApi
1314
{

src/MerchantApi/Balance.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<?php
22

3-
namespace Danielz\SettleApi\MerchantApi;
3+
namespace SettleApi\MerchantApi;
44

5-
use Danielz\SettleApi\SettleApi;
6-
use Danielz\SettleApi\SettleApiException;
5+
use SettleApi\SettleApi;
6+
use SettleApi\SettleApiException;
77

88
/**
99
* Class Balance
10-
* @package Danielz\SettleApi\MerchantApi
10+
* @package SettleApi\MerchantApi
11+
* @link https://api.support.settle.eu/api/reference/rest/v1/merchant.balance/
1112
*/
1213
class Balance extends SettleApi
1314
{

src/MerchantApi/MerchantApi.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<?php
22

3-
namespace Danielz\SettleApi\MerchantApi;
3+
namespace SettleApi\MerchantApi;
44

5-
use Danielz\SettleApi\SettleApi;
5+
use SettleApi\SettleApi;
66

77
/**
88
* Class MerchantApi
9-
* @package Danielz\SettleApi\MerchantApi
9+
* @package SettleApi\MerchantApi
1010
*
1111
* @property ApiKeys api_keys
1212
* @property PaymentRequests payment_requests
1313
* @property PaymentSends payment_sends
1414
* @property Pos pos
1515
* @property Settlements settlements
16-
* @property Shortlinks shortlinks
16+
* @property ShortLinks short_links
1717
* @property Balance balance
1818
* @property Profile profile
1919
* @property StatusCodes status_codes
@@ -33,7 +33,7 @@ protected function getMagicProperties()
3333
'pos' => Pos::class,
3434
'profile' => Profile::class,
3535
'settlements' => Settlements::class,
36-
'shortlinks' => Shortlinks::class,
36+
'short_links' => ShortLinks::class,
3737
'status_codes' => StatusCodes::class,
3838
];
3939
}

src/MerchantApi/PaymentRequests.php

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<?php
22

3-
namespace Danielz\SettleApi\MerchantApi;
3+
namespace SettleApi\MerchantApi;
44

5-
use Danielz\SettleApi\SettleApi;
6-
use Danielz\SettleApi\SettleApiException;
5+
use SettleApi\SettleApi;
6+
use SettleApi\SettleApiClient;
7+
use SettleApi\SettleApiException;
78

89
/**
910
* Class PaymentRequests
10-
* @package Danielz\SettleApi\MerchantApi
11+
* @package SettleApi\MerchantApi
12+
* @link https://api.support.settle.eu/api/reference/rest/v1/merchant.payment.request/
1113
*/
1214
class PaymentRequests extends SettleApi
1315
{
@@ -66,16 +68,22 @@ public function outcome($payment_request_id)
6668
* @param string $currency
6769
* @param float|int $amount
6870
* @param float|int $additional_amount
71+
* @param string $capture_id
6972
* @return array
73+
* @throws SettleApiException
7074
*/
71-
public function capture($payment_request_id, $currency, $amount, $additional_amount = 0)
75+
public function capture($payment_request_id, $currency, $amount, $additional_amount = 0, $capture_id = '')
7276
{
77+
if (empty($capture_id)) {
78+
$capture_id = 'cap_' . date('YmdHis');
79+
}
80+
7381
$data = [
7482
'action' => 'capture',
7583
'currency' => $currency,
7684
'amount' => $amount,
7785
'additional_amount' => $additional_amount,
78-
'capture_id' => 'cap_' . date('YmdHis'),
86+
'capture_id' => $capture_id,
7987
];
8088

8189
return $this->update($payment_request_id, $data);
@@ -87,16 +95,22 @@ public function capture($payment_request_id, $currency, $amount, $additional_amo
8795
* @param float $amount
8896
* @param float|int $additional_amount
8997
* @param string $message
98+
* @param string $refund_id
9099
* @return array
100+
* @throws SettleApiException
91101
*/
92-
public function refund($payment_request_id, $currency, $amount, $additional_amount = 0, $message = '')
102+
public function refund($payment_request_id, $currency, $amount, $additional_amount = 0, $message = '', $refund_id = '')
93103
{
104+
if (empty($refund_id)) {
105+
$refund_id = 'ref_' . date('YmdHis');
106+
}
107+
94108
$data = [
95109
'action' => 'refund',
96110
'currency' => $currency,
97111
'amount' => $amount,
98112
'additional_amount' => $additional_amount,
99-
'refund_id' => 'ref_' . date('YmdHis'),
113+
'refund_id' => $refund_id,
100114
'text' => $message,
101115
];
102116

@@ -109,15 +123,16 @@ public function refund($payment_request_id, $currency, $amount, $additional_amou
109123
*/
110124
public function getPaymentLink($payment_request_id)
111125
{
112-
return $this->createLink('payment_link', compact('payment_request_id'));
126+
return $this->createLink(SettleApiClient::LINK_TEMPLATE_PAYMENT, compact('payment_request_id'));
113127
}
114128

115129
/**
116130
* @param string $payment_request_id
131+
* @param array $socialData
117132
* @return string
118133
*/
119-
public function getMobilePaymentLink($payment_request_id)
134+
public function getDynamicLink($payment_request_id, $socialData = [])
120135
{
121-
return $this->createLink('payment_link_mobile', compact('payment_request_id'));
136+
return $this->createLink(SettleApiClient::LINK_TEMPLATE_DYNAMIC, compact('payment_request_id'), $socialData);
122137
}
123138
}

src/MerchantApi/PaymentSends.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<?php
22

3-
namespace Danielz\SettleApi\MerchantApi;
3+
namespace SettleApi\MerchantApi;
44

5-
use Danielz\SettleApi\SettleApi;
6-
use Danielz\SettleApi\SettleApiException;
5+
use SettleApi\SettleApi;
6+
use SettleApi\SettleApiException;
77

88
/**
99
* Class PaymentSends
10-
* @package Danielz\SettleApi\MerchantApi
10+
* @package SettleApi\MerchantApi
11+
* @link https://api.support.settle.eu/api/reference/rest/v1/merchant.payment.send/
1112
*/
1213
class PaymentSends extends SettleApi
1314
{

src/MerchantApi/Pos.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<?php
22

3-
namespace Danielz\SettleApi\MerchantApi;
3+
namespace SettleApi\MerchantApi;
44

5-
use Danielz\SettleApi\SettleApi;
6-
use Danielz\SettleApi\SettleApiException;
5+
use SettleApi\SettleApi;
6+
use SettleApi\SettleApiException;
77

88
/**
99
* Class Pos
10-
* @package Danielz\SettleApi\MerchantApi
10+
* @package SettleApi\MerchantApi
11+
* @link https://api.support.settle.eu/api/reference/rest/v1/merchant.pos/
1112
*/
1213
class Pos extends SettleApi
1314
{

src/MerchantApi/Profile.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<?php
22

3-
namespace Danielz\SettleApi\MerchantApi;
3+
namespace SettleApi\MerchantApi;
44

5-
use Danielz\SettleApi\SettleApi;
6-
use Danielz\SettleApi\SettleApiException;
5+
use SettleApi\SettleApi;
6+
use SettleApi\SettleApiException;
77

88
/**
99
* Class Profile
10-
* @package Danielz\SettleApi\MerchantApi
10+
* @package SettleApi\MerchantApi
11+
* @link https://api.support.settle.eu/api/reference/rest/v1/merchant.profile/
1112
*/
1213
class Profile extends SettleApi
1314
{

src/MerchantApi/Settlements.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

3-
namespace Danielz\SettleApi\MerchantApi;
3+
namespace SettleApi\MerchantApi;
44

5-
use Danielz\SettleApi\SettleApi;
6-
use Danielz\SettleApi\SettleApiException;
5+
use SettleApi\SettleApi;
6+
use SettleApi\SettleApiException;
77

88
/**
99
* Class Settlements
10-
* @package Danielz\SettleApi\MerchantApi
10+
* @package SettleApi\MerchantApi
1111
*/
1212
class Settlements extends SettleApi
1313
{
@@ -33,6 +33,7 @@ public function get($settlement_id)
3333
/**
3434
* @return array
3535
* @throws SettleApiException
36+
* @todo This endpoint isn't working properly
3637
*/
3738
public function latest()
3839
{
@@ -42,6 +43,7 @@ public function latest()
4243
/**
4344
* @return array
4445
* @throws SettleApiException
46+
* @todo This endpoint isn't working properly
4547
*/
4648
public function report()
4749
{

0 commit comments

Comments
 (0)