diff --git a/src/Entities/Adjustment.php b/src/Entities/Adjustment.php index a15b5d2..2cac3a7 100644 --- a/src/Entities/Adjustment.php +++ b/src/Entities/Adjustment.php @@ -11,7 +11,7 @@ namespace Paddle\SDK\Entities; -use Paddle\SDK\Entities\Adjustment\AdjustmentItemTotals; +use Paddle\SDK\Entities\Adjustment\AdjustmentItem; use Paddle\SDK\Entities\Shared\Action; use Paddle\SDK\Entities\Shared\AdjustmentStatus; use Paddle\SDK\Entities\Shared\CurrencyCode; @@ -23,7 +23,7 @@ class Adjustment implements Entity /** * @internal * - * @param array $items + * @param array $items */ protected function __construct( public string $id, @@ -55,7 +55,7 @@ public static function from(array $data): self creditAppliedToBalance: $data['credit_applied_to_balance'] ?? null, currencyCode: CurrencyCode::from($data['currency_code']), status: AdjustmentStatus::from($data['status']), - items: $data['items'], + items: array_map(fn (array $item) => AdjustmentItem::from($item), $data['items']), totals: TotalAdjustments::from($data['totals']), payoutTotals: isset($data['payout_totals']) ? PayoutTotalsAdjustment::from($data['payout_totals']) : null, createdAt: DateTime::from($data['created_at']), diff --git a/src/Entities/Adjustment/AdjustmentItem.php b/src/Entities/Adjustment/AdjustmentItem.php index 16e1a2c..6dba01c 100644 --- a/src/Entities/Adjustment/AdjustmentItem.php +++ b/src/Entities/Adjustment/AdjustmentItem.php @@ -11,12 +11,31 @@ namespace Paddle\SDK\Entities\Adjustment; +use Paddle\SDK\Entities\Shared\AdjustmentItemTotals; +use Paddle\SDK\Entities\Shared\AdjustmentProration; +use Paddle\SDK\Entities\Shared\AdjustmentType; + class AdjustmentItem { public function __construct( + public string $id, public string $itemId, public AdjustmentType $type, public string|null $amount, + public AdjustmentProration|null $proration, + public AdjustmentItemTotals $totals, ) { } + + public static function from(array $data): self + { + return new self( + id: $data['id'], + itemId: $data['item_id'], + type: AdjustmentType::from($data['type']), + amount: $data['amount'] ?? null, + proration: $data['proration'] ? AdjustmentProration::from($data['proration']) : null, + totals: AdjustmentItemTotals::from($data['totals']), + ); + } } diff --git a/src/Entities/Adjustment/AdjustmentItemTotals.php b/src/Entities/Adjustment/AdjustmentItemTotals.php deleted file mode 100644 index bcc6730..0000000 --- a/src/Entities/Adjustment/AdjustmentItemTotals.php +++ /dev/null @@ -1,28 +0,0 @@ - SubscriptionTransaction::from($item), $itemsData), - $paginator, - ); - } - - public function current(): SubscriptionTransaction - { - return parent::current(); - } -} diff --git a/src/Entities/Shared/AdjustmentItemTotals.php b/src/Entities/Shared/AdjustmentItemTotals.php index 4f06ec5..5494bc2 100644 --- a/src/Entities/Shared/AdjustmentItemTotals.php +++ b/src/Entities/Shared/AdjustmentItemTotals.php @@ -19,4 +19,13 @@ public function __construct( public string $total, ) { } + + public static function from(array $data): self + { + return new self( + subtotal: $data['subtotal'], + tax: $data['tax'], + total: $data['total'], + ); + } } diff --git a/src/Entities/Adjustment/AdjustmentProration.php b/src/Entities/Shared/AdjustmentProration.php similarity index 59% rename from src/Entities/Adjustment/AdjustmentProration.php rename to src/Entities/Shared/AdjustmentProration.php index 5482ed1..3fb23f2 100644 --- a/src/Entities/Adjustment/AdjustmentProration.php +++ b/src/Entities/Shared/AdjustmentProration.php @@ -9,7 +9,7 @@ * |-------------------------------------------------------------|. */ -namespace Paddle\SDK\Entities\Adjustment; +namespace Paddle\SDK\Entities\Shared; class AdjustmentProration { @@ -18,4 +18,12 @@ public function __construct( public AdjustmentTimePeriod $billingPeriod, ) { } + + public static function from(array $data): self + { + return new self( + rate: $data['rate'], + billingPeriod: AdjustmentTimePeriod::from($data['billing_period']), + ); + } } diff --git a/src/Entities/Adjustment/AdjustmentTimePeriod.php b/src/Entities/Shared/AdjustmentTimePeriod.php similarity index 57% rename from src/Entities/Adjustment/AdjustmentTimePeriod.php rename to src/Entities/Shared/AdjustmentTimePeriod.php index 5f01dba..2366239 100644 --- a/src/Entities/Adjustment/AdjustmentTimePeriod.php +++ b/src/Entities/Shared/AdjustmentTimePeriod.php @@ -9,7 +9,9 @@ * |-------------------------------------------------------------|. */ -namespace Paddle\SDK\Entities\Adjustment; +namespace Paddle\SDK\Entities\Shared; + +use Paddle\SDK\Entities\DateTime; class AdjustmentTimePeriod { @@ -18,4 +20,12 @@ public function __construct( public \DateTimeInterface $endsAt, ) { } + + public static function from(array $data): self + { + return new self( + startsAt: DateTime::from($data['starts_at']), + endsAt: DateTime::from($data['ends_at']), + ); + } } diff --git a/src/Entities/Adjustment/AdjustmentType.php b/src/Entities/Shared/AdjustmentType.php similarity index 89% rename from src/Entities/Adjustment/AdjustmentType.php rename to src/Entities/Shared/AdjustmentType.php index c9189b5..fde3348 100644 --- a/src/Entities/Adjustment/AdjustmentType.php +++ b/src/Entities/Shared/AdjustmentType.php @@ -9,7 +9,7 @@ * |-------------------------------------------------------------|. */ -namespace Paddle\SDK\Entities\Adjustment; +namespace Paddle\SDK\Entities\Shared; enum AdjustmentType: string { diff --git a/src/Entities/Subscription/SubscriptionAdjustment.php b/src/Entities/Subscription/SubscriptionAdjustment.php deleted file mode 100644 index 830dd58..0000000 --- a/src/Entities/Subscription/SubscriptionAdjustment.php +++ /dev/null @@ -1,42 +0,0 @@ - $items - */ - public function __construct( - public string $id, - public Action $action, - public string $transactionId, - public string|null $subscriptionId, - public string $customerId, - public string $reason, - public bool $creditAppliedToBalance, - public CurrencyCode $currencyCode, - public AdjustmentStatus $status, - public array $items, - public TotalAdjustments $totals, - public PayoutTotalsAdjustment $payoutTotals, - public \DateTimeInterface $createdAt, - public \DateTimeInterface $updatedAt, - ) { - } -} diff --git a/src/Entities/Subscription/SubscriptionAdjustmentItem.php b/src/Entities/Subscription/SubscriptionAdjustmentItem.php index 0a66ab0..923e046 100644 --- a/src/Entities/Subscription/SubscriptionAdjustmentItem.php +++ b/src/Entities/Subscription/SubscriptionAdjustmentItem.php @@ -11,8 +11,9 @@ namespace Paddle\SDK\Entities\Subscription; -use Paddle\SDK\Entities\Adjustment\AdjustmentType; use Paddle\SDK\Entities\Shared\AdjustmentItemTotals; +use Paddle\SDK\Entities\Shared\AdjustmentProration; +use Paddle\SDK\Entities\Shared\AdjustmentType; class SubscriptionAdjustmentItem { @@ -20,8 +21,19 @@ public function __construct( public string $itemId, public AdjustmentType $type, public string|null $amount, - public SubscriptionProration $proration, + public AdjustmentProration $proration, public AdjustmentItemTotals $totals, ) { } + + public static function from(array $data): self + { + return new self( + itemId: $data['item_id'], + type: AdjustmentType::from($data['type']), + amount: $data['amount'] ?? null, + proration: AdjustmentProration::from($data['proration']), + totals: AdjustmentItemTotals::from($data['totals']), + ); + } } diff --git a/src/Entities/Subscription/SubscriptionAdjustmentPreview.php b/src/Entities/Subscription/SubscriptionAdjustmentPreview.php index c9040ce..2f022cc 100644 --- a/src/Entities/Subscription/SubscriptionAdjustmentPreview.php +++ b/src/Entities/Subscription/SubscriptionAdjustmentPreview.php @@ -17,4 +17,13 @@ public function __construct( public TotalAdjustments $totals, ) { } + + public static function from(array $data): self + { + return new self( + transactionId: $data['transaction_id'], + items: array_map(fn (array $item) => SubscriptionAdjustmentItem::from($item), $data['items']), + totals: TotalAdjustments::from($data['totals']), + ); + } } diff --git a/src/Entities/Subscription/SubscriptionNextTransaction.php b/src/Entities/Subscription/SubscriptionNextTransaction.php index 1209ea2..f3e5eb1 100644 --- a/src/Entities/Subscription/SubscriptionNextTransaction.php +++ b/src/Entities/Subscription/SubscriptionNextTransaction.php @@ -30,7 +30,10 @@ public static function from(array $data): self return new self( billingPeriod: SubscriptionTimePeriod::from($data['billing_period']), details: TransactionDetailsPreview::from($data['details']), - adjustments: [], + adjustments: array_map( + fn (array $adjustment) => SubscriptionAdjustmentPreview::from($adjustment), + $data['adjustments'], + ), ); } } diff --git a/src/Entities/SubscriptionTransaction.php b/src/Entities/SubscriptionTransaction.php deleted file mode 100644 index c699a20..0000000 --- a/src/Entities/SubscriptionTransaction.php +++ /dev/null @@ -1,99 +0,0 @@ - $items - * @param array $payments - * @param array $adjustments - */ - protected function __construct( - public string $id, - public TransactionStatus $status, - public string|null $customerId, - public string|null $addressId, - public string|null $businessId, - public CustomData|null $customData, - public CurrencyCode $currencyCode, - public TransactionOrigin $origin, - public string|null $subscriptionId, - public string|null $invoiceId, - public string|null $invoiceNumber, - public CollectionMode $collectionMode, - public string|null $discountId, - public BillingDetails|null $billingDetails, - public SubscriptionTimePeriod $billingPeriod, - public array $items, - public SubscriptionDetails $details, - public array $payments, - public Checkout $checkout, - public \DateTimeInterface $createdAt, - public \DateTimeInterface $updatedAt, - public \DateTimeInterface|null $billedAt, - public Customer $customer, - public Address $address, - public Business $business, - public Discount $discount, - public array $adjustments, - ) { - } - - public static function from(array $data): self - { - return new self( - id: $data['id'], - status: TransactionStatus::from($data['status']), - customerId: $data['customer_id'] ?? null, - addressId: $data['address_id'] ?? null, - businessId: $data['business_id'] ?? null, - customData: new CustomData($data['custom_data'] ?? []), - currencyCode: CurrencyCode::from($data['currency_code']), - origin: TransactionOrigin::from($data['origin']), - subscriptionId: $data['subscription_id'] ?? null, - invoiceId: $data['invoice_id'] ?? null, - invoiceNumber: $data['invoice_number'] ?? null, - collectionMode: CollectionMode::from($data['collection_mode']), - discountId: $data['discount_id'] ?? null, - billingDetails: BillingDetails::from($data['billing_details']), - billingPeriod: SubscriptionTimePeriod::from($data['billing_period']), - items: $data['items'], - details: SubscriptionDetails::from($data['details']), - payments: $data['payments'], - checkout: Checkout::from($data['checkout']), - createdAt: DateTime::from($data['created_at']), - updatedAt: DateTime::from($data['updated_at']), - billedAt: isset($data['billed_at']) ? DateTime::from($data['billed_at']) : null, - customer: Customer::from($data['customer']), - address: Address::from($data['address']), - business: Business::from($data['business']), - discount: Discount::from($data['discount']), - adjustments: $data['adjustments'], - ); - } -} diff --git a/src/Entities/Transaction.php b/src/Entities/Transaction.php index 9a34c71..a9741a0 100644 --- a/src/Entities/Transaction.php +++ b/src/Entities/Transaction.php @@ -20,7 +20,6 @@ use Paddle\SDK\Entities\Shared\TransactionOrigin; use Paddle\SDK\Entities\Shared\TransactionPaymentAttempt; use Paddle\SDK\Entities\Shared\TransactionStatus; -use Paddle\SDK\Entities\Transaction\TransactionAdjustment; use Paddle\SDK\Entities\Transaction\TransactionAdjustmentsTotals; use Paddle\SDK\Entities\Transaction\TransactionDetails; use Paddle\SDK\Entities\Transaction\TransactionItem; @@ -33,7 +32,7 @@ class Transaction implements Entity * * @param array $items * @param array $payments - * @param array $adjustments + * @param array $adjustments * @param array $availablePaymentMethods */ protected function __construct( @@ -97,7 +96,7 @@ public static function from(array $data): self 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): TransactionAdjustment => TransactionAdjustment::from($adjustment), $data['adjustments'] ?? []), + adjustments: array_map(fn (array $adjustment): Adjustment => Adjustment::from($adjustment), $data['adjustments'] ?? []), adjustmentsTotals: isset($data['adjustments_totals']) ? TransactionAdjustmentsTotals::from($data['adjustments_totals']) : null, business: isset($data['business']) ? Business::from($data['business']) : null, customer: isset($data['customer']) ? Customer::from($data['customer']) : null, diff --git a/src/Entities/Transaction/TransactionAdjustment.php b/src/Entities/Transaction/TransactionAdjustment.php deleted file mode 100644 index a79a4d6..0000000 --- a/src/Entities/Transaction/TransactionAdjustment.php +++ /dev/null @@ -1,63 +0,0 @@ - $items - */ - public function __construct( - public string $id, - public Action $action, - public string $transactionId, - public string|null $subscriptionId, - public string $customerId, - public string $reason, - public bool $creditAppliedToBalance, - public CurrencyCode $currencyCode, - public AdjustmentStatus $status, - public array $items, - public TotalAdjustments $totals, - public PayoutTotalsAdjustment $payoutTotals, - public \DateTimeInterface $createdAt, - public \DateTimeInterface $updatedAt, - ) { - } - - public static function from(array $data): self - { - return new self( - id: $data['id'], - action: Action::from($data['action']), - transactionId: $data['transaction_id'], - subscriptionId: $data['subscription_id'] ?? null, - customerId: $data['customer_id'], - reason: $data['reason'], - creditAppliedToBalance: $data['credit_applied_to_balance'] ?? null, - currencyCode: CurrencyCode::from($data['currency_code']), - status: AdjustmentStatus::from($data['status']), - items: $data['items'], - totals: TotalAdjustments::from($data['totals']), - payoutTotals: isset($data['payout_totals']) ? PayoutTotalsAdjustment::from($data['payout_totals']) : null, - createdAt: DateTime::from($data['created_at']), - updatedAt: DateTime::from($data['updated_at']), - ); - } -} diff --git a/src/Entities/Transaction/TransactionAdjustmentItem.php b/src/Resources/Adjustments/Operations/Create/AdjustmentItem.php similarity index 51% rename from src/Entities/Transaction/TransactionAdjustmentItem.php rename to src/Resources/Adjustments/Operations/Create/AdjustmentItem.php index 50fad43..210950d 100644 --- a/src/Entities/Transaction/TransactionAdjustmentItem.php +++ b/src/Resources/Adjustments/Operations/Create/AdjustmentItem.php @@ -9,20 +9,16 @@ * |-------------------------------------------------------------|. */ -namespace Paddle\SDK\Entities\Transaction; +namespace Paddle\SDK\Resources\Adjustments\Operations\Create; -use Paddle\SDK\Entities\Shared\AdjustmentItemTotals; -use Paddle\SDK\Entities\Shared\Type; +use Paddle\SDK\Entities\Shared\AdjustmentType; -class TransactionAdjustmentItem +class AdjustmentItem { public function __construct( - public string $id, public string $itemId, - public Type $type, + public AdjustmentType $type, public string|null $amount, - public TransactionProration $proration, - public AdjustmentItemTotals $totals, ) { } } diff --git a/src/Resources/Adjustments/Operations/CreateAdjustment.php b/src/Resources/Adjustments/Operations/CreateAdjustment.php index 69c6a2d..6428805 100644 --- a/src/Resources/Adjustments/Operations/CreateAdjustment.php +++ b/src/Resources/Adjustments/Operations/CreateAdjustment.php @@ -4,8 +4,8 @@ namespace Paddle\SDK\Resources\Adjustments\Operations; -use Paddle\SDK\Entities\Adjustment\AdjustmentItem; use Paddle\SDK\Entities\Shared\Action; +use Paddle\SDK\Resources\Adjustments\Operations\Create\AdjustmentItem; class CreateAdjustment implements \JsonSerializable { diff --git a/tests/Functional/Resources/Adjustments/AdjustmentsClientTest.php b/tests/Functional/Resources/Adjustments/AdjustmentsClientTest.php index 3371aff..670ae3f 100644 --- a/tests/Functional/Resources/Adjustments/AdjustmentsClientTest.php +++ b/tests/Functional/Resources/Adjustments/AdjustmentsClientTest.php @@ -7,12 +7,12 @@ use GuzzleHttp\Psr7\Response; use Http\Mock\Client as MockClient; use Paddle\SDK\Client; -use Paddle\SDK\Entities\Adjustment\AdjustmentItem; -use Paddle\SDK\Entities\Adjustment\AdjustmentType; use Paddle\SDK\Entities\Shared\Action; use Paddle\SDK\Entities\Shared\AdjustmentStatus; +use Paddle\SDK\Entities\Shared\AdjustmentType; use Paddle\SDK\Environment; use Paddle\SDK\Options; +use Paddle\SDK\Resources\Adjustments\Operations\Create\AdjustmentItem; use Paddle\SDK\Resources\Adjustments\Operations\CreateAdjustment; use Paddle\SDK\Resources\Adjustments\Operations\ListAdjustments; use Paddle\SDK\Resources\Shared\Operations\List\Pager; diff --git a/tests/Functional/Resources/Subscriptions/_fixtures/response/preview_update_full_entity.json b/tests/Functional/Resources/Subscriptions/_fixtures/response/preview_update_full_entity.json index d999e5d..7f3b019 100644 --- a/tests/Functional/Resources/Subscriptions/_fixtures/response/preview_update_full_entity.json +++ b/tests/Functional/Resources/Subscriptions/_fixtures/response/preview_update_full_entity.json @@ -1,55 +1,166 @@ { "data": { - "id": "sub_01heb0tj9w00j33bfbq3469cy0", "status": "active", - "customer_id": "ctm_01heaqwvb9kv4dv4v67m738dta", - "address_id": "add_01heaqx50ad2sbsmf68saya8v2", + "customer_id": "ctm_01hm4e55f7cq759z2t4hny8ch2", + "address_id": "add_01hm4e55ftjwsc2pgzhx1qr0eg", "business_id": null, "currency_code": "USD", - "created_at": "2023-11-03T16:38:55.036Z", - "updated_at": "2023-11-24T16:38:53.111897Z", - "started_at": "2023-11-03T16:38:53.111897Z", - "first_billed_at": "2023-11-03T16:38:53.111897Z", - "next_billed_at": "2023-12-03T16:38:53.111897Z", + "created_at": "2024-01-14T16:52:08.075Z", + "updated_at": "2024-02-06T15:33:47.114Z", + "started_at": "2024-01-14T16:52:06.565582Z", + "first_billed_at": "2024-01-14T16:52:06.565582Z", + "next_billed_at": "2024-02-14T16:52:06.565582Z", "paused_at": null, "canceled_at": null, "collection_mode": "automatic", "billing_details": null, "current_billing_period": { - "starts_at": "2023-11-03T16:38:53.111897Z", - "ends_at": "2023-12-03T16:38:53.111897Z" + "starts_at": "2024-01-14T16:52:06.565582Z", + "ends_at": "2024-02-14T16:52:06.565582Z" }, "billing_cycle": { "frequency": 1, "interval": "month" }, + "recurring_transaction_details": { + "tax_rates_used": [ + { + "tax_rate": "0", + "totals": { + "subtotal": "175000", + "discount": "0", + "tax": "0", + "total": "175000" + } + } + ], + "totals": { + "subtotal": "175000", + "tax": "0", + "discount": "0", + "total": "175000", + "fee": null, + "credit": "0", + "credit_to_balance": "0", + "balance": "175000", + "grand_total": "175000", + "earnings": null, + "currency_code": "USD", + "exchange_rate": "1" + }, + "line_items": [ + { + "item_id": null, + "price_id": "pri_01gsz8x8sawmvhz1pv30nge1ke", + "quantity": 50, + "totals": { + "subtotal": "150000", + "tax": "0", + "discount": "0", + "total": "150000" + }, + "product": { + "id": "pro_01gsz4t5hdjse780zja8vvr7jg", + "name": "ChatApp Pro", + "type": "standard", + "tax_category": "standard", + "description": "Everything in basic, plus access to a suite of powerful tools and features designed to take your team's productivity to the next level.", + "image_url": "https://paddle-sandbox.s3.amazonaws.com/user/10889/2nmP8MQSret0aWeDemRw_icon1.png", + "custom_data": { + "features": { + "crm": true, + "data_retention": false, + "reports": true + }, + "suggested_addons": [ + "pro_01h1vjes1y163xfj1rh1tkfb65", + "pro_01gsz97mq9pa4fkyy0wqenepkz" + ], + "upgrade_description": "Move from Basic to Pro to take advantage of advanced reporting and a CRM that's right where you're chatting." + }, + "status": "active", + "import_meta": null + }, + "tax_rate": "0", + "unit_totals": { + "subtotal": "3000", + "discount": "0", + "tax": "0", + "total": "3000" + }, + "proration": { + "rate": "1", + "billing_period": { + "starts_at": "2024-01-14T16:52:06.565582Z", + "ends_at": "2024-02-14T16:52:06.565582Z" + } + } + }, + { + "item_id": null, + "price_id": "pri_01gsz95g2zrkagg294kpstx54r", + "quantity": 1, + "totals": { + "subtotal": "25000", + "tax": "0", + "discount": "0", + "total": "25000" + }, + "product": { + "id": "pro_01gsz92krfzy3hcx5h5rtgnfwz", + "name": "VIP support", + "type": "standard", + "tax_category": "standard", + "description": "Get exclusive access to our expert team of product specialists, available to help you make the most of your ChatApp subscription.", + "image_url": "https://paddle-sandbox.s3.amazonaws.com/user/10889/SW3OevDQ92dUHSkN5a2x_icon3.png", + "custom_data": null, + "status": "active", + "import_meta": null + }, + "tax_rate": "0", + "unit_totals": { + "subtotal": "25000", + "discount": "0", + "tax": "0", + "total": "25000" + }, + "proration": { + "rate": "1", + "billing_period": { + "starts_at": "2024-01-14T16:52:06.565582Z", + "ends_at": "2024-02-14T16:52:06.565582Z" + } + } + } + ] + }, "next_transaction": { "billing_period": { - "starts_at": "2023-12-03T16:38:53.111897Z", - "ends_at": "2024-01-03T16:38:53.111897Z" + "starts_at": "2024-02-14T16:52:06.565582Z", + "ends_at": "2024-03-14T16:52:06.565582Z" }, "details": { "tax_rates_used": [ { - "tax_rate": "0.2", + "tax_rate": "0", "totals": { - "subtotal": "41667", + "subtotal": "175000", "discount": "0", - "tax": "8333", - "total": "50000" + "tax": "0", + "total": "175000" } } ], "totals": { - "subtotal": "41667", - "tax": "8333", + "subtotal": "175000", + "tax": "0", "discount": "0", - "total": "50000", + "total": "175000", "fee": null, "credit": "0", "credit_to_balance": "0", - "balance": "50000", - "grand_total": "50000", + "balance": "175000", + "grand_total": "175000", "earnings": null, "currency_code": "USD", "exchange_rate": "1" @@ -57,67 +168,84 @@ "line_items": [ { "item_id": null, - "price_id": "pri_01heb0e913gej56emc8tjrkaq1", - "quantity": 5, + "price_id": "pri_01gsz8x8sawmvhz1pv30nge1ke", + "quantity": 50, "totals": { - "subtotal": "16667", - "tax": "3333", + "subtotal": "150000", + "tax": "0", "discount": "0", - "total": "20000" + "total": "150000" }, "product": { - "id": "pro_01heb0cesy14mwnpyps6ee3hdc", - "name": " Basic Plan Product", - "description": "This is a description of my fav product", + "id": "pro_01gsz4t5hdjse780zja8vvr7jg", + "name": "ChatApp Pro", + "type": "standard", "tax_category": "standard", - "image_url": "http://example.com", - "status": "active" + "description": "Everything in basic, plus access to a suite of powerful tools and features designed to take your team's productivity to the next level.", + "image_url": "https://paddle-sandbox.s3.amazonaws.com/user/10889/2nmP8MQSret0aWeDemRw_icon1.png", + "custom_data": { + "features": { + "crm": true, + "data_retention": false, + "reports": true + }, + "suggested_addons": [ + "pro_01h1vjes1y163xfj1rh1tkfb65", + "pro_01gsz97mq9pa4fkyy0wqenepkz" + ], + "upgrade_description": "Move from Basic to Pro to take advantage of advanced reporting and a CRM that's right where you're chatting." + }, + "status": "active", + "import_meta": null }, - "tax_rate": "0.2", + "tax_rate": "0", "unit_totals": { - "subtotal": "3333", + "subtotal": "3000", "discount": "0", - "tax": "667", - "total": "4000" + "tax": "0", + "total": "3000" }, "proration": { "rate": "1", "billing_period": { - "starts_at": "2023-12-03T16:38:53.111897Z", - "ends_at": "2024-01-03T16:38:53.111897Z" + "starts_at": "2024-02-14T16:52:06.565582Z", + "ends_at": "2024-03-14T16:52:06.565582Z" } } }, { "item_id": null, - "price_id": "pri_01heb0fkqcnj94ykp5c3r8e0ja", - "quantity": 10, + "price_id": "pri_01gsz95g2zrkagg294kpstx54r", + "quantity": 1, "totals": { "subtotal": "25000", - "tax": "5000", + "tax": "0", "discount": "0", - "total": "30000" + "total": "25000" }, "product": { - "id": "pro_01heb0eqkjnw4pwgshghq87qga", - "name": "Recurring Addon Test", - "description": "", + "id": "pro_01gsz92krfzy3hcx5h5rtgnfwz", + "name": "VIP support", + "type": "standard", "tax_category": "standard", - "image_url": "", - "status": "active" + "description": "Get exclusive access to our expert team of product specialists, available to help you make the most of your ChatApp subscription.", + "image_url": "https://paddle-sandbox.s3.amazonaws.com/user/10889/SW3OevDQ92dUHSkN5a2x_icon3.png", + "custom_data": null, + "status": "active", + "import_meta": null }, - "tax_rate": "0.2", + "tax_rate": "0", "unit_totals": { - "subtotal": "2500", + "subtotal": "25000", "discount": "0", - "tax": "500", - "total": "3000" + "tax": "0", + "total": "25000" }, "proration": { "rate": "1", "billing_period": { - "starts_at": "2023-12-03T16:38:53.111897Z", - "ends_at": "2024-01-03T16:38:53.111897Z" + "starts_at": "2024-02-14T16:52:06.565582Z", + "ends_at": "2024-03-14T16:52:06.565582Z" } } } @@ -125,171 +253,33 @@ }, "adjustments": [] }, - "scheduled_change": null, - "items": [ - { - "status": "active", - "quantity": 5, - "recurring": true, - "created_at": "2023-11-03T16:38:55.036Z", - "updated_at": "2023-11-03T16:38:55.036Z", - "previously_billed_at": "2023-11-03T16:38:53.111897Z", - "next_billed_at": "2023-12-03T16:38:53.111897Z", - "trial_dates": null, - "price": { - "id": "pri_01heb0e913gej56emc8tjrkaqa", - "product_id": "pro_01heb0cesy14mwnpyps6ee3hda", - "description": "basic plan", - "tax_mode": "internal", - "billing_cycle": { - "frequency": 1, - "interval": "month" - }, - "trial_period": null, - "unit_price": { - "amount": "4000", - "currency_code": "USD" - } - } - }, - { - "status": "active", - "quantity": 10, - "recurring": true, - "created_at": "2023-11-03T16:38:55.036Z", - "updated_at": "2023-11-03T16:38:55.036Z", - "previously_billed_at": "2023-11-03T16:38:53.111897Z", - "next_billed_at": "2023-12-03T16:38:53.111897Z", - "trial_dates": null, - "price": { - "id": "pri_01heb0fkqcnj94ykp5c3r8e0ja", - "product_id": "pro_01heb0eqkjnw4pwgshghq87qga", - "description": "recurring addon", - "tax_mode": "internal", - "billing_cycle": { - "frequency": 1, - "interval": "month" - }, - "trial_period": null, - "unit_price": { - "amount": "3000", - "currency_code": "USD" - } - } - } - ], - "custom_data": null, - "management_urls": { - "update_payment_method": "https://buyer-portal.paddle.com/subscriptions/sub_01heb0tj9w00j33bfbq3469cy0/update-payment-method?token=pga_eyJhbGciOiJFZERTQSIsImtpZCI6Imp3a18wMWhkazBuOHF3OG55NTJ5cGNocGNhazA1ayIsInR5cCI6IkpXVCJ9.eyJpZCI6InBnYV8wMWhlanBja2s1Z2trYmZhcWhhYXgyNnJlYSIsInNlbGxlci1pZCI6IjUwNiIsInR5cGUiOiJzdGFuZGFyZCIsInZlcnNpb24iOiIxIiwidXNhZ2UiOiJtYW5hZ2VtZW50X3VybCIsInNjb3BlIjoiY3VzdG9tZXIuc3Vic2NyaXB0aW9uLXBheW1lbnQudXBkYXRlIGN1c3RvbWVyLnN1YnNjcmlwdGlvbi1wYXltZW50LnJlYWQgY3VzdG9tZXIuc3Vic2NyaXB0aW9uLWNhbmNlbC5jcmVhdGUgY3VzdG9tZXIuc3Vic2NyaXB0aW9uLnJlYWQiLCJpc3MiOiJndWVzdGFjY2Vzcy1zZXJ2aWNlIiwic3ViIjoiY3RtXzAxaGVhcXd2YjlrdjRkdjR2NjdtNzM4ZHR2IiwiZXhwIjoxNzMyNzE3OTEyLCJpYXQiOjE2OTkyODcwMjd9.YX52k0BnP5KqXmaCKK7MBsvXMnxXDw0q_ZYKV25zkjLSzmAYG0ME1flRqj8b5WcoeFJLI8z0UPAhtFqys30XCA", - "cancel": "https://buyer-portal.paddle.com/subscriptions/sub_01heb0tj9w00j33bfbq3469cy0/cancel?token=pga_eyJhbGciOiJFZERTQSIsImtpZCI6Imp3a18wMWhkazBuOHF3OG55NTJ5cGNocGNhazA1ayIsInR5cCI6IkpXVCJ9.eyJpZCI6InBnYV8wMWhlanBja2s1Z2trYmZhcWhhYXgyNnJlYSIsInNlbGxlci1pZCI6IjUwNiIsInR5cGUiOiJzdGFuZGFyZCIsInZlcnNpb24iOiIxIiwidXNhZ2UiOiJtYW5hZ2VtZW50X3VybCIsInNjb3BlIjoiY3VzdG9tZXIuc3Vic2NyaXB0aW9uLXBheW1lbnQudXBkYXRlIGN1c3RvbWVyLnN1YnNjcmlwdGlvbi1wYXltZW50LnJlYWQgY3VzdG9tZXIuc3Vic2NyaXB0aW9uLWNhbmNlbC5jcmVhdGUgY3VzdG9tZXIuc3Vic2NyaXB0aW9uLnJlYWQiLCJpc3MiOiJndWVzdGFjY2Vzcy1zZXJ2aWNlIiwic3ViIjoiY3RtXzAxaGVhcXd2YjlrdjRkdjR2NjdtNzM4ZHR2IiwiZXhwIjoxNzMyNzE3OTEyLCJpYXQiOjE2OTkyODcwMjd9.YX52k0BnP5KqXmaCKK7MBsvXMnxXDw0q_ZYKV25zkjLSzmAYG0ME1flRqj8b5WcoeFJLI8z0UPAhtFqys30XCA" - }, - "discount": null, - "recurring_transaction_details": { - "tax_rates_used": [ - { - "tax_rate": "0.08875", - "totals": { - "subtotal": "178500", - "discount": "0", - "tax": "15841", - "total": "194341" - } - } - ], - "totals": { - "subtotal": "178500", - "tax": "15841", - "discount": "0", - "total": "194341", - "fee": null, - "credit": "0", - "credit_to_balance": "0", - "balance": "194341", - "grand_total": "194341", - "earnings": null, - "currency_code": "USD", - "exchange_rate": "1" - }, - "line_items": [ - { - "price_id": "pri_01gsz8x8sawmvhz1pv30nge1ke", - "quantity": 50, - "totals": { - "subtotal": "150000", - "tax": "13312", - "discount": "0", - "total": "163312" - }, - "product": { - "id": "pro_01gsz4t5hdjse780zja8vvr7jg", - "name": "ChatApp Pro", - "description": "Everything in basic, plus access to a suite of powerful tools and features designed to take your team's productivity to the next level.", - "tax_category": "standard", - "image_url": "https://paddle-sandbox.s3.amazonaws.com/user/10889/2nmP8MQSret0aWeDemRw_icon1.png", - "status": "active" - }, - "tax_rate": "0.08875", - "unit_totals": { - "subtotal": "3000", - "discount": "0", - "tax": "266", - "total": "3266" - } - }, - { - "price_id": "pri_01gsz95g2zrkagg294kpstx54r", - "quantity": 1, - "totals": { - "subtotal": "28500", - "tax": "2529", - "discount": "0", - "total": "31029" - }, - "product": { - "id": "pro_01gsz92krfzy3hcx5h5rtgnfwz", - "name": "VIP support", - "description": "Get exclusive access to our expert team of product specialists, available to help you make the most of your ChatApp subscription.", - "tax_category": "standard", - "image_url": "https://paddle-sandbox.s3.amazonaws.com/user/10889/SW3OevDQ92dUHSkN5a2x_icon3.png", - "status": "active" - }, - "tax_rate": "0.08875", - "unit_totals": { - "subtotal": "28500", - "discount": "0", - "tax": "2529", - "total": "31029" - } - } - ] - }, "immediate_transaction": { "billing_period": { - "starts_at": "2023-12-03T16:38:53.111897Z", - "ends_at": "2024-01-03T16:38:53.111897Z" + "starts_at": "2024-02-06T15:33:47.447Z", + "ends_at": "2024-02-14T16:52:06.565582Z" }, "details": { "tax_rates_used": [ { - "tax_rate": "0.2", + "tax_rate": "0", "totals": { - "subtotal": "41667", + "subtotal": "45471", "discount": "0", - "tax": "8333", - "total": "50000" + "tax": "0", + "total": "45471" } } ], "totals": { - "subtotal": "41667", - "tax": "8333", + "subtotal": "45471", + "tax": "0", "discount": "0", - "total": "50000", + "total": "45471", "fee": null, - "credit": "0", + "credit": "10393", "credit_to_balance": "0", - "balance": "50000", - "grand_total": "50000", + "balance": "35078", + "grand_total": "35078", "earnings": null, "currency_code": "USD", "exchange_rate": "1" @@ -297,67 +287,84 @@ "line_items": [ { "item_id": null, - "price_id": "pri_01heb0e913gej56emc8tjrkaq1", - "quantity": 5, + "price_id": "pri_01gsz8x8sawmvhz1pv30nge1ke", + "quantity": 50, "totals": { - "subtotal": "16667", - "tax": "3333", + "subtotal": "38975", + "tax": "0", "discount": "0", - "total": "20000" + "total": "38975" }, "product": { - "id": "pro_01heb0cesy14mwnpyps6ee3hdc", - "name": " Basic Plan Product", - "description": "This is a description of my fav product", + "id": "pro_01gsz4t5hdjse780zja8vvr7jg", + "name": "ChatApp Pro", + "type": "standard", "tax_category": "standard", - "image_url": "http://example.com", - "status": "active" + "description": "Everything in basic, plus access to a suite of powerful tools and features designed to take your team's productivity to the next level.", + "image_url": "https://paddle-sandbox.s3.amazonaws.com/user/10889/2nmP8MQSret0aWeDemRw_icon1.png", + "custom_data": { + "features": { + "crm": true, + "data_retention": false, + "reports": true + }, + "suggested_addons": [ + "pro_01h1vjes1y163xfj1rh1tkfb65", + "pro_01gsz97mq9pa4fkyy0wqenepkz" + ], + "upgrade_description": "Move from Basic to Pro to take advantage of advanced reporting and a CRM that's right where you're chatting." + }, + "status": "active", + "import_meta": null }, - "tax_rate": "0.2", + "tax_rate": "0", "unit_totals": { - "subtotal": "3333", + "subtotal": "779", "discount": "0", - "tax": "667", - "total": "4000" + "tax": "0", + "total": "779" }, "proration": { - "rate": "1", + "rate": "0.25983", "billing_period": { - "starts_at": "2023-12-03T16:38:53.111897Z", - "ends_at": "2024-01-03T16:38:53.111897Z" + "starts_at": "2024-02-06T15:33:46.944Z", + "ends_at": "2024-02-14T16:52:06.565582Z" } } }, { "item_id": null, - "price_id": "pri_01heb0fkqcnj94ykp5c3r8e0ja", - "quantity": 10, + "price_id": "pri_01gsz95g2zrkagg294kpstx54r", + "quantity": 1, "totals": { - "subtotal": "25000", - "tax": "5000", + "subtotal": "6496", + "tax": "0", "discount": "0", - "total": "30000" + "total": "6496" }, "product": { - "id": "pro_01heb0eqkjnw4pwgshghq87qga", - "name": "Recurring Addon Test", - "description": "", + "id": "pro_01gsz92krfzy3hcx5h5rtgnfwz", + "name": "VIP support", + "type": "standard", "tax_category": "standard", - "image_url": "", - "status": "active" + "description": "Get exclusive access to our expert team of product specialists, available to help you make the most of your ChatApp subscription.", + "image_url": "https://paddle-sandbox.s3.amazonaws.com/user/10889/SW3OevDQ92dUHSkN5a2x_icon3.png", + "custom_data": null, + "status": "active", + "import_meta": null }, - "tax_rate": "0.2", + "tax_rate": "0", "unit_totals": { - "subtotal": "2500", + "subtotal": "6496", "discount": "0", - "tax": "500", - "total": "3000" + "tax": "0", + "total": "6496" }, "proration": { - "rate": "1", + "rate": "0.25983", "billing_period": { - "starts_at": "2023-12-03T16:38:53.111897Z", - "ends_at": "2024-01-03T16:38:53.111897Z" + "starts_at": "2024-02-06T15:33:47.046Z", + "ends_at": "2024-02-14T16:52:06.565582Z" } } } @@ -365,39 +372,131 @@ }, "adjustments": [ { - "transaction_id": "txn_01h8bxpvx398a7zbawb77y0kp5", + "transaction_id": "txn_01hm4e3z7953tarerdx59n4cf6", "items": [ { - "item_id": "txnitm_01h8bxryv3065dyh6103p3yg28", + "item_id": "txnitm_01hm4e55pedstmc53e45qzf3jp", + "type": "proration", + "amount": "7795", + "proration": { + "rate": "0.25983", + "billing_period": { + "starts_at": "2024-02-06T15:33:46.939Z", + "ends_at": "2024-02-14T16:52:06.565582Z" + } + }, + "totals": { + "subtotal": "7795", + "tax": "0", + "total": "7795" + } + }, + { + "item_id": "txnitm_01hm4e55pedstmc53e4ae03ydh", "type": "proration", - "amount": "97987", + "amount": "2598", "proration": { - "rate": "1", + "rate": "0.25983", "billing_period": { - "starts_at": "2023-08-21T11:31:59.284Z", - "ends_at": "2023-09-21T11:31:08.689295Z" + "starts_at": "2024-02-06T15:33:46.96Z", + "ends_at": "2024-02-14T16:52:06.565582Z" } }, "totals": { - "subtotal": "90000", - "tax": "7987", - "total": "97987" + "subtotal": "2598", + "tax": "0", + "total": "2598" } } ], "totals": { - "subtotal": "90000", - "tax": "7987", - "total": "97987", - "fee": "4949", - "earnings": "85051", + "subtotal": "10393", + "tax": "0", + "total": "10393", + "fee": "528", + "earnings": "9865", "currency_code": "USD" } } ] - } + }, + "scheduled_change": null, + "items": [ + { + "status": "active", + "quantity": 50, + "recurring": true, + "created_at": "2024-01-14T16:52:08.075Z", + "updated_at": "2024-02-06T15:33:46.921Z", + "previously_billed_at": "2024-01-14T16:52:06.565582Z", + "next_billed_at": "2024-02-14T16:52:06.565582Z", + "trial_dates": null, + "price": { + "id": "pri_01gsz8x8sawmvhz1pv30nge1ke", + "product_id": "pro_01gsz4t5hdjse780zja8vvr7jg", + "description": "Monthly (per seat)", + "tax_mode": "account_setting", + "billing_cycle": { + "frequency": 1, + "interval": "month" + }, + "trial_period": null, + "unit_price": { + "amount": "3000", + "currency_code": "USD" + } + } + }, + { + "status": "active", + "quantity": 1, + "recurring": true, + "created_at": "2024-02-06T15:33:46.962Z", + "updated_at": "2024-02-06T15:33:46.962Z", + "previously_billed_at": "2024-02-06T15:33:46.962Z", + "next_billed_at": "2024-02-14T16:52:06.565582Z", + "trial_dates": null, + "price": { + "id": "pri_01gsz95g2zrkagg294kpstx54r", + "product_id": "pro_01gsz92krfzy3hcx5h5rtgnfwz", + "description": "Monthly (recurring addon)", + "tax_mode": "account_setting", + "billing_cycle": { + "frequency": 1, + "interval": "month" + }, + "trial_period": null, + "unit_price": { + "amount": "25000", + "currency_code": "USD" + } + } + } + ], + "custom_data": null, + "management_urls": { + "update_payment_method": "https://sandbox-buyer-portal.paddle.com/subscriptions/sub_01hm4e6grb3nm3y0kav5xz9g6w/update-payment-method?token=pga_eyJhbGciOiJFZERTQSIsImtpZCI6Imp3a18wMWhkazBuOHF3OG55NTJ5cGNocGNhazA1I6IkpXVCJ9.eyJpZCI6InBnYV8wMWhuemd2azlkdmt5N3pqM3FzdmVzajJnYSIsInNlbGxlci1pZCI6IjEwODg5IiwidHlwZSI6InN0YW5kYXJkIiwidmVyc2lvbiI6IjEiLCJ1c2FnZSI6Im1hbmFnZW1lbnRfdXJsIiwic2NvcGUiOiJjdXN0b21lci5zdWJzY3JpcHRpb24tcGF5bWVudC51cGRhdGUgY3VzdG9tZXIuc3Vic2NyaXB0aW9uLXBheW1lbnQucmVhZCBjdXN0b21lci5zdWJzY3JpcHRpb24tY2FuY2VsLmNyZWF0ZSBjdXN0b21lci5zdWJzY3JpcHRpb24ucmVhZCIsImlzcyI6Imd1ZXN0YWNjZXNzLXNlcnZpY2UiLCJzdWIiOiJjdG1fMDFobTRlNTVmN2NxNzU5ejJ0NGhueThjaDIiLCJleHAiOjE3Mzg4NTYwMjcsImlhdCI6MTcwNzIzMzYyN30.og8fsYmsErcNMoVnbhlddnecCziCWQsgtmtYAgrYuaLVWHSTYONWYo-h5KQKrUT9FiMrp38eeGSU-SyLEK8LCA", + "cancel": "https://sandbox-buyer-portal.paddle.com/subscriptions/sub_01hm4e6grb3nm3y0kav5xz9g6w/cancel?token=pga_eyJhbGciOiJFZERTQSIsImtpZCI6Imp3a18wMWhkazBuOHF3OG55NTJ5cGNocGNhazA1ayIsInR5cCI6IkpXVCJ9.eyJpZCI6Inuemd2azlkdmt5N3pqM3FzdmVzajJnYSIsInNlbGxlci1pZCI6IjEwODg5IiwidHlwZSI6InN0YW5kYXJkIiwidmVyc2lvbiI6IjEiLCJ1c2FnZSI6Im1hbmFnZW1lbnRfdXJsIiwic2NvcGUiOiJjdXN0b21lci5zdWJzY3JpcHRpb24tcGF5bWVudC51cGRhdGUgY3VzdG9tZXIuc3Vic2NyaXB0aW9uLXBheW1lbnQucmVhZCBjdXN0b21lci5zdWJzY3JpcHRpb24tY2FuY2VsLmNyZWF0ZSBjdXN0b21lci5zdWJzY3JpcHRpb24ucmVhZCIsImlzcyI6Imd1ZXN0YWNjZXNzLXNlcnZpY2UiLCJzdWIiOiJjdG1fMDFobTRlNTVmN2NxNzU5ejJ0NGhueThjaDIiLCJleHAiOjE3Mzg4NTYwMjcsImlhdCI6MTcwNzIzMzYyN30.og8fsYmsErcNMoVnbhlddnecCziCWQsgtmtYAgrYuaLVWHSTYONWYo-h5KQKrUT9FiMrp38eeGSU-SyLEK8LCA" + }, + "discount": null, + "update_summary": { + "credit": { + "amount": "10393", + "currency_code": "USD" + }, + "charge": { + "amount": "45471", + "currency_code": "USD" + }, + "result": { + "action": "charge", + "amount": "35078", + "currency_code": "USD" + } + }, + "import_meta": null }, "meta": { - "request_id": "1e465507-6d78-4553-9186-8ac8dfa02318" + "request_id": "cc2cfeba-1931-42ce-9557-9ac3ae18dd1b" } }