Skip to content

Commit

Permalink
Merge pull request #214 from pay-now/release/1.7.8
Browse files Browse the repository at this point in the history
Release/1.7.8
  • Loading branch information
DeveloperMovecloser authored Aug 12, 2024
2 parents 2e89067 + e06ad4d commit 72bc371
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 9 deletions.
4 changes: 4 additions & 0 deletions classes/PaynowAdminFormHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,10 @@ private function getForm(): array
'id_option' => 'DIGITAL_WALLETS',
'name' => $this->translations['Digital wallets']
],
[
'id_option' => Paynow\Model\PaymentMethods\Type::PAYPO,
'name' => $this->module->getPaymentMethodTitle(Paynow\Model\PaymentMethods\Type::PAYPO)
]
],
'id' => 'id_option',
'name' => 'name'
Expand Down
57 changes: 55 additions & 2 deletions classes/PaynowPaymentDataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ private function build(
): array {
$currency = Currency::getCurrency($id_currency);
$customer = new Customer((int)$id_customer);
$paymentMethodId = Tools::getValue('paymentMethodId');

$request = [
'amount' => number_format($total_to_paid * 100, 0, '', ''),
Expand All @@ -114,12 +115,64 @@ private function build(
)
];

try {
$address = new Address($this->context->cart->id_address_delivery);
$invoiceAddress = new Address($this->context->cart->id_address_invoice);

try {
$state = new State($address->id_state);
} catch (Throwable $e) {
$state = null;
}

try {
$invoiceState = new State($invoiceAddress->id_state);
} catch (Throwable $e) {
$invoiceState = null;
}

try {
$country = Country::getIsoById($address->id_country);
} catch (Throwable $e) {
$country = null;
}

try {
$invoiceCountry = Country::getIsoById($invoiceAddress->id_country);
} catch (Throwable $e) {
$invoiceCountry = null;
}

$request['buyer']['address'] = [
'billing' => [
'street' => $invoiceAddress->address1,
'houseNumber' => $invoiceAddress->address2,
'apartmentNumber' => '',
'zipcode' => $invoiceAddress->postcode,
'city' => $invoiceAddress->city,
'county' => $invoiceState ? $invoiceState->name : '',
'country' => $invoiceCountry ?: '',
],
'shipping' => [
'street' => $address->address1,
'houseNumber' => $address->address2,
'apartmentNumber' => '',
'zipcode' => $address->postcode,
'city' => $address->city,
'county' => $state ? $state->name : '',
'country' => $country ?: '',
]
];
} catch (Throwable $exception) {
PaynowLogger::error('Cannot add addresses to payment data', ['msg' => $exception->getMessage()]);
}

if (!empty($id_customer) && $this->context->customer && $this->context->customer->is_guest === '0'){
$request['buyer']['externalId'] = PaynowKeysGenerator::generateBuyerExternalId($id_customer, $this->module);
}

if (! empty(Tools::getValue('paymentMethodId'))) {
$request['paymentMethodId'] = (int)Tools::getValue('paymentMethodId');
if (! empty($paymentMethodId)) {
$request['paymentMethodId'] = (int)$paymentMethodId;
}

if (Configuration::get('PAYNOW_PAYMENT_VALIDITY_TIME_ENABLED')) {
Expand Down
12 changes: 11 additions & 1 deletion classes/PaynowPaymentOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,13 @@ private function setUpAdditionalTemplateVariables($payment_method)
'default_card_image' => Media::getMediaPath(_PS_MODULE_DIR_ . $this->module->name . '/views/img/card-default.svg'),
'paynow_card_instruments' => $payment_method->getSavedInstruments(),
]);
}
} elseif (Paynow\Model\PaymentMethods\Type::PAYPO == $payment_method->getType()) {
$this->context->smarty->assign([
'action_paypo' => PaynowLinkHelper::getPaymentUrl([
'paymentMethodId' => $payment_method->getId()
]),
]);
}
}

private function getForm($payment_method): ?string
Expand All @@ -185,6 +191,10 @@ private function getForm($payment_method): ?string
return 'module:paynow/views/templates/front/1.7/payment_method_card_form.tpl';
}

