@djangocfg/ext-payments 1.0.19 → 1.0.21
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 +117 -145
- package/dist/api/hooks.cjs +1701 -0
- package/dist/api/hooks.d.cts +4 -0
- package/dist/api/hooks.d.ts +4 -0
- package/dist/api/hooks.js +1681 -0
- package/dist/api/index.cjs +1738 -0
- package/dist/api/index.d.cts +372 -0
- package/dist/api/index.d.ts +372 -0
- package/dist/api/index.js +1688 -0
- package/dist/api-hooks-DG8taGyN.d.cts +1172 -0
- package/dist/api-hooks-DG8taGyN.d.ts +1172 -0
- package/dist/api-hooks.cjs +1701 -0
- package/dist/api-hooks.d.cts +4 -0
- package/dist/api-hooks.d.ts +4 -0
- package/dist/api-hooks.js +1681 -0
- package/dist/config.cjs +11 -1
- package/dist/config.js +11 -1
- package/dist/hooks-DG8taGyN.d.cts +1172 -0
- package/dist/hooks-DG8taGyN.d.ts +1172 -0
- package/dist/index.cjs +15 -5
- package/dist/index.d.cts +23 -1407
- package/dist/index.d.ts +23 -1407
- package/dist/index.js +15 -5
- package/package.json +13 -3
- package/src/api/hooks.ts +16 -0
- package/src/api/index.ts +20 -1
package/README.md
CHANGED
|
@@ -2,25 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|
|
|
5
|
-
**[
|
|
5
|
+
**[View in Marketplace](https://hub.djangocfg.com/extensions/djangocfg-ext-payments)** • **[Documentation](https://djangocfg.com)** • **[GitHub](https://github.com/markolofsen/django-cfg)**
|
|
6
6
|
|
|
7
7
|
</div>
|
|
8
8
|
|
|
9
9
|
# @djangocfg/ext-payments
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Wallet-style payment system extension for DjangoCFG with Apple-inspired UX.
|
|
12
12
|
|
|
13
13
|
**Part of [DjangoCFG](https://djangocfg.com)** — modern Django framework for production-ready SaaS applications.
|
|
14
14
|
|
|
15
15
|
## Features
|
|
16
16
|
|
|
17
|
-
- 💳 **
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
- 🔒 **Secure Payments** - PCI-compliant payment handling
|
|
17
|
+
- 💳 **Wallet Page** - Apple-style single page with balance and activity
|
|
18
|
+
- 💰 **Multi-Currency** - Support for crypto (USDT, BTC, ETH) and fiat
|
|
19
|
+
- 📊 **Real-time Balance** - Live balance updates via WebSocket
|
|
20
|
+
- 🔄 **Withdrawals** - Request withdrawals with status tracking
|
|
21
|
+
- 📜 **Transaction History** - Full payment and withdrawal history
|
|
22
|
+
- 🎨 **Ready Components** - BalanceHero, ActivityList, PaymentSheet
|
|
24
23
|
|
|
25
24
|
## Install
|
|
26
25
|
|
|
@@ -28,181 +27,154 @@ Payment processing and subscription management extension for DjangoCFG.
|
|
|
28
27
|
pnpm add @djangocfg/ext-payments
|
|
29
28
|
```
|
|
30
29
|
|
|
31
|
-
##
|
|
30
|
+
## Exports
|
|
32
31
|
|
|
33
|
-
|
|
32
|
+
| Path | Description |
|
|
33
|
+
|------|-------------|
|
|
34
|
+
| `@djangocfg/ext-payments` | Main exports (WalletPage, components, types) |
|
|
35
|
+
| `@djangocfg/ext-payments/api` | API client, fetchers, schemas |
|
|
36
|
+
| `@djangocfg/ext-payments/api/hooks` | SWR hooks for API |
|
|
37
|
+
| `@djangocfg/ext-payments/config` | Extension config (server-safe) |
|
|
34
38
|
|
|
35
|
-
|
|
36
|
-
import { PaymentsExtensionProvider } from '@djangocfg/ext-payments/hooks';
|
|
39
|
+
## Quick Start
|
|
37
40
|
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<PaymentsExtensionProvider>
|
|
41
|
-
{children}
|
|
42
|
-
</PaymentsExtensionProvider>
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
### Create Payment
|
|
48
|
-
|
|
49
|
-
```typescript
|
|
50
|
-
import { usePaymentsContext } from '@djangocfg/ext-payments/hooks';
|
|
51
|
-
|
|
52
|
-
function CheckoutPage() {
|
|
53
|
-
const { createPayment, isCreatingPayment } = usePaymentsContext();
|
|
54
|
-
|
|
55
|
-
const handleCheckout = async () => {
|
|
56
|
-
const payment = await createPayment({
|
|
57
|
-
amount: 99.99,
|
|
58
|
-
currency: 'USD',
|
|
59
|
-
description: 'Premium subscription',
|
|
60
|
-
success_url: '/success',
|
|
61
|
-
cancel_url: '/cancel',
|
|
62
|
-
});
|
|
41
|
+
### Full Wallet Page
|
|
63
42
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
43
|
+
```tsx
|
|
44
|
+
// app/wallet/page.tsx
|
|
45
|
+
import { WalletPage } from '@djangocfg/ext-payments';
|
|
67
46
|
|
|
68
|
-
|
|
69
|
-
<button onClick={handleCheckout} disabled={isCreatingPayment}>
|
|
70
|
-
{isCreatingPayment ? 'Processing...' : 'Pay $99.99'}
|
|
71
|
-
</button>
|
|
72
|
-
);
|
|
73
|
-
}
|
|
47
|
+
export default WalletPage;
|
|
74
48
|
```
|
|
75
49
|
|
|
76
|
-
###
|
|
50
|
+
### API Hooks
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
import {
|
|
54
|
+
usePaymentsBalanceRetrieve,
|
|
55
|
+
usePaymentsPaymentsList,
|
|
56
|
+
usePaymentsWithdrawalsList,
|
|
57
|
+
useCreatePaymentsPaymentsCreateCreate,
|
|
58
|
+
} from '@djangocfg/ext-payments/api/hooks';
|
|
77
59
|
|
|
78
|
-
|
|
79
|
-
|
|
60
|
+
function BalanceCard() {
|
|
61
|
+
const { data: balance, isLoading } = usePaymentsBalanceRetrieve();
|
|
80
62
|
|
|
81
|
-
|
|
82
|
-
const { balances, isLoadingBalances, refreshBalances } = useBalancesContext();
|
|
63
|
+
if (isLoading) return <Skeleton />;
|
|
83
64
|
|
|
84
65
|
return (
|
|
85
66
|
<div>
|
|
86
|
-
<h2>
|
|
87
|
-
<
|
|
88
|
-
{balances?.map(balance => (
|
|
89
|
-
<div key={balance.currency}>
|
|
90
|
-
<strong>{balance.currency}:</strong> {balance.amount}
|
|
91
|
-
</div>
|
|
92
|
-
))}
|
|
67
|
+
<h2>Balance: ${balance?.amount}</h2>
|
|
68
|
+
<p>Currency: {balance?.currency}</p>
|
|
93
69
|
</div>
|
|
94
70
|
);
|
|
95
71
|
}
|
|
96
72
|
```
|
|
97
73
|
|
|
98
|
-
###
|
|
74
|
+
### API Client
|
|
99
75
|
|
|
100
|
-
```
|
|
101
|
-
import {
|
|
76
|
+
```tsx
|
|
77
|
+
import { apiPayments } from '@djangocfg/ext-payments/api';
|
|
102
78
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return (
|
|
107
|
-
<select
|
|
108
|
-
value={selectedCurrency?.code}
|
|
109
|
-
onChange={(e) => {
|
|
110
|
-
const currency = currencies.find(c => c.code === e.target.value);
|
|
111
|
-
if (currency) setCurrency(currency);
|
|
112
|
-
}}
|
|
113
|
-
>
|
|
114
|
-
{currencies.map(currency => (
|
|
115
|
-
<option key={currency.code} value={currency.code}>
|
|
116
|
-
{currency.name} ({currency.symbol})
|
|
117
|
-
</option>
|
|
118
|
-
))}
|
|
119
|
-
</select>
|
|
120
|
-
);
|
|
121
|
-
}
|
|
79
|
+
// Direct API calls
|
|
80
|
+
const balance = await apiPayments.payments.balanceRetrieve();
|
|
81
|
+
const payments = await apiPayments.payments.paymentsList({ page: 1 });
|
|
122
82
|
```
|
|
123
83
|
|
|
124
|
-
###
|
|
84
|
+
### Individual Components
|
|
125
85
|
|
|
126
|
-
```
|
|
127
|
-
import {
|
|
86
|
+
```tsx
|
|
87
|
+
import {
|
|
88
|
+
BalanceHero,
|
|
89
|
+
ActivityList,
|
|
90
|
+
AddFundsSheet,
|
|
91
|
+
WithdrawSheet,
|
|
92
|
+
PaymentSheet,
|
|
93
|
+
WithdrawalSheet,
|
|
94
|
+
} from '@djangocfg/ext-payments';
|
|
128
95
|
|
|
129
|
-
function
|
|
130
|
-
const
|
|
96
|
+
function CustomWallet() {
|
|
97
|
+
const [addFundsOpen, setAddFundsOpen] = useState(false);
|
|
131
98
|
|
|
132
99
|
return (
|
|
133
100
|
<div>
|
|
134
|
-
<
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
101
|
+
<BalanceHero
|
|
102
|
+
onAddFunds={() => setAddFundsOpen(true)}
|
|
103
|
+
onWithdraw={() => {}}
|
|
104
|
+
/>
|
|
105
|
+
<ActivityList limit={10} />
|
|
106
|
+
<AddFundsSheet
|
|
107
|
+
open={addFundsOpen}
|
|
108
|
+
onOpenChange={setAddFundsOpen}
|
|
109
|
+
/>
|
|
143
110
|
</div>
|
|
144
111
|
);
|
|
145
112
|
}
|
|
146
113
|
```
|
|
147
114
|
|
|
148
|
-
###
|
|
115
|
+
### Context Provider
|
|
149
116
|
|
|
150
|
-
```
|
|
151
|
-
import {
|
|
117
|
+
```tsx
|
|
118
|
+
import { WalletProvider, useWallet } from '@djangocfg/ext-payments';
|
|
152
119
|
|
|
153
|
-
|
|
154
|
-
|
|
120
|
+
// Wrap your app
|
|
121
|
+
<WalletProvider>
|
|
122
|
+
<MyWalletPage />
|
|
123
|
+
</WalletProvider>
|
|
155
124
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
<h2>Payment Overview</h2>
|
|
161
|
-
<div>
|
|
162
|
-
<p>Total Revenue: ${overview.total_revenue}</p>
|
|
163
|
-
<p>Pending Payments: {overview.pending_count}</p>
|
|
164
|
-
<p>Completed Payments: {overview.completed_count}</p>
|
|
165
|
-
<p>This Month: ${overview.current_month_revenue}</p>
|
|
166
|
-
</div>
|
|
167
|
-
</div>
|
|
168
|
-
);
|
|
125
|
+
// Use in components
|
|
126
|
+
function MyComponent() {
|
|
127
|
+
const { balance, payments, withdrawals, isLoading } = useWallet();
|
|
128
|
+
// ...
|
|
169
129
|
}
|
|
170
130
|
```
|
|
171
131
|
|
|
172
132
|
## API Reference
|
|
173
133
|
|
|
174
|
-
###
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
134
|
+
### SWR Hooks
|
|
135
|
+
|
|
136
|
+
| Hook | Description |
|
|
137
|
+
|------|-------------|
|
|
138
|
+
| `usePaymentsBalanceRetrieve()` | Get user balance |
|
|
139
|
+
| `usePaymentsCurrenciesList()` | Get available currencies |
|
|
140
|
+
| `usePaymentsCurrenciesEstimateRetrieve(code, { amount })` | Get payment estimate |
|
|
141
|
+
| `usePaymentsPaymentsList({ page, page_size })` | List payments |
|
|
142
|
+
| `usePaymentsPaymentsRetrieve(id)` | Get payment details |
|
|
143
|
+
| `usePaymentsWithdrawalsList({ page, page_size })` | List withdrawals |
|
|
144
|
+
| `usePaymentsWithdrawalsRetrieve(id)` | Get withdrawal details |
|
|
145
|
+
| `useCreatePaymentsPaymentsCreateCreate()` | Create payment mutation |
|
|
146
|
+
| `useCreatePaymentsWithdrawalsCreateCreate()` | Create withdrawal mutation |
|
|
147
|
+
| `useCreatePaymentsWithdrawalsCancelCreate()` | Cancel withdrawal mutation |
|
|
148
|
+
|
|
149
|
+
### Components
|
|
150
|
+
|
|
151
|
+
| Component | Description |
|
|
152
|
+
|-----------|-------------|
|
|
153
|
+
| `WalletPage` | Full wallet page with all features |
|
|
154
|
+
| `BalanceHero` | Balance display with action buttons |
|
|
155
|
+
| `ActivityList` | Combined payments + withdrawals list |
|
|
156
|
+
| `AddFundsSheet` | Sheet for adding funds |
|
|
157
|
+
| `WithdrawSheet` | Sheet for withdrawing |
|
|
158
|
+
| `PaymentSheet` | Payment details sheet |
|
|
159
|
+
| `WithdrawalSheet` | Withdrawal details sheet |
|
|
160
|
+
| `CurrencyCombobox` | Currency selector |
|
|
161
|
+
|
|
162
|
+
### Types
|
|
163
|
+
|
|
164
|
+
```tsx
|
|
165
|
+
import type {
|
|
166
|
+
Balance,
|
|
167
|
+
PaymentDetail,
|
|
168
|
+
PaymentList,
|
|
169
|
+
PaymentCreateRequest,
|
|
170
|
+
PaymentCreateResponse,
|
|
171
|
+
WithdrawalDetail,
|
|
172
|
+
WithdrawalList,
|
|
173
|
+
WithdrawalCreateRequest,
|
|
174
|
+
Currency,
|
|
175
|
+
Transaction,
|
|
176
|
+
} from '@djangocfg/ext-payments';
|
|
177
|
+
```
|
|
206
178
|
|
|
207
179
|
## License
|
|
208
180
|
|