diff --git a/Config/module.xml b/Config/module.xml
index 41a210f..3723738 100755
--- a/Config/module.xml
+++ b/Config/module.xml
@@ -17,7 +17,7 @@
en_US
fr_FR
- 2.0.6
+ 2.0.7
Vincent Lopes-Vicente
diff --git a/Event/PayPlugPaymentEvent.php b/Event/PayPlugPaymentEvent.php
index f400872..bd76615 100755
--- a/Event/PayPlugPaymentEvent.php
+++ b/Event/PayPlugPaymentEvent.php
@@ -262,7 +262,8 @@ class PayPlugPaymentEvent extends ActionEvent
'brand' => [
'type' => "string",
'required' => true,
- 'access' => 'getBrand'
+ 'access' => 'getBrand',
+ 'maxLength' => 100
],
'expected_delivery_date' => [
'type' => "string",
@@ -272,7 +273,8 @@ class PayPlugPaymentEvent extends ActionEvent
'delivery_label' => [
'type' => "string",
'required' => true,
- 'access' => "getDeliveryLabel"
+ 'access' => "getDeliveryLabel",
+ 'maxLength' => 100
],
'delivery_type' => [
'type' => "string",
@@ -666,12 +668,14 @@ protected function buildArrayParameters($parameterDefinitions, &$array, $parentK
continue;
}
- $value = null;
$value = property_exists($target, $access) ? $target->{$access} :null;
if (null === $value && method_exists($target, $access)) {
$parameters = isset($parameterDefinition['accessParameters']) ? $parameterDefinition['accessParameters'] : [];
$value = call_user_func([$target, $access], ...$parameters);
}
+ if (isset($parameterDefinition['maxLength']) && strlen($value) > $parameterDefinition['maxLength']) {
+ $value = substr($value, 0, $parameterDefinition['maxLength']);
+ }
// If still null or empty no need to fill this parameter
if (null == $value) {
diff --git a/Event/PayPlugProduct.php b/Event/PayPlugProduct.php
index 042ba9c..b9dbebb 100644
--- a/Event/PayPlugProduct.php
+++ b/Event/PayPlugProduct.php
@@ -50,10 +50,17 @@ public function buildFromOrderProduct(OrderProduct $orderProduct, PayPlugModuleD
);
$deliveryType = $payPlugModuleDeliveryType !== null ? $payPlugModuleDeliveryType->getDeliveryType() : 'carrier';
- // Brand can't be find from order product but it's required so set store name as brand or "Unknown"
$this->setBrand($storeName);
$this->setExpectedDeliveryDate(date('Y-m-d'));
- $this->setDeliveryLabel($storeName);
+ $deliveryLabel = $storeName;
+ $order = $orderProduct->getOrder();
+ if (null !== $order) {
+ $deliveryLabelModule = $order->getDeliveryModuleInstance()->getCode();
+ if($deliveryLabelModule !== null) {
+ $deliveryLabel = $deliveryLabelModule;
+ }
+ }
+ $this->setDeliveryLabel($deliveryLabel);
$this->setDeliveryType($deliveryType);
$this->setMerchantItemId($orderProduct->getId());
$this->setName($orderProduct->getTitle());
diff --git a/EventListener/PaymentListener.php b/EventListener/PaymentListener.php
index b078eaa..b2639c3 100755
--- a/EventListener/PaymentListener.php
+++ b/EventListener/PaymentListener.php
@@ -173,15 +173,14 @@ protected function formatErrorMessage(PayplugException $exception)
$details = "";
-
if (isset($response['details'])) {
$details = implode(' -', array_map(
function ($v, $k) {
- $errors = [];
- foreach ($v as $field => $error) {
- $errors[] = "$field : $error";
+ if (is_array($v)) {
+ return " [$k] " . $this->processArray($v) . " .";
}
- return " [$k] ".implode(";", $errors)." .";
+
+ return " [$k] $v .";
},
$response['details'],
array_keys($response['details'])
@@ -191,6 +190,19 @@ function ($v, $k) {
return $response['message'] . $details;
}
+ private function processArray($array): string
+ {
+ $result = [];
+ foreach ($array as $key => $value) {
+ if (is_array($value)) {
+ $result[] = $this->processArray($value);
+ } else {
+ $result[] = "$key : $value";
+ }
+ }
+ return implode(";", $result);
+ }
+
/**
* @inheritDoc
*/
diff --git a/PayPlugModule.php b/PayPlugModule.php
index 8845604..6aa2b18 100755
--- a/PayPlugModule.php
+++ b/PayPlugModule.php
@@ -124,7 +124,9 @@ public function pay(Order $order)
if ($this->getRequest()->isXmlHttpRequest()) {
return new JsonResponse(['error' => $exception->getMessage()], 400);
}
- Tlog::getInstance()->addError('Error PayPlugModule::pay() : '. $exception->getMessage());
+ Tlog::getInstance()->addError(
+ 'Error PayPlugModule::pay() : ' . $exception->getMessage()
+ );
return new RedirectResponse(URL::getInstance()->absoluteUrl('error'));
}