From 9aa11842d43b76ab2df7706841450f80e050aae4 Mon Sep 17 00:00:00 2001 From: Anne Date: Fri, 15 Mar 2024 12:01:18 +0100 Subject: [PATCH 1/5] Clean Pay. api errors --- upload/Pay/Controller/Payment.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/upload/Pay/Controller/Payment.php b/upload/Pay/Controller/Payment.php index 75ac4a6..90fb7c3 100755 --- a/upload/Pay/Controller/Payment.php +++ b/upload/Pay/Controller/Payment.php @@ -258,7 +258,8 @@ public function startTransaction() $response['success'] = $result['transaction']['paymentURL']; } catch (Pay_Api_Exception $e) { - $response['error'] = "De Pay. api gaf de volgende fout: " . $e->getMessage(); + $message = $this->getErrorMessage($e->getMessage()); + $response['error'] = "De Pay. api gaf de volgende fout: " . $message; } catch (Pay_Exception $e) { $response['error'] = "Er is een fout opgetreden: " . $e->getMessage(); } catch (Exception $e) { @@ -359,4 +360,20 @@ public function isTestMode() } return $this->config->get('payment_paynl_general_testmode'); } + + public function getErrorMessage($message) + { + $errorCode = strtok($message, " "); + + if ($errorCode == "PAY-0") { + $errorMessage = str_replace("PAY-0 - An exception occurred: ", "", $message); + } else { + $message = explode(' ', $message); + $message = array_slice($message, 2); + $message = implode(' ', $message); + $errorMessage = $message; + } + + return $errorMessage; + } } From 035e451518b446fbe05a2f796670b3526f6afd54 Mon Sep 17 00:00:00 2001 From: Anne Date: Fri, 15 Mar 2024 14:48:21 +0100 Subject: [PATCH 2/5] Small code changes --- upload/Pay/Controller/Payment.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/upload/Pay/Controller/Payment.php b/upload/Pay/Controller/Payment.php index 90fb7c3..eff7992 100755 --- a/upload/Pay/Controller/Payment.php +++ b/upload/Pay/Controller/Payment.php @@ -361,6 +361,10 @@ public function isTestMode() return $this->config->get('payment_paynl_general_testmode'); } + /** + * @param $message + * @return string + */ public function getErrorMessage($message) { $errorCode = strtok($message, " "); From 1760d5dd64885a608d8150357894ee5ae80f3190 Mon Sep 17 00:00:00 2001 From: Anne Date: Wed, 20 Mar 2024 15:33:09 +0100 Subject: [PATCH 3/5] Made requested changes --- upload/Pay/Controller/Payment.php | 22 +++++++++++-------- .../de-de/extension/payment/paynl3.php | 5 +++++ .../en-gb/extension/payment/paynl3.php | 5 +++++ .../fr-fr/extension/payment/paynl3.php | 5 +++++ .../nl-nl/extension/payment/paynl3.php | 5 +++++ 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/upload/Pay/Controller/Payment.php b/upload/Pay/Controller/Payment.php index eff7992..1233497 100755 --- a/upload/Pay/Controller/Payment.php +++ b/upload/Pay/Controller/Payment.php @@ -58,6 +58,7 @@ public function index() */ public function startTransaction() { + $this->load->language('extension/payment/paynl3'); $this->load->model('extension/payment/' . $this->_paymentMethodName); $this->load->model('checkout/order'); $modelName = 'model_extension_payment_' . $this->_paymentMethodName; @@ -259,7 +260,7 @@ public function startTransaction() $response['success'] = $result['transaction']['paymentURL']; } catch (Pay_Api_Exception $e) { $message = $this->getErrorMessage($e->getMessage()); - $response['error'] = "De Pay. api gaf de volgende fout: " . $message; + $response['error'] = $this->language->get('text_pay_api_error') . " " . $this->language->get($message); } catch (Pay_Exception $e) { $response['error'] = "Er is een fout opgetreden: " . $e->getMessage(); } catch (Exception $e) { @@ -367,15 +368,18 @@ public function isTestMode() */ public function getErrorMessage($message) { - $errorCode = strtok($message, " "); - - if ($errorCode == "PAY-0") { - $errorMessage = str_replace("PAY-0 - An exception occurred: ", "", $message); + $message = strtolower(trim($message)); + + if (stripos($message, 'minimum amount') !== false + || stripos($message, 'maximum amount') !== false + || stripos($message, 'Amount is not allowed') !== false) { + $errorMessage = 'text_pay_api_error_amount'; + } elseif (stripos($message, 'is not activated for this sales location') !== false) { + $errorMessage = 'text_pay_api_error_activated'; + } elseif (stripos($message, 'not allowed in country') !== false) { + $errorMessage = 'text_pay_api_error_country'; } else { - $message = explode(' ', $message); - $message = array_slice($message, 2); - $message = implode(' ', $message); - $errorMessage = $message; + $errorMessage = 'text_pay_api_error_general'; } return $errorMessage; diff --git a/upload/catalog/language/de-de/extension/payment/paynl3.php b/upload/catalog/language/de-de/extension/payment/paynl3.php index 7c9f275..9a1a07a 100644 --- a/upload/catalog/language/de-de/extension/payment/paynl3.php +++ b/upload/catalog/language/de-de/extension/payment/paynl3.php @@ -9,3 +9,8 @@ $_['error_vat'] = 'Um diese Transaktion abzuschließen, ist eine Umsatzsteuer-Identifikationsnummer erforderlich. Bitte geben Sie diese hier ein.'; $_['text_cancel'] = 'Die Zahlung wurde storniert.'; $_['text_denied'] = 'Leider wurde die Zahlung abgelehnt. Bitte versuchen Sie es erneut oder verwenden Sie eine andere Zahlungsmethode.'; +$_['text_pay_api_error'] = 'Die Pay. API hat folgenden Fehler ausgegeben:'; +$_['text_pay_api_error_amount'] = 'Leider entspricht der Bestellbetrag nicht den Anforderungen für diese Zahlungsart.'; +$_['text_pay_api_error_activated'] = 'Die ausgewählte Zahlungsmethode ist nicht aktiviert. Bitte wählen Sie eine andere Zahlungsmethode.'; +$_['text_pay_api_error_country'] = 'Diese Währung ist in Kombination mit dieser Zahlungsmethode nicht zulässig. Bitte wählen Sie eine andere Zahlungsmethode.'; +$_['text_pay_api_error_general'] = 'Leider ist etwas schief gelaufen.'; diff --git a/upload/catalog/language/en-gb/extension/payment/paynl3.php b/upload/catalog/language/en-gb/extension/payment/paynl3.php index 98c4f4c..fc87be8 100644 --- a/upload/catalog/language/en-gb/extension/payment/paynl3.php +++ b/upload/catalog/language/en-gb/extension/payment/paynl3.php @@ -8,3 +8,8 @@ $_['error_vat'] = 'A VAT-id is required to finish this transaction, please fill it in.'; $_['text_cancel'] = 'The payment has been canceled, please try again.'; $_['text_denied'] = 'Unfortunately the payment has been denied. Please try again or use another payment method.'; +$_['text_pay_api_error'] = 'The Pay. api gave the following error:'; +$_['text_pay_api_error_amount'] = 'Unfortunately the order amount does not fit the requirements for this payment method.'; +$_['text_pay_api_error_activated'] = 'The selected payment method is not enabled. Please select another payment method.'; +$_['text_pay_api_error_country'] = 'This currency is not allowed in combination with this payment method. Please select another payment method.'; +$_['text_pay_api_error_general'] = 'Unfortunately something went wrong.'; diff --git a/upload/catalog/language/fr-fr/extension/payment/paynl3.php b/upload/catalog/language/fr-fr/extension/payment/paynl3.php index ecf3cb2..2adb680 100644 --- a/upload/catalog/language/fr-fr/extension/payment/paynl3.php +++ b/upload/catalog/language/fr-fr/extension/payment/paynl3.php @@ -9,3 +9,8 @@ $_['error_dob'] = 'Une date de naissance est requise pour finaliser votre transaction. Veuillez le saisir ici.'; $_['text_cancel'] = 'Le paiement a été annulé.'; $_['text_denied'] = 'Malheureusement, le paiement a été rejeté. Veuillez réessayer ou utiliser un autre mode de paiement'; +$_['text_pay_api_error'] = "La Pay. l'API a donné l'erreur suivante:"; +$_['text_pay_api_error_amount'] = "Malheureusement, le montant de la commande ne correspond pas aux exigences de ce mode de paiement."; +$_['text_pay_api_error_activated'] = "Le mode de paiement sélectionné n'est pas activé. Veuillez sélectionner un autre mode de paiement."; +$_['text_pay_api_error_country'] = "Cette devise n'est pas autorisée en combinaison avec ce mode de paiement. Veuillez sélectionner un autre mode de paiement."; +$_['text_pay_api_error_general'] = "Malheureusement, quelque chose s'est mal passé."; diff --git a/upload/catalog/language/nl-nl/extension/payment/paynl3.php b/upload/catalog/language/nl-nl/extension/payment/paynl3.php index b807a28..5f9a9fd 100644 --- a/upload/catalog/language/nl-nl/extension/payment/paynl3.php +++ b/upload/catalog/language/nl-nl/extension/payment/paynl3.php @@ -8,3 +8,8 @@ $_['error_dob'] = 'Een geboortedatum is vereist om uw transactie af te ronden. Vul deze aub hier in.'; $_['text_cancel'] = 'De betaling is geannuleerd.'; $_['text_denied'] = 'De betaling is helaas afgewezen. Probeer het opnieuw of gebruik een andere betaalmethode'; +$_['text_pay_api_error'] = 'De Pay. api gaf de volgende foutmelding:'; +$_['text_pay_api_error_amount'] = 'Helaas voldoet het bestelbedrag niet aan de eisen voor deze betaalmethode.'; +$_['text_pay_api_error_activated'] = 'De geselecteerde betaalmethode is niet ingeschakeld. Selecteer een andere betaalmethode.'; +$_['text_pay_api_error_country'] = 'Deze valuta is niet toegestaan in combinatie met deze betaalmethode. Selecteer een andere betaalmethode.'; +$_['text_pay_api_error_general'] = 'Helaas ging er iets mis.'; From 880f04813bff2a970ac93c24481a0288a62a2b23 Mon Sep 17 00:00:00 2001 From: Anne Date: Wed, 20 Mar 2024 15:42:08 +0100 Subject: [PATCH 4/5] Small changes --- upload/Pay/Controller/Payment.php | 6 ++++-- upload/catalog/language/en-gb/extension/payment/paynl3.php | 1 + upload/catalog/language/nl-nl/extension/payment/paynl3.php | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/upload/Pay/Controller/Payment.php b/upload/Pay/Controller/Payment.php index 1233497..c566ab5 100755 --- a/upload/Pay/Controller/Payment.php +++ b/upload/Pay/Controller/Payment.php @@ -370,9 +370,11 @@ public function getErrorMessage($message) { $message = strtolower(trim($message)); - if (stripos($message, 'minimum amount') !== false + if ( + stripos($message, 'minimum amount') !== false || stripos($message, 'maximum amount') !== false - || stripos($message, 'Amount is not allowed') !== false) { + || stripos($message, 'Amount is not allowed') !== false + ) { $errorMessage = 'text_pay_api_error_amount'; } elseif (stripos($message, 'is not activated for this sales location') !== false) { $errorMessage = 'text_pay_api_error_activated'; diff --git a/upload/catalog/language/en-gb/extension/payment/paynl3.php b/upload/catalog/language/en-gb/extension/payment/paynl3.php index fc87be8..b177a41 100644 --- a/upload/catalog/language/en-gb/extension/payment/paynl3.php +++ b/upload/catalog/language/en-gb/extension/payment/paynl3.php @@ -1,4 +1,5 @@ Date: Fri, 22 Mar 2024 11:00:44 +0100 Subject: [PATCH 5/5] Made requested change --- upload/Pay/Controller/Payment.php | 2 +- upload/catalog/language/de-de/extension/payment/paynl3.php | 1 - upload/catalog/language/en-gb/extension/payment/paynl3.php | 1 - upload/catalog/language/fr-fr/extension/payment/paynl3.php | 1 - upload/catalog/language/nl-nl/extension/payment/paynl3.php | 1 - 5 files changed, 1 insertion(+), 5 deletions(-) diff --git a/upload/Pay/Controller/Payment.php b/upload/Pay/Controller/Payment.php index c566ab5..6438414 100755 --- a/upload/Pay/Controller/Payment.php +++ b/upload/Pay/Controller/Payment.php @@ -260,7 +260,7 @@ public function startTransaction() $response['success'] = $result['transaction']['paymentURL']; } catch (Pay_Api_Exception $e) { $message = $this->getErrorMessage($e->getMessage()); - $response['error'] = $this->language->get('text_pay_api_error') . " " . $this->language->get($message); + $response['error'] = $this->language->get($message); } catch (Pay_Exception $e) { $response['error'] = "Er is een fout opgetreden: " . $e->getMessage(); } catch (Exception $e) { diff --git a/upload/catalog/language/de-de/extension/payment/paynl3.php b/upload/catalog/language/de-de/extension/payment/paynl3.php index 9a1a07a..2259fdb 100644 --- a/upload/catalog/language/de-de/extension/payment/paynl3.php +++ b/upload/catalog/language/de-de/extension/payment/paynl3.php @@ -9,7 +9,6 @@ $_['error_vat'] = 'Um diese Transaktion abzuschließen, ist eine Umsatzsteuer-Identifikationsnummer erforderlich. Bitte geben Sie diese hier ein.'; $_['text_cancel'] = 'Die Zahlung wurde storniert.'; $_['text_denied'] = 'Leider wurde die Zahlung abgelehnt. Bitte versuchen Sie es erneut oder verwenden Sie eine andere Zahlungsmethode.'; -$_['text_pay_api_error'] = 'Die Pay. API hat folgenden Fehler ausgegeben:'; $_['text_pay_api_error_amount'] = 'Leider entspricht der Bestellbetrag nicht den Anforderungen für diese Zahlungsart.'; $_['text_pay_api_error_activated'] = 'Die ausgewählte Zahlungsmethode ist nicht aktiviert. Bitte wählen Sie eine andere Zahlungsmethode.'; $_['text_pay_api_error_country'] = 'Diese Währung ist in Kombination mit dieser Zahlungsmethode nicht zulässig. Bitte wählen Sie eine andere Zahlungsmethode.'; diff --git a/upload/catalog/language/en-gb/extension/payment/paynl3.php b/upload/catalog/language/en-gb/extension/payment/paynl3.php index b177a41..4b240db 100644 --- a/upload/catalog/language/en-gb/extension/payment/paynl3.php +++ b/upload/catalog/language/en-gb/extension/payment/paynl3.php @@ -9,7 +9,6 @@ $_['error_vat'] = 'A VAT-id is required to finish this transaction, please fill it in.'; $_['text_cancel'] = 'The payment has been canceled, please try again.'; $_['text_denied'] = 'Unfortunately the payment has been denied. Please try again or use another payment method.'; -$_['text_pay_api_error'] = 'The Pay. api gave the following error:'; $_['text_pay_api_error_amount'] = 'Unfortunately the order amount does not fit the requirements for this payment method.'; $_['text_pay_api_error_activated'] = 'The selected payment method is not enabled. Please select another payment method.'; $_['text_pay_api_error_country'] = 'This currency is not allowed in combination with this payment method. Please select another payment method.'; diff --git a/upload/catalog/language/fr-fr/extension/payment/paynl3.php b/upload/catalog/language/fr-fr/extension/payment/paynl3.php index 2adb680..fc38111 100644 --- a/upload/catalog/language/fr-fr/extension/payment/paynl3.php +++ b/upload/catalog/language/fr-fr/extension/payment/paynl3.php @@ -9,7 +9,6 @@ $_['error_dob'] = 'Une date de naissance est requise pour finaliser votre transaction. Veuillez le saisir ici.'; $_['text_cancel'] = 'Le paiement a été annulé.'; $_['text_denied'] = 'Malheureusement, le paiement a été rejeté. Veuillez réessayer ou utiliser un autre mode de paiement'; -$_['text_pay_api_error'] = "La Pay. l'API a donné l'erreur suivante:"; $_['text_pay_api_error_amount'] = "Malheureusement, le montant de la commande ne correspond pas aux exigences de ce mode de paiement."; $_['text_pay_api_error_activated'] = "Le mode de paiement sélectionné n'est pas activé. Veuillez sélectionner un autre mode de paiement."; $_['text_pay_api_error_country'] = "Cette devise n'est pas autorisée en combinaison avec ce mode de paiement. Veuillez sélectionner un autre mode de paiement."; diff --git a/upload/catalog/language/nl-nl/extension/payment/paynl3.php b/upload/catalog/language/nl-nl/extension/payment/paynl3.php index a10a581..f0619f3 100644 --- a/upload/catalog/language/nl-nl/extension/payment/paynl3.php +++ b/upload/catalog/language/nl-nl/extension/payment/paynl3.php @@ -9,7 +9,6 @@ $_['error_dob'] = 'Een geboortedatum is vereist om uw transactie af te ronden. Vul deze aub hier in.'; $_['text_cancel'] = 'De betaling is geannuleerd.'; $_['text_denied'] = 'De betaling is helaas afgewezen. Probeer het opnieuw of gebruik een andere betaalmethode'; -$_['text_pay_api_error'] = 'De Pay. api gaf de volgende foutmelding:'; $_['text_pay_api_error_amount'] = 'Helaas voldoet het bestelbedrag niet aan de eisen voor deze betaalmethode.'; $_['text_pay_api_error_activated'] = 'De geselecteerde betaalmethode is niet ingeschakeld. Selecteer een andere betaalmethode.'; $_['text_pay_api_error_country'] = 'Deze valuta is niet toegestaan in combinatie met deze betaalmethode. Selecteer een andere betaalmethode.';