karni-commerce 0.6.0__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.
- karni_commerce-0.6.0/.gitignore +44 -0
- karni_commerce-0.6.0/LICENSE +201 -0
- karni_commerce-0.6.0/PKG-INFO +132 -0
- karni_commerce-0.6.0/README.md +101 -0
- karni_commerce-0.6.0/karni_commerce/AGENTS.fragment.md +39 -0
- karni_commerce-0.6.0/karni_commerce/__init__.py +25 -0
- karni_commerce-0.6.0/karni_commerce/api.py +930 -0
- karni_commerce-0.6.0/karni_commerce/apps.py +43 -0
- karni_commerce-0.6.0/karni_commerce/checks.py +26 -0
- karni_commerce-0.6.0/karni_commerce/conf.py +89 -0
- karni_commerce-0.6.0/karni_commerce/dashboard.py +151 -0
- karni_commerce-0.6.0/karni_commerce/documents.py +97 -0
- karni_commerce-0.6.0/karni_commerce/errorcodes.py +66 -0
- karni_commerce-0.6.0/karni_commerce/events.py +212 -0
- karni_commerce-0.6.0/karni_commerce/fulfilment.py +72 -0
- karni_commerce-0.6.0/karni_commerce/karni.module.toml +97 -0
- karni_commerce-0.6.0/karni_commerce/listeners.py +169 -0
- karni_commerce-0.6.0/karni_commerce/mail.py +25 -0
- karni_commerce-0.6.0/karni_commerce/messages.py +306 -0
- karni_commerce-0.6.0/karni_commerce/migrations/0001_initial.py +215 -0
- karni_commerce-0.6.0/karni_commerce/migrations/0002_order_notes.py +93 -0
- karni_commerce-0.6.0/karni_commerce/migrations/0003_coupons_shipping_tax.py +298 -0
- karni_commerce-0.6.0/karni_commerce/migrations/0004_invoices_settings_email_templates.py +82 -0
- karni_commerce-0.6.0/karni_commerce/migrations/0005_drop_setting.py +16 -0
- karni_commerce-0.6.0/karni_commerce/migrations/0006_order_person.py +80 -0
- karni_commerce-0.6.0/karni_commerce/migrations/0007_order_deposit.py +28 -0
- karni_commerce-0.6.0/karni_commerce/migrations/0008_email_templates_to_notify.py +36 -0
- karni_commerce-0.6.0/karni_commerce/migrations/__init__.py +0 -0
- karni_commerce-0.6.0/karni_commerce/models.py +743 -0
- karni_commerce-0.6.0/karni_commerce/payments.py +50 -0
- karni_commerce-0.6.0/karni_commerce/people.py +237 -0
- karni_commerce-0.6.0/karni_commerce/preferences.py +38 -0
- karni_commerce-0.6.0/karni_commerce/pricing.py +457 -0
- karni_commerce-0.6.0/karni_commerce/reports.py +410 -0
- karni_commerce-0.6.0/karni_commerce/sellables.py +392 -0
- karni_commerce-0.6.0/karni_commerce/services.py +1331 -0
- karni_commerce-0.6.0/karni_commerce/tasks.py +26 -0
- karni_commerce-0.6.0/karni_commerce/templates/karni_commerce/documents/_address.html +1 -0
- karni_commerce-0.6.0/karni_commerce/templates/karni_commerce/documents/_style.html +23 -0
- karni_commerce-0.6.0/karni_commerce/templates/karni_commerce/documents/invoice.html +60 -0
- karni_commerce-0.6.0/karni_commerce/templates/karni_commerce/documents/packing_slip.html +43 -0
- karni_commerce-0.6.0/karni_commerce/templates/karni_commerce/email/balance_due_body.txt +13 -0
- karni_commerce-0.6.0/karni_commerce/templates/karni_commerce/email/balance_due_subject.txt +1 -0
- karni_commerce-0.6.0/karni_commerce/templates/karni_commerce/email/new_order_body.txt +14 -0
- karni_commerce-0.6.0/karni_commerce/templates/karni_commerce/email/new_order_subject.txt +1 -0
- karni_commerce-0.6.0/karni_commerce/templates/karni_commerce/email/order_cancelled_body.txt +7 -0
- karni_commerce-0.6.0/karni_commerce/templates/karni_commerce/email/order_cancelled_subject.txt +1 -0
- karni_commerce-0.6.0/karni_commerce/templates/karni_commerce/email/order_note_body.txt +9 -0
- karni_commerce-0.6.0/karni_commerce/templates/karni_commerce/email/order_note_subject.txt +1 -0
- karni_commerce-0.6.0/karni_commerce/templates/karni_commerce/email/order_paid_body.html +11 -0
- karni_commerce-0.6.0/karni_commerce/templates/karni_commerce/email/order_paid_body.txt +14 -0
- karni_commerce-0.6.0/karni_commerce/templates/karni_commerce/email/order_paid_subject.txt +1 -0
- karni_commerce-0.6.0/karni_commerce/templates/karni_commerce/email/order_refunded_body.txt +7 -0
- karni_commerce-0.6.0/karni_commerce/templates/karni_commerce/email/order_refunded_subject.txt +1 -0
- karni_commerce-0.6.0/karni_commerce/templates/karni_commerce/email/payment_request_body.txt +16 -0
- karni_commerce-0.6.0/karni_commerce/templates/karni_commerce/email/payment_request_subject.txt +1 -0
- karni_commerce-0.6.0/karni_commerce/testing.py +323 -0
- karni_commerce-0.6.0/karni_commerce/viewsets.py +854 -0
- karni_commerce-0.6.0/pyproject.toml +91 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
.learning/
|
|
2
|
+
|
|
3
|
+
# Python
|
|
4
|
+
__pycache__/
|
|
5
|
+
*.py[cod]
|
|
6
|
+
*.egg-info/
|
|
7
|
+
.venv/
|
|
8
|
+
venv/
|
|
9
|
+
.pytest_cache/
|
|
10
|
+
.mypy_cache/
|
|
11
|
+
.ruff_cache/
|
|
12
|
+
.coverage
|
|
13
|
+
htmlcov/
|
|
14
|
+
|
|
15
|
+
# Build artifacts
|
|
16
|
+
dist/
|
|
17
|
+
build/
|
|
18
|
+
packages/karni-cli/karni_cli/_templates/
|
|
19
|
+
packages/karni-cli/karni_cli/_agent/
|
|
20
|
+
packages/karni-cli/karni_cli/_changelog/
|
|
21
|
+
packages/karni-cli/karni_cli/_errorcodes/
|
|
22
|
+
packages/karni-cli/karni_cli/_settings/
|
|
23
|
+
packages/karni-cli/karni_cli/_catalog/
|
|
24
|
+
packages/karni-cli/karni_cli/_ui/
|
|
25
|
+
|
|
26
|
+
# Node
|
|
27
|
+
node_modules/
|
|
28
|
+
storybook-static/
|
|
29
|
+
*.tsbuildinfo
|
|
30
|
+
|
|
31
|
+
# Local env / editor / tooling
|
|
32
|
+
.env
|
|
33
|
+
.env.*
|
|
34
|
+
!.env.example
|
|
35
|
+
.DS_Store
|
|
36
|
+
.idea/
|
|
37
|
+
|
|
38
|
+
# MkDocs build output
|
|
39
|
+
site/
|
|
40
|
+
.github/ci/prod_e2e/test-results/
|
|
41
|
+
|
|
42
|
+
# Contributors' own agent working files stay on their machines
|
|
43
|
+
/CLAUDE.md
|
|
44
|
+
/.claude/
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Chandrabhan Shekhawat, Gigai Kripa Services (https://gigaikripaservices.com)
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: karni-commerce
|
|
3
|
+
Version: 0.6.0
|
|
4
|
+
Summary: Commerce for Karni: one cart, checkout, orders, order numbers, payment settlement and refunds for anything a project sells, through a sellable adapter per kind. Karni is an open-source Django + React framework for building with AI coding agents. Your agent writes only your domain. The API, admin, permissions and React screens come from a package you upgrade, not code it rewrites in each project. One rule set covers every coding agent. The build fails when an agent hand-writes what Karni ships.
|
|
5
|
+
Project-URL: Homepage, https://github.com/cbsshekhawat18-lab/karni
|
|
6
|
+
Project-URL: Documentation, https://cbsshekhawat18-lab.github.io/karni/
|
|
7
|
+
Project-URL: Repository, https://github.com/cbsshekhawat18-lab/karni
|
|
8
|
+
Project-URL: Issues, https://github.com/cbsshekhawat18-lab/karni/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/cbsshekhawat18-lab/karni/tree/main/docs/migrations
|
|
10
|
+
Author-email: Chandrabhan Shekhawat <cbsshekhawat18@gmail.com>
|
|
11
|
+
License-Expression: Apache-2.0
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: cart,checkout,commerce,django,ecommerce,karni,orders,react
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Environment :: Web Environment
|
|
16
|
+
Classifier: Framework :: Django
|
|
17
|
+
Classifier: Framework :: Django :: 5.2
|
|
18
|
+
Classifier: Intended Audience :: Developers
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Classifier: Programming Language :: Python :: 3
|
|
21
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
25
|
+
Classifier: Topic :: Office/Business :: Financial
|
|
26
|
+
Classifier: Typing :: Typed
|
|
27
|
+
Requires-Python: >=3.12
|
|
28
|
+
Requires-Dist: karni-payments<0.7,>=0.6
|
|
29
|
+
Requires-Dist: karni<0.7,>=0.6
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# karni-commerce
|
|
33
|
+
|
|
34
|
+
One cart, checkout and order path for anything a Karni project sells. Experimental.
|
|
35
|
+
|
|
36
|
+
[](https://pypi.org/project/karni-commerce/) [](https://github.com/cbsshekhawat18-lab/karni/blob/main/LICENSE) [](https://cbsshekhawat18-lab.github.io/karni/commerce/)
|
|
37
|
+
|
|
38
|
+
A project's apps sell different things: a product, a booking, a course seat.
|
|
39
|
+
They share one path. A cart line names a *kind* and an item. Checkout turns
|
|
40
|
+
the cart into an order with its lines copied and every line held.
|
|
41
|
+
[karni-payments](https://pypi.org/project/karni-payments/) takes the money, and the
|
|
42
|
+
settlement and refunds move the order. Each kind is an adapter the selling
|
|
43
|
+
app registers in its own `sellables.py`. Commerce calls the adapter and
|
|
44
|
+
never imports the app.
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pip install karni-commerce
|
|
48
|
+
karni add payments
|
|
49
|
+
karni add commerce
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Or in karni.yaml:
|
|
53
|
+
|
|
54
|
+
```yaml
|
|
55
|
+
modules:
|
|
56
|
+
payments:
|
|
57
|
+
provider: stripe
|
|
58
|
+
currency: eur
|
|
59
|
+
checkout_validator: karni_commerce.payments.checkout_validator
|
|
60
|
+
commerce: {}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## What it gives
|
|
64
|
+
|
|
65
|
+
- `Cart` and `CartLine`: a signed-in person's cart, or a visitor's, found by
|
|
66
|
+
a token and merged at sign-in.
|
|
67
|
+
- `Order`, `OrderLine`, `OrderPayment` and `OrderRefund`: an order with a
|
|
68
|
+
readable number, the buyer's person (karni.people), user (or none), email
|
|
69
|
+
and name, the addresses, lines with the name, SKU and price copied at
|
|
70
|
+
checkout, several payments (a deposit and its balance, a retry) and refunds
|
|
71
|
+
by line or by amount.
|
|
72
|
+
- `karni_commerce.services`: `set_line`, `merge`, `checkout`, `place_order`,
|
|
73
|
+
`open_payment`, `settle`, `cancel`, `refund`, `settle_refund` and
|
|
74
|
+
`release_expired`, each in one transaction.
|
|
75
|
+
- The API: `/api/carts/current/` (and `lines/`, `merge/`, `checkout/`),
|
|
76
|
+
`/api/orders/` (and `lookup/`, `pay/`, `{id}/cancel/`, `{id}/refund/`),
|
|
77
|
+
`/api/order-lines/`, `/api/order-payments/`, `/api/order-refunds/`.
|
|
78
|
+
- Signals in `karni_commerce.events`: `order_placed`, `order_paid`,
|
|
79
|
+
`order_part_paid`, `order_failed`, `order_cancelled`, `order_refunded`,
|
|
80
|
+
`cart_merged` and `orders_claimed`, and the family events
|
|
81
|
+
`commerce.order.*` on the buyer's timeline.
|
|
82
|
+
- The person facts `orders`, `total_spent`, `last_order` and `first_order`,
|
|
83
|
+
and `karni_commerce.testing.assert_sellable` for a selling part's tests.
|
|
84
|
+
- Emails through `karni.mail`, each with a kind: `commerce.order_paid`,
|
|
85
|
+
`commerce.new_order`, `commerce.order_cancelled`, `commerce.order_refunded`,
|
|
86
|
+
`commerce.order_note`, `commerce.payment_request` and `commerce.balance_due`.
|
|
87
|
+
With `karni.notify` installed each lands in the recipient's inbox too.
|
|
88
|
+
- [`@karni/commerce-ui`](https://www.npmjs.com/package/@karni/commerce-ui):
|
|
89
|
+
the cart page, the mini cart, checkout, an order's page and the person's
|
|
90
|
+
orders.
|
|
91
|
+
|
|
92
|
+
## Selling something
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
# shop/sellables.py
|
|
96
|
+
from karni.capacity import release, reserve
|
|
97
|
+
from karni_commerce.sellables import Price, Sellable, register
|
|
98
|
+
|
|
99
|
+
from shop.models import Product
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
@register
|
|
103
|
+
class ProductSellable(Sellable):
|
|
104
|
+
kind = "product"
|
|
105
|
+
model = Product
|
|
106
|
+
|
|
107
|
+
def price(self, item, options, buyer):
|
|
108
|
+
return Price(unit=item.current_price(), compare_at=item.price)
|
|
109
|
+
|
|
110
|
+
def needs_shipping(self, item, options):
|
|
111
|
+
return True
|
|
112
|
+
|
|
113
|
+
def available(self, item, options):
|
|
114
|
+
return item.available
|
|
115
|
+
|
|
116
|
+
def hold(self, line):
|
|
117
|
+
reserve(Product.objects.get(pk=line.item), line.quantity)
|
|
118
|
+
|
|
119
|
+
def release(self, line):
|
|
120
|
+
release(Product.objects.get(pk=line.item), line.quantity)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
An order's `status` holds the money only: `pending`, `paid`, `part_paid`,
|
|
124
|
+
`failed`, `cancelled`, `refunded` and `part_refunded`. What happens to the
|
|
125
|
+
goods (shipped, delivered, a seat confirmed) stays in the selling app's own
|
|
126
|
+
records, which point at `karni_commerce.Order`.
|
|
127
|
+
|
|
128
|
+
The full guide is [docs/commerce.md](https://cbsshekhawat18-lab.github.io/karni/commerce/).
|
|
129
|
+
|
|
130
|
+
## License
|
|
131
|
+
|
|
132
|
+
Apache-2.0.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# karni-commerce
|
|
2
|
+
|
|
3
|
+
One cart, checkout and order path for anything a Karni project sells. Experimental.
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/karni-commerce/) [](https://github.com/cbsshekhawat18-lab/karni/blob/main/LICENSE) [](https://cbsshekhawat18-lab.github.io/karni/commerce/)
|
|
6
|
+
|
|
7
|
+
A project's apps sell different things: a product, a booking, a course seat.
|
|
8
|
+
They share one path. A cart line names a *kind* and an item. Checkout turns
|
|
9
|
+
the cart into an order with its lines copied and every line held.
|
|
10
|
+
[karni-payments](https://pypi.org/project/karni-payments/) takes the money, and the
|
|
11
|
+
settlement and refunds move the order. Each kind is an adapter the selling
|
|
12
|
+
app registers in its own `sellables.py`. Commerce calls the adapter and
|
|
13
|
+
never imports the app.
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install karni-commerce
|
|
17
|
+
karni add payments
|
|
18
|
+
karni add commerce
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Or in karni.yaml:
|
|
22
|
+
|
|
23
|
+
```yaml
|
|
24
|
+
modules:
|
|
25
|
+
payments:
|
|
26
|
+
provider: stripe
|
|
27
|
+
currency: eur
|
|
28
|
+
checkout_validator: karni_commerce.payments.checkout_validator
|
|
29
|
+
commerce: {}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## What it gives
|
|
33
|
+
|
|
34
|
+
- `Cart` and `CartLine`: a signed-in person's cart, or a visitor's, found by
|
|
35
|
+
a token and merged at sign-in.
|
|
36
|
+
- `Order`, `OrderLine`, `OrderPayment` and `OrderRefund`: an order with a
|
|
37
|
+
readable number, the buyer's person (karni.people), user (or none), email
|
|
38
|
+
and name, the addresses, lines with the name, SKU and price copied at
|
|
39
|
+
checkout, several payments (a deposit and its balance, a retry) and refunds
|
|
40
|
+
by line or by amount.
|
|
41
|
+
- `karni_commerce.services`: `set_line`, `merge`, `checkout`, `place_order`,
|
|
42
|
+
`open_payment`, `settle`, `cancel`, `refund`, `settle_refund` and
|
|
43
|
+
`release_expired`, each in one transaction.
|
|
44
|
+
- The API: `/api/carts/current/` (and `lines/`, `merge/`, `checkout/`),
|
|
45
|
+
`/api/orders/` (and `lookup/`, `pay/`, `{id}/cancel/`, `{id}/refund/`),
|
|
46
|
+
`/api/order-lines/`, `/api/order-payments/`, `/api/order-refunds/`.
|
|
47
|
+
- Signals in `karni_commerce.events`: `order_placed`, `order_paid`,
|
|
48
|
+
`order_part_paid`, `order_failed`, `order_cancelled`, `order_refunded`,
|
|
49
|
+
`cart_merged` and `orders_claimed`, and the family events
|
|
50
|
+
`commerce.order.*` on the buyer's timeline.
|
|
51
|
+
- The person facts `orders`, `total_spent`, `last_order` and `first_order`,
|
|
52
|
+
and `karni_commerce.testing.assert_sellable` for a selling part's tests.
|
|
53
|
+
- Emails through `karni.mail`, each with a kind: `commerce.order_paid`,
|
|
54
|
+
`commerce.new_order`, `commerce.order_cancelled`, `commerce.order_refunded`,
|
|
55
|
+
`commerce.order_note`, `commerce.payment_request` and `commerce.balance_due`.
|
|
56
|
+
With `karni.notify` installed each lands in the recipient's inbox too.
|
|
57
|
+
- [`@karni/commerce-ui`](https://www.npmjs.com/package/@karni/commerce-ui):
|
|
58
|
+
the cart page, the mini cart, checkout, an order's page and the person's
|
|
59
|
+
orders.
|
|
60
|
+
|
|
61
|
+
## Selling something
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
# shop/sellables.py
|
|
65
|
+
from karni.capacity import release, reserve
|
|
66
|
+
from karni_commerce.sellables import Price, Sellable, register
|
|
67
|
+
|
|
68
|
+
from shop.models import Product
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@register
|
|
72
|
+
class ProductSellable(Sellable):
|
|
73
|
+
kind = "product"
|
|
74
|
+
model = Product
|
|
75
|
+
|
|
76
|
+
def price(self, item, options, buyer):
|
|
77
|
+
return Price(unit=item.current_price(), compare_at=item.price)
|
|
78
|
+
|
|
79
|
+
def needs_shipping(self, item, options):
|
|
80
|
+
return True
|
|
81
|
+
|
|
82
|
+
def available(self, item, options):
|
|
83
|
+
return item.available
|
|
84
|
+
|
|
85
|
+
def hold(self, line):
|
|
86
|
+
reserve(Product.objects.get(pk=line.item), line.quantity)
|
|
87
|
+
|
|
88
|
+
def release(self, line):
|
|
89
|
+
release(Product.objects.get(pk=line.item), line.quantity)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
An order's `status` holds the money only: `pending`, `paid`, `part_paid`,
|
|
93
|
+
`failed`, `cancelled`, `refunded` and `part_refunded`. What happens to the
|
|
94
|
+
goods (shipped, delivered, a seat confirmed) stays in the selling app's own
|
|
95
|
+
records, which point at `karni_commerce.Order`.
|
|
96
|
+
|
|
97
|
+
The full guide is [docs/commerce.md](https://cbsshekhawat18-lab.github.io/karni/commerce/).
|
|
98
|
+
|
|
99
|
+
## License
|
|
100
|
+
|
|
101
|
+
Apache-2.0.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
## Commerce (karni-commerce)
|
|
2
|
+
- One cart, checkout and order path for every kind of thing the project sells.
|
|
3
|
+
Never write a cart, order, order line or order number model of your own.
|
|
4
|
+
- Make a model sellable with an adapter in `<app>/sellables.py`: subclass
|
|
5
|
+
`karni_commerce.sellables.Sellable`, set `kind` and `model`, implement
|
|
6
|
+
`price`, and the hooks your item needs (`validate`, `hold`, `release`,
|
|
7
|
+
`on_paid`, `on_cancelled`, `on_refunded`, `needs_shipping`), then
|
|
8
|
+
`@register` it. Hold stock with `karni.capacity.reserve`/`release`.
|
|
9
|
+
- Every order change goes through `karni_commerce.services` (`checkout`,
|
|
10
|
+
`place_order`, `open_payment`, `cancel`, `refund`). Prices and totals come
|
|
11
|
+
from the adapters, never from the client.
|
|
12
|
+
- An order's `status` is money only (pending, paid, part_paid, failed,
|
|
13
|
+
cancelled, refunded, part_refunded). Keep fulfilment (shipped, delivered,
|
|
14
|
+
confirmed) in your own model that points at `karni_commerce.Order`, and
|
|
15
|
+
report it with `karni_commerce.fulfilment.register_reporter`.
|
|
16
|
+
- React to orders with the signals in `karni_commerce.events` in your
|
|
17
|
+
`listeners.py`, or from another part with `@subscribe("commerce.order.paid",
|
|
18
|
+
version=1)` (the family events). Never import another app's code from yours.
|
|
19
|
+
- The buyer is `Order.person` (karni.people). Read what they bought through
|
|
20
|
+
the person facts (`orders`, `total_spent`, `last_order`), never by grouping
|
|
21
|
+
orders by email.
|
|
22
|
+
- A deposit is the adapter's (`allows_deposit`, `deposit`): the order is
|
|
23
|
+
`part_paid` and the balance is paid by its link. A short hold (a booking
|
|
24
|
+
slot) is `hold_minutes`. A free order is paid when placed: never skip
|
|
25
|
+
checkout for it.
|
|
26
|
+
- Test your adapter with `karni_commerce.testing.assert_sellable(kind, item)`.
|
|
27
|
+
- Set `KARNI_PAYMENTS_CHECKOUT_VALIDATOR =
|
|
28
|
+
"karni_commerce.payments.checkout_validator"` (karni.yaml:
|
|
29
|
+
`modules: {payments: {checkout_validator: ...}}`).
|
|
30
|
+
- Options (a size, a colour, a date) go in the line's `options`. The adapter
|
|
31
|
+
checks them (`clean_options`), tells lines apart (`option_key`) and says
|
|
32
|
+
them in words (`details`). Never add a variant column to commerce's tables.
|
|
33
|
+
- Coupons, shipping zones and methods and tax rates are commerce's
|
|
34
|
+
(`Coupon`, `ShippingZone`, `ShippingMethod`, `TaxRate`), priced by
|
|
35
|
+
`karni_commerce.pricing.quote`. Never compute a discount, shipping or tax
|
|
36
|
+
in your app: give `Price.tax_class` and `coupon_keys`, or replace
|
|
37
|
+
`KARNI_COMMERCE_SHIPPING` / `KARNI_COMMERCE_TAX`.
|
|
38
|
+
- UI: `@karni/commerce-ui` has the cart, mini cart, checkout and order pages,
|
|
39
|
+
and `CouponsPage`, `ShippingPage` and `TaxRatesPage` for staff.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""karni-commerce (experimental): one cart, checkout and order path for anything a project sells.
|
|
2
|
+
|
|
3
|
+
A project's apps sell different things (a product, a booking, a course, a
|
|
4
|
+
listing) through the same path: a cart line names a *kind* and an item,
|
|
5
|
+
checkout turns the cart into an :class:`~karni_commerce.models.Order` with
|
|
6
|
+
its lines copied, karni-payments takes the money, and the settlement and
|
|
7
|
+
refunds move the order. Each kind is a :class:`~karni_commerce.sellables.Sellable`
|
|
8
|
+
adapter the selling app registers in its ``<app>/sellables.py``: commerce
|
|
9
|
+
calls the adapter and never imports the app.
|
|
10
|
+
|
|
11
|
+
Project code talks to :mod:`karni_commerce.services`.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
from importlib import metadata as _metadata
|
|
17
|
+
|
|
18
|
+
#: The version of the commerce contract (the sellable adapter, the order path and the
|
|
19
|
+
#: signals of :mod:`karni_commerce.events`). Experimental until six recipes use it.
|
|
20
|
+
CONTRACT = 1
|
|
21
|
+
|
|
22
|
+
try:
|
|
23
|
+
__version__ = _metadata.version("karni-commerce") # [project] version in pyproject.toml
|
|
24
|
+
except _metadata.PackageNotFoundError: # a source tree on sys.path, never installed
|
|
25
|
+
__version__ = "0+unknown"
|