@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 CHANGED
@@ -2,25 +2,24 @@
2
2
 
3
3
  ![DjangoCFG Extension Preview](https://unpkg.com/@djangocfg/ext-payments@latest/preview.png)
4
4
 
5
- **[📦 View in Marketplace](https://hub.djangocfg.com/extensions/djangocfg-ext-payments)** • **[📖 Documentation](https://djangocfg.com)** • **[GitHub](https://github.com/markolofsen/django-cfg)**
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
- Payment processing and subscription management extension for DjangoCFG.
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
- - 💳 **Payment Processing** - Handle cryptocurrency and fiat payments
18
- - 🔄 **Subscription Management** - Recurring billing and subscriptions
19
- - 💰 **Multi-Currency Support** - Support for multiple cryptocurrencies
20
- - 📊 **Balance Tracking** - Real-time balance and transaction history
21
- - 🔔 **Webhook Integration** - Receive payment notifications
22
- - 📈 **Analytics Dashboard** - Payment statistics and insights
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
- ## Usage
30
+ ## Exports
32
31
 
33
- ### Provider Setup
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
- ```typescript
36
- import { PaymentsExtensionProvider } from '@djangocfg/ext-payments/hooks';
39
+ ## Quick Start
37
40
 
38
- export default function RootLayout({ children }) {
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
- // Redirect to payment URL
65
- window.location.href = payment.payment_url;
66
- };
43
+ ```tsx
44
+ // app/wallet/page.tsx
45
+ import { WalletPage } from '@djangocfg/ext-payments';
67
46
 
68
- return (
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
- ### Balance Management
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
- ```typescript
79
- import { useBalancesContext } from '@djangocfg/ext-payments/hooks';
60
+ function BalanceCard() {
61
+ const { data: balance, isLoading } = usePaymentsBalanceRetrieve();
80
62
 
81
- function WalletPage() {
82
- const { balances, isLoadingBalances, refreshBalances } = useBalancesContext();
63
+ if (isLoading) return <Skeleton />;
83
64
 
84
65
  return (
85
66
  <div>
86
- <h2>Your Balances</h2>
87
- <button onClick={refreshBalances}>Refresh</button>
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
- ### Currency Management
74
+ ### API Client
99
75
 
100
- ```typescript
101
- import { useCurrenciesContext } from '@djangocfg/ext-payments/hooks';
76
+ ```tsx
77
+ import { apiPayments } from '@djangocfg/ext-payments/api';
102
78
 
103
- function CurrencySelector() {
104
- const { currencies, selectedCurrency, setCurrency } = useCurrenciesContext();
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
- ### Payment History
84
+ ### Individual Components
125
85
 
126
- ```typescript
127
- import { usePaymentsContext } from '@djangocfg/ext-payments/hooks';
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 TransactionsPage() {
130
- const { payments, isLoadingPayments } = usePaymentsContext();
96
+ function CustomWallet() {
97
+ const [addFundsOpen, setAddFundsOpen] = useState(false);
131
98
 
132
99
  return (
133
100
  <div>
134
- <h2>Transaction History</h2>
135
- {payments.map(payment => (
136
- <div key={payment.id}>
137
- <span>{payment.description}</span>
138
- <span>{payment.amount} {payment.currency}</span>
139
- <span>Status: {payment.status}</span>
140
- <span>{new Date(payment.created_at).toLocaleDateString()}</span>
141
- </div>
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
- ### Payment Overview
115
+ ### Context Provider
149
116
 
150
- ```typescript
151
- import { useOverviewContext } from '@djangocfg/ext-payments/hooks';
117
+ ```tsx
118
+ import { WalletProvider, useWallet } from '@djangocfg/ext-payments';
152
119
 
153
- function DashboardPage() {
154
- const { overview, isLoadingOverview } = useOverviewContext();
120
+ // Wrap your app
121
+ <WalletProvider>
122
+ <MyWalletPage />
123
+ </WalletProvider>
155
124
 
156
- if (isLoadingOverview) return <div>Loading...</div>;
157
-
158
- return (
159
- <div>
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
- ### Payments Context
175
-
176
- - `payments` - List of all payments
177
- - `createPayment(data)` - Create new payment
178
- - `getPaymentById(id)` - Get payment details
179
- - `cancelPayment(id)` - Cancel payment
180
- - `isLoadingPayments` - Loading state
181
-
182
- ### Balances Context
183
-
184
- - `balances` - User's cryptocurrency balances
185
- - `refreshBalances()` - Refresh balance data
186
- - `isLoadingBalances` - Loading state
187
-
188
- ### Currencies Context
189
-
190
- - `currencies` - Available cryptocurrencies
191
- - `selectedCurrency` - Currently selected currency
192
- - `setCurrency(currency)` - Set active currency
193
- - `getCurrencyByCode(code)` - Get currency details
194
-
195
- ### Overview Context
196
-
197
- - `overview` - Payment statistics and analytics
198
- - `refreshOverview()` - Refresh overview data
199
- - `isLoadingOverview` - Loading state
200
-
201
- ### Root Payments Context
202
-
203
- - `currencies` - Global currencies list
204
- - `refreshCurrencies()` - Refresh currency data
205
- - `isLoadingCurrencies` - Loading state
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