Skip to content

Commit

Permalink
IRIS support
Browse files Browse the repository at this point in the history
  • Loading branch information
dimosKougiou committed Sep 30, 2024
1 parent c3225ba commit 0d01867
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 31 deletions.
41 changes: 22 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,24 @@

## Changelog

- **1.0.5**
- Fixed guest checkout bug.

- **1.0.4**
- Minor bug fixes.

- **1.0.0**
- Initial release
- **1.0.1**
- Only send order confirmation email to customer when the order has been successfully paid for.
- Auto cancel order after 30 minutes in pending payment state.
- **1.0.2**
- Fixed a bug that failed checkout with PayPal Standard.
- Changed auto cancel order period to 60 minutes.
- **1.0.3**
- Order creation only happens after successful payment.
- Fixed bug with credit memo creation.
- Fixed bug with reorder in admin.

- **1.0.2**
- Fixed a bug that failed checkout with PayPal Standard.
- Changed auto cancel order period to 60 minutes.

- **1.0.1**
- Only send order confirmation email to customer when the order has been successfully paid for.
- Auto cancel order after 30 minutes in pending payment state.

- **1.0.0**
- Initial release
- **1.0.4**
- Minor bug fixes.
- **1.0.5**
- Fixed guest checkout bug.
- **1.1.0**
- Added support for IRIS payments.

## Description

Expand All @@ -53,10 +50,11 @@ Once you have completed the requested tests and any changes to your website, you
9. Translation ready for Greek & English languages.
10. Automatically cancel pending payment orders after 60 minutes.
11. Only send the order confirmation email to the customer after a successful payment.
12. Support for IRIS payments.

## Installation

You need to manually upload the contents of the .zip file of the module’s latest version to your server’s web root folder that your Magento store is installed. You will first need to extract the file’s contents to a temporary folder. Then, go to the ``Cardlink\Checkout\Controller\Payment`` folder. Replace the Response.php file with the file that corresponds to your installed Magento version, ``Response-v2.2.php`` for any 2.2.x version and ``Response-v2.3.php`` for any version 2.3.x-2.4.x.
You need to manually upload the contents of the .zip file of the module’s latest version to your server’s web root folder that your Magento store is installed. You will first need to extract the file’s contents to a temporary folder. Then, go to the ``Cardlink\Checkout\Controller\Payment`` folder. If you are using previous Magento version 2.2.x, replace the ``Response.php`` file with the contents of file ``Response-v2.2.php``.

Depending on your hosting provider, you will probably have to be familiar with the process of transferring files using an FTP or SFTP client. If no FTP/SFTP access is provided, use your hosting provider’s administration panel to upload the folders to the folder of your Magento installation.

