Skip to content

Commit 6b8ed26

Browse files
committed
Update chainside sdk to latest API version
1 parent 74a608c commit 6b8ed26

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1073
-430
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
/.idea/
33
__pycache__
44
composer.lock
5-
test.php
5+
test.php
6+
*nigiri*

README.md

Lines changed: 164 additions & 100 deletions
Large diffs are not rendered by default.

src/Actions/ChainsideAction.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
namespace Chainside\SDK\WebPos\Actions;
44

55

6+
use Chainside\SDK\WebPos\Exceptions\ChainsideSdkException;
67
use SDK\Boilerplate\Action;
78
use SDK\Boilerplate\Context;
89
use Chainside\SDK\WebPos\Exceptions\UnknownError;
910
use SDK\Boilerplate\Contracts\Response as IResponse;
10-
use Chainside\SDK\WebPos\Exceptions\ChainsideServerException;
1111
use Chainside\SDK\WebPos\Exceptions\Factory\ChainsideExceptionFactory;
1212

1313
abstract class ChainsideAction extends Action
@@ -51,7 +51,7 @@ protected function getExceptionKey(IResponse $response)
5151

5252
/**
5353
* @param string $errorCode
54-
* @return ChainsideServerException
54+
* @return ChainsideSdkException
5555
*/
5656
protected function getException($errorCode)
5757
{

src/Actions/Factory.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@ public static function actions()
2929
"client_credentials_login" => ClientCredentialsLogin::class,
3030
"delete_payment_order" => DeletePaymentOrder::class,
3131
"get_payment_order" => GetPaymentOrder::class,
32-
"get_web_pos_payments" => GetWebPosPayments::class,
32+
"get_payment_orders" => GetPaymentOrders::class,
3333
"create_payment_order" => CreatePaymentOrder::class,
34+
"get_callbacks" => GetCallbacks::class,
35+
"payment_reset" => PaymentReset::class,
36+
"payment_update" => PaymentUpdate::class,
3437

3538
];
3639

src/Actions/GetCallbacks.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
namespace Chainside\SDK\WebPos\Actions;
4+
5+
use SDK\Boilerplate\Context;
6+
use Chainside\SDK\WebPos\Objects\GetCallbacksUrlParams;
7+
use Chainside\SDK\WebPos\Objects\CallbackList;
8+
9+
10+
/**
11+
* GetCallbacks Class
12+
*
13+
* Endpoint to retrieve the possible sent callbacks based on legal payment's state transitions
14+
*
15+
* @method CallbackList run() Execute the API call
16+
*
17+
*/
18+
class GetCallbacks extends WebPosAuthenticatedAction
19+
{
20+
21+
protected $verb = 'GET';
22+
protected $route = '/payment-order/{payment_order_uuid}/callbacks';
23+
protected $requestBodyClass = null;
24+
protected $responseBodyClass = CallbackList::class;
25+
26+
public function __construct(Context $context)
27+
{
28+
$this->routeParametersSchema = GetCallbacksUrlParams::schema()->toArray();
29+
parent::__construct($context);
30+
}
31+
32+
33+
34+
/**
35+
*
36+
* @param string $paymentOrderUuid
37+
* @return $this
38+
*/
39+
public function setPaymentOrderUuid($paymentOrderUuid) {
40+
$this->addRouteParameter('payment_order_uuid', $paymentOrderUuid);
41+
return $this;
42+
}
43+
44+
45+
46+
}

src/Actions/GetPaymentOrders.php

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
namespace Chainside\SDK\WebPos\Actions;
4+
5+
use SDK\Boilerplate\Context;
6+
use Chainside\SDK\WebPos\Objects\GetPaymentOrdersQueryParams;
7+
use Chainside\SDK\WebPos\Objects\PaymentOrderList;
8+
9+
10+
/**
11+
* GetPaymentOrders Class
12+
*
13+
* Endpoint to retrieve all business' payment orders
14+
*
15+
* @method PaymentOrderList run() Execute the API call
16+
*
17+
*/
18+
class GetPaymentOrders extends WebPosAuthenticatedAction
19+
{
20+
21+
protected $verb = 'GET';
22+
protected $route = '/payment-order';
23+
protected $requestBodyClass = null;
24+
protected $responseBodyClass = PaymentOrderList::class;
25+
26+
public function __construct(Context $context)
27+
{
28+
$this->queryParametersSchema = GetPaymentOrdersQueryParams::schema()->toArray();
29+
parent::__construct($context);
30+
}
31+
32+
/**
33+
*
34+
* @param string $status
35+
* @return $this
36+
*/
37+
public function setStatus($status) {
38+
$this->addQueryParameter('status', $status);
39+
return $this;
40+
}/**
41+
*
42+
* @param string $sortBy
43+
* @return $this
44+
*/
45+
public function setSortBy($sortBy) {
46+
$this->addQueryParameter('sort_by', $sortBy);
47+
return $this;
48+
}/**
49+
*
50+
* @param string $sortOrder
51+
* @return $this
52+
*/
53+
public function setSortOrder($sortOrder) {
54+
$this->addQueryParameter('sort_order', $sortOrder);
55+
return $this;
56+
}/**
57+
*
58+
* @param integer $page
59+
* @return $this
60+
*/
61+
public function setPage($page) {
62+
$this->addQueryParameter('page', $page);
63+
return $this;
64+
}/**
65+
*
66+
* @param integer $pageSize
67+
* @return $this
68+
*/
69+
public function setPageSize($pageSize) {
70+
$this->addQueryParameter('page_size', $pageSize);
71+
return $this;
72+
}
73+
74+
75+
76+
77+
78+
}

