Skip to content

Commit

Permalink
Actualización compatibilidad PHP 8
Browse files Browse the repository at this point in the history
  • Loading branch information
JKacicM committed Aug 4, 2023
1 parent 251ca96 commit 562b795
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 13 deletions.
22 changes: 22 additions & 0 deletions Model/CsrfValidatorSkip.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
namespace Khipu\Payment\Model;
class CsrfValidatorSkip
{
/**
* @param \Magento\Framework\App\Request\CsrfValidator $subject
* @param \Closure $proceed
* @param \Magento\Framework\App\RequestInterface $request
* @param \Magento\Framework\App\ActionInterface $action
*/
public function aroundValidate(
$subject,
\Closure $proceed,
$request,
$action
) {
if ($request->getModuleName() == 'Your_Module_frontName_Here') {
return; // Skip CSRF check
}
$proceed($request, $action); // Proceed Magento 2 core functionalities
}
}
14 changes: 6 additions & 8 deletions Model/Simplified.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,13 @@ public function getKhipuRequest(Order $order)

$opts = array(
"transaction_id" => $order->getIncrementId(),
"body" => join($description, ', '),
"body" => join(', ',$description),
"custom" => $payment->getAdditionalInformation('khipu_order_token'),
"return_url" => $this->urlBuilder->getUrl('checkout/onepage/success'),
"cancel_url" => $this->urlBuilder->getUrl('checkout/onepage/failure'),
"notify_url" => ($this->urlBuilder->getUrl('khipupayment/payment/callback', array("order_id" => $order->getIncrementId()))),
"notify_api_version" => "1.3"
"notify_api_version" => "1.3",
"payer_email" => $order->getCustomerEmail()
);

$createPaymentResponse = $payments->paymentsPost(
Expand Down Expand Up @@ -222,11 +223,8 @@ public function validateKhipuCallback(Order $order, $notificationToken, $apiVers
if ($paymentResponse->getCurrency() != $order->getOrderCurrencyCode()) {
throw new \Exception('Currency mismatch');
}
$order
->setState(Order::STATE_PROCESSING, TRUE)
->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_PROCESSING))
->save();


$order->setState(Order::STATE_PROCESSING, TRUE);
$order->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_PROCESSING));
$order->save();
}
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Magento 2 Khipu Plugin

khipu payment gateway Magento 2.4 plugin.
khipu payment gateway Magento 2.4.5 plugin.

This version is compatible with Magento 2.3 and 2.4
This version is compatible with Magento 2.3 to 2.6

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

## Install via Composer

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

1. Go to your Magento 2 root folder.

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "khipu/magento2-khipu",
"type": "magento2-module",
"description": "khipu integration for Magento 2",
"version": "2.4.1",
"version": "2.4.5",
"homepage": "https://khipu.com",
"license": [
"OSL-3.0"
Expand Down
6 changes: 6 additions & 0 deletions etc/di.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Framework\App\Request\CsrfValidator">
<plugin name="csrf_validator_skip" type="Khipu\Payment\Model\CsrfValidatorSkip" />
</type>
</config>
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noTestSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Khipu_Payment" setup_version="2.4.1" active="true">
<module name="Khipu_Payment" setup_version="2.4.5" active="true">
<sequence>
<module name="Magento_Sales"/>
<module name="Magento_Checkout"/>
Expand Down

0 comments on commit 562b795

Please sign in to comment.