Skip to content

Funding sources to allow from showing in the buttons and marks. #2414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: 2.9
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion system/modules/isotope/dca/tl_iso_payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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,
Expand Down
22 changes: 21 additions & 1 deletion system/modules/isotope/languages/de/tl_iso_payment.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,26 @@
<source>Enter your PayPal API secret.</source>
<target>Geben Sie Ihren PayPal API Schlüssel ein.</target>
</trans-unit>
<trans-unit id="tl_iso_payment.paypal_enable_funding.0">
<source>Enable funding</source>
<target>Finanzierungsquellen aktivieren</target>
</trans-unit>
<trans-unit id="tl_iso_payment.paypal_enable_funding.1">
<source>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.</source>
<target>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.</target>
</trans-unit>
<trans-unit id="tl_iso_payment.paypal_enable_funding_options.card">
<source>Credit or debit cards</source>
<target>Kredit- oder Debitkarten</target>
</trans-unit>
<trans-unit id="tl_iso_payment.paypal_enable_funding_options.credit">
<source>PayPal Credit (US, UK)</source>
<target>PayPal Credit (US, UK)</target>
</trans-unit>
<trans-unit id="tl_iso_payment.paypal_enable_funding_options.paylater">
<source>Pay Later (US, UK), Pay in 4 (AU)</source>
<target>Später Bezahlen</target>
</trans-unit>
<trans-unit id="tl_iso_payment.psp_pspid.0">
<source>PSPID</source>
<target>PSPID</target>
Expand Down Expand Up @@ -1016,4 +1036,4 @@ SOFORTüberweisung</target>
</trans-unit>
</body>
</file>
</xliff>
</xliff>
48 changes: 48 additions & 0 deletions system/modules/isotope/languages/en/tl_iso_payment.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,54 @@
<trans-unit id="tl_iso_payment.paypal_secret.1">
<source>Enter your PayPal API secret.</source>
</trans-unit>
<trans-unit id="tl_iso_payment.paypal_enable_funding.0">
<source>Enable funding</source>
</trans-unit>
<trans-unit id="tl_iso_payment.paypal_enable_funding.1">
<source>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.</source>
</trans-unit>
<trans-unit id="tl_iso_payment.paypal_enable_funding_options.card">
<source>Credit or debit cards</source>
</trans-unit>
<trans-unit id="tl_iso_payment.paypal_enable_funding_options.credit">
<source>PayPal Credit (US, UK)</source>
</trans-unit>
<trans-unit id="tl_iso_payment.paypal_enable_funding_options.paylater">
<source>Pay Later (US, UK), Pay in 4 (AU)</source>
</trans-unit>
<trans-unit id="tl_iso_payment.paypal_enable_funding_options.venmo">
<source>Venmo</source>
</trans-unit>
<trans-unit id="tl_iso_payment.paypal_enable_funding_options.bancontact">
<source>Bancontact</source>
</trans-unit>
<trans-unit id="tl_iso_payment.paypal_enable_funding_options.blik">
<source>BLIK</source>
</trans-unit>
<trans-unit id="tl_iso_payment.paypal_enable_funding_options.eps">
<source>eps</source>
</trans-unit>
<trans-unit id="tl_iso_payment.paypal_enable_funding_options.giropay">
<source>giropay</source>
</trans-unit>
<trans-unit id="tl_iso_payment.paypal_enable_funding_options.ideal">
<source>iDEAL</source>
</trans-unit>
<trans-unit id="tl_iso_payment.paypal_enable_funding_options.mercadopago">
<source>Mercado Pago</source>
</trans-unit>
<trans-unit id="tl_iso_payment.paypal_enable_funding_options.mybank">
<source>MyBank</source>
</trans-unit>
<trans-unit id="tl_iso_payment.paypal_enable_funding_options.p24">
<source>Przelewy24</source>
</trans-unit>
<trans-unit id="tl_iso_payment.paypal_enable_funding_options.sepa">
<source>SEPA-Lastschrift</source>
</trans-unit>
<trans-unit id="tl_iso_payment.paypal_enable_funding_options.sofort">
<source>Sofort</source>
</trans-unit>
<trans-unit id="tl_iso_payment.psp_pspid.0">
<source>PSPID</source>
</trans-unit>
Expand Down
6 changes: 5 additions & 1 deletion system/modules/isotope/languages/es/tl_iso_payment.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@
<trans-unit id="tl_iso_payment.paypal_secret.1">
<source>Enter your PayPal API secret.</source>
</trans-unit>
<trans-unit id="tl_iso_payment.paypal_enable_funding_options.paylater">
<source>Pay Later (US, UK), Pay in 4 (AU)</source>
<target>Paga en 3 plazos</target>
</trans-unit>
<trans-unit id="tl_iso_payment.psp_pspid.0">
<source>PSPID</source>
</trans-unit>
Expand Down Expand Up @@ -875,4 +879,4 @@
</trans-unit>
</body>
</file>
</xliff>
</xliff>
6 changes: 5 additions & 1 deletion system/modules/isotope/languages/fr/tl_iso_payment.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@
<trans-unit id="tl_iso_payment.paypal_secret.1">
<source>Enter your PayPal API secret.</source>
</trans-unit>
<trans-unit id="tl_iso_payment.paypal_enable_funding_options.paylater">
<source>Pay Later (US, UK), Pay in 4 (AU)</source>
<target>4X PayPal</target>
</trans-unit>
<trans-unit id="tl_iso_payment.psp_pspid.0">
<source>PSPID</source>
<target>PSPID</target>
Expand Down Expand Up @@ -888,4 +892,4 @@
</trans-unit>
</body>
</file>
</xliff>
</xliff>
6 changes: 5 additions & 1 deletion system/modules/isotope/languages/it/tl_iso_payment.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@
<source>Enter your PayPal API secret.</source>
<target>Inserire il vostro segreto API PayPal.</target>
</trans-unit>
<trans-unit id="tl_iso_payment.paypal_enable_funding_options.paylater">
<source>Pay Later (US, UK), Pay in 4 (AU)</source>
<target>Paga in 3 rate</target>
</trans-unit>
<trans-unit id="tl_iso_payment.psp_pspid.0">
<source>PSPID</source>
<target>PSPID</target>
Expand Down Expand Up @@ -1015,4 +1019,4 @@
</trans-unit>
</body>
</file>
</xliff>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -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'])) {
Expand Down Expand Up @@ -63,6 +84,7 @@ public function checkoutForm(IsotopeProductCollection $objOrder, Module $objModu

$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'];
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div id="paypal_checkout<?= $this->id ?>"></div>
<script src="https://www.paypal.com/sdk/js?client-id=<?= $this->client_id ?>&currency=<?= $this->currency ?>&debug=<?= $this->debug ? 'true' : 'false' ?>"></script>
<script src="https://www.paypal.com/sdk/js?client-id=<?= $this->client_id ?>&currency=<?= $this->currency ?>&debug=<?= $this->debug ? 'true' : 'false' ?><?php if($this->enable_funding): ?>&enable-funding=<?= $this->enable_funding ?><?php endif; ?>"></script>
<script>
paypal.Buttons({
createOrder: function () {
Expand Down