@flopay/node 1.10.4 → 1.10.6
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 +13 -11
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -59,9 +59,10 @@ Customers can keep saved payment methods of any type, not only cards, and the se
|
|
|
59
59
|
|
|
60
60
|
`@flopay/shared` types the mixed method types for list and delete:
|
|
61
61
|
|
|
62
|
-
- `
|
|
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
|
|
64
|
-
- `ListSavedPaymentMethodsQuery` is the list request's optional `type` filter
|
|
62
|
+
- `SavedPaymentMethodFamily` is `'card'`, `'wallet'`, `'paypal'`, or `'apm'`: the family a saved method belongs to, for grouping. `SAVED_PAYMENT_METHOD_FAMILIES` lists every value for exhaustive handling. `SavedPaymentMethodType` and `SAVED_PAYMENT_METHOD_TYPES` are deprecated aliases with the same values.
|
|
63
|
+
- `SavedPaymentMethodDisplay` is one display-only saved method of any type, discriminated by its family `type`. Every variant has an `id` and a lifecycle `status`, and may carry the billing API row's `methodType` and `displayLabel`. `methodType` tells methods of one family apart: an Apple Pay row and a Google Pay row are both `type: 'wallet'`, with `methodType` `apple_pay` and `google_pay`. A wallet, PayPal, or APM method always has a safe display `label`, deprecated in favour of `displayLabel`, which holds the same value. A card has `brand`, `lastFour`, `expiryMonth`, and `expiryYear`, its `methodType` is `card`, and its `label` is optional and its `displayLabel` is `null`: build the display text from `brand` and `lastFour` instead, 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, a `SavedPaymentMethodListType`. Leave it out to list every saved method, as card-only integrations do today.
|
|
65
|
+
- `SavedPaymentMethodListType` is a method type the billing API accepts for that filter: `card`, `paypal`, `apple_pay`, `google_pay`, `sepa_debit`, or `us_bank_account`, and `SAVED_PAYMENT_METHOD_LIST_TYPES` lists every value. It filters by method type, never by family, so there is no `wallet` or `apm` filter: ask for `apple_pay` or `google_pay` instead. PayPal is `paypal`, not the setup flow's `paypal_vaulted`.
|
|
65
66
|
- `isSetupCheckoutSession` is `true` for a no-charge setup session (`checkoutMode: 'setup'`, zero amount, no products), whatever methods its `advertisedPaymentMethods` list. `isCardSetupCheckoutSession` is unchanged.
|
|
66
67
|
|
|
67
68
|
Deleting a saved method works the same way for every type, with the same `PaymentMethodRemovalError` responses.
|
|
@@ -146,7 +147,7 @@ export async function createCardSetupSession(post: AuthenticatedPost, userId: st
|
|
|
146
147
|
}
|
|
147
148
|
```
|
|
148
149
|
|
|
149
|
-
List saved payment methods of any type, optionally filtered by `type`, and label each one without branching on a gateway:
|
|
150
|
+
List saved payment methods of any type, optionally filtered by method `type`, and label each one without branching on a gateway:
|
|
150
151
|
|
|
151
152
|
```ts
|
|
152
153
|
import type { ListSavedPaymentMethodsQuery, SavedPaymentMethodDisplay } from '@flopay/shared';
|
|
@@ -159,16 +160,17 @@ export function describeSavedMethod(method: SavedPaymentMethodDisplay): string {
|
|
|
159
160
|
case 'wallet':
|
|
160
161
|
case 'paypal':
|
|
161
162
|
case 'apm':
|
|
162
|
-
return method.label;
|
|
163
|
+
return method.displayLabel ?? method.label;
|
|
163
164
|
default:
|
|
164
|
-
// A card; card-only responses may omit `type
|
|
165
|
-
return method.label ?? `${method.brand} ending ${method.lastFour}`;
|
|
165
|
+
// A card; card-only responses may omit `type`, and a card's `displayLabel` is null.
|
|
166
|
+
return method.displayLabel ?? method.label ?? `${method.brand} ending ${method.lastFour}`;
|
|
166
167
|
}
|
|
167
168
|
}
|
|
168
169
|
|
|
169
|
-
export async function
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
export async function listSavedApplePay(list: AuthenticatedList): Promise<string[]> {
|
|
171
|
+
// Filter by method type: the billing API accepts `apple_pay`, never the `wallet` family.
|
|
172
|
+
const methods = await list({ type: 'apple_pay' });
|
|
173
|
+
return methods.map(describeSavedMethod);
|
|
172
174
|
}
|
|
173
175
|
```
|
|
174
176
|
|
|
@@ -262,7 +264,7 @@ The parameter and result types (`CreateSessionParams`, `CheckoutSessionResult`,
|
|
|
262
264
|
|
|
263
265
|
`@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.
|
|
264
266
|
|
|
265
|
-
Saved payment methods of any type are typed by `@flopay/shared` too: `SavedPaymentMethodDisplay`, `SavedPaymentMethodType
|
|
267
|
+
Saved payment methods of any type are typed by `@flopay/shared` too: `SavedPaymentMethodDisplay`, `SavedPaymentMethodFamily` (with the deprecated alias `SavedPaymentMethodType`), `ListSavedPaymentMethodsQuery` and its `SavedPaymentMethodListType` filter values, `AdvertisedPaymentMethod`, and the `isSetupCheckoutSession` guard. `@flopay/node` adds no list or delete method for them.
|
|
266
268
|
|
|
267
269
|
## Errors
|
|
268
270
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flopay/node",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.6",
|
|
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.10.
|
|
30
|
+
"@flopay/shared": "1.10.6"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"tsup": "^8.3.0",
|