Skip to content

Commit beadffd

Browse files
authored
Merge pull request #254 from vadimsallee/feature/253-add-linking-cart-items
Feature/253 add linking cart items
2 parents 52c13b3 + ec164c0 commit beadffd

26 files changed

+2251
-0
lines changed

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,28 @@
4444
- `list` returns a list of payments
4545
- `delete` deletes a payment
4646
- `getFields` returns the fields and settings for payments
47+
- Added service `Services\Sale\PaymentItemBasket\Service\PaymentItemBasket` with support methods,
48+
see [sale.paymentitembasket.* methods](https://github.com/bitrix24/b24phpsdk/issues/253):
49+
- `add` adds a binding of a basket item to a payment
50+
- `update` updates the binding of a basket item to a payment
51+
- `get` returns the values of all fields for the basket item binding to payment
52+
- `list` returns a list of bindings of basket items to payments
53+
- `delete` deletes the binding of a basket item to a payment
54+
- `getFields` returns the available fields for payment item basket bindings
55+
- Added service `Services\Sale\PaymentItemShipment\Service\PaymentItemShipment` with support methods,
56+
see [sale.paymentitemshipment.* methods](https://github.com/bitrix24/b24phpsdk/issues/253):
57+
- `add` adds a binding of a payment to a shipment
58+
- `update` updates the binding of a payment to a shipment
59+
- `get` returns the values of all fields for the payment binding to shipment
60+
- `list` returns a list of bindings of payments to shipments
61+
- `delete` deletes the binding of a payment to a shipment
62+
- `getFields` returns the available fields for payment item shipment bindings
63+
- Added service `Services\Sale\PropertyRelation\Service\PropertyRelation` with support methods,
64+
see [sale.propertyRelation.* methods](https://github.com/bitrix24/b24phpsdk/issues/253):
65+
- `add` adds a property binding
66+
- `list` retrieves a list of property bindings
67+
- `deleteByFilter` removes the property relation
68+
- `getFields` returns the available fields for property binding
4769

4870
## 1.6.0 – 2025.09.01
4971

Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ help:
5151
@echo ""
5252
@echo "test-unit - run unit tests"
5353
@echo "test-integration-sale-basket-property - run BasketProperty integration tests"
54+
@echo "test-integration-sale-payment-item-basket - run PaymentItemBasket integration tests"
55+
@echo "test-integration-sale-payment-item-shipment - run PaymentItemShipment integration tests"
56+
@echo "test-integration-sale-property-relation - run PropertyRelation integration tests"
5457

5558

5659
.PHONY: docker-init
@@ -227,6 +230,18 @@ test-integration-sale-basket:
227230
.PHONY: test-integration-sale-order
228231
test-integration-sale-order:
229232
docker-compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_sale_order
233+
234+
.PHONY: test-integration-sale-payment-item-basket
235+
test-integration-sale-payment-item-basket:
236+
docker-compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_sale_payment_item_basket
237+
238+
.PHONY: test-integration-sale-payment-item-shipment
239+
test-integration-sale-payment-item-shipment:
240+
docker-compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_sale_payment_item_shipment
241+
242+
.PHONY: test-integration-sale-property-relation
243+
test-integration-sale-property-relation:
244+
docker-compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_sale_property_relation
230245

231246
.PHONY: test-integration-scope-crm
232247
test-integration-scope-crm:
@@ -320,6 +335,10 @@ integration_tests_sale:
320335
integration_tests_sale_payment:
321336
docker-compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_sale_payment
322337

338+
.PHONY: integration_tests_sale_payment_item_basket
339+
integration_tests_sale_payment_item_basket:
340+
docker-compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_sale_payment_item_basket
341+
323342
# work dev environment
324343
.PHONY: php-dev-server-up
325344
php-dev-server-up:

phpunit.xml.dist

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,15 @@
133133
<testsuite name="integration_tests_sale_payment">
134134
<directory>./tests/Integration/Services/Sale/Payment/</directory>
135135
</testsuite>
136+
<testsuite name="integration_tests_sale_payment_item_basket">
137+
<directory>./tests/Integration/Services/Sale/PaymentItemBasket/</directory>
138+
</testsuite>
139+
<testsuite name="integration_tests_sale_payment_item_shipment">
140+
<directory>./tests/Integration/Services/Sale/PaymentItemShipment/</directory>
141+
</testsuite>
142+
<testsuite name="integration_tests_sale_property_relation">
143+
<directory>./tests/Integration/Services/Sale/PropertyRelation/</directory>
144+
</testsuite>
136145
<testsuite name="integration_tests_sale_order">
137146
<directory>./tests/Integration/Services/Sale/Order/</directory>
138147
</testsuite>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the bitrix24-php-sdk package.
5+
*
6+
* © Sally Fancen <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the MIT-LICENSE.txt
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace Bitrix24\SDK\Services\Sale\PaymentItemBasket\Result;
15+
16+
use Bitrix24\SDK\Core\Exceptions\BaseException;
17+
use Bitrix24\SDK\Core\Result\AddedItemResult;
18+
19+
/**
20+
* Class PaymentItemBasketAddedResult
21+
* Represents the result of an add payment item basket binding operation.
22+
*/
23+
class PaymentItemBasketAddedResult extends AddedItemResult
24+
{
25+
/**
26+
* @throws BaseException
27+
*/
28+
public function getId(): int
29+
{
30+
$result = $this->getCoreResponse()->getResponseData()->getResult();
31+
return isset($result['paymentItemBasket']['id']) ? (int)$result['paymentItemBasket']['id'] : 0;
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the bitrix24-php-sdk package.
5+
*
6+
* © Sally Fancen <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the MIT-LICENSE.txt
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace Bitrix24\SDK\Services\Sale\PaymentItemBasket\Result;
15+
16+
use Bitrix24\SDK\Core\Exceptions\BaseException;
17+
use Bitrix24\SDK\Core\Result\FieldsResult;
18+
19+
/**
20+
* Class PaymentItemBasketFieldsResult
21+
* Represents the result of a payment item basket binding fields operation.
22+
*/
23+
class PaymentItemBasketFieldsResult extends FieldsResult
24+
{
25+
/**
26+
* @throws BaseException
27+
*/
28+
public function getFieldsDescription(): array
29+
{
30+
$result = $this->getCoreResponse()->getResponseData()->getResult();
31+
return $result['paymentItemBasket'] ?? [];
32+
}
33+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the bitrix24-php-sdk package.
5+
*
6+
* © Sally Fancen <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the MIT-LICENSE.txt
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace Bitrix24\SDK\Services\Sale\PaymentItemBasket\Result;
15+
16+
use Bitrix24\SDK\Core\Result\AbstractItem;
17+
use Carbon\CarbonImmutable;
18+
19+
/**
20+
* Class PaymentItemBasketItemResult
21+
* Represents a single payment item basket binding returned by Bitrix24 REST API.
22+
*
23+
* Fields and their types are taken from Bitrix24 API (sale.paymentitembasket.getfields).
24+
*
25+
* @property-read int|null $id Binding identifier
26+
* @property-read int|null $paymentId Payment identifier
27+
* @property-read int|null $basketId Basket item identifier
28+
* @property-read string|null $quantity Quantity of the product
29+
* @property-read string|null $xmlId External record identifier
30+
* @property-read CarbonImmutable|null $dateInsert Date when the binding was created
31+
*/
32+
class PaymentItemBasketItemResult extends AbstractItem
33+
{
34+
public function getId(): ?int
35+
{
36+
return isset($this->data['id']) ? (int)$this->data['id'] : null;
37+
}
38+
39+
public function getPaymentId(): ?int
40+
{
41+
return isset($this->data['paymentId']) ? (int)$this->data['paymentId'] : null;
42+
}
43+
44+
public function getBasketId(): ?int
45+
{
46+
return isset($this->data['basketId']) ? (int)$this->data['basketId'] : null;
47+
}
48+
49+
public function getQuantity(): ?float
50+
{
51+
return isset($this->data['quantity']) ? (float)$this->data['quantity'] : null;
52+
}
53+
54+
public function getXmlId(): ?string
55+
{
56+
return isset($this->data['xmlId']) ? (string)$this->data['xmlId'] : null;
57+
}
58+
59+
public function getDateInsert(): ?CarbonImmutable
60+
{
61+
return isset($this->data['dateInsert']) ? CarbonImmutable::parse($this->data['dateInsert']) : null;
62+
}
63+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the bitrix24-php-sdk package.
5+
*
6+
* © Sally Fancen <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the MIT-LICENSE.txt
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace Bitrix24\SDK\Services\Sale\PaymentItemBasket\Result;
15+
16+
use Bitrix24\SDK\Core\Result\AbstractResult;
17+
18+
/**
19+
* Class PaymentItemBasketResult
20+
* Represents the result of a single payment item basket binding operation.
21+
*/
22+
class PaymentItemBasketResult extends AbstractResult
23+
{
24+
/**
25+
* Returns the payment item basket binding as PaymentItemBasketItemResult
26+
*/
27+
public function paymentItemBasket(): PaymentItemBasketItemResult
28+
{
29+
$result = $this->getCoreResponse()->getResponseData()->getResult();
30+
return new PaymentItemBasketItemResult($result['paymentItemBasket'] ?? []);
31+
}
32+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the bitrix24-php-sdk package.
5+
*
6+
* © Sally Fancen <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the MIT-LICENSE.txt
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace Bitrix24\SDK\Services\Sale\PaymentItemBasket\Result;
15+
16+
use Bitrix24\SDK\Core\Exceptions\BaseException;
17+
use Bitrix24\SDK\Core\Result\UpdatedItemResult;
18+
19+
/**
20+
* Class PaymentItemBasketUpdatedResult
21+
* Represents the result of an update payment item basket binding operation.
22+
*/
23+
class PaymentItemBasketUpdatedResult extends UpdatedItemResult
24+
{
25+
/**
26+
* @throws BaseException
27+
*/
28+
public function isSuccess(): bool
29+
{
30+
$result = $this->getCoreResponse()->getResponseData()->getResult();
31+
return isset($result['paymentItemBasket']) && !empty($result['paymentItemBasket']);
32+
}
33+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the bitrix24-php-sdk package.
5+
*
6+
* © Sally Fancen <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the MIT-LICENSE.txt
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace Bitrix24\SDK\Services\Sale\PaymentItemBasket\Result;
15+
16+
use Bitrix24\SDK\Core\Exceptions\BaseException;
17+
use Bitrix24\SDK\Core\Result\AbstractResult;
18+
19+
/**
20+
* Class PaymentItemBasketsResult
21+
* Represents the result of a list payment item basket bindings operation.
22+
*/
23+
class PaymentItemBasketsResult extends AbstractResult
24+
{
25+
/**
26+
* Returns an array of payment item basket binding items
27+
*
28+
* @return PaymentItemBasketItemResult[] array of payment item basket binding item results
29+
* @throws BaseException
30+
*/
31+
public function getPaymentItemBaskets(): array
32+
{
33+
$result = $this->getCoreResponse()->getResponseData()->getResult();
34+
$paymentItemBaskets = $result['paymentItemsBasket'] ?? [];
35+
return array_map(fn ($item): PaymentItemBasketItemResult => new PaymentItemBasketItemResult($item), $paymentItemBaskets);
36+
}
37+
}

0 commit comments

Comments
 (0)