@deliverart/sdk-js-payment 2.1.50 → 2.1.51

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.
Files changed (2) hide show
  1. package/README.md +214 -0
  2. package/package.json +4 -4
package/README.md ADDED
@@ -0,0 +1,214 @@
1
+ # @deliverart/sdk-js-payment
2
+
3
+ Payment management package for the DeliverArt JavaScript SDK.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @deliverart/sdk-js-payment @deliverart/sdk-js-core
9
+ ```
10
+
11
+ ## Exported Types
12
+
13
+ ### Core Types
14
+ - `Payment` - Payment information
15
+ - `PaymentDetails` - Extended payment with order details
16
+ - `PaymentConfig` - Payment configuration for point of sale
17
+ - `PaymentMethod` - Payment method type
18
+ - `PaymentStatus` - Payment status
19
+
20
+ ### Payment Method Types
21
+ ```typescript
22
+ type PaymentMethod =
23
+ | 'CASH'
24
+ | 'CREDIT_CARD'
25
+ | 'DEBIT_CARD'
26
+ | 'STRIPE'
27
+ | 'PAYPAL'
28
+ | 'SATISPAY'
29
+ | 'ONLINE'
30
+ | 'POS'
31
+ ```
32
+
33
+ ### Payment Status Types
34
+ ```typescript
35
+ type PaymentStatus =
36
+ | 'PENDING'
37
+ | 'PROCESSING'
38
+ | 'COMPLETED'
39
+ | 'FAILED'
40
+ | 'REFUNDED'
41
+ | 'CANCELLED'
42
+ ```
43
+
44
+ ### IRI Types
45
+ - `PaymentIri` - Payment IRI (`/payments/:id`)
46
+ - `PaymentConfigIri` - Payment config IRI (`/payment_configs/:id`)
47
+
48
+ ## Available Requests
49
+
50
+ ### Payments
51
+
52
+ #### CreatePayment
53
+ ```typescript
54
+ import { CreatePayment } from '@deliverart/sdk-js-payment';
55
+
56
+ const payment = await sdk.call(new CreatePayment({
57
+ order: '/orders/123',
58
+ method: 'CREDIT_CARD',
59
+ amount: 2500, // In cents
60
+ status: 'PENDING'
61
+ }));
62
+ ```
63
+
64
+ **Input Parameters:**
65
+ - `order: string` (required) - Order IRI
66
+ - `method: PaymentMethod` (required) - Payment method
67
+ - `amount: number` (required) - Amount in cents
68
+ - `status?: PaymentStatus` (optional) - Initial status (default: 'PENDING')
69
+ - `transactionId?: string` (optional) - External transaction ID
70
+ - `metadata?: object` (optional) - Additional metadata
71
+
72
+ #### GetPayments
73
+ ```typescript
74
+ import { GetPayments } from '@deliverart/sdk-js-payment';
75
+
76
+ const payments = await sdk.call(new GetPayments({
77
+ query: {
78
+ order: '/orders/123',
79
+ method: 'CREDIT_CARD',
80
+ 'status[]': ['COMPLETED', 'PENDING'],
81
+ page: 1
82
+ }
83
+ }));
84
+ ```
85
+
86
+ **Query Parameters:**
87
+ - `order?: string` - Filter by order
88
+ - `method?: PaymentMethod` - Filter by payment method
89
+ - `status[]?: PaymentStatus[]` - Filter by statuses
90
+ - `createdAt[before]?: string` - Created before date
91
+ - `createdAt[after]?: string` - Created after date
92
+ - `page?: number` - Page number
93
+
94
+ #### GetPaymentDetails
95
+ ```typescript
96
+ import { GetPaymentDetails } from '@deliverart/sdk-js-payment';
97
+
98
+ const payment = await sdk.call(new GetPaymentDetails('payment-123'));
99
+ ```
100
+
101
+ #### UpdatePayment
102
+ ```typescript
103
+ import { UpdatePayment } from '@deliverart/sdk-js-payment';
104
+
105
+ const updated = await sdk.call(new UpdatePayment('payment-123', {
106
+ status: 'COMPLETED',
107
+ transactionId: 'txn_abc123'
108
+ }));
109
+ ```
110
+
111
+ ---
112
+
113
+ ### Payment Configurations
114
+
115
+ #### CreatePaymentConfig
116
+ ```typescript
117
+ import { CreatePaymentConfig } from '@deliverart/sdk-js-payment';
118
+
119
+ const config = await sdk.call(new CreatePaymentConfig({
120
+ pointOfSale: '/point_of_sales/123',
121
+ method: 'STRIPE',
122
+ enabled: true,
123
+ config: {
124
+ publicKey: 'pk_test_...',
125
+ secretKey: 'sk_test_...'
126
+ }
127
+ }));
128
+ ```
129
+
130
+ **Input Parameters:**
131
+ - `pointOfSale: string` (required) - Point of sale IRI
132
+ - `method: PaymentMethod` (required) - Payment method
133
+ - `enabled: boolean` (required) - Enable/disable payment method
134
+ - `config: object` (required) - Method-specific configuration
135
+
136
+ #### GetPaymentConfigs
137
+ ```typescript
138
+ import { GetPaymentConfigs } from '@deliverart/sdk-js-payment';
139
+
140
+ const configs = await sdk.call(new GetPaymentConfigs({
141
+ query: {
142
+ pointOfSale: '/point_of_sales/123',
143
+ enabled: true
144
+ }
145
+ }));
146
+ ```
147
+
148
+ #### UpdatePaymentConfig
149
+ ```typescript
150
+ import { UpdatePaymentConfig } from '@deliverart/sdk-js-payment';
151
+
152
+ const updated = await sdk.call(new UpdatePaymentConfig('config-123', {
153
+ enabled: false
154
+ }));
155
+ ```
156
+
157
+ ---
158
+
159
+ ## Complete Usage Example
160
+
161
+ ```typescript
162
+ import { sdk } from './lib/sdk';
163
+ import {
164
+ CreatePaymentConfig,
165
+ CreatePayment,
166
+ UpdatePayment,
167
+ GetPayments
168
+ } from '@deliverart/sdk-js-payment';
169
+
170
+ async function paymentWorkflow() {
171
+ // Setup payment methods for point of sale
172
+ await sdk.call(new CreatePaymentConfig({
173
+ pointOfSale: '/point_of_sales/123',
174
+ method: 'STRIPE',
175
+ enabled: true,
176
+ config: {
177
+ publicKey: process.env.STRIPE_PUBLIC_KEY,
178
+ secretKey: process.env.STRIPE_SECRET_KEY
179
+ }
180
+ }));
181
+
182
+ // Create payment for order
183
+ const payment = await sdk.call(new CreatePayment({
184
+ order: '/orders/456',
185
+ method: 'CREDIT_CARD',
186
+ amount: 2500,
187
+ status: 'PENDING'
188
+ }));
189
+
190
+ // Process payment (integrate with payment gateway)
191
+ // ... payment processing logic ...
192
+
193
+ // Update payment status
194
+ await sdk.call(new UpdatePayment(payment.id, {
195
+ status: 'COMPLETED',
196
+ transactionId: 'txn_abc123'
197
+ }));
198
+
199
+ // Get all completed payments
200
+ const completed = await sdk.call(new GetPayments({
201
+ query: {
202
+ 'status[]': ['COMPLETED'],
203
+ 'order[createdAt]': 'desc'
204
+ }
205
+ }));
206
+
207
+ console.log(`Total completed: ${completed.pagination.totalItems}`);
208
+ }
209
+ ```
210
+
211
+ ## License
212
+
213
+ MIT
214
+
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deliverart/sdk-js-payment",
3
3
  "description": "Deliverart JavaScript SDK for Payment Management",
4
- "version": "2.1.50",
4
+ "version": "2.1.51",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -18,9 +18,9 @@
18
18
  "dist"
19
19
  ],
20
20
  "dependencies": {
21
- "@deliverart/sdk-js-core": "2.1.50",
22
- "@deliverart/sdk-js-global-types": "2.1.50",
23
- "@deliverart/sdk-js-point-of-sale": "2.1.50"
21
+ "@deliverart/sdk-js-core": "2.1.51",
22
+ "@deliverart/sdk-js-global-types": "2.1.51",
23
+ "@deliverart/sdk-js-point-of-sale": "2.1.51"
24
24
  },
25
25
  "publishConfig": {
26
26
  "access": "public"