Skip to content

Commit

Permalink
fix Add support for transaction update items with optional properties
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgrayston-paddle committed Oct 7, 2024
1 parent f983c60 commit 7f50dff
Show file tree
Hide file tree
Showing 22 changed files with 645 additions and 19 deletions.
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,30 @@ Check our main [developer changelog](https://developer.paddle.com/?utm_source=dx
### Fixed

- Dropped `receipt_data` on create and preview of a one-time charge for Subscriptions and Transactions
- `TransactionsClient::preview()` `TransactionPreview` response now allows null price ID for non-catalog prices:
- `TransactionPreview` `items[]->price` can now return `Price` (with `id`) or `TransactionPreviewPrice` (with nullable `id`)
- `TransactionPreview` `details->lineItems[]->priceId` is now nullable

### Added
- `TransactionsClient::create()` now supports operations with optional properties:
- `Resources\Transactions\Operations\Create\TransactionCreateItem`
- `Resources\Transactions\Operations\Create\TransactionCreateItemWithPrice`
- `TransactionsClient::update()` now supports operations with optional properties:
- `Resources\Transactions\Operations\Update\TransactionUpdateItem`
- `Resources\Transactions\Operations\Update\TransactionUpdateItemWithPrice`
- `TransactionsClient::preview()` now supports operation items with optional properties:
- `Resources\Transactions\Operations\Preview\TransactionItemPreviewWithNonCatalogPrice`
- `Resources\Transactions\Operations\Preview\TransactionItemPreviewWithPriceId`

### Deprecated
- The following `TransactionsClient::create()` operations items have been deprecated:
- `Entities\Transaction\TransactionCreateItem`
- `Entities\Transaction\TransactionCreateItemWithPrice`
- The following `TransactionsClient::update()` operations items have been deprecated:
- `Entities\Transaction\TransactionUpdateTransactionItem`
- The following `TransactionsClient::preview()` operations items have been deprecated:
- `Entities\Transaction\TransactionItemPreviewWithNonCatalogPrice`
- `Entities\Transaction\TransactionItemPreviewWithPriceId`

# [1.3.1] - 2024-09-30

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Paddle\SDK\Entities\Transaction;


/**
* @deprecated Replaced by \Paddle\SDK\Resources\Transactions\Operations\Create\TransactionCreateItemWithPrice
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Transaction/TransactionNonCatalogPrice.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Paddle\SDK\Entities\Shared\UnitPriceOverride;

/**
* @deprecated Replaced by \Paddle\SDK\Resources\Transactions\Operations\Preview\TransactionNonCatalogPrice
* @deprecated Replaced by \Paddle\SDK\Resources\Transactions\Operations\Price\TransactionNonCatalogPrice
*/
class TransactionNonCatalogPrice
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Paddle\SDK\Entities\Shared\UnitPriceOverride;

/**
* @deprecated Replaced by \Paddle\SDK\Resources\Transactions\Operations\Preview\TransactionNonCatalogPriceWithProduct
* @deprecated Replaced by \Paddle\SDK\Resources\Transactions\Operations\Price\TransactionNonCatalogPriceWithProduct
*/
class TransactionNonCatalogPriceWithProduct
{
Expand Down
3 changes: 3 additions & 0 deletions src/Entities/Transaction/TransactionNonCatalogProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
use Paddle\SDK\Entities\Shared\CustomData;
use Paddle\SDK\Entities\Shared\TaxCategory;

/**
* @deprecated Replaced by \Paddle\SDK\Resources\Transactions\Operations\Price\TransactionNonCatalogProduct
*/
class TransactionNonCatalogProduct
{
public function __construct(
Expand Down
3 changes: 3 additions & 0 deletions src/Entities/Transaction/TransactionUpdateTransactionItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

namespace Paddle\SDK\Entities\Transaction;

/**
* @deprecated Replaced by \Paddle\SDK\Resources\Transactions\Operations\Update\TransactionUpdateItem
*/
class TransactionUpdateTransactionItem
{
public function __construct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Paddle\SDK\Resources\Transactions\Operations\Create;

use Paddle\SDK\Resources\Transactions\Operations\Price\TransactionNonCatalogPrice;
use Paddle\SDK\Resources\Transactions\Operations\Price\TransactionNonCatalogPriceWithProduct;

class TransactionCreateItemWithPrice
{
public function __construct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
namespace Paddle\SDK\Resources\Transactions\Operations\Preview;

use Paddle\SDK\FiltersUndefined;
use Paddle\SDK\Resources\Transactions\Operations\Create\TransactionNonCatalogPrice;
use Paddle\SDK\Resources\Transactions\Operations\Create\TransactionNonCatalogPriceWithProduct;
use Paddle\SDK\Resources\Transactions\Operations\Price\TransactionNonCatalogPrice;
use Paddle\SDK\Resources\Transactions\Operations\Price\TransactionNonCatalogPriceWithProduct;
use Paddle\SDK\Undefined;

class TransactionItemPreviewWithNonCatalogPrice implements \JsonSerializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Paddle\SDK\Resources\Transactions\Operations\Create;
namespace Paddle\SDK\Resources\Transactions\Operations\Price;

use Paddle\SDK\Entities\Shared\CustomData;
use Paddle\SDK\Entities\Shared\Money;
Expand All @@ -24,13 +24,13 @@ public function __construct(
public string $description,
public Money $unitPrice,
public string $productId,
public string|null|Undefined $name = new Undefined(),
public TimePeriod|null|Undefined $billingCycle = new Undefined(),
public TimePeriod|null|Undefined $trialPeriod = new Undefined(),
public string|Undefined|null $name = new Undefined(),
public TimePeriod|Undefined|null $billingCycle = new Undefined(),
public TimePeriod|Undefined|null $trialPeriod = new Undefined(),
public TaxMode|Undefined $taxMode = new Undefined(),
public array|Undefined $unitPriceOverrides = new Undefined(),
public PriceQuantity|Undefined $quantity = new Undefined(),
public CustomData|null|Undefined $customData = new Undefined(),
public CustomData|Undefined|null $customData = new Undefined(),
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

declare(strict_types=1);

namespace Paddle\SDK\Resources\Transactions\Operations\Create;
namespace Paddle\SDK\Resources\Transactions\Operations\Price;

use Paddle\SDK\Entities\Shared\CustomData;
use Paddle\SDK\Entities\Shared\Money;
use Paddle\SDK\Entities\Shared\PriceQuantity;
use Paddle\SDK\Entities\Shared\TaxMode;
use Paddle\SDK\Entities\Shared\TimePeriod;
use Paddle\SDK\Entities\Shared\UnitPriceOverride;
use Paddle\SDK\Entities\Transaction\TransactionNonCatalogProduct;
use Paddle\SDK\FiltersUndefined;
use Paddle\SDK\Undefined;

Expand All @@ -25,13 +24,13 @@ public function __construct(
public string $description,
public Money $unitPrice,
public TransactionNonCatalogProduct $product,
public string|null|Undefined $name = new Undefined(),
public TimePeriod|null|Undefined $billingCycle = new Undefined(),
public TimePeriod|null|Undefined $trialPeriod = new Undefined(),
public string|Undefined|null $name = new Undefined(),
public TimePeriod|Undefined|null $billingCycle = new Undefined(),
public TimePeriod|Undefined|null $trialPeriod = new Undefined(),
public TaxMode|Undefined $taxMode = new Undefined(),
public array|Undefined $unitPriceOverrides = new Undefined(),
public PriceQuantity|Undefined $quantity = new Undefined(),
public CustomData|null|Undefined $customData = new Undefined(),
public CustomData|Undefined|null $customData = new Undefined(),
) {
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace Paddle\SDK\Resources\Transactions\Operations\Price;

use Paddle\SDK\Entities\Shared\CustomData;
use Paddle\SDK\Entities\Shared\TaxCategory;
use Paddle\SDK\FiltersUndefined;
use Paddle\SDK\Undefined;

class TransactionNonCatalogProduct implements \JsonSerializable
{
use FiltersUndefined;

public function __construct(
public string $name,
public TaxCategory $taxCategory,
public string|Undefined|null $description = new Undefined(),
public string|Undefined|null $imageUrl = new Undefined(),
public CustomData|Undefined|null $customData = new Undefined(),
) {
}

public function jsonSerialize(): array
{
return $this->filterUndefined([
'name' => $this->name,
'description' => $this->description,
'tax_category' => $this->taxCategory,
'image_url' => $this->imageUrl,
'custom_data' => $this->customData,
]);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace Paddle\SDK\Resources\Transactions\Operations\Update;

class TransactionUpdateItem
{
public function __construct(
public string $priceId,
public int $quantity,
) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace Paddle\SDK\Resources\Transactions\Operations\Update;

use Paddle\SDK\Resources\Transactions\Operations\Price\TransactionNonCatalogPrice;
use Paddle\SDK\Resources\Transactions\Operations\Price\TransactionNonCatalogPriceWithProduct;

class TransactionUpdateItemWithPrice
{
public function __construct(
public TransactionNonCatalogPrice|TransactionNonCatalogPriceWithProduct $price,
public int $quantity,
) {
}
}
4 changes: 3 additions & 1 deletion src/Resources/Transactions/Operations/UpdateTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
use Paddle\SDK\Entities\Transaction\TransactionTimePeriod;
use Paddle\SDK\Entities\Transaction\TransactionUpdateTransactionItem;
use Paddle\SDK\FiltersUndefined;
use Paddle\SDK\Resources\Transactions\Operations\Update\TransactionUpdateItem;
use Paddle\SDK\Resources\Transactions\Operations\Update\TransactionUpdateItemWithPrice;
use Paddle\SDK\Undefined;

class UpdateTransaction implements \JsonSerializable
{
use FiltersUndefined;

/**
* @param array<TransactionUpdateTransactionItem> $items
* @param array<TransactionUpdateItem|TransactionUpdateItemWithPrice|TransactionUpdateTransactionItem> $items
*/
public function __construct(
public readonly TransactionStatus|Undefined $status = new Undefined(),
Expand Down
Loading

0 comments on commit 7f50dff

Please sign in to comment.