Skip to content

Commit

Permalink
Version 100.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Mussulis committed Nov 9, 2018
1 parent fcfe5f8 commit 5a7d213
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 13 deletions.
51 changes: 42 additions & 9 deletions Model/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class Payment extends PaymentAbstractMethod
const PO_EXPIRED = 9;
const PO_AUTH_ERROR = 10;
const PO_PAYMENT_ONHOLD = 13;
const PO_TIMEOUT_CC_PAGE = 16;
const PO_ABANDONED_CC_PAGE = 17;

/* Plationline credits response statuses */
const PO_CREDIT_CREDITING = 1;
Expand Down Expand Up @@ -473,16 +475,37 @@ public function processItsn(array $parameters)

$statusCode = $this->_queryResponse['ORDER']['TRANZACTION']['STATUS_FIN1']['CODE'];

if ($statusCode == self::PO_AUTHORIZED) {
if ($this->_order->getState() != \Magento\Sales\Model\Order::STATE_PROCESSING) {
if ($statusCode == self::PO_AUTHORIZED)
{
if ($this->_order->getState() != \Magento\Sales\Model\Order::STATE_PROCESSING)
{
//$this->orderSender->send($order);
$this->_order->setAuthorized(true);
$this->_order->save();
}
}
/*else if (in_array($statusCode, [self::PO_CANCELED, self::PO_AUTH_REFUSED])) {
$this->_order->cancel()->save();
}*/
else if (in_array($statusCode, [self::PO_TIMEOUT_CC_PAGE, self::PO_ABANDONED_CC_PAGE]))
{
$stateName = $this->getPOStateName($statusCode, null);
$poComment = $this->getPOComment($statusCode, null, $this->_transaction_id, ' (RELAY)') ;
$this->logger->debug(array("Timeout or Abandoned: " => $poComment), null, true);
$this->_order->addStatusToHistory(
$stateName,
$poComment
);
$this->_order->save();
}
else if ($statusCode == self::PO_AUTH_REFUSED)
{
$stateName = $this->getPOStateName($statusCode, null);
$poComment = $this->getPOComment($statusCode, null, $this->_transaction_id, ' (RELAY)') ;
$this->logger->debug(array("PO Declined: " => $poComment), null, true);
$this->_order->addStatusToHistory(
$stateName,
$poComment
);
$this->_order->save();
}

//$this->_handleAuthorization();
if($statusCode == self::PO_AUTHORIZED)
Expand Down Expand Up @@ -550,11 +573,11 @@ public function processReturn(array $parameters = null)
$this->_order = $this->orderFactory->create()->loadByIncrementId($authData['F_ORDER_NUMBER']);
$this->_transaction_id = $authData['X_TRANS_ID'];
$statusCode = $authData['X_RESPONSE_CODE'];
$stateName = $this->getPOStateName($statusCode, null);
$poComment = $this->getPOComment($statusCode, null, $this->_transaction_id, ' (RELAY)') ;
$this->logger->debug(array("processReturn statename: " => $stateName, "poComment" => $poComment), null, true);
$stateName = $this->getPOStateName($statusCode, null);
$poComment = $this->getPOComment($statusCode, null, $this->_transaction_id, ' (RELAY)') ;
$this->logger->debug(array("processReturn statename: " => $stateName, "poComment" => $poComment), null, true);

$this->_order->addStatusToHistory(
$this->_order->addStatusToHistory(
$stateName,
$poComment
);
Expand Down Expand Up @@ -833,6 +856,10 @@ protected function getPOStateName($status, $creditState)
return 'error_plationline';
case self::PO_PAYMENT_ONHOLD:
return 'onhold_plationline';
case self::PO_TIMEOUT_CC_PAGE:
return 'timeoutccpage_plationline';
case self::PO_ABANDONED_CC_PAGE;
return 'abandonedccpage_plationline';
}
}

Expand Down Expand Up @@ -892,6 +919,12 @@ protected function getPOComment($status, $creditState, $transactionId, $suffix =
case self::PO_PAYMENT_ONHOLD:
$comment = __('PlatiOnline on hold, Transaction code: ');
break;
case self::PO_TIMEOUT_CC_PAGE:
$comment = __('PlatiOnline timeout payment page, Transaction code: ');
break;
case self::PO_ABANDONED_CC_PAGE;
$comment = __('PlatiOnline abandoned cart, Transaction code: ');
break;
}

$comment .= $transactionId;
Expand Down
12 changes: 10 additions & 2 deletions Setup/InstallData.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ public function install(
'payment_refused_plationline' => __('Refused PO'),
'expired30_plationline' => __('Expired PO'),
'error_plationline' => __('Error PO'),
'onhold_plationline' => __('On Hold PO')
'onhold_plationline' => __('On Hold PO'),
'timeoutccpage_plationline' => __('Timeout CC Page PO'),
'abandonedccpage_plationline' => __('Abandoned CC Page PO')
];

foreach ($statuses as $code => $info) {
Expand All @@ -84,7 +86,13 @@ public function install(
'visible_on_front' => true,
],
'pending_payment' => [
'statuses' => ['pending_settled_plationline', 'pending_credited_plationline', 'credited_plationline'],
'statuses' => [
'pending_settled_plationline',
'pending_credited_plationline',
'credited_plationline',
'timeoutccpage_plationline',
'abandonedccpage_plationline'
],
'visible_on_front' => true,
],
'completed' => [
Expand Down
43 changes: 43 additions & 0 deletions Setup/UpgradeData.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,49 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
{
$setup->startSetup();

/**
* Install order states
*/
$data = [];
$statuses = [
'timeoutccpage_plationline' => __('Timeout CC Page PO'),
'abandonedccpage_plationline' => __('Abandoned CC Page PO')
];

foreach ($statuses as $code => $info) {
$data[] = ['status' => $code, 'label' => $info];
}
$setup->getConnection()->insertArray($setup->getTable('sales_order_status'), ['status', 'label'], $data);

$data = [];
$states = [
'pending_payment' => [
'statuses' => [
'timeoutccpage_plationline',
'abandonedccpage_plationline'
],
'visible_on_front' => true,
],
];

foreach ($states as $code => $info) {
if (isset($info['statuses'])) {
foreach ($info['statuses'] as $status) {
$data[] = [
'status' => $status,
'state' => $code,
'is_default' => 0,
];
}
}
}
$setup->getConnection()->insertArray(
$setup->getTable('sales_order_status_state'),
['status', 'state', 'is_default'],
$data
);


/** Update visibility for states */
$states = ['new', 'completed', 'canceled', 'holded', 'pending_payment'];
foreach ($states as $state) {
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"php": "~5.5.0|~5.6.0|~7.0.0|~7.1.0"
},
"type": "magento2-module",
"version": "100.0.3",
"version": "100.0.5",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Module Config
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Xtreme_PlatiOnline" setup_version="0.3.0">
<module name="Xtreme_PlatiOnline" setup_version="0.5.0">
<sequence>
<module name="Magento_Sales" />
<module name="Magento_Payment" />
Expand Down

0 comments on commit 5a7d213

Please sign in to comment.