@flopay/node 1.9.30 → 1.10.1

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 +41 -0
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -53,6 +53,19 @@ Type the setup request body with `CreateCardSetupSessionRequest` from `@flopay/s
53
53
 
54
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
55
 
56
+ ### Saved payment methods
57
+
58
+ Customers can keep saved payment methods of any type, not only cards, and the server-side flow is the same one as for saved cards. Merchant credentials stay on the merchant server: your server creates the setup session through its own authenticated billing API client, and no FloPay package sends the setup request. Type the body with `CreateCardSetupSessionRequest` from `@flopay/shared` exactly as for a card. Saving another method type needs no extra field, and the request carries no gateway hint, provider allow-list, or eligibility table. The billing API advertises which methods a setup session can save, and the SDK never decides which gateway or method is eligible.
59
+
60
+ `@flopay/shared` types the mixed method types for list and delete:
61
+
62
+ - `SavedPaymentMethodType` is `'card'`, `'wallet'`, `'paypal'`, or `'apm'`. `SAVED_PAYMENT_METHOD_TYPES` lists every value for exhaustive handling.
63
+ - `SavedPaymentMethodDisplay` is one display-only saved method of any type, discriminated by `type`. Every variant has an `id` and a lifecycle `status`. A wallet, PayPal, or APM method always has a safe display `label`. A card has `brand`, `lastFour`, `expiryMonth`, and `expiryYear`, and its `label` is optional: when it is missing, build the display text from `brand` and `lastFour`, as the example below does. No variant carries a reusable credential, token, or card number. An existing `SavedCardDisplay` is a valid `SavedPaymentMethodDisplay` without a `type`, so card-only code keeps compiling.
64
+ - `ListSavedPaymentMethodsQuery` is the list request's optional `type` filter. Leave it out to list every saved method, as card-only integrations do today.
65
+ - `isSetupCheckoutSession` is `true` for a no-charge setup session (`checkoutMode: 'setup'`, zero amount, no products), whatever methods its `savableMethods` advertise. `isCardSetupCheckoutSession` is unchanged.
66
+
67
+ Deleting a saved method works the same way for every type, with the same `PaymentMethodRemovalError` responses.
68
+
56
69
  ### Stripe checkout sessions and customers
57
70
 
58
71
  `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`.
@@ -133,6 +146,32 @@ export async function createCardSetupSession(post: AuthenticatedPost, userId: st
133
146
  }
134
147
  ```
135
148
 
149
+ List saved payment methods of any type, optionally filtered by `type`, and label each one without branching on a gateway:
150
+
151
+ ```ts
152
+ import type { ListSavedPaymentMethodsQuery, SavedPaymentMethodDisplay } from '@flopay/shared';
153
+
154
+ // Your server's existing billing API client; it adds your merchant authentication.
155
+ type AuthenticatedList = (query: ListSavedPaymentMethodsQuery) => Promise<SavedPaymentMethodDisplay[]>;
156
+
157
+ export function describeSavedMethod(method: SavedPaymentMethodDisplay): string {
158
+ switch (method.type) {
159
+ case 'wallet':
160
+ case 'paypal':
161
+ case 'apm':
162
+ return method.label;
163
+ default:
164
+ // A card; card-only responses may omit `type`.
165
+ return method.label ?? `${method.brand} ending ${method.lastFour}`;
166
+ }
167
+ }
168
+
169
+ export async function listSavedWallets(list: AuthenticatedList): Promise<string[]> {
170
+ const wallets = await list({ type: 'wallet' });
171
+ return wallets.map(describeSavedMethod);
172
+ }
173
+ ```
174
+
136
175
  Verify a Stripe webhook in a plain Node.js HTTP server:
137
176
 
138
177
  ```ts
@@ -223,6 +262,8 @@ The parameter and result types (`CreateSessionParams`, `CheckoutSessionResult`,
223
262
 
224
263
  `@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
264
 
265
+ Saved payment methods of any type are typed by `@flopay/shared` too: `SavedPaymentMethodDisplay`, `SavedPaymentMethodType`, `ListSavedPaymentMethodsQuery`, `AdvertisedSavableMethod`, and the `isSetupCheckoutSession` guard. `@flopay/node` adds no list or delete method for them.
266
+
226
267
  ## Errors
227
268
 
228
269
  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.30",
3
+ "version": "1.10.1",
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"
30
+ "@flopay/shared": "1.10.1"
31
31
  },
32
32
  "devDependencies": {
33
33
  "tsup": "^8.3.0",