paddle-python-sdk 1.5.0__py3-none-any.whl → 1.6.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
paddle_billing/Client.py CHANGED
@@ -192,7 +192,7 @@ class Client:
192
192
  "Authorization": f"Bearer {self.__api_key}",
193
193
  "Content-Type": "application/json",
194
194
  "Paddle-Version": str(self.use_api_version),
195
- "User-Agent": "PaddleSDK/python 1.5.0",
195
+ "User-Agent": "PaddleSDK/python 1.6.0",
196
196
  }
197
197
  )
198
198
 
@@ -0,0 +1,18 @@
1
+ from dataclasses import dataclass
2
+
3
+ from paddle_billing.Operation import Operation
4
+ from paddle_billing.Undefined import Undefined
5
+ from paddle_billing.Entities.Shared import CurrencyCode
6
+ from paddle_billing.Resources.Transactions.Operations.Preview import (
7
+ TransactionItemPreviewWithPriceId,
8
+ TransactionItemPreviewWithNonCatalogPrice,
9
+ )
10
+
11
+
12
+ @dataclass
13
+ class PreviewTransaction(Operation):
14
+ items: list[TransactionItemPreviewWithPriceId | TransactionItemPreviewWithNonCatalogPrice]
15
+ customer_id: str | None | Undefined = Undefined()
16
+ currency_code: CurrencyCode | None | Undefined = Undefined()
17
+ discount_id: str | None | Undefined = Undefined()
18
+ ignore_trials: bool | Undefined = Undefined()
@@ -14,6 +14,6 @@ class PreviewTransactionByAddress(Operation):
14
14
  address: AddressPreview
15
15
  items: list[TransactionItemPreviewWithPriceId | TransactionItemPreviewWithNonCatalogPrice]
16
16
  customer_id: str | None | Undefined = Undefined()
17
- currency_code: CurrencyCode | Undefined = Undefined()
17
+ currency_code: CurrencyCode | None | Undefined = Undefined()
18
18
  discount_id: str | None | Undefined = Undefined()
19
19
  ignore_trials: bool | Undefined = Undefined()
@@ -15,6 +15,6 @@ class PreviewTransactionByCustomer(Operation):
15
15
  customer_id: str
16
16
  items: list[TransactionItemPreviewWithPriceId | TransactionItemPreviewWithNonCatalogPrice]
17
17
  business_id: str | None | Undefined = Undefined()
18
- currency_code: CurrencyCode | Undefined = Undefined()
18
+ currency_code: CurrencyCode | None | Undefined = Undefined()
19
19
  discount_id: str | None | Undefined = Undefined()
20
20
  ignore_trials: bool | Undefined = Undefined()
@@ -14,6 +14,6 @@ class PreviewTransactionByIP(Operation):
14
14
  customer_ip_address: str
15
15
  items: list[TransactionItemPreviewWithPriceId | TransactionItemPreviewWithNonCatalogPrice]
16
16
  customer_id: str | None | Undefined = Undefined()
17
- currency_code: CurrencyCode | Undefined = Undefined()
17
+ currency_code: CurrencyCode | None | Undefined = Undefined()
18
18
  discount_id: str | None | Undefined = Undefined()
19
19
  ignore_trials: bool | Undefined = Undefined()
@@ -2,6 +2,7 @@ from paddle_billing.Resources.Transactions.Operations.CreateTransaction import C
2
2
  from paddle_billing.Resources.Transactions.Operations.ListTransactions import ListTransactions
3
3
  from paddle_billing.Resources.Transactions.Operations.List.Includes import Includes as TransactionIncludes
4
4
  from paddle_billing.Resources.Transactions.Operations.List.Origin import Origin as TransactionOrigin
5
+ from paddle_billing.Resources.Transactions.Operations.PreviewTransaction import PreviewTransaction
5
6
  from paddle_billing.Resources.Transactions.Operations.PreviewTransactionByAddress import PreviewTransactionByAddress
6
7
  from paddle_billing.Resources.Transactions.Operations.PreviewTransactionByCustomer import PreviewTransactionByCustomer
7
8
  from paddle_billing.Resources.Transactions.Operations.PreviewTransactionByIP import PreviewTransactionByIP
