Skip to content

Commit

Permalink
Merge pull request #116 from Invertus/SL-176/unset-notification-conta…
Browse files Browse the repository at this point in the history
…iner

SL-176: unset notification container for previous API version
  • Loading branch information
APabisz authored Jul 19, 2023
2 parents fb6dac9 + c6fd810 commit ebdf890
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
22 changes: 13 additions & 9 deletions src/DTO/Request/Initialize/InitializeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ class InitializeRequest
private $returnUrl;

/**
* @var array
* @var SaferPayNotification|null
*/
private $notification;

/**
* @var array
* @var DeliveryAddressForm
*/
private $deliveryAddressForm;

Expand Down Expand Up @@ -124,7 +124,7 @@ public function __construct(
Payment $payment,
Payer $payer,
ReturnUrl $returnUrl,
SaferPayNotification $notification,
$notification,
DeliveryAddressForm $deliveryAddressForm,
$configSet,
$cssUrl,
Expand Down Expand Up @@ -214,17 +214,21 @@ public function getAsArray()
'ReturnUrl' => [
'Url' => $this->returnUrl->getReturnUrl(),
],
'Notification' => [
'PayerEmail' => $this->notification->getPayerEmail(),
'MerchantEmails' => [$this->notification->getMerchantEmail()],
'SuccessNotifyUrl' => $this->notification->getNotifyUrl(),
'FailNotifyUrl' => $this->notification->getNotifyUrl(),
],
'DeliveryAddressForm' => [
'AddressSource' => $this->deliveryAddressForm->getAddressSource(),
'MandatoryFields' => $this->deliveryAddressForm->getMandatoryFields(),
],
];

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

if ($this->configSet) {
$return['ConfigSet'] = $this->configSet;
}
Expand Down
4 changes: 3 additions & 1 deletion src/Service/Request/InitializeRequestObjectCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use Configuration;
use Customer;
use Invertus\SaferPay\Config\SaferPayConfig;
use Invertus\SaferPay\DTO\Request\RequestHeader;
use Invertus\SaferPay\DTO\Request\Initialize\InitializeRequest;
use Invertus\SaferPay\DTO\Request\Payer;

Expand All @@ -51,6 +52,7 @@ public function create(
$deliveryAddressId,
$invoiceAddressId,
$customerId,
$isBusinessLicence,
$alias = null,
$fieldToken = null
) {
Expand All @@ -63,7 +65,7 @@ public function create(
$payment = $this->requestObjectCreator->createPayment($cart, $totalPrice);
$payer = new Payer();
$returnUrl = $this->requestObjectCreator->createReturnUrl($returnUrl);
$notification = $this->requestObjectCreator->createNotification($customerEmail, $notifyUrl);
$notification = ($isBusinessLicence && version_compare(Configuration::get(RequestHeader::SPEC_VERSION), '1.35', '<')) ? null : $this->requestObjectCreator->createNotification($customerEmail, $notifyUrl);
$deliveryAddressForm = $this->requestObjectCreator->createDeliveryAddressForm();
$configSet = Configuration::get(SaferPayConfig::CONFIGURATION_NAME);
$cssUrl = Configuration::get(SaferPayConfig::CSS_FILE);
Expand Down
1 change: 1 addition & 0 deletions src/Service/SaferPayInitialize.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public function initialize(
$this->context->cart->id_address_delivery,
$this->context->cart->id_address_invoice,
$this->context->cart->id_customer,
$isBusinessLicence,
$alias,
$fieldToken
);
Expand Down

0 comments on commit ebdf890

Please sign in to comment.