Skip to content

Commit

Permalink
Merge branch 'hotfix/1.16.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Alima Grine committed Dec 26, 2023
2 parents 8054057 + 4e57747 commit e5a961c
Show file tree
Hide file tree
Showing 12 changed files with 167 additions and 13 deletions.
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
1.16.3, 2023-12-26:
- [technical] Improve features management by plugin variant.

1.16.2, 2023-11-28:
- Bug fix: Fix order slip amount.
- [embedded] Send capture delay parameter for Smartform modes.
- [embedded] Added possibility to display/hide payment method title on checkout page for Smartform modes.
- [smartform] Send capture delay parameter for Smartform modes.
- [smartform] Added possibility to display/hide payment method title on checkout page for Smartform modes.
- Compatibility with PrestaShop 8.1.x and higher.
- Update list of supported payment means.
- Update list of supported currencies.
Expand All @@ -14,7 +17,7 @@
- Update list of supported currencies.

1.16.0, 2023-07-06:
- [embedded] Smartform integration.
- [smartform] Smartform integration.
- [embedded] Send shopping cart content for payment with embedded fields.
- [embedded] Bug fix: Fix error related to validation mode.
- [oney] Added 10x 12x Oney and Paylater means of payment.
Expand Down
21 changes: 20 additions & 1 deletion payzen/classes/PayzenTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class PayzenTools

private static $CMS_IDENTIFIER = 'PrestaShop_1.5-8.x';
private static $SUPPORT_EMAIL = '[email protected]';
private static $PLUGIN_VERSION = '1.16.2';
private static $PLUGIN_VERSION = '1.16.3';
private static $GATEWAY_VERSION = 'V2';

const ORDER_ID_REGEX = '#^[a-zA-Z0-9]{1,9}$#';
Expand Down Expand Up @@ -95,7 +95,9 @@ class PayzenTools
'restrictmulti' => false,
'shatwo' => true,
'embedded' => true,
'smartform' => true,
'support' => true,
'brazil' => false,

'multi' => true,
'choozeo' => false,
Expand Down Expand Up @@ -250,6 +252,10 @@ public static function getAdminParameters()
array('key' => 'PAYZEN_REST_SERVER_URL', 'default' => self::getDefault('REST_URL'), 'label' => 'REST API server URL'),
array('key' => 'PAYZEN_REST_JS_CLIENT_URL', 'default' => self::getDefault('STATIC_URL'), 'label' => 'JavaScript client URL'),

array('key' => 'PAYZEN_DOCUMENT', 'name' => 'document_custom_field', 'default' => '', 'label' => 'CPF/CNPJ field'),
array('key' => 'PAYZEN_NUMBER', 'name' => 'number_custom_field', 'default' => '', 'label' => 'Address number field'),
array('key' => 'PAYZEN_NEIGHBORHOOD', 'name' => 'neighborhood_custom_field', 'default' => '', 'label' => 'Neighborhood field'),

array('key' => 'PAYZEN_DEFAULT_LANGUAGE', 'default' => self::getDefault('LANGUAGE'), 'label' => 'Default language'),
array('key' => 'PAYZEN_AVAILABLE_LANGUAGES', 'name' => 'available_languages', 'default' => '',
'label' => 'Available languages'),
Expand Down Expand Up @@ -1076,4 +1082,17 @@ public static function getCardDataEntryModes() {
'9' => 'SMARTFORM_EXT_WITHOUT_LOGOS'
);
}

public static function formatDocument($cnpj_cpf)
{
$cnpj_cpf = preg_replace('/[^0-9]/is', '', $cnpj_cpf);

if (strlen(preg_replace("/\D/", '', $cnpj_cpf)) === 11) {
$response = preg_replace("/(\d{3})(\d{3})(\d{3})(\d{2})/", "\$1.\$2.\$3-\$4", $cnpj_cpf);
} else {
$response = preg_replace("/(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})/", "\$1.\$2.\$3/\$4-\$5", $cnpj_cpf);
}

return $response;
}
}
40 changes: 33 additions & 7 deletions payzen/classes/admin/PayzenHelperForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ public static function getAdminFormContext()
'code' => '',
'title' => ''
),
'payzen_sepa_mandate_mode_options' => array(
'PAYMENT' => $payzen->l('One-off SEPA direct debit', 'payzenhelperform'),
'REGISTER_PAY' => $payzen->l('Register a recurrent SEPA mandate with direct debit', 'payzenhelperform'),
'REGISTER' => $payzen->l('Register a recurrent SEPA mandate without direct debit', 'payzenhelperform')
),
'payzen_extra_options' => self::getExtraConfig(),

