Skip to content

Commit d54f8ee

Browse files
Cleanup old methods, Add Payment Request link methods, Add doc blocks
1 parent a9efcbe commit d54f8ee

17 files changed

Lines changed: 368 additions & 88 deletions

composer.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
},
2929
"scripts": {
3030
"test": "set -a; source .env; pest",
31-
"coverage": "set -a; source .env; php-coveralls --coverage_clover=coverage/logs/clover.xml --json_path=coverage/logs/coveralls-upload.json -v"
31+
"coverage": "set -a; source .env; php-coveralls --coverage_clover=coverage/logs/clover.xml --json_path=coverage/logs/coveralls-upload.json -v",
32+
"all": [
33+
"@test",
34+
"@coverage"
35+
]
3236
}
3337
}

src/MerchantApi/ApiKeys.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,59 @@
33
namespace Danielz\SettleApi\MerchantApi;
44

55
use Danielz\SettleApi\SettleApi;
6+
use Danielz\SettleApi\SettleApiException;
67

8+
/**
9+
* Class ApiKeys
10+
* @package Danielz\SettleApi\MerchantApi
11+
*/
712
class ApiKeys extends SettleApi
813
{
14+
/**
15+
* @return array
16+
* @throws SettleApiException
17+
*/
918
public function list()
1019
{
1120
return $this->call('GET', 'api_key/');
1221
}
1322

23+
/**
24+
* @param string $api_key_id
25+
* @return array
26+
* @throws SettleApiException
27+
*/
1428
public function get($api_key_id)
1529
{
1630
return $this->call('GET', "api_key/{$api_key_id}/");
1731
}
1832

33+
/**
34+
* @param array $data
35+
* @return array
36+
* @throws SettleApiException
37+
*/
1938
public function create(array $data)
2039
{
2140
return $this->call('POST', 'api_key/', $data);
2241
}
2342

43+
/**
44+
* @param string $api_key_id
45+
* @param array $data
46+
* @return array
47+
* @throws SettleApiException
48+
*/
2449
public function update($api_key_id, array $data)
2550
{
2651
return $this->call('PUT', "api_key/{$api_key_id}/", $data);
2752
}
2853

54+
/**
55+
* @param string $api_key_id
56+
* @return array
57+
* @throws SettleApiException
58+
*/
2959
public function delete($api_key_id)
3060
{
3161
return $this->call('DELETE', "api_key/{$api_key_id}/");

src/MerchantApi/Balance.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,19 @@
33
namespace Danielz\SettleApi\MerchantApi;
44

55
use Danielz\SettleApi\SettleApi;
6+
use Danielz\SettleApi\SettleApiException;
67

8+
/**
9+
* Class Balance
10+
* @package Danielz\SettleApi\MerchantApi
11+
*/
712
class Balance extends SettleApi
813
{
14+
/**
15+
* @param string $merchant_id
16+
* @return array
17+
* @throws SettleApiException
18+
*/
919
public function get($merchant_id)
1020
{
1121
return $this->call('GET', "merchant/{$merchant_id}/balance/");

src/MerchantApi/Logo.php

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/MerchantApi/MerchantApi.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@
1313
* @property PaymentSends payment_sends
1414
* @property Pos pos
1515
* @property Settlements settlements
16-
* @property SettlementAccounts settlement_accounts
17-
* @property SalesSummary sales_summary
1816
* @property Shortlinks shortlinks
1917
* @property Balance balance
20-
* @property Logo logo
2118
* @property Profile profile
2219
* @property StatusCodes status_codes
2320
*/
@@ -26,20 +23,17 @@ class MerchantApi extends SettleApi
2623
/**
2724
* @return string[]
2825
*/
29-
protected function getMagicProperties(): array
26+
protected function getMagicProperties()
3027
{
3128
return [
3229
'api_keys' => ApiKeys::class,
30+
'balance' => Balance::class,
3331
'payment_requests' => PaymentRequests::class,
3432
'payment_sends' => PaymentSends::class,
3533
'pos' => Pos::class,
34+
'profile' => Profile::class,
3635
'settlements' => Settlements::class,
37-
'settlement_accounts' => SettlementAccounts::class,
38-
'sales_summary' => SalesSummary::class,
3936
'shortlinks' => Shortlinks::class,
40-
'balance' => Balance::class,
41-
'logo' => Logo::class,
42-
'profile' => Profile::class,
4337
'status_codes' => StatusCodes::class,
4438
];
4539
}

src/MerchantApi/PaymentRequests.php

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,121 @@
33
namespace Danielz\SettleApi\MerchantApi;
44

55
use Danielz\SettleApi\SettleApi;
6+
use Danielz\SettleApi\SettleApiException;
67

8+
/**
9+
* Class PaymentRequests
10+
* @package Danielz\SettleApi\MerchantApi
11+
*/
712
class PaymentRequests extends SettleApi
813
{
14+
/**
15+
* @return array
16+
* @throws SettleApiException
17+
*/
918
public function list()
1019
{
1120
return $this->call('GET', 'payment_request/');
1221
}
1322

23+
/**
24+
* @param string $payment_request_id
25+
* @return array
26+
* @throws SettleApiException
27+
*/
1428
public function get($payment_request_id)
1529
{
1630
return $this->call('GET', "payment_request/{$payment_request_id}/");
1731
}
1832

33+
/**
34+
* @param array $data
35+
* @return array
36+
* @throws SettleApiException
37+
*/
1938
public function create(array $data)
2039
{
2140
return $this->call('POST', 'payment_request/', $data);
2241
}
2342

43+
/**
44+
* @param string $payment_request_id
45+
* @param array $data
46+
* @return array
47+
* @throws SettleApiException
48+
*/
2449
public function update($payment_request_id, array $data)
2550
{
2651
return $this->call('PUT', "payment_request/{$payment_request_id}/", $data);
2752
}
2853

54+
/**
55+
* @param string $payment_request_id
56+
* @return array
57+
* @throws SettleApiException
58+
*/
2959
public function outcome($payment_request_id)
3060
{
3161
return $this->call('GET', "payment_request/{$payment_request_id}/outcome/");
3262
}
63+
64+
/**
65+
* @param string $payment_request_id
66+
* @param string $currency
67+
* @param float|int $amount
68+
* @param float|int $additional_amount
69+
* @return array
70+
*/
71+
public function capture($payment_request_id, $currency, $amount, $additional_amount = 0)
72+
{
73+
$data = [
74+
'action' => 'capture',
75+
'currency' => $currency,
76+
'amount' => $amount,
77+
'additional_amount' => $additional_amount,
78+
'capture_id' => 'cap_' . date('YmdHis'),
79+
];
80+
81+
return $this->update($payment_request_id, $data);
82+
}
83+
84+
/**
85+
* @param string $payment_request_id
86+
* @param string $currency
87+
* @param float $amount
88+
* @param float|int $additional_amount
89+
* @param string $message
90+
* @return array
91+
*/
92+
public function refund($payment_request_id, $currency, $amount, $additional_amount = 0, $message = '')
93+
{
94+
$data = [
95+
'action' => 'refund',
96+
'currency' => $currency,
97+
'amount' => $amount,
98+
'additional_amount' => $additional_amount,
99+
'refund_id' => 'ref_' . date('YmdHis'),
100+
'text' => $message,
101+
];
102+
103+
return $this->update($payment_request_id, $data);
104+
}
105+
106+
/**
107+
* @param string $payment_request_id
108+
* @return string
109+
*/
110+
public function getPaymentLink($payment_request_id)
111+
{
112+
return $this->createLink('payment_link', compact('payment_request_id'));
113+
}
114+
115+
/**
116+
* @param string $payment_request_id
117+
* @return string
118+
*/
119+
public function getMobilePaymentLink($payment_request_id)
120+
{
121+
return $this->createLink('payment_link_mobile', compact('payment_request_id'));
122+
}
33123
}

src/MerchantApi/PaymentSends.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,29 @@
33
namespace Danielz\SettleApi\MerchantApi;
44

55
use Danielz\SettleApi\SettleApi;
6+
use Danielz\SettleApi\SettleApiException;
67

8+
/**
9+
* Class PaymentSends
10+
* @package Danielz\SettleApi\MerchantApi
11+
*/
712
class PaymentSends extends SettleApi
813
{
14+
/**
15+
* @param array $data
16+
* @return array
17+
* @throws SettleApiException
18+
*/
919
public function create(array $data)
1020
{
1121
return $this->call('POST', 'payment/', $data);
1222
}
1323

24+
/**
25+
* @param $payment_send_id
26+
* @return array
27+
* @throws SettleApiException
28+
*/
1429
public function outcome($payment_send_id)
1530
{
1631
return $this->call('GET', "payment/{$payment_send_id}/outcome/");

src/MerchantApi/Pos.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,59 @@
33
namespace Danielz\SettleApi\MerchantApi;
44

55
use Danielz\SettleApi\SettleApi;
6+
use Danielz\SettleApi\SettleApiException;
67

8+
/**
9+
* Class Pos
10+
* @package Danielz\SettleApi\MerchantApi
11+
*/
712
class Pos extends SettleApi
813
{
14+
/**
15+
* @return array
16+
* @throws SettleApiException
17+
*/
918
public function list()
1019
{
1120
return $this->call('GET', 'pos/');
1221
}
1322

23+
/**
24+
* @param string $pos_id
25+
* @return array
26+
* @throws SettleApiException
27+
*/
1428
public function get($pos_id)
1529
{
1630
return $this->call('GET', "pos/{$pos_id}/");
1731
}
1832

33+
/**
34+
* @param array $data
35+
* @return array
36+
* @throws SettleApiException
37+
*/
1938
public function create(array $data)
2039
{
2140
return $this->call('POST', 'pos/', $data);
2241
}
2342

43+
/**
44+
* @param string $pos_id
45+
* @param array $data
46+
* @return array
47+
* @throws SettleApiException
48+
*/
2449
public function update($pos_id, array $data)
2550
{
2651
return $this->call('PUT', "pos/{$pos_id}/", $data);
2752
}
2853

54+
/**
55+
* @param string $pos_id
56+
* @return array
57+
* @throws SettleApiException
58+
*/
2959
public function delete($pos_id)
3060
{
3161
return $this->call('DELETE', "pos/{$pos_id}/");

src/MerchantApi/Profile.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,29 @@
33
namespace Danielz\SettleApi\MerchantApi;
44

55
use Danielz\SettleApi\SettleApi;
6+
use Danielz\SettleApi\SettleApiException;
67

8+
/**
9+
* Class Profile
10+
* @package Danielz\SettleApi\MerchantApi
11+
*/
712
class Profile extends SettleApi
813
{
14+
/**
15+
* @param string $merchant_id
16+
* @return array
17+
* @throws SettleApiException
18+
*/
919
public function get($merchant_id)
1020
{
1121
return $this->call('GET', "merchant/{$merchant_id}/");
1222
}
1323

24+
/**
25+
* @param string $merchant_id
26+
* @return array
27+
* @throws SettleApiException
28+
*/
1429
public function lookup($merchant_id)
1530
{
1631
return $this->call('GET', "merchant_lookup/{$merchant_id}/");

src/MerchantApi/SalesSummary.php

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)