Skip to content

Commit 562b795

Browse files
committed
Actualización compatibilidad PHP 8
1 parent 251ca96 commit 562b795

File tree

6 files changed

+39
-13
lines changed

6 files changed

+39
-13
lines changed

Model/CsrfValidatorSkip.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
namespace Khipu\Payment\Model;
3+
class CsrfValidatorSkip
4+
{
5+
/**
6+
* @param \Magento\Framework\App\Request\CsrfValidator $subject
7+
* @param \Closure $proceed
8+
* @param \Magento\Framework\App\RequestInterface $request
9+
* @param \Magento\Framework\App\ActionInterface $action
10+
*/
11+
public function aroundValidate(
12+
$subject,
13+
\Closure $proceed,
14+
$request,
15+
$action
16+
) {
17+
if ($request->getModuleName() == 'Your_Module_frontName_Here') {
18+
return; // Skip CSRF check
19+
}
20+
$proceed($request, $action); // Proceed Magento 2 core functionalities
21+
}
22+
}

Model/Simplified.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,13 @@ public function getKhipuRequest(Order $order)
126126

127127
$opts = array(
128128
"transaction_id" => $order->getIncrementId(),
129-
"body" => join($description, ', '),
129+
"body" => join(', ',$description),
130130
"custom" => $payment->getAdditionalInformation('khipu_order_token'),
131131
"return_url" => $this->urlBuilder->getUrl('checkout/onepage/success'),
132132
"cancel_url" => $this->urlBuilder->getUrl('checkout/onepage/failure'),
133133
"notify_url" => ($this->urlBuilder->getUrl('khipupayment/payment/callback', array("order_id" => $order->getIncrementId()))),
134-
"notify_api_version" => "1.3"
134+
"notify_api_version" => "1.3",
135+
"payer_email" => $order->getCustomerEmail()
135136
);
136137

137138
$createPaymentResponse = $payments->paymentsPost(
@@ -222,11 +223,8 @@ public function validateKhipuCallback(Order $order, $notificationToken, $apiVers
222223
if ($paymentResponse->getCurrency() != $order->getOrderCurrencyCode()) {
223224
throw new \Exception('Currency mismatch');
224225
}
225-
$order
226-
->setState(Order::STATE_PROCESSING, TRUE)
227-
->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_PROCESSING))
228-
->save();
229-
230-
226+
$order->setState(Order::STATE_PROCESSING, TRUE);
227+
$order->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_PROCESSING));
228+
$order->save();
231229
}
232230
}

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Magento 2 Khipu Plugin
22

3-
khipu payment gateway Magento 2.4 plugin.
3+
khipu payment gateway Magento 2.4.5 plugin.
44

5-
This version is compatible with Magento 2.3 and 2.4
5+
This version is compatible with Magento 2.3 to 2.6
66

77
You can sign up for khipu account at <https://khipu.com>
88

99
## Install via Composer
1010

11-
You can install Magento 2.4 khipu plugin via [Composer](http://getcomposer.org/). Run the following command in your terminal:
11+
You can install Magento 2.4.5 khipu plugin via [Composer](http://getcomposer.org/). Run the following command in your terminal:
1212

1313
1. Go to your Magento 2 root folder.
1414

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "khipu/magento2-khipu",
33
"type": "magento2-module",
44
"description": "khipu integration for Magento 2",
5-
"version": "2.4.1",
5+
"version": "2.4.5",
66
"homepage": "https://khipu.com",
77
"license": [
88
"OSL-3.0"

etc/di.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0"?>
2+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
3+
<type name="Magento\Framework\App\Request\CsrfValidator">
4+
<plugin name="csrf_validator_skip" type="Khipu\Payment\Model\CsrfValidatorSkip" />
5+
</type>
6+
</config>

etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noTestSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
3-
<module name="Khipu_Payment" setup_version="2.4.1" active="true">
3+
<module name="Khipu_Payment" setup_version="2.4.5" active="true">
44
<sequence>
55
<module name="Magento_Sales"/>
66
<module name="Magento_Checkout"/>

0 commit comments

Comments
 (0)