swarmauri_billing_braintree 0.1.3.dev3__tar.gz → 0.11.0.dev1__tar.gz
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.
- swarmauri_billing_braintree-0.11.0.dev1/PKG-INFO +194 -0
- swarmauri_billing_braintree-0.11.0.dev1/README.md +159 -0
- {swarmauri_billing_braintree-0.1.3.dev3 → swarmauri_billing_braintree-0.11.0.dev1}/pyproject.toml +19 -4
- {swarmauri_billing_braintree-0.1.3.dev3 → swarmauri_billing_braintree-0.11.0.dev1}/swarmauri_billing_braintree/provider.py +209 -94
- swarmauri_billing_braintree-0.1.3.dev3/PKG-INFO +0 -91
- swarmauri_billing_braintree-0.1.3.dev3/README.md +0 -61
- {swarmauri_billing_braintree-0.1.3.dev3 → swarmauri_billing_braintree-0.11.0.dev1}/LICENSE +0 -0
- {swarmauri_billing_braintree-0.1.3.dev3 → swarmauri_billing_braintree-0.11.0.dev1}/swarmauri_billing_braintree/__init__.py +0 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: swarmauri_billing_braintree
|
|
3
|
+
Version: 0.11.0.dev1
|
|
4
|
+
Summary: Braintree SDK backed Swarmauri billing provider for transactions, settlement, voids, refunds, subscriptions, customers, payment methods, disputes, and webhooks.
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: swarmauri,sdk,billing,braintree,braintree billing provider,braintree payments,community,payments,payment gateway,checkout,hosted checkout,customer vault,fraud,refunds,webhooks,transactions,settlement,subscription management,merchant services,e-commerce integration
|
|
8
|
+
Author: Jacob Stewart
|
|
9
|
+
Author-email: jacob@swarmauri.com
|
|
10
|
+
Requires-Python: >=3.10,<3.15
|
|
11
|
+
Classifier: Development Status :: 1 - Planning
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Information Technology
|
|
14
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
17
|
+
Classifier: Topic :: Office/Business :: Financial
|
|
18
|
+
Classifier: Topic :: Office/Business :: Financial :: Point-Of-Sale
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
21
|
+
Classifier: Topic :: Software Development :: Testing
|
|
22
|
+
Classifier: Programming Language :: Python
|
|
23
|
+
Classifier: Programming Language :: Python :: 3
|
|
24
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
27
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
28
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
29
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
30
|
+
Requires-Dist: braintree (>=4.37.0)
|
|
31
|
+
Requires-Dist: swarmauri_base
|
|
32
|
+
Requires-Dist: swarmauri_core
|
|
33
|
+
Description-Content-Type: text/markdown
|
|
34
|
+
|
|
35
|
+

