Skip to content
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

Release 1.1.8 #139

Merged
merged 26 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1081705
authorize error on iframe payment method
mant02 Nov 23, 2023
b767741
fix
mant02 Nov 23, 2023
1ca6db8
Merge pull request #131 from Invertus/SL-197-authorize-error-on-iframe
mant02 Nov 23, 2023
891a113
SL-ą„“-saferpay-email-sending
mant02 Nov 24, 2023
644616a
fix
mant02 Nov 24, 2023
20b383c
SL-192-new-description-field
mant02 Nov 24, 2023
5f13f85
SL-196-payment-method-invoice-append
mant02 Dec 8, 2023
cf7181f
SL-203-match-shop-language-with-iframe
mant02 Dec 8, 2023
e456b75
update
mant02 Dec 12, 2023
0f6a67f
Merge pull request #132 from Invertus/SL-190-saferpay-payer-email
mant02 Dec 12, 2023
26a77fb
added string cast
mant02 Dec 12, 2023
eace5e5
Merge pull request #133 from Invertus/SL-192-new-description-field
mant02 Dec 12, 2023
2ae7b3d
update
mant02 Dec 12, 2023
c210cc5
Merge pull request #134 from Invertus/SL-196-payment-method-invoice-a…
mant02 Dec 12, 2023
6f851d1
Merge pull request #135 from Invertus/SL-203-match-shop-language-with…
mant02 Dec 12, 2023
1cd100e
SL-206: apple pay desktop
mant02 Dec 12, 2023
8fdc3f9
update
mant02 Dec 12, 2023
52db2b7
cast
mant02 Dec 12, 2023
4b9da01
remove comment
mant02 Dec 12, 2023
1499dad
Merge pull request #137 from Invertus/SL-206-apple-pay-desktop
mant02 Dec 12, 2023
f1270d7
SL-205: API version increase
mant02 Dec 13, 2023
e4520b6
updated config
mant02 Dec 13, 2023
956318c
update
mant02 Dec 13, 2023
f20b786
Merge pull request #138 from Invertus/SL-205-API-version-increase
mant02 Dec 19, 2023
079e868
changelog update
mant02 Dec 19, 2023
0c33d7d
Merge branch '1.2.0' into release_1_1_8
GytisZum Jan 11, 2024
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
9 changes: 8 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,12 @@
- BO : Added PrestaShop module security validations
- FO : Added PrestaShop module security validations

## [1.1.8] - *
- BO : Added a toggle setting for Saferpay email sending option
- BO : Added a configuration field for the customization of the description parameter
- BO : Increased module's API version
- BO : Added a more descriptive payment method name in invoices
- BO : Additional improvements and fixes

- ## [1.2.0] - *
- BO : Added order creation after authorization functionality
- BO : Added order creation after authorization functionality
36 changes: 36 additions & 0 deletions controllers/admin/AdminSaferPayOfficialSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

class AdminSaferPayOfficialSettingsController extends ModuleAdminController
{
const FILE_NAME = 'AdminSaferPayOfficialSettingsController';

public function __construct()
{
parent::__construct();
Expand Down Expand Up @@ -327,6 +329,13 @@ public function initOptions()
'cast' => 'intval',
'type' => 'bool',
],
SaferPayConfig::SAFERPAY_ALLOW_SAFERPAY_SEND_CUSTOMER_MAIL => [
'title' => $this->l('Send an email from Saferpay on payment completion'),
'desc' => $this->l('With this setting enabled an email from the Saferpay system will be sent to the customer'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool',
],
SaferPayConfig::SAFERPAY_SEND_NEW_ORDER_MAIL => [
'title' => $this->l('Send new order mail on authorization'),
'desc' => $this->l('Receive a notification when an order is authorized by Saferpay (Using the Mail alert module)'),
Expand All @@ -352,6 +361,7 @@ public function initOptions()
}

$this->fields_options[] = $this->getFieldOptionsOrderState();
$this->fields_options[] = $this->displayConfigurationSettings();
}

private function getFieldOptionsOrderState()
Expand Down Expand Up @@ -385,6 +395,32 @@ private function getFieldOptionsOrderState()
];
}