Expand Down Expand Up @@ -109,8 +107,13 @@ Header always edit Set-Cookie ^(.*)$ $1;SameSite=None;Secure
</IfModule>
```

#### Custom or Unknown Hosting

If you do not have full control of your hosting services, or not very confident with such changes, you can try installing the [Veriteworks CookieFix](https://github.com/Veriteworks/CookieFix) extension.
Follow the instructions on the extensions Github page and set the SameSite setting to None.


If you are unsure or unfamiliar with the actions described above, please ask a trained IT person or contact your hosting provider to do them for you.
If you are still unsure or unfamiliar with the actions described above, please ask a trained IT person or contact your hosting provider to do them for you.

## Screenshots

Expand Down
28 changes: 24 additions & 4 deletions app/code/Cardlink/Checkout/Controller/Payment/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,34 @@
use Cardlink\Checkout\Helper\Data;
use Cardlink\Checkout\Helper\Payment;
use Magento\Checkout\Model\Session;

use Magento\Framework\App\CsrfAwareActionInterface;

use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\Data\Form\FormKey;
use Magento\Framework\UrlInterface;
use Magento\Framework\Message\ManagerInterface;
use Magento\Framework\Controller\Result\RedirectFactory;
use Magento\Framework\App\Request\InvalidRequestException;
use Magento\Framework\App\RequestInterface;
use Magento\Sales\Model\OrderFactory;


/**
* Controller action used to handle responses from the payment gateway.
*
* @author Cardlink S.A.
*/
class Response extends Action
class Response extends Action implements CsrfAwareActionInterface, HttpPostActionInterface
{
/**
* @var FormKey
*/
protected $formKey;

/**
* @var Logger
*/
Expand Down Expand Up @@ -82,8 +93,8 @@ public function __construct(
Logger $logger,
Data $dataHelper,
Payment $paymentHelper,
OrderFactory $orderFactory

OrderFactory $orderFactory,
FormKey $formKey
) {
$this->checkoutSession = $checkoutSession;
$this->messageManager = $messageManager;
Expand All @@ -94,6 +105,7 @@ public function __construct(
$this->dataHelper = $dataHelper;
$this->paymentHelper = $paymentHelper;
$this->orderFactory = $orderFactory;
$this->formKey = $formKey;

return parent::__construct($context);
}
Expand Down Expand Up @@ -162,6 +174,9 @@ public function execute()
// Mark the payment as successful and remove the quote from the customer's session.
$this->paymentHelper->markSuccessfulPayment($order, $responseData);

$quote->setIsActive(false);
$quote->save();

$message = array_key_exists(ApiFields::Message, $responseData)
? $responseData[ApiFields::Message]
: '';
Expand Down Expand Up @@ -189,6 +204,12 @@ public function execute()
}
}

// Regenerate a new form key
$newFormKey = $this->formKey->getFormKey();

// Optionally set the new form key in the request
$this->getRequest()->setParam('form_key', $newFormKey);

// If the payment flow executed inside the IFRAME, send out a redirection form page to force open the final response page in the parent frame (store window/tab).
if ($this->dataHelper->doCheckoutInIframe()) {
$redirectUrl = $success
Expand Down Expand Up @@ -237,5 +258,4 @@ public function createCsrfValidationException(RequestInterface $request): Invali
{
return null;
}

}
2 changes: 1 addition & 1 deletion app/code/Cardlink/Checkout/Helper/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ public static function generateIrisRFCode(string $diasCustomerCode, $orderId, $a

$orderIdNum = (int) filter_var($orderId, FILTER_SANITIZE_NUMBER_INT);

$randomNumber = str_pad($orderIdNum, 13, '0', STR_PAD_LEFT);
$randomNumber = substr(str_pad($orderIdNum, 13, '0', STR_PAD_LEFT), -13);
$paymentCode = $paymentSum ? ($paymentSum % 8) : '8';
$systemCode = '12';
$tempCode = $diasCustomerCode . $paymentCode . $systemCode . $randomNumber . '271500';
Expand Down
5 changes: 2 additions & 3 deletions app/code/Cardlink/Checkout/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,9 @@
<field id="enable">1</field>
</depends>
</field>

</group>

<!--

<group id="cardlink_checkout_iris" translate="label comment" type="text" sortOrder="11" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Cardlink CheckOut - Pay via IRIS</label>
<comment>Display settings for the 'Pay via Card' method are shared with this method.</comment>
Expand Down Expand Up @@ -273,7 +272,7 @@
</field>

</group>
-->

</section>
</system>
</config>
4 changes: 1 addition & 3 deletions app/code/Cardlink/Checkout/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@

</cardlink_checkout>

<!--
<cardlink_checkout_iris>
<model>CardlinkCheckoutIrisFacade</model>
<active>0</active>
Expand Down Expand Up @@ -76,9 +75,8 @@
<business_partner>cardlink</business_partner>
<transaction_environment>sandbox</transaction_environment>
<dias_code></dias_code>
</cardlink_checkout_iris>
-->

</payment>
</default>
</config>
2 changes: 1 addition & 1 deletion app/code/Cardlink/Checkout/etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">

<module name="Cardlink_Checkout" setup_version="1.0.5" schema_version="0.1.0">
<module name="Cardlink_Checkout" setup_version="1.1.0" schema_version="0.1.0">
<sequence>
<module name="Magento_Sales"/>
<module name="Magento_Payment"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<script src="Cardlink_Checkout::js/invalidate-localstorage-cart.js"/>
</head>
</page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<script src="Cardlink_Checkout::js/invalidate-localstorage-cart.js"/>
</head>
</page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require([
'Magento_Customer/js/customer-data'
], function (customerData) {
var sections = ['cart'];
customerData.invalidate(sections);
customerData.reload(sections, true);
});

0 comments on commit 0d01867

Please sign in to comment.