paddle-python-sdk 1.0.0__py3-none-any.whl → 1.1.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 +3 -1
- paddle_billing/Entities/Collections/PaymentMethodCollection.py +13 -0
- paddle_billing/Entities/Collections/__init__.py +1 -0
- paddle_billing/Entities/CustomerAuthToken.py +18 -0
- paddle_billing/Entities/PaymentMethod.py +38 -0
- paddle_billing/Entities/Shared/Paypal.py +15 -0
- paddle_billing/Entities/Shared/SavedPaymentMethodOrigin.py +6 -0
- paddle_billing/Entities/Shared/SavedPaymentMethodType.py +9 -0
- paddle_billing/Entities/Shared/__init__.py +3 -0
- paddle_billing/Notifications/Entities/Entity.py +3 -1
- paddle_billing/Notifications/Entities/PaymentMethod.py +32 -0
- paddle_billing/Notifications/Entities/PaymentMethodDeleted.py +35 -0
- paddle_billing/Notifications/Entities/Shared/Paypal.py +15 -0
- paddle_billing/Notifications/Entities/Shared/SavedPaymentMethodDeletionReason.py +6 -0
- paddle_billing/Notifications/Entities/Shared/SavedPaymentMethodOrigin.py +6 -0
- paddle_billing/Notifications/Entities/Shared/SavedPaymentMethodType.py +9 -0
- paddle_billing/Notifications/Entities/Shared/__init__.py +6 -0
- paddle_billing/Notifications/Events/PaymentMethodDeleted.py +17 -0
- paddle_billing/Notifications/Events/PaymentMethodSaved.py +17 -0
- paddle_billing/Resources/Customers/CustomersClient.py +12 -1
- paddle_billing/Resources/PaymentMethods/Operations/ListPaymentMethods.py +32 -0
- paddle_billing/Resources/PaymentMethods/Operations/__init__.py +1 -0
- paddle_billing/Resources/PaymentMethods/PaymentMethodsClient.py +45 -0
- paddle_billing/Resources/PaymentMethods/__init__.py +0 -0
- {paddle_python_sdk-1.0.0.dist-info → paddle_python_sdk-1.1.0.dist-info}/METADATA +1 -1
- {paddle_python_sdk-1.0.0.dist-info → paddle_python_sdk-1.1.0.dist-info}/RECORD +32 -12
- {paddle_python_sdk-1.0.0.dist-info → paddle_python_sdk-1.1.0.dist-info}/WHEEL +1 -1
- tests/Functional/Resources/Customers/test_CustomersClient.py +34 -0
- tests/Functional/Resources/PaymentMethods/__init__.py +0 -0
- tests/Functional/Resources/PaymentMethods/test_PaymentMethodsClient.py +287 -0
- {paddle_python_sdk-1.0.0.dist-info → paddle_python_sdk-1.1.0.dist-info}/LICENSE +0 -0
- {paddle_python_sdk-1.0.0.dist-info → paddle_python_sdk-1.1.0.dist-info}/top_level.txt +0 -0
paddle_billing/Client.py
CHANGED
|
@@ -27,6 +27,7 @@ from paddle_billing.Resources.IPAddresses.IPAddressesClient import IPAddressesCl
|
|
|
27
27
|
from paddle_billing.Resources.Notifications.NotificationsClient import NotificationsClient
|
|
28
28
|
from paddle_billing.Resources.NotificationLogs.NotificationLogsClient import NotificationLogsClient
|
|
29
29
|
from paddle_billing.Resources.NotificationSettings.NotificationSettingsClient import NotificationSettingsClient
|
|
30
|
+
from paddle_billing.Resources.PaymentMethods.PaymentMethodsClient import PaymentMethodsClient
|
|
30
31
|
from paddle_billing.Resources.Prices.PricesClient import PricesClient
|
|
31
32
|
from paddle_billing.Resources.PricingPreviews.PricingPreviewsClient import PricingPreviewsClient
|
|
32
33
|
from paddle_billing.Resources.Products.ProductsClient import ProductsClient
|
|
@@ -90,6 +91,7 @@ class Client:
|
|
|
90
91
|
self.notifications = NotificationsClient(self)
|
|
91
92
|
self.notification_logs = NotificationLogsClient(self)
|
|
92
93
|
self.notification_settings = NotificationSettingsClient(self)
|
|
94
|
+
self.payment_methods = PaymentMethodsClient(self)
|
|
93
95
|
self.prices = PricesClient(self)
|
|
94
96
|
self.pricing_previews = PricingPreviewsClient(self)
|
|
95
97
|
self.products = ProductsClient(self)
|
|
@@ -200,7 +202,7 @@ class Client:
|
|
|
200
202
|
"Authorization": f"Bearer {self.__api_key}",
|
|
201
203
|
"Content-Type": "application/json",
|
|
202
204
|
"Paddle-Version": str(self.use_api_version),
|
|
203
|
-
"User-Agent": "PaddleSDK/python 1.
|
|
205
|
+
"User-Agent": "PaddleSDK/python 1.1.0",
|
|
204
206
|
}
|
|
205
207
|
)
|
|
206
208
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from paddle_billing.Entities.Collections.Collection import Collection
|
|
4
|
+
from paddle_billing.Entities.Collections.Paginator import Paginator
|
|
5
|
+
from paddle_billing.Entities.PaymentMethod import PaymentMethod
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class PaymentMethodCollection(Collection[PaymentMethod]):
|
|
9
|
+
@classmethod
|
|
10
|
+
def from_list(cls, items_data: list, paginator: Paginator | None = None) -> PaymentMethodCollection:
|
|
11
|
+
items: list[PaymentMethod] = [PaymentMethod.from_dict(item) for item in items_data]
|
|
12
|
+
|
|
13
|
+
return PaymentMethodCollection(items, paginator)
|
|
@@ -11,6 +11,7 @@ from paddle_billing.Entities.Collections.NotificationCollection import Notificat
|
|
|
11
11
|
from paddle_billing.Entities.Collections.NotificationLogCollection import NotificationLogCollection
|
|
12
12
|
from paddle_billing.Entities.Collections.NotificationSettingCollection import NotificationSettingCollection
|
|
13
13
|
from paddle_billing.Entities.Collections.Paginator import Paginator
|
|
14
|
+
from paddle_billing.Entities.Collections.PaymentMethodCollection import PaymentMethodCollection
|
|
14
15
|
from paddle_billing.Entities.Collections.PriceCollection import PriceCollection
|
|
15
16
|
from paddle_billing.Entities.Collections.ProductCollection import ProductCollection
|
|
16
17
|
from paddle_billing.Entities.Collections.ReportCollection import ReportCollection
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
|
|
5
|
+
from paddle_billing.Entities.Entity import Entity
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass
|
|
9
|
+
class CustomerAuthToken(Entity):
|
|
10
|
+
customer_auth_token: str
|
|
11
|
+
expires_at: datetime
|
|
12
|
+
|
|
13
|
+
@staticmethod
|
|
14
|
+
def from_dict(data: dict) -> CustomerAuthToken:
|
|
15
|
+
return CustomerAuthToken(
|
|
16
|
+
customer_auth_token=data["customer_auth_token"],
|
|
17
|
+
expires_at=datetime.fromisoformat(data["expires_at"]),
|
|
18
|
+
)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
|
|
5
|
+
from paddle_billing.Entities.Entity import Entity
|
|
6
|
+
from paddle_billing.Entities.Shared import (
|
|
7
|
+
Card,
|
|
8
|
+
Paypal,
|
|
9
|
+
SavedPaymentMethodOrigin,
|
|
10
|
+
SavedPaymentMethodType,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass
|
|
15
|
+
class PaymentMethod(Entity):
|
|
16
|
+
id: str
|
|
17
|
+
customer_id: str
|
|
18
|
+
address_id: str
|
|
19
|
+
type: SavedPaymentMethodType | None
|
|
20
|
+
card: Card | None
|
|
21
|
+
paypal: Paypal | None
|
|
22
|
+
origin: SavedPaymentMethodOrigin
|
|
23
|
+
saved_at: datetime
|
|
24
|
+
updated_at: datetime
|
|
25
|
+
|
|
26
|
+
@staticmethod
|
|
27
|
+
def from_dict(data: dict) -> PaymentMethod:
|
|
28
|
+
return PaymentMethod(
|
|
29
|
+
id=data["id"],
|
|
30
|
+
customer_id=data["customer_id"],
|
|
31
|
+
address_id=data["address_id"],
|
|
32
|
+
type=SavedPaymentMethodType(data["type"]),
|
|
33
|
+
card=Card.from_dict(data["card"]) if data.get("card") else None,
|
|
34
|
+
paypal=Paypal.from_dict(data["paypal"]) if data.get("paypal") else None,
|
|
35
|
+
origin=SavedPaymentMethodOrigin(data["origin"]),
|
|
36
|
+
saved_at=datetime.fromisoformat(data["saved_at"]),
|
|
37
|
+
updated_at=datetime.fromisoformat(data["updated_at"]),
|
|
38
|
+
)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@dataclass
|
|
6
|
+
class Paypal:
|
|
7
|
+
email: str
|
|
8
|
+
reference: str
|
|
9
|
+
|
|
10
|
+
@staticmethod
|
|
11
|
+
def from_dict(data: dict) -> Paypal:
|
|
12
|
+
return Paypal(
|
|
13
|
+
email=data["email"],
|
|
14
|
+
reference=data["reference"],
|
|
15
|
+
)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
from paddle_billing.PaddleStrEnum import PaddleStrEnum, PaddleStrEnumMeta
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class SavedPaymentMethodOrigin(PaddleStrEnum, metaclass=PaddleStrEnumMeta):
|
|
5
|
+
SavedDuringPurchase: "SavedPaymentMethodOrigin" = "saved_during_purchase"
|
|
6
|
+
Subscription: "SavedPaymentMethodOrigin" = "subscription"
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
from paddle_billing.PaddleStrEnum import PaddleStrEnum, PaddleStrEnumMeta
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class SavedPaymentMethodType(PaddleStrEnum, metaclass=PaddleStrEnumMeta):
|
|
5
|
+
Alipay: "SavedPaymentMethodType" = "alipay"
|
|
6
|
+
ApplePay: "SavedPaymentMethodType" = "apple_pay"
|
|
7
|
+
Card: "SavedPaymentMethodType" = "card"
|
|
8
|
+
GooglePay: "SavedPaymentMethodType" = "google_pay"
|
|
9
|
+
Paypal: "SavedPaymentMethodType" = "paypal"
|
|
@@ -31,8 +31,11 @@ from paddle_billing.Entities.Shared.Pagination import Pagination
|
|
|
31
31
|
from paddle_billing.Entities.Shared.PaymentAttemptStatus import PaymentAttemptStatus
|
|
32
32
|
from paddle_billing.Entities.Shared.PaymentMethodType import PaymentMethodType
|
|
33
33
|
from paddle_billing.Entities.Shared.PayoutTotalsAdjustment import PayoutTotalsAdjustment
|
|
34
|
+
from paddle_billing.Entities.Shared.Paypal import Paypal
|
|
34
35
|
from paddle_billing.Entities.Shared.PriceQuantity import PriceQuantity
|
|
35
36
|
from paddle_billing.Entities.Shared.Proration import Proration
|
|
37
|
+
from paddle_billing.Entities.Shared.SavedPaymentMethodOrigin import SavedPaymentMethodOrigin
|
|
38
|
+
from paddle_billing.Entities.Shared.SavedPaymentMethodType import SavedPaymentMethodType
|
|
36
39
|
from paddle_billing.Entities.Shared.Status import Status
|
|
37
40
|
from paddle_billing.Entities.Shared.TransactionStatus import TransactionStatus
|
|
38
41
|
from paddle_billing.Entities.Shared.TaxCategory import TaxCategory
|
|
@@ -44,10 +44,12 @@ class Entity(ABC, EntityDict):
|
|
|
44
44
|
def _resolve_event_class_name(event_type) -> str:
|
|
45
45
|
if event_type == "subscription.created":
|
|
46
46
|
return "SubscriptionCreated"
|
|
47
|
+
if event_type == "payment_method.deleted":
|
|
48
|
+
return "PaymentMethodDeleted"
|
|
47
49
|
|
|
48
50
|
event_entity = event_type.split(".")[0] or ""
|
|
49
51
|
|
|
50
|
-
return event_entity.lower().title()
|
|
52
|
+
return event_entity.lower().title().replace("_", "")
|
|
51
53
|
|
|
52
54
|
def to_dict(self) -> dict:
|
|
53
55
|
return asdict(self)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
|
|
5
|
+
from paddle_billing.Notifications.Entities.Entity import Entity
|
|
6
|
+
from paddle_billing.Notifications.Entities.Shared import (
|
|
7
|
+
SavedPaymentMethodOrigin,
|
|
8
|
+
SavedPaymentMethodType,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclass
|
|
13
|
+
class PaymentMethod(Entity):
|
|
14
|
+
id: str
|
|
15
|
+
customer_id: str
|
|
16
|
+
address_id: str
|
|
17
|
+
type: SavedPaymentMethodType | None
|
|
18
|
+
origin: SavedPaymentMethodOrigin
|
|
19
|
+
saved_at: datetime
|
|
20
|
+
updated_at: datetime
|
|
21
|
+
|
|
22
|
+
@staticmethod
|
|
23
|
+
def from_dict(data: dict) -> PaymentMethod:
|
|
24
|
+
return PaymentMethod(
|
|
25
|
+
id=data["id"],
|
|
26
|
+
customer_id=data["customer_id"],
|
|
27
|
+
address_id=data["address_id"],
|
|
28
|
+
type=SavedPaymentMethodType(data["type"]),
|
|
29
|
+
origin=SavedPaymentMethodOrigin(data["origin"]),
|
|
30
|
+
saved_at=datetime.fromisoformat(data["saved_at"]),
|
|
31
|
+
updated_at=datetime.fromisoformat(data["updated_at"]),
|
|
32
|
+
)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
|
|
5
|
+
from paddle_billing.Notifications.Entities.Entity import Entity
|
|
6
|
+
from paddle_billing.Notifications.Entities.Shared import (
|
|
7
|
+
SavedPaymentMethodDeletionReason,
|
|
8
|
+
SavedPaymentMethodOrigin,
|
|
9
|
+
SavedPaymentMethodType,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass
|
|
14
|
+
class PaymentMethodDeleted(Entity):
|
|
15
|
+
id: str
|
|
16
|
+
customer_id: str
|
|
17
|
+
address_id: str
|
|
18
|
+
type: SavedPaymentMethodType | None
|
|
19
|
+
origin: SavedPaymentMethodOrigin
|
|
20
|
+
saved_at: datetime
|
|
21
|
+
updated_at: datetime
|
|
22
|
+
deletion_reason: SavedPaymentMethodDeletionReason
|
|
23
|
+
|
|
24
|
+
@staticmethod
|
|
25
|
+
def from_dict(data: dict) -> PaymentMethodDeleted:
|
|
26
|
+
return PaymentMethodDeleted(
|
|
27
|
+
id=data["id"],
|
|
28
|
+
customer_id=data["customer_id"],
|
|
29
|
+
address_id=data["address_id"],
|
|
30
|
+
type=SavedPaymentMethodType(data["type"]),
|
|
31
|
+
origin=SavedPaymentMethodOrigin(data["origin"]),
|
|
32
|
+
saved_at=datetime.fromisoformat(data["saved_at"]),
|
|
33
|
+
updated_at=datetime.fromisoformat(data["updated_at"]),
|
|
34
|
+
deletion_reason=SavedPaymentMethodDeletionReason(data["deletion_reason"]),
|
|
35
|
+
)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@dataclass
|
|
6
|
+
class Paypal:
|
|
7
|
+
email: str
|
|
8
|
+
reference: str
|
|
9
|
+
|
|
10
|
+
@staticmethod
|
|
11
|
+
def from_dict(data: dict) -> Paypal:
|
|
12
|
+
return Paypal(
|
|
13
|
+
email=data["email"],
|
|
14
|
+
reference=data["reference"],
|
|
15
|
+
)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
from paddle_billing.PaddleStrEnum import PaddleStrEnum, PaddleStrEnumMeta
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class SavedPaymentMethodDeletionReason(PaddleStrEnum, metaclass=PaddleStrEnumMeta):
|
|
5
|
+
ReplacedByNewerVersion: "SavedPaymentMethodDeletionReason" = "replaced_by_newer_version"
|
|
6
|
+
Api: "SavedPaymentMethodDeletionReason" = "api"
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
from paddle_billing.PaddleStrEnum import PaddleStrEnum, PaddleStrEnumMeta
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class SavedPaymentMethodOrigin(PaddleStrEnum, metaclass=PaddleStrEnumMeta):
|
|
5
|
+
SavedDuringPurchase: "SavedPaymentMethodOrigin" = "saved_during_purchase"
|
|
6
|
+
Subscription: "SavedPaymentMethodOrigin" = "subscription"
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
from paddle_billing.PaddleStrEnum import PaddleStrEnum, PaddleStrEnumMeta
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class SavedPaymentMethodType(PaddleStrEnum, metaclass=PaddleStrEnumMeta):
|
|
5
|
+
Alipay: "SavedPaymentMethodType" = "alipay"
|
|
6
|
+
ApplePay: "SavedPaymentMethodType" = "apple_pay"
|
|
7
|
+
Card: "SavedPaymentMethodType" = "card"
|
|
8
|
+
GooglePay: "SavedPaymentMethodType" = "google_pay"
|
|
9
|
+
Paypal: "SavedPaymentMethodType" = "paypal"
|
|
@@ -26,8 +26,14 @@ from paddle_billing.Notifications.Entities.Shared.Original import Original
|
|
|
26
26
|
from paddle_billing.Notifications.Entities.Shared.PaymentAttemptStatus import PaymentAttemptStatus
|
|
27
27
|
from paddle_billing.Notifications.Entities.Shared.PaymentMethodType import PaymentMethodType
|
|
28
28
|
from paddle_billing.Notifications.Entities.Shared.PayoutTotalsAdjustment import PayoutTotalsAdjustment
|
|
29
|
+
from paddle_billing.Notifications.Entities.Shared.Paypal import Paypal
|
|
29
30
|
from paddle_billing.Notifications.Entities.Shared.PriceQuantity import PriceQuantity
|
|
30
31
|
from paddle_billing.Notifications.Entities.Shared.Proration import Proration
|
|
32
|
+
from paddle_billing.Notifications.Entities.Shared.SavedPaymentMethodDeletionReason import (
|
|
33
|
+
SavedPaymentMethodDeletionReason,
|
|
34
|
+
)
|
|
35
|
+
from paddle_billing.Notifications.Entities.Shared.SavedPaymentMethodOrigin import SavedPaymentMethodOrigin
|
|
36
|
+
from paddle_billing.Notifications.Entities.Shared.SavedPaymentMethodType import SavedPaymentMethodType
|
|
31
37
|
from paddle_billing.Notifications.Entities.Shared.Status import Status
|
|
32
38
|
from paddle_billing.Notifications.Entities.Shared.TransactionStatus import TransactionStatus
|
|
33
39
|
from paddle_billing.Notifications.Entities.Shared.TaxCategory import TaxCategory
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
|
|
3
|
+
from paddle_billing.Entities.Event import Event
|
|
4
|
+
from paddle_billing.Entities.Events import EventTypeName
|
|
5
|
+
|
|
6
|
+
from paddle_billing.Notifications.Entities.Customer import PaymentMethod
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class PaymentMethodDeleted(Event):
|
|
10
|
+
def __init__(
|
|
11
|
+
self,
|
|
12
|
+
event_id: str,
|
|
13
|
+
event_type: EventTypeName,
|
|
14
|
+
occurred_at: datetime,
|
|
15
|
+
data: PaymentMethod,
|
|
16
|
+
):
|
|
17
|
+
super().__init__(event_id, event_type, occurred_at, data)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
|
|
3
|
+
from paddle_billing.Entities.Event import Event
|
|
4
|
+
from paddle_billing.Entities.Events import EventTypeName
|
|
5
|
+
|
|
6
|
+
from paddle_billing.Notifications.Entities.PaymentMethod import PaymentMethod
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class PaymentMethodSaved(Event):
|
|
10
|
+
def __init__(
|
|
11
|
+
self,
|
|
12
|
+
event_id: str,
|
|
13
|
+
event_type: EventTypeName,
|
|
14
|
+
occurred_at: datetime,
|
|
15
|
+
data: PaymentMethod,
|
|
16
|
+
):
|
|
17
|
+
super().__init__(event_id, event_type, occurred_at, data)
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
from paddle_billing.ResponseParser import ResponseParser
|
|
2
2
|
|
|
3
|
-
from paddle_billing.Entities.Collections import
|
|
3
|
+
from paddle_billing.Entities.Collections import (
|
|
4
|
+
Paginator,
|
|
5
|
+
CreditBalanceCollection,
|
|
6
|
+
CustomerCollection,
|
|
7
|
+
)
|
|
4
8
|
from paddle_billing.Entities.Customer import Customer
|
|
9
|
+
from paddle_billing.Entities.CustomerAuthToken import CustomerAuthToken
|
|
5
10
|
from paddle_billing.Entities.Shared import Status
|
|
6
11
|
|
|
7
12
|
from paddle_billing.Resources.Customers.Operations import (
|
|
@@ -62,3 +67,9 @@ class CustomersClient:
|
|
|
62
67
|
parser = ResponseParser(self.response)
|
|
63
68
|
|
|
64
69
|
return CreditBalanceCollection.from_list(parser.get_data())
|
|
70
|
+
|
|
71
|
+
def create_auth_token(self, customer_id: str) -> CustomerAuthToken:
|
|
72
|
+
self.response = self.client.post_raw(f"/customers/{customer_id}/auth-token")
|
|
73
|
+
parser = ResponseParser(self.response)
|
|
74
|
+
|
|
75
|
+
return CustomerAuthToken.from_dict(parser.get_data())
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from paddle_billing.HasParameters import HasParameters
|
|
2
|
+
from paddle_billing.Exceptions.SdkExceptions.InvalidArgumentException import InvalidArgumentException
|
|
3
|
+
from paddle_billing.Resources.Shared.Operations import Pager
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ListPaymentMethods(HasParameters):
|
|
7
|
+
def __init__(
|
|
8
|
+
self,
|
|
9
|
+
pager: Pager | None = None,
|
|
10
|
+
address_ids: list[str] = None,
|
|
11
|
+
supports_checkout: bool = None,
|
|
12
|
+
):
|
|
13
|
+
self.pager = pager
|
|
14
|
+
self.address_ids = address_ids
|
|
15
|
+
self.supports_checkout = supports_checkout
|
|
16
|
+
|
|
17
|
+
# Validation
|
|
18
|
+
if address_ids is not None:
|
|
19
|
+
invalid_items = [id for id in address_ids if not isinstance(id, str)]
|
|
20
|
+
if invalid_items:
|
|
21
|
+
raise InvalidArgumentException.array_contains_invalid_types("ids", str.__name__, invalid_items)
|
|
22
|
+
|
|
23
|
+
def get_parameters(self) -> dict:
|
|
24
|
+
parameters = {}
|
|
25
|
+
if self.pager:
|
|
26
|
+
parameters.update(self.pager.get_parameters())
|
|
27
|
+
if self.address_ids:
|
|
28
|
+
parameters["address_id"] = ",".join(self.address_ids)
|
|
29
|
+
if self.supports_checkout is not None:
|
|
30
|
+
parameters["supports_checkout"] = "true" if self.supports_checkout else "false"
|
|
31
|
+
|
|
32
|
+
return parameters
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from paddle_billing.Resources.PaymentMethods.Operations.ListPaymentMethods import ListPaymentMethods
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from paddle_billing.ResponseParser import ResponseParser
|
|
2
|
+
|
|
3
|
+
from paddle_billing.Entities.Collections import (
|
|
4
|
+
PaymentMethodCollection,
|
|
5
|
+
Paginator,
|
|
6
|
+
)
|
|
7
|
+
from paddle_billing.Entities.PaymentMethod import PaymentMethod
|
|
8
|
+
|
|
9
|
+
from paddle_billing.Resources.PaymentMethods.Operations import (
|
|
10
|
+
ListPaymentMethods,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
from typing import TYPE_CHECKING
|
|
14
|
+
|
|
15
|
+
if TYPE_CHECKING:
|
|
16
|
+
from paddle_billing.Client import Client
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class PaymentMethodsClient:
|
|
20
|
+
def __init__(self, client: "Client"):
|
|
21
|
+
self.client = client
|
|
22
|
+
self.response = None
|
|
23
|
+
|
|
24
|
+
def list(self, customer_id: str, operation: ListPaymentMethods = None) -> PaymentMethodCollection:
|
|
25
|
+
if operation is None:
|
|
26
|
+
operation = ListPaymentMethods()
|
|
27
|
+
|
|
28
|
+
self.response = self.client.get_raw(f"/customers/{customer_id}/payment-methods", operation)
|
|
29
|
+
parser = ResponseParser(self.response)
|
|
30
|
+
|
|
31
|
+
return PaymentMethodCollection.from_list(
|
|
32
|
+
parser.get_data(),
|
|
33
|
+
Paginator(self.client, parser.get_pagination(), PaymentMethodCollection),
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
def get(self, customer_id: str, payment_method_id: str) -> PaymentMethod:
|
|
37
|
+
self.response = self.client.get_raw(f"/customers/{customer_id}/payment-methods/{payment_method_id}")
|
|
38
|
+
parser = ResponseParser(self.response)
|
|
39
|
+
|
|
40
|
+
return PaymentMethod.from_dict(parser.get_data())
|
|
41
|
+
|
|
42
|
+
def delete(self, customer_id: str, payment_method_id: str) -> None:
|
|
43
|
+
self.response = self.client.delete_raw(f"/customers/{customer_id}/payment-methods/{payment_method_id}")
|
|
44
|
+
|
|
45
|
+
return None
|
|
File without changes
|
|
@@ -4,7 +4,7 @@ examples/event_polling.py,sha256=580dg_8CFrSCA89Mr1ny4V1gtB3-hk-LfePTbI7DT5w,217
|
|
|
4
4
|
examples/get_products.py,sha256=4V7ZG1SH6Oxojufbtzm_TMySw4cOBMQ99mgQK_hlwFQ,1875
|
|
5
5
|
examples/logger.py,sha256=AxmQmMrsM0ZqMIUnh6iARiczL4S4F9OqQcOu-67owNg,1042
|
|
6
6
|
examples/webhook_verification.py,sha256=qkNscNdNZUAgxEIk83tCiljN2VmfePZ_k8zTliKz2QY,1205
|
|
7
|
-
paddle_billing/Client.py,sha256=
|
|
7
|
+
paddle_billing/Client.py,sha256=kzzT-4wDo9Xxeqb6MjBOef0whF2siXMJHnJpcowHDV8,8594
|
|
8
8
|
paddle_billing/EnumStringify.py,sha256=iDvKULZat3jx9A-_PhvoN6CbFGf2pyxrQeYZxqX9n8M,48
|
|
9
9
|
paddle_billing/Environment.py,sha256=sY4nrJUwlTugsZKncieAnvfCojqCcKWi4X7rFzjFeSQ,417
|
|
10
10
|
paddle_billing/FiltersNone.py,sha256=HxjE6RJb7sy6txphpZSrCTQZt1Ua0XpIz8NDLHC43zo,268
|
|
@@ -23,6 +23,7 @@ paddle_billing/Entities/AdjustmentCreditNote.py,sha256=nMXkYk4hDyxv4Oaw0iFgslmgM
|
|
|
23
23
|
paddle_billing/Entities/Business.py,sha256=wlnAd_lC0Fuw7_BHKZGHt8q-aeLYO6MjO92EYedRnmo,1331
|
|
24
24
|
paddle_billing/Entities/CreditBalance.py,sha256=aGCsfSf-qZl6kVTfHd41_1raiNuI29picji-bj7-lvg,673
|
|
25
25
|
paddle_billing/Entities/Customer.py,sha256=3Ae2wmopq5CWL5FKiWGjXkEVcDVWLZHKCF4N3cjtFO4,1165
|
|
26
|
+
paddle_billing/Entities/CustomerAuthToken.py,sha256=Zsm0NJDHRt9TYLTRXueW_m01piRA2QLRJ6SkfB_fLWo,493
|
|
26
27
|
paddle_billing/Entities/DateTime.py,sha256=vJJRO6nASbJzESSk0LO6RxfroHnkvOBDfJKLswovbHE,1512
|
|
27
28
|
paddle_billing/Entities/Discount.py,sha256=btcN1MSiKSDd-p5HMQikijDRIl2HGf-USd8pZ3CmGjE,1993
|
|
28
29
|
paddle_billing/Entities/Entity.py,sha256=8zY_ehy4uqylrgY4Qo9yzsSPnpPa5PluzqytE9wcXrA,271
|
|
@@ -32,6 +33,7 @@ paddle_billing/Entities/IPAddresses.py,sha256=ElpiJi-YSDXz7vc7OT908XL3qQH4BxrpjG
|
|
|
32
33
|
paddle_billing/Entities/Notification.py,sha256=pfFpwziRegGfr4cb5QMFZqtPafpP7AASHAmv6Ab6of4,1745
|
|
33
34
|
paddle_billing/Entities/NotificationLog.py,sha256=ezWhRCVPFu1S-p-bvbWL1zxN_52dOe0loZCVGn83XFc,693
|
|
34
35
|
paddle_billing/Entities/NotificationSetting.py,sha256=a4D9Sugwe6X2XDqicJ1aOyW7se2H5iiy5m3T0Mvu_D8,1145
|
|
36
|
+
paddle_billing/Entities/PaymentMethod.py,sha256=GpI5s9ZqSNd6BkKhNFzEFNSMAI9O7HDdczNH96uNnZE,1175
|
|
35
37
|
paddle_billing/Entities/Price.py,sha256=mE2n4ajmjCAXZN9BJoJtIewIreLvwGTNOJUm-VzsnOA,2256
|
|
36
38
|
paddle_billing/Entities/PricePreview.py,sha256=8EJ9Li4cQrWtYoDm0088pZJbnplCs35w9mrW2zRMf7A,1328
|
|
37
39
|
paddle_billing/Entities/Product.py,sha256=MUtkd80wUzj2P-osXaxltSmSnvyZ0s2ELvR7zAar0vk,1550
|
|
@@ -61,6 +63,7 @@ paddle_billing/Entities/Collections/NotificationCollection.py,sha256=07H5mZqurda
|
|
|
61
63
|
paddle_billing/Entities/Collections/NotificationLogCollection.py,sha256=mMOkHhGR8vA1NKwuFDM4Mi9c3v9WtefuTiatnpm3nZ4,586
|
|
62
64
|
paddle_billing/Entities/Collections/NotificationSettingCollection.py,sha256=su2RkcTKFNiXh_QXccNSnbAEK0lxRQLMkJpm7ntix0A,618
|
|
63
65
|
paddle_billing/Entities/Collections/Paginator.py,sha256=pVXmXShjFtE0AasS-fi4ClbGRqhAVR6x_a0ij5Wo370,875
|
|
66
|
+
paddle_billing/Entities/Collections/PaymentMethodCollection.py,sha256=uUnxNyevEOduyJHYUozKWmb-tF4Ngg1zB5M_JXv5nYw,570
|
|
64
67
|
paddle_billing/Entities/Collections/PriceCollection.py,sha256=dZjz9Ce7swHNUmAc6F9fMI4sKYTtBd66hAJrB05DQzE,506
|
|
65
68
|
paddle_billing/Entities/Collections/ProductCollection.py,sha256=bVKuDSrwiHukC1ufO0b65CfLvm0edtjP3x2ProkfdAE,522
|
|
66
69
|
paddle_billing/Entities/Collections/ReportCollection.py,sha256=21AxfmbCq1tojIuqoK2Epw1kNOZ3sgH0hxrvyB8iHzU,514
|
|
@@ -69,7 +72,7 @@ paddle_billing/Entities/Collections/SubscriptionPreviewCollection.py,sha256=Nt7Z
|
|
|
69
72
|
paddle_billing/Entities/Collections/TransactionCollection.py,sha256=gF1Kf9m5Gxc9JNSz4XQt7845Q5n44mjTvaHYiXuw7QE,554
|
|
70
73
|
paddle_billing/Entities/Collections/TransactionPreviewCollection.py,sha256=Rr8wgUgKItTqpRpJd12lJTH6Omgl0TSwdtvhpu23fKM,610
|
|
71
74
|
paddle_billing/Entities/Collections/TransactionsDataCollection.py,sha256=cbOXZiwzK0zExvuep3W0abTTBuUuXA4gNuf2EyBR_p4,589
|
|
72
|
-
paddle_billing/Entities/Collections/__init__.py,sha256=
|
|
75
|
+
paddle_billing/Entities/Collections/__init__.py,sha256=pxBG0tG74_DLxZ_hoA21X06u76fa2zMoRoLQEEPeRko,1980
|
|
73
76
|
paddle_billing/Entities/Discounts/DiscountStatus.py,sha256=ss0Btu04U7NEXYgWxlnkUOWINjSXILu67LWEgLb1DaA,304
|
|
74
77
|
paddle_billing/Entities/Discounts/DiscountType.py,sha256=7JQCM_dN2PGHSiA-jzBHTIRVMVTRFKdHAMKxDxpQgf0,270
|
|
75
78
|
paddle_billing/Entities/Discounts/__init__.py,sha256=2zGGjrklZaaWj0iAwFRvTs_87yl8TOYy6R2RcH2kT_4,148
|
|
@@ -133,8 +136,11 @@ paddle_billing/Entities/Shared/Pagination.py,sha256=M1UmYlpqKiHAmWFBeCPaRvCAIGEZ
|
|
|
133
136
|
paddle_billing/Entities/Shared/PaymentAttemptStatus.py,sha256=6GUTDsnb0Gi5sFmeOtT-wmPTDKQ5TBHGMaDa4z9e-u0,657
|
|
134
137
|
paddle_billing/Entities/Shared/PaymentMethodType.py,sha256=ZVesDTs1CVyXteGk8eghnd87Qe9vKcmSjqtepX4rHK0,606
|
|
135
138
|
paddle_billing/Entities/Shared/PayoutTotalsAdjustment.py,sha256=D1jdl4oCRqekfLpaELgicU-lM2jJQUR3GZOK3bVBTf8,904
|
|
139
|
+
paddle_billing/Entities/Shared/Paypal.py,sha256=RcDw5bceAv83BGFNkpH4kcM16ohyR66CY-859nDwhqY,297
|
|
136
140
|
paddle_billing/Entities/Shared/PriceQuantity.py,sha256=QbjjesYBzr9mkCuvULrdp00KKHu10WNaXmL5Pe42PeE,318
|
|
137
141
|
paddle_billing/Entities/Shared/Proration.py,sha256=ke_MIguWriSaPm77yeK_-wogxhePKTBuSLZJsMI4t50,413
|
|
142
|
+
paddle_billing/Entities/Shared/SavedPaymentMethodOrigin.py,sha256=iJuS2h_mjxVAoGUbPlnjUPfa7jwPWIA30QaV3zF2FF4,292
|
|
143
|
+
paddle_billing/Entities/Shared/SavedPaymentMethodType.py,sha256=C4iy0VdmTM7TjOT9JtxcXURjKPYvg0ufrcs3WjfVX1A,398
|
|
138
144
|
paddle_billing/Entities/Shared/Status.py,sha256=iU7MeQzGN5E30PyZbWMdlAQNapNbfznUPXYmCJxc1tA,202
|
|
139
145
|
paddle_billing/Entities/Shared/TaxCategory.py,sha256=jfbAJKB3IghLnLtjcbPgUEDE94m3Zq114DoNoOgR6j4,629
|
|
140
146
|
paddle_billing/Entities/Shared/TaxMode.py,sha256=e2KjLNEIdgo0-PtOaAfboDxRHIavmQ24Ms34Iy4wdNw,259
|
|
@@ -153,7 +159,7 @@ paddle_billing/Entities/Shared/TransactionTotals.py,sha256=gJJigGiALHRS9TkY_VoM7
|
|
|
153
159
|
paddle_billing/Entities/Shared/TransactionTotalsAdjusted.py,sha256=1Wd25MnlECJsriuanamLriPENy2deS9dFHmAG3uCE3Y,745
|
|
154
160
|
paddle_billing/Entities/Shared/UnitPriceOverride.py,sha256=-Y1GQXjP9S3j6_4d4Uz96Wz1ITMM2sktQIWz3tIzvyw,545
|
|
155
161
|
paddle_billing/Entities/Shared/UnitTotals.py,sha256=tCqi2TRsNCwnWNznmKf_bELptCbjdBkNwYkJjHyhhi0,405
|
|
156
|
-
paddle_billing/Entities/Shared/__init__.py,sha256=
|
|
162
|
+
paddle_billing/Entities/Shared/__init__.py,sha256=04s3rcSe7mnJJBsmUbffDUow1wLCWonJ85yy2blAHJo,4025
|
|
157
163
|
paddle_billing/Entities/Subscriptions/SubscriptionAdjustmentItem.py,sha256=a0QNBmdL2CAbrqkQicwqtIT_1p7Wn_SEK9cSUIJy4qQ,758
|
|
158
164
|
paddle_billing/Entities/Subscriptions/SubscriptionAdjustmentPreview.py,sha256=vd1fXc9X0IecddOkMxNivHgU0C2-2cGV37iVqotrcds,725
|
|
159
165
|
paddle_billing/Entities/Subscriptions/SubscriptionCharge.py,sha256=toASyrKTGeZ7X0ppmjinFGO5MeaeZWINEK8vyerzDDo,428
|
|
@@ -212,8 +218,10 @@ paddle_billing/Notifications/Entities/Business.py,sha256=Xgd0W5VdD4wn7QGRbCaVior
|
|
|
212
218
|
paddle_billing/Notifications/Entities/Customer.py,sha256=06ZXKUu8BsWMtrmL29xwTWZ_H3PeZCVKbD_W7QVBD2E,1193
|
|
213
219
|
paddle_billing/Notifications/Entities/DateTime.py,sha256=iJLwbDZwmfHW2TgE8HRPpkw_xZBrwZyVhFaQnKJENu8,1459
|
|
214
220
|
paddle_billing/Notifications/Entities/Discount.py,sha256=__FiaKUrfVVUDglDPbtgU3vg8kEXiOb9VG7CGjFFk7A,2046
|
|
215
|
-
paddle_billing/Notifications/Entities/Entity.py,sha256=
|
|
221
|
+
paddle_billing/Notifications/Entities/Entity.py,sha256=Fek0uj5QgGfLtJuRn5CJ0jXRTsxQRO6gIS5GngrCYMI,1918
|
|
216
222
|
paddle_billing/Notifications/Entities/EntityDict.py,sha256=EPYzfWxPHu8uf5mbV_Fs7lkUdLXD7gCEsGq3NLzWH3I,128
|
|
223
|
+
paddle_billing/Notifications/Entities/PaymentMethod.py,sha256=IIkEXECIojST58XdY3kmWAbWxRmP3XnI-aJb4BpGC3s,971
|
|
224
|
+
paddle_billing/Notifications/Entities/PaymentMethodDeleted.py,sha256=84c3stm3Yc40IQ-oY5IkKngyObSZAP3ANN6DH1A9THg,1171
|
|
217
225
|
paddle_billing/Notifications/Entities/Payout.py,sha256=Zezrof-earP-RFiFopjRIIPysFOD53U1zPxmqiphZ28,683
|
|
218
226
|
paddle_billing/Notifications/Entities/Price.py,sha256=CNrkC_2JabAzMFqNtTevgfCGT8lIZgxpwNDK9vkIuH8,2257
|
|
219
227
|
paddle_billing/Notifications/Entities/Product.py,sha256=9JnGoO3uhcb73pv3FcPr3FMLpmZMiAmdamhrBNlgmM8,1678
|
|
@@ -268,8 +276,12 @@ paddle_billing/Notifications/Entities/Shared/Original.py,sha256=QLRt2WdQCpOoWqxS
|
|
|
268
276
|
paddle_billing/Notifications/Entities/Shared/PaymentAttemptStatus.py,sha256=6GUTDsnb0Gi5sFmeOtT-wmPTDKQ5TBHGMaDa4z9e-u0,657
|
|
269
277
|
paddle_billing/Notifications/Entities/Shared/PaymentMethodType.py,sha256=A8jWJjArNGJwc585QZ-CHsvP2_wJ6aZuZguWmSVw7AQ,645
|
|
270
278
|
paddle_billing/Notifications/Entities/Shared/PayoutTotalsAdjustment.py,sha256=DCZgKVlsPWW0FzGX-28MV0LrNO9iKU2V5JEXGADZSTs,932
|
|
279
|
+
paddle_billing/Notifications/Entities/Shared/Paypal.py,sha256=RcDw5bceAv83BGFNkpH4kcM16ohyR66CY-859nDwhqY,297
|
|
271
280
|
paddle_billing/Notifications/Entities/Shared/PriceQuantity.py,sha256=QbjjesYBzr9mkCuvULrdp00KKHu10WNaXmL5Pe42PeE,318
|
|
272
281
|
paddle_billing/Notifications/Entities/Shared/Proration.py,sha256=H4PilDvIz-DfVR_W4zz13hwyFE1514PCov5DE6wd8iw,427
|
|
282
|
+
paddle_billing/Notifications/Entities/Shared/SavedPaymentMethodDeletionReason.py,sha256=8OJ1Sa3ClLX6uYk5hcfSxtcdK-TF63VDYJcBMjqOpk8,305
|
|
283
|
+
paddle_billing/Notifications/Entities/Shared/SavedPaymentMethodOrigin.py,sha256=iJuS2h_mjxVAoGUbPlnjUPfa7jwPWIA30QaV3zF2FF4,292
|
|
284
|
+
paddle_billing/Notifications/Entities/Shared/SavedPaymentMethodType.py,sha256=C4iy0VdmTM7TjOT9JtxcXURjKPYvg0ufrcs3WjfVX1A,398
|
|
273
285
|
paddle_billing/Notifications/Entities/Shared/Status.py,sha256=iU7MeQzGN5E30PyZbWMdlAQNapNbfznUPXYmCJxc1tA,202
|
|
274
286
|
paddle_billing/Notifications/Entities/Shared/TaxCategory.py,sha256=jfbAJKB3IghLnLtjcbPgUEDE94m3Zq114DoNoOgR6j4,629
|
|
275
287
|
paddle_billing/Notifications/Entities/Shared/TaxMode.py,sha256=e2KjLNEIdgo0-PtOaAfboDxRHIavmQ24Ms34Iy4wdNw,259
|
|
@@ -285,7 +297,7 @@ paddle_billing/Notifications/Entities/Shared/TransactionTotals.py,sha256=GzsNxcN
|
|
|
285
297
|
paddle_billing/Notifications/Entities/Shared/TransactionTotalsAdjusted.py,sha256=sZdgI-OGmVmRuMUmcNsd0bhTGB2RzcZCrQofxfuCmUw,759
|
|
286
298
|
paddle_billing/Notifications/Entities/Shared/UnitPriceOverride.py,sha256=fLiujCD9KQPgRLN9LVRUmYEFtWuodJPmTFlVEYQO4fA,573
|
|
287
299
|
paddle_billing/Notifications/Entities/Shared/UnitTotals.py,sha256=tCqi2TRsNCwnWNznmKf_bELptCbjdBkNwYkJjHyhhi0,405
|
|
288
|
-
paddle_billing/Notifications/Entities/Shared/__init__.py,sha256=
|
|
300
|
+
paddle_billing/Notifications/Entities/Shared/__init__.py,sha256=UvruDr0XkWMEt05BQtSPimy2GxVag_ux_xJdbSVsro4,4278
|
|
289
301
|
paddle_billing/Notifications/Entities/Subscriptions/SubscriptionAdjustmentItem.py,sha256=aED3Eq_OIWuR9RynjvVxa6LhuF6yYDfdpmRB9kiXbTg,730
|
|
290
302
|
paddle_billing/Notifications/Entities/Subscriptions/SubscriptionCharge.py,sha256=RZ9TkL9UckSUJ8stglrI_Ri71sy_-AZmbsTx2790sXQ,442
|
|
291
303
|
paddle_billing/Notifications/Entities/Subscriptions/SubscriptionCredit.py,sha256=v1R271DEZz8emuvxlpTPpNNR68Ye9OgFjoGSczQSs-0,442
|
|
@@ -317,6 +329,8 @@ paddle_billing/Notifications/Events/CustomerUpdated.py,sha256=nC7X_bCLb7j4uo_ZJ_
|
|
|
317
329
|
paddle_billing/Notifications/Events/DiscountCreated.py,sha256=w8r8aMdrPPMT4VKWq-S4S07QLFPUvT2QdO98i3TbXHE,455
|
|
318
330
|
paddle_billing/Notifications/Events/DiscountImported.py,sha256=u3YbYPBIiKRly7f8KMiWGVkvzjo4lA4lDNM6kIinxv0,456
|
|
319
331
|
paddle_billing/Notifications/Events/DiscountUpdated.py,sha256=aWd3IiyiuxtpxkkPhmGmZe56h0LsAGPAu800miODoR4,455
|
|
332
|
+
paddle_billing/Notifications/Events/PaymentMethodDeleted.py,sha256=nSkwVe3qVZP0CGPfN_al7e8TGW-NZqNy-eEQp1qlfW4,470
|
|
333
|
+
paddle_billing/Notifications/Events/PaymentMethodSaved.py,sha256=MSyMEB4-079Vrx9EidMX2NDqUwE7FkfWm5O4On3PnJA,473
|
|
320
334
|
paddle_billing/Notifications/Events/PayoutCreated.py,sha256=MOh6Y0tlSb1fDjIEs9u90Z2TtezTdGeQavlBedkLZq0,447
|
|
321
335
|
paddle_billing/Notifications/Events/PayoutPaid.py,sha256=TtVxkRtvLidXyakb9s6hDzYJBYdGdfHxS5EN0x5qhh4,444
|
|
322
336
|
paddle_billing/Notifications/Events/PriceCreated.py,sha256=8aQ8DiV96c2MtVd9qnfAxiZVZr70FOJv4tl8g8T9lgE,443
|
|
@@ -368,7 +382,7 @@ paddle_billing/Resources/Businesses/Operations/CreateBusiness.py,sha256=zDQ-V7El
|
|
|
368
382
|
paddle_billing/Resources/Businesses/Operations/ListBusinesses.py,sha256=41XRKW61uAN9hepj2Nps0g2H5AtL7O2JqQUcyGhzt6M,1595
|
|
369
383
|
paddle_billing/Resources/Businesses/Operations/UpdateBusiness.py,sha256=fzijE9x9ru58jOW5Rq-ZvV_LtFc7m6rksyJQiSNwyLA,562
|
|
370
384
|
paddle_billing/Resources/Businesses/Operations/__init__.py,sha256=mctosPK-Kdb4n_AmdIqVFKeldZxcjw8e4k4iWWoRml0,267
|
|
371
|
-
paddle_billing/Resources/Customers/CustomersClient.py,sha256=
|
|
385
|
+
paddle_billing/Resources/Customers/CustomersClient.py,sha256=sYouOQZipuAG4ScusIepg7xM9B76BL2nF-21_WwLBDM,2691
|
|
372
386
|
paddle_billing/Resources/Customers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
373
387
|
paddle_billing/Resources/Customers/Operations/CreateCustomer.py,sha256=IxY4Df6S8f51VPM-CIrTQnPFjhoTh1l3BeBA7XseUNw,394
|
|
374
388
|
paddle_billing/Resources/Customers/Operations/ListCreditBalances.py,sha256=6ohD_SjEV6EjmFOVmPbOp__P9Vbp9r5suYkrJr6HUEI,1111
|
|
@@ -403,6 +417,10 @@ paddle_billing/Resources/Notifications/NotificationsClient.py,sha256=k11E2qp1OIR
|
|
|
403
417
|
paddle_billing/Resources/Notifications/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
404
418
|
paddle_billing/Resources/Notifications/Operations/ListNotifications.py,sha256=SCqonil6IAkS0g_NROyDQ5VO2RL-ghcr14Uwk2SJSZA,2355
|
|
405
419
|
paddle_billing/Resources/Notifications/Operations/__init__.py,sha256=4IoWBPYjRPK37GAMhfrxVH5IpAygcaqm3EpwYdvm1IM,98
|
|
420
|
+
paddle_billing/Resources/PaymentMethods/PaymentMethodsClient.py,sha256=f4dREa--LdWEd1qGF5uOllLjUCNfT171YTOAT73xes8,1543
|
|
421
|
+
paddle_billing/Resources/PaymentMethods/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
422
|
+
paddle_billing/Resources/PaymentMethods/Operations/ListPaymentMethods.py,sha256=K3qk628UIjWS3qM2jHhQw1l1Wu84UhtnkBf-At6u47E,1220
|
|
423
|
+
paddle_billing/Resources/PaymentMethods/Operations/__init__.py,sha256=VB0VnlVZ8pnX-GDSOLz5XWR9BgCnB3XDj3equbhlSbg,101
|
|
406
424
|
paddle_billing/Resources/Prices/PricesClient.py,sha256=KcegaWzkEfu1kSqVs0fTF1xsIeK0lcPVwKeKd6xe9OI,2328
|
|
407
425
|
paddle_billing/Resources/Prices/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
408
426
|
paddle_billing/Resources/Prices/Operations/CreatePrice.py,sha256=g9V29Bv9gloIVkH07BuMtV-8GgAjqWpDXq4C00olHJY,850
|
|
@@ -522,7 +540,7 @@ tests/Functional/Resources/Adjustments/test_AdjustmentsClient.py,sha256=WJdb0EZ0
|
|
|
522
540
|
tests/Functional/Resources/Businesses/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
523
541
|
tests/Functional/Resources/Businesses/test_BusinessesClient.py,sha256=uUAydFqmXq3snmu--gGVI5nNrpg6oySQM_Ulg9q-G1Q,12727
|
|
524
542
|
tests/Functional/Resources/Customers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
525
|
-
tests/Functional/Resources/Customers/test_CustomersClient.py,sha256=
|
|
543
|
+
tests/Functional/Resources/Customers/test_CustomersClient.py,sha256=tWDmre025VMQuUGcK6UE12Ulh7Ju_BeprKon2bM-OLk,14755
|
|
526
544
|
tests/Functional/Resources/Discounts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
527
545
|
tests/Functional/Resources/Discounts/test_DiscountsClient.py,sha256=zHQnpm107e9q-ob7aTTdgjG9_gwVHomcxoZdpsBX19w,13447
|
|
528
546
|
tests/Functional/Resources/EventTypes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -537,6 +555,8 @@ tests/Functional/Resources/NotificationSettings/__init__.py,sha256=47DEQpj8HBSa-
|
|
|
537
555
|
tests/Functional/Resources/NotificationSettings/test_NotificationSettingsClient.py,sha256=EbRqcQ0e1M8lfrsLKfWhzyhs4gYoZfVQzFPyDOo_qxk,16538
|
|
538
556
|
tests/Functional/Resources/Notifications/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
539
557
|
tests/Functional/Resources/Notifications/test_NotificationsClient.py,sha256=JgGw5NV6kHi4lsh5wWM0LAilpnWZX-3xT994GaRxoqg,12734
|
|
558
|
+
tests/Functional/Resources/PaymentMethods/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
559
|
+
tests/Functional/Resources/PaymentMethods/test_PaymentMethodsClient.py,sha256=U9dYiAVXcY6K-NL4lYamz7tPpGeo6OZcCnxcR6EH8LE,12046
|
|
540
560
|
tests/Functional/Resources/Prices/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
541
561
|
tests/Functional/Resources/Prices/test_PricesClient.py,sha256=48EtY6zhChPIel57xGQdMsfQEy3mhgMqQ5_nkwnMS6s,13024
|
|
542
562
|
tests/Functional/Resources/PricingPreviews/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -561,8 +581,8 @@ tests/Utils/ReadsFixture.py,sha256=M3Ot3xHXp_C7vwttna9deLPHBAO8ml2Jb4thhHOJJ38,1
|
|
|
561
581
|
tests/Utils/TestClient.py,sha256=-wc7hJMuR6WC-ukw0c7I59b5-8hj_-nzq__-2M81elg,1453
|
|
562
582
|
tests/Utils/TestLogger.py,sha256=pFO9x711buRmg-8DAqpzIJP_hr21JPty1_ZQRcwoGKk,554
|
|
563
583
|
tests/Utils/__init__.py,sha256=JtqJNPKqbNZ9exlpXlF3yj_9cfylPGlvopjQYi7yYTA,37
|
|
564
|
-
paddle_python_sdk-1.
|
|
565
|
-
paddle_python_sdk-1.
|
|
566
|
-
paddle_python_sdk-1.
|
|
567
|
-
paddle_python_sdk-1.
|
|
568
|
-
paddle_python_sdk-1.
|
|
584
|
+
paddle_python_sdk-1.1.0.dist-info/LICENSE,sha256=e5Sn9mzCdpjnqCLxXpGHNKdYB6JlRSTLhN_CD4WSO6w,10770
|
|
585
|
+
paddle_python_sdk-1.1.0.dist-info/METADATA,sha256=7mC1TTC4ghCUhNms-i_U3n7Z1QpDaovdj_g7XFSaA6k,7392
|
|
586
|
+
paddle_python_sdk-1.1.0.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
|
587
|
+
paddle_python_sdk-1.1.0.dist-info/top_level.txt,sha256=9a07VPng7o5wK8VAXkl6NC30xrNbW9zff_02jHyHi4c,30
|
|
588
|
+
paddle_python_sdk-1.1.0.dist-info/RECORD,,
|
|
@@ -4,6 +4,7 @@ from urllib.parse import unquote
|
|
|
4
4
|
|
|
5
5
|
from paddle_billing.Entities.Collections import CreditBalanceCollection, CustomerCollection
|
|
6
6
|
from paddle_billing.Entities.Customer import Customer
|
|
7
|
+
from paddle_billing.Entities.CustomerAuthToken import CustomerAuthToken
|
|
7
8
|
from paddle_billing.Entities.Shared import CustomData, Status, CurrencyCode
|
|
8
9
|
|
|
9
10
|
from paddle_billing.Resources.Customers.Operations import (
|
|
@@ -323,3 +324,36 @@ class TestCustomersClient:
|
|
|
323
324
|
assert response_json == loads(
|
|
324
325
|
str(expected_response_body)
|
|
325
326
|
), "The response JSON generated by ResponseParser() doesn't match the expected fixture JSON"
|
|
327
|
+
|
|
328
|
+
def test_create_customer_auth_token_returns_expected_response(
|
|
329
|
+
self,
|
|
330
|
+
test_client,
|
|
331
|
+
mock_requests,
|
|
332
|
+
):
|
|
333
|
+
customer_id = "ctm_01h8441jn5pcwrfhwh78jqt8hk"
|
|
334
|
+
expected_path = "/customers/ctm_01h8441jn5pcwrfhwh78jqt8hk/auth-token"
|
|
335
|
+
expected_response_body = ReadsFixtures.read_raw_json_fixture("response/auth_token")
|
|
336
|
+
|
|
337
|
+
expected_url = f"{test_client.base_url}{expected_path}"
|
|
338
|
+
mock_requests.post(expected_url, status_code=200, text=expected_response_body)
|
|
339
|
+
|
|
340
|
+
response = test_client.client.customers.create_auth_token(customer_id)
|
|
341
|
+
response_json = test_client.client.customers.response.json()
|
|
342
|
+
last_request = mock_requests.last_request
|
|
343
|
+
|
|
344
|
+
assert isinstance(response, CustomerAuthToken)
|
|
345
|
+
assert last_request is not None
|
|
346
|
+
assert last_request.method == "POST"
|
|
347
|
+
assert test_client.client.status_code == 200
|
|
348
|
+
assert (
|
|
349
|
+
unquote(last_request.url) == expected_url
|
|
350
|
+
), "The URL does not match the expected URL, verify the query string is correct"
|
|
351
|
+
assert response_json == loads(
|
|
352
|
+
str(expected_response_body)
|
|
353
|
+
), "The response JSON doesn't match the expected fixture JSON"
|
|
354
|
+
|
|
355
|
+
assert (
|
|
356
|
+
response.customer_auth_token
|
|
357
|
+
== "pca_01hwyzq8hmdwed5p4jc4hnv6bh_01hwwggymjn0yhhb2gr4p91276_6xaav4lydudt6bgmuefeaf2xnu3umegx"
|
|
358
|
+
)
|
|
359
|
+
assert response.expires_at.isoformat() == "2024-05-03T10:34:12.345000+00:00"
|
|
File without changes
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
from json import loads
|
|
2
|
+
from pytest import mark
|
|
3
|
+
from urllib.parse import unquote
|
|
4
|
+
|
|
5
|
+
from paddle_billing.Entities.Collections import PaymentMethodCollection
|
|
6
|
+
from paddle_billing.Entities.PaymentMethod import PaymentMethod
|
|
7
|
+
|
|
8
|
+
from paddle_billing.Resources.Shared.Operations import Pager
|
|
9
|
+
|
|
10
|
+
from paddle_billing.Resources.PaymentMethods.Operations import (
|
|
11
|
+
ListPaymentMethods,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
from paddle_billing.Entities.Shared import Card, Paypal, SavedPaymentMethodOrigin, SavedPaymentMethodType
|
|
15
|
+
|
|
16
|
+
from tests.Utils.ReadsFixture import ReadsFixtures
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class TestPaymentMethodsClient:
|
|
20
|
+
@mark.parametrize(
|
|
21
|
+
"customer_id, expected_response_status, expected_response_body, expected_path",
|
|
22
|
+
[
|
|
23
|
+
(
|
|
24
|
+
"ctm_01hv6y1jedq4p1n0yqn5ba3ky4",
|
|
25
|
+
200,
|
|
26
|
+
ReadsFixtures.read_raw_json_fixture("response/list_default"),
|
|
27
|
+
"/customers/ctm_01hv6y1jedq4p1n0yqn5ba3ky4/payment-methods",
|
|
28
|
+
)
|
|
29
|
+
],
|
|
30
|
+
ids=["List payment-methods"],
|
|
31
|
+
)
|
|
32
|
+
def test_list_payment_methods_returns_expected_response(
|
|
33
|
+
self,
|
|
34
|
+
test_client,
|
|
35
|
+
mock_requests,
|
|
36
|
+
customer_id,
|
|
37
|
+
expected_response_status,
|
|
38
|
+
expected_response_body,
|
|
39
|
+
expected_path,
|
|
40
|
+
):
|
|
41
|
+
expected_url = f"{test_client.base_url}{expected_path}"
|
|
42
|
+
mock_requests.get(expected_url, status_code=expected_response_status, text=expected_response_body)
|
|
43
|
+
|
|
44
|
+
response = test_client.client.payment_methods.list(customer_id)
|
|
45
|
+
last_request = mock_requests.last_request
|
|
46
|
+
|
|
47
|
+
assert isinstance(response, PaymentMethodCollection)
|
|
48
|
+
assert all(isinstance(item, PaymentMethod) for item in response.items), "Not all items are PaymentMethod"
|
|
49
|
+
assert last_request is not None
|
|
50
|
+
|
|
51
|
+
assert last_request.method == "GET"
|
|
52
|
+
assert test_client.client.status_code == expected_response_status
|
|
53
|
+
assert (
|
|
54
|
+
unquote(last_request.url) == expected_url
|
|
55
|
+
), "The URL does not match the expected URL, verify the query string is correct"
|
|
56
|
+
|
|
57
|
+
@mark.parametrize(
|
|
58
|
+
"customer_id, operation, expected_path",
|
|
59
|
+
[
|
|
60
|
+
(
|
|
61
|
+
"ctm_01hv6y1jedq4p1n0yqn5ba3ky4",
|
|
62
|
+
None,
|
|
63
|
+
"/customers/ctm_01hv6y1jedq4p1n0yqn5ba3ky4/payment-methods",
|
|
64
|
+
),
|
|
65
|
+
(
|
|
66
|
+
"ctm_01hv6y1jedq4p1n0yqn5ba3ky4",
|
|
67
|
+
ListPaymentMethods(
|
|
68
|
+
pager=None,
|
|
69
|
+
address_ids=["add_01hv8h6jj90jjz0d71m6hj4r9z", "add_02hv8h6jj90jjz0d71m6hj4r9z"],
|
|
70
|
+
),
|
|
71
|
+
"/customers/ctm_01hv6y1jedq4p1n0yqn5ba3ky4/payment-methods?address_id=add_01hv8h6jj90jjz0d71m6hj4r9z,add_02hv8h6jj90jjz0d71m6hj4r9z",
|
|
72
|
+
),
|
|
73
|
+
(
|
|
74
|
+
"ctm_01hv6y1jedq4p1n0yqn5ba3ky4",
|
|
75
|
+
ListPaymentMethods(
|
|
76
|
+
pager=None,
|
|
77
|
+
supports_checkout=False,
|
|
78
|
+
),
|
|
79
|
+
"/customers/ctm_01hv6y1jedq4p1n0yqn5ba3ky4/payment-methods?supports_checkout=false",
|
|
80
|
+
),
|
|
81
|
+
(
|
|
82
|
+
"ctm_01hv6y1jedq4p1n0yqn5ba3ky4",
|
|
83
|
+
ListPaymentMethods(
|
|
84
|
+
pager=None,
|
|
85
|
+
supports_checkout=True,
|
|
86
|
+
),
|
|
87
|
+
"/customers/ctm_01hv6y1jedq4p1n0yqn5ba3ky4/payment-methods?supports_checkout=true",
|
|
88
|
+
),
|
|
89
|
+
(
|
|
90
|
+
"ctm_01hv6y1jedq4p1n0yqn5ba3ky4",
|
|
91
|
+
ListPaymentMethods(
|
|
92
|
+
pager=None,
|
|
93
|
+
supports_checkout=True,
|
|
94
|
+
address_ids=["add_01hv8h6jj90jjz0d71m6hj4r9z", "add_02hv8h6jj90jjz0d71m6hj4r9z"],
|
|
95
|
+
),
|
|
96
|
+
"/customers/ctm_01hv6y1jedq4p1n0yqn5ba3ky4/payment-methods?address_id=add_01hv8h6jj90jjz0d71m6hj4r9z,add_02hv8h6jj90jjz0d71m6hj4r9z&supports_checkout=true",
|
|
97
|
+
),
|
|
98
|
+
(
|
|
99
|
+
"ctm_01hv6y1jedq4p1n0yqn5ba3ky4",
|
|
100
|
+
ListPaymentMethods(
|
|
101
|
+
pager=Pager(),
|
|
102
|
+
),
|
|
103
|
+
"/customers/ctm_01hv6y1jedq4p1n0yqn5ba3ky4/payment-methods?order_by=id[asc]&per_page=50",
|
|
104
|
+
),
|
|
105
|
+
(
|
|
106
|
+
"ctm_01hv6y1jedq4p1n0yqn5ba3ky4",
|
|
107
|
+
ListPaymentMethods(
|
|
108
|
+
pager=Pager(
|
|
109
|
+
after="paymtd_01hs8zx6x377xfsfrt2bqsevbw",
|
|
110
|
+
order_by="id[desc]",
|
|
111
|
+
per_page=100,
|
|
112
|
+
),
|
|
113
|
+
),
|
|
114
|
+
"/customers/ctm_01hv6y1jedq4p1n0yqn5ba3ky4/payment-methods?after=paymtd_01hs8zx6x377xfsfrt2bqsevbw&order_by=id[desc]&per_page=100",
|
|
115
|
+
),
|
|
116
|
+
],
|
|
117
|
+
ids=[
|
|
118
|
+
"List all payment-methods",
|
|
119
|
+
"List by address IDs",
|
|
120
|
+
"List supports_checkout false",
|
|
121
|
+
"List supports_checkout true",
|
|
122
|
+
"List by address IDs and supports_checkout",
|
|
123
|
+
"List payment-methods with pagination",
|
|
124
|
+
"List payment-methods with pagination after",
|
|
125
|
+
],
|
|
126
|
+
)
|
|
127
|
+
def test_list_payment_methods_hits_expected_url(
|
|
128
|
+
self,
|
|
129
|
+
test_client,
|
|
130
|
+
mock_requests,
|
|
131
|
+
customer_id,
|
|
132
|
+
operation,
|
|
133
|
+
expected_path,
|
|
134
|
+
):
|
|
135
|
+
expected_url = f"{test_client.base_url}{expected_path}"
|
|
136
|
+
|
|
137
|
+
mock_requests.get(
|
|
138
|
+
expected_url,
|
|
139
|
+
status_code=200,
|
|
140
|
+
text=ReadsFixtures.read_raw_json_fixture("response/list_default"),
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
response = test_client.client.payment_methods.list(customer_id, operation)
|
|
144
|
+
last_request = mock_requests.last_request
|
|
145
|
+
|
|
146
|
+
assert isinstance(response, PaymentMethodCollection)
|
|
147
|
+
assert (
|
|
148
|
+
unquote(last_request.url) == expected_url
|
|
149
|
+
), "The URL does not match the expected URL, verify the query string is correct"
|
|
150
|
+
|
|
151
|
+
def test_list_payment_methods_can_paginate(
|
|
152
|
+
self,
|
|
153
|
+
test_client,
|
|
154
|
+
mock_requests,
|
|
155
|
+
):
|
|
156
|
+
mock_requests.get(
|
|
157
|
+
f"{test_client.base_url}/customers/ctm_01hv6y1jedq4p1n0yqn5ba3ky4/payment-methods",
|
|
158
|
+
status_code=200,
|
|
159
|
+
text=ReadsFixtures.read_raw_json_fixture("response/list_paginated_page_one"),
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
mock_requests.get(
|
|
163
|
+
f"{test_client.base_url}/customers/ctm_01hv6y1jedq4p1n0yqn5ba3ky4/payment-methods?after=paymtd_02hs8zx6x377xfsfrt2bqsevbw",
|
|
164
|
+
status_code=200,
|
|
165
|
+
text=ReadsFixtures.read_raw_json_fixture("response/list_paginated_page_two"),
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
response = test_client.client.payment_methods.list("ctm_01hv6y1jedq4p1n0yqn5ba3ky4")
|
|
169
|
+
|
|
170
|
+
assert isinstance(response, PaymentMethodCollection)
|
|
171
|
+
|
|
172
|
+
allPaymentMethods = []
|
|
173
|
+
for paymentMethod in response:
|
|
174
|
+
allPaymentMethods.append(paymentMethod)
|
|
175
|
+
|
|
176
|
+
assert len(allPaymentMethods) == 4
|
|
177
|
+
|
|
178
|
+
def test_get_payment_methods_returns_expected_card_response(
|
|
179
|
+
self,
|
|
180
|
+
test_client,
|
|
181
|
+
mock_requests,
|
|
182
|
+
):
|
|
183
|
+
customer_id = "ctm_01hv6y1jedq4p1n0yqn5ba3ky4"
|
|
184
|
+
payment_method_id = "paymtd_01hs8zx6x377xfsfrt2bqsevbw"
|
|
185
|
+
expected_response_status = 200
|
|
186
|
+
expected_response_body = ReadsFixtures.read_raw_json_fixture("response/full_entity_card")
|
|
187
|
+
expected_path = "/customers/ctm_01hv6y1jedq4p1n0yqn5ba3ky4/payment-methods/paymtd_01hs8zx6x377xfsfrt2bqsevbw"
|
|
188
|
+
|
|
189
|
+
expected_url = f"{test_client.base_url}{expected_path}"
|
|
190
|
+
mock_requests.get(expected_url, status_code=expected_response_status, text=expected_response_body)
|
|
191
|
+
|
|
192
|
+
response = test_client.client.payment_methods.get(customer_id, payment_method_id)
|
|
193
|
+
response_json = test_client.client.payment_methods.response.json()
|
|
194
|
+
last_request = mock_requests.last_request
|
|
195
|
+
|
|
196
|
+
assert isinstance(response, PaymentMethod)
|
|
197
|
+
assert last_request is not None
|
|
198
|
+
assert last_request.method == "GET"
|
|
199
|
+
assert test_client.client.status_code == expected_response_status
|
|
200
|
+
assert (
|
|
201
|
+
unquote(last_request.url) == expected_url
|
|
202
|
+
), "The URL does not match the expected URL, verify the query string is correct"
|
|
203
|
+
assert response_json == loads(
|
|
204
|
+
str(expected_response_body)
|
|
205
|
+
), "The response JSON generated by ResponseParser() doesn't match the expected fixture JSON"
|
|
206
|
+
|
|
207
|
+
assert response.customer_id == "ctm_01hv6y1jedq4p1n0yqn5ba3ky4"
|
|
208
|
+
assert response.address_id == "add_01hv8h6jj90jjz0d71m6hj4r9z"
|
|
209
|
+
assert response.paypal is None
|
|
210
|
+
assert response.type == SavedPaymentMethodType.Card
|
|
211
|
+
assert response.origin == SavedPaymentMethodOrigin.Subscription
|
|
212
|
+
assert response.saved_at.isoformat() == "2024-05-03T11:50:23.422000+00:00"
|
|
213
|
+
assert response.updated_at.isoformat() == "2024-05-04T11:50:23.422000+00:00"
|
|
214
|
+
|
|
215
|
+
card = response.card
|
|
216
|
+
assert isinstance(card, Card)
|
|
217
|
+
assert card.type == "visa"
|
|
218
|
+
assert card.last4 == 2
|
|
219
|
+
assert card.expiry_month == 1
|
|
220
|
+
assert card.expiry_year == 2025
|
|
221
|
+
assert card.cardholder_name == "Sam Miller"
|
|
222
|
+
|
|
223
|
+
def test_get_payment_methods_returns_expected_paypal_response(
|
|
224
|
+
self,
|
|
225
|
+
test_client,
|
|
226
|
+
mock_requests,
|
|
227
|
+
):
|
|
228
|
+
customer_id = "ctm_01hv6y1jedq4p1n0yqn5ba3ky4"
|
|
229
|
+
payment_method_id = "paymtd_01hs8zx6x377xfsfrt2bqsevbw"
|
|
230
|
+
expected_response_status = 200
|
|
231
|
+
expected_response_body = ReadsFixtures.read_raw_json_fixture("response/full_entity_paypal")
|
|
232
|
+
expected_path = "/customers/ctm_01hv6y1jedq4p1n0yqn5ba3ky4/payment-methods/paymtd_01hs8zx6x377xfsfrt2bqsevbw"
|
|
233
|
+
|
|
234
|
+
expected_url = f"{test_client.base_url}{expected_path}"
|
|
235
|
+
mock_requests.get(expected_url, status_code=expected_response_status, text=expected_response_body)
|
|
236
|
+
|
|
237
|
+
response = test_client.client.payment_methods.get(customer_id, payment_method_id)
|
|
238
|
+
response_json = test_client.client.payment_methods.response.json()
|
|
239
|
+
last_request = mock_requests.last_request
|
|
240
|
+
|
|
241
|
+
assert isinstance(response, PaymentMethod)
|
|
242
|
+
assert last_request is not None
|
|
243
|
+
assert last_request.method == "GET"
|
|
244
|
+
assert test_client.client.status_code == expected_response_status
|
|
245
|
+
assert (
|
|
246
|
+
unquote(last_request.url) == expected_url
|
|
247
|
+
), "The URL does not match the expected URL, verify the query string is correct"
|
|
248
|
+
assert response_json == loads(
|
|
249
|
+
str(expected_response_body)
|
|
250
|
+
), "The response JSON generated by ResponseParser() doesn't match the expected fixture JSON"
|
|
251
|
+
|
|
252
|
+
assert response.customer_id == "ctm_01hv6y1jedq4p1n0yqn5ba3ky4"
|
|
253
|
+
assert response.address_id == "add_01hv8h6jj90jjz0d71m6hj4r9z"
|
|
254
|
+
assert response.card is None
|
|
255
|
+
assert response.type == SavedPaymentMethodType.Paypal
|
|
256
|
+
assert response.origin == SavedPaymentMethodOrigin.SavedDuringPurchase
|
|
257
|
+
assert response.saved_at.isoformat() == "2024-05-03T11:50:23.422000+00:00"
|
|
258
|
+
assert response.updated_at.isoformat() == "2024-05-04T11:50:23.422000+00:00"
|
|
259
|
+
|
|
260
|
+
paypal = response.paypal
|
|
261
|
+
assert isinstance(paypal, Paypal)
|
|
262
|
+
assert paypal.email == "sam@example.com"
|
|
263
|
+
assert paypal.reference == "some-reference"
|
|
264
|
+
|
|
265
|
+
def test_delete_payment_method_returns_expected_response(
|
|
266
|
+
self,
|
|
267
|
+
test_client,
|
|
268
|
+
mock_requests,
|
|
269
|
+
):
|
|
270
|
+
customer_id = "ctm_01hv6y1jedq4p1n0yqn5ba3ky4"
|
|
271
|
+
payment_method_id = "paymtd_01hs8zx6x377xfsfrt2bqsevbw"
|
|
272
|
+
expected_response_status = 200
|
|
273
|
+
expected_path = "/customers/ctm_01hv6y1jedq4p1n0yqn5ba3ky4/payment-methods/paymtd_01hs8zx6x377xfsfrt2bqsevbw"
|
|
274
|
+
|
|
275
|
+
expected_url = f"{test_client.base_url}{expected_path}"
|
|
276
|
+
mock_requests.delete(expected_url, status_code=expected_response_status)
|
|
277
|
+
|
|
278
|
+
response = test_client.client.payment_methods.delete(customer_id, payment_method_id)
|
|
279
|
+
last_request = mock_requests.last_request
|
|
280
|
+
|
|
281
|
+
assert response is None
|
|
282
|
+
assert last_request is not None
|
|
283
|
+
assert last_request.method == "DELETE"
|
|
284
|
+
assert test_client.client.status_code == expected_response_status
|
|
285
|
+
assert (
|
|
286
|
+
unquote(last_request.url) == expected_url
|
|
287
|
+
), "The URL does not match the expected URL, verify the query string is correct"
|
|
File without changes
|
|
File without changes
|