if (Paynow\Model\PaymentMethods\Type::PAYPO === $payment_method->getType()) {
return 'module:paynow/views/templates/front/1.7/payment_method_paypo_form.tpl';
}

return null;
}

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
}
],
"require": {
"php": ">=7.1",
"php": ">=7.2",
"ext-json": "*",
"pay-now/paynow-php-sdk": "^2.3.1",
"pay-now/paynow-php-sdk": "^2.4.1",
"nyholm/psr7": "^1.2",
"php-http/curl-client": "^2.1"
},
Expand All @@ -22,7 +22,7 @@
},
"config": {
"platform": {
"php": "7.1"
"php": "7.2"
},
"prepend-autoloader": false,
"optimize-autoloader": true
Expand Down
4 changes: 3 additions & 1 deletion paynow.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct()
{
$this->name = 'paynow';
$this->tab = 'payments_gateways';
$this->version = '1.7.7';
$this->version = '1.7.8';
$this->ps_versions_compliancy = ['min' => '1.6.0', 'max' => _PS_VERSION_];
$this->author = 'mElements S.A.';
$this->is_eu_compatible = 1;
Expand Down Expand Up @@ -383,6 +383,8 @@ public function getPaymentMethodTitle($payment_method_type): string
return $this->l('Pay by Apple Pay');
case 'DIGITAL_WALLETS':
return $this->l('Pay by digital wallets');
case \Paynow\Model\PaymentMethods\Type::PAYPO:
return $this->l('PayPo - buy now, pay later');
}
}

Expand Down
1 change: 1 addition & 0 deletions translations/pl.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
$_MODULE['<{paynow}prestashop>paynow_2a34963732b2fea04f1417120be393ae'] = 'Płatność Google Pay';
$_MODULE['<{paynow}prestashop>paynow_111999b13ca63380771744ea02c4906b'] = 'Płatność Apple Pay';
$_MODULE['<{paynow}prestashop>paynow_80f5e0ec61eb764d2c250d5c1c96da57'] = 'Płatność portfelami cyfrowymi';
$_MODULE['<{paynow}prestashop>paynow_6b46e5850b6a6bf8af7118c5f21cd916'] = 'PayPo - kup teraz, zapłać później';
$_MODULE['<{paynow}prestashop>paynow_428a1abd50e8dadb4fdc0f3861dbe04b'] = 'Zleć zwrot środków przez paynow.pl';
$_MODULE['<{paynow}prestashop>paynow_dc34c9c3d4e62630ad62b58828cae5d8'] = 'Musisz wprowadzić klucze integracyjne';
$_MODULE['<{paynow}prestashop>paynow_aaca790b3b211a66ee5ddb51b817cbf2'] = 'Czas ważności płatności musi być większy niż 60 i mniejszy niż 86400 sekund.';
Expand Down
2 changes: 1 addition & 1 deletion upgrade/upgrade-1.7.7.php → upgrade/upgrade-1.7.8.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* @throws PrestaShopDatabaseException
*/
function upgrade_module_1_7_7($module)
function upgrade_module_1_7_8($module)
{
try {

Expand Down
2 changes: 1 addition & 1 deletion views/css/front.css
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ p.payment_module.paynow button:after {
}

.payment-option img {
max-height: 1.5rem !important;
max-height: 1rem !important;
max-width: 80px !important;
height: auto !important;
margin-right: 10px;
Expand Down
Binary file modified views/img/logo-paynow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions views/templates/front/1.7/payment_method_paypo_form.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{*
* NOTICE OF LICENSE
*
* This source file is subject to the MIT License (MIT)
* that is bundled with this package in the file LICENSE.md.
*
* @author mElements S.A.
* @copyright mElements S.A.
* @license MIT License
*}
<form class="payment-form paynow-payment-form" method="POST" action="{$action_paypo}">
<div class="paynow-payment-option-container">
{include file="module:paynow/views/templates/front/1.7/_partials/payment_data_processing_info.tpl"}
</div>
</form>

0 comments on commit 72bc371

Please sign in to comment.