Skip to content

Commit

Permalink
Feat/update laminas (#186)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
yanoandri authored Feb 25, 2025
1 parent d2cb9f0 commit b787ee8
Show file tree
Hide file tree
Showing 16 changed files with 34 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ telepresence.log

.DS_Store

docker/magento2
docker-magento/magento2
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# CHANGELOG
## 12.0.4 (2025-02-25)
- Fix Undefined variable $xenditSerializerJson
- Upgrade using Laminas\Http\Request from previous Zend\Http\Request on several class

## 12.0.3 (2024-11-25)
- Remove UangMe as a payment method (regular & invoice multishipping)
Expand Down
2 changes: 1 addition & 1 deletion Controller/Checkout/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Magento\Framework\Phrase;
use Magento\Sales\Api\Data\OrderItemInterface;
use Magento\Sales\Model\Order;
use Zend\Http\Request;
use Laminas\Http\Request;

/**
* Class Invoice
Expand Down
2 changes: 1 addition & 1 deletion Controller/Checkout/InvoiceMultishipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Magento\Framework\Phrase;
use Magento\Sales\Api\Data\OrderItemInterface;
use Magento\Sales\Model\Order;
use Zend\Http\Request;
use Laminas\Http\Request;

/**
* Class InvoiceMultishipping
Expand Down
4 changes: 2 additions & 2 deletions Controller/Checkout/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use Xendit\M2Invoice\Helper\Data;
use Xendit\M2Invoice\Logger\Logger as XenditLogger;
use Xendit\M2Invoice\Model\Payment\Xendit;
use Zend\Http\Request;
use Laminas\Http\Request;

/**
* Class Notification
Expand Down Expand Up @@ -146,7 +146,7 @@ public function execute()
{
$post = $this->getRequest()->getContent();
$callbackPayload = json_decode($post, true);
$this->logger->info("callbackPayload", $callbackPayload);
$this->logger->info("callbackPayload", array('payload' => $callbackPayload));

try {
// Invoice: Regular CC, Ewallet, Retail Outlet, PayLater
Expand Down
2 changes: 1 addition & 1 deletion Helper/ApiRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Magento\Framework\Phrase;
use Xendit\M2Invoice\Logger\Logger as XenditLogger;
use Xendit\M2Invoice\Model\Payment\Xendit;
use Zend\Http\Request;
use Laminas\Http\Request;

/**
* Class ApiRequest
Expand Down
2 changes: 1 addition & 1 deletion Helper/Metric.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function trackMetricCount(array $requestData)
try {
return $this->apiRequestHelper->request(
$this->dataHelper->getXenditApiUrl() . "/tpi/log/metrics/count",
\Zend\Http\Request::METHOD_POST,
\Laminas\Http\Request::METHOD_POST,
$requestData
);
} catch (LocalizedException $e) {
Expand Down
12 changes: 2 additions & 10 deletions Model/Adminhtml/Source/CartRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Magento\Framework\Model\Context;
use Magento\SalesRule\Model\ResourceModel\Rule\CollectionFactory;
use Magento\Framework\Serialize\Serializer\Json as MagentoSerializerJson;
use Xendit\M2Invoice\External\Serialize\Serializer\Json as XenditSerializerJson;

/**
* Class CartRule
Expand Down Expand Up @@ -48,23 +47,16 @@ class CartRule implements \Magento\Framework\Option\ArrayInterface
* @param Context $context
* @param CollectionFactory $ruleCollectionFactory
* @param MagentoSerializerJson $magentoSerializerJson
* @param XenditSerializerJson $xenditSerializerJson
*/
public function __construct(
Context $context,
CollectionFactory $ruleCollectionFactory,
MagentoSerializerJson $magentoSerializerJson,
XenditSerializerJson $xenditSerializerJson
MagentoSerializerJson $magentoSerializerJson
) {
$this->ruleCollectionFactory = $ruleCollectionFactory;
$this->cache = $context->getCacheManager();
$this->magentoSerializerJson = $magentoSerializerJson;
$this->xenditSerializerJson = $xenditSerializerJson;
if (interface_exists("Magento\Framework\Serialize\Serializer\Json")) {
$this->serializer = $this->magentoSerializerJson;
} else {
$this->serializer = $this->xenditSerializerJson;
}
$this->serializer = $this->magentoSerializerJson;
}

/**
Expand Down
12 changes: 2 additions & 10 deletions Model/Payment/AbstractInvoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Xendit\M2Invoice\Helper\ApiRequest;
use Magento\Quote\Api\CartRepositoryInterface;
use Magento\Framework\Serialize\Serializer\Json as MagentoSerializerJson;
use Xendit\M2Invoice\External\Serialize\Serializer\Json as XenditSerializerJson;
use Magento\Quote\Api\Data\CartInterface;
use Magento\Customer\Model\Session as CustomerSession;
use Xendit\M2Invoice\Helper\Metric;
Expand Down Expand Up @@ -109,7 +108,6 @@ class AbstractInvoice extends AbstractMethod
* @param RuleRepository $ruleRepo
* @param CartRepositoryInterface $quoteRepository
* @param MagentoSerializerJson $magentoSerializerJson
* @param XenditSerializerJson $xenditSerializerJson
* @param CustomerSession $customerSession
*/
public function __construct(
Expand All @@ -126,7 +124,7 @@ public function __construct(
RuleRepository $ruleRepo,
CartRepositoryInterface $quoteRepository,
MagentoSerializerJson $magentoSerializerJson,
XenditSerializerJson $xenditSerializerJson,
// XenditSerializerJson $xenditSerializerJson,
CustomerSession $customerSession,
Metric $metricHelper
) {
Expand All @@ -147,15 +145,9 @@ public function __construct(
$this->ruleRepo = $ruleRepo;
$this->quoteRepository = $quoteRepository;
$this->magentoSerializerJson = $magentoSerializerJson;
$this->xenditSerializerJson = $xenditSerializerJson;
$this->customerSession = $customerSession;
$this->metricHelper = $metricHelper;

if (interface_exists("Magento\Framework\Serialize\Serializer\Json")) {
$this->serializer = $this->magentoSerializerJson;
} else {
$this->serializer = $this->xenditSerializerJson;
}
$this->serializer = $this->magentoSerializerJson;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Model/Payment/CC.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private function handleRefundResult($payment, $refund, $canRefundMore)
private function requestRefund($chargeId, $requestData)
{
$refundUrl = $this->dataHelper->getXenditApiUrl() . "/tpi/payment/xendit/credit-card/charges/$chargeId/refund";
$refundMethod = \Zend\Http\Request::METHOD_POST;
$refundMethod = \Laminas\Http\Request::METHOD_POST;

try {
$refund = $this->apiHelper->request($refundUrl, $refundMethod, $requestData);
Expand Down
9 changes: 7 additions & 2 deletions bin/copy-plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ fi
SOURCE_DIR="$1"

# Define the files and directories to zip
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"
FILES_TO_COPY="Block Controller etc External Gateway Helper Logger Model Plugin Setup Test view CHANGELOG.md LICENSE README.md registration.php composer.json"

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

# Check if the copy was successful
if [ $? -eq 0 ]; then
echo "Files copied successfully, please run 'bash setup-compile.sh' to compile the module"
echo "Files copied successfully, please run 'bash setup-compile.sh' under folder \"app\" to compile the module"
if [ "$SOURCE_DIR" = "local-74" ]; then
docker exec web bash -c "cd /app && bash setup-compile.sh"
fi
else
echo "Failed to copy files"
proxit 1
Expand Down
File renamed without changes.
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": "xendit/m2invoice",
"description": "Xendit Payment Gateway Module",
"type": "magento2-module",
"version": "12.0.3",
"version": "12.0.4",
"license": [
"GPL-3.0"
],
Expand Down
6 changes: 5 additions & 1 deletion docker/README.md → docker-magento/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ php bin/magento setup:install \
--admin-use-security-key=1 \
--session-save=files \
--use-sample-data \
--elasticsearch-host=elasticsearch
--search-engine=elasticsearch7 \
--elasticsearch-host=elasticsearch \
--elasticsearch-port=9200
```

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

After that run setup & compile command again

### Alternative (Non auth)

You can also get the sample data by adding several package from composer, add this package into your `composer.json` installation
Expand Down
File renamed without changes.
10 changes: 6 additions & 4 deletions docker/docker-compose.yml → docker-magento/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
version: '3'
services:
web:
image: webdevops/php-apache-dev:7.4
image: webdevops/php-apache-dev:8.2
container_name: web
restart: always
user: application
user: root
environment:
- WEB_ALIAS_DOMAIN=magento24.local
- WEB_DOCUMENT_ROOT=/app/pub
Expand All @@ -15,7 +15,7 @@ services:
- PHP_POST_MAX_SIZE=500M
- PHP_UPLOAD_MAX_FILESIZE=1024M
volumes:
- ./magento2:/app:cached
- ./magento2:/app
ports:
- "80:80"
- "443:443"
Expand Down Expand Up @@ -53,9 +53,11 @@ services:
container_name: elasticsearch
ports:
- "9200:9200"
- "9300:9300"
environment:
- discovery.type=single-node
- network.host=0.0.0.0 # Changed from localhost
- http.port=9200
- cluster.name=elasticsearch
volumes:
- elasticsearch_data:/var/lib/elastisearch
volumes:
Expand Down

0 comments on commit b787ee8

Please sign in to comment.