'prestashop_categories' => Category::getCategories((int) $context->language->id, true, false),
'prestashop_languages' => Language::getLanguages(false),
Expand All @@ -252,11 +258,6 @@ public static function getAdminFormContext()
Carrier::ALL_CARRIERS
),
'prestashop_groups' => self::getAuthorizedGroups(),
'payzen_sepa_mandate_mode_options' => array(
'PAYMENT' => $payzen->l('One-off SEPA direct debit', 'payzenhelperform'),
'REGISTER_PAY' => $payzen->l('Register a recurrent SEPA mandate with direct debit', 'payzenhelperform'),
'REGISTER' => $payzen->l('Register a recurrent SEPA mandate without direct debit', 'payzenhelperform')
),

'PAYZEN_ENABLE_LOGS' => Configuration::get('PAYZEN_ENABLE_LOGS'),
'PAYZEN_ENABLE_CUST_MSG' => Configuration::get('PAYZEN_ENABLE_CUST_MSG'),
Expand Down Expand Up @@ -292,6 +293,10 @@ public static function getAdminFormContext()

'PAYZEN_3DS_MIN_AMOUNT' => self::getArrayConfig('PAYZEN_3DS_MIN_AMOUNT'),

'PAYZEN_DOCUMENT' => Configuration::get('PAYZEN_DOCUMENT'),
'PAYZEN_NUMBER' => Configuration::get('PAYZEN_NUMBER'),
'PAYZEN_NEIGHBORHOOD' => Configuration::get('PAYZEN_NEIGHBORHOOD'),

'PAYZEN_REDIRECT_ENABLED' => Configuration::get('PAYZEN_REDIRECT_ENABLED'),
'PAYZEN_REDIRECT_SUCCESS_T' => Configuration::get('PAYZEN_REDIRECT_SUCCESS_T'),
'PAYZEN_REDIRECT_SUCCESS_M' => self::getLangConfig('PAYZEN_REDIRECT_SUCCESS_M'),
Expand Down Expand Up @@ -402,8 +407,11 @@ public static function getAdminFormContext()
array() : explode(';', Configuration::get('PAYZEN_' . $key . '_COUNTRY_LST'));
}

if (! PayzenTools::$plugin_features['embedded']) {
unset($tpl_vars['payzen_card_data_mode_options'][PayzenTools::MODE_EMBEDDED]);
if (! PayzenTools::$plugin_features['embedded'] || ! PayzenTools::$plugin_features['smartform']) {
if (! PayzenTools::$plugin_features['embedded']) {
unset($tpl_vars['payzen_card_data_mode_options'][PayzenTools::MODE_EMBEDDED]);
}

unset($tpl_vars['payzen_card_data_mode_options'][PayzenTools::MODE_SMARTFORM]);
unset($tpl_vars['payzen_card_data_mode_options'][PayzenTools::MODE_SMARTFORM_EXT_WITH_LOGOS]);
unset($tpl_vars['payzen_card_data_mode_options'][PayzenTools::MODE_SMARTFORM_EXT_WITHOUT_LOGOS]);
Expand Down Expand Up @@ -467,4 +475,22 @@ private static function getAuthorizedGroups()

return Db::getInstance()->executeS($sql);
}

private static function getExtraConfig()
{
$fields[''] = '-- Select custom field --';
$customer = Db::getInstance()->executeS("SHOW COLUMNS FROM `" . _DB_PREFIX_ . "customer`");
foreach ($customer as $k => $v) {
$input = _DB_PREFIX_ . 'customer.' . $v['Field'];
$fields[$input] = $input;
}

$address = Db::getInstance()->executeS("SHOW COLUMNS FROM `" . _DB_PREFIX_ . "address`");
foreach ($address as $k => $v) {
$input = _DB_PREFIX_ . 'address.' . $v['Field'];
$fields[$input] = $input;
}

return $fields;
}
}
41 changes: 41 additions & 0 deletions payzen/classes/payment/AbstractPayzenPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,47 @@ public function prepareRequest($cart, $data = array())
/* @var $cust Customer */
$cust = new Customer((int) $cart->id_customer);