/**
* @return array
*/
private function displayConfigurationSettings()
{
return [
'title' => $this->module->l('Configuration', self::FILE_NAME),
'fields' => [
SaferPayConfig::SAFERPAY_PAYMENT_DESCRIPTION => [
'title' => $this->module->l('Description', self::FILE_NAME),
'type' => 'text',
'desc' => 'This description is visible in payment page also in payment confirmation email',
'class' => 'fixed-width-xxl'
],
],
'buttons' => [
'save_and_connect' => [
'title' => $this->module->l('Save', self::FILE_NAME),
'icon' => 'process-icon-save',
'class' => 'btn btn-default pull-right',
'type' => 'submit',
],
],
];
}

public function setMedia($isNewTheme = false)
{
parent::setMedia($isNewTheme);
Expand Down
21 changes: 19 additions & 2 deletions controllers/front/successIFrame.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function postProcess()
'cartId' => $cartId,
'secureKey' => $secureKey,
'orderId' => $orderId,
\Invertus\SaferPay\Config\SaferPayConfig::IS_BUSINESS_LICENCE => true,
'moduleId' => $moduleId,
],
true
));
Expand Down Expand Up @@ -115,7 +115,24 @@ public function postProcess()
));
}

$orderStatusService->authorize($order);
try {
$orderStatusService->authorize($order);

Tools::redirect($this->getOrderConfirmationLink($cartId, $moduleId, $orderId, $secureKey));
} catch (Exception $exception) {
$this->warning[] = $this->module->l('We couldn\'t authorize your payment. Please try again.', self::FILENAME);
$this->redirectWithNotifications($this->context->link->getModuleLink(
$this->module->name,
ControllerName::FAIL_IFRAME,
[
'cartId' => $cartId,
'secureKey' => $secureKey,
'orderId' => $orderId,
'moduleId' => $moduleId,
],
true
));
}

$paymentBehaviour = (int) Configuration::get(SaferPayConfig::PAYMENT_BEHAVIOR);

Expand Down
41 changes: 41 additions & 0 deletions saferpayofficial.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,47 @@ public function getService($service)
return $containerProvider->getService($service);
}

public function hookActionObjectOrderPaymentAddAfter($params)
{
if (!isset($params['object'])) {
return;
}

/** @var OrderPayment $orderPayment */
$orderPayment = $params['object'];

if (!Validate::isLoadedObject($orderPayment)) {
return;
}

/** @var \Invertus\SaferPay\Repository\SaferPayOrderRepository $saferPayOrderRepository */
$saferPayOrderRepository = $this->getService(\Invertus\SaferPay\Repository\SaferPayOrderRepository::class);

$orders = Order::getByReference($orderPayment->order_reference);

/** @var Order|bool $order */
$order = $orders->getFirst();

if (!Validate::isLoadedObject($order) || !$order) {
return;
}

$saferPayOrderId = (int) $saferPayOrderRepository->getIdByOrderId($order->id);

if (!$saferPayOrderId) {
return;
}

$brand = $saferPayOrderRepository->getPaymentBrandBySaferpayOrderId($saferPayOrderId);

if (!$brand) {
return;
}

$orderPayment->payment_method = 'Saferpay - ' . $brand;
$orderPayment->update();
}

