Skip to content

Commit

Permalink
Reversal fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
veneliniliev committed Jul 6, 2021
1 parent 38d4cbc commit 5656d17
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 11 deletions.
38 changes: 38 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -59,6 +61,29 @@

<hr />

### Class: \VenelinIliev\Borica3ds\ReversalRequest

| Visibility | Function |
|:-----------|:---------|
| public | <strong>__construct()</strong> : <em>void</em><br /><em>StatusCheckRequest constructor.</em> |
| public | <strong>generateForm()</strong> : <em>array</em> |
| public | <strong>generateSignature()</strong> : <em>string</em> |
| public | <strong>getData()</strong> : <em>array</em> |
| public | <strong>getIntRef()</strong> : <em>string</em> |
| public | <strong>getMerchantName()</strong> : <em>string</em> |
| public | <strong>getRrn()</strong> : <em>string</em> |
| public | <strong>send()</strong> : <em>[\VenelinIliev\Borica3ds\ReversalResponse](#class-venelinilievborica3dsreversalresponse)</em><br /><em>Send data to borica</em> |
| public | <strong>setIntRef(</strong><em>string</em> <strong>$intRef</strong>)</strong> : <em>[\VenelinIliev\Borica3ds\ReversalRequest](#class-venelinilievborica3dsreversalrequest)</em><br /><em>Set transaction internal reference.</em> |
| public | <strong>setMerchantName(</strong><em>string</em> <strong>$merchantName</strong>)</strong> : <em>[\VenelinIliev\Borica3ds\ReversalRequest](#class-venelinilievborica3dsreversalrequest)</em> |
| public | <strong>setRrn(</strong><em>string</em> <strong>$rrn</strong>)</strong> : <em>[\VenelinIliev\Borica3ds\ReversalRequest](#class-venelinilievborica3dsreversalrequest)</em><br /><em>Set transaction reference.</em> |
| public | <strong>validateRequiredParameters()</strong> : <em>void</em> |

*This class extends [\VenelinIliev\Borica3ds\Request](#class-venelinilievborica3dsrequest-abstract)*

*This class implements [\VenelinIliev\Borica3ds\RequestInterface](#interface-venelinilievborica3dsrequestinterface)*

<hr />

### Class: \VenelinIliev\Borica3ds\Base (abstract)

> Borica base
Expand Down Expand Up @@ -165,6 +190,19 @@

<hr />

### 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)*

<hr />

### Interface: \VenelinIliev\Borica3ds\ResponseInterface

> Interface ResponseInterface
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ $isSuccessfulPayment = (new SaleResponse())
#### Get response code

```php
use VenelinIliev\Borica3ds\SaleResponse;
// ...
$saleResponse= (new SaleResponse())
->setPublicKey('<path to public certificate.cer>');

Expand Down Expand Up @@ -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('\<path to certificate.key>', '<password / or use method from bottom>')
Expand All @@ -146,6 +151,8 @@ $statusCheckResponse->getVerifiedData('<field from response. ex: ACTION');
### Reversal request
```php
use VenelinIliev\Borica3ds\ReversalRequest;
// ...
$reversalRequest = (new ReversalRequest())
//->inDevelopment()
->setPrivateKey('\<path to certificate.key>', '<password / or use method from bottom>')
Expand All @@ -166,7 +173,7 @@ $reversalRequestResponse = $reversalRequest->send();
$verifiedResponseData = $reversalRequestResponse->getResponseData();

// get field from borica reversal response
$reversalRequestResponse->getVerifiedData('STATUSMSG')
$reversalRequestResponse->getVerifiedData('STATUSMSG');
```


Expand Down
5 changes: 4 additions & 1 deletion src/Enums/TransactionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@
* @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
{
const SALE = 1;
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;
}
11 changes: 3 additions & 8 deletions src/ReversalRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@

class ReversalRequest extends Request implements RequestInterface
{
/**
* @var array
*/
private $sendResponse;

/**
* @var string
*/
Expand All @@ -43,7 +38,7 @@ public function __construct()
/**
* Send data to borica
*
* @return StatusCheckResponse
* @return ReversalResponse
* @throws Exceptions\SignatureException|ParameterValidationException|SendingException
*/
public function send()
Expand All @@ -63,7 +58,7 @@ public function send()
}
curl_close($ch);

return (new StatusCheckResponse())
return (new ReversalResponse())
->setResponseData(json_decode($response, true))
->setPublicKey($this->getPublicKey());
}
Expand Down Expand Up @@ -160,7 +155,7 @@ public function validateRequiredParameters()
}

/**
* @return mixed|void
* @return array
* @throws Exceptions\SignatureException
* @throws ParameterValidationException
*/
Expand Down
17 changes: 17 additions & 0 deletions src/ReversalResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
/*
* Copyright (c) 2021. Venelin Iliev.
* https://veneliniliev.com
*/

namespace VenelinIliev\Borica3ds;

/**
* Class ReversalResponse
*
* @package VenelinIliev\Borica3ds
*/
class ReversalResponse extends Response implements ResponseInterface
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use VenelinIliev\Borica3ds\Exceptions\SignatureException;
use VenelinIliev\Borica3ds\Exceptions\ParameterValidationException;

class ReversaslRequestTest extends TestCase
class ReversalRequestTest extends TestCase
{
/**
* @throws ParameterValidationException|SignatureException
Expand Down

0 comments on commit 5656d17

Please sign in to comment.