Skip to content

Commit b787ee8

Browse files
authored
Feat/update laminas (#186)
* use only serializer json * remove xendit serializer all at once * Update to laminas and remove XenditSerializer class * Modify testing environment for 8.2 PHP * Add change log
1 parent d2cb9f0 commit b787ee8

16 files changed

+34
-36
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,4 @@ telepresence.log
9191

9292
.DS_Store
9393

94-
docker/magento2
94+
docker-magento/magento2

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# CHANGELOG
2+
## 12.0.4 (2025-02-25)
3+
- Fix Undefined variable $xenditSerializerJson
4+
- Upgrade using Laminas\Http\Request from previous Zend\Http\Request on several class
25

36
## 12.0.3 (2024-11-25)
47
- Remove UangMe as a payment method (regular & invoice multishipping)

Controller/Checkout/Invoice.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Magento\Framework\Phrase;
88
use Magento\Sales\Api\Data\OrderItemInterface;
99
use Magento\Sales\Model\Order;
10-
use Zend\Http\Request;
10+
use Laminas\Http\Request;
1111

1212
/**
1313
* Class Invoice

Controller/Checkout/InvoiceMultishipping.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Magento\Framework\Phrase;
88
use Magento\Sales\Api\Data\OrderItemInterface;
99
use Magento\Sales\Model\Order;
10-
use Zend\Http\Request;
10+
use Laminas\Http\Request;
1111

1212
/**
1313
* Class InvoiceMultishipping

Controller/Checkout/Notification.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
use Xendit\M2Invoice\Helper\Data;
2424
use Xendit\M2Invoice\Logger\Logger as XenditLogger;
2525
use Xendit\M2Invoice\Model\Payment\Xendit;
26-
use Zend\Http\Request;
26+
use Laminas\Http\Request;
2727

2828
/**
2929
* Class Notification
@@ -146,7 +146,7 @@ public function execute()
146146
{
147147
$post = $this->getRequest()->getContent();
148148
$callbackPayload = json_decode($post, true);
149-
$this->logger->info("callbackPayload", $callbackPayload);
149+
$this->logger->info("callbackPayload", array('payload' => $callbackPayload));
150150

151151
try {
152152
// Invoice: Regular CC, Ewallet, Retail Outlet, PayLater

Helper/ApiRequest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Magento\Framework\Phrase;
77
use Xendit\M2Invoice\Logger\Logger as XenditLogger;
88
use Xendit\M2Invoice\Model\Payment\Xendit;
9-
use Zend\Http\Request;
9+
use Laminas\Http\Request;
1010

1111
/**
1212
* Class ApiRequest

Helper/Metric.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function trackMetricCount(array $requestData)
7878
try {
7979
return $this->apiRequestHelper->request(
8080
$this->dataHelper->getXenditApiUrl() . "/tpi/log/metrics/count",
81-
\Zend\Http\Request::METHOD_POST,
81+
\Laminas\Http\Request::METHOD_POST,
8282
$requestData
8383
);
8484
} catch (LocalizedException $e) {

Model/Adminhtml/Source/CartRule.php

+2-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Magento\Framework\Model\Context;
66
use Magento\SalesRule\Model\ResourceModel\Rule\CollectionFactory;
77
use Magento\Framework\Serialize\Serializer\Json as MagentoSerializerJson;
8-
use Xendit\M2Invoice\External\Serialize\Serializer\Json as XenditSerializerJson;
98

109
/**
1110
* Class CartRule
@@ -48,23 +47,16 @@ class CartRule implements \Magento\Framework\Option\ArrayInterface
4847
* @param Context $context
4948
* @param CollectionFactory $ruleCollectionFactory
5049
* @param MagentoSerializerJson $magentoSerializerJson
51-
* @param XenditSerializerJson $xenditSerializerJson
5250
*/
5351
public function __construct(
5452
Context $context,
5553
CollectionFactory $ruleCollectionFactory,
56-
MagentoSerializerJson $magentoSerializerJson,
57-
XenditSerializerJson $xenditSerializerJson
54+
MagentoSerializerJson $magentoSerializerJson
5855
) {
5956
$this->ruleCollectionFactory = $ruleCollectionFactory;
6057
$this->cache = $context->getCacheManager();
6158
$this->magentoSerializerJson = $magentoSerializerJson;
62-
$this->xenditSerializerJson = $xenditSerializerJson;
63-
if (interface_exists("Magento\Framework\Serialize\Serializer\Json")) {
64-
$this->serializer = $this->magentoSerializerJson;
65-
} else {
66-
$this->serializer = $this->xenditSerializerJson;
67-
}
59+
$this->serializer = $this->magentoSerializerJson;
6860
}
6961

7062
/**

Model/Payment/AbstractInvoice.php

+2-10
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Xendit\M2Invoice\Helper\ApiRequest;
1717
use Magento\Quote\Api\CartRepositoryInterface;
1818
use Magento\Framework\Serialize\Serializer\Json as MagentoSerializerJson;
19-
use Xendit\M2Invoice\External\Serialize\Serializer\Json as XenditSerializerJson;
2019
use Magento\Quote\Api\Data\CartInterface;
2120
use Magento\Customer\Model\Session as CustomerSession;
2221
use Xendit\M2Invoice\Helper\Metric;
@@ -109,7 +108,6 @@ class AbstractInvoice extends AbstractMethod
109108
* @param RuleRepository $ruleRepo
110109
* @param CartRepositoryInterface $quoteRepository
111110
* @param MagentoSerializerJson $magentoSerializerJson
112-
* @param XenditSerializerJson $xenditSerializerJson
113111
* @param CustomerSession $customerSession
114112
*/
115113
public function __construct(
@@ -126,7 +124,7 @@ public function __construct(
126124
RuleRepository $ruleRepo,
127125
CartRepositoryInterface $quoteRepository,
128126
MagentoSerializerJson $magentoSerializerJson,
129-
XenditSerializerJson $xenditSerializerJson,
127+
// XenditSerializerJson $xenditSerializerJson,
130128
CustomerSession $customerSession,
131129
Metric $metricHelper
132130
) {
@@ -147,15 +145,9 @@ public function __construct(
147145
$this->ruleRepo = $ruleRepo;
148146
$this->quoteRepository = $quoteRepository;
149147
$this->magentoSerializerJson = $magentoSerializerJson;
150-
$this->xenditSerializerJson = $xenditSerializerJson;
151148
$this->customerSession = $customerSession;
152149
$this->metricHelper = $metricHelper;
153-
154-
if (interface_exists("Magento\Framework\Serialize\Serializer\Json")) {
155-
$this->serializer = $this->magentoSerializerJson;
156-
} else {
157-
$this->serializer = $this->xenditSerializerJson;
158-
}
150+
$this->serializer = $this->magentoSerializerJson;
159151
}
160152

161153
/**

Model/Payment/CC.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ private function handleRefundResult($payment, $refund, $canRefundMore)
107107
private function requestRefund($chargeId, $requestData)
108108
{
109109
$refundUrl = $this->dataHelper->getXenditApiUrl() . "/tpi/payment/xendit/credit-card/charges/$chargeId/refund";
110-
$refundMethod = \Zend\Http\Request::METHOD_POST;
110+
$refundMethod = \Laminas\Http\Request::METHOD_POST;
111111

112112
try {
113113
$refund = $this->apiHelper->request($refundUrl, $refundMethod, $requestData);

bin/copy-plugin.sh

+7-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ fi
1010
SOURCE_DIR="$1"
1111

1212
# Define the files and directories to zip
13-
FILES_TO_COPY="Block Controller etc External Gateway Helper Logger Model Plugin Setup Test view CHANGELOG.md LICENSE README.md registration.php composer.json setup-compile.sh"
13+
FILES_TO_COPY="Block Controller etc External Gateway Helper Logger Model Plugin Setup Test view CHANGELOG.md LICENSE README.md registration.php composer.json"
1414

1515
if [ "$SOURCE_DIR" = "devilbox" ]; then
1616
DESTINATION="../devilbox/data/www/magento/magento2/app/code/Xendit/M2Invoice"
1717
elif [ "$SOURCE_DIR" = "demosites" ]; then
1818
DESTINATION="../public_html/app/code/Xendit/M2Invoice"
19+
elif [ "$SOURCE_DIR" = "local-74" ]; then
20+
DESTINATION="./docker-magento/magento2/app/code/Xendit/M2Invoice"
1921
else
2022
echo "Invalid source directory"
2123
exit 1
@@ -28,7 +30,10 @@ cp -r $FILES_TO_COPY $DESTINATION || mkdir -p $DESTINATION && cp -r $FILES_TO_CO
2830

2931
# Check if the copy was successful
3032
if [ $? -eq 0 ]; then
31-
echo "Files copied successfully, please run 'bash setup-compile.sh' to compile the module"
33+
echo "Files copied successfully, please run 'bash setup-compile.sh' under folder \"app\" to compile the module"
34+
if [ "$SOURCE_DIR" = "local-74" ]; then
35+
docker exec web bash -c "cd /app && bash setup-compile.sh"
36+
fi
3237
else
3338
echo "Failed to copy files"
3439
proxit 1
File renamed without changes.

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "xendit/m2invoice",
33
"description": "Xendit Payment Gateway Module",
44
"type": "magento2-module",
5-
"version": "12.0.3",
5+
"version": "12.0.4",
66
"license": [
77
"GPL-3.0"
88
],

docker/README.md docker-magento/README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ php bin/magento setup:install \
8989
--admin-use-security-key=1 \
9090
--session-save=files \
9191
--use-sample-data \
92-
--elasticsearch-host=elasticsearch
92+
--search-engine=elasticsearch7 \
93+
--elasticsearch-host=elasticsearch \
94+
--elasticsearch-port=9200
9395
```
9496

9597
To include Xendit_M2Invoice module without composer, copy the inner `Xendit` folder into your `MAGENTO_DIR/app/code`
@@ -117,6 +119,8 @@ Install sample data:
117119
php bin/magento sampledata:deploy
118120
```
119121

122+
After that run setup & compile command again
123+
120124
### Alternative (Non auth)
121125

122126
You can also get the sample data by adding several package from composer, add this package into your `composer.json` installation
File renamed without changes.

docker/docker-compose.yml docker-magento/docker-compose.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
version: '3'
22
services:
33
web:
4-
image: webdevops/php-apache-dev:7.4
4+
image: webdevops/php-apache-dev:8.2
55
container_name: web
66
restart: always
7-
user: application
7+
user: root
88
environment:
99
- WEB_ALIAS_DOMAIN=magento24.local
1010
- WEB_DOCUMENT_ROOT=/app/pub
@@ -15,7 +15,7 @@ services:
1515
- PHP_POST_MAX_SIZE=500M
1616
- PHP_UPLOAD_MAX_FILESIZE=1024M
1717
volumes:
18-
- ./magento2:/app:cached
18+
- ./magento2:/app
1919
ports:
2020
- "80:80"
2121
- "443:443"
@@ -53,9 +53,11 @@ services:
5353
container_name: elasticsearch
5454
ports:
5555
- "9200:9200"
56-
- "9300:9300"
5756
environment:
5857
- discovery.type=single-node
58+
- network.host=0.0.0.0 # Changed from localhost
59+
- http.port=9200
60+
- cluster.name=elasticsearch
5961
volumes:
6062
- elasticsearch_data:/var/lib/elastisearch
6163
volumes:

0 commit comments

Comments
 (0)