Skip to content

Commit

Permalink
MPGS-570: [Simplify][Prestashop] Tokenisation option is visible for G…
Browse files Browse the repository at this point in the history
…uest on Storefront
  • Loading branch information
riversy committed Dec 28, 2021
1 parent 97f865b commit 904c0fd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion simplifycommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,10 @@ public function installOrderState()
$destination = _PS_ROOT_DIR_.'/img/os/'.(int)$order_state->id.'.gif';
copy($source, $destination);
}

return Configuration::updateValue('SIMPLIFY_OS_AUTHORIZED', (int)$order_state->id);
}

return true;
}

Expand Down Expand Up @@ -417,7 +419,9 @@ public function hookPaymentOptions($params)
$this->initSimplify();

// If flag checked in the settings, look up customer details in the DB
if (Configuration::get('SIMPLIFY_SAVE_CUSTOMER_DETAILS')) {
$isTokenizationEnabled = (bool)Configuration::get('SIMPLIFY_SAVE_CUSTOMER_DETAILS');
$isLogged = $this->context->customer->isLogged();
if ($isTokenizationEnabled && $isLogged) {
$this->smarty->assign('show_save_customer_details_checkbox', true);
$simplify_customer_id = Db::getInstance()->getValue(
'SELECT simplify_customer_id FROM '.
Expand Down Expand Up @@ -456,6 +460,13 @@ public function hookPaymentOptions($params)
// Set js variables to send in card tokenization
$this->smarty->assign('simplify_public_key', Simplify::$publicKey);

$this->smarty->assign('customer_name',
sprintf(
'%s %s',
$this->safe($cardholder_details->firstname),
$this->safe($cardholder_details->lastname)
)
);
$this->smarty->assign('firstname', $this->safe($cardholder_details->firstname));
$this->smarty->assign('lastname', $this->safe($cardholder_details->lastname));
$this->smarty->assign('city', $this->safe($cardholder_details->city));
Expand Down
3 changes: 2 additions & 1 deletion views/templates/front/embedded-payment.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<div>
<script>
var simplifyPublicKey = "{$simplify_public_key|escape:'htmlall':'UTF-8'}",
simplifyCustomerName = "{$customer_name|escape:'htmlall':'UTF-8'}",
simplifyFirstname = "{$firstname|escape:'htmlall':'UTF-8'}",
simplifyLastname = "{$lastname|escape:'htmlall':'UTF-8'}",
simplifyCity = "{$city|escape:'htmlall':'UTF-8'}",
Expand Down Expand Up @@ -170,7 +171,7 @@
data-description="{$hosted_payment_description|escape:'htmlall':'UTF-8'}"
data-reference="{$hosted_payment_reference|escape:'htmlall':'UTF-8'}"
data-amount="{$hosted_payment_amount}"
data-customer-name="{$firstname|escape:'htmlall':'UTF-8'} {$lastname|escape:'htmlall':'UTF-8'}"
data-customer-name="{$customer_name|escape:'htmlall':'UTF-8'}"
data-color="{$overlay_color|escape:'htmlall':'UTF-8'}"
data-currency="{$currency_iso}"
data-operation="create.token">
Expand Down

0 comments on commit 904c0fd

Please sign in to comment.