Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: API sync #85

Merged
merged 3 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ Check our main [developer changelog](https://developer.paddle.com/?utm_source=dx

- Added `traffic_source` property to `NotificationSetting` entity
- Support notification settings `traffic_source` filter
- Support new payment methods `offline`, `unknown`, `wire_transfer`
- Support `tax_rates_used` property on `Adjustment` entity

### Fixed

- Dropped `receipt_data` on create and preview of a one-time charge for Subscriptions and Transactions

# [1.3.1] - 2024-09-30

Expand Down
6 changes: 5 additions & 1 deletion src/Entities/Adjustment.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Paddle\SDK\Entities;

use Paddle\SDK\Entities\Adjustment\AdjustmentItem;
use Paddle\SDK\Entities\Adjustment\AdjustmentTaxRatesUsed;
use Paddle\SDK\Entities\Shared\Action;
use Paddle\SDK\Entities\Shared\AdjustmentStatus;
use Paddle\SDK\Entities\Shared\AdjustmentTotals;
Expand All @@ -21,7 +22,8 @@
class Adjustment implements Entity
{
/**
* @param array<AdjustmentItem> $items
* @param array<AdjustmentItem> $items
* @param array<AdjustmentTaxRatesUsed> $taxRatesUsed
*/
private function __construct(
public string $id,
Expand All @@ -36,6 +38,7 @@ private function __construct(
public array $items,
public AdjustmentTotals $totals,
public PayoutTotalsAdjustment|null $payoutTotals,
public array $taxRatesUsed,
public \DateTimeInterface $createdAt,
public \DateTimeInterface|null $updatedAt,
) {
Expand All @@ -56,6 +59,7 @@ public static function from(array $data): self
items: array_map(fn (array $item): AdjustmentItem => AdjustmentItem::from($item), $data['items']),
totals: AdjustmentTotals::from($data['totals']),
payoutTotals: isset($data['payout_totals']) ? PayoutTotalsAdjustment::from($data['payout_totals']) : null,
taxRatesUsed: array_map(fn (array $taxRateUsed): AdjustmentTaxRatesUsed => AdjustmentTaxRatesUsed::from($taxRateUsed), $data['tax_rates_used'] ?? []),
createdAt: DateTime::from($data['created_at']),
updatedAt: DateTime::from($data['updated_at']),
);
Expand Down
29 changes: 29 additions & 0 deletions src/Entities/Adjustment/AdjustmentTaxRatesUsed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

/**
* |------
* | ! Generated code !
* | Altering this code will result in changes being overwritten |
* |-------------------------------------------------------------|.
*/

namespace Paddle\SDK\Entities\Adjustment;

class AdjustmentTaxRatesUsed
{
private function __construct(
public string $taxRate,
public AdjustmentTaxRatesUsedTotals $totals,
) {
}

public static function from(array $data): self
{
return new self(
$data['tax_rate'],
AdjustmentTaxRatesUsedTotals::from($data['totals']),
);
}
}
31 changes: 31 additions & 0 deletions src/Entities/Adjustment/AdjustmentTaxRatesUsedTotals.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

/**
* |------
* | ! Generated code !
* | Altering this code will result in changes being overwritten |
* |-------------------------------------------------------------|.
*/

namespace Paddle\SDK\Entities\Adjustment;

class AdjustmentTaxRatesUsedTotals
{
private function __construct(
public string $subtotal,
public string $tax,
public string $total,
) {
}

public static function from(array $data): self
{
return new self(
$data['subtotal'],
$data['tax'],
$data['total'],
);
}
}
6 changes: 6 additions & 0 deletions src/Entities/Shared/AvailablePaymentMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
* @method static AvailablePaymentMethods Card()
* @method static AvailablePaymentMethods GooglePay()
* @method static AvailablePaymentMethods Ideal()
* @method static AvailablePaymentMethods Offline()
* @method static AvailablePaymentMethods Paypal()
* @method static AvailablePaymentMethods Unknown()
* @method static AvailablePaymentMethods WireTransfer()
*/
final class AvailablePaymentMethods extends PaddleEnum
{
Expand All @@ -30,5 +33,8 @@ final class AvailablePaymentMethods extends PaddleEnum
private const Card = 'card';
private const GooglePay = 'google_pay';
private const Ideal = 'ideal';
private const Offline = 'offline';
private const Paypal = 'paypal';
private const Unknown = 'unknown';
private const WireTransfer = 'wire_transfer';
}
2 changes: 0 additions & 2 deletions src/Entities/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ private function __construct(
public \DateTimeInterface $createdAt,
public \DateTimeInterface $updatedAt,
public \DateTimeInterface|null $billedAt,
public string|null $receiptData,
public Address|null $address,
public array $adjustments,
public TransactionAdjustmentsTotals|null $adjustmentsTotals,
Expand Down Expand Up @@ -92,7 +91,6 @@ public static function from(array $data): self
createdAt: DateTime::from($data['created_at']),
updatedAt: DateTime::from($data['updated_at']),
billedAt: isset($data['billed_at']) ? DateTime::from($data['billed_at']) : null,
receiptData: $data['receipt_data'] ?? null,
address: isset($data['address']) ? Address::from($data['address']) : null,
adjustments: array_map(fn (array $adjustment): Adjustment => Adjustment::from($adjustment), $data['adjustments'] ?? []),
adjustmentsTotals: isset($data['adjustments_totals']) ? TransactionAdjustmentsTotals::from($data['adjustments_totals']) : null,
Expand Down
6 changes: 5 additions & 1 deletion src/Notifications/Entities/Adjustment.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Paddle\SDK\Notifications\Entities;

use Paddle\SDK\Notifications\Entities\Adjustment\AdjustmentItem;
use Paddle\SDK\Notifications\Entities\Adjustment\AdjustmentTaxRatesUsed;
use Paddle\SDK\Notifications\Entities\Shared\Action;
use Paddle\SDK\Notifications\Entities\Shared\AdjustmentStatus;
use Paddle\SDK\Notifications\Entities\Shared\AdjustmentTotals;
Expand All @@ -21,7 +22,8 @@
class Adjustment implements Entity
{
/**
* @param array<AdjustmentItem> $items
* @param array<AdjustmentItem> $items
* @param array<AdjustmentTaxRatesUsed> $taxRatesUsed
*/
private function __construct(
public string $id,
Expand All @@ -36,6 +38,7 @@ private function __construct(
public array $items,
public AdjustmentTotals $totals,
public PayoutTotalsAdjustment|null $payoutTotals,
public array $taxRatesUsed,
public \DateTimeInterface $createdAt,
public \DateTimeInterface|null $updatedAt,
) {
Expand All @@ -56,6 +59,7 @@ public static function from(array $data): self
items: array_map(fn (array $item): AdjustmentItem => AdjustmentItem::from($item), $data['items']),
totals: AdjustmentTotals::from($data['totals']),
payoutTotals: isset($data['payout_totals']) ? PayoutTotalsAdjustment::from($data['payout_totals']) : null,
taxRatesUsed: array_map(fn (array $taxRateUsed): AdjustmentTaxRatesUsed => AdjustmentTaxRatesUsed::from($taxRateUsed), $data['tax_rates_used'] ?? []),
createdAt: DateTime::from($data['created_at']),
updatedAt: isset($data['updated_at']) ? DateTime::from($data['updated_at']) : null,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

/**
* |------
* | ! Generated code !
* | Altering this code will result in changes being overwritten |
* |-------------------------------------------------------------|.
*/

namespace Paddle\SDK\Notifications\Entities\Adjustment;

class AdjustmentTaxRatesUsed
{
private function __construct(
public string $taxRate,
public AdjustmentTaxRatesUsedTotals $totals,
) {
}

public static function from(array $data): self
{
return new self(
$data['tax_rate'],
AdjustmentTaxRatesUsedTotals::from($data['totals']),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

/**
* |------
* | ! Generated code !
* | Altering this code will result in changes being overwritten |
* |-------------------------------------------------------------|.
*/

namespace Paddle\SDK\Notifications\Entities\Adjustment;

class AdjustmentTaxRatesUsedTotals
{
private function __construct(
public string $subtotal,
public string $tax,
public string $total,
) {
}

public static function from(array $data): self
{
return new self(
$data['subtotal'],
$data['tax'],
$data['total'],
);
}
}
2 changes: 0 additions & 2 deletions src/Notifications/Entities/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ private function __construct(
public \DateTimeInterface $createdAt,
public \DateTimeInterface $updatedAt,
public \DateTimeInterface|null $billedAt,
public string|null $receiptData,
) {
}

Expand Down Expand Up @@ -81,7 +80,6 @@ public static function from(array $data): self
createdAt: DateTime::from($data['created_at']),
updatedAt: DateTime::from($data['updated_at']),
billedAt: isset($data['billed_at']) ? DateTime::from($data['billed_at']) : null,
receiptData: $data['receipt_data'] ?? null,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public function jsonSerialize(): array
'effective_from' => $this->effectiveFrom,
'items' => $this->items,
'on_payment_failure' => $this->onPaymentFailure,
'receipt_data' => $this->receiptData,
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@
"earnings": "2029",
"currency_code": "USD"
},
"tax_rates_used": [
{
"tax_rate": "0.08875",
"totals": {
"subtotal": "59900",
"tax": "5315",
"total": "65215"
}
}
],
"created_at": "2023-08-21T13:57:15.489634Z",
"updated_at": "0001-01-01T00:00:00Z"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@
"earnings": "87",
"currency_code": "USD"
},
"tax_rates_used": [
{
"tax_rate": "0.08875",
"totals": {
"subtotal": "59900",
"tax": "5315",
"total": "65215"
}
}
],
"created_at": "2023-08-21T13:57:15.489634Z",
"updated_at": "2023-08-21T13:57:15.489634Z"
},
Expand Down Expand Up @@ -88,6 +98,16 @@
"earnings": "141771",
"currency_code": "USD"
},
"tax_rates_used": [
{
"tax_rate": "0.08875",
"totals": {
"subtotal": "59900",
"tax": "5315",
"total": "65215"
}
}
],
"created_at": "2023-08-21T11:25:13.138521Z",
"updated_at": "2023-08-21T11:25:13.138521Z"
},
Expand Down Expand Up @@ -137,6 +157,16 @@
"earnings": "56356",
"currency_code": "USD"
},
"tax_rates_used": [
{
"tax_rate": "0.08875",
"totals": {
"subtotal": "59900",
"tax": "5315",
"total": "65215"
}
}
],
"created_at": "2023-08-11T14:46:04.811464Z",
"updated_at": "2023-08-11T14:46:05.13404Z"
},
Expand Down Expand Up @@ -186,6 +216,16 @@
"earnings": "28151",
"currency_code": "USD"
},
"tax_rates_used": [
{
"tax_rate": "0.08875",
"totals": {
"subtotal": "59900",
"tax": "5315",
"total": "65215"
}
}
],
"created_at": "2023-08-11T14:15:01.225381Z",
"updated_at": "2023-08-11T14:15:03.54843Z"
},
Expand Down Expand Up @@ -253,6 +293,16 @@
"earnings": "42608",
"currency_code": "USD"
},
"tax_rates_used": [
{
"tax_rate": "0.08875",
"totals": {
"subtotal": "59900",
"tax": "5315",
"total": "65215"
}
}
],
"created_at": "2023-06-30T13:46:24.240375Z",
"updated_at": "2023-06-30T13:46:24.240376Z"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@
"earnings": "87",
"currency_code": "USD"
},
"tax_rates_used": [
{
"tax_rate": "0.08875",
"totals": {
"subtotal": "59900",
"tax": "5315",
"total": "65215"
}
}
],
"created_at": "2023-08-21T13:57:15.489634Z",
"updated_at": "0001-01-01T00:00:00Z"
},
Expand Down
Loading