From 5656d17b51b63353811b174906682e0f21bab8b5 Mon Sep 17 00:00:00 2001 From: Venelin Iliev Date: Tue, 6 Jul 2021 10:36:15 +0300 Subject: [PATCH] Reversal fixes --- API.md | 38 +++++++++++++++++++ README.md | 9 ++++- src/Enums/TransactionType.php | 5 ++- src/ReversalRequest.php | 11 ++---- src/ReversalResponse.php | 17 +++++++++ ...equestTest.php => ReversalRequestTest.php} | 2 +- 6 files changed, 71 insertions(+), 11 deletions(-) create mode 100644 src/ReversalResponse.php rename tests/{ReversaslRequestTest.php => ReversalRequestTest.php} (98%) diff --git a/API.md b/API.md index 23a5fd6..7cc1307 100644 --- a/API.md +++ b/API.md @@ -2,11 +2,13 @@ - [\VenelinIliev\Borica3ds\SaleResponse](#class-venelinilievborica3dssaleresponse) - [\VenelinIliev\Borica3ds\Request (abstract)](#class-venelinilievborica3dsrequest-abstract) +- [\VenelinIliev\Borica3ds\ReversalRequest](#class-venelinilievborica3dsreversalrequest) - [\VenelinIliev\Borica3ds\Base (abstract)](#class-venelinilievborica3dsbase-abstract) - [\VenelinIliev\Borica3ds\StatusCheckResponse](#class-venelinilievborica3dsstatuscheckresponse) - [\VenelinIliev\Borica3ds\Response (abstract)](#class-venelinilievborica3dsresponse-abstract) - [\VenelinIliev\Borica3ds\StatusCheckRequest](#class-venelinilievborica3dsstatuscheckrequest) - [\VenelinIliev\Borica3ds\SaleRequest](#class-venelinilievborica3dssalerequest) +- [\VenelinIliev\Borica3ds\ReversalResponse](#class-venelinilievborica3dsreversalresponse) - [\VenelinIliev\Borica3ds\ResponseInterface (interface)](#interface-venelinilievborica3dsresponseinterface) - [\VenelinIliev\Borica3ds\RequestInterface (interface)](#interface-venelinilievborica3dsrequestinterface) - [\VenelinIliev\Borica3ds\Enums\TransactionType](#class-venelinilievborica3dsenumstransactiontype) @@ -59,6 +61,29 @@
+### Class: \VenelinIliev\Borica3ds\ReversalRequest + +| Visibility | Function | +|:-----------|:---------| +| public | __construct() : void
StatusCheckRequest constructor. | +| public | generateForm() : array | +| public | generateSignature() : string | +| public | getData() : array | +| public | getIntRef() : string | +| public | getMerchantName() : string | +| public | getRrn() : string | +| public | send() : [\VenelinIliev\Borica3ds\ReversalResponse](#class-venelinilievborica3dsreversalresponse)
Send data to borica | +| public | setIntRef(string $intRef) : [\VenelinIliev\Borica3ds\ReversalRequest](#class-venelinilievborica3dsreversalrequest)
Set transaction internal reference. | +| public | setMerchantName(string $merchantName) : [\VenelinIliev\Borica3ds\ReversalRequest](#class-venelinilievborica3dsreversalrequest) | +| public | setRrn(string $rrn) : [\VenelinIliev\Borica3ds\ReversalRequest](#class-venelinilievborica3dsreversalrequest)
Set transaction reference. | +| public | validateRequiredParameters() : void | + +*This class extends [\VenelinIliev\Borica3ds\Request](#class-venelinilievborica3dsrequest-abstract)* + +*This class implements [\VenelinIliev\Borica3ds\RequestInterface](#interface-venelinilievborica3dsrequestinterface)* + +
+ ### Class: \VenelinIliev\Borica3ds\Base (abstract) > Borica base @@ -165,6 +190,19 @@
+### Class: \VenelinIliev\Borica3ds\ReversalResponse + +> Class ReversalResponse + +| Visibility | Function | +|:-----------|:---------| + +*This class extends [\VenelinIliev\Borica3ds\Response](#class-venelinilievborica3dsresponse-abstract)* + +*This class implements [\VenelinIliev\Borica3ds\ResponseInterface](#interface-venelinilievborica3dsresponseinterface)* + +
+ ### Interface: \VenelinIliev\Borica3ds\ResponseInterface > Interface ResponseInterface diff --git a/README.md b/README.md index 52ebb48..4d4a9ea 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,8 @@ $isSuccessfulPayment = (new SaleResponse()) #### Get response code ```php +use VenelinIliev\Borica3ds\SaleResponse; +// ... $saleResponse= (new SaleResponse()) ->setPublicKey(''); @@ -123,6 +125,9 @@ Response codes table ### Transaction status check ```php + use VenelinIliev\Borica3ds\Enums\TransactionType; + use VenelinIliev\Borica3ds\StatusCheckRequest; + // ... $statusCheckRequest = (new StatusCheckRequest()) //->inDevelopment() ->setPrivateKey('\', '') @@ -146,6 +151,8 @@ $statusCheckResponse->getVerifiedData('inDevelopment() ->setPrivateKey('\', '') @@ -166,7 +173,7 @@ $reversalRequestResponse = $reversalRequest->send(); $verifiedResponseData = $reversalRequestResponse->getResponseData(); // get field from borica reversal response -$reversalRequestResponse->getVerifiedData('STATUSMSG') +$reversalRequestResponse->getVerifiedData('STATUSMSG'); ``` diff --git a/src/Enums/TransactionType.php b/src/Enums/TransactionType.php index 46a0557..6576be3 100644 --- a/src/Enums/TransactionType.php +++ b/src/Enums/TransactionType.php @@ -13,6 +13,10 @@ * @package VenelinIliev\Borica3ds\Enums * @method static SALE() * @method static TRANSACTION_STATUS_CHECK() + * @method static REVERSAL() + * @method static REVERSAL_REQUEST() + * @method static REVERSAL_REQUESTREVERSAL_REQUEST() + * @method static DEFERRED_AUTHORIZATION() */ class TransactionType extends Enum { @@ -20,7 +24,6 @@ class TransactionType extends Enum const DEFERRED_AUTHORIZATION = 12; const COMPLETION_DEFERRED_AUTHORIZATION = 21; const REVERSAL_REQUEST = 22; - const REVERSAL_ADVICE = 24; const TRANSACTION_STATUS_CHECK = 90; const REVERSAL = 24; } diff --git a/src/ReversalRequest.php b/src/ReversalRequest.php index 3159fa1..40dfc79 100644 --- a/src/ReversalRequest.php +++ b/src/ReversalRequest.php @@ -12,11 +12,6 @@ class ReversalRequest extends Request implements RequestInterface { - /** - * @var array - */ - private $sendResponse; - /** * @var string */ @@ -43,7 +38,7 @@ public function __construct() /** * Send data to borica * - * @return StatusCheckResponse + * @return ReversalResponse * @throws Exceptions\SignatureException|ParameterValidationException|SendingException */ public function send() @@ -63,7 +58,7 @@ public function send() } curl_close($ch); - return (new StatusCheckResponse()) + return (new ReversalResponse()) ->setResponseData(json_decode($response, true)) ->setPublicKey($this->getPublicKey()); } @@ -160,7 +155,7 @@ public function validateRequiredParameters() } /** - * @return mixed|void + * @return array * @throws Exceptions\SignatureException * @throws ParameterValidationException */ diff --git a/src/ReversalResponse.php b/src/ReversalResponse.php new file mode 100644 index 0000000..39397e1 --- /dev/null +++ b/src/ReversalResponse.php @@ -0,0 +1,17 @@ +