From f9825d93fb887ff2d6a7b60dcb5d54a9abb49573 Mon Sep 17 00:00:00 2001 From: Andreas Schempp Date: Mon, 25 Jul 2022 16:17:59 +0200 Subject: [PATCH 1/4] Implemented PayPal Checkout payment method --- system/modules/isotope/config/config.php | 1 + system/modules/isotope/dca/tl_iso_payment.php | 1 + .../modules/isotope/languages/en/default.xlf | 6 + .../Isotope/Model/Payment/PaypalApi.php | 110 ++++++++++++++++ .../Isotope/Model/Payment/PaypalCheckout.php | 124 ++++++++++++++++++ .../Isotope/Model/Payment/PaypalPlus.php | 108 --------------- .../payment/iso_payment_paypal_checkout.html5 | 22 ++++ 7 files changed, 264 insertions(+), 108 deletions(-) create mode 100644 system/modules/isotope/library/Isotope/Model/Payment/PaypalCheckout.php create mode 100644 system/modules/isotope/templates/payment/iso_payment_paypal_checkout.html5 diff --git a/system/modules/isotope/config/config.php b/system/modules/isotope/config/config.php index 1fb0713b5f..f7df350c24 100755 --- a/system/modules/isotope/config/config.php +++ b/system/modules/isotope/config/config.php @@ -194,6 +194,7 @@ \Isotope\Model\Payment::registerModelType('payone', 'Isotope\Model\Payment\Payone'); \Isotope\Model\Payment::registerModelType('paypal', 'Isotope\Model\Payment\Paypal'); \Isotope\Model\Payment::registerModelType('paypal_plus', 'Isotope\Model\Payment\PaypalPlus'); +\Isotope\Model\Payment::registerModelType('paypal_checkout', 'Isotope\Model\Payment\PaypalCheckout'); \Isotope\Model\Payment::registerModelType('postfinance', 'Isotope\Model\Payment\Postfinance'); \Isotope\Model\Payment::registerModelType('quickpay', 'Isotope\Model\Payment\QuickPay'); \Isotope\Model\Payment::registerModelType('saferpay', 'Isotope\Model\Payment\Saferpay'); diff --git a/system/modules/isotope/dca/tl_iso_payment.php b/system/modules/isotope/dca/tl_iso_payment.php index 7f106d3615..5393c683de 100644 --- a/system/modules/isotope/dca/tl_iso_payment.php +++ b/system/modules/isotope/dca/tl_iso_payment.php @@ -103,6 +103,7 @@ 'paybyway' => '{type_legend},name,label,type;{note_legend:hide},note;{config_legend},new_order_status,quantity_mode,minimum_quantity,maximum_quantity,minimum_total,maximum_total,countries,shipping_modules,product_types,product_types_condition,config_ids;{gateway_legend},paybyway_merchant_id,paybyway_private_key;{price_legend:hide},price,tax_class;{expert_legend:hide},guests,protected;{enabled_legend},enabled,debug,logging', 'paypal' => '{type_legend},name,label,type;{note_legend:hide},note;{config_legend},new_order_status,quantity_mode,minimum_quantity,maximum_quantity,minimum_total,maximum_total,countries,shipping_modules,product_types,product_types_condition,config_ids;{gateway_legend},paypal_account;{price_legend:hide},price,tax_class;{expert_legend:hide},guests,protected;{enabled_legend},enabled,debug,logging', 'paypal_plus' => '{type_legend},name,label,type;{note_legend:hide},note;{config_legend},new_order_status,quantity_mode,minimum_quantity,maximum_quantity,minimum_total,maximum_total,countries,shipping_modules,product_types,product_types_condition,config_ids;{gateway_legend},paypal_client,paypal_secret;{price_legend:hide},price,tax_class;{expert_legend:hide},guests,protected;{enabled_legend},enabled,debug,logging', + 'paypal_checkout' => '{type_legend},name,label,type;{note_legend:hide},note;{config_legend},new_order_status,quantity_mode,minimum_quantity,maximum_quantity,minimum_total,maximum_total,countries,shipping_modules,product_types,product_types_condition,config_ids;{gateway_legend},paypal_client,paypal_secret;{price_legend:hide},price,tax_class;{expert_legend:hide},guests,protected;{enabled_legend},enabled,debug,logging', 'postfinance' => '{type_legend},name,label,type;{note_legend:hide},note;{config_legend},new_order_status,quantity_mode,minimum_quantity,maximum_quantity,minimum_total,maximum_total,countries,shipping_modules,product_types,product_types_condition,config_ids;{gateway_legend},psp_pspid,psp_http_method,psp_hash_method,psp_hash_in,psp_hash_out,psp_dynamic_template,psp_payment_method;{price_legend:hide},price,tax_class;{expert_legend:hide},guests,protected;{enabled_legend},enabled,debug,logging', 'viveum' => '{type_legend},name,label,type;{note_legend:hide},note;{config_legend},new_order_status,quantity_mode,minimum_quantity,maximum_quantity,minimum_total,maximum_total,countries,shipping_modules,product_types,product_types_condition,config_ids;{gateway_legend},psp_pspid,psp_http_method,psp_hash_method,psp_hash_in,psp_hash_out,psp_dynamic_template,psp_payment_method;{price_legend:hide},price,tax_class;{expert_legend:hide},guests,protected;{enabled_legend},enabled,debug,logging', 'datatrans' => '{type_legend},name,label,type;{note_legend:hide},note;{config_legend},new_order_status,trans_type,quantity_mode,minimum_quantity,maximum_quantity,minimum_total,maximum_total,countries,shipping_modules,product_types,product_types_condition,config_ids;{gateway_legend},datatrans_id,datatrans_sign,datatrans_hash_method,datatrans_hash_convert;{price_legend:hide},price,tax_class;{expert_legend:hide},guests,protected;{enabled_legend},enabled,debug,logging', diff --git a/system/modules/isotope/languages/en/default.xlf b/system/modules/isotope/languages/en/default.xlf index d402b68d98..0b92eadc8d 100644 --- a/system/modules/isotope/languages/en/default.xlf +++ b/system/modules/isotope/languages/en/default.xlf @@ -710,6 +710,12 @@ Paypal PLUS is currently only available in Germany. + + PayPal Checkout + + + Checkout is the latest PayPal payment method. + PostFinance diff --git a/system/modules/isotope/library/Isotope/Model/Payment/PaypalApi.php b/system/modules/isotope/library/Isotope/Model/Payment/PaypalApi.php index 3f08446ff6..b9d2f1ebc0 100644 --- a/system/modules/isotope/library/Isotope/Model/Payment/PaypalApi.php +++ b/system/modules/isotope/library/Isotope/Model/Payment/PaypalApi.php @@ -1,5 +1,10 @@ save(); } + /** + * {@inheritdoc} + */ + public function backendInterface($orderId) + { + if (($objOrder = Order::findByPk($orderId)) === null) { + return parent::backendInterface($orderId); + } + + $arrPayment = StringUtil::deserialize($objOrder->payment_data, true); + + if (!\is_array($arrPayment['PAYPAL_HISTORY']) || empty($arrPayment['PAYPAL_HISTORY'])) { + return parent::backendInterface($orderId); + } + + $strBuffer = ' +
+' . $GLOBALS['TL_LANG']['MSC']['backBT'] . ' +
'; + + foreach ($arrPayment['PAYPAL_HISTORY'] as $response) { + if ($response['intent'] === 'sale' + && $response['state'] === 'approved' + && isset($response['transactions'][0]['related_resources'][0]['sale']['id']) + ) { + $saleId = $response['transactions'][0]['related_resources'][0]['sale']['id']; + + $strBuffer .= ' +
+

' . $this->name . ' (' . $GLOBALS['TL_LANG']['MODEL']['tl_iso_payment'][$this->type][0] . ')' . '

+
+

' . sprintf($GLOBALS['TL_LANG']['MSC']['paypalTransaction'], $saleId) . '

+

' . $GLOBALS['TL_LANG']['MSC']['paypalTransactionOnline'] .'

+' . $GLOBALS['TL_LANG']['MSC']['paypalTransactionButton'] . ' +
+
'; + + break; + } + } + + foreach (array_reverse($arrPayment['PAYPAL_HISTORY']) as $transaction) { + if (isset($transaction['create_time'])) { + $dateCreated = Date::parse( + $GLOBALS['TL_CONFIG']['datimFormat'], + strtotime($transaction['create_time']) + ); + } else { + $dateCreated = 'UNKNOWN'; + } + + $strBuffer .= ' +
+

' . sprintf($GLOBALS['TL_LANG']['MSC']['paypalTransactionDetails'], $dateCreated) . '

+ + +'; + + $render = function($k, $v, &$i) use (&$strBuffer) { + $strBuffer .= ' + + ' . $k . ': + ' . $v . ' + '; + + ++$i; + }; + + $loop = function($data, $loop, $i=0) use ($render, &$strBuffer) { + foreach ($data as $k => $v) { + if (\in_array($k, ['potential_payer_info', 'links', 'create_time'], true)) { + continue; + } + + if (\is_array($v)) { + $strBuffer .= ' + + ' . $k . ': + +
'; + + $i++; + $loop($v, $loop, (int) $i % 2); + + $strBuffer .= '
'; + + continue; + } + + $render($k, $v, $i); + } + }; + + $loop($transaction, $loop); + + $strBuffer .= ' + +
'; + } + + return $strBuffer; + } + /** * @return array|null */ diff --git a/system/modules/isotope/library/Isotope/Model/Payment/PaypalCheckout.php b/system/modules/isotope/library/Isotope/Model/Payment/PaypalCheckout.php new file mode 100644 index 0000000000..ebbc570748 --- /dev/null +++ b/system/modules/isotope/library/Isotope/Model/Payment/PaypalCheckout.php @@ -0,0 +1,124 @@ +currency, ['AUD', 'BRL', 'CAD', 'CZK', 'DKK', 'EUR', 'HKD', 'HUF', 'ILS', 'JPY', 'MYR', 'MXN', 'TWD', 'NZD', 'NOK', 'PHP', 'PLN', 'GBP', 'RUB', 'SGD', 'SEK', 'CHF', 'THB', 'USD'])) { + return false; + } + + return parent::isAvailable(); + } + + public function checkoutForm(IsotopeProductCollection $objOrder, \Module $objModule) + { + if (!$objOrder instanceof IsotopePurchasableCollection) { + System::log('Product collection ID "' . $objOrder->getId() . '" is not purchasable', __METHOD__, TL_ERROR); + Checkout::redirectToStep(Checkout::STEP_COMPLETE, $objOrder); + } + + try { + $response = $this->createPayment($objOrder); + } catch (TransportExceptionInterface $e) { + System::log('PayPayl payment failed. See paypal.log for more information.', __METHOD__, TL_ERROR); + Checkout::redirectToStep(Checkout::STEP_FAILED); + } + + $this->debugLog($response->getContent(false)); + + if (201 === $response->getStatusCode()) { + $paypalData = $response->toArray(); + $this->storePayment($objOrder, $paypalData); + $this->storeHistory($objOrder, $paypalData); + + $this->patchPayment($objOrder, $paypalData['id']); + + foreach ($paypalData['links'] as $link) { + if ('approval_url' === $link['rel']) { + $template = new Template('iso_payment_paypal_paypal'); + $template->setData($this->arrData); + + $template->client_id = $this->paypal_client; + $template->currency = $objOrder->getCurrency(); + + parse_str(parse_url($link['href'], PHP_URL_QUERY), $params); + $template->token = $params['token']; + + $successUrl = Checkout::generateUrlForStep(Checkout::STEP_COMPLETE, $objOrder, null, true); + $successUrl = Url::addQueryString('paymentID=__paymentID__', $successUrl); + $successUrl = Url::addQueryString('payerID=__payerID__', $successUrl); + $template->success_url = $successUrl; + + $template->cancel_url = Checkout::generateUrlForStep(Checkout::STEP_FAILED, null, null, true); + + return $template->parse(); + } + } + } + + return false; + } + + /** + * @inheritdoc + */ + public function processPayment(IsotopeProductCollection $objOrder, Module $objModule) + { + if (!$objOrder instanceof IsotopePurchasableCollection) { + System::log('Product collection ID "' . $objOrder->getId() . '" is not purchasable', __METHOD__, TL_ERROR); + return false; + } + + $paypalData = $this->retrievePayment($objOrder); + + if (0 === \count($paypalData) + || Input::get('paymentID') !== $paypalData['id'] + || 'created' !== $paypalData['state'] + ) { + return false; + } + + try { + $response = $this->executePayment($paypalData['id'], Input::get('payerID')); + } catch (TransportExceptionInterface $e) { + return false; + } + + $this->debugLog($response->getContent(false)); + + if (200 !== $response->getStatusCode()) { + return false; + } + + $this->storeHistory($objOrder, $response->toArray()); + + $objOrder->checkout(); + $objOrder->setDatePaid(time()); + $objOrder->updateOrderStatus($this->new_order_status); + $objOrder->save(); + + return true; + } +} diff --git a/system/modules/isotope/library/Isotope/Model/Payment/PaypalPlus.php b/system/modules/isotope/library/Isotope/Model/Payment/PaypalPlus.php index 6431468712..f335fe4714 100644 --- a/system/modules/isotope/library/Isotope/Model/Payment/PaypalPlus.php +++ b/system/modules/isotope/library/Isotope/Model/Payment/PaypalPlus.php @@ -11,19 +11,14 @@ namespace Isotope\Model\Payment; -use Contao\Date; -use Contao\Environment; use Contao\Input; use Contao\Module; -use Contao\StringUtil; use Contao\System; use Isotope\Interfaces\IsotopeProductCollection; use Isotope\Interfaces\IsotopePurchasableCollection; -use Isotope\Model\ProductCollection\Order; use Isotope\Module\Checkout; use Isotope\Template; use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; -use Symfony\Contracts\HttpClient\ResponseInterface; class PaypalPlus extends PaypalApi { @@ -66,109 +61,6 @@ public function checkoutForm(IsotopeProductCollection $objOrder, Module $objModu return false; } - /** - * {@inheritdoc} - */ - public function backendInterface($orderId) - { - if (($objOrder = Order::findByPk($orderId)) === null) { - return parent::backendInterface($orderId); - } - - $arrPayment = StringUtil::deserialize($objOrder->payment_data, true); - - if (!\is_array($arrPayment['PAYPAL_HISTORY']) || empty($arrPayment['PAYPAL_HISTORY'])) { - return parent::backendInterface($orderId); - } - - $strBuffer = ' -
-' . $GLOBALS['TL_LANG']['MSC']['backBT'] . ' -
'; - - foreach ($arrPayment['PAYPAL_HISTORY'] as $response) { - if ($response['intent'] === 'sale' - && $response['state'] === 'approved' - && isset($response['transactions'][0]['related_resources'][0]['sale']['id']) - ) { - $saleId = $response['transactions'][0]['related_resources'][0]['sale']['id']; - - $strBuffer .= ' -
-

' . $this->name . ' (' . $GLOBALS['TL_LANG']['MODEL']['tl_iso_payment'][$this->type][0] . ')' . '

-
-

' . sprintf($GLOBALS['TL_LANG']['MSC']['paypalTransaction'], $saleId) . '

-

' . $GLOBALS['TL_LANG']['MSC']['paypalTransactionOnline'] .'

-' . $GLOBALS['TL_LANG']['MSC']['paypalTransactionButton'] . ' -
-
'; - - break; - } - } - - foreach (array_reverse($arrPayment['PAYPAL_HISTORY']) as $transaction) { - if (isset($transaction['create_time'])) { - $dateCreated = Date::parse( - $GLOBALS['TL_CONFIG']['datimFormat'], - strtotime($transaction['create_time']) - ); - } else { - $dateCreated = 'UNKNOWN'; - } - - $strBuffer .= ' -
-

' . sprintf($GLOBALS['TL_LANG']['MSC']['paypalTransactionDetails'], $dateCreated) . '

- - -'; - - $render = function($k, $v, &$i) use (&$strBuffer) { - $strBuffer .= ' - - ' . $k . ': - ' . $v . ' - '; - - ++$i; - }; - - $loop = function($data, $loop, $i=0) use ($render, &$strBuffer) { - foreach ($data as $k => $v) { - if (\in_array($k, ['potential_payer_info', 'links', 'create_time'], true)) { - continue; - } - - if (\is_array($v)) { - $strBuffer .= ' - - ' . $k . ': - -
'; - - $i++; - $loop($v, $loop, (int) $i % 2); - - $strBuffer .= '
'; - - continue; - } - - $render($k, $v, $i); - } - }; - - $loop($transaction, $loop); - - $strBuffer .= ' - -
'; - } - - return $strBuffer; - } - /** * @inheritdoc */ diff --git a/system/modules/isotope/templates/payment/iso_payment_paypal_checkout.html5 b/system/modules/isotope/templates/payment/iso_payment_paypal_checkout.html5 new file mode 100644 index 0000000000..58af904f03 --- /dev/null +++ b/system/modules/isotope/templates/payment/iso_payment_paypal_checkout.html5 @@ -0,0 +1,22 @@ +
+ + From f2fdc89400a64b52115efb8fa7e4502d740c901a Mon Sep 17 00:00:00 2001 From: Oliver Willmes Date: Tue, 2 Aug 2022 11:42:15 +0200 Subject: [PATCH 2/4] fix isAvailable function and template name (#2344) --- .../isotope/library/Isotope/Model/Payment/PaypalCheckout.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/system/modules/isotope/library/Isotope/Model/Payment/PaypalCheckout.php b/system/modules/isotope/library/Isotope/Model/Payment/PaypalCheckout.php index ebbc570748..9a771f44ae 100644 --- a/system/modules/isotope/library/Isotope/Model/Payment/PaypalCheckout.php +++ b/system/modules/isotope/library/Isotope/Model/Payment/PaypalCheckout.php @@ -19,13 +19,14 @@ use Isotope\Interfaces\IsotopePurchasableCollection; use Isotope\Module\Checkout; use Isotope\Template; +use Isotope\Isotope; use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; class PaypalCheckout extends PaypalApi { public function isAvailable(): bool { - if (!in_array($this->currency, ['AUD', 'BRL', 'CAD', 'CZK', 'DKK', 'EUR', 'HKD', 'HUF', 'ILS', 'JPY', 'MYR', 'MXN', 'TWD', 'NZD', 'NOK', 'PHP', 'PLN', 'GBP', 'RUB', 'SGD', 'SEK', 'CHF', 'THB', 'USD'])) { + if (!in_array(Isotope::getConfig()->currency, ['AUD', 'BRL', 'CAD', 'CZK', 'DKK', 'EUR', 'HKD', 'HUF', 'ILS', 'JPY', 'MYR', 'MXN', 'TWD', 'NZD', 'NOK', 'PHP', 'PLN', 'GBP', 'RUB', 'SGD', 'SEK', 'CHF', 'THB', 'USD'])) { return false; } @@ -57,7 +58,7 @@ public function checkoutForm(IsotopeProductCollection $objOrder, \Module $objMod foreach ($paypalData['links'] as $link) { if ('approval_url' === $link['rel']) { - $template = new Template('iso_payment_paypal_paypal'); + $template = new Template('iso_payment_paypal_checkout'); $template->setData($this->arrData); $template->client_id = $this->paypal_client; From 4d30a1585c521c68155d6a09a8f6ded3d9b74720 Mon Sep 17 00:00:00 2001 From: Mathias Arzberger Date: Fri, 3 Feb 2023 05:53:16 +0100 Subject: [PATCH 3/4] add enable funding parameters feature --- system/modules/isotope/dca/tl_iso_payment.php | 14 ++++- .../isotope/languages/de/tl_iso_payment.xlf | 22 ++++++- .../isotope/languages/en/tl_iso_payment.xlf | 48 ++++++++++++++ .../isotope/languages/es/tl_iso_payment.xlf | 6 +- .../isotope/languages/fr/tl_iso_payment.xlf | 6 +- .../isotope/languages/it/tl_iso_payment.xlf | 6 +- .../Isotope/Model/Payment/PaypalCheckout.php | 62 +++++++++++++++++++ .../payment/iso_payment_paypal_checkout.html5 | 2 +- 8 files changed, 160 insertions(+), 6 deletions(-) diff --git a/system/modules/isotope/dca/tl_iso_payment.php b/system/modules/isotope/dca/tl_iso_payment.php index 5393c683de..1433b07967 100644 --- a/system/modules/isotope/dca/tl_iso_payment.php +++ b/system/modules/isotope/dca/tl_iso_payment.php @@ -103,7 +103,7 @@ 'paybyway' => '{type_legend},name,label,type;{note_legend:hide},note;{config_legend},new_order_status,quantity_mode,minimum_quantity,maximum_quantity,minimum_total,maximum_total,countries,shipping_modules,product_types,product_types_condition,config_ids;{gateway_legend},paybyway_merchant_id,paybyway_private_key;{price_legend:hide},price,tax_class;{expert_legend:hide},guests,protected;{enabled_legend},enabled,debug,logging', 'paypal' => '{type_legend},name,label,type;{note_legend:hide},note;{config_legend},new_order_status,quantity_mode,minimum_quantity,maximum_quantity,minimum_total,maximum_total,countries,shipping_modules,product_types,product_types_condition,config_ids;{gateway_legend},paypal_account;{price_legend:hide},price,tax_class;{expert_legend:hide},guests,protected;{enabled_legend},enabled,debug,logging', 'paypal_plus' => '{type_legend},name,label,type;{note_legend:hide},note;{config_legend},new_order_status,quantity_mode,minimum_quantity,maximum_quantity,minimum_total,maximum_total,countries,shipping_modules,product_types,product_types_condition,config_ids;{gateway_legend},paypal_client,paypal_secret;{price_legend:hide},price,tax_class;{expert_legend:hide},guests,protected;{enabled_legend},enabled,debug,logging', - 'paypal_checkout' => '{type_legend},name,label,type;{note_legend:hide},note;{config_legend},new_order_status,quantity_mode,minimum_quantity,maximum_quantity,minimum_total,maximum_total,countries,shipping_modules,product_types,product_types_condition,config_ids;{gateway_legend},paypal_client,paypal_secret;{price_legend:hide},price,tax_class;{expert_legend:hide},guests,protected;{enabled_legend},enabled,debug,logging', + 'paypal_checkout' => '{type_legend},name,label,type;{note_legend:hide},note;{config_legend},new_order_status,quantity_mode,minimum_quantity,maximum_quantity,minimum_total,maximum_total,countries,shipping_modules,product_types,product_types_condition,config_ids;{gateway_legend},paypal_client,paypal_secret,paypal_enable_funding;{price_legend:hide},price,tax_class;{expert_legend:hide},guests,protected;{enabled_legend},enabled,debug,logging', 'postfinance' => '{type_legend},name,label,type;{note_legend:hide},note;{config_legend},new_order_status,quantity_mode,minimum_quantity,maximum_quantity,minimum_total,maximum_total,countries,shipping_modules,product_types,product_types_condition,config_ids;{gateway_legend},psp_pspid,psp_http_method,psp_hash_method,psp_hash_in,psp_hash_out,psp_dynamic_template,psp_payment_method;{price_legend:hide},price,tax_class;{expert_legend:hide},guests,protected;{enabled_legend},enabled,debug,logging', 'viveum' => '{type_legend},name,label,type;{note_legend:hide},note;{config_legend},new_order_status,quantity_mode,minimum_quantity,maximum_quantity,minimum_total,maximum_total,countries,shipping_modules,product_types,product_types_condition,config_ids;{gateway_legend},psp_pspid,psp_http_method,psp_hash_method,psp_hash_in,psp_hash_out,psp_dynamic_template,psp_payment_method;{price_legend:hide},price,tax_class;{expert_legend:hide},guests,protected;{enabled_legend},enabled,debug,logging', 'datatrans' => '{type_legend},name,label,type;{note_legend:hide},note;{config_legend},new_order_status,trans_type,quantity_mode,minimum_quantity,maximum_quantity,minimum_total,maximum_total,countries,shipping_modules,product_types,product_types_condition,config_ids;{gateway_legend},datatrans_id,datatrans_sign,datatrans_hash_method,datatrans_hash_convert;{price_legend:hide},price,tax_class;{expert_legend:hide},guests,protected;{enabled_legend},enabled,debug,logging', @@ -344,6 +344,18 @@ 'eval' => array('mandatory'=>true, 'maxlength'=>128, 'hideInput'=>true, 'tl_class'=>'w50'), 'sql' => "varchar(128) NOT NULL default ''", ), + 'paypal_enable_funding' => array + ( + 'exclude' => true, + 'inputType' => 'select', + 'options' => \Isotope\Model\Payment\PaypalCheckout::$enableFundingParameters, + 'options_callback' => function() { + return \Isotope\Model\Payment\PaypalCheckout::getEnableFundingOptions(); + }, + 'reference' => &$GLOBALS['TL_LANG']['tl_iso_payment']['paypal_enable_funding'], + 'eval' => array('multiple'=>true, 'size'=>8, 'tl_class'=>'w50 w50h', 'chosen'=>true), + 'sql' => "blob NULL", + ), 'psp_pspid' => array ( 'exclude' => true, diff --git a/system/modules/isotope/languages/de/tl_iso_payment.xlf b/system/modules/isotope/languages/de/tl_iso_payment.xlf index cb60d6b4bb..fa285db628 100644 --- a/system/modules/isotope/languages/de/tl_iso_payment.xlf +++ b/system/modules/isotope/languages/de/tl_iso_payment.xlf @@ -193,6 +193,26 @@ Enter your PayPal API secret. Geben Sie Ihren PayPal API Schlüssel ein. + + Enable funding + Finanzierungsquellen aktivieren + + + The enabled funding sources for the transaction. By default, funding source eligibility is determined based on a variety of factors. Enable funding can be used to ensure a funding source is rendered, if eligible. + Geben Sie die Finanzierungsquellen an die Sie aktivieren möchten. Standardmäßig wird die Zulässigkeit von Finanzierungsquellen auf der Grundlage einer Reihe von Faktoren bestimmt. Mit der Option "Finanzierung aktivieren" kann sichergestellt werden, dass eine Finanzierungsquelle genutzt wird, wenn sie in Frage kommt. + + + Credit or debit cards + Kredit- oder Debitkarten + + + PayPal Credit (US, UK) + PayPal Credit (US, UK) + + + Pay Later (US, UK), Pay in 4 (AU) + Später Bezahlen + PSPID PSPID @@ -1016,4 +1036,4 @@ SOFORTüberweisung - \ No newline at end of file + diff --git a/system/modules/isotope/languages/en/tl_iso_payment.xlf b/system/modules/isotope/languages/en/tl_iso_payment.xlf index 0072911515..b14d805b21 100644 --- a/system/modules/isotope/languages/en/tl_iso_payment.xlf +++ b/system/modules/isotope/languages/en/tl_iso_payment.xlf @@ -146,6 +146,54 @@ Enter your PayPal API secret. + + Enable funding + + + The enabled funding sources for the transaction. By default, funding source eligibility is determined based on a variety of factors. Enable funding can be used to ensure a funding source is rendered, if eligible. + + + Credit or debit cards + + + PayPal Credit (US, UK) + + + Pay Later (US, UK), Pay in 4 (AU) + + + Venmo + + + Bancontact + + + BLIK + + + eps + + + giropay + + + iDEAL + + + Mercado Pago + + + MyBank + + + Przelewy24 + + + SEPA-Lastschrift + + + Sofort + PSPID diff --git a/system/modules/isotope/languages/es/tl_iso_payment.xlf b/system/modules/isotope/languages/es/tl_iso_payment.xlf index a774ecc8c7..aade76318b 100644 --- a/system/modules/isotope/languages/es/tl_iso_payment.xlf +++ b/system/modules/isotope/languages/es/tl_iso_payment.xlf @@ -174,6 +174,10 @@ Enter your PayPal API secret. + + Pay Later (US, UK), Pay in 4 (AU) + Paga en 3 plazos + PSPID @@ -875,4 +879,4 @@ - \ No newline at end of file + diff --git a/system/modules/isotope/languages/fr/tl_iso_payment.xlf b/system/modules/isotope/languages/fr/tl_iso_payment.xlf index 7aa6cc2353..0f5c0f7c90 100644 --- a/system/modules/isotope/languages/fr/tl_iso_payment.xlf +++ b/system/modules/isotope/languages/fr/tl_iso_payment.xlf @@ -178,6 +178,10 @@ Enter your PayPal API secret. + + Pay Later (US, UK), Pay in 4 (AU) + 4X PayPal + PSPID PSPID @@ -888,4 +892,4 @@ - \ No newline at end of file + diff --git a/system/modules/isotope/languages/it/tl_iso_payment.xlf b/system/modules/isotope/languages/it/tl_iso_payment.xlf index 726c12f933..5bcdae5a25 100644 --- a/system/modules/isotope/languages/it/tl_iso_payment.xlf +++ b/system/modules/isotope/languages/it/tl_iso_payment.xlf @@ -193,6 +193,10 @@ Enter your PayPal API secret. Inserire il vostro segreto API PayPal. + + Pay Later (US, UK), Pay in 4 (AU) + Paga in 3 rate + PSPID PSPID @@ -1015,4 +1019,4 @@ - \ No newline at end of file + diff --git a/system/modules/isotope/library/Isotope/Model/Payment/PaypalCheckout.php b/system/modules/isotope/library/Isotope/Model/Payment/PaypalCheckout.php index 9a771f44ae..9e7fcaeb52 100644 --- a/system/modules/isotope/library/Isotope/Model/Payment/PaypalCheckout.php +++ b/system/modules/isotope/library/Isotope/Model/Payment/PaypalCheckout.php @@ -24,6 +24,27 @@ class PaypalCheckout extends PaypalApi { + /** + * List of parameters to enable funding + * @var array + */ + public static $enableFundingParameters = array( + 'card', + 'credit', + 'paylater', + 'venmo', + 'bancontact', + 'blik', + 'eps', + 'giropay', + 'ideal', + 'mercadopago', + 'mybank', + 'p24', + 'sepa', + 'sofort' + ); + public function isAvailable(): bool { if (!in_array(Isotope::getConfig()->currency, ['AUD', 'BRL', 'CAD', 'CZK', 'DKK', 'EUR', 'HKD', 'HUF', 'ILS', 'JPY', 'MYR', 'MXN', 'TWD', 'NZD', 'NOK', 'PHP', 'PLN', 'GBP', 'RUB', 'SGD', 'SEK', 'CHF', 'THB', 'USD'])) { @@ -63,6 +84,7 @@ public function checkoutForm(IsotopeProductCollection $objOrder, \Module $objMod $template->client_id = $this->paypal_client; $template->currency = $objOrder->getCurrency(); + $template->enable_funding = $this->getEnableFundingParameters(); parse_str(parse_url($link['href'], PHP_URL_QUERY), $params); $template->token = $params['token']; @@ -122,4 +144,44 @@ public function processPayment(IsotopeProductCollection $objOrder, Module $objMo return true; } + + /** + * Get list of model types + * + * @return array + */ + public static function getFundingParameters() + { + return static::$enableFundingParameters; + } + + /** + * Return options list of model types + * + * @return array + */ + public static function getEnableFundingOptions() + { + $arrOptions = array(); + + foreach (static::getFundingParameters() as $strName => $strClass) { + $arrOptions[$strClass] = $GLOBALS['TL_LANG']['tl_iso_payment']['paypal_enable_funding_options'][$strClass] ?? $strClass; + } + + return $arrOptions; + } + + /** + * Get enable funding parameters + * + * @return null|string + */ + public function getEnableFundingParameters() + { + if (isset($this->paypal_enable_funding)) { + return implode(',', array_values(unserialize($this->paypal_enable_funding))); + } + + return null; + } } diff --git a/system/modules/isotope/templates/payment/iso_payment_paypal_checkout.html5 b/system/modules/isotope/templates/payment/iso_payment_paypal_checkout.html5 index 58af904f03..ced5af1b3c 100644 --- a/system/modules/isotope/templates/payment/iso_payment_paypal_checkout.html5 +++ b/system/modules/isotope/templates/payment/iso_payment_paypal_checkout.html5 @@ -1,5 +1,5 @@
- + +