// Customized fields for Brazil payment means.
if(PayzenTools::$plugin_features['brazil']) {
$customer_address = array_merge((array) $cust, (array) $billing_address);

$address_number = '0';
$config_number = Configuration::get('PAYZEN_NUMBER');
if (! empty($config_number)) {
$parts = explode('.', $config_number);
$data_array = json_decode(json_encode($customer_address), true);
if (! empty($data_array[$parts[1]])) {
$address_number = $data_array[$parts[1]];
}
}

$document = '';
$config_document = Configuration::get('PAYZEN_DOCUMENT');
if (! empty($config_document)) {
$parts = explode('.', $config_document);
$data_array = json_decode(json_encode($customer_address), true);
if (! empty($data_array[$parts[1]])) {
$document = $data_array[$parts[1]];
}
}

$document = PayzenTools::formatDocument($document);

$neighborhood = '-';
$config_neighborhood = Configuration::get('PAYZEN_NEIGHBORHOOD');
if (! empty($config_neighborhood)) {
$parts = explode('.', $config_neighborhood);
$data_array = json_decode(json_encode($customer_address), true);
if (! empty($data_array[$parts[1]])) {
$neighborhood = $data_array[$parts[1]];
}
}

$request->set('cust_district', $neighborhood);
$request->set('cust_address_number', $address_number);
$request->set('cust_national_id', $document);
}

// Customer data.
$request->set('cust_email', $cust->email);
$request->set('cust_id', $cust->id);
Expand Down
4 changes: 2 additions & 2 deletions payzen/payzen.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct()
{
$this->name = 'payzen';
$this->tab = 'payments_gateways';
$this->version = '1.16.2';
$this->version = '1.16.3';
$this->author = 'Lyra Network';
$this->controllers = array('redirect', 'submit', 'rest', 'iframe');
$this->module_key = 'f3e5d07f72a9d27a5a09196d54b9648e';
Expand Down Expand Up @@ -943,7 +943,7 @@ private function postProcess()
}

