diff --git a/changelog.md b/changelog.md index 89c98abd..8760bdef 100755 --- a/changelog.md +++ b/changelog.md @@ -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 \ No newline at end of file diff --git a/controllers/admin/AdminSaferPayOfficialSettingsController.php b/controllers/admin/AdminSaferPayOfficialSettingsController.php index 94b3d7b1..dd83b297 100755 --- a/controllers/admin/AdminSaferPayOfficialSettingsController.php +++ b/controllers/admin/AdminSaferPayOfficialSettingsController.php @@ -30,6 +30,8 @@ class AdminSaferPayOfficialSettingsController extends ModuleAdminController { + const FILE_NAME = 'AdminSaferPayOfficialSettingsController'; + public function __construct() { parent::__construct(); @@ -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)'), @@ -352,6 +361,7 @@ public function initOptions() } $this->fields_options[] = $this->getFieldOptionsOrderState(); + $this->fields_options[] = $this->displayConfigurationSettings(); } private function getFieldOptionsOrderState() @@ -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); diff --git a/controllers/front/successIFrame.php b/controllers/front/successIFrame.php index 8ede330d..1916c9c3 100755 --- a/controllers/front/successIFrame.php +++ b/controllers/front/successIFrame.php @@ -84,7 +84,7 @@ public function postProcess() 'cartId' => $cartId, 'secureKey' => $secureKey, 'orderId' => $orderId, - \Invertus\SaferPay\Config\SaferPayConfig::IS_BUSINESS_LICENCE => true, + 'moduleId' => $moduleId, ], true )); @@ -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); diff --git a/saferpayofficial.php b/saferpayofficial.php index 4aa213ad..145e8e78 100755 --- a/saferpayofficial.php +++ b/saferpayofficial.php @@ -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 */ diff --git a/src/Api/ApiRequest.php b/src/Api/ApiRequest.php index 14e4fed5..a3526737 100755 --- a/src/Api/ApiRequest.php +++ b/src/Api/ApiRequest.php @@ -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 = []) diff --git a/src/Api/Request/AssertService.php b/src/Api/Request/AssertService.php index 50563d3e..8ec796db 100755 --- a/src/Api/Request/AssertService.php +++ b/src/Api/Request/AssertService.php @@ -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) @@ -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 { @@ -93,7 +98,7 @@ public function assert(AssertRequest $assertRequest, $saferPayOrderId) } /** - * @param object $responseBody + * @param object|null $responseBody * @param int $saferPayOrderId * * @return AssertBody diff --git a/src/Config/SaferPayConfig.php b/src/Config/SaferPayConfig.php index f7279ff1..6cf6f69e 100755 --- a/src/Config/SaferPayConfig.php +++ b/src/Config/SaferPayConfig.php @@ -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, @@ -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, @@ -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 = [ @@ -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 = [ @@ -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'; @@ -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/'; @@ -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'; @@ -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, @@ -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, diff --git a/src/DTO/Request/Assert/AssertRequest.php b/src/DTO/Request/Assert/AssertRequest.php index 5b3b90c7..0ed01f54 100755 --- a/src/DTO/Request/Assert/AssertRequest.php +++ b/src/DTO/Request/Assert/AssertRequest.php @@ -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 { diff --git a/src/DTO/Request/Initialize/InitializeRequest.php b/src/DTO/Request/Initialize/InitializeRequest.php index 9b10f015..192dee0f 100755 --- a/src/DTO/Request/Initialize/InitializeRequest.php +++ b/src/DTO/Request/Initialize/InitializeRequest.php @@ -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) { diff --git a/src/DTO/Request/Payment.php b/src/DTO/Request/Payment.php index aeaa7247..5b3f910c 100755 --- a/src/DTO/Request/Payment.php +++ b/src/DTO/Request/Payment.php @@ -50,9 +50,9 @@ class Payment private $payerNote = null; /** - * @var null + * @var string */ - private $description = 'PrestaShop payment'; + private $description; /** * @return string @@ -119,7 +119,7 @@ public function setPayerNote($payerNote) } /** - * @return null + * @return string */ public function getDescription() { @@ -127,7 +127,7 @@ public function getDescription() } /** - * @param null $description + * @param string $description */ public function setDescription($description) { diff --git a/src/DTO/Response/ThreeDs.php b/src/DTO/Response/ThreeDs.php index e764ff03..cd69013a 100755 --- a/src/DTO/Response/ThreeDs.php +++ b/src/DTO/Response/ThreeDs.php @@ -34,11 +34,6 @@ class ThreeDs */ private $authenticated; - /** - * @var string|null - */ - private $liabilityShift; - /** * @var string|null */ @@ -52,14 +47,12 @@ class ThreeDs /** * ThreeDs constructor. * @param string $authenticated - * @param string $liabilityShift * @param string $xid * @param string $verificationValue */ - public function __construct($authenticated = null, $liabilityShift = null, $xid = null, $verificationValue = null) + public function __construct($authenticated = null, $xid = null, $verificationValue = null) { $this->authenticated = $authenticated; - $this->liabilityShift = $liabilityShift; $this->xid = $xid; $this->verificationValue = $verificationValue; } @@ -80,22 +73,6 @@ public function setAuthenticated($authenticated) $this->authenticated = $authenticated; } - /** - * @return mixed - */ - public function getLiabilityShift() - { - return $this->liabilityShift; - } - - /** - * @param mixed $liabilityShift - */ - public function setLiabilityShift($liabilityShift) - { - $this->liabilityShift = $liabilityShift; - } - /** * @return mixed */ diff --git a/src/Install/Installer.php b/src/Install/Installer.php index 962cdd72..0e37ed4e 100755 --- a/src/Install/Installer.php +++ b/src/Install/Installer.php @@ -95,6 +95,7 @@ private function registerHooks() $this->module->registerHook('displayAdminOrderTabContent'); $this->module->registerHook('actionAdminControllerSetMedia'); $this->module->registerHook('actionOrderStatusUpdate'); + $this->module->registerHook('actionObjectOrderPaymentAddAfter'); } private function installConfiguration() diff --git a/src/Repository/SaferPayOrderRepository.php b/src/Repository/SaferPayOrderRepository.php index 1223aeaf..ae51aa3f 100755 --- a/src/Repository/SaferPayOrderRepository.php +++ b/src/Repository/SaferPayOrderRepository.php @@ -75,4 +75,14 @@ public function getOrderRefunds($saferPayOrderId) return Db::getInstance()->executeS($query); } + + public function getPaymentBrandBySaferpayOrderId($saferpayOrderId) + { + $query = new DbQuery(); + $query->select('`brand`'); + $query->from('saferpay_assert'); + $query->where('id_saferpay_order = "' . (int) $saferpayOrderId . '"'); + + return Db::getInstance()->getValue($query); + } } diff --git a/src/Service/LegacyTranslator.php b/src/Service/LegacyTranslator.php index d6b31d2b..96a0e1b8 100755 --- a/src/Service/LegacyTranslator.php +++ b/src/Service/LegacyTranslator.php @@ -72,12 +72,15 @@ private function getTranslations() SaferPayConfig::PAYMENT_POSTFINANCE => $this->module->l('Postfinance', self::FILE_NAME), SaferPayConfig::PAYMENT_SOFORT => $this->module->l('Sofort', self::FILE_NAME), SaferPayConfig::PAYMENT_TWINT => $this->module->l('Twint', self::FILE_NAME), - SaferPayConfig::PAYMENT_UNIONPAY => $this->module->l('Unionpay', self::FILE_NAME), SaferPayConfig::PAYMENT_VISA => $this->module->l('Visa', self::FILE_NAME), SaferPayConfig::PAYMENT_VPAY => $this->module->l('Vpay', self::FILE_NAME), SaferPayConfig::PAYMENT_APPLEPAY => $this->module->l('Applepay', self::FILE_NAME), SaferPayConfig::PAYMENT_KLARNA => $this->module->l('Klarna', self::FILE_NAME), SaferPayConfig::PAYMENT_WLCRYPTOPAYMENTS => $this->module->l('Cryptocurrencies', self::FILE_NAME), + SaferPayConfig::PAYMENT_ACCOUNTTOACCOUNT => $this->module->l('AccountToAccount', self::FILE_NAME), + SaferPayConfig::PAYMENT_PAYCONIQ => $this->module->l('Payconiq', self::FILE_NAME), + SaferPayConfig::PAYMENT_CARD => $this->module->l('Card', self::FILE_NAME), + SaferPayConfig::PAYMENT_POSTFINANCE_PAY => $this->module->l('PostFinancePay', self::FILE_NAME), ]; } } diff --git a/src/Service/PaymentRestrictionValidation/ApplePayPaymentRestrictionValidation.php b/src/Service/PaymentRestrictionValidation/ApplePayPaymentRestrictionValidation.php index 035016ba..6dc84419 100755 --- a/src/Service/PaymentRestrictionValidation/ApplePayPaymentRestrictionValidation.php +++ b/src/Service/PaymentRestrictionValidation/ApplePayPaymentRestrictionValidation.php @@ -80,6 +80,6 @@ private function isMacDesktop() $device = $this->context->getDeviceDetect(); - return $device === \Context::DEVICE_COMPUTER && preg_match('/macintosh|mac os x|mac_powerpc/i', $_SERVER['HTTP_USER_AGENT']) !== false; + return $device === \Context::DEVICE_COMPUTER && (int) preg_match('/macintosh|mac os x|mac_powerpc/i', $_SERVER['HTTP_USER_AGENT']); } } diff --git a/src/Service/Request/InitializeRequestObjectCreator.php b/src/Service/Request/InitializeRequestObjectCreator.php index 805da6b2..8ce62fd9 100755 --- a/src/Service/Request/InitializeRequestObjectCreator.php +++ b/src/Service/Request/InitializeRequestObjectCreator.php @@ -30,6 +30,7 @@ use Invertus\SaferPay\DTO\Request\RequestHeader; use Invertus\SaferPay\DTO\Request\Initialize\InitializeRequest; use Invertus\SaferPay\DTO\Request\Payer; +use PrestaShop\PrestaShop\Adapter\Shop\Context; if (!defined('_PS_VERSION_')) { exit; @@ -68,8 +69,14 @@ public function create( $totalPrice = (int) (round($totalPrice)); $payment = $this->requestObjectCreator->createPayment($cart, $totalPrice); $payer = new Payer(); + + $languageCode = !empty($cart->getAssociatedLanguage()->iso_code) + ? $cart->getAssociatedLanguage()->iso_code + : 'en'; + + $payer->setLanguageCode($languageCode); $returnUrl = $this->requestObjectCreator->createReturnUrl($returnUrl); - $notification = ($isBusinessLicence && version_compare(Configuration::get(RequestHeader::SPEC_VERSION), '1.35', '<')) ? null : $this->requestObjectCreator->createNotification($customerEmail, $notifyUrl); + $notification = $isBusinessLicence ? null : $this->requestObjectCreator->createNotification($customerEmail, $notifyUrl); $deliveryAddressForm = $this->requestObjectCreator->createDeliveryAddressForm(); $configSet = Configuration::get(SaferPayConfig::CONFIGURATION_NAME); $cssUrl = Configuration::get(SaferPayConfig::CSS_FILE); diff --git a/src/Service/Request/RequestObjectCreator.php b/src/Service/Request/RequestObjectCreator.php index abeb061e..2e45878a 100755 --- a/src/Service/Request/RequestObjectCreator.php +++ b/src/Service/Request/RequestObjectCreator.php @@ -125,6 +125,7 @@ public function createPayment(Cart $cart, $totalPrice) /** This param is not mandatory, but recommended **/ $payment->setOrderReference($order->reference); + $payment->setDescription((string) Configuration::get(SaferPayConfig::SAFERPAY_PAYMENT_DESCRIPTION)); return $payment; } diff --git a/src/Service/Response/ResponseObjectCreator.php b/src/Service/Response/ResponseObjectCreator.php index 3b935dbd..6db2cd0e 100755 --- a/src/Service/Response/ResponseObjectCreator.php +++ b/src/Service/Response/ResponseObjectCreator.php @@ -154,7 +154,6 @@ protected function createThreeDs($threeDs) { $threeDsObj = new ThreeDs(); $threeDsObj->setAuthenticated($threeDs->Authenticated); - $threeDsObj->setLiabilityShift($threeDs->LiabilityShift); $threeDsObj->setXid($threeDs->Xid); $threeDsObj->setVerificationValue($threeDs->VerificationValue); @@ -168,7 +167,6 @@ protected function createLiability($liability) $threeDs = $liability->ThreeDs; $threeDsObj = new ThreeDs(); $threeDsObj->setAuthenticated($threeDs->Authenticated); - $threeDsObj->setLiabilityShift($threeDs->LiabilityShift); $threeDsObj->setXid($threeDs->Xid); if (isset($threeDs->VerificationValue)) { $threeDsObj->setVerificationValue($threeDs->VerificationValue); diff --git a/src/Service/TransactionFlow/SaferPayTransactionAssertion.php b/src/Service/TransactionFlow/SaferPayTransactionAssertion.php index 4b3aba86..05667d4c 100755 --- a/src/Service/TransactionFlow/SaferPayTransactionAssertion.php +++ b/src/Service/TransactionFlow/SaferPayTransactionAssertion.php @@ -73,6 +73,10 @@ public function assert($cartId) $assertRequest = $this->assertRequestCreator->create($saferPayOrder->token); $assertResponse = $this->assertionService->assert($assertRequest, $saferPayOrder->id); + if (empty($assertResponse)) { + return null; + } + $assertBody = $this->assertionService->createObjectsFromAssertResponse( $assertResponse, $saferPayOrder->id diff --git a/upgrade/install-1.1.4.php b/upgrade/install-1.1.4.php index 8b710f13..daa84eb9 100644 --- a/upgrade/install-1.1.4.php +++ b/upgrade/install-1.1.4.php @@ -27,7 +27,7 @@ if (!defined('_PS_VERSION_')) { exit; } -function upgrade_module_1_1_4($module) +function upgrade_module_1_1_4() { Configuration::updateValue(RequestHeader::SPEC_VERSION, SaferPayConfig::API_VERSION); Configuration::updateValue(RequestHeader::SPEC_REFUND_VERSION, SaferPayConfig::API_VERSION); diff --git a/upgrade/install-1.1.8.php b/upgrade/install-1.1.8.php new file mode 100644 index 00000000..d52c8914 --- /dev/null +++ b/upgrade/install-1.1.8.php @@ -0,0 +1,44 @@ + + *@copyright SIX Payment Services + *@license SIX Payment Services + */ + +use Invertus\SaferPay\Config\SaferPayConfig; +use Invertus\SaferPay\DTO\Request\RequestHeader; + +if (!defined('_PS_VERSION_')) { + exit; +} +function upgrade_module_1_1_8(SaferPayOfficial $module) +{ + Configuration::updateValue(SaferPayConfig::SAFERPAY_ALLOW_SAFERPAY_SEND_CUSTOMER_MAIL, 1); + Configuration::updateValue( + SaferPayConfig::SAFERPAY_PAYMENT_DESCRIPTION, + SaferPayConfig::SAFERPAY_PAYMENT_DESCRIPTION_DEFAULT_VALUE + ); + + Configuration::updateValue(RequestHeader::SPEC_VERSION, SaferPayConfig::API_VERSION); + Configuration::updateValue(RequestHeader::SPEC_REFUND_VERSION, SaferPayConfig::API_VERSION); + + $module->registerHook('actionObjectOrderPaymentAddAfter'); + + return true; +} \ No newline at end of file