Skip to content

Instantly share code, notes, and snippets.

@Frank-Magmodules
Created July 28, 2023 13:48
Show Gist options
  • Save Frank-Magmodules/579b252a75ceb4b1aa0a1c4239254f16 to your computer and use it in GitHub Desktop.
Save Frank-Magmodules/579b252a75ceb4b1aa0a1c4239254f16 to your computer and use it in GitHub Desktop.
diff --git a/Model/Client/Payments.php b/Model/Client/Payments.php
index 4251d29..2aaea59 100644
--- a/Model/Client/Payments.php
+++ b/Model/Client/Payments.php
@@ -221,7 +221,7 @@ class Payments extends AbstractModel
$orderId = $order->getEntityId();
$transactionId = $order->getMollieTransactionId();
- if (!empty($transactionId) && !preg_match('/^ord_\w+$/', $transactionId)) {
+ if (!empty($transactionId) && substr($transactionId, 0, 4) != 'ord_') {
$payment = $mollieApi->payments->get($transactionId);
return $payment->getCheckoutUrl();
}
diff --git a/Model/Mollie.php b/Model/Mollie.php
index 65f30db..399e975 100644
--- a/Model/Mollie.php
+++ b/Model/Mollie.php
@@ -359,7 +359,7 @@ class Mollie extends Adapter
$type,
$paymentToken
) {
- if (preg_match('/^ord_\w+$/', $transactionId)) {
+ if (substr($transactionId, 0, 4) == 'ord_') {
$result = $this->ordersProcessTraction->execute($order, $type)->toArray();
} else {
$mollieApi = $this->mollieApiClient->loadByStore($order->getStoreId());
@@ -397,7 +397,7 @@ class Mollie extends Adapter
$mollieApi = $this->mollieApiClient->loadByStore($order->getStoreId());
- if (preg_match('/^ord_\w+$/', $transactionId)) {
+ if (substr($transactionId, 0, 4) == 'ord_') {
return $this->ordersApi->orderHasUpdate($order, $mollieApi);
} else {
return $this->paymentsApi->orderHasUpdate($order, $mollieApi);
diff --git a/Observer/SalesOrderShipmentSaveBefore/CreateMollieShipment.php b/Observer/SalesOrderShipmentSaveBefore/CreateMollieShipment.php
index e9846cb..485cf4d 100644
--- a/Observer/SalesOrderShipmentSaveBefore/CreateMollieShipment.php
+++ b/Observer/SalesOrderShipmentSaveBefore/CreateMollieShipment.php
@@ -59,7 +59,7 @@ class CreateMollieShipment implements ObserverInterface
$order = $shipment->getOrder();
$transactionId = $order->getMollieTransactionId() ?? '';
- $useOrdersApi = preg_match('/^ord_\w+$/', $transactionId);
+ $useOrdersApi = substr($transactionId, 0, 4) == 'ord_';
if ($useOrdersApi) {
$this->ordersApi->createShipment($shipment, $order);
}
diff --git a/Service/Mollie/Order/CreateInvoiceOnShipment.php b/Service/Mollie/Order/CreateInvoiceOnShipment.php
index 79c4867..7fbcd18 100644
--- a/Service/Mollie/Order/CreateInvoiceOnShipment.php
+++ b/Service/Mollie/Order/CreateInvoiceOnShipment.php
@@ -32,7 +32,7 @@ class CreateInvoiceOnShipment
}
$transactionId = $order->getMollieTransactionId() ?? '';
- $api = preg_match('/^ord_\w+$/', $transactionId) ? 'orders' : 'payments';
+ $api = substr($transactionId, 0, 4) == 'ord_' ? 'orders' : 'payments';
if ($methodCode == 'mollie_methods_creditcard' &&
$this->config->useManualCapture($order->getStoreId()) &&
$api == 'payments'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment