@unchainedshop/core-payment 5.0.0-alpha.5 → 5.0.0-alpha.8
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 +11 -105
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -13,117 +13,23 @@ npm install @unchainedshop/core-payment
|
|
|
13
13
|
|
|
14
14
|
## Usage
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
import { configurePaymentModule, PaymentProviderType } from '@unchainedshop/core-payment';
|
|
18
|
-
|
|
19
|
-
const paymentModule = await configurePaymentModule({ db });
|
|
16
|
+
The platform initializes this module as `platform.unchainedAPI.modules.payment`. Register a payment plugin before platform startup; the base preset includes Invoice payment.
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
type: PaymentProviderType.CARD,
|
|
24
|
-
adapterKey: 'shop.unchained.payment.stripe',
|
|
25
|
-
});
|
|
18
|
+
```typescript
|
|
19
|
+
import { PaymentProviderType } from '@unchainedshop/core-payment';
|
|
26
20
|
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
21
|
+
const { payment } = platform.unchainedAPI.modules;
|
|
22
|
+
const provider = await payment.paymentProviders.create({
|
|
23
|
+
type: PaymentProviderType.INVOICE,
|
|
24
|
+
adapterKey: 'shop.unchained.invoice',
|
|
25
|
+
configuration: [],
|
|
30
26
|
});
|
|
27
|
+
const providers = await payment.paymentProviders.findProviders({});
|
|
31
28
|
```
|
|
32
29
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
### Module Configuration
|
|
36
|
-
|
|
37
|
-
| Export | Description |
|
|
38
|
-
|--------|-------------|
|
|
39
|
-
| `configurePaymentModule` | Configure and return the payment module |
|
|
40
|
-
|
|
41
|
-
### Queries
|
|
42
|
-
|
|
43
|
-
| Method | Description |
|
|
44
|
-
|--------|-------------|
|
|
45
|
-
| `findProvider` | Find provider by ID |
|
|
46
|
-
| `findProviders` | Find providers with filtering |
|
|
47
|
-
| `count` | Count providers |
|
|
48
|
-
| `providerExists` | Check if provider exists |
|
|
49
|
-
| `findSupported` | Find providers supported for context |
|
|
50
|
-
| `findInterface` | Get provider interface definition |
|
|
51
|
-
|
|
52
|
-
### Mutations
|
|
53
|
-
|
|
54
|
-
| Method | Description |
|
|
55
|
-
|--------|-------------|
|
|
56
|
-
| `create` | Create a new payment provider |
|
|
57
|
-
| `update` | Update provider configuration |
|
|
58
|
-
| `delete` | Soft delete a provider |
|
|
59
|
-
|
|
60
|
-
### Credentials
|
|
61
|
-
|
|
62
|
-
| Method | Description |
|
|
63
|
-
|--------|-------------|
|
|
64
|
-
| `findCredentials` | Find stored credentials for user |
|
|
65
|
-
| `createCredentials` | Store payment credentials |
|
|
66
|
-
| `deleteCredentials` | Remove stored credentials |
|
|
67
|
-
| `markPreferred` | Mark credentials as preferred |
|
|
68
|
-
|
|
69
|
-
### Constants
|
|
70
|
-
|
|
71
|
-
| Export | Description |
|
|
72
|
-
|--------|-------------|
|
|
73
|
-
| `PaymentProviderType` | Provider types (CARD, INVOICE, GENERIC) |
|
|
74
|
-
|
|
75
|
-
### Settings
|
|
76
|
-
|
|
77
|
-
| Export | Description |
|
|
78
|
-
|--------|-------------|
|
|
79
|
-
| `paymentSettings` | Access payment module settings |
|
|
80
|
-
|
|
81
|
-
### Types
|
|
82
|
-
|
|
83
|
-
| Export | Description |
|
|
84
|
-
|--------|-------------|
|
|
85
|
-
| `PaymentProvider` | Provider document type |
|
|
86
|
-
| `PaymentCredentials` | Credentials document type |
|
|
87
|
-
| `PaymentModule` | Module interface type |
|
|
88
|
-
|
|
89
|
-
## Events
|
|
90
|
-
|
|
91
|
-
| Event | Description |
|
|
92
|
-
|-------|-------------|
|
|
93
|
-
| `PAYMENT_PROVIDER_CREATE` | Provider created |
|
|
94
|
-
| `PAYMENT_PROVIDER_UPDATE` | Provider updated |
|
|
95
|
-
| `PAYMENT_PROVIDER_REMOVE` | Provider deleted |
|
|
96
|
-
|
|
97
|
-
## Security (PCI DSS)
|
|
98
|
-
|
|
99
|
-
This module is designed for **PCI DSS SAQ-A eligibility**:
|
|
100
|
-
|
|
101
|
-
### Tokenization
|
|
102
|
-
|
|
103
|
-
- **No card data storage**: Credit card numbers (PAN) and CVV are never stored
|
|
104
|
-
- **Provider tokens only**: Only payment provider-issued tokens are stored
|
|
105
|
-
- **Secure credentials**: Payment credentials contain references, not card data
|
|
106
|
-
|
|
107
|
-
```typescript
|
|
108
|
-
// PaymentCredentials structure - tokens only, no card data
|
|
109
|
-
type PaymentCredentials = {
|
|
110
|
-
paymentProviderId: string;
|
|
111
|
-
userId: string;
|
|
112
|
-
token?: string; // Provider-issued token (NOT card number)
|
|
113
|
-
isPreferred?: boolean;
|
|
114
|
-
meta: any; // Provider-specific metadata
|
|
115
|
-
};
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### Payment Flow
|
|
119
|
-
|
|
120
|
-
All payment integrations use tokenization patterns:
|
|
121
|
-
1. Card data collected by payment provider (Stripe, Datatrans, etc.)
|
|
122
|
-
2. Provider returns secure token
|
|
123
|
-
3. Unchained stores only the token reference
|
|
124
|
-
4. Subsequent charges use the token
|
|
30
|
+
Provider records are managed by `paymentProviders`; stored credentials by `paymentCredentials`. Order services and payment adapters coordinate provider selection and charging. Payment integrations should store provider tokens and references rather than card data.
|
|
125
31
|
|
|
126
|
-
See [
|
|
32
|
+
See the [module guide](https://docs.unchained.shop/platform-configuration/modules/payment), [payment integration guide](https://docs.unchained.shop/guides/payment-integration), [public exports](src/payment-index.ts), and [module implementation](src/module/configurePaymentModule.ts).
|
|
127
33
|
|
|
128
34
|
## License
|
|
129
35
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/core-payment",
|
|
3
3
|
"description": "Payment provider management module for the Unchained Engine",
|
|
4
|
-
"version": "5.0.0-alpha.
|
|
4
|
+
"version": "5.0.0-alpha.8",
|
|
5
5
|
"main": "lib/payment-index.js",
|
|
6
6
|
"types": "lib/payment-index.d.ts",
|
|
7
7
|
"type": "module",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@unchainedshop/events": "^5.0.0-alpha.
|
|
39
|
-
"@unchainedshop/mongodb": "^5.0.0-alpha.
|
|
40
|
-
"@unchainedshop/utils": "^5.0.0-alpha.
|
|
38
|
+
"@unchainedshop/events": "^5.0.0-alpha.8",
|
|
39
|
+
"@unchainedshop/mongodb": "^5.0.0-alpha.8",
|
|
40
|
+
"@unchainedshop/utils": "^5.0.0-alpha.8"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "^26.2.0",
|