Skip to content

Commit

Permalink
Merge pull request #849 from mollie/PIPRES-349-append-subscription-ca…
Browse files Browse the repository at this point in the history
…rrier-id-to-metadata

PIPRES-349: Append subscription carrier ID to metadata
  • Loading branch information
tomjas1997 authored Nov 28, 2023
2 parents c931eec + 058954a commit ac4e891
Show file tree
Hide file tree
Showing 36 changed files with 582 additions and 277 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"autoload": {
"psr-4": {
"Mollie\\": "src/",
"Mollie\\Subscription\\": "subscription/"
"Mollie\\Subscription\\": "subscription/",
"Mollie\\Shared\\": "shared/"
},
"classmap": [
"mollie.php",
Expand Down
2 changes: 1 addition & 1 deletion controllers/front/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Mollie\Controller\AbstractMollieController;
use Mollie\Exception\FailedToProvidePaymentFeeException;
use Mollie\Provider\PaymentFeeProviderInterface;
use Mollie\Repository\CurrencyRepositoryInterface;
use Mollie\Shared\Infrastructure\Repository\CurrencyRepositoryInterface;
use Mollie\Subscription\Exception\SubscriptionProductValidationException;
use Mollie\Subscription\Validator\CanProductBeAddedToCartValidator;
use Mollie\Utility\NumberUtility;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@
* @codingStandardsIgnoreStart
*/

namespace Mollie\Repository;
namespace Mollie\Shared\Infrastructure\Repository;

use Currency;
use Mollie\Repository\AbstractRepository;

if (!defined('_PS_VERSION_')) {
exit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
* @codingStandardsIgnoreStart
*/

namespace Mollie\Repository;
namespace Mollie\Shared\Infrastructure\Repository;

use Mollie\Repository\ReadOnlyRepositoryInterface;

if (!defined('_PS_VERSION_')) {
exit;
Expand Down
11 changes: 11 additions & 0 deletions shared/Infrastructure/Repository/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');

header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

header('Location: ../');
exit;
11 changes: 11 additions & 0 deletions shared/Infrastructure/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');

header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

header('Location: ../');
exit;
11 changes: 11 additions & 0 deletions shared/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');

header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

header('Location: ../');
exit;
2 changes: 1 addition & 1 deletion src/Builder/InvoicePdfTemplateBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
namespace Mollie\Builder;

use Currency;
use Mollie\Repository\CurrencyRepositoryInterface;
use Mollie\Repository\MolOrderPaymentFeeRepositoryInterface;
use Mollie\Shared\Infrastructure\Repository\CurrencyRepositoryInterface;
use MolOrderPaymentFee;
use Order;
use PrestaShop\PrestaShop\Core\Localization\Locale;
Expand Down
7 changes: 5 additions & 2 deletions src/ServiceProvider/BaseServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@
use Mollie\Repository\CartRuleRepositoryInterface;
use Mollie\Repository\CountryRepository;
use Mollie\Repository\CountryRepositoryInterface;
use Mollie\Repository\CurrencyRepository;
use Mollie\Repository\CurrencyRepositoryInterface;
use Mollie\Repository\CustomerRepository;
use Mollie\Repository\CustomerRepositoryInterface;
use Mollie\Repository\GenderRepository;
Expand Down Expand Up @@ -105,11 +103,15 @@
use Mollie\Service\Shipment\ShipmentInformationSenderInterface;
use Mollie\Service\ShipmentService;
use Mollie\Service\ShipmentServiceInterface;
use Mollie\Shared\Infrastructure\Repository\CurrencyRepository;
use Mollie\Shared\Infrastructure\Repository\CurrencyRepositoryInterface;
use Mollie\Subscription\Grid\Accessibility\SubscriptionCancelAccessibility;
use Mollie\Subscription\Install\Installer;
use Mollie\Subscription\Install\InstallerInterface;
use Mollie\Subscription\Logger\Logger;
use Mollie\Subscription\Logger\LoggerInterface;
use Mollie\Subscription\Repository\CombinationRepository;
use Mollie\Subscription\Repository\CombinationRepositoryInterface;
use Mollie\Subscription\Repository\OrderDetailRepository;
use Mollie\Subscription\Repository\OrderDetailRepositoryInterface;
use Mollie\Subscription\Repository\RecurringOrderRepository;
Expand Down Expand Up @@ -161,6 +163,7 @@ public function register(Container $container)
$this->addService($container, CountryRepositoryInterface::class, $container->get(CountryRepository::class));
$this->addService($container, PaymentMethodRepositoryInterface::class, $container->get(PaymentMethodRepository::class));
$this->addService($container, GenderRepositoryInterface::class, $container->get(GenderRepository::class));
$this->addService($container, CombinationRepositoryInterface::class, $container->get(CombinationRepository::class));
$this->addService($container, MolCustomerRepository::class, MolCustomerRepository::class)
->withArgument('MolCustomer');

Expand Down
85 changes: 85 additions & 0 deletions subscription/DTO/SubscriptionCarrierDeliveryPriceData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php
/**
* Mollie https://www.mollie.nl
*
* @author Mollie B.V. <[email protected]>
* @copyright Mollie B.V.
* @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md
*
* @see https://github.com/mollie/PrestaShop
* @codingStandardsIgnoreStart
*/

namespace Mollie\Subscription\DTO;

if (!defined('_PS_VERSION_')) {
exit;
}

class SubscriptionCarrierDeliveryPriceData
{
/** @var int */
private $deliveryAddressId;
/** @var int */
private $cartId;
/** @var int */
private $customerId;
/** @var array */
private $subscriptionProduct;
/** @var int */
private $subscriptionCarrierId;

public function __construct(
int $deliveryAddressId,
int $cartId,
int $customerId,
array $subscriptionProduct,
int $subscriptionCarrierId
) {
$this->deliveryAddressId = $deliveryAddressId;
$this->cartId = $cartId;
$this->customerId = $customerId;
$this->subscriptionProduct = $subscriptionProduct;
$this->subscriptionCarrierId = $subscriptionCarrierId;
}

/**
* @return int
*/
public function getDeliveryAddressId(): int
{
return $this->deliveryAddressId;
}

/**
* @return int
*/
public function getCartId(): int
{
return $this->cartId;
}

/**
* @return int
*/
public function getCustomerId(): int
{
return $this->customerId;
}

/**
* @return array
*/
public function getSubscriptionProduct(): array
{
return $this->subscriptionProduct;
}

/**
* @return int
*/
public function getSubscriptionCarrierId(): int
{
return $this->subscriptionCarrierId;
}
}
63 changes: 63 additions & 0 deletions subscription/Exception/CouldNotCreateSubscriptionData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
/**
* Mollie https://www.mollie.nl
*
* @author Mollie B.V. <[email protected]>
* @copyright Mollie B.V.
* @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md
*
* @see https://github.com/mollie/PrestaShop
* @codingStandardsIgnoreStart
*/

namespace Mollie\Subscription\Exception;

if (!defined('_PS_VERSION_')) {
exit;
}

class CouldNotCreateSubscriptionData extends MollieSubscriptionException
{
public static function failedToFindMollieCustomer(string $email): self
{
return new self(
sprintf(
'Failed to find Mollie customer. Email: (%s)',
$email
),
ExceptionCode::ORDER_FAILED_TO_FIND_MOLLIE_CUSTOMER
);
}

public static function failedToRetrieveSubscriptionInterval(\Throwable $exception, int $productAttributeId): self
{
return new self(
sprintf(
'Failed to retrieve subscription interval. Product attribute ID: (%s)',
$productAttributeId
),
ExceptionCode::ORDER_FAILED_TO_RETRIEVE_SUBSCRIPTION_INTERVAL,
$exception
);
}

public static function failedToProvideCarrierDeliveryPrice(\Throwable $exception): self
{
return new self(
'Failed to provide carrier delivery price.',
ExceptionCode::ORDER_FAILED_TO_PROVIDE_CARRIER_DELIVERY_PRICE,
$exception
);
}

public static function failedToFindCurrency(int $currencyId): self
{
return new self(
sprintf(
'Failed to find currency. Currency ID: (%s)',
$currencyId
),
ExceptionCode::ORDER_FAILED_TO_FIND_CURRENCY
);
}
}
13 changes: 13 additions & 0 deletions subscription/Exception/CouldNotHandleRecurringOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@

class CouldNotHandleRecurringOrder extends MollieSubscriptionException
{
public static function failedToMatchSelectedCarrier(
int $activeSubscriptionCarrierId,
int $orderSubscriptionCarrierId
): self {
return new self(
sprintf('Failed to match selected carrier. active_carrier_id: (%s), order_carrier_id: (%s),',
$activeSubscriptionCarrierId,
$orderSubscriptionCarrierId
),
ExceptionCode::RECURRING_ORDER_FAILED_TO_MATCH_SELECTED_CARRIER
);
}

public static function failedToFindSelectedCarrier(): self
{
return new self(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,58 +18,79 @@

class CouldNotProvideSubscriptionCarrierDeliveryPrice extends MollieSubscriptionException
{
public static function failedToFindSelectedCarrier(): self
public static function failedToFindSelectedCarrier(int $subscriptionCarrierId): self
{
return new self(
'Failed to find selected carrier',
sprintf(
'Failed to find selected carrier. Subscription carrier ID: (%s)',
$subscriptionCarrierId
),
ExceptionCode::ORDER_FAILED_TO_FIND_SELECTED_CARRIER
);
}

public static function failedToFindOrderCart(): self
public static function failedToFindCart(int $cartId): self
{
return new self(
'Failed to find order cart',
ExceptionCode::ORDER_FAILED_TO_FIND_ORDER_CART
sprintf(
'Failed to find cart. Cart ID: (%s)',
$cartId
),
ExceptionCode::ORDER_FAILED_TO_FIND_CART
);
}

public static function failedToFindOrderCustomer(): self
public static function failedToFindCustomer(int $customerId): self
{
return new self(
'Failed to find order customer',
ExceptionCode::ORDER_FAILED_TO_FIND_ORDER_CUSTOMER
sprintf(
'Failed to find customer. Customer ID: (%s)',
$customerId
),
ExceptionCode::ORDER_FAILED_TO_FIND_CUSTOMER
);
}

public static function failedToApplySelectedCarrier(): self
public static function failedToApplySelectedCarrier(int $subscriptionCarrierId): self
{
return new self(
'Failed to apply selected carrier',
sprintf(
'Failed to apply selected carrier. Subscription carrier ID: (%s)',
$subscriptionCarrierId
),
ExceptionCode::ORDER_FAILED_TO_APPLY_SELECTED_CARRIER
);
}

public static function failedToFindOrderDeliveryAddress(): self
public static function failedToFindDeliveryAddress(int $deliveryAddressId): self
{
return new self(
'Failed to find order delivery address',
ExceptionCode::ORDER_FAILED_TO_FIND_ORDER_DELIVERY_ADDRESS
sprintf(
'Failed to find delivery address. Delivery address ID: (%s)',
$deliveryAddressId
),
ExceptionCode::ORDER_FAILED_TO_FIND_DELIVERY_ADDRESS
);
}

public static function failedToFindOrderDeliveryCountry(): self
public static function failedToFindDeliveryCountry(int $countryId): self
{
return new self(
'Failed to find order delivery country',
ExceptionCode::ORDER_FAILED_TO_FIND_ORDER_DELIVERY_COUNTRY
sprintf(
'Failed to find delivery country. Country ID: (%s)',
$countryId
),
ExceptionCode::ORDER_FAILED_TO_FIND_DELIVERY_COUNTRY
);
}

public static function failedToGetSelectedCarrierPrice(): self
public static function failedToGetSelectedCarrierPrice(int $subscriptionCarrierId): self
{
return new self(
'Failed to get selected carrier price',
sprintf(
'Failed to get selected carrier price. Subscription carrier ID: (%s)',
$subscriptionCarrierId
),
ExceptionCode::ORDER_FAILED_TO_GET_SELECTED_CARRIER_PRICE
);
}
Expand Down
Loading

0 comments on commit ac4e891

Please sign in to comment.