|
|
36
|
+
|
|
37
|
+
<p align="center">
|
|
38
|
+
<a href="https://pepy.tech/project/swarmauri_billing_braintree/">
|
|
39
|
+
<img src="https://static.pepy.tech/badge/swarmauri_billing_braintree/month" alt="PyPI - Downloads"/></a>
|
|
40
|
+
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_billing_braintree/">
|
|
41
|
+
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_billing_braintree.svg"/></a>
|
|
42
|
+
<a href="https://pypi.org/project/swarmauri_billing_braintree/">
|
|
43
|
+
<img src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue" alt="PyPI - Python Version"/></a>
|
|
44
|
+
<a href="https://pypi.org/project/swarmauri_billing_braintree/">
|
|
45
|
+
<img src="https://img.shields.io/pypi/l/swarmauri_billing_braintree" alt="PyPI - License"/></a>
|
|
46
|
+
<a href="https://pypi.org/project/swarmauri_billing_braintree/">
|
|
47
|
+
<img src="https://img.shields.io/pypi/v/swarmauri_billing_braintree?label=swarmauri_billing_braintree&color=green" alt="PyPI - swarmauri_billing_braintree"/></a>
|
|
48
|
+
<a href="https://discord.gg/N4UpBuQv8T">
|
|
49
|
+
<img src="https://img.shields.io/badge/Discord-Join%20Chat-5865F2?logo=discord&logoColor=white" alt="Discord"/></a></p>
|
|
50
|
+
|
|
51
|
+
# Swarmauri Billing Braintree
|
|
52
|
+
|
|
53
|
+
`swarmauri_billing_braintree` provides a Braintree SDK backed billing provider for Swarmauri checkout, payment, subscription, refund, customer-vault, reporting, risk, and webhook workflows. It connects Swarmauri billing interfaces to Braintree transactions, settlement submission, voids, refunds, customers, payment methods, subscriptions, disputes, and webhook notifications.
|
|
54
|
+
|
|
55
|
+
## Why Swarmauri Billing Braintree?
|
|
56
|
+
|
|
57
|
+
`swarmauri_billing_braintree` gives billing integrators Braintree payment runtime behavior behind Swarmauri billing interfaces. Applications can create transactions, submit authorized payments for settlement, void transactions, refund payments, manage customer vault records, create subscriptions, and parse Braintree webhooks without hard-coding Braintree SDK calls throughout the codebase.
|
|
58
|
+
|
|
59
|
+
## FAQ
|
|
60
|
+
|
|
61
|
+
### Q: Does this package call live Braintree APIs?
|
|
62
|
+
|
|
63
|
+
A: Yes. It creates a `braintree.BraintreeGateway` from merchant credentials and calls Braintree SDK resources for transactions, customers, payment methods, subscriptions, disputes, and webhooks.
|
|
64
|
+
|
|
65
|
+
### Q: Which Swarmauri billing flows does it cover?
|
|
66
|
+
|
|
67
|
+
A: It covers online payments, settlement capture, voids, refunds, customers, payment methods, subscriptions, dispute listing, and webhook parsing. Product, price, hosted-checkout, and report helpers remain compatibility placeholders where Braintree does not expose direct matching objects through the same API shape.
|
|
68
|
+
|
|
69
|
+
### Q: Why use this instead of `swarmauri_billing_mock`?
|
|
70
|
+
|
|
71
|
+
A: Use this package when you want Braintree-shaped IDs, statuses, checkout URLs, and webhook headers. Use a generic mock when gateway-specific behavior is not relevant.
|
|
72
|
+
|
|
73
|
+
## Features
|
|
74
|
+
|
|
75
|
+
- Braintree provider class registered as `BraintreeBillingProvider`.
|
|
76
|
+
- Transaction sale, submit-for-settlement, void, and refund support.
|
|
77
|
+
- Customer creation and lookup through the Braintree customer vault.
|
|
78
|
+
- Payment method create/delete support.
|
|
79
|
+
- Subscription create/cancel support.
|
|
80
|
+
- Dispute search support.
|
|
81
|
+
- Webhook parsing and signature validation through Braintree SDK helpers.
|
|
82
|
+
- Compatibility placeholders for product, price, hosted-checkout, and report methods that do not map directly to Braintree SDK resources.
|
|
83
|
+
- Python 3.10, 3.11, 3.12, 3.13, and 3.14 support.
|
|
84
|
+
|
|
85
|
+
## Installation
|
|
86
|
+
|
|
87
|
+
Install with `uv`:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
uv add swarmauri_billing_braintree
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Install with `pip`:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
pip install swarmauri_billing_braintree
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Usage
|
|
100
|
+
|
|
101
|
+
Authorize and capture a Braintree-style payment:
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from swarmauri_billing_braintree import BraintreeBillingProvider
|
|
105
|
+
from swarmauri_base.billing import PaymentIntentRequest
|
|
106
|
+
|
|
107
|
+
provider = BraintreeBillingProvider(
|
|
108
|
+
api_key="braintree",
|
|
109
|
+
merchant_id="merchant-id",
|
|
110
|
+
public_key="public-key",
|
|
111
|
+
private_key="private-key",
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
payment = provider.create_payment_intent(
|
|
115
|
+
PaymentIntentRequest(
|
|
116
|
+
amount_minor=1500,
|
|
117
|
+
currency="USD",
|
|
118
|
+
confirm=True,
|
|
119
|
+
)
|
|
120
|
+
)
|
|
121
|
+
captured = provider.capture_payment(payment.id, idempotency_key="capture-bt-1")
|
|
122
|
+
|
|
123
|
+
print(payment.status, captured.status)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Create a plan, price, and checkout session:
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
from swarmauri_billing_braintree import BraintreeBillingProvider
|
|
130
|
+
from swarmauri_base.billing import CheckoutRequest, PriceSpec, ProductSpec
|
|
131
|
+
|
|
132
|
+
provider = BraintreeBillingProvider(
|
|
133
|
+
api_key="braintree",
|
|
134
|
+
merchant_id="merchant-id",
|
|
135
|
+
public_key="public-key",
|
|
136
|
+
private_key="private-key",
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
plan = provider.create_product(
|
|
140
|
+
ProductSpec(name="SaaS Plan"),
|
|
141
|
+
idempotency_key="plan-bt-1",
|
|
142
|
+
)
|
|
143
|
+
price = provider.create_price(
|
|
144
|
+
plan,
|
|
145
|
+
PriceSpec(currency="USD", unit_amount_minor=2900),
|
|
146
|
+
idempotency_key="price-bt-1",
|
|
147
|
+
)
|
|
148
|
+
checkout = provider.create_checkout(price, CheckoutRequest(quantity=1))
|
|
149
|
+
|
|
150
|
+
print(checkout.url)
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Important Scope Notes
|
|
154
|
+
|
|
155
|
+
This package uses live Braintree SDK calls for payment, customer, payment-method, subscription, dispute, and webhook workflows. Production use requires valid Braintree merchant credentials and tokenized payment-method nonces or vaulted payment method tokens.
|
|
156
|
+
|
|
157
|
+
## Entry Point
|
|
158
|
+
|
|
159
|
+
The package exposes a Swarmauri billing provider entry point:
|
|
160
|
+
|
|
161
|
+
```toml
|
|
162
|
+
[project.entry-points.'swarmauri.billing_providers']
|
|
163
|
+
BraintreeBillingProvider = "swarmauri_billing_braintree.provider:BraintreeBillingProvider"
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Related Packages
|
|
167
|
+
|
|
168
|
+
Billing provider packages:
|
|
169
|
+
|
|
170
|
+
- [swarmauri_billing_adyen](https://pypi.org/project/swarmauri_billing_adyen/)
|
|
171
|
+
- [swarmauri_billing_authorize_net](https://pypi.org/project/swarmauri_billing_authorize_net/)
|
|
172
|
+
- [swarmauri_billing_mock](https://pypi.org/project/swarmauri_billing_mock/)
|
|
173
|
+
- [swarmauri_billing_paypal](https://pypi.org/project/swarmauri_billing_paypal/)
|
|
174
|
+
- [swarmauri_billing_paystack](https://pypi.org/project/swarmauri_billing_paystack/)
|
|
175
|
+
- [swarmauri_billing_razorpay](https://pypi.org/project/swarmauri_billing_razorpay/)
|
|
176
|
+
- [swarmauri_billing_square](https://pypi.org/project/swarmauri_billing_square/)
|
|
177
|
+
- [swarmauri_billing_stripe](https://pypi.org/project/swarmauri_billing_stripe/)
|
|
178
|
+
|
|
179
|
+
Foundational packages:
|
|
180
|
+
|
|
181
|
+
- [swarmauri_core](https://pypi.org/project/swarmauri_core/) defines billing capabilities and interfaces.
|
|
182
|
+
- [swarmauri_base](https://pypi.org/project/swarmauri_base/) provides billing specs, refs, mixins, and `BillingProviderBase`.
|
|
183
|
+
- [swarmauri](https://pypi.org/project/swarmauri/) provides namespace imports and plugin discovery.
|
|
184
|
+
|
|
185
|
+
## License
|
|
186
|
+
|
|
187
|
+
Apache-2.0
|
|
188
|
+
|
|
189
|
+
## Contributing
|
|
190
|
+
|
|
191
|
+
If you connect this provider to live Braintree APIs, preserve deterministic tests, document required credentials and webhook behavior, and add coverage for each supported billing capability.
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="https://pepy.tech/project/swarmauri_billing_braintree/">
|
|
5
|
+
<img src="https://static.pepy.tech/badge/swarmauri_billing_braintree/month" alt="PyPI - Downloads"/></a>
|
|
6
|
+
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_billing_braintree/">
|
|
7
|
+
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_billing_braintree.svg"/></a>
|
|
8
|
+
<a href="https://pypi.org/project/swarmauri_billing_braintree/">
|
|
9
|
+
<img src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue" alt="PyPI - Python Version"/></a>
|
|
10
|
+
<a href="https://pypi.org/project/swarmauri_billing_braintree/">
|
|
11
|
+
<img src="https://img.shields.io/pypi/l/swarmauri_billing_braintree" alt="PyPI - License"/></a>
|
|
12
|
+
<a href="https://pypi.org/project/swarmauri_billing_braintree/">
|
|
13
|
+
<img src="https://img.shields.io/pypi/v/swarmauri_billing_braintree?label=swarmauri_billing_braintree&color=green" alt="PyPI - swarmauri_billing_braintree"/></a>
|
|
14
|
+
<a href="https://discord.gg/N4UpBuQv8T">
|
|
15
|
+
<img src="https://img.shields.io/badge/Discord-Join%20Chat-5865F2?logo=discord&logoColor=white" alt="Discord"/></a></p>
|
|
16
|
+
|
|
17
|
+
# Swarmauri Billing Braintree
|
|
18
|
+
|
|
19
|
+
`swarmauri_billing_braintree` provides a Braintree SDK backed billing provider for Swarmauri checkout, payment, subscription, refund, customer-vault, reporting, risk, and webhook workflows. It connects Swarmauri billing interfaces to Braintree transactions, settlement submission, voids, refunds, customers, payment methods, subscriptions, disputes, and webhook notifications.
|
|
20
|
+
|
|
21
|
+
## Why Swarmauri Billing Braintree?
|
|
22
|
+
|
|
23
|
+
`swarmauri_billing_braintree` gives billing integrators Braintree payment runtime behavior behind Swarmauri billing interfaces. Applications can create transactions, submit authorized payments for settlement, void transactions, refund payments, manage customer vault records, create subscriptions, and parse Braintree webhooks without hard-coding Braintree SDK calls throughout the codebase.
|
|
24
|
+
|
|
25
|
+
## FAQ
|
|
26
|
+
|
|
27
|
+
### Q: Does this package call live Braintree APIs?
|
|
28
|
+
|
|
29
|
+
A: Yes. It creates a `braintree.BraintreeGateway` from merchant credentials and calls Braintree SDK resources for transactions, customers, payment methods, subscriptions, disputes, and webhooks.
|
|
30
|
+
|
|
31
|
+
### Q: Which Swarmauri billing flows does it cover?
|
|
32
|
+
|
|
33
|
+
A: It covers online payments, settlement capture, voids, refunds, customers, payment methods, subscriptions, dispute listing, and webhook parsing. Product, price, hosted-checkout, and report helpers remain compatibility placeholders where Braintree does not expose direct matching objects through the same API shape.
|
|
34
|
+
|
|
35
|
+
### Q: Why use this instead of `swarmauri_billing_mock`?
|
|
36
|
+
|
|
37
|
+
A: Use this package when you want Braintree-shaped IDs, statuses, checkout URLs, and webhook headers. Use a generic mock when gateway-specific behavior is not relevant.
|
|
38
|
+
|
|
39
|
+
## Features
|
|
40
|
+
|
|
41
|
+
- Braintree provider class registered as `BraintreeBillingProvider`.
|
|
42
|
+
- Transaction sale, submit-for-settlement, void, and refund support.
|
|
43
|
+
- Customer creation and lookup through the Braintree customer vault.
|
|
44
|
+
- Payment method create/delete support.
|
|
45
|
+
- Subscription create/cancel support.
|
|
46
|
+
- Dispute search support.
|
|
47
|
+
- Webhook parsing and signature validation through Braintree SDK helpers.
|
|
48
|
+
- Compatibility placeholders for product, price, hosted-checkout, and report methods that do not map directly to Braintree SDK resources.
|
|
49
|
+
- Python 3.10, 3.11, 3.12, 3.13, and 3.14 support.
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
|
|
53
|
+
Install with `uv`:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
uv add swarmauri_billing_braintree
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Install with `pip`:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pip install swarmauri_billing_braintree
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Usage
|
|
66
|
+
|
|
67
|
+
Authorize and capture a Braintree-style payment:
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from swarmauri_billing_braintree import BraintreeBillingProvider
|
|
71
|
+
from swarmauri_base.billing import PaymentIntentRequest
|
|
72
|
+
|
|
73
|
+
provider = BraintreeBillingProvider(
|
|
74
|
+
api_key="braintree",
|
|
75
|
+
merchant_id="merchant-id",
|
|
76
|
+
public_key="public-key",
|
|
77
|
+
private_key="private-key",
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
payment = provider.create_payment_intent(
|
|
81
|
+
PaymentIntentRequest(
|
|
82
|
+
amount_minor=1500,
|
|
83
|
+
currency="USD",
|
|
84
|
+
confirm=True,
|
|
85
|
+
)
|
|
86
|
+
)
|
|
87
|
+
captured = provider.capture_payment(payment.id, idempotency_key="capture-bt-1")
|
|
88
|
+
|
|
89
|
+
print(payment.status, captured.status)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Create a plan, price, and checkout session:
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
from swarmauri_billing_braintree import BraintreeBillingProvider
|
|
96
|
+
from swarmauri_base.billing import CheckoutRequest, PriceSpec, ProductSpec
|
|
97
|
+
|
|
98
|
+
provider = BraintreeBillingProvider(
|
|
99
|
+
api_key="braintree",
|
|
100
|
+
merchant_id="merchant-id",
|
|
101
|
+
public_key="public-key",
|
|
102
|
+
private_key="private-key",
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
plan = provider.create_product(
|
|
106
|
+
ProductSpec(name="SaaS Plan"),
|
|
107
|
+
idempotency_key="plan-bt-1",
|
|
108
|
+
)
|
|
109
|
+
price = provider.create_price(
|
|
110
|
+
plan,
|
|
111
|
+
PriceSpec(currency="USD", unit_amount_minor=2900),
|
|
112
|
+
idempotency_key="price-bt-1",
|
|
113
|
+
)
|
|
114
|
+
checkout = provider.create_checkout(price, CheckoutRequest(quantity=1))
|
|
115
|
+
|
|
116
|
+
print(checkout.url)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Important Scope Notes
|
|
120
|
+
|
|
121
|
+
This package uses live Braintree SDK calls for payment, customer, payment-method, subscription, dispute, and webhook workflows. Production use requires valid Braintree merchant credentials and tokenized payment-method nonces or vaulted payment method tokens.
|
|
122
|
+
|
|
123
|
+
## Entry Point
|
|
124
|
+
|
|
125
|
+
The package exposes a Swarmauri billing provider entry point:
|
|
126
|
+
|
|
127
|
+
```toml
|
|
128
|
+
[project.entry-points.'swarmauri.billing_providers']
|
|
129
|
+
BraintreeBillingProvider = "swarmauri_billing_braintree.provider:BraintreeBillingProvider"
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Related Packages
|
|
133
|
+
|
|
134
|
+
Billing provider packages:
|
|
135
|
+
|
|
136
|
+
- [swarmauri_billing_adyen](https://pypi.org/project/swarmauri_billing_adyen/)
|
|
137
|
+
- [swarmauri_billing_authorize_net](https://pypi.org/project/swarmauri_billing_authorize_net/)
|
|
138
|
+
- [swarmauri_billing_mock](https://pypi.org/project/swarmauri_billing_mock/)
|
|
139
|
+
- [swarmauri_billing_paypal](https://pypi.org/project/swarmauri_billing_paypal/)
|
|
140
|
+
- [swarmauri_billing_paystack](https://pypi.org/project/swarmauri_billing_paystack/)
|
|
141
|
+
- [swarmauri_billing_razorpay](https://pypi.org/project/swarmauri_billing_razorpay/)
|
|
142
|
+
- [swarmauri_billing_square](https://pypi.org/project/swarmauri_billing_square/)
|
|
143
|
+
- [swarmauri_billing_stripe](https://pypi.org/project/swarmauri_billing_stripe/)
|
|
144
|
+
|
|
145
|
+
Foundational packages:
|
|
146
|
+
|
|
147
|
+
- [swarmauri_core](https://pypi.org/project/swarmauri_core/) defines billing capabilities and interfaces.
|
|
148
|
+
- [swarmauri_base](https://pypi.org/project/swarmauri_base/) provides billing specs, refs, mixins, and `BillingProviderBase`.
|
|
149
|
+
- [swarmauri](https://pypi.org/project/swarmauri/) provides namespace imports and plugin discovery.
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
Apache-2.0
|
|
154
|
+
|
|
155
|
+
## Contributing
|
|
156
|
+
|
|
157
|
+
If you connect this provider to live Braintree APIs, preserve deterministic tests, document required credentials and webhook behavior, and add coverage for each supported billing capability.
|
|
158
|
+
|
|
159
|
+
|
{swarmauri_billing_braintree-0.1.3.dev3 → swarmauri_billing_braintree-0.11.0.dev1}/pyproject.toml
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "swarmauri_billing_braintree"
|
|
3
|
-
version = "0.
|
|
4
|
-
description = "Braintree billing provider for
|
|
3
|
+
version = "0.11.0.dev1"
|
|
4
|
+
description = "Braintree SDK backed Swarmauri billing provider for transactions, settlement, voids, refunds, subscriptions, customers, payment methods, disputes, and webhooks."
|
|
5
5
|
license = "Apache-2.0"
|
|
6
6
|
readme = "README.md"
|
|
7
7
|
repository = "http://github.com/swarmauri/swarmauri-sdk"
|
|
@@ -12,8 +12,12 @@ classifiers = [
|
|
|
12
12
|
"Intended Audience :: Information Technology",
|
|
13
13
|
"License :: OSI Approved :: Apache Software License",
|
|
14
14
|
"Operating System :: OS Independent",
|
|
15
|
+
"Topic :: Internet :: WWW/HTTP",
|
|
16
|
+
"Topic :: Office/Business :: Financial",
|
|
15
17
|
"Topic :: Office/Business :: Financial :: Point-Of-Sale",
|
|
18
|
+
"Topic :: Software Development :: Libraries",
|
|
16
19
|
"Topic :: Software Development :: Libraries :: Application Frameworks",
|
|
20
|
+
"Topic :: Software Development :: Testing",
|
|
17
21
|
"Programming Language :: Python",
|
|
18
22
|
"Programming Language :: Python :: 3",
|
|
19
23
|
"Programming Language :: Python :: 3 :: Only",
|
|
@@ -27,15 +31,26 @@ authors = [{ name = "Jacob Stewart", email = "jacob@swarmauri.com" }]
|
|
|
27
31
|
dependencies = [
|
|
28
32
|
"swarmauri_core",
|
|
29
33
|
"swarmauri_base",
|
|
34
|
+
"braintree>=4.37.0",
|
|
30
35
|
]
|
|
31
36
|
keywords = [
|
|
32
37
|
"swarmauri",
|
|
33
38
|
"sdk",
|
|
34
39
|
"billing",
|
|
35
40
|
"braintree",
|
|
36
|
-
"
|
|
41
|
+
"braintree billing provider",
|
|
42
|
+
"braintree payments",
|
|
43
|
+
"community",
|
|
37
44
|
"payments",
|
|
45
|
+
"payment gateway",
|
|
46
|
+
"checkout",
|
|
47
|
+
"hosted checkout",
|
|
48
|
+
"customer vault",
|
|
38
49
|
"fraud",
|
|
50
|
+
"refunds",
|
|
51
|
+
"webhooks",
|
|
52
|
+
"transactions",
|
|
53
|
+
"settlement",
|
|
39
54
|
"subscription management",
|
|
40
55
|
"merchant services",
|
|
41
56
|
"e-commerce integration",
|
|
@@ -79,7 +94,7 @@ dev = [
|
|
|
79
94
|
"pytest-xdist>=3.6.1",
|
|
80
95
|
"pytest-json-report>=1.5.0",
|
|
81
96
|
"python-dotenv",
|
|
82
|
-
"
|
|
97
|
+
"httpx>=0.27",
|
|
83
98
|
"flake8>=7.0",
|
|
84
99
|
"pytest-timeout>=2.3.1",
|
|
85
100
|
"ruff>=0.9.9",
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
"""Braintree billing provider
|
|
1
|
+
"""Braintree billing provider for Swarmauri interfaces."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
from typing import Any, Mapping, Optional, Sequence, cast
|
|
6
6
|
from uuid import uuid4
|
|
7
7
|
|
|
8
|
+
from pydantic import Field, PrivateAttr, SecretStr
|
|
9
|
+
|
|
8
10
|
from swarmauri_base.billing import (
|
|
9
11
|
BillingProviderBase,
|
|
10
12
|
CustomersMixin,
|
|
@@ -34,7 +36,8 @@ class BraintreeBillingProvider(
|
|
|
34
36
|
WebhooksMixin,
|
|
35
37
|
BillingProviderBase,
|
|
36
38
|
):
|
|
37
|
-
"""
|
|
39
|
+
"""Braintree SDK backed provider featuring the primary Swarmauri
|
|
40
|
+
capabilities."""
|
|
38
41
|
|
|
39
42
|
CAPABILITIES = frozenset(
|
|
40
43
|
{
|
|
@@ -51,8 +54,64 @@ class BraintreeBillingProvider(
|
|
|
51
54
|
}
|
|
52
55
|
)
|
|
53
56
|
component_name: str = "braintree"
|
|
57
|
+
merchant_id: str | None = Field(
|
|
58
|
+
default=None, description="Braintree merchant ID"
|
|
59
|
+
)
|
|
60
|
+
public_key: str | None = Field(
|
|
61
|
+
default=None, description="Braintree public key"
|
|
62
|
+
)
|
|
63
|
+
private_key: SecretStr | None = Field(
|
|
64
|
+
default=None, description="Braintree private key"
|
|
65
|
+
)
|
|
66
|
+
environment: str = Field(
|
|
67
|
+
default="sandbox", description="Braintree environment"
|
|
68
|
+
)
|
|
69
|
+
_gateway: Any = PrivateAttr(default=None)
|
|
70
|
+
|
|
71
|
+
def _bt(self) -> Any:
|
|
72
|
+
if self._gateway is None:
|
|
73
|
+
import braintree
|
|
54
74
|
|
|
55
|
-
|
|
75
|
+
if not (self.merchant_id and self.public_key and self.private_key):
|
|
76
|
+
raise ValueError(
|
|
77
|
+
(
|
|
78
|
+
"merchant_id, public_key, and private_key are required " # noqa: E501
|
|
79
|
+
"for "
|
|
80
|
+
"Braintree API calls"
|
|
81
|
+
)
|
|
82
|
+
)
|
|
83
|
+
env = (
|
|
84
|
+
braintree.Environment.Production
|
|
85
|
+
if self.environment.lower() == "production"
|
|
86
|
+
else braintree.Environment.Sandbox
|
|
87
|
+
)
|
|
88
|
+
self._gateway = braintree.BraintreeGateway(
|
|
89
|
+
braintree.Configuration(
|
|
90
|
+
env,
|
|
91
|
+
merchant_id=self.merchant_id,
|
|
92
|
+
public_key=self.public_key,
|
|
93
|
+
private_key=self.private_key.get_secret_value(),
|
|
94
|
+
)
|
|
95
|
+
)
|
|
96
|
+
return self._gateway
|
|
97
|
+
|
|
98
|
+
@staticmethod
|
|
99
|
+
def _result_payload(result: Any) -> Mapping[str, Any]:
|
|
100
|
+
if not getattr(result, "is_success", False):
|
|
101
|
+
raise RuntimeError(str(getattr(result, "message", result)))
|
|
102
|
+
obj = getattr(result, "transaction", None)
|
|
103
|
+
obj = obj or getattr(result, "customer", None)
|
|
104
|
+
obj = obj or getattr(result, "payment_method", None)
|
|
105
|
+
obj = obj or getattr(result, "subscription", None)
|
|
106
|
+
obj = obj or getattr(result, "refund", None)
|
|
107
|
+
if obj is None:
|
|
108
|
+
return {"raw": str(result)}
|
|
109
|
+
if hasattr(obj, "__dict__"):
|
|
110
|
+
return dict(obj.__dict__)
|
|
111
|
+
return {"raw": str(obj)}
|
|
112
|
+
|
|
113
|
+
# ---------------------------------------------------------------------
|
|
114
|
+
# utils
|
|
56
115
|
@staticmethod
|
|
57
116
|
def _dump(obj: Any) -> Mapping[str, Any]:
|
|
58
117
|
if hasattr(obj, "model_dump"):
|
|
@@ -70,7 +129,8 @@ class BraintreeBillingProvider(
|
|
|
70
129
|
"payload": payload,
|
|
71
130
|
}
|
|
72
131
|
|
|
73
|
-
# ------------------------------------------------------------
|
|
132
|
+
# ------------------------------------------------------------
|
|
133
|
+
# products/prices
|
|
74
134
|
def _create_product(
|
|
75
135
|
self, product_spec: Any, *, idempotency_key: str
|
|
76
136
|
) -> Mapping[str, Any]:
|
|
@@ -107,7 +167,8 @@ class BraintreeBillingProvider(
|
|
|
107
167
|
),
|
|
108
168
|
}
|
|
109
169
|
|
|
110
|
-
# --------------------------------------------------------------- hosted
|
|
170
|
+
# --------------------------------------------------------------- hosted
|
|
171
|
+
# flow
|
|
111
172
|
def _create_checkout(self, price: Any, request: Any) -> Mapping[str, Any]:
|
|
112
173
|
return {
|
|
113
174
|
"id": f"bt_checkout_{uuid4().hex[:8]}",
|
|
@@ -120,33 +181,44 @@ class BraintreeBillingProvider(
|
|
|
120
181
|
),
|
|
121
182
|
}
|
|
122
183
|
|
|
123
|
-
# ----------------------------------------------------------- online
|
|
184
|
+
# ----------------------------------------------------------- online
|
|
185
|
+
# payments
|
|
124
186
|
def _create_payment_intent(self, req: Any) -> Mapping[str, Any]:
|
|
187
|
+
gateway = self._bt()
|
|
125
188
|
amount = int(req.resolve("amount_minor") or 0)
|
|
126
189
|
currency = (req.resolve("currency") or "USD").upper()
|
|
190
|
+
metadata = dict(req.resolve("metadata") or {})
|
|
191
|
+
sale = gateway.transaction.sale(
|
|
192
|
+
{
|
|
193
|
+
"amount": f"{amount / 100:.2f}",
|
|
194
|
+
"payment_method_nonce": req.resolve("payment_method_id")
|
|
195
|
+
or metadata.get("payment_method_nonce", "fake-valid-nonce"),
|
|
196
|
+
"options": {
|
|
197
|
+
"submit_for_settlement": bool(req.resolve("capture"))
|
|
198
|
+
},
|
|
199
|
+
"order_id": req.resolve("idempotency_key"),
|
|
200
|
+
}
|
|
201
|
+
)
|
|
202
|
+
raw = self._result_payload(sale)
|
|
127
203
|
return {
|
|
128
|
-
"id": f"bt_txn_{uuid4().hex[:8]}",
|
|
129
|
-
"status": "
|
|
130
|
-
if req.resolve("confirm")
|
|
131
|
-
else "SUBMITTED_FOR_SETTLEMENT",
|
|
204
|
+
"id": raw.get("id", f"bt_txn_{uuid4().hex[:8]}"),
|
|
205
|
+
"status": raw.get("status"),
|
|
132
206
|
"amount_minor": amount,
|
|
133
207
|
"currency": currency,
|
|
134
208
|
"provider": self.component_name,
|
|
135
|
-
"raw":
|
|
209
|
+
"raw": raw,
|
|
136
210
|
}
|
|
137
211
|
|
|
138
212
|
def _capture_payment(
|
|
139
213
|
self, payment_id: str, *, idempotency_key: Optional[str] = None
|
|
140
214
|
) -> Mapping[str, Any]:
|
|
215
|
+
result = self._bt().transaction.submit_for_settlement(payment_id)
|
|
216
|
+
raw = self._result_payload(result)
|
|
141
217
|
return {
|
|
142
|
-
"id": payment_id,
|
|
143
|
-
"status": "
|
|
218
|
+
"id": raw.get("id", payment_id),
|
|
219
|
+
"status": raw.get("status"),
|
|
144
220
|
"provider": self.component_name,
|
|
145
|
-
"raw":
|
|
146
|
-
"capture_payment",
|
|
147
|
-
payment_id=payment_id,
|
|
148
|
-
idempotency_key=idempotency_key,
|
|
149
|
-
),
|
|
221
|
+
"raw": raw,
|
|
150
222
|
}
|
|
151
223
|
|
|
152
224
|
def _cancel_payment(
|
|
@@ -156,89 +228,111 @@ class BraintreeBillingProvider(
|
|
|
156
228
|
reason: Optional[str] = None,
|
|
157
229
|
idempotency_key: Optional[str] = None,
|
|
158
230
|
) -> Mapping[str, Any]:
|
|
231
|
+
result = self._bt().transaction.void(payment_id)
|
|
232
|
+
raw = self._result_payload(result)
|
|
159
233
|
return {
|
|
160
|
-
"id": payment_id,
|
|
161
|
-
"status": "
|
|
234
|
+
"id": raw.get("id", payment_id),
|
|
235
|
+
"status": raw.get("status"),
|
|
162
236
|
"provider": self.component_name,
|
|
163
|
-
"raw":
|
|
164
|
-
"cancel_payment",
|
|
165
|
-
payment_id=payment_id,
|
|
166
|
-
reason=reason,
|
|
167
|
-
idempotency_key=idempotency_key,
|
|
168
|
-
),
|
|
237
|
+
"raw": raw,
|
|
169
238
|
}
|
|
170
239
|
|
|
171
|
-
# ---------------------------------------------------------------
|
|
240
|
+
# ---------------------------------------------------------------
|
|
241
|
+
# subscription
|
|
172
242
|
def _create_subscription(
|
|
173
243
|
self, spec: Any, *, idempotency_key: str
|
|
174
244
|
) -> Mapping[str, Any]:
|
|
245
|
+
if not spec.items:
|
|
246
|
+
raise ValueError(
|
|
247
|
+
"Braintree subscription creation requires a plan_id"
|
|
248
|
+
)
|
|
249
|
+
result = self._bt().subscription.create(
|
|
250
|
+
{
|
|
251
|
+
"payment_method_token": (spec.metadata or {}).get(
|
|
252
|
+
"payment_method_token"
|
|
253
|
+
),
|
|
254
|
+
"plan_id": spec.items[0].price_id,
|
|
255
|
+
}
|
|
256
|
+
)
|
|
257
|
+
raw = self._result_payload(result)
|
|
175
258
|
return {
|
|
176
|
-
"subscription_id": f"bt_sub_{uuid4().hex[:8]}",
|
|
177
|
-
"status": "
|
|
259
|
+
"subscription_id": raw.get("id", f"bt_sub_{uuid4().hex[:8]}"),
|
|
260
|
+
"status": raw.get("status"),
|
|
178
261
|
"provider": self.component_name,
|
|
179
|
-
"raw":
|
|
180
|
-
"create_subscription",
|
|
181
|
-
idempotency_key=idempotency_key,
|
|
182
|
-
spec=self._dump(spec),
|
|
183
|
-
),
|
|
262
|
+
"raw": raw,
|
|
184
263
|
}
|
|
185
264
|
|
|
186
265
|
def _cancel_subscription(
|
|
187
266
|
self, subscription_id: str, *, at_period_end: bool = True
|
|
188
267
|
) -> Mapping[str, Any]:
|
|
189
|
-
|
|
268
|
+
result = self._bt().subscription.cancel(subscription_id)
|
|
269
|
+
raw = self._result_payload(result)
|
|
190
270
|
return {
|
|
191
271
|
"subscription_id": subscription_id,
|
|
192
|
-
"status": status,
|
|
272
|
+
"status": raw.get("status", "Canceled"),
|
|
193
273
|
"provider": self.component_name,
|
|
194
|
-
"raw":
|
|
195
|
-
"cancel_subscription",
|
|
196
|
-
subscription_id=subscription_id,
|
|
197
|
-
at_period_end=at_period_end,
|
|
198
|
-
),
|
|
274
|
+
"raw": raw,
|
|
199
275
|
}
|
|
200
276
|
|
|
201
|
-
# ---------------------------------------------------------------------
|
|
277
|
+
# ---------------------------------------------------------------------
|
|
278
|
+
# refund
|
|
202
279
|
def _create_refund(
|
|
203
280
|
self, payment: Any, req: Any, *, idempotency_key: str
|
|
204
281
|
) -> Mapping[str, Any]:
|
|
282
|
+
amount = req.resolve("amount_minor")
|
|
283
|
+
result = self._bt().transaction.refund(
|
|
284
|
+
getattr(payment, "id", ""),
|
|
285
|
+
f"{int(amount) / 100:.2f}" if amount is not None else None,
|
|
286
|
+
)
|
|
287
|
+
raw = self._result_payload(result)
|
|
205
288
|
return {
|
|
206
|
-
"id": f"bt_refund_{uuid4().hex[:8]}",
|
|
207
|
-
"status": "
|
|
289
|
+
"id": raw.get("id", f"bt_refund_{uuid4().hex[:8]}"),
|
|
290
|
+
"status": raw.get("status"),
|
|
208
291
|
"provider": self.component_name,
|
|
209
|
-
"raw":
|
|
210
|
-
"create_refund",
|
|
211
|
-
payment_id=getattr(payment, "id", ""),
|
|
212
|
-
request=self._dump(req),
|
|
213
|
-
idempotency_key=idempotency_key,
|
|
214
|
-
),
|
|
292
|
+
"raw": raw,
|
|
215
293
|
}
|
|
216
294
|
|
|
217
295
|
def _get_refund(self, refund_id: str) -> Mapping[str, Any]:
|
|
296
|
+
transaction = self._bt().transaction.find(refund_id)
|
|
297
|
+
raw = (
|
|
298
|
+
dict(transaction.__dict__)
|
|
299
|
+
if hasattr(transaction, "__dict__")
|
|
300
|
+
else {}
|
|
301
|
+
)
|
|
218
302
|
return {
|
|
219
303
|
"id": refund_id,
|
|
220
|
-
"status": "
|
|
304
|
+
"status": raw.get("status"),
|
|
221
305
|
"provider": self.component_name,
|
|
222
|
-
"raw":
|
|
306
|
+
"raw": raw,
|
|
223
307
|
}
|
|
224
308
|
|
|
225
|
-
# -------------------------------------------------------------------
|
|
226
|
-
|
|
309
|
+
# -------------------------------------------------------------------
|
|
310
|
+
# customer
|
|
311
|
+
def _create_customer(
|
|
312
|
+
self, spec: Any, *, idempotency_key: str
|
|
313
|
+
) -> Mapping[str, Any]:
|
|
314
|
+
result = self._bt().customer.create(
|
|
315
|
+
{
|
|
316
|
+
"id": idempotency_key,
|
|
317
|
+
"email": spec.resolve("email"),
|
|
318
|
+
"first_name": spec.resolve("first_name"),
|
|
319
|
+
"last_name": spec.resolve("last_name"),
|
|
320
|
+
}
|
|
321
|
+
)
|
|
322
|
+
raw = self._result_payload(result)
|
|
227
323
|
return {
|
|
228
|
-
"id": f"bt_customer_{uuid4().hex[:8]}",
|
|
324
|
+
"id": raw.get("id", f"bt_customer_{uuid4().hex[:8]}"),
|
|
229
325
|
"provider": self.component_name,
|
|
230
|
-
"raw":
|
|
231
|
-
"create_customer",
|
|
232
|
-
idempotency_key=idempotency_key,
|
|
233
|
-
spec=self._dump(spec),
|
|
234
|
-
),
|
|
326
|
+
"raw": raw,
|
|
235
327
|
}
|
|
236
328
|
|
|
237
329
|
def _get_customer(self, customer_id: str) -> Mapping[str, Any]:
|
|
330
|
+
customer = self._bt().customer.find(customer_id)
|
|
331
|
+
raw = dict(customer.__dict__) if hasattr(customer, "__dict__") else {}
|
|
238
332
|
return {
|
|
239
333
|
"id": customer_id,
|
|
240
334
|
"provider": self.component_name,
|
|
241
|
-
"raw":
|
|
335
|
+
"raw": raw,
|
|
242
336
|
}
|
|
243
337
|
|
|
244
338
|
def _attach_payment_method_to_customer(
|
|
@@ -250,22 +344,31 @@ class BraintreeBillingProvider(
|
|
|
250
344
|
payment_method_id=getattr(pm, "id", ""),
|
|
251
345
|
)
|
|
252
346
|
|
|
253
|
-
# --------------------------------------------------------------- payment
|
|
347
|
+
# --------------------------------------------------------------- payment
|
|
348
|
+
# info
|
|
254
349
|
def _create_payment_method(
|
|
255
350
|
self, spec: Any, *, idempotency_key: str
|
|
256
351
|
) -> Mapping[str, Any]:
|
|
352
|
+
result = self._bt().payment_method.create(
|
|
353
|
+
{
|
|
354
|
+
"customer_id": spec.resolve("customer_id"),
|
|
355
|
+
"payment_method_nonce": spec.resolve("payment_method_nonce")
|
|
356
|
+
or spec.resolve("nonce"),
|
|
357
|
+
"token": idempotency_key,
|
|
358
|
+
}
|
|
359
|
+
)
|
|
360
|
+
raw = self._result_payload(result)
|
|
257
361
|
return {
|
|
258
|
-
"id": f"bt_pm_{uuid4().hex[:8]}",
|
|
362
|
+
"id": raw.get("token", f"bt_pm_{uuid4().hex[:8]}"),
|
|
259
363
|
"provider": self.component_name,
|
|
260
|
-
"raw":
|
|
261
|
-
"create_payment_method",
|
|
262
|
-
idempotency_key=idempotency_key,
|
|
263
|
-
spec=self._dump(spec),
|
|
264
|
-
),
|
|
364
|
+
"raw": raw,
|
|
265
365
|
}
|
|
266
366
|
|
|
267
|
-
def _detach_payment_method(
|
|
268
|
-
|
|
367
|
+
def _detach_payment_method(
|
|
368
|
+
self, payment_method_id: str
|
|
369
|
+
) -> Mapping[str, Any]:
|
|
370
|
+
self._bt().payment_method.delete(payment_method_id)
|
|
371
|
+
return {"id": payment_method_id, "provider": self.component_name}
|
|
269
372
|
|
|
270
373
|
def _list_payment_methods(
|
|
271
374
|
self,
|
|
@@ -292,8 +395,11 @@ class BraintreeBillingProvider(
|
|
|
292
395
|
)
|
|
293
396
|
return methods
|
|
294
397
|
|
|
295
|
-
# ---------------------------------------------------------------------
|
|
296
|
-
|
|
398
|
+
# ---------------------------------------------------------------------
|
|
399
|
+
# reports
|
|
400
|
+
def _create_report(
|
|
401
|
+
self, req: Any, *, idempotency_key: str
|
|
402
|
+
) -> Mapping[str, Any]:
|
|
297
403
|
return {
|
|
298
404
|
"report_id": f"bt_report_{uuid4().hex[:8]}",
|
|
299
405
|
"status": "QUEUED",
|
|
@@ -305,40 +411,49 @@ class BraintreeBillingProvider(
|
|
|
305
411
|
),
|
|
306
412
|
}
|
|
307
413
|
|
|
308
|
-
# ------------------------------------------------------------------------
|
|
414
|
+
# ------------------------------------------------------------------------
|
|
415
|
+
# risk
|
|
309
416
|
def _verify_webhook_signature(
|
|
310
417
|
self, raw_body: bytes, headers: Mapping[str, str], secret: str
|
|
311
418
|
) -> bool:
|
|
312
419
|
signature = headers.get("BT-Signature", "")
|
|
313
|
-
|
|
420
|
+
payload = headers.get("BT-Payload") or raw_body.decode("utf-8")
|
|
421
|
+
try:
|
|
422
|
+
self._bt().webhook_notification.parse(signature, payload)
|
|
423
|
+
return True
|
|
424
|
+
except Exception:
|
|
425
|
+
return False
|
|
314
426
|
|
|
315
|
-
def _list_disputes(
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
}
|
|
427
|
+
def _list_disputes(
|
|
428
|
+
self, *, limit: int = 50
|
|
429
|
+
) -> Sequence[Mapping[str, Any]]:
|
|
430
|
+
# Braintree's Python SDK exposes disputes through a search iterator.
|
|
431
|
+
rows = []
|
|
432
|
+
for index, dispute in enumerate(self._bt().dispute.search()):
|
|
433
|
+
if index >= limit:
|
|
434
|
+
break
|
|
435
|
+
rows.append(
|
|
436
|
+
dict(dispute.__dict__) if hasattr(dispute, "__dict__") else {}
|
|
325
437
|
)
|
|
326
|
-
return
|
|
438
|
+
return rows
|
|
327
439
|
|
|
328
|
-
# ---------------------------------------------------------------------
|
|
440
|
+
# ---------------------------------------------------------------------
|
|
441
|
+
# webhooks
|
|
329
442
|
def _parse_event(
|
|
330
443
|
self, raw_body: bytes, headers: Mapping[str, str]
|
|
331
444
|
) -> Mapping[str, Any]:
|
|
332
|
-
|
|
445
|
+
signature = headers.get("BT-Signature", "")
|
|
446
|
+
payload = headers.get("BT-Payload") or raw_body.decode("utf-8")
|
|
447
|
+
notification = self._bt().webhook_notification.parse(
|
|
448
|
+
signature, payload
|
|
449
|
+
)
|
|
333
450
|
return {
|
|
334
|
-
"event_id":
|
|
335
|
-
|
|
336
|
-
"provider": self.component_name,
|
|
337
|
-
"raw": self._stub(
|
|
338
|
-
"parse_event",
|
|
339
|
-
headers=dict(headers),
|
|
340
|
-
raw_body=raw_body.decode("utf-8", errors="ignore"),
|
|
451
|
+
"event_id": getattr(
|
|
452
|
+
notification, "timestamp", f"bt_evt_{uuid4().hex[:8]}"
|
|
341
453
|
),
|
|
454
|
+
"type": getattr(notification, "kind", "braintree.event"),
|
|
455
|
+
"provider": self.component_name,
|
|
456
|
+
"raw": dict(notification.__dict__),
|
|
342
457
|
}
|
|
343
458
|
|
|
344
459
|
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: swarmauri_billing_braintree
|
|
3
|
-
Version: 0.1.3.dev3
|
|
4
|
-
Summary: Braintree billing provider for the Swarmauri SDK.
|
|
5
|
-
License-Expression: Apache-2.0
|
|
6
|
-
License-File: LICENSE
|
|
7
|
-
Keywords: swarmauri,sdk,billing,braintree,standards,payments,fraud,subscription management,merchant services,e-commerce integration
|
|
8
|
-
Author: Jacob Stewart
|
|
9
|
-
Author-email: jacob@swarmauri.com
|
|
10
|
-
Requires-Python: >=3.10,<3.15
|
|
11
|
-
Classifier: Development Status :: 1 - Planning
|
|
12
|
-
Classifier: Intended Audience :: Developers
|
|
13
|
-
Classifier: Intended Audience :: Information Technology
|
|
14
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
|
-
Classifier: Operating System :: OS Independent
|
|
16
|
-
Classifier: Topic :: Office/Business :: Financial :: Point-Of-Sale
|
|
17
|
-
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
18
|
-
Classifier: Programming Language :: Python
|
|
19
|
-
Classifier: Programming Language :: Python :: 3
|
|
20
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
|
21
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
25
|
-
Classifier: Programming Language :: Python :: 3.14
|
|
26
|
-
Requires-Dist: swarmauri_base
|
|
27
|
-
Requires-Dist: swarmauri_core
|
|
28
|
-
Description-Content-Type: text/markdown
|
|
29
|
-
|
|
30
|
-

|
|
31
|
-
|
|
32
|
-
<p align="center">
|
|
33
|
-
<a href="https://pepy.tech/project/swarmauri_billing_braintree/">
|
|
34
|
-
<img src="https://static.pepy.tech/badge/swarmauri_billing_braintree/month" alt="PyPI - Downloads"/></a>
|
|
35
|
-
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_billing_braintree/">
|
|
36
|
-
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_billing_braintree.svg"/></a>
|
|
37
|
-
<a href="https://pypi.org/project/swarmauri_billing_braintree/">
|
|
38
|
-
<img src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue" alt="PyPI - Python Version"/></a>
|
|
39
|
-
<a href="https://pypi.org/project/swarmauri_billing_braintree/">
|
|
40
|
-
<img src="https://img.shields.io/pypi/l/swarmauri_billing_braintree" alt="PyPI - License"/></a>
|
|
41
|
-
<a href="https://pypi.org/project/swarmauri_billing_braintree/">
|
|
42
|
-
<img src="https://img.shields.io/pypi/v/swarmauri_billing_braintree?label=swarmauri_billing_braintree&color=green" alt="PyPI - swarmauri_billing_braintree"/></a>
|
|
43
|
-
</p>
|
|
44
|
-
|
|
45
|
-
# Swarmauri Billing Braintree
|
|
46
|
-
|
|
47
|
-
**Swarmauri Billing Braintree** offers a Braintree-flavoured provider that implements the Swarmauri billing interfaces. Use the package to exercise subscription renewals, vaulting, drop-in checkouts, and settlement reporting without wiring up the live Braintree SDK on day one.
|
|
48
|
-
|
|
49
|
-
## Features
|
|
50
|
-
|
|
51
|
-
- ✅ Models Braintree primitives such as customer vault, payment methods, subscriptions, and disbursements.
|
|
52
|
-
- ✅ Returns predictable payloads so downstream Swarmauri workflows can be validated in isolation.
|
|
53
|
-
- ✅ Highlights Braintree's fraud tools and reporting by exposing capability flags.
|
|
54
|
-
- ✅ Stays self-contained: swap the stubbed responses for real API calls when ready.
|
|
55
|
-
|
|
56
|
-
## Installation
|
|
57
|
-
|
|
58
|
-
Install from PyPI using either `pip` or `uv`:
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
pip install swarmauri_billing_braintree
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
uv add swarmauri_billing_braintree
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Usage
|
|
69
|
-
|
|
70
|
-
```python
|
|
71
|
-
from swarmauri_billing_braintree import BraintreeBillingProvider
|
|
72
|
-
from swarmauri_base.billing import PaymentIntentRequest
|
|
73
|
-
|
|
74
|
-
provider = BraintreeBillingProvider(api_key="sandbox-key")
|
|
75
|
-
|
|
76
|
-
payment_intent = provider.create_payment_intent(
|
|
77
|
-
PaymentIntentRequest(payload={"amount_minor": 1500, "currency": "USD", "confirm": True}),
|
|
78
|
-
)
|
|
79
|
-
result = provider.capture_payment(payment_intent.id)
|
|
80
|
-
|
|
81
|
-
print(payment_intent.status, result.status)
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
## Capability Mapping
|
|
85
|
-
|
|
86
|
-
The provider advertises Swarmauri `Capability` values which map to `tigrbl_billing` through `capabilities_to_tigrbl`. You can assert on those capabilities to feature-gate behaviour before hitting the Braintree API for real.
|
|
87
|
-
|
|
88
|
-
## Contributing
|
|
89
|
-
|
|
90
|
-
Contributions that wire the stubbed operations to official Braintree REST or GraphQL calls are welcome. Please update the README usage section and add tests when expanding the integration.
|
|
91
|
-
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-

|
|
2
|
-
|
|
3
|
-
<p align="center">
|
|
4
|
-
<a href="https://pepy.tech/project/swarmauri_billing_braintree/">
|
|
5
|
-
<img src="https://static.pepy.tech/badge/swarmauri_billing_braintree/month" alt="PyPI - Downloads"/></a>
|
|
6
|
-
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_billing_braintree/">
|
|
7
|
-
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_billing_braintree.svg"/></a>
|
|
8
|
-
<a href="https://pypi.org/project/swarmauri_billing_braintree/">
|
|
9
|
-
<img src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue" alt="PyPI - Python Version"/></a>
|
|
10
|
-
<a href="https://pypi.org/project/swarmauri_billing_braintree/">
|
|
11
|
-
<img src="https://img.shields.io/pypi/l/swarmauri_billing_braintree" alt="PyPI - License"/></a>
|
|
12
|
-
<a href="https://pypi.org/project/swarmauri_billing_braintree/">
|
|
13
|
-
<img src="https://img.shields.io/pypi/v/swarmauri_billing_braintree?label=swarmauri_billing_braintree&color=green" alt="PyPI - swarmauri_billing_braintree"/></a>
|
|
14
|
-
</p>
|
|
15
|
-
|
|
16
|
-
# Swarmauri Billing Braintree
|
|
17
|
-
|
|
18
|
-
**Swarmauri Billing Braintree** offers a Braintree-flavoured provider that implements the Swarmauri billing interfaces. Use the package to exercise subscription renewals, vaulting, drop-in checkouts, and settlement reporting without wiring up the live Braintree SDK on day one.
|
|
19
|
-
|
|
20
|
-
## Features
|
|
21
|
-
|
|
22
|
-
- ✅ Models Braintree primitives such as customer vault, payment methods, subscriptions, and disbursements.
|
|
23
|
-
- ✅ Returns predictable payloads so downstream Swarmauri workflows can be validated in isolation.
|
|
24
|
-
- ✅ Highlights Braintree's fraud tools and reporting by exposing capability flags.
|
|
25
|
-
- ✅ Stays self-contained: swap the stubbed responses for real API calls when ready.
|
|
26
|
-
|
|
27
|
-
## Installation
|
|
28
|
-
|
|
29
|
-
Install from PyPI using either `pip` or `uv`:
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
pip install swarmauri_billing_braintree
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
uv add swarmauri_billing_braintree
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Usage
|
|
40
|
-
|
|
41
|
-
```python
|
|
42
|
-
from swarmauri_billing_braintree import BraintreeBillingProvider
|
|
43
|
-
from swarmauri_base.billing import PaymentIntentRequest
|
|
44
|
-
|
|
45
|
-
provider = BraintreeBillingProvider(api_key="sandbox-key")
|
|
46
|
-
|
|
47
|
-
payment_intent = provider.create_payment_intent(
|
|
48
|
-
PaymentIntentRequest(payload={"amount_minor": 1500, "currency": "USD", "confirm": True}),
|
|
49
|
-
)
|
|
50
|
-
result = provider.capture_payment(payment_intent.id)
|
|
51
|
-
|
|
52
|
-
print(payment_intent.status, result.status)
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Capability Mapping
|
|
56
|
-
|
|
57
|
-
The provider advertises Swarmauri `Capability` values which map to `tigrbl_billing` through `capabilities_to_tigrbl`. You can assert on those capabilities to feature-gate behaviour before hitting the Braintree API for real.
|
|
58
|
-
|
|
59
|
-
## Contributing
|
|
60
|
-
|
|
61
|
-
Contributions that wire the stubbed operations to official Braintree REST or GraphQL calls are welcome. Please update the README usage section and add tests when expanding the integration.
|
|
File without changes
|