-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Add billing details create/update operations (#58)
- Loading branch information
1 parent
55a9f85
commit 0dee3db
Showing
30 changed files
with
310 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from abc import ABC | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass | ||
class Operation(ABC): | ||
pass |
24 changes: 9 additions & 15 deletions
24
paddle_billing/Resources/Subscriptions/Operations/PreviewUpdateSubscription.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,35 @@ | ||
from dataclasses import asdict, dataclass | ||
from dataclasses import dataclass | ||
|
||
from paddle_billing.Operation import Operation | ||
from paddle_billing.Undefined import Undefined | ||
|
||
from paddle_billing.Entities.DateTime import DateTime | ||
from paddle_billing.Entities.Shared import BillingDetails, CollectionMode, CurrencyCode, CustomData | ||
from paddle_billing.Entities.Shared import CollectionMode, CurrencyCode, CustomData | ||
from paddle_billing.Entities.Subscriptions import ( | ||
SubscriptionItems, | ||
SubscriptionItemsWithPrice, | ||
SubscriptionOnPaymentFailure, | ||
SubscriptionProrationBillingMode, | ||
) | ||
|
||
from paddle_billing.Resources.Subscriptions.Operations.Update.SubscriptionDiscount import SubscriptionDiscount | ||
from paddle_billing.Resources.Subscriptions.Operations.Update import ( | ||
SubscriptionDiscount, | ||
UpdateBillingDetails, | ||
) | ||
|
||
|
||
@dataclass | ||
class PreviewUpdateSubscription: | ||
class PreviewUpdateSubscription(Operation): | ||
customer_id: str | Undefined = Undefined() | ||
address_id: str | Undefined = Undefined() | ||
business_id: str | None | Undefined = Undefined() | ||
currency_code: CurrencyCode | Undefined = Undefined() | ||
next_billed_at: DateTime | Undefined = Undefined() | ||
discount: SubscriptionDiscount | None | Undefined = Undefined() | ||
collection_mode: CollectionMode | Undefined = Undefined() | ||
billing_details: BillingDetails | None | Undefined = Undefined() | ||
billing_details: UpdateBillingDetails | None | Undefined = Undefined() | ||
scheduled_change: None | Undefined = Undefined() | ||
items: list[SubscriptionItems | SubscriptionItemsWithPrice] | Undefined = Undefined() | ||
custom_data: CustomData | None | Undefined = Undefined() | ||
proration_billing_mode: SubscriptionProrationBillingMode | Undefined = Undefined() | ||
on_payment_failure: SubscriptionOnPaymentFailure | Undefined = Undefined() | ||
|
||
def get_parameters(self) -> dict: | ||
parameters = asdict(self) | ||
|
||
if isinstance(self.next_billed_at, DateTime): | ||
parameters["next_billed_at"] = self.next_billed_at.format() | ||
if not isinstance(self.items, Undefined): | ||
parameters["items"] = [item.get_parameters() for item in self.items] | ||
|
||
return parameters |
13 changes: 13 additions & 0 deletions
13
paddle_billing/Resources/Subscriptions/Operations/Update/UpdateBillingDetails.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from __future__ import annotations | ||
from dataclasses import dataclass | ||
|
||
from paddle_billing.Entities.Shared.Duration import Duration | ||
from paddle_billing.Undefined import Undefined | ||
|
||
|
||
@dataclass | ||
class UpdateBillingDetails: | ||
payment_terms: Duration | Undefined = Undefined() | ||
enable_checkout: bool | Undefined = Undefined() | ||
purchase_order_number: str | Undefined = Undefined() | ||
additional_information: str | None | Undefined = Undefined() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from paddle_billing.Resources.Subscriptions.Operations.Update.SubscriptionDiscount import SubscriptionDiscount | ||
from paddle_billing.Resources.Subscriptions.Operations.Update.UpdateBillingDetails import UpdateBillingDetails |
24 changes: 9 additions & 15 deletions
24
paddle_billing/Resources/Subscriptions/Operations/UpdateSubscription.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,35 @@ | ||
from dataclasses import asdict, dataclass | ||
from dataclasses import dataclass | ||
|
||
from paddle_billing.Operation import Operation | ||
from paddle_billing.Undefined import Undefined | ||
|
||
from paddle_billing.Entities.DateTime import DateTime | ||
from paddle_billing.Entities.Shared import BillingDetails, CollectionMode, CurrencyCode, CustomData | ||
from paddle_billing.Entities.Shared import CollectionMode, CurrencyCode, CustomData | ||
from paddle_billing.Entities.Subscriptions import ( | ||
SubscriptionItems, | ||
SubscriptionItemsWithPrice, | ||
SubscriptionOnPaymentFailure, | ||
SubscriptionProrationBillingMode, | ||
) | ||
|
||
from paddle_billing.Resources.Subscriptions.Operations.Update.SubscriptionDiscount import SubscriptionDiscount | ||
from paddle_billing.Resources.Subscriptions.Operations.Update import ( | ||
SubscriptionDiscount, | ||
UpdateBillingDetails, | ||
) | ||
|
||
|
||
@dataclass | ||
class UpdateSubscription: | ||
class UpdateSubscription(Operation): | ||
customer_id: str | Undefined = Undefined() | ||
address_id: str | Undefined = Undefined() | ||
business_id: str | None | Undefined = Undefined() | ||
currency_code: CurrencyCode | Undefined = Undefined() | ||
next_billed_at: DateTime | Undefined = Undefined() | ||
discount: SubscriptionDiscount | None | Undefined = Undefined() | ||
collection_mode: CollectionMode | Undefined = Undefined() | ||
billing_details: BillingDetails | None | Undefined = Undefined() | ||
billing_details: UpdateBillingDetails | None | Undefined = Undefined() | ||
scheduled_change: None | Undefined = Undefined() | ||
items: list[SubscriptionItems | SubscriptionItemsWithPrice] | Undefined = Undefined() | ||
custom_data: CustomData | None | Undefined = Undefined() | ||
proration_billing_mode: SubscriptionProrationBillingMode | Undefined = Undefined() | ||
on_payment_failure: SubscriptionOnPaymentFailure | Undefined = Undefined() | ||
|
||
def get_parameters(self) -> dict: | ||
parameters = asdict(self) | ||
|
||
if isinstance(self.next_billed_at, DateTime): | ||
parameters["next_billed_at"] = self.next_billed_at.format() | ||
if not isinstance(self.items, Undefined): | ||
parameters["items"] = [item.get_parameters() for item in self.items] | ||
|
||
return parameters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
paddle_billing/Resources/Transactions/Operations/Create/CreateBillingDetails.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from __future__ import annotations | ||
from dataclasses import dataclass | ||
|
||
from paddle_billing.Entities.Shared.Duration import Duration | ||
from paddle_billing.Undefined import Undefined | ||
|
||
|
||
@dataclass | ||
class CreateBillingDetails: | ||
payment_terms: Duration | ||
enable_checkout: bool | Undefined = Undefined() | ||
purchase_order_number: str | Undefined = Undefined() | ||
additional_information: str | None | Undefined = Undefined() |
1 change: 1 addition & 0 deletions
1
paddle_billing/Resources/Transactions/Operations/Create/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from paddle_billing.Resources.Transactions.Operations.Create.CreateBillingDetails import CreateBillingDetails |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
paddle_billing/Resources/Transactions/Operations/Update/UpdateBillingDetails.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from __future__ import annotations | ||
from dataclasses import dataclass | ||
|
||
from paddle_billing.Entities.Shared.Duration import Duration | ||
from paddle_billing.Undefined import Undefined | ||
|
||
|
||
@dataclass | ||
class UpdateBillingDetails: | ||
payment_terms: Duration | Undefined = Undefined() | ||
enable_checkout: bool | Undefined = Undefined() | ||
purchase_order_number: str | Undefined = Undefined() | ||
additional_information: str | None | Undefined = Undefined() |
1 change: 1 addition & 0 deletions
1
paddle_billing/Resources/Transactions/Operations/Update/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from paddle_billing.Resources.Transactions.Operations.Update.UpdateBillingDetails import UpdateBillingDetails |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.