@frontastic/common 2.30.0 → 2.31.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # common Changelog
2
2
 
3
+ ## `2.31.1` (2022-04-08)
4
+
5
+ * fix: prevent bc break on commercetools CartApi
6
+
7
+ ## `2.31.0` (2022-04-07)
8
+
9
+ * feat(FP-1794): extracted logic to validate cart status before checkout
10
+
11
+ ## `2.30.1` (2022-04-07)
12
+
13
+ * fix(FP-1794): consider only single successful payment as payment completed
14
+ * fix(FP-1794): moved cart readines validation to isReadyForCheckout
15
+ * fix(FP-1794): validated if cart is completed
16
+
3
17
  ## `2.30.0` (2022-04-05)
4
18
 
5
19
  * feat: allow field type dataSource in Classic as well
package/composer.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "frontastic/common",
3
3
  "license": "None",
4
- "version": "2.30.0",
4
+ "version": "2.31.1",
5
5
  "repositories": [
6
6
  {
7
7
  "type": "path",
package/docs/README.md CHANGED
@@ -67,7 +67,9 @@ Here you find the API documentation for the relevant classes:
67
67
  * [LifecycleEventDecorator](php/CartApiBundle/Domain/CartApi/LifecycleEventDecorator.md)
68
68
  * [CartApiBase](php/CartApiBundle/Domain/CartApiBase.md)
69
69
  * [CartApiFactory](php/CartApiBundle/Domain/CartApiFactory.md)
70
+ * [CartCheckoutService](php/CartApiBundle/Domain/CartCheckoutService.md)
70
71
  * [DefaultCartApiFactory](php/CartApiBundle/Domain/DefaultCartApiFactory.md)
72
+ * [DefaultCartCheckoutService](php/CartApiBundle/Domain/DefaultCartCheckoutService.md)
71
73
  * [Discount](php/CartApiBundle/Domain/Discount.md)
72
74
  * [DummyCartApiFactory](php/CartApiBundle/Domain/DummyCartApiFactory.md)
73
75
  * [LineItem](php/CartApiBundle/Domain/LineItem.md)
@@ -26,7 +26,8 @@ public function __construct(
26
26
  Commercetools\Locale\CommercetoolsLocaleCreator $localeCreator,
27
27
  OrderIdGeneratorV2 $orderIdGenerator,
28
28
  \Psr\Log\LoggerInterface $logger,
29
- ?Commercetools\Options $options = null
29
+ ?Commercetools\Options $options = null,
30
+ ?CartCheckoutService $cartCheckoutService = null
30
31
  ): mixed
31
32
  ```
32
33
 
@@ -38,6 +39,7 @@ Argument|Type|Default|Description
38
39
  `$orderIdGenerator`|[`OrderIdGeneratorV2`](../OrderIdGeneratorV2.md)||
39
40
  `$logger`|`\Psr\Log\LoggerInterface`||
40
41
  `$options`|?[`Commercetools`](Commercetools.md)\Options|`null`|
42
+ `$cartCheckoutService`|?[`CartCheckoutService`](../CartCheckoutService.md)|`null`|
41
43
 
42
44
  Return Value: `mixed`
43
45
 
@@ -0,0 +1,68 @@
1
+ # `interface` CartCheckoutService
2
+
3
+ **Fully Qualified**: [`\Frontastic\Common\CartApiBundle\Domain\CartCheckoutService`](../../../../src/php/CartApiBundle/Domain/CartCheckoutService.php)
4
+
5
+ ## Methods
6
+
7
+ * [getPayedAmount()](#getpayedamount)
8
+ * [hasCompletePayments()](#hascompletepayments)
9
+ * [isPaymentCompleted()](#ispaymentcompleted)
10
+ * [isReadyForCheckout()](#isreadyforcheckout)
11
+
12
+ ### getPayedAmount()
13
+
14
+ ```php
15
+ public function getPayedAmount(
16
+ Cart $cart
17
+ ): int
18
+ ```
19
+
20
+ Argument|Type|Default|Description
21
+ --------|----|-------|-----------
22
+ `$cart`|[`Cart`](Cart.md)||
23
+
24
+ Return Value: `int`
25
+
26
+ ### hasCompletePayments()
27
+
28
+ ```php
29
+ public function hasCompletePayments(
30
+ Cart $cart
31
+ ): bool
32
+ ```
33
+
34
+ Argument|Type|Default|Description
35
+ --------|----|-------|-----------
36
+ `$cart`|[`Cart`](Cart.md)||
37
+
38
+ Return Value: `bool`
39
+
40
+ ### isPaymentCompleted()
41
+
42
+ ```php
43
+ public function isPaymentCompleted(
44
+ Payment $payment
45
+ ): bool
46
+ ```
47
+
48
+ Argument|Type|Default|Description
49
+ --------|----|-------|-----------
50
+ `$payment`|[`Payment`](Payment.md)||
51
+
52
+ Return Value: `bool`
53
+
54
+ ### isReadyForCheckout()
55
+
56
+ ```php
57
+ public function isReadyForCheckout(
58
+ Cart $cart
59
+ ): bool
60
+ ```
61
+
62
+ Argument|Type|Default|Description
63
+ --------|----|-------|-----------
64
+ `$cart`|[`Cart`](Cart.md)||
65
+
66
+ Return Value: `bool`
67
+
68
+ Generated with [Frontastic API Docs](https://github.com/FrontasticGmbH/apidocs).
@@ -17,6 +17,7 @@ public function __construct(
17
17
  AccountApiFactory $accountApiFactory,
18
18
  object $orderIdGenerator,
19
19
  iterable $decorators,
20
+ CartCheckoutService $cartCheckoutService,
20
21
  \Psr\Log\LoggerInterface $logger
21
22
  ): mixed
22
23
  ```
@@ -27,6 +28,7 @@ Argument|Type|Default|Description
27
28
  `$accountApiFactory`|[`AccountApiFactory`](../../AccountApiBundle/Domain/AccountApiFactory.md)||
28
29
  `$orderIdGenerator`|`object`||
29
30
  `$decorators`|`iterable`||
31
+ `$cartCheckoutService`|[`CartCheckoutService`](CartCheckoutService.md)||
30
32
  `$logger`|`\Psr\Log\LoggerInterface`||
31
33
 
32
34
  Return Value: `mixed`
@@ -0,0 +1,77 @@
1
+ # DefaultCartCheckoutService
2
+
3
+ **Fully Qualified**: [`\Frontastic\Common\CartApiBundle\Domain\DefaultCartCheckoutService`](../../../../src/php/CartApiBundle/Domain/DefaultCartCheckoutService.php)
4
+
5
+ **Implements**: [`CartCheckoutService`](CartCheckoutService.md)
6
+
7
+ ## Methods
8
+
9
+ * [getPayedAmount()](#getpayedamount)
10
+ * [hasCompletePayments()](#hascompletepayments)
11
+ * [isPaymentCompleted()](#ispaymentcompleted)
12
+ * [isReadyForCheckout()](#isreadyforcheckout)
13
+
14
+ ### getPayedAmount()
15
+
16
+ ```php
17
+ public function getPayedAmount(
18
+ Cart $cart
19
+ ): int
20
+ ```
21
+
22
+ Argument|Type|Default|Description
23
+ --------|----|-------|-----------
24
+ `$cart`|[`Cart`](Cart.md)||
25
+
26
+ Return Value: `int`
27
+
28
+ ### hasCompletePayments()
29
+
30
+ ```php
31
+ public function hasCompletePayments(
32
+ Cart $cart
33
+ ): bool
34
+ ```
35
+
36
+ Argument|Type|Default|Description
37
+ --------|----|-------|-----------
38
+ `$cart`|[`Cart`](Cart.md)||
39
+
40
+ Return Value: `bool`
41
+
42
+ ### isPaymentCompleted()
43
+
44
+ ```php
45
+ public function isPaymentCompleted(
46
+ Payment $payment
47
+ ): bool
48
+ ```
49
+
50
+ *We only consider payments with status "paid" as completed*
51
+
52
+ Argument|Type|Default|Description
53
+ --------|----|-------|-----------
54
+ `$payment`|[`Payment`](Payment.md)||
55
+
56
+ Return Value: `bool`
57
+
58
+ ### isReadyForCheckout()
59
+
60
+ ```php
61
+ public function isReadyForCheckout(
62
+ Cart $cart
63
+ ): bool
64
+ ```
65
+
66
+ *Some commerce backends might consider a cart ready without payment(s).*
67
+
68
+ This method will return true if there are no payments or if all payments
69
+ had paid status and the total amounts are equal to cart total amount.
70
+
71
+ Argument|Type|Default|Description
72
+ --------|----|-------|-----------
73
+ `$cart`|[`Cart`](Cart.md)||
74
+
75
+ Return Value: `bool`
76
+
77
+ Generated with [Frontastic API Docs](https://github.com/FrontasticGmbH/apidocs).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontastic/common",
3
- "version": "2.30.0",
3
+ "version": "2.31.1",
4
4
  "devDependencies": {
5
5
  "@babel/core": "7.5.4",
6
6
  "@babel/plugin-proposal-class-properties": "^7.5.0",