-
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.
feat: Add transaction preview operations (#45)
* feat: Add transaction preview operations * fix: Fixed TransactionItemPreviewWithNonCatalogPrice.from_dict
- Loading branch information
1 parent
5fa760f
commit 5c9815d
Showing
18 changed files
with
657 additions
and
78 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
11 changes: 3 additions & 8 deletions
11
...sactions/Operations/PreviewTransaction.py → ...Operations/PreviewTransactionByAddress.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
20 changes: 20 additions & 0 deletions
20
paddle_billing/Resources/Transactions/Operations/PreviewTransactionByCustomer.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,20 @@ | ||
from dataclasses import asdict, dataclass | ||
|
||
from paddle_billing.Undefined import Undefined | ||
from paddle_billing.Entities.Shared import CurrencyCode | ||
from paddle_billing.Entities.Transactions import TransactionItemPreviewWithPriceId, TransactionItemPreviewWithNonCatalogPrice | ||
|
||
|
||
@dataclass | ||
class PreviewTransactionByCustomer: | ||
address_id: str | ||
customer_id: str | ||
items: list[TransactionItemPreviewWithPriceId | TransactionItemPreviewWithNonCatalogPrice] | ||
business_id: str | None | Undefined = Undefined() | ||
currency_code: CurrencyCode | Undefined = Undefined() | ||
discount_id: str | None | Undefined = Undefined() | ||
ignore_trials: bool | Undefined = Undefined() | ||
|
||
|
||
def get_parameters(self) -> dict: | ||
return asdict(self) |
19 changes: 19 additions & 0 deletions
19
paddle_billing/Resources/Transactions/Operations/PreviewTransactionByIP.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,19 @@ | ||
from dataclasses import asdict, dataclass | ||
|
||
from paddle_billing.Undefined import Undefined | ||
from paddle_billing.Entities.Shared import CurrencyCode | ||
from paddle_billing.Entities.Transactions import TransactionItemPreviewWithPriceId, TransactionItemPreviewWithNonCatalogPrice | ||
|
||
|
||
@dataclass | ||
class PreviewTransactionByIP: | ||
customer_ip_address: str | ||
items: list[TransactionItemPreviewWithPriceId | TransactionItemPreviewWithNonCatalogPrice] | ||
customer_id: str | None | Undefined = Undefined() | ||
currency_code: CurrencyCode | Undefined = Undefined() | ||
discount_id: str | None | Undefined = Undefined() | ||
ignore_trials: bool | Undefined = Undefined() | ||
|
||
|
||
def get_parameters(self) -> dict: | ||
return asdict(self) |
16 changes: 9 additions & 7 deletions
16
paddle_billing/Resources/Transactions/Operations/__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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
from paddle_billing.Resources.Transactions.Operations.CreateTransaction import CreateTransaction | ||
from paddle_billing.Resources.Transactions.Operations.ListTransactions import ListTransactions | ||
from paddle_billing.Resources.Transactions.Operations.List.Includes import Includes as TransactionIncludes | ||
from paddle_billing.Resources.Transactions.Operations.List.Origin import Origin as TransactionOrigin | ||
from paddle_billing.Resources.Transactions.Operations.PreviewTransaction import PreviewTransaction | ||
from paddle_billing.Resources.Transactions.Operations.UpdateTransaction import UpdateTransaction | ||
from paddle_billing.Resources.Transactions.Operations.GetTransactionInvoice import GetTransactionInvoice | ||
from paddle_billing.Resources.Transactions.Operations.CreateTransaction import CreateTransaction | ||
from paddle_billing.Resources.Transactions.Operations.ListTransactions import ListTransactions | ||
from paddle_billing.Resources.Transactions.Operations.List.Includes import Includes as TransactionIncludes | ||
from paddle_billing.Resources.Transactions.Operations.List.Origin import Origin as TransactionOrigin | ||
from paddle_billing.Resources.Transactions.Operations.PreviewTransactionByAddress import PreviewTransactionByAddress | ||
from paddle_billing.Resources.Transactions.Operations.PreviewTransactionByCustomer import PreviewTransactionByCustomer | ||
from paddle_billing.Resources.Transactions.Operations.PreviewTransactionByIP import PreviewTransactionByIP | ||
from paddle_billing.Resources.Transactions.Operations.UpdateTransaction import UpdateTransaction | ||
from paddle_billing.Resources.Transactions.Operations.GetTransactionInvoice import GetTransactionInvoice |
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
tests/Functional/Resources/Transactions/_fixtures/request/preview_by_address_basic.json
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 @@ | ||
{ | ||
"address": { | ||
"postal_code": "12345", | ||
"country_code": "US" | ||
}, | ||
"items": [ | ||
{ | ||
"quantity": 1, | ||
"price_id": "pri_01he5kxqey1k8ankgef29cj4bv", | ||
"include_in_totals": true | ||
} | ||
] | ||
} |
70 changes: 70 additions & 0 deletions
70
tests/Functional/Resources/Transactions/_fixtures/request/preview_by_address_full.json
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,70 @@ | ||
{ | ||
"address": { | ||
"postal_code": "12345", | ||
"country_code": "US" | ||
}, | ||
"customer_id": "ctm_01h844q4mznqpgqgm6evgw1w63", | ||
"currency_code": "USD", | ||
"discount_id": "dsc_01gtgztp8fpchantd5g1wrksa3", | ||
"ignore_trials": true, | ||
"items": [ | ||
{ | ||
"quantity": 20, | ||
"price": { | ||
"description": "Annual (per seat)", | ||
"name": "Annual (per seat)", | ||
"product_id": "pro_01gsz4t5hdjse780zja8vvr7jg", | ||
"billing_cycle": { | ||
"interval": "year", | ||
"frequency": 1 | ||
}, | ||
"trial_period": null, | ||
"tax_mode": "account_setting", | ||
"unit_price": { | ||
"amount": "30000", | ||
"currency_code": "USD" | ||
}, | ||
"unit_price_overrides": [], | ||
"quantity": { | ||
"minimum": 10, | ||
"maximum": 999 | ||
}, | ||
"custom_data": null | ||
}, | ||
"include_in_totals": true | ||
}, | ||
{ | ||
"quantity": 20, | ||
"price": { | ||
"description": "Annual (per seat)", | ||
"name": "Annual (per seat)", | ||
"product": { | ||
"name": "Analytics addon", | ||
"description": "Some Description", | ||
"tax_category": "standard", | ||
"image_url": "https://paddle.s3.amazonaws.com/user/165798/97dRpA6SXzcE6ekK9CAr_analytics.png", | ||
"custom_data": { | ||
"key": "value" | ||
} | ||
}, | ||
"billing_cycle": { | ||
"interval": "year", | ||
"frequency": 1 | ||
}, | ||
"trial_period": null, | ||
"tax_mode": "account_setting", | ||
"unit_price": { | ||
"amount": "30000", | ||
"currency_code": "USD" | ||
}, | ||
"unit_price_overrides": [], | ||
"quantity": { | ||
"minimum": 10, | ||
"maximum": 999 | ||
}, | ||
"custom_data": null | ||
}, | ||
"include_in_totals": true | ||
} | ||
] | ||
} |
11 changes: 11 additions & 0 deletions
11
tests/Functional/Resources/Transactions/_fixtures/request/preview_by_customer_basic.json
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,11 @@ | ||
{ | ||
"address_id": "add_01hv8h6jj90jjz0d71m6hj4r9z", | ||
"customer_id": "ctm_01h844q4mznqpgqgm6evgw1w63", | ||
"items": [ | ||
{ | ||
"quantity": 1, | ||
"price_id": "pri_01he5kxqey1k8ankgef29cj4bv", | ||
"include_in_totals": true | ||
} | ||
] | ||
} |
68 changes: 68 additions & 0 deletions
68
tests/Functional/Resources/Transactions/_fixtures/request/preview_by_customer_full.json
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,68 @@ | ||
{ | ||
"address_id": "add_01hv8h6jj90jjz0d71m6hj4r9z", | ||
"customer_id": "ctm_01h844q4mznqpgqgm6evgw1w63", | ||
"business_id": "biz_01hv8j0z17hv4ew8teebwjmfcb", | ||
"currency_code": "USD", | ||
"discount_id": "dsc_01gtgztp8fpchantd5g1wrksa3", | ||
"ignore_trials": true, | ||
"items": [ | ||
{ | ||
"quantity": 20, | ||
"price": { | ||
"description": "Annual (per seat)", | ||
"name": "Annual (per seat)", | ||
"product_id": "pro_01gsz4t5hdjse780zja8vvr7jg", | ||
"billing_cycle": { | ||
"interval": "year", | ||
"frequency": 1 | ||
}, | ||
"trial_period": null, | ||
"tax_mode": "account_setting", | ||
"unit_price": { | ||
"amount": "30000", | ||
"currency_code": "USD" | ||
}, | ||
"unit_price_overrides": [], | ||
"quantity": { | ||
"minimum": 10, | ||
"maximum": 999 | ||
}, | ||
"custom_data": null | ||
}, | ||
"include_in_totals": true | ||
}, | ||
{ | ||
"quantity": 20, | ||
"price": { | ||
"description": "Annual (per seat)", | ||
"name": "Annual (per seat)", | ||
"product": { | ||
"name": "Analytics addon", | ||
"description": "Some Description", | ||
"tax_category": "standard", | ||
"image_url": "https://paddle.s3.amazonaws.com/user/165798/97dRpA6SXzcE6ekK9CAr_analytics.png", | ||
"custom_data": { | ||
"key": "value" | ||
} | ||
}, | ||
"billing_cycle": { | ||
"interval": "year", | ||
"frequency": 1 | ||
}, | ||
"trial_period": null, | ||
"tax_mode": "account_setting", | ||
"unit_price": { | ||
"amount": "30000", | ||
"currency_code": "USD" | ||
}, | ||
"unit_price_overrides": [], | ||
"quantity": { | ||
"minimum": 10, | ||
"maximum": 999 | ||
}, | ||
"custom_data": null | ||
}, | ||
"include_in_totals": true | ||
} | ||
] | ||
} |
1 change: 1 addition & 0 deletions
1
...ions/_fixtures/request/preview_basic.json → ...fixtures/request/preview_by_ip_basic.json
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,4 +1,5 @@ | ||
{ | ||
"customer_ip_address": "203.0.113.0", | ||
"items": [ | ||
{ | ||
"quantity": 1, | ||
|
67 changes: 67 additions & 0 deletions
67
tests/Functional/Resources/Transactions/_fixtures/request/preview_by_ip_full.json
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,67 @@ | ||
{ | ||
"customer_ip_address": "203.0.113.0", | ||
"customer_id": "ctm_01h844q4mznqpgqgm6evgw1w63", | ||
"currency_code": "USD", | ||
"discount_id": "dsc_01gtgztp8fpchantd5g1wrksa3", | ||
"ignore_trials": true, | ||
"items": [ | ||
{ | ||
"quantity": 20, | ||
"price": { | ||
"description": "Annual (per seat)", | ||
"name": "Annual (per seat)", | ||
"product_id": "pro_01gsz4t5hdjse780zja8vvr7jg", | ||
"billing_cycle": { | ||
"interval": "year", | ||
"frequency": 1 | ||
}, | ||
"trial_period": null, | ||
"tax_mode": "account_setting", | ||
"unit_price": { | ||
"amount": "30000", | ||
"currency_code": "USD" | ||
}, | ||
"unit_price_overrides": [], | ||
"quantity": { | ||
"minimum": 10, | ||
"maximum": 999 | ||
}, | ||
"custom_data": null | ||
}, | ||
"include_in_totals": true | ||
}, | ||
{ | ||
"quantity": 20, | ||
"price": { | ||
"description": "Annual (per seat)", | ||
"name": "Annual (per seat)", | ||
"product": { | ||
"name": "Analytics addon", | ||
"description": "Some Description", | ||
"tax_category": "standard", | ||
"image_url": "https://paddle.s3.amazonaws.com/user/165798/97dRpA6SXzcE6ekK9CAr_analytics.png", | ||
"custom_data": { | ||
"key": "value" | ||
} | ||
}, | ||
"billing_cycle": { | ||
"interval": "year", | ||
"frequency": 1 | ||
}, | ||
"trial_period": null, | ||
"tax_mode": "account_setting", | ||
"unit_price": { | ||
"amount": "30000", | ||
"currency_code": "USD" | ||
}, | ||
"unit_price_overrides": [], | ||
"quantity": { | ||
"minimum": 10, | ||
"maximum": 999 | ||
}, | ||
"custom_data": null | ||
}, | ||
"include_in_totals": true | ||
} | ||
] | ||
} |
Oops, something went wrong.