@djangocfg/ext-payments 1.0.0
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.
- package/README.md +206 -0
- package/dist/chunk-5KY6HVXF.js +2593 -0
- package/dist/hooks.cjs +2666 -0
- package/dist/hooks.d.cts +186 -0
- package/dist/hooks.d.ts +186 -0
- package/dist/hooks.js +1 -0
- package/dist/index.cjs +2590 -0
- package/dist/index.d.cts +1287 -0
- package/dist/index.d.ts +1287 -0
- package/dist/index.js +1 -0
- package/package.json +79 -0
- package/src/api/generated/ext_payments/_utils/fetchers/ext_payments__payments.ts +408 -0
- package/src/api/generated/ext_payments/_utils/fetchers/index.ts +28 -0
- package/src/api/generated/ext_payments/_utils/hooks/ext_payments__payments.ts +147 -0
- package/src/api/generated/ext_payments/_utils/hooks/index.ts +28 -0
- package/src/api/generated/ext_payments/_utils/schemas/Balance.schema.ts +23 -0
- package/src/api/generated/ext_payments/_utils/schemas/Currency.schema.ts +28 -0
- package/src/api/generated/ext_payments/_utils/schemas/PaginatedPaymentListList.schema.ts +24 -0
- package/src/api/generated/ext_payments/_utils/schemas/PaymentDetail.schema.ts +44 -0
- package/src/api/generated/ext_payments/_utils/schemas/PaymentList.schema.ts +28 -0
- package/src/api/generated/ext_payments/_utils/schemas/Transaction.schema.ts +28 -0
- package/src/api/generated/ext_payments/_utils/schemas/index.ts +24 -0
- package/src/api/generated/ext_payments/api-instance.ts +131 -0
- package/src/api/generated/ext_payments/client.ts +301 -0
- package/src/api/generated/ext_payments/enums.ts +64 -0
- package/src/api/generated/ext_payments/errors.ts +116 -0
- package/src/api/generated/ext_payments/ext_payments__payments/client.ts +118 -0
- package/src/api/generated/ext_payments/ext_payments__payments/index.ts +2 -0
- package/src/api/generated/ext_payments/ext_payments__payments/models.ts +135 -0
- package/src/api/generated/ext_payments/http.ts +103 -0
- package/src/api/generated/ext_payments/index.ts +273 -0
- package/src/api/generated/ext_payments/logger.ts +259 -0
- package/src/api/generated/ext_payments/retry.ts +175 -0
- package/src/api/generated/ext_payments/schema.json +850 -0
- package/src/api/generated/ext_payments/storage.ts +161 -0
- package/src/api/generated/ext_payments/validation-events.ts +133 -0
- package/src/api/index.ts +9 -0
- package/src/config.ts +20 -0
- package/src/contexts/BalancesContext.tsx +62 -0
- package/src/contexts/CurrenciesContext.tsx +63 -0
- package/src/contexts/OverviewContext.tsx +173 -0
- package/src/contexts/PaymentsContext.tsx +121 -0
- package/src/contexts/PaymentsExtensionProvider.tsx +55 -0
- package/src/contexts/README.md +201 -0
- package/src/contexts/RootPaymentsContext.tsx +65 -0
- package/src/contexts/index.ts +45 -0
- package/src/contexts/types.ts +40 -0
- package/src/hooks/index.ts +20 -0
- package/src/index.ts +36 -0
- package/src/layouts/PaymentsLayout/PaymentsLayout.tsx +92 -0
- package/src/layouts/PaymentsLayout/components/CreatePaymentDialog.tsx +291 -0
- package/src/layouts/PaymentsLayout/components/PaymentDetailsDialog.tsx +290 -0
- package/src/layouts/PaymentsLayout/components/index.ts +2 -0
- package/src/layouts/PaymentsLayout/events.ts +47 -0
- package/src/layouts/PaymentsLayout/index.ts +16 -0
- package/src/layouts/PaymentsLayout/types.ts +6 -0
- package/src/layouts/PaymentsLayout/views/overview/components/BalanceCard.tsx +128 -0
- package/src/layouts/PaymentsLayout/views/overview/components/RecentPayments.tsx +142 -0
- package/src/layouts/PaymentsLayout/views/overview/components/index.ts +2 -0
- package/src/layouts/PaymentsLayout/views/overview/index.tsx +20 -0
- package/src/layouts/PaymentsLayout/views/payments/components/PaymentsList.tsx +277 -0
- package/src/layouts/PaymentsLayout/views/payments/components/index.ts +1 -0
- package/src/layouts/PaymentsLayout/views/payments/index.tsx +17 -0
- package/src/layouts/PaymentsLayout/views/transactions/components/TransactionsList.tsx +273 -0
- package/src/layouts/PaymentsLayout/views/transactions/components/index.ts +1 -0
- package/src/layouts/PaymentsLayout/views/transactions/index.tsx +17 -0
- package/src/utils/logger.ts +9 -0
package/README.md
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# @djangocfg/ext-payments
|
|
2
|
+
|
|
3
|
+
Payment processing and subscription management extension for DjangoCFG.
|
|
4
|
+
|
|
5
|
+
**Part of [DjangoCFG](https://djangocfg.com)** — modern Django framework for production-ready SaaS applications.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- 💳 **Payment Processing** - Handle cryptocurrency and fiat payments
|
|
10
|
+
- 🔄 **Subscription Management** - Recurring billing and subscriptions
|
|
11
|
+
- 💰 **Multi-Currency Support** - Support for multiple cryptocurrencies
|
|
12
|
+
- 📊 **Balance Tracking** - Real-time balance and transaction history
|
|
13
|
+
- 🔔 **Webhook Integration** - Receive payment notifications
|
|
14
|
+
- 📈 **Analytics Dashboard** - Payment statistics and insights
|
|
15
|
+
- 🔒 **Secure Payments** - PCI-compliant payment handling
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pnpm add @djangocfg/ext-payments
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
### Provider Setup
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { PaymentsExtensionProvider } from '@djangocfg/ext-payments/hooks';
|
|
29
|
+
|
|
30
|
+
export default function RootLayout({ children }) {
|
|
31
|
+
return (
|
|
32
|
+
<PaymentsExtensionProvider>
|
|
33
|
+
{children}
|
|
34
|
+
</PaymentsExtensionProvider>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Create Payment
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { usePaymentsContext } from '@djangocfg/ext-payments/hooks';
|
|
43
|
+
|
|
44
|
+
function CheckoutPage() {
|
|
45
|
+
const { createPayment, isCreatingPayment } = usePaymentsContext();
|
|
46
|
+
|
|
47
|
+
const handleCheckout = async () => {
|
|
48
|
+
const payment = await createPayment({
|
|
49
|
+
amount: 99.99,
|
|
50
|
+
currency: 'USD',
|
|
51
|
+
description: 'Premium subscription',
|
|
52
|
+
success_url: '/success',
|
|
53
|
+
cancel_url: '/cancel',
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Redirect to payment URL
|
|
57
|
+
window.location.href = payment.payment_url;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<button onClick={handleCheckout} disabled={isCreatingPayment}>
|
|
62
|
+
{isCreatingPayment ? 'Processing...' : 'Pay $99.99'}
|
|
63
|
+
</button>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Balance Management
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import { useBalancesContext } from '@djangocfg/ext-payments/hooks';
|
|
72
|
+
|
|
73
|
+
function WalletPage() {
|
|
74
|
+
const { balances, isLoadingBalances, refreshBalances } = useBalancesContext();
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<div>
|
|
78
|
+
<h2>Your Balances</h2>
|
|
79
|
+
<button onClick={refreshBalances}>Refresh</button>
|
|
80
|
+
{balances?.map(balance => (
|
|
81
|
+
<div key={balance.currency}>
|
|
82
|
+
<strong>{balance.currency}:</strong> {balance.amount}
|
|
83
|
+
</div>
|
|
84
|
+
))}
|
|
85
|
+
</div>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Currency Management
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { useCurrenciesContext } from '@djangocfg/ext-payments/hooks';
|
|
94
|
+
|
|
95
|
+
function CurrencySelector() {
|
|
96
|
+
const { currencies, selectedCurrency, setCurrency } = useCurrenciesContext();
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<select
|
|
100
|
+
value={selectedCurrency?.code}
|
|
101
|
+
onChange={(e) => {
|
|
102
|
+
const currency = currencies.find(c => c.code === e.target.value);
|
|
103
|
+
if (currency) setCurrency(currency);
|
|
104
|
+
}}
|
|
105
|
+
>
|
|
106
|
+
{currencies.map(currency => (
|
|
107
|
+
<option key={currency.code} value={currency.code}>
|
|
108
|
+
{currency.name} ({currency.symbol})
|
|
109
|
+
</option>
|
|
110
|
+
))}
|
|
111
|
+
</select>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Payment History
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
import { usePaymentsContext } from '@djangocfg/ext-payments/hooks';
|
|
120
|
+
|
|
121
|
+
function TransactionsPage() {
|
|
122
|
+
const { payments, isLoadingPayments } = usePaymentsContext();
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<div>
|
|
126
|
+
<h2>Transaction History</h2>
|
|
127
|
+
{payments.map(payment => (
|
|
128
|
+
<div key={payment.id}>
|
|
129
|
+
<span>{payment.description}</span>
|
|
130
|
+
<span>{payment.amount} {payment.currency}</span>
|
|
131
|
+
<span>Status: {payment.status}</span>
|
|
132
|
+
<span>{new Date(payment.created_at).toLocaleDateString()}</span>
|
|
133
|
+
</div>
|
|
134
|
+
))}
|
|
135
|
+
</div>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Payment Overview
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
import { useOverviewContext } from '@djangocfg/ext-payments/hooks';
|
|
144
|
+
|
|
145
|
+
function DashboardPage() {
|
|
146
|
+
const { overview, isLoadingOverview } = useOverviewContext();
|
|
147
|
+
|
|
148
|
+
if (isLoadingOverview) return <div>Loading...</div>;
|
|
149
|
+
|
|
150
|
+
return (
|
|
151
|
+
<div>
|
|
152
|
+
<h2>Payment Overview</h2>
|
|
153
|
+
<div>
|
|
154
|
+
<p>Total Revenue: ${overview.total_revenue}</p>
|
|
155
|
+
<p>Pending Payments: {overview.pending_count}</p>
|
|
156
|
+
<p>Completed Payments: {overview.completed_count}</p>
|
|
157
|
+
<p>This Month: ${overview.current_month_revenue}</p>
|
|
158
|
+
</div>
|
|
159
|
+
</div>
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## API Reference
|
|
165
|
+
|
|
166
|
+
### Payments Context
|
|
167
|
+
|
|
168
|
+
- `payments` - List of all payments
|
|
169
|
+
- `createPayment(data)` - Create new payment
|
|
170
|
+
- `getPaymentById(id)` - Get payment details
|
|
171
|
+
- `cancelPayment(id)` - Cancel payment
|
|
172
|
+
- `isLoadingPayments` - Loading state
|
|
173
|
+
|
|
174
|
+
### Balances Context
|
|
175
|
+
|
|
176
|
+
- `balances` - User's cryptocurrency balances
|
|
177
|
+
- `refreshBalances()` - Refresh balance data
|
|
178
|
+
- `isLoadingBalances` - Loading state
|
|
179
|
+
|
|
180
|
+
### Currencies Context
|
|
181
|
+
|
|
182
|
+
- `currencies` - Available cryptocurrencies
|
|
183
|
+
- `selectedCurrency` - Currently selected currency
|
|
184
|
+
- `setCurrency(currency)` - Set active currency
|
|
185
|
+
- `getCurrencyByCode(code)` - Get currency details
|
|
186
|
+
|
|
187
|
+
### Overview Context
|
|
188
|
+
|
|
189
|
+
- `overview` - Payment statistics and analytics
|
|
190
|
+
- `refreshOverview()` - Refresh overview data
|
|
191
|
+
- `isLoadingOverview` - Loading state
|
|
192
|
+
|
|
193
|
+
### Root Payments Context
|
|
194
|
+
|
|
195
|
+
- `currencies` - Global currencies list
|
|
196
|
+
- `refreshCurrencies()` - Refresh currency data
|
|
197
|
+
- `isLoadingCurrencies` - Loading state
|
|
198
|
+
|
|
199
|
+
## License
|
|
200
|
+
|
|
201
|
+
MIT
|
|
202
|
+
|
|
203
|
+
## Links
|
|
204
|
+
|
|
205
|
+
- [DjangoCFG Documentation](https://djangocfg.com)
|
|
206
|
+
- [GitHub](https://github.com/markolofsen/django-cfg)
|