public function hookPaymentOptions($params)
{
/** @var Invertus\SaferPay\Service\SaferPayCartService $assertService */
Expand Down
2 changes: 1 addition & 1 deletion src/Api/ApiRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ApiRequest
*
* @param string $url
* @param array $params
* @return array |null
* @return object|null
* @throws Exception
*/
public function post($url, $params = [])
Expand Down
11 changes: 8 additions & 3 deletions src/Api/Request/AssertService.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function __construct(
* @param AssertRequest $assertRequest
* @param int $saferPayOrderId
*
* @return array|null
* @return object|null
* @throws \Exception
*/
public function assert(AssertRequest $assertRequest, $saferPayOrderId)
Expand All @@ -78,8 +78,13 @@ public function assert(AssertRequest $assertRequest, $saferPayOrderId)

$assertApi = self::ASSERT_API_PAYMENT;

//TODO: refactor this to use authorize request.
// naming is weird. With transaction, we do a request to an authorize endpoint but name it assert ?
// also we call authorize method in some of the success controllers, so if we leave the logic here,
// we get an error with TRANSACTION_IN_WRONG_STATE
if ($saferPayOrder->is_transaction) {
$assertApi = self::ASSERT_API_TRANSACTION;
return null;
// $assertApi = self::ASSERT_API_TRANSACTION;
}

try {
Expand All @@ -93,7 +98,7 @@ public function assert(AssertRequest $assertRequest, $saferPayOrderId)
}

/**
* @param object $responseBody
* @param object|null $responseBody
* @param int $saferPayOrderId
*
* @return AssertBody
Expand Down
35 changes: 21 additions & 14 deletions src/Config/SaferPayConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SaferPayConfig
const CONFIGURATION_NAME = 'SAFERPAY_CONFIGURATION_NAME';
const CSS_FILE = 'SAFERPAY_CSS_FILE';
const TEST_SUFFIX = '_TEST';
const API_VERSION = 1.32;
const API_VERSION = 1.37;
const PAYMENT_METHODS = [
self::PAYMENT_ALIPAY,
self::PAYMENT_AMEX,
Expand All @@ -72,7 +72,6 @@ class SaferPayConfig
self::PAYMENT_POSTFINANCE,
self::PAYMENT_SOFORT,
self::PAYMENT_TWINT,
self::PAYMENT_UNIONPAY,
self::PAYMENT_VISA,
self::PAYMENT_VPAY,
self::PAYMENT_APPLEPAY,
Expand Down Expand Up @@ -100,21 +99,22 @@ class SaferPayConfig
const PAYMENT_POSTFINANCE = 'POSTFINANCE';
const PAYMENT_SOFORT = 'SOFORT';
const PAYMENT_TWINT = 'TWINT';
const PAYMENT_UNIONPAY = 'UNIONPAY';
const PAYMENT_VISA = 'VISA';
const PAYMENT_VPAY = 'VPAY';
const PAYMENT_KLARNA = 'KLARNA';
const PAYMENT_APPLEPAY = 'APPLEPAY';
const PAYMENT_WLCRYPTOPAYMENTS = 'WLCRYPTOPAYMENTS';
const PAYMENT_GOOGLEPAY = 'GOOGLEPAY';
const PAYMENT_MASTERPASS = 'MASTERPASS';
const PAYMENT_BONUS = 'BONUS';
const PAYMENT_LASTSCHRIFT = 'DIRECTDEBIT';
const PAYMENT_ACCOUNTTOACCOUNT = 'ACCOUNTTOACCOUNT';
const PAYMENT_PAYCONIQ = 'PAYCONIQ';
const PAYMENT_CARD = 'CARD';
const PAYMENT_POSTFINANCE_PAY = 'POSTFINANCEPAY';

const WALLET_PAYMENT_METHODS = [
self::PAYMENT_APPLEPAY,
self::PAYMENT_GOOGLEPAY,
self::PAYMENT_MASTERPASS,
];

const PAYMENT_METHODS_KEYS = [
Expand All @@ -127,18 +127,20 @@ class SaferPayConfig
'KlarnaPayments' => self::PAYMENT_KLARNA,
'MaestroInternational' => self::PAYMENT_MAESTRO,
'Mastercard' => self::PAYMENT_MASTERCARD,
'Masterpass' =>self::PAYMENT_MASTERPASS,
'myOne' => self::PAYMENT_MYONE,
'paydirekt' => self::PAYMENT_PAYDIREKT,
'PayPal' => self::PAYMENT_PAYPAL,
'Twint' => self::PAYMENT_TWINT,
'UnionPay' => self::PAYMENT_UNIONPAY,
'Visa' => self::PAYMENT_VISA,
'WLCryptoPayments' => self::PAYMENT_WLCRYPTOPAYMENTS,
'Postcard' => self::PAYMENT_POSTCARD,
'BonusCard' => self::PAYMENT_BONUS,
'Lastschrift' => self::PAYMENT_LASTSCHRIFT,
'SOFORTUEBERWEISUNG' => self::PAYMENT_SOFORT,
'AccountToAccount' => self::PAYMENT_ACCOUNTTOACCOUNT,
'Payconiq' => self::PAYMENT_PAYCONIQ,
'Card' => self::PAYMENT_CARD,
'PostFinancePay' => self::PAYMENT_POSTFINANCE_PAY,
];

const FIELD_SUPPORTED_PAYMENT_METHODS = [
Expand Down Expand Up @@ -204,12 +206,12 @@ class SaferPayConfig
self::PAYMENT_MASTERCARD,
self::PAYMENT_VISA,
self::PAYMENT_VPAY,
self::PAYMENT_UNIONPAY,
self::PAYMENT_APPLEPAY,
self::PAYMENT_AMEX,
];

const WEB_SERVICE_PASSWORD_PLACEHOLDER = '••••••';

const SAFERPAY_PAYMENT_COMPLETED = 'SAFERPAY_PAYMENT_COMPLETED';
const SAFERPAY_PAYMENT_AUTHORIZED = 'SAFERPAY_PAYMENT_AUTHORIZED';
const SAFERPAY_PAYMENT_REJECTED = 'SAFERPAY_PAYMENT_REJECTED';
Expand All @@ -219,14 +221,19 @@ class SaferPayConfig
const SAFERPAY_PAYMENT_PENDING_REFUND = 'SAFERPAY_PAYMENT_PENDING_REFUND';
const SAFERPAY_PAYMENT_CANCELED = 'SAFERPAY_PAYMENT_CANCELED';
const SAFERPAY_PAYMENT_AUTHORIZATION_FAILED = 'SAFERPAY_PAYMENT_AUTHORIZATION_FAILED';

const SAFERPAY_SEND_ORDER_CONFIRMATION = 'SAFERPAY_SEND_ORDER_CONFIRMATION';
const SAFERPAY_SEND_NEW_ORDER_MAIL = 'SAFERPAY_SEND_NEW_ORDER_MAIL';
const SAFERPAY_ALLOW_SAFERPAY_SEND_CUSTOMER_MAIL = 'SAFERPAY_ALLOW_SAFERPAY_SEND_CUSTOMER_MAIL';
const SAFERPAY_ORDER_CREATION_AFTER_AUTHORIZATION = 'SAFERPAY_ORDER_CREATION_AFTER_AUTHORIZATION';

const STATUS_PS_OS_OUTOFSTOCK_PAID = 'PS_OS_OUTOFSTOCK_PAID';

const SAFERPAY_ORDER_STATE_CHOICE_AWAITING_PAYMENT = 'SAFERPAY_ORDER_STATE_CHOICE_AWAITING_PAYMENT';

const SAFERPAY_PAYMENT_DESCRIPTION = 'SAFERPAY_PAYMENT_DESCRIPTION';
const SAFERPAY_PAYMENT_DESCRIPTION_DEFAULT_VALUE = 'Prestashop Payment';

const SAFERPAY_TEMPLATE_LOCATION = 'module:saferpayofficial/views/templates/';
const SAFERPAY_HOSTED_TEMPLATE_LOCATION = 'module:saferpayofficial/views/templates/front/hosted-templates/';

Expand All @@ -241,10 +248,6 @@ class SaferPayConfig
const TRANSACTION_STATUS_PENDING = 'PENDING';
const TRANSACTION_STATUS_CANCELED = 'CANCELED';

const LOG_TYPE_SUCCESS = 'SUCCESS';
const LOG_TYPE_ERROR = 'ERROR';
const LOG_TYPE_CRITICAL_ERROR = 'CRITICAL ERROR';

const FIELDS_ACCESS_TOKEN = 'SAFERPAY_FIELDS_ACCESS_TOKEN';
const FIELDS_LIBRARY = 'SAFERPAY_FIELDS_JAVASCRIPT_LIBRARY';
const FIELDS_LIBRARY_DEFAULT_VALUE = 'https://www.saferpay.com/Fields/lib/1/saferpay-fields.js';
Expand Down Expand Up @@ -331,12 +334,14 @@ public static function getBaseUrl()
public static function getDefaultConfiguration()
{
return [
RequestHeader::SPEC_VERSION => '1.32',
RequestHeader::SPEC_REFUND_VERSION => '1.32',
RequestHeader::SPEC_VERSION => '1.37',
RequestHeader::SPEC_REFUND_VERSION => '1.37',
RequestHeader::RETRY_INDICATOR => 0,
SaferPayConfig::PAYMENT_BEHAVIOR => 1,
SaferPayConfig::PAYMENT_BEHAVIOR_WITHOUT_3D => 1,
SaferPayConfig::SAFERPAY_SEND_ORDER_CONFIRMATION => 1,
SaferPayConfig::SAFERPAY_ALLOW_SAFERPAY_SEND_CUSTOMER_MAIL => 1,
SaferPayConfig::SAFERPAY_PAYMENT_DESCRIPTION => self::SAFERPAY_PAYMENT_DESCRIPTION_DEFAULT_VALUE,
SaferPayConfig::FIELDS_LIBRARY => self::FIELDS_LIBRARY_DEFAULT_VALUE,
SaferPayConfig::FIELDS_LIBRARY . SaferPayConfig::TEST_SUFFIX => self::FIELDS_LIBRARY_TEST_DEFAULT_VALUE,
self::SAFERPAY_ORDER_CREATION_AFTER_AUTHORIZATION => 0,
Expand All @@ -354,6 +359,8 @@ public static function getUninstallConfiguration()
RequestHeader::SPEC_VERSION,
RequestHeader::RETRY_INDICATOR,
RequestHeader::SPEC_REFUND_VERSION,
self::SAFERPAY_ALLOW_SAFERPAY_SEND_CUSTOMER_MAIL,
self::SAFERPAY_PAYMENT_DESCRIPTION,
self::TEST_MODE,
self::USERNAME,
self::PASSWORD,
Expand Down
2 changes: 2 additions & 0 deletions src/DTO/Request/Assert/AssertRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
exit;
}

// TODO: A lot of these request are the same, we can at least put them under an interface

class AssertRequest
{

Expand Down
5 changes: 4 additions & 1 deletion src/DTO/Request/Initialize/InitializeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,14 @@ public function getAsArray()

if ($this->notification !== null) {
$return['Notification'] = [
'PayerEmail' => $this->notification->getPayerEmail(),
'MerchantEmails' => [$this->notification->getMerchantEmail()],
'SuccessNotifyUrl' => $this->notification->getNotifyUrl(),
'FailNotifyUrl' => $this->notification->getNotifyUrl(),
];

if (\Configuration::get(SaferPayConfig::SAFERPAY_ALLOW_SAFERPAY_SEND_CUSTOMER_MAIL)) {
$return['Notification'] = ['PayerEmail' => $this->notification->getPayerEmail()];
}
}

if ($this->configSet) {
Expand Down
8 changes: 4 additions & 4 deletions src/DTO/Request/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ class Payment
private $payerNote = null;

/**
* @var null
* @var string
*/
private $description = 'PrestaShop payment';
private $description;

/**
* @return string
Expand Down Expand Up @@ -119,15 +119,15 @@ public function setPayerNote($payerNote)
}

/**
* @return null
* @return string
*/
public function getDescription()
{
return $this->description;
}

/**
* @param null $description
* @param string $description
*/
public function setDescription($description)
{
Expand Down
Loading
Loading