Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
crefopay
Magento 2
Commits
d6ce311a
Commit
d6ce311a
authored
Apr 15, 2020
by
Oleksandr Gotgelf
Browse files
CREF-310: Create a controller to check availability and system response times,
CREF-309: Switch the mns/sink controller to an API endpoint
parent
4e37f191
Changes
11
Hide whitespace changes
Inline
Side-by-side
app/code/Trilix/CrefoPay/Api/ConnectionInterface.php
0 → 100755
View file @
d6ce311a
<?php
declare
(
strict_types
=
1
);
namespace
Trilix\CrefoPay\Api
;
/**
* Interface ConnectionInterface
*
* @api
*/
interface
ConnectionInterface
{
/**
* @return void
*/
public
function
ping
():
void
;
}
app/code/Trilix/CrefoPay/Api/CrefoPayMnsRepositoryInterface.php
View file @
d6ce311a
<?php
declare
(
strict_types
=
1
);
namespace
Trilix\CrefoPay\Api
;
use
Magento\Framework\Api\SearchCriteriaInterface
;
use
Magento\Framework\Exception\NoSuchEntityException
;
use
Magento\Framework\Exception\StateException
;
use
Trilix\CrefoPay\Api\Data\CrefoPayMnsInterface
;
use
Trilix\CrefoPay\Api\Data\CrefoPayMnsSearchResultInterface
;
...
...
@@ -9,45 +15,54 @@ interface CrefoPayMnsRepositoryInterface
/**
* Retrieve all MNS events for search criteria
*
* @param
\Magento\Framework\Api\
SearchCriteriaInterface $searchCriteria
* @param SearchCriteriaInterface $searchCriteria
* @return CrefoPayMnsSearchResultInterface
*/
public
function
getList
(
\
Magento\Framework\Api\
SearchCriteriaInterface
$searchCriteria
);
public
function
getList
(
SearchCriteriaInterface
$searchCriteria
)
:
CrefoPayMnsSearchResultInterface
;
/**
* Retrieve specific MNS event
*
* @param int $id
* @return CrefoPayMnsInterface
* @throws
\Magento\Framework\Exception\
NoSuchEntityException
* @throws NoSuchEntityException
*/
public
function
get
(
$id
)
;
public
function
get
(
int
$id
):
CrefoPayMnsInterface
;
/**
* Create MNS event
*
* @param CrefoPayMnsInterface $mnsEvent
* @return CrefoPayMnsInterface
* @throws \Magento\Framework\Exception\StateException
* @throws StateException
*/
public
function
save
(
CrefoPayMnsInterface
$mnsEvent
):
CrefoPayMnsInterface
;
/**
* Create MNS event via API
*
* @param CrefoPayMnsInterface $mnsEvent
* @return CrefoPayMnsInterface
* @throws StateException
*/
public
function
save
(
CrefoPayMnsInterface
$mnsEvent
);
public
function
save
ViaApi
(
CrefoPayMnsInterface
$mnsEvent
)
:
CrefoPayMnsInterface
;
/**
* Delete MNS event
*
* @param CrefoPayMnsInterface $mnsEvent
* @return void
* @throws
\Magento\Framework\Exception\
StateException
* @throws StateException
*/
public
function
delete
(
CrefoPayMnsInterface
$mnsEvent
);
public
function
delete
(
CrefoPayMnsInterface
$mnsEvent
)
:
void
;
/**
* Delete MNS event by ID
*
* @param int $id
* @return void
* @throws
\Magento\Framework\Exception\
NoSuchEntityException
* @throws
\Magento\Framework\Exception\
StateException
* @throws NoSuchEntityException
* @throws StateException
*/
public
function
deleteById
(
$id
);
}
\ No newline at end of file
public
function
deleteById
(
$id
):
void
;
}
app/code/Trilix/CrefoPay/Api/Data/CrefoPayMnsInterface.php
View file @
d6ce311a
<?php
declare
(
strict_types
=
1
);
namespace
Trilix\CrefoPay\Api\Data
;
use
DateTime
;
interface
CrefoPayMnsInterface
{
const
MERCHANT_ID
=
'merchant_id'
;
const
STORE_ID
=
'store_id'
;
const
ORDER_INCREMENT_ID
=
'order_increment_id'
;
const
CAPTURE_ID
=
'capture_id'
;
const
MERCHANT_REFERENCE
=
'merchant_reference'
;
const
PAYMENT_REFERENCE
=
'payment_reference'
;
const
USER_ID
=
'user_id'
;
const
AMOUNT
=
'amount'
;
const
CURRENCY
=
'currency'
;
const
TRANSACTION_STATUS
=
'transaction_status'
;
const
CAPTURE_STATUS
=
'capture_status'
;
const
CREATED_AT
=
'created_at'
;
const
MNS_STATUS
=
'mns_status'
;
// See STATUS_* constants
const
PROCESSED_AT
=
'processed_at'
;
const
ERROR_DETAILS
=
'error_details'
;
// If mns_status is 'failed'
public
const
MERCHANT_ID
=
'merchant_id'
;
public
const
STORE_ID
=
'store_id'
;
public
const
ORDER_INCREMENT_ID
=
'order_increment_id'
;
public
const
CAPTURE_ID
=
'capture_id'
;
public
const
MERCHANT_REFERENCE
=
'merchant_reference'
;
public
const
PAYMENT_REFERENCE
=
'payment_reference'
;
public
const
USER_ID
=
'user_id'
;
public
const
AMOUNT
=
'amount'
;
public
const
CURRENCY
=
'currency'
;
public
const
TRANSACTION_STATUS
=
'transaction_status'
;
public
const
CAPTURE_STATUS
=
'capture_status'
;
public
const
CREATED_AT
=
'created_at'
;
public
const
MNS_STATUS
=
'mns_status'
;
// See STATUS_* constants
public
const
PROCESSED_AT
=
'processed_at'
;
public
const
ERROR_DETAILS
=
'error_details'
;
// If mns_status is 'failed'
/**
* MNS statuses
*/
const
STATUS_ACK
=
'ack'
;
// Notification has been received and recorded for future processing
const
STATUS_CONSUMED
=
'consumed'
;
// Notification has been successfully processed
const
STATUS_FAILED
=
'failed'
;
// There was an error processing the notification
public
const
STATUS_ACK
=
'ack'
;
// Notification has been received and recorded for future processing
public
const
STATUS_CONSUMED
=
'consumed'
;
// Notification has been successfully processed
public
const
STATUS_FAILED
=
'failed'
;
// There was an error processing the notification
/**
* Set CrefoPay Merchant ID
...
...
@@ -33,14 +38,14 @@ interface CrefoPayMnsInterface
*
* @return void
*/
public
function
setMerchantId
(
$merchantId
);
public
function
setMerchantId
(
int
$merchantId
)
:
void
;
/**
* Get CrefoPay Merchant ID
*
* @return int
* @return int
|null
*/
public
function
getMerchantId
();
public
function
getMerchantId
()
:
?int
;
/**
* Set CrefoPay store ID
...
...
@@ -49,14 +54,14 @@ interface CrefoPayMnsInterface
*
* @return void
*/
public
function
setStoreId
(
$storeId
);
public
function
setStoreId
(
string
$storeId
)
:
void
;
/**
* Get CrefoPay store ID
*
* @return string
* @return string
|null
*/
public
function
getStoreId
();
public
function
getStoreId
()
:
?string
;
/**
* Set increment order ID
...
...
@@ -65,14 +70,14 @@ interface CrefoPayMnsInterface
*
* @return void
*/
public
function
setIncrementOrderId
(
$orderId
);
public
function
setIncrementOrderId
(
string
$orderId
)
:
void
;
/**
* Get increment order ID
*
* @return string
* @return string
|null
*/
public
function
getIncrementOrderId
();
public
function
getIncrementOrderId
()
:
?string
;
/**
* Set capture ID
...
...
@@ -81,14 +86,14 @@ interface CrefoPayMnsInterface
*
* @return void
*/
public
function
setCaptureId
(
$captureId
);
public
function
setCaptureId
(
string
$captureId
)
:
void
;
/**
* Get capture ID
*
* @return string
* @return string
|null
*/
public
function
getCaptureId
();
public
function
getCaptureId
()
:
?string
;
/**
* Set merchant reference
...
...
@@ -97,14 +102,14 @@ interface CrefoPayMnsInterface
*
* @return void
*/
public
function
setMerchantReference
(
$merchantReference
);
public
function
setMerchantReference
(
string
$merchantReference
)
:
void
;
/**
* Get merchant reference
*
* @return string
* @return string
|null
*/
public
function
getMerchantReference
();
public
function
getMerchantReference
()
:
?string
;
/**
* Set CrefoPay payment reference
...
...
@@ -113,14 +118,14 @@ interface CrefoPayMnsInterface
*
* @return void
*/
public
function
setPaymentReference
(
$paymentReference
);
public
function
setPaymentReference
(
string
$paymentReference
)
:
void
;
/**
* Get CrefoPay payment reference
*
* @return string
* @return string
|null
*/
public
function
getPaymentReference
();
public
function
getPaymentReference
()
:
?string
;
/**
* Set CrefoPay user ID
...
...
@@ -129,14 +134,12 @@ interface CrefoPayMnsInterface
*
* @return void
*/
public
function
setUserId
(
$userId
);
public
function
setUserId
(
string
$userId
)
:
void
;
/**
* Get CrefoPay user ID
*
* @return string
* @return string|null
*/
public
function
getUserId
();
public
function
getUserId
()
:
?string
;
/**
* Set amount (formatted as '0.00')
...
...
@@ -145,14 +148,14 @@ interface CrefoPayMnsInterface
*
* @return void
*/
public
function
setAmount
(
$amount
);
public
function
setAmount
(
string
$amount
)
:
void
;
/**
* Get amount (formatted as '0.00')
*
* @return string
* @return string
|null
*/
public
function
getAmount
();
public
function
getAmount
()
:
?string
;
/**
* Set currency code (3-letter ISO 4217 alpha)
...
...
@@ -161,14 +164,14 @@ interface CrefoPayMnsInterface
*
* @return void
*/
public
function
setCurrency
(
$currency
);
public
function
setCurrency
(
string
$currency
)
:
void
;
/**
* Get currency code (3-letter ISO 4217 alpha)
*
* @return string
* @return string
|null
*/
public
function
getCurrency
();
public
function
getCurrency
()
:
?string
;
/**
* Set transaction status
...
...
@@ -177,14 +180,14 @@ interface CrefoPayMnsInterface
*
* @return void
*/
public
function
setTransactionStatus
(
$transactionStatus
);
public
function
setTransactionStatus
(
string
$transactionStatus
)
:
void
;
/**
* Get transaction status
*
* @return string
* @return string
|null
*/
public
function
getTransactionStatus
();
public
function
getTransactionStatus
()
:
?string
;
/**
* Set capture status (orderStatus in CrefoPay terms)
...
...
@@ -193,14 +196,14 @@ interface CrefoPayMnsInterface
*
* @return void
*/
public
function
setCaptureStatus
(
$captureStatus
);
public
function
setCaptureStatus
(
string
$captureStatus
)
:
void
;
/**
* Get capture status (orderStatus in CrefoPay terms)
*
* @return string
* @return string
|null
*/
public
function
getCaptureStatus
();
public
function
getCaptureStatus
()
:
?string
;
/**
* Set created at datetime
...
...
@@ -209,14 +212,14 @@ interface CrefoPayMnsInterface
*
* @return void
*/
public
function
setCreatedAt
(
$createdAt
);
public
function
setCreatedAt
(
string
$createdAt
)
:
void
;
/**
* Get created at datetime
*
* @return string
* @return string
|null
*/
public
function
getCreatedAt
();
public
function
getCreatedAt
()
:
?string
;
/**
* Set processing status of the notification record
...
...
@@ -225,30 +228,30 @@ interface CrefoPayMnsInterface
*
* @return void
*/
public
function
setMnsStatus
(
$mnsStatus
);
public
function
setMnsStatus
(
string
$mnsStatus
)
:
void
;
/**
* Get processing status of the notification record
*
* @return string See STATUS_* constants
* @return string
|null
See STATUS_* constants
*/
public
function
getMnsStatus
();
public
function
getMnsStatus
()
:
?string
;
/**
* Set date and time of record processing (null - if not processed)
*
* @param
\
DateTime|null $processedAt
* @param DateTime|null $processedAt
*
* @return void
*/
public
function
setProcessedAt
(
$processedAt
);
public
function
setProcessedAt
(
?DateTime
$processedAt
)
:
void
;
/**
* Get date and time of record processing (null - if not processed)
*
* @return string|null
*/
public
function
getProcessedAt
();
public
function
getProcessedAt
()
:
?string
;
/**
* Set error details (if record failed to be processed)
...
...
@@ -257,12 +260,12 @@ interface CrefoPayMnsInterface
*
* @return void
*/
public
function
setErrorDetails
(
$errorDetails
);
public
function
setErrorDetails
(
?string
$errorDetails
)
:
void
;
/**
* Get error details (if record failed to be processed)
*
* @return string|null
*/
public
function
getErrorDetails
();
}
\ No newline at end of file
public
function
getErrorDetails
():
?string
;
}
app/code/Trilix/CrefoPay/Model/Connection.php
0 → 100755
View file @
d6ce311a
<?php
declare
(
strict_types
=
1
);
namespace
Trilix\CrefoPay\Model
;
use
Trilix\CrefoPay\Api\ConnectionInterface
;
/**
* Class Connection
*/
class
Connection
implements
ConnectionInterface
{
/**
* {@inheritDoc}
*/
public
function
ping
():
void
{
}
}
app/code/Trilix/CrefoPay/Model/Mns/AmountConverter.php
0 → 100644
View file @
d6ce311a
<?php
declare
(
strict_types
=
1
);
namespace
Trilix\CrefoPay\Model\Mns
;
class
AmountConverter
{
/**
* Convert Amount value coming from CrefoPay
*
* @param string $value
*
* @return string
*/
public
static
function
convertValue
(
string
$value
):
string
{
return
sprintf
(
'%.2f'
,
intval
(
$value
)
/
100
);
}
}
app/code/Trilix/CrefoPay/Model/Mns/MnsEvent.php
View file @
d6ce311a
<?php
declare
(
strict_types
=
1
);
namespace
Trilix\CrefoPay\Model\Mns
;
use
Magento\Framework\Model\AbstractModel
;
use
DateTime
;
use
InvalidArgumentException
;
use
Trilix\CrefoPay\Api\Data\CrefoPayMnsInterface
;
use
Trilix\CrefoPay\Model\ResourceModel\Mns
;
use
Magento\Framework\Model\AbstractModel
;
class
MnsEvent
extends
AbstractModel
implements
CrefoPayMnsInterface
{
protected
function
_construct
()
{
$this
->
_init
(
\
Trilix\CrefoPay\Model\ResourceModel\
Mns
::
class
);
$this
->
_init
(
Mns
::
class
);
}
public
static
function
getAvailableMnsStatuses
()
/**
* @return array
*/
public
static
function
getAvailableMnsStatuses
():
array
{
return
[
CrefoPayMnsInterface
::
STATUS_ACK
,
...
...
@@ -23,7 +32,7 @@ class MnsEvent extends AbstractModel implements CrefoPayMnsInterface
/**
* {@inheritdoc}
*/
public
function
setMerchantId
(
$merchantId
)
public
function
setMerchantId
(
int
$merchantId
)
:
void
{
$this
->
setData
(
CrefoPayMnsInterface
::
MERCHANT_ID
,
$merchantId
);
}
...
...
@@ -31,7 +40,7 @@ class MnsEvent extends AbstractModel implements CrefoPayMnsInterface
/**
* {@inheritdoc}
*/
public
function
getMerchantId
()
public
function
getMerchantId
()
:
?int
{
return
$this
->
getData
(
CrefoPayMnsInterface
::
MERCHANT_ID
);
}
...
...
@@ -39,7 +48,7 @@ class MnsEvent extends AbstractModel implements CrefoPayMnsInterface
/**
* {@inheritdoc}
*/
public
function
setStoreId
(
$storeId
)
public
function
setStoreId
(
string
$storeId
)
:
void
{
$this
->
setData
(
CrefoPayMnsInterface
::
STORE_ID
,
$storeId
);
}
...
...
@@ -47,7 +56,7 @@ class MnsEvent extends AbstractModel implements CrefoPayMnsInterface
/**
* {@inheritdoc}
*/
public
function
getStoreId
()
public
function
getStoreId
()
:
?string
{
return
$this
->
getData
(
CrefoPayMnsInterface
::
STORE_ID
);
}
...
...
@@ -55,7 +64,7 @@ class MnsEvent extends AbstractModel implements CrefoPayMnsInterface
/**
* {@inheritdoc}
*/
public
function
setIncrementOrderId
(
$orderId
)
public
function
setIncrementOrderId
(
string
$orderId
)
:
void
{
$this
->
setData
(
CrefoPayMnsInterface
::
ORDER_INCREMENT_ID
,
$orderId
);
}
...
...
@@ -63,7 +72,7 @@ class MnsEvent extends AbstractModel implements CrefoPayMnsInterface
/**
* {@inheritdoc}
*/
public
function
getIncrementOrderId
()
public
function
getIncrementOrderId
()
:
?string
{
return
$this
->
getData
(
CrefoPayMnsInterface
::
ORDER_INCREMENT_ID
);
}
...
...
@@ -71,7 +80,7 @@ class MnsEvent extends AbstractModel implements CrefoPayMnsInterface
/**
* {@inheritdoc}
*/
public
function
setCaptureId
(
$captureId
)
public
function
setCaptureId
(
string
$captureId
)
:
void
{
$this
->
setData
(
CrefoPayMnsInterface
::
CAPTURE_ID
,
$captureId
);
}
...
...
@@ -79,7 +88,7 @@ class MnsEvent extends AbstractModel implements CrefoPayMnsInterface
/**
* {@inheritdoc}
*/
public
function
getCaptureId
()
public
function
getCaptureId
()
:
?string
{
return
$this
->
getData
(
CrefoPayMnsInterface
::
CAPTURE_ID
);
}
...
...
@@ -87,7 +96,7 @@ class MnsEvent extends AbstractModel implements CrefoPayMnsInterface
/**
* {@inheritdoc}
*/
public
function
setMerchantReference
(
$merchantReference
)
public
function
setMerchantReference
(
string
$merchantReference
)
:
void
{
$this
->
setData
(
CrefoPayMnsInterface
::
MERCHANT_REFERENCE
,
$merchantReference
);
}
...
...
@@ -95,7 +104,7 @@ class MnsEvent extends AbstractModel implements CrefoPayMnsInterface
/**
* {@inheritdoc}
*/
public
function
getMerchantReference
()
public
function
getMerchantReference
()
:
?string
{
return
$this
->
getData
(
CrefoPayMnsInterface
::
MERCHANT_REFERENCE
);
}
...
...
@@ -103,7 +112,7 @@ class MnsEvent extends AbstractModel implements CrefoPayMnsInterface
/**
* {@inheritdoc}
*/
public
function
setPaymentReference
(
$paymentReference
)
public
function
setPaymentReference
(
string
$paymentReference
)
:
void
{
$this
->
setData
(
CrefoPayMnsInterface
::
PAYMENT_REFERENCE
,
$paymentReference
);
}
...
...
@@ -111,7 +120,7 @@ class MnsEvent extends AbstractModel implements CrefoPayMnsInterface
/**
* {@inheritdoc}
*/
public
function
getPaymentReference
()
public
function
getPaymentReference
()
:
?string
{
return
$this
->
getData
(
CrefoPayMnsInterface
::
PAYMENT_REFERENCE
);
}
...
...
@@ -119,7 +128,7 @@ class MnsEvent extends AbstractModel implements CrefoPayMnsInterface
/**
* {@inheritdoc}
*/
public
function
setUserId
(
$userId
)
public
function
setUserId
(
string
$userId
)
:
void
{
$this
->
setData
(
CrefoPayMnsInterface
::
USER_ID
,
$userId
);
}
...
...
@@ -127,7 +136,7 @@ class MnsEvent extends AbstractModel implements CrefoPayMnsInterface
/**
* {@inheritdoc}
*/
public
function
getUserId
()
public
function
getUserId
()
:
?string
{
return
$this
->
getData
(
CrefoPayMnsInterface
::
USER_ID
);
}
...
...
@@ -135,7 +144,7 @@ class MnsEvent extends AbstractModel implements CrefoPayMnsInterface
/**
* {@inheritdoc}
*/
public
function
setAmount
(
$amount
)
public
function
setAmount
(
string
$amount
)
:
void
{
$this
->
setData
(
CrefoPayMnsInterface
::
AMOUNT
,
$amount
);
}
...
...
@@ -143,7 +152,7 @@ class MnsEvent extends AbstractModel implements CrefoPayMnsInterface
/**
* {@inheritdoc}
*/