@flopay/node 1.10.5 → 1.11.0
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 +14 -13
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -49,7 +49,7 @@ Type the setup request body with `CreateCardSetupSessionRequest` from `@flopay/s
|
|
|
49
49
|
|
|
50
50
|
- `country`: the ISO 3166-1 alpha-2 country the card will be used in.
|
|
51
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'`
|
|
52
|
+
- `futureUse`: **deprecated** (`CardSetupFutureUse`, `'on_session'` or `'off_session'`). Future use is platform policy: the billing API sets every saved method up `'off_session'` and ignores this value. It is still accepted so existing requests keep working; leave it out of new code.
|
|
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
|
|
|
@@ -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.
|
|
@@ -138,7 +139,6 @@ export async function createCardSetupSession(post: AuthenticatedPost, userId: st
|
|
|
138
139
|
userId,
|
|
139
140
|
country: 'GB',
|
|
140
141
|
currency: 'GBP',
|
|
141
|
-
futureUse: 'off_session',
|
|
142
142
|
};
|
|
143
143
|
const { data } = await post('/v1/checkouts/sessions/setup', request);
|
|
144
144
|
|
|
@@ -146,7 +146,7 @@ export async function createCardSetupSession(post: AuthenticatedPost, userId: st
|
|
|
146
146
|
}
|
|
147
147
|
```
|
|
148
148
|
|
|
149
|
-
List saved payment methods of any type, optionally filtered by `type`, and label each one without branching on a gateway:
|
|
149
|
+
List saved payment methods of any type, optionally filtered by method `type`, and label each one without branching on a gateway:
|
|
150
150
|
|
|
151
151
|
```ts
|
|
152
152
|
import type { ListSavedPaymentMethodsQuery, SavedPaymentMethodDisplay } from '@flopay/shared';
|
|
@@ -159,16 +159,17 @@ export function describeSavedMethod(method: SavedPaymentMethodDisplay): string {
|
|
|
159
159
|
case 'wallet':
|
|
160
160
|
case 'paypal':
|
|
161
161
|
case 'apm':
|
|
162
|
-
return method.label;
|
|
162
|
+
return method.displayLabel ?? method.label;
|
|
163
163
|
default:
|
|
164
|
-
// A card; card-only responses may omit `type
|
|
165
|
-
return method.label ?? `${method.brand} ending ${method.lastFour}`;
|
|
164
|
+
// A card; card-only responses may omit `type`, and a card's `displayLabel` is null.
|
|
165
|
+
return method.displayLabel ?? method.label ?? `${method.brand} ending ${method.lastFour}`;
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
export async function
|
|
170
|
-
|
|
171
|
-
|
|
169
|
+
export async function listSavedApplePay(list: AuthenticatedList): Promise<string[]> {
|
|
170
|
+
// Filter by method type: the billing API accepts `apple_pay`, never the `wallet` family.
|
|
171
|
+
const methods = await list({ type: 'apple_pay' });
|
|
172
|
+
return methods.map(describeSavedMethod);
|
|
172
173
|
}
|
|
173
174
|
```
|
|
174
175
|
|
|
@@ -262,7 +263,7 @@ The parameter and result types (`CreateSessionParams`, `CheckoutSessionResult`,
|
|
|
262
263
|
|
|
263
264
|
`@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
265
|
|
|
265
|
-
Saved payment methods of any type are typed by `@flopay/shared` too: `SavedPaymentMethodDisplay`, `SavedPaymentMethodType
|
|
266
|
+
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
267
|
|
|
267
268
|
## Errors
|
|
268
269
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flopay/node",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
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.
|
|
30
|
+
"@flopay/shared": "1.11.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"tsup": "^8.3.0",
|