Skip to content

Commit 55336c6

Browse files
Added method for mobile friendly deep links; Improved handling of received headers in callbacks from Settle;
1 parent 6c66d27 commit 55336c6

15 files changed

Lines changed: 199 additions & 186 deletions

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"php": "^7.4|^8.0",
1515
"ext-curl": "*",
1616
"ext-json": "*",
17-
"ext-openssl": "*"
17+
"ext-openssl": "*",
18+
"danielz/shape-validator-php": "^1.0"
1819
},
1920
"require-dev": {
2021
"pestphp/pest": "^1.21",

src/MerchantApi/ApiKeys.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* Class ApiKeys
1010
* @package SettleApi\MerchantApi
11-
* @link https://api.support.settle.eu/api/reference/rest/v1/merchant.apiKeys/
11+
* @link https://settleapi.stoplight.io/docs/settleapis/b3A6MTUzOTU0MDg-merchant-api-keys-list
1212
*/
1313
class ApiKeys extends SettleApi
1414
{

src/MerchantApi/Balance.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* Class Balance
1010
* @package SettleApi\MerchantApi
11-
* @link https://api.support.settle.eu/api/reference/rest/v1/merchant.balance/
11+
* @link https://settleapi.stoplight.io/docs/settleapis/b3A6MTUzOTU0NDE-merchant-balance-get
1212
*/
1313
class Balance extends SettleApi
1414
{

src/MerchantApi/PaymentRequests.php

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,44 @@
99
/**
1010
* Class PaymentRequests
1111
* @package SettleApi\MerchantApi
12-
* @link https://api.support.settle.eu/api/reference/rest/v1/merchant.payment.request/
12+
* @link https://settleapi.stoplight.io/docs/settleapis/b3A6MTUzOTU0MTE-merchant-payment-request-list
1313
*/
1414
class PaymentRequests extends SettleApi
1515
{
16+
const REQUEST_SHAPE = [
17+
'customer' => 'string',
18+
'action' => 'required|string',
19+
'currency' => 'string',
20+
'amount' => 'numeric',
21+
'pos_id' => 'string',
22+
'pos_tid' => 'string',
23+
'additional_amount' => 'numeric',
24+
'additional_edit' => 'bool',
25+
'allow_credit' => 'bool',
26+
'required_scope' => 'string',
27+
'required_scope_text' => 'string',
28+
'uri' => 'string',
29+
'scope' => 'string',
30+
'callback_uri' => 'string',
31+
'success_return_uri' => 'string',
32+
'failure_return_uri' => 'string',
33+
'display_message_uri' => 'string',
34+
'expires_in' => 'numeric',
35+
'max_scan_age' => 'numeric',
36+
'text' => 'string',
37+
'refund_id' => 'string',
38+
'capture_id' => 'string',
39+
'line_items' => 'any',
40+
'links' => 'any',
41+
];
42+
1643
/**
1744
* @return array
1845
* @throws SettleApiException
1946
*/
20-
public function list()
47+
public function list($query = [])
2148
{
22-
return $this->call('GET', 'payment_request/');
49+
return $this->call('GET', 'payment_request/', $query);
2350
}
2451

2552
/**
@@ -39,7 +66,7 @@ public function get($payment_request_id)
3966
*/
4067
public function create(array $data)
4168
{
42-
return $this->call('POST', 'payment_request/', $data);
69+
return $this->call('POST', 'payment_request/', $data, self::REQUEST_SHAPE);
4370
}
4471

4572
/**
@@ -50,7 +77,9 @@ public function create(array $data)
5077
*/
5178
public function update($payment_request_id, array $data)
5279
{
53-
return $this->call('PUT', "payment_request/{$payment_request_id}/", $data);
80+
$path = "payment_request/{$payment_request_id}/";
81+
82+
return $this->call('PUT', $path, $data, self::REQUEST_SHAPE);
5483
}
5584

5685
/**
@@ -119,20 +148,21 @@ public function refund($payment_request_id, $currency, $amount, $additional_amou
119148

120149
/**
121150
* @param string $payment_request_id
151+
* @param array $extraData
122152
* @return string
123153
*/
124-
public function getPaymentLink($payment_request_id)
154+
public function getLink($payment_request_id, $extraData = [])
125155
{
126-
return $this->createLink(SettleApiClient::LINK_TEMPLATE_PAYMENT, compact('payment_request_id'));
156+
return $this->createLink(SettleApiClient::LINK_TEMPLATE_PAYMENT, compact('payment_request_id'), $extraData);
127157
}
128158

129159
/**
130160
* @param string $payment_request_id
131-
* @param array $socialData
161+
* @param array $extraData
132162
* @return string
133163
*/
134-
public function getDynamicLink($payment_request_id, $socialData = [])
164+
public function getDeepLink($payment_request_id, $extraData = [])
135165
{
136-
return $this->createLink(SettleApiClient::LINK_TEMPLATE_DYNAMIC, compact('payment_request_id'), $socialData);
166+
return $this->createDeepLink($this->getLink($payment_request_id, $extraData));
137167
}
138168
}

src/MerchantApi/PaymentSends.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* Class PaymentSends
1010
* @package SettleApi\MerchantApi
11-
* @link https://api.support.settle.eu/api/reference/rest/v1/merchant.payment.send/
11+
* @link https://settleapi.stoplight.io/docs/settleapis/b3A6MTUzOTU0Mzc-merchant-payment-send-create
1212
*/
1313
class PaymentSends extends SettleApi
1414
{

src/MerchantApi/PermissionRequests.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* Class PermissionRequests
1010
* @package SettleApi\MerchantApi
11-
* @link https://api.support.settle.eu/api/reference/rest/v1/merchant.permissions.request/
11+
* @link https://settleapi.stoplight.io/docs/settleapis/b3A6Mjk5NjUxNjA-merchant-permissions-request-get
1212
*/
1313
class PermissionRequests extends SettleApi
1414
{

src/MerchantApi/Pos.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* Class Pos
1010
* @package SettleApi\MerchantApi
11-
* @link https://api.support.settle.eu/api/reference/rest/v1/merchant.pos/
11+
* @link https://settleapi.stoplight.io/docs/settleapis/b3A6MTUzOTU0MTY-merchant-pos-list
1212
*/
1313
class Pos extends SettleApi
1414
{

src/MerchantApi/Settlements.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
/**
99
* Class Settlements
1010
* @package SettleApi\MerchantApi
11+
* @link https://settleapi.stoplight.io/docs/settleapis/b3A6MTUzOTU0MjM-merchant-settlement-list
1112
*/
1213
class Settlements extends SettleApi
1314
{

src/MerchantApi/ShortLinks.php

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
namespace SettleApi\MerchantApi;
44

55
use SettleApi\SettleApi;
6+
use SettleApi\SettleApiClient;
67
use SettleApi\SettleApiException;
78

89
/**
910
* Class ShortLinks
1011
* @package SettleApi\MerchantApi
11-
* @link https://api.support.settle.eu/api/reference/rest/v1/merchant.shortlink/
12+
* @link https://settleapi.stoplight.io/docs/settleapis/b3A6MTUzOTU0Mjg-merchant-shortlink-list
1213
*/
1314
class ShortLinks extends SettleApi
1415
{
@@ -22,13 +23,13 @@ public function list()
2223
}
2324

2425
/**
25-
* @param string $shortlink_id
26+
* @param string $short_link_id
2627
* @return array
2728
* @throws SettleApiException
2829
*/
29-
public function get($shortlink_id)
30+
public function get($short_link_id)
3031
{
31-
return $this->call('GET', "shortlink/{$shortlink_id}/");
32+
return $this->call('GET', "shortlink/{$short_link_id}/");
3233
}
3334

3435
/**
@@ -42,23 +43,33 @@ public function create(array $data)
4243
}
4344

4445
/**
45-
* @param string $shortlink_id
46+
* @param string $short_link_id
4647
* @param array $data
4748
* @return array
4849
* @throws SettleApiException
4950
*/
50-
public function update($shortlink_id, array $data)
51+
public function update($short_link_id, array $data)
5152
{
52-
return $this->call('PUT', "shortlink/{$shortlink_id}/", $data);
53+
return $this->call('PUT', "shortlink/{$short_link_id}/", $data);
5354
}
5455

5556
/**
56-
* @param string $shortlink_id
57+
* @param string $short_link_id
5758
* @return array
5859
* @throws SettleApiException
5960
*/
60-
public function delete($shortlink_id)
61+
public function delete($short_link_id)
6162
{
62-
return $this->call('DELETE', "shortlink/{$shortlink_id}/");
63+
return $this->call('DELETE', "shortlink/{$short_link_id}/");
64+
}
65+
66+
/**
67+
* @param string $short_link_id
68+
* @param array $extraData
69+
* @return string
70+
*/
71+
public function getLink($short_link_id, $extraData = [])
72+
{
73+
return parent::createLink(SettleApiClient::LINK_TEMPLATE_SHORT_LINK, compact('short_link_id'), $extraData);
6374
}
6475
}

src/MerchantApi/StatusCodes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* Class StatusCodes
1010
* @package SettleApi\MerchantApi
11-
* @link https://api.support.settle.eu/api/reference/rest/v1/merchant.statusCodes/
11+
* @link https://settleapi.stoplight.io/docs/settleapis/b3A6MTUzOTU0MzU-merchant-status-codes-list
1212
*/
1313
class StatusCodes extends SettleApi
1414
{

0 commit comments

Comments
 (0)