@flopay/node 1.9.18 → 1.9.19
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 +34 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -45,6 +45,14 @@ To authorise an eligible one-time card cart without capturing it, pass `captureM
|
|
|
45
45
|
|
|
46
46
|
Saved-card management is also not an `@flopay/node` credential surface. From trusted server code, use the authenticated REST API to list display-only payment methods, create a setup session, and delete an eligible method, then pass only the setup session's `sessionId` and `nonce` to `FloPayCardSetup` in `@flopay/react`. Replace a card setup-first, then delete, so a failed or cancelled setup leaves the existing card intact. See the [payment methods reference](https://flopay.com/docs/technical-reference/rest/payment-methods).
|
|
47
47
|
|
|
48
|
+
Type the setup request body with `CreateCardSetupSessionRequest` from `@flopay/shared`. Alongside the required `userId` and the optional `successUrl` and `cancelUrl`, it accepts transaction context your server may already know, which the billing API routes card verification on. Each field is optional and independent of the others, and a request without any of them stays valid and unchanged:
|
|
49
|
+
|
|
50
|
+
- `country`: the ISO 3166-1 alpha-2 country the card will be used in.
|
|
51
|
+
- `currency`: the three-letter currency later payments will be charged in. A supplied `currency` becomes the setup session's currency.
|
|
52
|
+
- `futureUse`: `'on_session'` or `'off_session'` (`CardSetupFutureUse`). Send `'on_session'` only when the card will be charged only while the customer is present. For cards charged without the customer present, including cards used both ways, leave it out or send `'off_session'`.
|
|
53
|
+
|
|
54
|
+
The context needs billing API v1.9.48 or later. Older billing APIs silently ignore it and set the card up exactly as before. Send values as you hold them: the billing API trims and uppercases `country` and `currency`, validates all three fields, and rejects an invalid value with a `400`. The context describes the transaction and never selects a gateway; the billing API alone decides which gateway verifies the card.
|
|
55
|
+
|
|
48
56
|
### Stripe checkout sessions and customers
|
|
49
57
|
|
|
50
58
|
`checkout.sessions.retrieve()`, `expire()`, and `listLineItems()` call Stripe directly and normalize the result. `customers.create()`, `retrieve()`, and `update()` manage Stripe customers and return a normalized `Customer`.
|
|
@@ -101,6 +109,30 @@ if (result.status === 201 && 'redirectUrl' in result) {
|
|
|
101
109
|
}
|
|
102
110
|
```
|
|
103
111
|
|
|
112
|
+
Type a card-setup request with optional transaction context, send it with the billing API client your server already authenticates, and return only the session handle for `FloPayCardSetup`:
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
import type { CreateCardSetupSessionRequest } from '@flopay/shared';
|
|
116
|
+
|
|
117
|
+
// Your server's existing billing API client; it adds your merchant authentication.
|
|
118
|
+
type AuthenticatedPost = (
|
|
119
|
+
path: string,
|
|
120
|
+
body: CreateCardSetupSessionRequest,
|
|
121
|
+
) => Promise<{ data: { uuid: string; nonce: string } }>;
|
|
122
|
+
|
|
123
|
+
export async function createCardSetupSession(post: AuthenticatedPost, userId: string) {
|
|
124
|
+
const request: CreateCardSetupSessionRequest = {
|
|
125
|
+
userId,
|
|
126
|
+
country: 'GB',
|
|
127
|
+
currency: 'GBP',
|
|
128
|
+
futureUse: 'off_session',
|
|
129
|
+
};
|
|
130
|
+
const { data } = await post('/v1/checkouts/sessions/setup', request);
|
|
131
|
+
|
|
132
|
+
return { sessionId: data.uuid, nonce: data.nonce };
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
104
136
|
Verify a Stripe webhook in a plain Node.js HTTP server:
|
|
105
137
|
|
|
106
138
|
```ts
|
|
@@ -189,6 +221,8 @@ console.log(updated.email, session.status, session.amount);
|
|
|
189
221
|
|
|
190
222
|
The parameter and result types (`CreateSessionParams`, `CheckoutSessionResult`, `CheckoutSession`, `Customer`, `LineItem`, `WebhookEvent`) are exported by `@flopay/shared`.
|
|
191
223
|
|
|
224
|
+
`@flopay/node` has no card-setup method and holds no merchant credential. `CreateCardSetupSessionRequest` and `CardSetupFutureUse`, also exported by `@flopay/shared`, type the body your server sends to the authenticated `POST /v1/checkouts/sessions/setup` route with its own billing API client.
|
|
225
|
+
|
|
192
226
|
## Errors
|
|
193
227
|
|
|
194
228
|
SDK validation and billing API failures are `FloPayError`s from `@flopay/shared`; branch on `type` and `code`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flopay/node",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.19",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"stripe": "^22.2.1",
|
|
30
|
-
"@flopay/shared": "1.9.
|
|
30
|
+
"@flopay/shared": "1.9.19"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"tsup": "^8.3.0",
|