src/Actions/GetWebPosPayments.php

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

src/Actions/PaymentReset.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
namespace Chainside\SDK\WebPos\Actions;
4+
5+
use SDK\Boilerplate\Context;
6+
use Chainside\SDK\WebPos\Objects\PaymentResetUrlParams;
7+
use Chainside\SDK\WebPos\Objects\PaymentOrderRetrieval;
8+
9+
10+
/**
11+
* PaymentReset Class
12+
*
13+
* Endpoint to reset a payment order to its initial state
14+
*
15+
* @method PaymentOrderRetrieval run() Execute the API call
16+
*
17+
*/
18+
class PaymentReset extends WebPosAuthenticatedAction
19+
{
20+
21+
protected $verb = 'PATCH';
22+
protected $route = '/payment-order/{payment_order_uuid}/test/reset';
23+
protected $requestBodyClass = null;
24+
protected $responseBodyClass = PaymentOrderRetrieval::class;
25+
26+
public function __construct(Context $context)
27+
{
28+
$this->routeParametersSchema = PaymentResetUrlParams::schema()->toArray();
29+
parent::__construct($context);
30+
}
31+
32+
33+
34+
/**
35+
*
36+
* @param string $paymentOrderUuid
37+
* @return $this
38+
*/
39+
public function setPaymentOrderUuid($paymentOrderUuid) {
40+
$this->addRouteParameter('payment_order_uuid', $paymentOrderUuid);
41+
return $this;
42+
}
43+
44+
45+
46+
}

src/Actions/PaymentUpdate.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
namespace Chainside\SDK\WebPos\Actions;
4+
5+
use SDK\Boilerplate\Context;
6+
use Chainside\SDK\WebPos\Objects\PaymentUpdateObject;
7+
use Chainside\SDK\WebPos\Objects\PaymentUpdateUrlParams;
8+
9+
10+
/**
11+
* PaymentUpdate Class
12+
*
13+
* Endpoint to change a payment order status and trigger callbacks
14+
*
15+
*
16+
*/
17+
class PaymentUpdate extends WebPosAuthenticatedAction
18+
{
19+
20+
protected $verb = 'PATCH';
21+
protected $route = '/payment-order/{payment_order_uuid}/test/';
22+
protected $requestBodyClass = PaymentUpdateObject::class;
23+
protected $responseBodyClass = null;
24+
25+
public function __construct(Context $context)
26+
{
27+
$this->routeParametersSchema = PaymentUpdateUrlParams::schema()->toArray();
28+
parent::__construct($context);
29+
}
30+
31+
32+
33+
/**
34+
*
35+
* @param string $paymentOrderUuid
36+
* @return $this
37+
*/
38+
public function setPaymentOrderUuid($paymentOrderUuid) {
39+
$this->addRouteParameter('payment_order_uuid', $paymentOrderUuid);
40+
return $this;
41+
}
42+
43+
/**
44+
*
45+
* @param PaymentUpdateObject $paymentUpdateObject
46+
* @return $this
47+
*/
48+
public function setPaymentUpdateObject(PaymentUpdateObject $paymentUpdateObject)
49+
{
50+
$this->setRequestBody($paymentUpdateObject);
51+
return $this;
52+
}
53+
54+
55+
}

src/ChainsideCallbacksHandler.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@
55
use SDK\Boilerplate\Callbacks\CallbacksHandler;
66
use Chainside\SDK\WebPos\Exceptions\CallbackParseException;
77
use Chainside\SDK\WebPos\Exceptions\UnknownCallbackException;
8+
use Chainside\SDK\WebPos\Objects\PaymentOverpaidCallback;
89
use Chainside\SDK\WebPos\Objects\PaymentCompletedCallback;
9-
use Chainside\SDK\WebPos\Objects\PaymentExpiredCallback;
10-
use Chainside\SDK\WebPos\Objects\PaymentDisputeEndCallback;
1110
use Chainside\SDK\WebPos\Objects\PaymentDisputeStartCallback;
1211
use Chainside\SDK\WebPos\Objects\PaymentChargebackCallback;
13-
use Chainside\SDK\WebPos\Objects\PaymentOverpaidCallback;
1412
use Chainside\SDK\WebPos\Objects\PaymentCancelledCallback;
13+
use Chainside\SDK\WebPos\Objects\PaymentDisputeEndCallback;
14+
use Chainside\SDK\WebPos\Objects\PaymentExpiredCallback;
1515

1616

1717
class ChainsideCallbacksHandler extends CallbacksHandler
1818
{
1919

2020
protected $callbacks = [
21+
'payment.overpaid' => PaymentOverpaidCallback::class,
2122
'payment.completed' => PaymentCompletedCallback::class,
22-
'payment.expired' => PaymentExpiredCallback::class,
23-
'payment.dispute.end' => PaymentDisputeEndCallback::class,
2423
'payment.dispute.start' => PaymentDisputeStartCallback::class,
2524
'payment.chargeback' => PaymentChargebackCallback::class,
26-
'payment.overpaid' => PaymentOverpaidCallback::class,
2725
'payment.cancelled' => PaymentCancelledCallback::class,
26+
'payment.dispute.end' => PaymentDisputeEndCallback::class,
27+
'payment.expired' => PaymentExpiredCallback::class,
2828
];
2929

3030
/**

0 commit comments

Comments
 (0)