diff --git a/admin/controller/payment/worldline.php b/admin/controller/payment/worldline.php index 540d8c2..3488809 100644 --- a/admin/controller/payment/worldline.php +++ b/admin/controller/payment/worldline.php @@ -152,14 +152,26 @@ public function advanced(): void { $data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones(); $this->load->model('localisation/language'); - - $data['languages'] = $this->model_localisation_language->getLanguages(); - foreach ($data['languages'] as $language) { + $data['languages'] = []; + + $languages = $this->model_localisation_language->getLanguages(); + + foreach ($languages as $language) { + $language_code = explode('-', $language['code']); + $language_code = strtoupper(reset($language_code)); + + $data['languages'][] = [ + 'language_id' => $language['language_id'], + 'language_code' => $language_code, + 'code' => $language['code'], + 'name' => $language['name'] + ]; + $_language = new \Opencart\System\Library\Language($language['code']); $_language->addPath(DIR_EXTENSION . 'worldline/admin/language/'); $_language->load('payment/worldline'); - + if (file_exists(DIR_EXTENSION . 'worldline/admin/language/' . $language['code'] . '/payment/worldline.php')) { if (empty($data['setting']['advanced']['title'][$language['language_id']])) { $data['setting']['advanced']['title'][$language['language_id']] = $_language->get('heading_title'); @@ -178,7 +190,7 @@ public function advanced(): void { } } } - + $result = $this->model_extension_worldline_payment_worldline->checkVersion(VERSION, $data['setting']['version']); if (!empty($result['href'])) { @@ -469,9 +481,9 @@ public function transaction(): void { 'limit' => (int)$this->config->get('config_pagination_admin') ]; - $order_total = $this->model_extension_worldline_payment_worldline->getTotalOrders($filter_data); + $order_total = $this->model_extension_worldline_payment_worldline->getTotalWorldlineOrders($filter_data); - $results = $this->model_extension_worldline_payment_worldline->getOrders($filter_data); + $results = $this->model_extension_worldline_payment_worldline->getWorldlineOrders($filter_data); foreach ($results as $result) { if ($result['date']) { @@ -780,16 +792,20 @@ public function install(): void { $this->model_setting_event->deleteEventByCode('worldline_order_info'); $this->model_setting_event->deleteEventByCode('worldline_order_delete_order'); + $this->model_setting_event->deleteEventByCode('worldline_customer_delete_customer'); if (VERSION >= '4.0.2.0') { $this->model_setting_event->addEvent(['code' => 'worldline_order_info', 'description' => '', 'trigger' => 'admin/view/sale/order_info/before', 'action' => 'extension/worldline/payment/worldline.order_info_before', 'status' => true, 'sort_order' => 1]); $this->model_setting_event->addEvent(['code' => 'worldline_order_delete_order', 'description' => '', 'trigger' => 'catalog/model/checkout/order/deleteOrder/before', 'action' => 'extension/worldline/payment/worldline.order_delete_order_before', 'status' => true, 'sort_order' => 2]); + $this->model_setting_event->addEvent(['code' => 'worldline_customer_delete_custome', 'description' => '', 'trigger' => 'admin/model/customer/customer/deleteCustomer/before', 'action' => 'extension/worldline/payment/worldline.customer_delete_customer_before', 'status' => true, 'sort_order' => 3]); } elseif (VERSION >= '4.0.1.0') { $this->model_setting_event->addEvent(['code' => 'worldline_order_info', 'description' => '', 'trigger' => 'admin/view/sale/order_info/before', 'action' => 'extension/worldline/payment/worldline|order_info_before', 'status' => true, 'sort_order' => 1]); $this->model_setting_event->addEvent(['code' => 'worldline_order_delete_order', 'description' => '', 'trigger' => 'catalog/model/checkout/order/deleteOrder/before', 'action' => 'extension/worldline/payment/worldline|order_delete_order_before', 'status' => true, 'sort_order' => 2]); + $this->model_setting_event->addEvent(['code' => 'worldline_customer_delete_customer', 'description' => '', 'trigger' => 'admin/model/customer/customer/deleteCustomer/before', 'action' => 'extension/worldline/payment/worldline|customer_delete_customer_before', 'status' => true, 'sort_order' => 3]); } else { $this->model_setting_event->addEvent('worldline_order_info', '', 'admin/view/sale/order_info/before', 'extension/worldline/payment/worldline|order_info_before', true, 1); $this->model_setting_event->addEvent('worldline_order_delete_order', '', 'catalog/model/checkout/order/deleteOrder/before', 'extension/worldline/payment/worldline|order_delete_order_before', true, 2); + $this->model_setting_event->addEvent('worldline_customer_delete_customer', '', 'admin/model/customer/customer/deleteCustomer/before', 'extension/worldline/payment/worldline|customer_delete_customer_before', true, 3); } // Setting @@ -815,12 +831,21 @@ public function uninstall(): void { $this->model_setting_event->deleteEventByCode('worldline_order_info'); $this->model_setting_event->deleteEventByCode('worldline_order_delete_order'); + $this->model_setting_event->deleteEventByCode('worldline_customer_delete_customer'); $this->load->model('setting/setting'); $this->model_setting_setting->deleteSetting('worldline_version'); } + public function customer_delete_customer_before($route, &$data) { + $this->load->model('extension/worldline/payment/worldline'); + + $customer_id = $data[0]; + + $this->model_extension_worldline_payment_worldline->deleteWorldlineCustomerTokens($customer_id); + } + public function order_info_before(string $route, array &$data): void { if ($data['tabs']) { foreach ($data['tabs'] as $tab_key => $tab) { @@ -867,7 +892,7 @@ private function getPaymentDetails(int $order_id): string { $this->load->model('localisation/country'); $order_info = $this->model_sale_order->getOrder($order_id); - $worldline_order_info = $this->model_extension_worldline_payment_worldline->getOrder($order_id); + $worldline_order_info = $this->model_extension_worldline_payment_worldline->getWorldlineOrder($order_id); if ($order_info && $worldline_order_info) { $data['order_id'] = $order_id; @@ -948,6 +973,8 @@ private function getPaymentDetails(int $order_id): string { $data['currency_code'] = $payment_response->getPaymentOutput()->getAmountOfMoney()->getCurrencyCode(); $data['payment_product_id'] = ''; + $data['payment_type'] = ''; + $data['token'] = ''; if (!empty($payment_response->getPaymentOutput()->getCardPaymentMethodSpecificOutput())) { $data['payment_product_id'] = $payment_response->getPaymentOutput()->getCardPaymentMethodSpecificOutput()->getPaymentProductId(); @@ -957,6 +984,8 @@ private function getPaymentDetails(int $order_id): string { $data['liability'] = $payment_response->getPaymentOutput()->getCardPaymentMethodSpecificOutput()->getThreeDSecureResults()->getLiability(); $data['exemption'] = $payment_response->getPaymentOutput()->getCardPaymentMethodSpecificOutput()->getThreeDSecureResults()->getAppliedExemption(); $data['authentication_status'] = $payment_response->getPaymentOutput()->getCardPaymentMethodSpecificOutput()->getThreeDSecureResults()->getAuthenticationStatus(); + $data['token'] = $payment_response->getPaymentOutput()->getCardPaymentMethodSpecificOutput()->getToken(); + $data['payment_type'] = 'card'; } if (!empty($payment_response->getPaymentOutput()->getMobilePaymentMethodSpecificOutput())) { @@ -970,6 +999,8 @@ private function getPaymentDetails(int $order_id): string { if (!empty($payment_response->getPaymentOutput()->getRedirectPaymentMethodSpecificOutput())) { $data['payment_product_id'] = $payment_response->getPaymentOutput()->getRedirectPaymentMethodSpecificOutput()->getPaymentProductId(); $data['fraud_result'] = $payment_response->getPaymentOutput()->getRedirectPaymentMethodSpecificOutput()->getFraudResults()->getFraudServiceResult(); + $data['token'] = $payment_response->getPaymentOutput()->getRedirectPaymentMethodSpecificOutput()->getToken(); + $data['payment_type'] = 'card'; } if (!empty($payment_response->getPaymentOutput()->getSepaDirectDebitPaymentMethodSpecificOutput())) { @@ -1002,13 +1033,11 @@ private function getPaymentDetails(int $order_id): string { if ($data['transaction_status'] == 'refunded') { $order_status_id = $setting['order_status']['refunded']['id']; } - - if ($order_status_id) { - if ($order_info['order_status_id'] != $order_status_id) { - $this->model_extension_worldline_payment_worldline->addHistory($order_id, $order_status_id, '', true); - } + + if ($order_status_id && ($order_info['order_status_id'] != $order_status_id)) { + $this->model_extension_worldline_payment_worldline->addHistory($order_id, $order_status_id, '', true); } - + if (($data['transaction_status'] == 'created') || ($data['transaction_status'] == 'pending_capture') || ($data['transaction_status'] == 'captured') || ($data['transaction_status'] == 'cancelled') || ($data['transaction_status'] == 'rejected') || ($data['transaction_status'] == 'rejected_capture') || ($data['transaction_status'] == 'refunded') || ($data['transaction_status'] == 'authorization_requested') || ($data['transaction_status'] == 'capture_requested') || ($data['transaction_status'] == 'refund_requested')) { if (!$worldline_order_info['transaction_status']) { $payment_product_params = new \OnlinePayments\Sdk\Merchant\Products\GetPaymentProductParams(); @@ -1038,16 +1067,36 @@ private function getPaymentDetails(int $order_id): string { } } - $worldline_data = [ + $worldline_order_data = [ 'order_id' => $worldline_order_info['order_id'], 'transaction_status' => $data['transaction_status'], 'payment_product' => $data['payment_product'], + 'payment_type' => $data['payment_type'], + 'token' => $data['token'], 'total' => $data['total'], 'amount' => $data['amount'], 'currency_code' => $data['currency_code'] ]; - $this->model_extension_worldline_payment_worldline->updateOrder($worldline_data); + $this->model_extension_worldline_payment_worldline->editWorldlineOrder($worldline_order_data); + + if (!empty($order_info['customer_id']) && $data['token']) { + $customer_id = $order_info['customer_id']; + + $worldline_customer_token_info = $this->model_extension_worldline_payment_worldline->getWorldlineCustomerToken($customer_id, $data['payment_type'], $data['token']); + + if (!$worldline_customer_token_info) { + $worldline_customer_token_data = [ + 'customer_id' => $customer_id, + 'payment_type' => $data['payment_type'], + 'token' => $data['token'] + ]; + + $this->model_extension_worldline_payment_worldline->addWorldlineCustomerToken($worldline_customer_token_data); + } + + $this->model_extension_worldline_payment_worldline->setWorldlineCustomerMainToken($customer_id, $data['payment_type'], $data['token']); + } } } @@ -1127,16 +1176,15 @@ public function capturePayment(): void { $currency_code = $capture_response->getCaptureOutput()->getAmountOfMoney()->getCurrencyCode(); if (($transaction_status == 'created') || ($transaction_status == 'pending_capture') || ($transaction_status == 'captured') || ($transaction_status == 'cancelled') || ($transaction_status == 'rejected') || ($transaction_status == 'rejected_capture') || ($transaction_status == 'refunded') || ($transaction_status == 'authorization_requested') || ($transaction_status == 'capture_requested') || ($transaction_status == 'refund_requested')) { - $worldline_data = [ + $worldline_order_data = [ 'order_id' => $order_id, 'transaction_status' => $transaction_status, - 'payment_product' => '', 'total' => $total, 'amount' => $amount, 'currency_code' => $currency_code ]; - $this->model_extension_worldline_payment_worldline->updateOrder($worldline_data); + $this->model_extension_worldline_payment_worldline->editWorldlineOrder($worldline_order_data); } $data['success'] = $this->language->get('success_capture'); @@ -1223,7 +1271,7 @@ public function cancelPayment(): void { $currency_code = $cancel_response->getPayment()->getPaymentOutput()->getAmountOfMoney()->getCurrencyCode(); if (($transaction_status == 'created') || ($transaction_status == 'pending_capture') || ($transaction_status == 'captured') || ($transaction_status == 'cancelled') || ($transaction_status == 'rejected') || ($transaction_status == 'rejected_capture') || ($transaction_status == 'refunded') || ($transaction_status == 'authorization_requested') || ($transaction_status == 'capture_requested') || ($transaction_status == 'refund_requested')) { - $worldline_data = [ + $worldline_order_data = [ 'order_id' => $order_id, 'transaction_status' => $transaction_status, 'total' => $total, @@ -1231,7 +1279,7 @@ public function cancelPayment(): void { 'currency_code' => $currency_code ]; - $this->model_extension_worldline_payment_worldline->updateOrder($worldline_data); + $this->model_extension_worldline_payment_worldline->editWorldlineOrder($worldline_order_data); } $data['success'] = $this->language->get('success_cancel'); @@ -1317,14 +1365,14 @@ public function refundPayment(): void { $currency_code = $refund_response->getRefundOutput()->getAmountOfMoney()->getCurrencyCode(); if (($transaction_status == 'created') || ($transaction_status == 'pending_capture') || ($transaction_status == 'captured') || ($transaction_status == 'cancelled') || ($transaction_status == 'rejected') || ($transaction_status == 'rejected_capture') || ($transaction_status == 'refunded') || ($transaction_status == 'authorization_requested') || ($transaction_status == 'capture_requested') || ($transaction_status == 'refund_requested')) { - $worldline_data = [ + $worldline_order_data = [ 'order_id' => $order_id, 'transaction_status' => $transaction_status, 'total' => $total, 'currency_code' => $currency_code ]; - $this->model_extension_worldline_payment_worldline->updateOrder($worldline_data); + $this->model_extension_worldline_payment_worldline->editWorldlineOrder($worldline_order_data); } $data['success'] = $this->language->get('success_refund'); @@ -1403,16 +1451,16 @@ private function validateSave(): array|bool { $api_endpoint = $setting['account']['api_endpoint'][$environment]; require_once DIR_EXTENSION . 'worldline/system/library/worldline/OnlinePayments.php'; - - $connection = new \OnlinePayments\Sdk\DefaultConnection(); - $communicator_configuration = new \OnlinePayments\Sdk\CommunicatorConfiguration($api_key, $api_secret, $api_endpoint, 'OnlinePayments'); + try { + $connection = new \OnlinePayments\Sdk\DefaultConnection(); + + $communicator_configuration = new \OnlinePayments\Sdk\CommunicatorConfiguration($api_key, $api_secret, $api_endpoint, 'OnlinePayments'); - $communicator = new \OnlinePayments\Sdk\Communicator($connection, $communicator_configuration); + $communicator = new \OnlinePayments\Sdk\Communicator($connection, $communicator_configuration); - $client = new \OnlinePayments\Sdk\Client($communicator); - - try { + $client = new \OnlinePayments\Sdk\Client($communicator); + $client->merchant($merchant_id)->services()->testConnection(); } catch (\OnlinePayments\Sdk\ResponseException $exception) { $errors = $exception->getResponse()->getErrors(); @@ -1431,6 +1479,15 @@ private function validateSave(): array|bool { } } } + + if (!empty($setting['advanced'])) { + $setting['advanced']['template'] = trim($setting['advanced']['template']); + + if (($setting['advanced']['template'] != '') && (substr($setting['advanced']['template'], -4, 4) != '.htm') && (substr($setting['advanced']['template'], -5, 5) != '.html') && (substr($setting['advanced']['template'], -6, 6) != '.dhtml')) { + $this->error['template'] = $this->language->get('error_template'); + $this->error['warning'] = $this->language->get('error_warning'); + } + } return !$this->error; } diff --git a/admin/language/de-de/payment/worldline.php b/admin/language/de-de/payment/worldline.php index 9ccafdd..56f93d3 100644 --- a/admin/language/de-de/payment/worldline.php +++ b/admin/language/de-de/payment/worldline.php @@ -10,7 +10,7 @@ $_['text_tab_advanced'] = 'Erweiterte Einstellungen'; $_['text_tab_order_status'] = 'Bestellstatus'; $_['text_tab_transaction'] = 'Transaktionen'; -$_['text_tab_suggest'] = 'Schlagen Sie eine neue Funktion vor'; +$_['text_tab_suggest'] = 'Kontaktiere uns'; $_['text_live'] = 'Live'; $_['text_test'] = 'Test'; $_['text_api_credential_alert'] = 'Um den API Key und das API Secret in Ihrer PSPID abzurufen, führen Sie die folgenden Schritte aus:
1) Melden Sie sich im Backoffice an
2) Gehen Sie zu Configuration > Technical information > Ingenico Direct Settings > Direct API Key
3) Wenn Sie noch nichts konfiguriert haben, wird auf dem Bildschirm "No API credentials found" angezeigt. Um sowohl den API Key als auch das API Secret zu erstellen, klicken Sie auf "GENERATE"'; @@ -94,9 +94,12 @@ $_['entry_title'] = 'Zahlungstitel'; $_['entry_button_title'] = 'Titel der Zahlungsschaltfläche'; $_['entry_authorization_mode'] = 'Autorisierungsmodus'; +$_['entry_group_cards'] = 'Gruppenkarten'; +$_['entry_forced_tokenization'] = 'Erzwungene Tokenisierung'; +$_['entry_tds_status'] = '3DS-Status'; $_['entry_challenge_indicator'] = '3DS-Herausforderungsanzeige'; $_['entry_exemption_request'] = '3DS-Ausnahmeantrag'; -$_['entry_group_cards'] = 'Gruppenkarten'; +$_['entry_template'] = 'Name der Vorlagendatei'; $_['entry_debug'] = 'Debug Protokollierung'; $_['entry_total'] = 'Summe'; $_['entry_geo_zone'] = 'Geozone'; @@ -115,6 +118,8 @@ // Help $_['help_webhook_url'] = 'Legen Sie Webhooks im Worldline Back Office fest, um diese URL aufzurufen.'; $_['help_cron_url'] = 'Legen Sie einen Cron fest, um diese URL aufzurufen.'; +$_['help_template'] = 'Wenn Sie eine benutzerdefinierte Vorlage verwenden, geben Sie bitte hier den Namen ein. Wenn leer, wird die Standard-Zahlungsseite angezeigt. Das Erscheinungsbild der Zahlungsseite kann im Worldline Back Office angepasst werden.'; +$_['help_total'] = 'Mindestgesamtsumme im Warenkorb damit diese Zahlungsart verfügbar ist.'; $_['help_company_name'] = 'Ihr Firmenname.'; $_['help_message'] = 'Bitte erläutern Sie, wie unser Zahlungs-Plugin weiter verbessert werden kann.'; @@ -132,11 +137,10 @@ // Button $_['button_save'] = 'Speichern'; -$_['button_back'] = 'Zurück'; $_['button_sign_up'] = 'Konto erstellen / Anmelden'; $_['button_contact_us'] = 'Kontaktiere uns'; $_['button_reset_api_endpoint'] = 'API Endpoint zurücksetzen'; -$_['button_copy_url'] = 'URL kopieren'; +$_['button_copy_url'] = 'URL in die Zwischenablage kopieren'; $_['button_filter'] = 'Filter'; $_['button_send_suggest'] = 'Senden'; $_['button_capture'] = 'Erfassen'; @@ -164,5 +168,6 @@ $_['error_api_secret_test'] = 'Test API Secret ist falsch!'; $_['error_webhook_key_test'] = 'Test Webhook Key ist falsch!'; $_['error_webhook_secret_test'] = 'Test Webhook Secret ist falsch!'; +$_['error_template'] = 'Der Name der Vorlagendatei ist falsch! Es muss die Endung .htm, .html oder .dhtml haben!'; $_['error_company_name'] = 'Der Firmenname muss zwischen 3 und 32 Zeichen lang sein!'; $_['error_message'] = 'Die Nachricht muss zwischen 20 und 1000 Zeichen lang sein!'; \ No newline at end of file diff --git a/admin/language/en-gb/payment/worldline.php b/admin/language/en-gb/payment/worldline.php index 6581bfe..44c91cf 100644 --- a/admin/language/en-gb/payment/worldline.php +++ b/admin/language/en-gb/payment/worldline.php @@ -10,7 +10,7 @@ $_['text_tab_advanced'] = 'Advanced Settings'; $_['text_tab_order_status'] = 'Order Status'; $_['text_tab_transaction'] = 'Transactions'; -$_['text_tab_suggest'] = 'Suggest a new feature'; +$_['text_tab_suggest'] = 'Contact Us'; $_['text_live'] = 'Live'; $_['text_test'] = 'Test'; $_['text_api_credential_alert'] = 'To retrieve the API Key and API Secret in your PSPID, follow these steps:
1) Login to the Back Office
2) Go to Configuration > Technical information > Ingenico Direct Settings > Direct API Key
3) If you have not configured anything yet, the screen shows "No API credentials found". To create both API Key and API Secret click on "GENERATE"'; @@ -94,9 +94,12 @@ $_['entry_title'] = 'Payment Title'; $_['entry_button_title'] = 'Payment Button Title'; $_['entry_authorization_mode'] = 'Authorization Mode'; -$_['entry_challenge_indicator'] = '3DS Challenge Indicator'; -$_['entry_exemption_request'] = '3DS Exemption Request'; $_['entry_group_cards'] = 'Group Cards'; +$_['entry_forced_tokenization'] = 'Forced Tokenization'; +$_['entry_tds_status'] = '3DS Status'; +$_['entry_tds_challenge_indicator'] = '3DS Challenge Indicator'; +$_['entry_tds_exemption_request'] = '3DS Exemption Request'; +$_['entry_template'] = 'Template File Name'; $_['entry_debug'] = 'Debug Logging'; $_['entry_total'] = 'Total'; $_['entry_geo_zone'] = 'Geo Zone'; @@ -115,6 +118,8 @@ // Help $_['help_webhook_url'] = 'Set webhooks in Worldline Back Office to call this URL.'; $_['help_cron_url'] = 'Set a cron to call this URL.'; +$_['help_template'] = 'If you are using a customized template, please enter the name here. If empty, the standard payment page will be displayed. Payment page look and feel can be customized on Worldline Back Office.'; +$_['help_total'] = 'The checkout total the order must reach before this payment method becomes active.'; $_['help_company_name'] = 'Your company name.'; $_['help_message'] = 'Please explain how our payment plugin can be further improved.'; @@ -132,11 +137,10 @@ // Button $_['button_save'] = 'Save'; -$_['button_back'] = 'Back'; $_['button_sign_up'] = 'Create Account / Sign Up'; $_['button_contact_us'] = 'Contact Us'; $_['button_reset_api_endpoint'] = 'Reset API Endpoint'; -$_['button_copy_url'] = 'Copy to clipboard'; +$_['button_copy_url'] = 'Copy URL to clipboard'; $_['button_filter'] = 'Filter'; $_['button_send_suggest'] = 'Send'; $_['button_capture'] = 'Capture'; @@ -164,5 +168,6 @@ $_['error_api_secret_test'] = 'Test API Secret is incorrect!'; $_['error_webhook_key_test'] = 'Test Webhook Key is incorrect!'; $_['error_webhook_secret_test'] = 'Test Webhook Secret is incorrect!'; +$_['error_template'] = 'Template File Name is incorrect! It must have the extension .htm, .html or .dhtml!'; $_['error_company_name'] = 'Company Name must be between 3 and 32 characters!'; $_['error_message'] = 'Message must be between 20 and 1000 characters!'; \ No newline at end of file diff --git a/admin/language/es-es/payment/worldline.php b/admin/language/es-es/payment/worldline.php index a318575..c65e149 100644 --- a/admin/language/es-es/payment/worldline.php +++ b/admin/language/es-es/payment/worldline.php @@ -10,7 +10,7 @@ $_['text_tab_advanced'] = 'Ajustes avanzados'; $_['text_tab_order_status'] = 'Estado del pedido'; $_['text_tab_transaction'] = 'Actas'; -$_['text_tab_suggest'] = 'Sugerir una nueva característica'; +$_['text_tab_suggest'] = 'Contacta con nosotros'; $_['text_live'] = 'Vivir'; $_['text_test'] = 'Test'; $_['text_api_credential_alert'] = 'Para recuperar el API Key y el API Secret en su PSPID, siga estos pasos:
1) Inicie sesión en la oficina virtual
2) Vaya a Configuration > Technical information > Ingenico Direct Settings > Direct API Key
3) Si aún no ha configurado nada, la pantalla muestra "No API credentials found". Para crear tanto API Key como el API Secret, haga clic en "GENERATE"'; @@ -94,9 +94,12 @@ $_['entry_title'] = 'Título de pago'; $_['entry_button_title'] = 'Título del botón de pago'; $_['entry_authorization_mode'] = 'Modo de autorización'; +$_['entry_group_cards'] = 'Tarjetas de grupo'; +$_['entry_forced_tokenization'] = 'Tokenización forzada'; +$_['entry_tds_status'] = 'Estado 3DS'; $_['entry_challenge_indicator'] = 'Indicador de desafío 3DS'; $_['entry_exemption_request'] = 'Solicitud de exención 3DS'; -$_['entry_group_cards'] = 'Tarjetas de grupo'; +$_['entry_template'] = 'Nombre del archivo de plantilla'; $_['entry_debug'] = 'Registro de depuración'; $_['entry_total'] = 'Total'; $_['entry_geo_zone'] = 'Zona Geográfica'; @@ -115,6 +118,8 @@ // Help $_['help_webhook_url'] = 'Configure webhooks en el Back Office de Worldline para llamar a esta URL.'; $_['help_cron_url'] = 'Configure un cron para llamar a esta URL.'; +$_['help_template'] = 'Si está utilizando una plantilla personalizada, ingrese el nombre aquí. Si está vacía, se mostrará la página de pago estándar. La apariencia de la página de pago se puede personalizar en el Back Office de Worldline.'; +$_['help_total'] = 'El total que el pedido debe alcanzar para que este método de pago sea activado.'; $_['help_company_name'] = 'El nombre de tu compañía.'; $_['help_message'] = 'Explique cómo se puede mejorar aún más nuestro complemento de pago.'; @@ -132,11 +137,10 @@ // Button $_['button_save'] = 'Guardar'; -$_['button_back'] = 'Atrás'; $_['button_sign_up'] = 'Crear cuenta / Registrarse'; $_['button_contact_us'] = 'Contacta con nosotros'; $_['button_reset_api_endpoint'] = 'Restablecer API Endpoint'; -$_['button_copy_url'] = 'Copiar al portapapeles'; +$_['button_copy_url'] = 'Copiar URL al portapapeles'; $_['button_filter'] = 'Filtrar'; $_['button_send_suggest'] = 'Enviar'; $_['button_capture'] = 'Captura'; @@ -164,5 +168,6 @@ $_['error_api_secret_test'] = 'Test API Secret ¡Es incorrecto!'; $_['error_webhook_key_test'] = 'Test Webhook Key ¡Es incorrecto!'; $_['error_webhook_secret_test'] = 'Test Webhook Secret ¡Es incorrecto!'; +$_['error_template'] = '¡El nombre del archivo de plantilla es incorrecto! ¡Debe tener la extensión .htm, .html o .dhtml!'; $_['error_company_name'] = '¡El nombre de la empresa debe tener entre 3 y 32 caracteres!'; $_['error_message'] = '¡El mensaje debe tener entre 20 y 1000 caracteres!'; \ No newline at end of file diff --git a/admin/language/fr-fr/payment/worldline.php b/admin/language/fr-fr/payment/worldline.php index 8c37709..b3d0274 100644 --- a/admin/language/fr-fr/payment/worldline.php +++ b/admin/language/fr-fr/payment/worldline.php @@ -10,7 +10,7 @@ $_['text_tab_advanced'] = 'Réglages avancés'; $_['text_tab_order_status'] = 'Statut de la commande'; $_['text_tab_transaction'] = 'Transactions'; -$_['text_tab_suggest'] = 'Suggérer une nouvelle fonctionnalité'; +$_['text_tab_suggest'] = 'Contactez-nous'; $_['text_live'] = 'Vivre'; $_['text_test'] = 'Test'; $_['text_api_credential_alert'] = 'Pour récupérer la API Key et le API Secret dans votre PSPID, suivez ces étapes :
1) Connectez-vous au Back Office
2) Allez dans Configuration > Technical information > Ingenico Direct Settings > Direct API Key
3) Si vous n\'avez encore rien configuré, l\'écran affiche "No API credentials found". Pour créer à la fois la API Key et le API Secret, cliquez sur "GENERATE"'; @@ -94,9 +94,12 @@ $_['entry_title'] = 'Titre du paiement'; $_['entry_button_title'] = 'Titre du bouton de paiement'; $_['entry_authorization_mode'] = 'Mode d\'autorisation'; +$_['entry_group_cards'] = 'Cartes de groupe'; +$_['entry_forced_tokenization'] = 'Tokenisation forcée'; +$_['entry_tds_status'] = 'Statut 3DS'; $_['entry_challenge_indicator'] = 'Indicateur de défi 3DS'; $_['entry_exemption_request'] = 'Demande d\'exemption 3DS'; -$_['entry_group_cards'] = 'Cartes de groupe'; +$_['entry_template'] = 'Nom du fichier modèle'; $_['entry_debug'] = 'Journalisation du débogage'; $_['entry_total'] = 'Total'; $_['entry_geo_zone'] = 'Zone géographique'; @@ -115,6 +118,8 @@ // Help $_['help_webhook_url'] = 'Configurez des webhooks dans le Back Office Worldline pour appeler cette URL.'; $_['help_cron_url'] = 'Définissez un cron pour appeler cette URL.'; +$_['help_template'] = 'Si vous utilisez un modèle personnalisé, veuillez saisir le nom ici. Si vide, la page de paiement standard sera affichée. L’apparence et la convivialité de la page de paiement peuvent être personnalisées sur le Back Office Worldline.'; +$_['help_total'] = 'Le montant total que la commande doit atteindre avant que ce mode de paiement ne devienne actif.'; $_['help_company_name'] = 'Le nom de votre société.'; $_['help_message'] = 'Veuillez expliquer comment notre plugin de paiement peut être encore amélioré.'; @@ -132,11 +137,10 @@ // Button $_['button_save'] = 'Sauvegarder'; -$_['button_back'] = 'Dos'; $_['button_sign_up'] = 'Créer un compte / S\'inscrire'; $_['button_contact_us'] = 'Contactez-nous'; $_['button_reset_api_endpoint'] = 'Réinitialiser API Endpoint'; -$_['button_copy_url'] = 'Copier dans le presse-papiers'; +$_['button_copy_url'] = 'Copier l\'URL dans le presse-papiers'; $_['button_filter'] = 'Filtrer'; $_['button_send_suggest'] = 'Envoyer'; $_['button_capture'] = 'Capturer'; @@ -164,5 +168,6 @@ $_['error_api_secret_test'] = 'Test API Secret est incorrect!'; $_['error_webhook_key_test'] = 'Test Webhook Key est incorrect!'; $_['error_webhook_secret_test'] = 'Test Webhook Secret est incorrect!'; +$_['error_template'] = 'Le nom du fichier modèle est incorrect! Il doit avoir l\'extension .htm, .html ou .dhtml!'; $_['error_company_name'] = 'Le nom de l’entreprise doit comporter entre 3 et 32 caractères!'; $_['error_message'] = 'Le message doit comporter entre 20 et 1000 caractères!'; \ No newline at end of file diff --git a/admin/language/it-it/payment/worldline.php b/admin/language/it-it/payment/worldline.php index 50343eb..e124fcc 100644 --- a/admin/language/it-it/payment/worldline.php +++ b/admin/language/it-it/payment/worldline.php @@ -10,7 +10,7 @@ $_['text_tab_advanced'] = 'Impostazioni avanzate'; $_['text_tab_order_status'] = 'Lo stato dell\'ordine'; $_['text_tab_transaction'] = 'Transazioni'; -$_['text_tab_suggest'] = 'Suggerisci una nuova funzionalità'; +$_['text_tab_suggest'] = 'Contattaci'; $_['text_live'] = 'Vivere'; $_['text_test'] = 'Test'; $_['text_api_credential_alert'] = 'Per recuperare la API Key e l\'API Secret nel tuo PSPID, segui questi passaggi:
1) Accedi al Back Office
2) Vai a Configuration > Technical information > Ingenico Direct Settings > Direct API Key
3) Se non hai ancora configurato nulla, la schermata mostra "No API credentials found". Per creare sia API Key che API Secret clicca su "GENERATE"'; @@ -94,9 +94,12 @@ $_['entry_title'] = 'Titolo di pagamento'; $_['entry_button_title'] = 'Titolo del pulsante di pagamento'; $_['entry_authorization_mode'] = 'Modalità di autorizzazione'; +$_['entry_group_cards'] = 'Carte di gruppo'; +$_['entry_forced_tokenization'] = 'Tokenizzazione forzata'; +$_['entry_tds_status'] = 'Stato 3DS'; $_['entry_challenge_indicator'] = 'Indicatore di sfida 3DS'; $_['entry_exemption_request'] = 'Richiesta di esenzione 3DS'; -$_['entry_group_cards'] = 'Carte di gruppo'; +$_['entry_template'] = 'Nome file modello'; $_['entry_debug'] = 'Registrazione di debug'; $_['entry_total'] = 'Totale'; $_['entry_geo_zone'] = 'Zona geografica'; @@ -115,6 +118,8 @@ // Help $_['help_webhook_url'] = 'Imposta i webhook nel Back Office di Worldline per chiamare questo URL.'; $_['help_cron_url'] = 'Imposta un cron per chiamare questo URL.'; +$_['help_template'] = 'Se stai utilizzando un modello personalizzato, inserisci il nome qui. Se vuoto, verrà visualizzata la pagina di pagamento standard. L\'aspetto della pagina di pagamento può essere personalizzato sul Back Office di Worldline.'; +$_['help_total'] = 'Il totale che deve essere raggiunto per abilitare questo metodo di pagamento.'; $_['help_company_name'] = 'Il nome della tua azienda.'; $_['help_message'] = 'Spiega come il nostro plugin di pagamento può essere ulteriormente migliorato.'; @@ -132,11 +137,10 @@ // Button $_['button_save'] = 'Salva'; -$_['button_back'] = 'Indietro'; $_['button_sign_up'] = 'Crea un account/Registrati'; $_['button_contact_us'] = 'Contattaci'; $_['button_reset_api_endpoint'] = 'Reimposta API Endpoint'; -$_['button_copy_url'] = 'Copia negli appunti'; +$_['button_copy_url'] = 'Copia l\'URL negli appunti'; $_['button_filter'] = 'Filtra'; $_['button_send_suggest'] = 'Invia'; $_['button_capture'] = 'Catturare'; @@ -164,5 +168,6 @@ $_['error_api_secret_test'] = 'Test API Secret non è corretto!'; $_['error_webhook_key_test'] = 'Test Webhook Key non è corretto!'; $_['error_webhook_secret_test'] = 'Test Webhook Secret non è corretto!'; +$_['error_template'] = 'Il nome del file modello non è corretto! Deve avere l\'estensione .htm, .html o .dhtml!'; $_['error_company_name'] = 'Il nome dell\'azienda deve contenere da 3 a 32 caratteri!'; $_['error_message'] = 'Il messaggio deve contenere tra 20 e 1000 caratteri!'; \ No newline at end of file diff --git a/admin/language/nl-nl/payment/worldline.php b/admin/language/nl-nl/payment/worldline.php index f902b64..a2120f3 100644 --- a/admin/language/nl-nl/payment/worldline.php +++ b/admin/language/nl-nl/payment/worldline.php @@ -10,7 +10,7 @@ $_['text_tab_advanced'] = 'Geavanceerde instellingen'; $_['text_tab_order_status'] = 'Bestelstatus'; $_['text_tab_transaction'] = 'Transacties'; -$_['text_tab_suggest'] = 'Stel een nieuwe functie voor'; +$_['text_tab_suggest'] = 'Neem contact met ons op'; $_['text_live'] = 'Live'; $_['text_test'] = 'Test'; $_['text_api_credential_alert'] = 'Om de API-Key en het API Secret in uw PSPID op te halen, volgt u deze stappen:
1) Meld u aan bij de backoffice
2) Ga naar Configuration > Technical information > Ingenico Direct Settings > Direct API Key
3) Als u nog niets heeft geconfigureerd, toont het scherm "No API credentials found". Om zowel API Key als API Secret aan te maken, klikt u op "GENERATE"'; @@ -94,9 +94,12 @@ $_['entry_title'] = 'Betalingstitel'; $_['entry_button_title'] = 'Titel van de betalingsknop'; $_['entry_authorization_mode'] = 'Autorisatiemodus'; +$_['entry_group_cards'] = 'Groepskaarten'; +$_['entry_forced_tokenization'] = 'Geforceerde tokenisatie'; +$_['entry_tds_status'] = '3DS-status'; $_['entry_challenge_indicator'] = '3DS-uitdagingsindicator'; $_['entry_exemption_request'] = '3DS-vrijstellingsverzoek'; -$_['entry_group_cards'] = 'Groepskaarten'; +$_['entry_template'] = 'Sjabloonbestandsnaam'; $_['entry_debug'] = 'Foutopsporing in logboekregistratie'; $_['entry_total'] = 'Totaal'; $_['entry_geo_zone'] = 'Geo-zone'; @@ -115,6 +118,8 @@ // Help $_['help_webhook_url'] = 'Stel webhooks in Worldline Back Office in om deze URL aan te roepen.'; $_['help_cron_url'] = 'Stel een cron in om deze URL aan te roepen.'; +$_['help_template'] = 'Als u een aangepast sjabloon gebruikt, voer dan hier de naam in. Indien leeg wordt de standaard betaalpagina weergegeven. Het uiterlijk van de betaalpagina kan worden aangepast in de Worldline Back Office.'; +$_['help_total'] = 'Het afrekentotaal dat de bestelling moet bereiken voordat deze betaalmethode actief wordt.'; $_['help_company_name'] = 'Je bedrijfsnaam.'; $_['help_message'] = 'Leg uit hoe onze betalingsplug-in verder kan worden verbeterd.'; @@ -132,11 +137,10 @@ // Button $_['button_save'] = 'Opslaan'; -$_['button_back'] = 'Rug'; $_['button_sign_up'] = 'Account aanmaken / Aanmelden'; $_['button_contact_us'] = 'Neem contact met ons op'; $_['button_reset_api_endpoint'] = 'Opnieuw instellen API Endpoint'; -$_['button_copy_url'] = 'Kopieer naar klembord'; +$_['button_copy_url'] = 'Kopieer URL naar klembord'; $_['button_filter'] = 'Filter'; $_['button_send_suggest'] = 'Versturen'; $_['button_capture'] = 'Gevangen nemen'; @@ -164,5 +168,6 @@ $_['error_api_secret_test'] = 'Test API Secret is onjuist!'; $_['error_webhook_key_test'] = 'Test Webhook Key is onjuist!'; $_['error_webhook_secret_test'] = 'Test Webhook Secret is onjuist!'; +$_['error_template'] = 'Sjabloonbestandsnaam is onjuist! Het moet de extensie .htm, .html of .dhtml hebben!'; $_['error_company_name'] = 'Bedrijfsnaam moet tussen 3 en 32 tekens lang zijn!'; $_['error_message'] = 'Bericht moet tussen de 20 en 1000 tekens lang zijn!'; \ No newline at end of file diff --git a/admin/model/payment/worldline.php b/admin/model/payment/worldline.php index 051e0fa..368ec72 100644 --- a/admin/model/payment/worldline.php +++ b/admin/model/payment/worldline.php @@ -2,7 +2,60 @@ namespace Opencart\Admin\Model\Extension\Worldline\Payment; class Worldline extends \Opencart\System\Engine\Model { - public function updateOrder(array $data): void { + public function addWorldlineCustomerToken(array $data): void { + $sql = "INSERT INTO `" . DB_PREFIX . "worldline_customer_token` SET"; + + $implode = []; + + if (!empty($data['customer_id'])) { + $implode[] .= "`customer_id` = '" . (int)$data['customer_id'] . "'"; + } + + if (!empty($data['payment_type'])) { + $implode[] .= "`payment_type` = '" . $this->db->escape($data['payment_type']) . "'"; + } + + if (!empty($data['token'])) { + $implode[] .= "`token` = '" . $this->db->escape($data['token']) . "'"; + } + + if ($implode) { + $sql .= implode(", ", $implode); + } + + $this->db->query($sql); + } + + public function deleteWorldlineCustomerTokens(int $customer_id): void { + $query = $this->db->query("DELETE FROM `" . DB_PREFIX . "worldline_customer` WHERE `customer_id` = '" . (int)$customer_id . "'"); + } + + public function setWorldlineCustomerMainToken(int $customer_id, string $payment_type, string $token): void { + $this->db->query("UPDATE `" . DB_PREFIX . "worldline_customer_token` SET `main_token_status` = '0' WHERE `customer_id` = '" . (int)$customer_id . "' AND `payment_type` = '" . $this->db->escape($payment_type) . "'"); + $this->db->query("UPDATE `" . DB_PREFIX . "worldline_customer_token` SET `main_token_status` = '1' WHERE `customer_id` = '" . (int)$customer_id . "' AND `payment_type` = '" . $this->db->escape($payment_type) . "' AND `token` = '" . $this->db->escape($token) . "'"); + } + + public function getWorldlineCustomerToken(int $customer_id, string $payment_type, string $token): array { + $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "worldline_customer_token` WHERE `customer_id` = '" . (int)$customer_id . "' AND `payment_type` = '" . $this->db->escape($payment_type) . "' AND `token` = '" . $this->db->escape($token) . "'"); + + if ($query->num_rows) { + return $query->row; + } else { + return []; + } + } + + public function getWorldlineCustomerTokens(int $customer_id): array { + $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "worldline_customer_token` WHERE `customer_id` = '" . (int)$customer_id . "'"); + + if ($query->num_rows) { + return $query->rows; + } else { + return []; + } + } + + public function editWorldlineOrder(array $data): void { $sql = "UPDATE `" . DB_PREFIX . "worldline_order` SET"; $implode = []; @@ -19,6 +72,14 @@ public function updateOrder(array $data): void { $implode[] .= "`payment_product` = '" . $this->db->escape($data['payment_product']) . "'"; } + if (!empty($data['payment_type'])) { + $implode[] .= "`payment_type` = '" . $this->db->escape($data['payment_type']) . "'"; + } + + if (!empty($data['token'])) { + $implode[] .= "`token` = '" . $this->db->escape($data['token']) . "'"; + } + if (!empty($data['total'])) { $implode[] .= "`total` = '" . (float)$data['total'] . "'"; } @@ -50,11 +111,11 @@ public function updateOrder(array $data): void { $this->db->query($sql); } - public function deleteOrder(int $order_id): void { + public function deleteWorldlineOrder(int $order_id): void { $query = $this->db->query("DELETE FROM `" . DB_PREFIX . "worldline_order` WHERE `order_id` = '" . (int)$order_id . "'"); } - public function getOrder(int $order_id): array { + public function getWorldlineOrder(int $order_id): array { $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "worldline_order` WHERE `order_id` = '" . (int)$order_id . "'"); if ($query->num_rows) { @@ -64,8 +125,8 @@ public function getOrder(int $order_id): array { } } - public function getOrders(array $data = []): array { - $sql = "SELECT wo.order_id, wo.transaction_id, wo.transaction_status, wo.payment_product, wo.total, wo.amount, wo.currency_code, wo.date, wo.environment FROM `" . DB_PREFIX . "worldline_order` wo"; + public function getWorldlineOrders(array $data = []): array { + $sql = "SELECT wo.order_id, wo.transaction_id, wo.transaction_status, wo.payment_product, wo.payment_type, wo.token, wo.total, wo.amount, wo.currency_code, wo.date, wo.environment FROM `" . DB_PREFIX . "worldline_order` wo"; $implode = []; @@ -85,6 +146,14 @@ public function getOrders(array $data = []): array { $implode[] .= "wo.payment_product LIKE '%" . $this->db->escape($data['filter_payment_product']) . "%'"; } + if (isset($data['filter_payment_type'])) { + $implode[] .= "wo.payment_type = '" . $this->db->escape($data['filter_payment_type']) . "'"; + } + + if (isset($data['filter_token'])) { + $implode[] .= "wo.token = '" . $this->db->escape($data['filter_token']) . "'"; + } + if (!empty($data['filter_total'])) { $implode[] = "wo.total = '" . (float)$data['filter_total'] . "'"; } @@ -119,6 +188,8 @@ public function getOrders(array $data = []): array { 'wo.transaction_id', 'wo.transaction_status', 'wo.payment_product', + 'wo.payment_type', + 'wo.token', 'wo.total', 'wo.amount', 'wo.currency_code', @@ -155,7 +226,7 @@ public function getOrders(array $data = []): array { return $query->rows; } - public function getTotalOrders(array $data = []): int { + public function getTotalWorldlineOrders(array $data = []): int { $sql = "SELECT COUNT(DISTINCT order_id) AS total FROM `" . DB_PREFIX . "worldline_order` wo"; $implode = []; @@ -176,6 +247,14 @@ public function getTotalOrders(array $data = []): int { $implode[] .= "wo.payment_product LIKE '%" . $this->db->escape($data['filter_payment_product']) . "%'"; } + if (isset($data['filter_payment_type'])) { + $implode[] .= "wo.payment_type = '" . $this->db->escape($data['filter_payment_type']) . "'"; + } + + if (isset($data['filter_token'])) { + $implode[] .= "wo.token = '" . $this->db->escape($data['filter_token']) . "'"; + } + if (!empty($data['filter_total'])) { $implode[] = "wo.total = '" . (float)$data['filter_total'] . "'"; } @@ -206,9 +285,9 @@ public function getTotalOrders(array $data = []): int { $query = $this->db->query($sql); - return (int)$query->row['total']; + return $query->row['total']; } - + public function addHistory(int $order_id, int $order_status_id, string $comment = '', bool $notify = false, bool $override = false): void { $this->db->query("UPDATE `" . DB_PREFIX . "order` SET order_status_id = '" . (int)$order_status_id . "', date_modified = NOW() WHERE order_id = '" . (int)$order_id . "'"); $this->db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int)$order_id . "', order_status_id = '" . (int)$order_status_id . "', notify = '" . (int)$notify . "', comment = '" . $this->db->escape($comment) . "', date_added = NOW()"); @@ -287,10 +366,12 @@ public function log(string|array $data, string $title = ''): void { } public function install(): void { - $this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "worldline_order` (`order_id` INT(11) NOT NULL, `transaction_id` VARCHAR(20) NOT NULL, `transaction_status` VARCHAR(20) NULL, `payment_product` VARCHAR(40) NULL, `total` DECIMAL(15,2) NULL, `amount` DECIMAL(15,2) NULL, `currency_code` VARCHAR(3) NULL, `country_code` VARCHAR(2) NULL, `environment` VARCHAR(20) NULL, `date` DATETIME NULL, PRIMARY KEY (`order_id`, `transaction_id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci"); + $this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "worldline_customer_token` (`customer_id` INT(11) NOT NULL, `payment_type` VARCHAR(20) NOT NULL, `token` VARCHAR(50) NOT NULL, `main_token_status` TINYINT(1) NOT NULL, PRIMARY KEY (`customer_id`, `payment_type`, `token`), KEY `main_token_status` (`main_token_status`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci"); + $this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "worldline_order` (`order_id` INT(11) NOT NULL, `transaction_id` VARCHAR(20) NOT NULL, `transaction_status` VARCHAR(20) NULL, `payment_product` VARCHAR(40) NULL, `payment_type` VARCHAR(20) NOT NULL, `token` VARCHAR(50), `total` DECIMAL(15,2) NULL, `amount` DECIMAL(15,2) NULL, `currency_code` VARCHAR(3) NULL, `country_code` VARCHAR(2) NULL, `environment` VARCHAR(20) NULL, `date` DATETIME NULL, PRIMARY KEY (`order_id`), KEY `transaction_id` (`transaction_id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci"); } public function uninstall(): void { + $this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "worldline_customer_token`"); $this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "worldline_order`"); } } diff --git a/admin/view/template/payment/account.twig b/admin/view/template/payment/account.twig index 61a9610..f301b47 100644 --- a/admin/view/template/payment/account.twig +++ b/admin/view/template/payment/account.twig @@ -73,7 +73,7 @@
- +
@@ -82,7 +82,7 @@
- +
@@ -104,7 +104,7 @@
- +
@@ -113,7 +113,7 @@
- +
diff --git a/admin/view/template/payment/advanced.twig b/admin/view/template/payment/advanced.twig index f9f577d..18bc042 100644 --- a/admin/view/template/payment/advanced.twig +++ b/admin/view/template/payment/advanced.twig @@ -87,15 +87,47 @@
- +
- + {% if setting['advanced']['forced_tokenization'] %} + + + {% else %} + + + {% endif %} + +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ @@ -103,21 +135,29 @@
- +
- + {% for tds_exemption_request in setting['tds_exemption_request'] %} + {% if tds_exemption_request['code'] == setting['advanced']['tds_exemption_request'] %} + {% else %} - + {% endif %} {% endfor %}
+
+ +
+
+ +
+
+
diff --git a/catalog/controller/payment/worldline.php b/catalog/controller/payment/worldline.php index 9b8ec19..6128226 100644 --- a/catalog/controller/payment/worldline.php +++ b/catalog/controller/payment/worldline.php @@ -66,8 +66,6 @@ public function confirm(): void { $api_secret = $setting['account']['api_secret'][$environment]; $api_endpoint = $setting['account']['api_endpoint'][$environment]; $authorization_mode = strtoupper($setting['advanced']['authorization_mode']); - $challenge_indicator = $setting['advanced']['challenge_indicator']; - $exemption_request = $setting['advanced']['exemption_request']; $language_code = explode('-', $this->config->get('config_language')); $language_code = strtoupper(reset($language_code)); @@ -275,6 +273,16 @@ public function confirm(): void { $item_total += $shipping_total; } + $tokens = []; + + if ($this->customer->isLogged()) { + $worldline_customer_tokens = $this->model_extension_worldline_payment_worldline->getWorldlineCustomerTokens($this->customer->getId()); + + foreach ($worldline_customer_tokens as $worldline_customer_token) { + $tokens[] = $worldline_customer_token['token']; + } + } + $order_references = new \OnlinePayments\Sdk\Domain\OrderReferences(); $order_references->setMerchantReference($order_info['order_id'] . '_' . date('Ymd_His')); @@ -297,9 +305,20 @@ public function confirm(): void { $card_payment_method_specific_input = new \OnlinePayments\Sdk\Domain\CardPaymentMethodSpecificInput(); $card_payment_method_specific_input->setAuthorizationMode($authorization_mode); - $card_payment_method_specific_input->setSkipAuthentication(false); - $card_payment_method_specific_input->setThreeDSecure($three_d_secure); $card_payment_method_specific_input->setTransactionChannel('ECOMMERCE'); + + if ($setting['advanced']['tds_status']) { + $card_payment_method_specific_input->setSkipAuthentication(false); + $card_payment_method_specific_input->setThreeDSecure($three_d_secure); + } else { + $card_payment_method_specific_input->setSkipAuthentication(true); + } + + if ($setting['advanced']['forced_tokenization']) { + $card_payment_method_specific_input->setTokenize(true); + } else { + $card_payment_method_specific_input->setTokenize(false); + } $redirect_payment_method_specific_input = new \OnlinePayments\Sdk\Domain\RedirectPaymentMethodSpecificInput(); @@ -308,6 +327,12 @@ public function confirm(): void { } else { $redirect_payment_method_specific_input->setRequiresApproval(true); } + + if ($this->customer->isLogged() && $setting['advanced']['forced_tokenization']) { + $redirect_payment_method_specific_input->setTokenize(true); + } else { + $redirect_payment_method_specific_input->setTokenize(false); + } $mobile_payment_method_specific_input = new \OnlinePayments\Sdk\Domain\MobilePaymentMethodSpecificInput(); $mobile_payment_method_specific_input->setAuthorizationMode($authorization_mode); @@ -319,6 +344,14 @@ public function confirm(): void { $hosted_checkout_specific_input->setLocale($language_code . '-' . strtoupper($language_code)); $hosted_checkout_specific_input->setReturnUrl(str_replace('&', '&', $this->url->link('extension/worldline/payment/worldline' . $this->separator . 'callback', 'language=' . $this->config->get('config_language')))); $hosted_checkout_specific_input->setCardPaymentMethodSpecificInput($card_payment_method_specific_input_for_hosted_checkout); + + if ($setting['advanced']['template']) { + $hosted_checkout_specific_input->setVariant($setting['advanced']['template']); + } + + if ($tokens) { + $hosted_checkout_specific_input->setTokens(implode(',', $tokens)); + } $create_hosted_checkout_request = new \OnlinePayments\Sdk\Domain\CreateHostedCheckoutRequest(); $create_hosted_checkout_request->setOrder($order); @@ -355,9 +388,9 @@ public function confirm(): void { $hosted_checkout_id = $create_hosted_checkout_response->getHostedCheckoutId(); $hosted_checkout_url = $create_hosted_checkout_response->getRedirectUrl(); - $this->model_extension_worldline_payment_worldline->deleteOrder($order_id); + $this->model_extension_worldline_payment_worldline->deleteWorldlineOrder($order_id); - $worldline_data = [ + $worldline_order_data = [ 'order_id' => $order_id, 'transaction_id' => $hosted_checkout_id, 'total' => ($order_info['total'] * $currency_value), @@ -366,7 +399,7 @@ public function confirm(): void { 'environment' => $environment ]; - $this->model_extension_worldline_payment_worldline->createOrder($worldline_data); + $this->model_extension_worldline_payment_worldline->addWorldlineOrder($worldline_order_data); $data['redirect'] = $hosted_checkout_url; } @@ -429,9 +462,13 @@ public function callback(): bool { $currency_code = $hosted_checkout_response->getCreatedPaymentOutput()->getPayment()->getPaymentOutput()->getAmountOfMoney()->getCurrencyCode(); $payment_product_id = ''; + $payment_type = ''; + $token = ''; if (!empty($hosted_checkout_response->getCreatedPaymentOutput()->getPayment()->getPaymentOutput()->getCardPaymentMethodSpecificOutput())) { $payment_product_id = $hosted_checkout_response->getCreatedPaymentOutput()->getPayment()->getPaymentOutput()->getCardPaymentMethodSpecificOutput()->getPaymentProductId(); + $token = $hosted_checkout_response->getCreatedPaymentOutput()->getPayment()->getPaymentOutput()->getCardPaymentMethodSpecificOutput()->getToken(); + $payment_type = 'card'; } if (!empty($hosted_checkout_response->getCreatedPaymentOutput()->getPayment()->getPaymentOutput()->getMobilePaymentMethodSpecificOutput())) { @@ -440,6 +477,8 @@ public function callback(): bool { if (!empty($hosted_checkout_response->getCreatedPaymentOutput()->getPayment()->getPaymentOutput()->getRedirectPaymentMethodSpecificOutput())) { $payment_product_id = $hosted_checkout_response->getCreatedPaymentOutput()->getPayment()->getPaymentOutput()->getRedirectPaymentMethodSpecificOutput()->getPaymentProductId(); + $token = $hosted_checkout_response->getCreatedPaymentOutput()->getPayment()->getPaymentOutput()->getRedirectPaymentMethodSpecificOutput()->getToken(); + $payment_type = 'redirect'; } if (!empty($hosted_checkout_response->getCreatedPaymentOutput()->getPayment()->getPaymentOutput()->getSepaDirectDebitPaymentMethodSpecificOutput())) { @@ -451,7 +490,7 @@ public function callback(): bool { $this->load->model('extension/worldline/payment/worldline'); - $worldline_order_info = $this->model_extension_worldline_payment_worldline->getOrder($order_id); + $worldline_order_info = $this->model_extension_worldline_payment_worldline->getWorldlineOrder($order_id); if ($worldline_order_info) { $order_status_id = 0; @@ -521,16 +560,36 @@ public function callback(): bool { } } - $worldline_data = [ + $worldline_order_data = [ 'order_id' => $order_id, 'transaction_status' => $transaction_status, 'payment_product' => $payment_product, + 'payment_type' => $payment_type, + 'token' => $token, 'total' => $total, 'amount' => $amount, 'currency_code' => $currency_code ]; - $this->model_extension_worldline_payment_worldline->updateOrder($worldline_data); + $this->model_extension_worldline_payment_worldline->editWorldlineOrder($worldline_order_data); + + if ($this->customer->isLogged() && $token) { + $customer_id = $this->customer->getId(); + + $worldline_customer_token_info = $this->model_extension_worldline_payment_worldline->getWorldlineCustomerToken($customer_id, $payment_type, $token); + + if (!$worldline_customer_token_info) { + $worldline_customer_token_data = [ + 'customer_id' => $customer_id, + 'payment_type' => $payment_type, + 'token' => $token + ]; + + $this->model_extension_worldline_payment_worldline->addWorldlineCustomerToken($worldline_customer_token_data); + } + + $this->model_extension_worldline_payment_worldline->setWorldlineCustomerMainToken($customer_id, $payment_type, $token); + } } if (($transaction_status == 'pending_capture') || ($transaction_status == 'captured')) { @@ -660,7 +719,7 @@ public function failurePage(): void { $this->load->model('extension/worldline/payment/worldline'); - $worldline_order_info = $this->model_extension_worldline_payment_worldline->getOrder($order_id); + $worldline_order_info = $this->model_extension_worldline_payment_worldline->getWorldlineOrder($order_id); if ($worldline_order_info) { $transaction_id = $worldline_order_info['transaction_id']; @@ -690,7 +749,7 @@ public function getPaymentInfo(): void { $this->load->model('extension/worldline/payment/worldline'); - $worldline_order_info = $this->model_extension_worldline_payment_worldline->getOrder($order_id); + $worldline_order_info = $this->model_extension_worldline_payment_worldline->getWorldlineOrder($order_id); if ($worldline_order_info) { $transaction_id = $worldline_order_info['transaction_id']; @@ -759,9 +818,13 @@ public function getPaymentInfo(): void { $currency_code = $payment_response->getPaymentOutput()->getAmountOfMoney()->getCurrencyCode(); $payment_product_id = ''; + $payment_type = ''; + $token = ''; if (!empty($payment_response->getPaymentOutput()->getCardPaymentMethodSpecificOutput())) { $payment_product_id = $payment_response->getPaymentOutput()->getCardPaymentMethodSpecificOutput()->getPaymentProductId(); + $token = $payment_response->getPaymentOutput()->getCardPaymentMethodSpecificOutput()->getToken(); + $payment_type = 'card'; } if (!empty($payment_response->getPaymentOutput()->getMobilePaymentMethodSpecificOutput())) { @@ -770,6 +833,8 @@ public function getPaymentInfo(): void { if (!empty($payment_response->getPaymentOutput()->getRedirectPaymentMethodSpecificOutput())) { $payment_product_id = $payment_response->getPaymentOutput()->getRedirectPaymentMethodSpecificOutput()->getPaymentProductId(); + $token = $payment_response->getPaymentOutput()->getRedirectPaymentMethodSpecificOutput()->getToken(); + $payment_type = 'redirect'; } if (!empty($payment_response->getPaymentOutput()->getSepaDirectDebitPaymentMethodSpecificOutput())) { @@ -843,16 +908,36 @@ public function getPaymentInfo(): void { } } - $worldline_data = [ + $worldline_order_data = [ 'order_id' => $order_id, 'transaction_status' => $transaction_status, 'payment_product' => $payment_product, + 'payment_type' => $payment_type, + 'token' => $token, 'total' => $total, 'amount' => $amount, 'currency_code' => $currency_code ]; - - $this->model_extension_worldline_payment_worldline->updateOrder($worldline_data); + + $this->model_extension_worldline_payment_worldline->editWorldlineOrder($worldline_order_data); + + if ($this->customer->isLogged() && $token) { + $customer_id = $this->customer->getId(); + + $worldline_customer_token_info = $this->model_extension_worldline_payment_worldline->getWorldlineCustomerToken($customer_id, $payment_type, $token); + + if (!$worldline_customer_token_info) { + $worldline_customer_token_data = [ + 'customer_id' => $customer_id, + 'payment_type' => $payment_type, + 'token' => $token + ]; + + $this->model_extension_worldline_payment_worldline->addWorldlineCustomerToken($worldline_customer_token_data); + } + + $this->model_extension_worldline_payment_worldline->setWorldlineCustomerMainToken($customer_id, $payment_type, $token); + } } if (($transaction_status == 'pending_capture') || ($transaction_status == 'captured')) { @@ -893,6 +978,7 @@ public function webhook(): bool { $this->load->language('extension/worldline/payment/worldline'); $this->load->model('extension/worldline/payment/worldline'); + $this->load->model('checkout/order'); $this->model_extension_worldline_payment_worldline->log($webhook_info, 'Webhook'); @@ -954,9 +1040,13 @@ public function webhook(): bool { $currency_code = $payment_response->getPaymentOutput()->getAmountOfMoney()->getCurrencyCode(); $payment_product_id = ''; + $payment_type = ''; + $token = ''; if (!empty($payment_response->getPaymentOutput()->getCardPaymentMethodSpecificOutput())) { $payment_product_id = $payment_response->getPaymentOutput()->getCardPaymentMethodSpecificOutput()->getPaymentProductId(); + $token = $payment_response->getPaymentOutput()->getCardPaymentMethodSpecificOutput()->getToken(); + $payment_type = 'card'; } if (!empty($payment_response->getPaymentOutput()->getMobilePaymentMethodSpecificOutput())) { @@ -965,6 +1055,8 @@ public function webhook(): bool { if (!empty($payment_response->getPaymentOutput()->getRedirectPaymentMethodSpecificOutput())) { $payment_product_id = $payment_response->getPaymentOutput()->getRedirectPaymentMethodSpecificOutput()->getPaymentProductId(); + $token = $payment_response->getPaymentOutput()->getRedirectPaymentMethodSpecificOutput()->getToken(); + $payment_type = 'redirect'; } if (!empty($payment_response->getPaymentOutput()->getSepaDirectDebitPaymentMethodSpecificOutput())) { @@ -977,9 +1069,10 @@ public function webhook(): bool { $payment_id = explode('_', $webhook_info['payment']['id']); $transaction_id = reset($payment_id); - $worldline_order_info = $this->model_extension_worldline_payment_worldline->getOrder($order_id); + $worldline_order_info = $this->model_extension_worldline_payment_worldline->getWorldlineOrder($order_id); + $order_info = $this->model_checkout_order->getOrder($order_id); - if ($worldline_order_info && ($worldline_order_info['transaction_id'] == $transaction_id)) { + if ($worldline_order_info && ($worldline_order_info['transaction_id'] == $transaction_id) && $order_info) { $order_status_id = 0; if ($transaction_status == 'created') { @@ -1006,14 +1099,8 @@ public function webhook(): bool { $order_status_id = $setting['order_status']['refunded']['id']; } - if ($order_status_id) { - $this->load->model('checkout/order'); - - $order_info = $this->model_checkout_order->getOrder($order_id); - - if ($order_info && ($order_info['order_status_id'] != $order_status_id)) { - $this->model_checkout_order->addHistory($order_id, $order_status_id, '', true); - } + if ($order_status_id && ($order_info['order_status_id'] != $order_status_id)) { + $this->model_checkout_order->addHistory($order_id, $order_status_id, '', true); } if (($transaction_status == 'created') || ($transaction_status == 'pending_capture') || ($transaction_status == 'captured') || ($transaction_status == 'cancelled') || ($transaction_status == 'rejected') || ($transaction_status == 'rejected_capture') || ($transaction_status == 'refunded') || ($transaction_status == 'authorization_requested') || ($transaction_status == 'capture_requested') || ($transaction_status == 'refund_requested')) { @@ -1047,16 +1134,36 @@ public function webhook(): bool { } } - $worldline_data = [ + $worldline_order_data = [ 'order_id' => $order_id, 'transaction_status' => $transaction_status, 'payment_product' => $payment_product, + 'payment_type' => $payment_type, + 'token' => $token, 'total' => $total, 'amount' => $amount, 'currency_code' => $currency_code ]; - $this->model_extension_worldline_payment_worldline->updateOrder($worldline_data); + $this->model_extension_worldline_payment_worldline->editWorldlineOrder($worldline_order_data); + + if (!empty($order_info['customer_id']) && $token) { + $customer_id = $order_info['customer_id']; + + $worldline_customer_token_info = $this->model_extension_worldline_payment_worldline->getWorldlineCustomerToken($customer_id, $payment_type, $token); + + if (!$worldline_customer_token_info) { + $worldline_customer_token_data = [ + 'customer_id' => $customer_id, + 'payment_type' => $payment_type, + 'token' => $token + ]; + + $this->model_extension_worldline_payment_worldline->addWorldlineCustomerToken($worldline_customer_token_data); + } + + $this->model_extension_worldline_payment_worldline->setWorldlineCustomerMainToken($customer_id, $payment_type, $token); + } } } } @@ -1082,10 +1189,11 @@ public function cron(): bool { if (hash_equals($setting['account']['cron_token'], $this->request->get['cron_token'])) { $this->load->model('extension/worldline/payment/worldline'); + $this->load->model('checkout/order'); - $waiting_orders = $this->model_extension_worldline_payment_worldline->getWaitingOrders(); + $waiting_worldline_orders = $this->model_extension_worldline_payment_worldline->getWaitingWorldlineOrders(); - if ($waiting_orders) { + if ($waiting_worldline_orders) { $environment = $setting['account']['environment']; $merchant_id = $setting['account']['merchant_id'][$environment]; $api_key = $setting['account']['api_key'][$environment]; @@ -1103,9 +1211,11 @@ public function cron(): bool { $client = new \OnlinePayments\Sdk\Client($communicator); - foreach ($waiting_orders as $waiting_order) { - $order_id = $waiting_order['order_id']; - $transaction_id = $waiting_order['transaction_id']; + foreach ($waiting_worldline_orders as $waiting_worldline_order) { + $order_id = $waiting_worldline_order['order_id']; + $transaction_id = $waiting_worldline_order['transaction_id']; + + $order_info = $this->model_checkout_order->getOrder($order_id); $errors = []; @@ -1121,16 +1231,20 @@ public function cron(): bool { } } - if (!$errors) { + if ($order_info && !$errors) { $transaction_status = strtolower($payment_response->getStatus()); $total = $payment_response->getPaymentOutput()->getAmountOfMoney()->getAmount() / 100; $amount = $payment_response->getPaymentOutput()->getAcquiredAmount()->getAmount() / 100; $currency_code = $payment_response->getPaymentOutput()->getAmountOfMoney()->getCurrencyCode(); $payment_product_id = ''; + $payment_type = ''; + $token = ''; if (!empty($payment_response->getPaymentOutput()->getCardPaymentMethodSpecificOutput())) { $payment_product_id = $payment_response->getPaymentOutput()->getCardPaymentMethodSpecificOutput()->getPaymentProductId(); + $token = $payment_response->getPaymentOutput()->getCardPaymentMethodSpecificOutput()->getToken(); + $payment_type = 'card'; } if (!empty($payment_response->getPaymentOutput()->getMobilePaymentMethodSpecificOutput())) { @@ -1139,6 +1253,8 @@ public function cron(): bool { if (!empty($payment_response->getPaymentOutput()->getRedirectPaymentMethodSpecificOutput())) { $payment_product_id = $payment_response->getPaymentOutput()->getRedirectPaymentMethodSpecificOutput()->getPaymentProductId(); + $token = $payment_response->getPaymentOutput()->getRedirectPaymentMethodSpecificOutput()->getToken(); + $payment_type = 'redirect'; } if (!empty($payment_response->getPaymentOutput()->getSepaDirectDebitPaymentMethodSpecificOutput())) { @@ -1170,24 +1286,18 @@ public function cron(): bool { if ($transaction_status == 'refunded') { $order_status_id = $setting['order_status']['refunded']['id']; } - - if ($order_status_id) { - $this->load->model('checkout/order'); - $order_info = $this->model_checkout_order->getOrder($order_id); - - if ($order_info && ($order_info['order_status_id'] != $order_status_id)) { - $this->model_checkout_order->addHistory($order_id, $order_status_id, '', true); - } + if ($order_status_id && ($order_info['order_status_id'] != $order_status_id)) { + $this->model_checkout_order->addHistory($order_id, $order_status_id, '', true); } if (($transaction_status == 'created') || ($transaction_status == 'pending_capture') || ($transaction_status == 'captured') || ($transaction_status == 'cancelled') || ($transaction_status == 'rejected') || ($transaction_status == 'rejected_capture') || ($transaction_status == 'refunded') || ($transaction_status == 'authorization_requested') || ($transaction_status == 'capture_requested') || ($transaction_status == 'refund_requested')) { - $payment_product = $waiting_order['payment_product']; + $payment_product = $waiting_worldline_order['payment_product']; - if (!$waiting_order['transaction_status']) { + if (!$waiting_worldline_order['transaction_status']) { $payment_product_params = new \OnlinePayments\Sdk\Merchant\Products\GetPaymentProductParams(); $payment_product_params->setCurrencyCode($currency_code); - $payment_product_params->setCountryCode($waiting_order['country_code']); + $payment_product_params->setCountryCode($waiting_worldline_order['country_code']); try { $payment_product_response = $client->merchant($merchant_id)->products()->getPaymentProduct($payment_product_id, $payment_product_params); @@ -1212,16 +1322,36 @@ public function cron(): bool { } } - $worldline_data = [ + $worldline_order_data = [ 'order_id' => $order_id, 'transaction_status' => $transaction_status, 'payment_product' => $payment_product, + 'payment_type' => $payment_type, + 'token' => $token, 'total' => $total, 'amount' => $amount, 'currency_code' => $currency_code ]; - $this->model_extension_worldline_payment_worldline->updateOrder($worldline_data); + $this->model_extension_worldline_payment_worldline->editWorldlineOrder($worldline_order_data); + + if (!empty($order_info['customer_id']) && $token) { + $customer_id = $order_info['customer_id']; + + $worldline_customer_token_info = $this->model_extension_worldline_payment_worldline->getWorldlineCustomerToken($customer_id, $payment_type, $token); + + if (!$worldline_customer_token_info) { + $worldline_customer_token_data = [ + 'customer_id' => $customer_id, + 'payment_type' => $payment_type, + 'token' => $token + ]; + + $this->model_extension_worldline_payment_worldline->addWorldlineCustomerToken($worldline_customer_token_data); + } + + $this->model_extension_worldline_payment_worldline->setWorldlineCustomerMainToken($customer_id, $payment_type, $token); + } } } } @@ -1239,7 +1369,7 @@ public function order_delete_order_before(string $route, array $data): void { $order_id = $data[0]; - $this->model_extension_worldline_payment_worldline->deleteOrder($order_id); + $this->model_extension_worldline_payment_worldline->deleteWorldlineOrder($order_id); } private function getallheaders() { diff --git a/catalog/model/payment/worldline.php b/catalog/model/payment/worldline.php index 725b1ef..7838045 100644 --- a/catalog/model/payment/worldline.php +++ b/catalog/model/payment/worldline.php @@ -101,7 +101,56 @@ public function getMethods(array $address = []): array { return $method_data; } - public function createOrder(array $data): void { + public function addWorldlineCustomerToken(array $data): void { + $sql = "INSERT INTO `" . DB_PREFIX . "worldline_customer_token` SET"; + + $implode = []; + + if (!empty($data['customer_id'])) { + $implode[] .= "`customer_id` = '" . (int)$data['customer_id'] . "'"; + } + + if (!empty($data['payment_type'])) { + $implode[] .= "`payment_type` = '" . $this->db->escape($data['payment_type']) . "'"; + } + + if (!empty($data['token'])) { + $implode[] .= "`token` = '" . $this->db->escape($data['token']) . "'"; + } + + if ($implode) { + $sql .= implode(", ", $implode); + } + + $this->db->query($sql); + } + + public function setWorldlineCustomerMainToken(int $customer_id, string $payment_type, string $token): void { + $this->db->query("UPDATE `" . DB_PREFIX . "worldline_customer_token` SET `main_token_status` = '0' WHERE `customer_id` = '" . (int)$customer_id . "' AND `payment_type` = '" . $this->db->escape($payment_type) . "'"); + $this->db->query("UPDATE `" . DB_PREFIX . "worldline_customer_token` SET `main_token_status` = '1' WHERE `customer_id` = '" . (int)$customer_id . "' AND `payment_type` = '" . $this->db->escape($payment_type) . "' AND `token` = '" . $this->db->escape($token) . "'"); + } + + public function getWorldlineCustomerToken(int $customer_id, string $payment_type, string $token): array { + $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "worldline_customer_token` WHERE `customer_id` = '" . (int)$customer_id . "' AND `payment_type` = '" . $this->db->escape($payment_type) . "' AND `token` = '" . $this->db->escape($token) . "'"); + + if ($query->num_rows) { + return $query->row; + } else { + return []; + } + } + + public function getWorldlineCustomerTokens(int $customer_id): array { + $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "worldline_customer_token` WHERE `customer_id` = '" . (int)$customer_id . "'"); + + if ($query->num_rows) { + return $query->rows; + } else { + return []; + } + } + + public function addWorldlineOrder(array $data): void { $sql = "INSERT INTO `" . DB_PREFIX . "worldline_order` SET"; $implode = []; @@ -122,6 +171,14 @@ public function createOrder(array $data): void { $implode[] .= "`payment_product` = '" . $this->db->escape($data['payment_product']) . "'"; } + if (!empty($data['payment_type'])) { + $implode[] .= "`payment_type` = '" . $this->db->escape($data['payment_type']) . "'"; + } + + if (!empty($data['token'])) { + $implode[] .= "`token` = '" . $this->db->escape($data['token']) . "'"; + } + if (!empty($data['total'])) { $implode[] .= "`total` = '" . (float)$data['total'] . "'"; } @@ -146,6 +203,10 @@ public function createOrder(array $data): void { $implode[] .= "`environment` = '" . $this->db->escape($data['environment']) . "'"; } + if (!empty($data['token'])) { + $implode[] .= "`token` = '" . $this->db->escape($data['token']) . "'"; + } + if ($implode) { $sql .= implode(", ", $implode); } @@ -153,7 +214,7 @@ public function createOrder(array $data): void { $this->db->query($sql); } - public function updateOrder(array $data): void { + public function editWorldlineOrder(array $data): void { $sql = "UPDATE `" . DB_PREFIX . "worldline_order` SET"; $implode = []; @@ -170,6 +231,14 @@ public function updateOrder(array $data): void { $implode[] .= "`payment_product` = '" . $this->db->escape($data['payment_product']) . "'"; } + if (!empty($data['payment_type'])) { + $implode[] .= "`payment_type` = '" . $this->db->escape($data['payment_type']) . "'"; + } + + if (!empty($data['token'])) { + $implode[] .= "`token` = '" . $this->db->escape($data['token']) . "'"; + } + if (!empty($data['total'])) { $implode[] .= "`total` = '" . (float)$data['total'] . "'"; } @@ -189,7 +258,7 @@ public function updateOrder(array $data): void { if (!empty($data['environment'])) { $implode[] .= "`environment` = '" . $this->db->escape($data['environment']) . "'"; } - + $implode[] .= "`date` = COALESCE(`date`, NOW())"; if ($implode) { @@ -201,11 +270,11 @@ public function updateOrder(array $data): void { $this->db->query($sql); } - public function deleteOrder(int $order_id): void { + public function deleteWorldlineOrder(int $order_id): void { $query = $this->db->query("DELETE FROM `" . DB_PREFIX . "worldline_order` WHERE `order_id` = '" . (int)$order_id . "'"); } - public function getOrder(int $order_id): array { + public function getWorldlineOrder(int $order_id): array { $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "worldline_order` WHERE `order_id` = '" . (int)$order_id . "'"); if ($query->num_rows) { @@ -215,7 +284,7 @@ public function getOrder(int $order_id): array { } } - public function getWaitingOrders(): array { + public function getWaitingWorldlineOrders(): array { $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "worldline_order` WHERE `transaction_status` = '' OR `transaction_status` = 'created' OR `transaction_status` = 'authorization_requested' OR `transaction_status` = 'capture_requested' OR `transaction_status` = 'refund_requested'"); return $query->rows; diff --git a/system/config/worldline.php b/system/config/worldline.php index 2a14da9..1948e3f 100644 --- a/system/config/worldline.php +++ b/system/config/worldline.php @@ -21,8 +21,11 @@ 'debug' => false, 'authorization_mode' => 'sale', 'group_cards' => true, - 'challenge_indicator' => 'challenge-required', - 'exemption_request' => 'low-value' + 'forced_tokenization' => true, + 'tds_secure_status' => true, + 'tds_challenge_indicator' => 'challenge-required', + 'tds_exemption_request' => 'low-value', + 'template' => '' ], 'order_status' => [ 'created' => [ @@ -88,7 +91,7 @@ 'name' => 'text_sale' ] ], - 'challenge_indicator' => [ + 'tds_challenge_indicator' => [ 'no-preference' => [ 'code' => 'no-preference', 'name' => 'text_no_preference' @@ -106,7 +109,7 @@ 'name' => 'text_challenge_required' ] ], - 'exemption_request' => [ + 'tds_exemption_request' => [ 'none' => [ 'code' => 'none', 'name' => 'text_exemption_none'