// Validate with Lyranetwork\Payzen\Sdk\Form\Request.
if ($name && ($name !== 'theme_config')) {
if ($name && ($name !== 'theme_config') && ! strpos($name, 'custom')) {
$values = is_array($value) ? $value : array($value); // To check multilingual fields.
$error = false;

Expand Down
6 changes: 6 additions & 0 deletions payzen/translations/br.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,12 @@
$_MODULE['<{payzen}prestashop>back_office_42ed277b2d23ac14d5d6a9f2e8fe6141'] = 'Valor máximo para propor o meio de pagamento.';
$_MODULE['<{payzen}prestashop>back_office_0b68d09900a5d634731c294747dd52d3'] = 'Se você ativar esta opção, a forma de pagamento será exibida em um Smartform. Atenção, nem todos os meios de pagamento disponíveis são suportados pelo Smartform. Para maiores informações, consulte a documentação do módulo.';
$_MODULE['<{payzen}prestashop>back_office_c9cc8cce247e49bae79f15173ce97354'] = 'Salvar';
$_MODULE['<{payzen}prestashop>back_office_f4f0f2856a5a0ecb77b781f508f389bc'] = 'Campo para CPF/CNPJ';
$_MODULE['<{payzen}prestashop>back_office_8289d453954e51b0f2c08aafa63edde7'] = 'Campo customizado onde o CPF/CNPJ do cliente é salvo na loja.';
$_MODULE['<{payzen}prestashop>back_office_d22c3279d5e4b4965e00f74ac950275e'] = 'Campo para número do endereço';
$_MODULE['<{payzen}prestashop>back_office_1ca3be7d867a113084017262b5a82432'] = 'Campo customizado onde o número do endereço do cliente é salvo na loja.';
$_MODULE['<{payzen}prestashop>back_office_71d0e1e74023b945415a441e3be21169'] = 'Campo para bairro';
$_MODULE['<{payzen}prestashop>back_office_75e603c964afa4529a36b2eb37694240'] = 'Campo customizado onde o bairro do endereço do cliente é salvo na loja.';
$_MODULE['<{payzen}prestashop>refund_6d789b879990e5f4c52eb9aa38f1f10b'] = 'Reembolsar o comprador por Web Services com%s';
$_MODULE['<{payzen}prestashop>refund_bc_6d789b879990e5f4c52eb9aa38f1f10b'] = 'Reembolsar o comprador por Web services com %s';
$_MODULE['<{payzen}prestashop>row_multi_option_f2a6c498fb90ee345d997f888fce3b18'] = 'Apagar';
Expand Down
6 changes: 6 additions & 0 deletions payzen/translations/de.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,12 @@
$_MODULE['<{payzen}prestashop>back_office_42ed277b2d23ac14d5d6a9f2e8fe6141'] = 'Höchstbetrag für die Aktivierung die Zahlungsmittel.';
$_MODULE['<{payzen}prestashop>back_office_0b68d09900a5d634731c294747dd52d3'] = 'If you enable this option, the payment mean will be displayed in the Smartform. Attention, not all available payment means are supported by the Smartform. For more information, refer to the module documentation.';
$_MODULE['<{payzen}prestashop>back_office_c9cc8cce247e49bae79f15173ce97354'] = 'Speichern';
$_MODULE['<{payzen}prestashop>back_office_f4f0f2856a5a0ecb77b781f508f389bc'] = 'CPF/CNPJ-Feld';
$_MODULE['<{payzen}prestashop>back_office_8289d453954e51b0f2c08aafa63edde7'] = 'Benutzerdefiniertes Feld, in dem CPF/CNPJ im Shop gespeichert wird.';
$_MODULE['<{payzen}prestashop>back_office_d22c3279d5e4b4965e00f74ac950275e'] = 'Feld für die Adressnummer';
$_MODULE['<{payzen}prestashop>back_office_1ca3be7d867a113084017262b5a82432'] = 'Benutzerdefiniertes Feld, in dem die Adressnummer im Shop gespeichert wird.';
$_MODULE['<{payzen}prestashop>back_office_71d0e1e74023b945415a441e3be21169'] = 'Nachbarschaftliches Feld';
$_MODULE['<{payzen}prestashop>back_office_75e603c964afa4529a36b2eb37694240'] = 'Benutzerdefiniertes Feld, in dem die Nachbarschaft der Adresse im Shop gespeichert wird.';
$_MODULE['<{payzen}prestashop>refund_6d789b879990e5f4c52eb9aa38f1f10b'] = 'Rückerstatt dem Käufer durch Web Services mit %s';
$_MODULE['<{payzen}prestashop>refund_bc_6d789b879990e5f4c52eb9aa38f1f10b'] = 'Rückerstatt dem Käufer durch Web Services mit %s';
$_MODULE['<{payzen}prestashop>row_multi_option_f2a6c498fb90ee345d997f888fce3b18'] = 'Löschen';
Expand Down
6 changes: 6 additions & 0 deletions payzen/translations/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,12 @@
$_MODULE['<{payzen}prestashop>back_office_42ed277b2d23ac14d5d6a9f2e8fe6141'] = 'Maximum amount to enable the means of payment.';
$_MODULE['<{payzen}prestashop>back_office_0b68d09900a5d634731c294747dd52d3'] = 'If you enable this option, the payment mean will be displayed in the Smartform. Attention, not all available payment means are supported by the Smartform. For more information, refer to the module documentation.';
$_MODULE['<{payzen}prestashop>back_office_c9cc8cce247e49bae79f15173ce97354'] = 'Save';
$_MODULE['<{payzen}prestashop>back_office_f4f0f2856a5a0ecb77b781f508f389bc'] = 'CPF/CNPJ field';
$_MODULE['<{payzen}prestashop>back_office_8289d453954e51b0f2c08aafa63edde7'] = 'Custom field where CPF/CNPJ is saved on shop.';
$_MODULE['<{payzen}prestashop>back_office_d22c3279d5e4b4965e00f74ac950275e'] = 'Address number field';
$_MODULE['<{payzen}prestashop>back_office_1ca3be7d867a113084017262b5a82432'] = 'Custom field where address number is saved on shop.';
$_MODULE['<{payzen}prestashop>back_office_71d0e1e74023b945415a441e3be21169'] = 'Neighborhood field';
$_MODULE['<{payzen}prestashop>back_office_75e603c964afa4529a36b2eb37694240'] = 'Custom field where address neighborhood is saved on shop.';
$_MODULE['<{payzen}prestashop>refund_6d789b879990e5f4c52eb9aa38f1f10b'] = 'Refund the buyer by Web Services with %s';
$_MODULE['<{payzen}prestashop>refund_bc_6d789b879990e5f4c52eb9aa38f1f10b'] = 'Refund the buyer by Web Services with %s';
$_MODULE['<{payzen}prestashop>row_multi_option_f2a6c498fb90ee345d997f888fce3b18'] = 'Delete';
Expand Down
6 changes: 6 additions & 0 deletions payzen/translations/es.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,12 @@
$_MODULE['<{payzen}prestashop>back_office_42ed277b2d23ac14d5d6a9f2e8fe6141'] = 'Monto máximo para habilitar el medio de pago.';
$_MODULE['<{payzen}prestashop>back_office_0b68d09900a5d634731c294747dd52d3'] = 'Si activa esta opción, el método de pago se mostrará en un Smartform. Atención, no todos los medios de pago disponibles son compatibles con Smartform. Para más información, consulte la documentación del módulo.';
$_MODULE['<{payzen}prestashop>back_office_c9cc8cce247e49bae79f15173ce97354'] = 'Guardar';
$_MODULE['<{payzen}prestashop>back_office_f4f0f2856a5a0ecb77b781f508f389bc'] = 'Campo CPF/CNPJ';
$_MODULE['<{payzen}prestashop>back_office_8289d453954e51b0f2c08aafa63edde7'] = 'Campo personalizado donde se guarda CPF/CNPJ en la tienda.';
$_MODULE['<{payzen}prestashop>back_office_d22c3279d5e4b4965e00f74ac950275e'] = 'Campo del número de dirección';
$_MODULE['<{payzen}prestashop>back_office_1ca3be7d867a113084017262b5a82432'] = 'Campo personalizado donde se guarda el número de dirección en la tienda.';
$_MODULE['<{payzen}prestashop>back_office_71d0e1e74023b945415a441e3be21169'] = 'Campo vecinal';
$_MODULE['<{payzen}prestashop>back_office_75e603c964afa4529a36b2eb37694240'] = 'Campo personalizado donde se guarda la dirección del barrio en la tienda.';
$_MODULE['<{payzen}prestashop>refund_6d789b879990e5f4c52eb9aa38f1f10b'] = 'Reembolsar al comprador por Web Services con %s';
$_MODULE['<{payzen}prestashop>refund_bc_6d789b879990e5f4c52eb9aa38f1f10b'] = 'Reembolsar al comprador por de Web Services con %s';
$_MODULE['<{payzen}prestashop>row_multi_option_f2a6c498fb90ee345d997f888fce3b18'] = 'Eliminar';
Expand Down
6 changes: 6 additions & 0 deletions payzen/translations/fr.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,12 @@
$_MODULE['<{payzen}prestashop>back_office_42ed277b2d23ac14d5d6a9f2e8fe6141'] = 'Montant maximum pour proposer le moyen de paiement.';
$_MODULE['<{payzen}prestashop>back_office_0b68d09900a5d634731c294747dd52d3'] = 'Si vous activez cette option, le moyen de paiement sera affiché dans le Smartform. À noter que tous les moyens de paiement ne sont pas supportés par le Smartform. Reportez-vous à la documentation pour plus d\'informations.';
$_MODULE['<{payzen}prestashop>back_office_c9cc8cce247e49bae79f15173ce97354'] = 'Enregistrer';
$_MODULE['<{payzen}prestashop>back_office_f4f0f2856a5a0ecb77b781f508f389bc'] = 'Champ CPF/CNPJ';
$_MODULE['<{payzen}prestashop>back_office_8289d453954e51b0f2c08aafa63edde7'] = 'Champ personnalisé dans lequel le CPF/CNPJ est enregistré dans la boutique.';
$_MODULE['<{payzen}prestashop>back_office_d22c3279d5e4b4965e00f74ac950275e'] = 'Champ du numéro d\'adresse';
$_MODULE['<{payzen}prestashop>back_office_1ca3be7d867a113084017262b5a82432'] = 'Champ personnalisé dans lequel le numéro d\'adresse est enregistré dans la boutique.';
$_MODULE['<{payzen}prestashop>back_office_71d0e1e74023b945415a441e3be21169'] = 'Champ du quartier';
$_MODULE['<{payzen}prestashop>back_office_75e603c964afa4529a36b2eb37694240'] = 'Champ personnalisé dans lequel le quartier de l\'adresse est sauvegardé dans la boutique.';
$_MODULE['<{payzen}prestashop>refund_6d789b879990e5f4c52eb9aa38f1f10b'] = 'Rembourser l\'acheteur par Web Services avec %s';
$_MODULE['<{payzen}prestashop>refund_bc_6d789b879990e5f4c52eb9aa38f1f10b'] = 'Rembourser l\'acheteur par Web Services avec %s';
$_MODULE['<{payzen}prestashop>row_multi_option_f2a6c498fb90ee345d997f888fce3b18'] = 'Supprimer';
Expand Down
6 changes: 6 additions & 0 deletions payzen/translations/pt.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,12 @@
$_MODULE['<{payzen}prestashop>back_office_42ed277b2d23ac14d5d6a9f2e8fe6141'] = 'Valor máximo para propor o meio de pagamento.';
$_MODULE['<{payzen}prestashop>back_office_0b68d09900a5d634731c294747dd52d3'] = 'Se você ativar esta opção, a forma de pagamento será exibida em um Smartform. Atenção, nem todos os meios de pagamento disponíveis são suportados pelo Smartform. Para maiores informações, consulte a documentação do módulo.';
$_MODULE['<{payzen}prestashop>back_office_c9cc8cce247e49bae79f15173ce97354'] = 'Salvar';
$_MODULE['<{payzen}prestashop>back_office_f4f0f2856a5a0ecb77b781f508f389bc'] = 'Campo CPF/CNPJ';
$_MODULE['<{payzen}prestashop>back_office_8289d453954e51b0f2c08aafa63edde7'] = 'Campo personalizado onde o CPF/CNPJ é salvo na loja.';
$_MODULE['<{payzen}prestashop>back_office_d22c3279d5e4b4965e00f74ac950275e'] = 'Campo do número de endereço';
$_MODULE['<{payzen}prestashop>back_office_1ca3be7d867a113084017262b5a82432'] = 'Campo personalizado onde o número de endereço é guardado na loja.';
$_MODULE['<{payzen}prestashop>back_office_71d0e1e74023b945415a441e3be21169'] = 'Campo para bairro';
$_MODULE['<{payzen}prestashop>back_office_75e603c964afa4529a36b2eb37694240'] = 'Campo personalizado onde a bairro do endereço é guardado na loja.';
$_MODULE['<{payzen}prestashop>refund_6d789b879990e5f4c52eb9aa38f1f10b'] = 'Reembolsar o comprador por Web Services com%s';
$_MODULE['<{payzen}prestashop>refund_bc_6d789b879990e5f4c52eb9aa38f1f10b'] = 'Reembolsar o comprador por Web services com %s';
$_MODULE['<{payzen}prestashop>row_multi_option_f2a6c498fb90ee345d997f888fce3b18'] = 'Apagar';
Expand Down
Loading

0 comments on commit e5a961c

Please sign in to comment.