@@ -11,6 +11,7 @@ from paddle_billing.Resources.Transactions.Operations import (
11
11
  CreateTransaction,
12
12
  ListTransactions,
13
13
  UpdateTransaction,
14
+ PreviewTransaction,
14
15
  PreviewTransactionByAddress,
15
16
  PreviewTransactionByCustomer,
16
17
  PreviewTransactionByIP,
@@ -80,7 +81,10 @@ class TransactionsClient:
80
81
  return Transaction.from_dict(parser.get_data())
81
82
 
82
83
  def preview(
83
- self, operation: PreviewTransactionByAddress | PreviewTransactionByCustomer | PreviewTransactionByIP
84
+ self,
85
+ operation: (
86
+ PreviewTransaction | PreviewTransactionByAddress | PreviewTransactionByCustomer | PreviewTransactionByIP
87
+ ),
84
88
  ) -> TransactionPreview:
85
89
  self.response = self.client.post_raw("/transactions/preview", operation)
86
90
  parser = ResponseParser(self.response)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: paddle-python-sdk
3
- Version: 1.5.0
3
+ Version: 1.6.0
4
4
  Summary: Paddle's Python SDK for Paddle Billing
5
5
  Home-page: https://developer.paddle.com/api-reference/overview
6
6
  Author: Paddle and contributors
@@ -194,6 +194,14 @@ from paddle_billing.Notifications import Secret, Verifier
194
194
  integrity_check = Verifier().verify(request, Secret('WEBHOOK_SECRET_KEY'))
195
195
  ```
196
196
 
197
+ The `verify()` method currently accepts any request object matching the `paddle_billing.Notifications.Requests.Request` protocol, and supports popular frameworks such as Flask and Django.
198
+
199
+ Time drift max variance can be adjusted by passing `seconds` to `Verifier()` _(default: 5 seconds)_:
200
+
201
+ ```python
202
+ integrity_check = Verifier(seconds).verify(request, Secret('WEBHOOK_SECRET_KEY'))
203
+ ```
204
+
197
205
  ## Learn more
198
206
  - [Paddle API reference](https://developer.paddle.com/api-reference/overview?utm_source=dx&utm_medium=paddle-python-sdk)
199
207
  - [Sign up for Paddle Billing](https://login.paddle.com/signup?utm_source=dx&utm_medium=paddle-python-sdk)
@@ -5,7 +5,7 @@ examples/event_polling.py,sha256=580dg_8CFrSCA89Mr1ny4V1gtB3-hk-LfePTbI7DT5w,217
5
5
  examples/get_products.py,sha256=4V7ZG1SH6Oxojufbtzm_TMySw4cOBMQ99mgQK_hlwFQ,1875
6
6
  examples/logger.py,sha256=AxmQmMrsM0ZqMIUnh6iARiczL4S4F9OqQcOu-67owNg,1042
7
7
  examples/webhook_verification.py,sha256=qkNscNdNZUAgxEIk83tCiljN2VmfePZ_k8zTliKz2QY,1205
8
- paddle_billing/Client.py,sha256=1p2Y2bAppu9xunEKN6kvBMoIPFd93ZNTtXkVEdq78Xk,8830
8
+ paddle_billing/Client.py,sha256=f1NheODtuwtMQ-rDXapcJfYaGSPbGodZyfqiY8LBQMc,8830
9
9
  paddle_billing/EnumStringify.py,sha256=iDvKULZat3jx9A-_PhvoN6CbFGf2pyxrQeYZxqX9n8M,48
10
10
  paddle_billing/Environment.py,sha256=sY4nrJUwlTugsZKncieAnvfCojqCcKWi4X7rFzjFeSQ,417
11
11
  paddle_billing/FiltersNone.py,sha256=HxjE6RJb7sy6txphpZSrCTQZt1Ua0XpIz8NDLHC43zo,268
@@ -570,17 +570,18 @@ paddle_billing/Resources/Subscriptions/Operations/Update/SubscriptionUpdateItem.
570
570
  paddle_billing/Resources/Subscriptions/Operations/Update/SubscriptionUpdateItemWithPrice.py,sha256=rgegAndEJZV2TyORSWUQCM-vw-EUmsfB83KXKlGGDno,369
571
571
  paddle_billing/Resources/Subscriptions/Operations/Update/UpdateBillingDetails.py,sha256=NAfwUJrT3slphzWfVQjDMElwjljde72wwMBX25Qe9YA,447
572
572
  paddle_billing/Resources/Subscriptions/Operations/Update/__init__.py,sha256=E6f9MsuE7pSOTUteSYIeopXw-8LL98JrGi4M15lLdqw,479
573
- paddle_billing/Resources/Transactions/TransactionsClient.py,sha256=LEZn_u8_-uc53_ZG0ed3S3AjnYPl-_6fdhv0TccQn74,4074
573
+ paddle_billing/Resources/Transactions/TransactionsClient.py,sha256=zCZMdjlOfnWOdjcYNhNMSvbRv34aK0RrpDAadfw7g28,4152
574
574
  paddle_billing/Resources/Transactions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
575
575
  paddle_billing/Resources/Transactions/Operations/CreateTransaction.py,sha256=mep3t6VssT0OCoKv4avn32nLAglSWmwTHeLQkJwLoz0,1212
576
576
  paddle_billing/Resources/Transactions/Operations/GetTransactionInvoice.py,sha256=_75FP5d6J88qsAyzUkQUFQ9JilA__AAFDZhFP5fGuqE,466
577
577
  paddle_billing/Resources/Transactions/Operations/ListTransactions.py,sha256=z6Kei4qNIo82g2uMoS-gfj4vDgTyGedyqf8S6wSD538,3946
578
- paddle_billing/Resources/Transactions/Operations/PreviewTransactionByAddress.py,sha256=ID2-iUmPKTXmhxSVfMC9GlFqnnBx108nrRllwtYr2x4,758
579
- paddle_billing/Resources/Transactions/Operations/PreviewTransactionByCustomer.py,sha256=R4cSV8a8AlLeR7u0x0RBiEcleS6D8tYGZPcHJMzGHW4,756
580
- paddle_billing/Resources/Transactions/Operations/PreviewTransactionByIP.py,sha256=I3qCgvoYD36ygnwIVBvVuy7Yk849OQD5X08k3rBnFFA,738
578
+ paddle_billing/Resources/Transactions/Operations/PreviewTransaction.py,sha256=XHUQ9g7VHFxyvom4jjCsrkKd3K7vxwTGxJ63z-FvFoY,712
579
+ paddle_billing/Resources/Transactions/Operations/PreviewTransactionByAddress.py,sha256=DMQUXKwL5T1UmDO6pyUCCjqU1oSlkCjHouAvZJViiWg,765
580
+ paddle_billing/Resources/Transactions/Operations/PreviewTransactionByCustomer.py,sha256=5-XEbEWUXzbNMCz_P8PjYFgEKKRXy1J5op0nvPcnMPE,763
581
+ paddle_billing/Resources/Transactions/Operations/PreviewTransactionByIP.py,sha256=xO7YJqNi6GMmwsXcW75Lo8wuedKSHql0fXlDYreOIko,745
581
582
  paddle_billing/Resources/Transactions/Operations/ReviseTransaction.py,sha256=zJzdYrjWGz7v246qZCu8f7VCNrwNlfUxUtZ9XyjwzEQ,472
582
583
  paddle_billing/Resources/Transactions/Operations/UpdateTransaction.py,sha256=XlBa6sDRyRonCQFspuBYqK2IFqPYhIGZpPKJZQuLnNU,1226
583
- paddle_billing/Resources/Transactions/Operations/__init__.py,sha256=JsNlLXxinM5PH6EeuN2fQgZCMSTEfo-HLZTuZtdWCNg,1042
584
+ paddle_billing/Resources/Transactions/Operations/__init__.py,sha256=oZA2BqBqIf1iB7a1WUW1WZad0zQ9vRCxq_JS3Y6OAeE,1141
584
585
  paddle_billing/Resources/Transactions/Operations/Create/CreateBillingDetails.py,sha256=e3jJJuh2q2IdU38Z8Vu724Daw65_u59ZAWuLzK4BpPI,421
585
586
  paddle_billing/Resources/Transactions/Operations/Create/TransactionCreateItem.py,sha256=220MOofKkMytoJenDdupSG2ITz67Jav5eILBKXPL4z0,147
586
587
  paddle_billing/Resources/Transactions/Operations/Create/TransactionCreateItemWithPrice.py,sha256=x0FSarygxbqzzXiFQVUHZh7t3n7idcLOuS8OACAOsE8,490
@@ -654,7 +655,7 @@ tests/Functional/Resources/Simulations/test_SimulationsClient.py,sha256=_IRaQPMS
654
655
  tests/Functional/Resources/Subscriptions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
655
656
  tests/Functional/Resources/Subscriptions/test_SubscriptionsClient.py,sha256=_QNeQ_5hk4sGQyAHpaD43t8z0zlkvZ9xYpdVlfyJanI,64187
656
657
  tests/Functional/Resources/Transactions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
657
- tests/Functional/Resources/Transactions/test_TransactionsClient.py,sha256=1TczVywW3AKhEveBN_lOP0F4y7hcXNGDL0_FX7StXhs,63884
658
+ tests/Functional/Resources/Transactions/test_TransactionsClient.py,sha256=bKYtjyA39BL1adz3CIYv0-3tAUNQoivtp6BeX3xTEdI,68896
658
659
  tests/Unit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
659
660
  tests/Unit/Logger/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
660
661
  tests/Unit/Logger/test_Logger.py,sha256=ScJoSbqpAKzw1jXGbYhnc7Y-dhf3_BY5OPsUllGFxn0,414
@@ -667,8 +668,8 @@ tests/Utils/ReadsFixture.py,sha256=3CQ_8XHji3kuR28Ktlmw1Kip565UycocUytldWtuAyw,1
667
668
  tests/Utils/TestClient.py,sha256=-wc7hJMuR6WC-ukw0c7I59b5-8hj_-nzq__-2M81elg,1453
668
669
  tests/Utils/TestLogger.py,sha256=pFO9x711buRmg-8DAqpzIJP_hr21JPty1_ZQRcwoGKk,554
669
670
  tests/Utils/__init__.py,sha256=JtqJNPKqbNZ9exlpXlF3yj_9cfylPGlvopjQYi7yYTA,37
670
- paddle_python_sdk-1.5.0.dist-info/LICENSE,sha256=e5Sn9mzCdpjnqCLxXpGHNKdYB6JlRSTLhN_CD4WSO6w,10770
671
- paddle_python_sdk-1.5.0.dist-info/METADATA,sha256=Jyt2aOgbSg9k7y8TSHDsC2MN-EDSuBgwcYgETX46xXU,7632
672
- paddle_python_sdk-1.5.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
673
- paddle_python_sdk-1.5.0.dist-info/top_level.txt,sha256=9a07VPng7o5wK8VAXkl6NC30xrNbW9zff_02jHyHi4c,30
674
- paddle_python_sdk-1.5.0.dist-info/RECORD,,
671
+ paddle_python_sdk-1.6.0.dist-info/LICENSE,sha256=e5Sn9mzCdpjnqCLxXpGHNKdYB6JlRSTLhN_CD4WSO6w,10770
672
+ paddle_python_sdk-1.6.0.dist-info/METADATA,sha256=wRs_8-4LOowtkOYJL0dMOF6_E1dQlT8LkU10dP6M2Uo,8020
673
+ paddle_python_sdk-1.6.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
674
+ paddle_python_sdk-1.6.0.dist-info/top_level.txt,sha256=9a07VPng7o5wK8VAXkl6NC30xrNbW9zff_02jHyHi4c,30
675
+ paddle_python_sdk-1.6.0.dist-info/RECORD,,
@@ -32,6 +32,7 @@ from paddle_billing.Resources.Transactions.Operations import (
32
32
  ListTransactions,
33
33
  TransactionIncludes,
34
34
  TransactionOrigin,
35
+ PreviewTransaction,
35
36
  PreviewTransactionByAddress,
36
37
  PreviewTransactionByCustomer,
37
38
  PreviewTransactionByIP,
@@ -840,6 +841,95 @@ class TestTransactionsClient:
840
841
  @mark.parametrize(
841
842
  "operation, expected_request_body, expected_response_status, expected_response_body, expected_url",
842
843
  [
844
+ (
845
+ PreviewTransaction(
846
+ items=[
847
+ TransactionItemPreviewWithPriceId(
848
+ price_id="pri_01he5kxqey1k8ankgef29cj4bv",
849
+ quantity=1,
850
+ include_in_totals=True,
851
+ )
852
+ ],
853
+ ),
854
+ ReadsFixtures.read_raw_json_fixture("request/preview_default_basic"),
855
+ 200,
856
+ ReadsFixtures.read_raw_json_fixture("response/preview_entity"),
857
+ "/transactions/preview",
858
+ ),
859
+ (
860
+ PreviewTransaction(
861
+ customer_id="ctm_01h844q4mznqpgqgm6evgw1w63",
862
+ currency_code=CurrencyCode.USD,
863
+ discount_id="dsc_01gtgztp8fpchantd5g1wrksa3",
864
+ ignore_trials=True,
865
+ items=[
866
+ TransactionItemPreviewWithNonCatalogPrice(
867
+ quantity=20,
868
+ include_in_totals=True,
869
+ price=TransactionNonCatalogPrice(
870
+ description="Annual (per seat)",
871
+ name="Annual (per seat)",
872
+ billing_cycle=Duration(Interval.Year, 1),
873
+ trial_period=None,
874
+ tax_mode=TaxMode.AccountSetting,
875
+ unit_price=Money("30000", CurrencyCode.USD),
876
+ unit_price_overrides=[],
877
+ quantity=PriceQuantity(minimum=10, maximum=999),
878
+ custom_data=None,
879
+ product_id="pro_01gsz4t5hdjse780zja8vvr7jg",
880
+ ),
881
+ ),
882
+ TransactionItemPreviewWithNonCatalogPrice(
883
+ quantity=20,
884
+ include_in_totals=True,
885
+ price=TransactionNonCatalogPriceWithProduct(
886
+ description="Annual (per seat)",
887
+ name="Annual (per seat)",
888
+ billing_cycle=Duration(Interval.Year, 1),
889
+ trial_period=None,
890
+ tax_mode=TaxMode.AccountSetting,
891
+ unit_price=Money("30000", CurrencyCode.USD),
892
+ unit_price_overrides=[],
893
+ quantity=PriceQuantity(minimum=10, maximum=999),
894
+ custom_data=None,
895
+ product=TransactionNonCatalogProduct(
896
+ name="Analytics addon",
897
+ description="Some Description",
898
+ image_url="https://paddle.s3.amazonaws.com/user/165798/97dRpA6SXzcE6ekK9CAr_analytics.png",
899
+ tax_category=TaxCategory.Standard,
900
+ custom_data=CustomData({"key": "value"}),
901
+ ),
902
+ ),
903
+ ),
904
+ TransactionItemPreviewWithNonCatalogPrice(
905
+ quantity=20,
906
+ price=TransactionNonCatalogPrice(
907
+ description="Annual (per seat)",
908
+ unit_price=Money("30000", CurrencyCode.USD),
909
+ product_id="pro_01gsz4t5hdjse780zja8vvr7jg",
910
+ ),
911
+ ),
912
+ TransactionItemPreviewWithNonCatalogPrice(
913
+ quantity=20,
914
+ price=TransactionNonCatalogPriceWithProduct(
915
+ description="Annual (per seat)",
916
+ unit_price=Money("30000", CurrencyCode.USD),
917
+ product=TransactionNonCatalogProduct(
918
+ name="Analytics addon",
919
+ description="Some Description",
920
+ image_url="https://paddle.s3.amazonaws.com/user/165798/97dRpA6SXzcE6ekK9CAr_analytics.png",
921
+ tax_category=TaxCategory.Standard,
922
+ custom_data=CustomData({"key": "value"}),
923
+ ),
924
+ ),
925
+ ),
926
+ ],
927
+ ),
928
+ ReadsFixtures.read_raw_json_fixture("request/preview_default_full"),
929
+ 200,
930
+ ReadsFixtures.read_raw_json_fixture("response/preview_entity"),
931
+ "/transactions/preview",
932
+ ),
843
933
  (
844
934
  PreviewTransactionByAddress(
845
935
  address=AddressPreview(
@@ -1123,6 +1213,8 @@ class TestTransactionsClient:
1123
1213
  ),
1124
1214
  ],
1125
1215
  ids=[
1216
+ "Basic transaction preview with no location information",
1217
+ "Full transaction preview with no location information",
1126
1218
  "Basic transaction preview by address",
1127
1219
  "Full transaction preview by address",
1128
1220
  "Basic transaction preview by customer",