@flopay/vue 0.0.0-stage → 1.13.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.
package/README.md CHANGED
@@ -1,3 +1,103 @@
1
- # Temporary Holding Version
1
+ # @flopay/vue
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Vue 3 components and composables for FloPay checkout, card setup and one-click payments: the Vue counterpart of `@flopay/react`, with the same props, events and behaviour.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @flopay/vue
9
+ ```
10
+
11
+ `vue` (`>=3.3.0`) is a peer dependency. `@flopay/js` and `@flopay/shared` are installed with the package.
12
+
13
+ ## Usage
14
+
15
+ Render `FloPayCheckout` with a session the merchant server created, or with an inline `createSession` draft. Notification callbacks are Vue events: React's `onComplete` is `@complete` in templates and `onComplete` in `h()`.
16
+
17
+ ```ts
18
+ import { FloPayCheckout } from '@flopay/vue';
19
+ import { h } from 'vue';
20
+
21
+ export default {
22
+ setup() {
23
+ return () =>
24
+ h(FloPayCheckout, {
25
+ sessionId: 'sess_123',
26
+ nonce: 'nonce_123',
27
+ onComplete: (result) => console.log(result.status),
28
+ onDecline: (decline) => console.log(decline.message),
29
+ });
30
+ },
31
+ };
32
+ ```
33
+
34
+ Browser work (session reads, SDK loading, the hosted card widget) starts in `onMounted`, so server rendering never touches `window` and renders the loading state.
35
+
36
+ ## Examples
37
+
38
+ Card setup from the Stripe-free subpath:
39
+
40
+ ```ts
41
+ import { FloPayCardSetup } from '@flopay/vue/card-setup';
42
+ import { h } from 'vue';
43
+
44
+ const render = () =>
45
+ h(FloPayCardSetup, {
46
+ sessionId: 'sess_setup_123',
47
+ nonce: 'nonce_setup_123',
48
+ onComplete: (event) => console.log(event.sessionId),
49
+ });
50
+ ```
51
+
52
+ One-click payment with the buyer's saved payment method:
53
+
54
+ ```ts
55
+ import { FloPayAutomaticPaymentButton } from '@flopay/vue';
56
+ import { h } from 'vue';
57
+
58
+ const render = () =>
59
+ h(FloPayAutomaticPaymentButton, {
60
+ clientId: 'client_123',
61
+ account: { userId: 'user_123', email: 'buyer@example.com' },
62
+ products: [{ code: 'pro-monthly', quantity: 1 }],
63
+ successUrl: 'https://example.com/success',
64
+ cancelUrl: 'https://example.com/cancel',
65
+ onSuccess: (event) => console.log(event.autoCompleted),
66
+ });
67
+ ```
68
+
69
+ ## Public API
70
+
71
+ Every `@flopay/react` component and hook has a same-name Vue export. React's notification callbacks are Vue events with the same payloads.
72
+
73
+ | Export | React (`@flopay/react`) | Vue (`@flopay/vue`) |
74
+ |--------|-------------------------|---------------------|
75
+ | `FloPayProvider` | `<FloPayProvider>` | `FloPayProvider`, provided to descendants; `@instrument` |
76
+ | `FloPayCheckout` | `<FloPayCheckout>` | `FloPayCheckout`: `@complete`, `@decline`, `@error`, `@button-click` |
77
+ | `SplitCardForm` | `<SplitCardForm>` | `SplitCardForm`: `@complete`, `@decline`, `@error` |
78
+ | `VaultCardFields` | `<VaultCardFields>` | `VaultCardFields`: `@ready`, `@error`, `@validation` |
79
+ | `DirectPayPalButton` | `<DirectPayPalButton>` | `DirectPayPalButton` |
80
+ | `FloPayAutomaticPaymentButton` | `<FloPayAutomaticPaymentButton>` | `FloPayAutomaticPaymentButton`: `@success`, `@error`, `@decline` |
81
+ | `FloPayCardSetup` | `<FloPayCardSetup>` | `FloPayCardSetup`: `@ready`, `@complete`, `@decline`, `@cancel`, `@error` |
82
+ | `FloPayPaymentMethodSetup` | `<FloPayPaymentMethodSetup>` | `FloPayPaymentMethodSetup` |
83
+ | `useFloPay` | `useFloPay()` | `useFloPay()`: a ref, `null` until `loadFloPay()` resolves |
84
+ | `usePayPalFloPay` | `usePayPalFloPay()` | `usePayPalFloPay()`: a ref |
85
+ | `useCheckout` | `useCheckout()` | `useCheckout()`: a reactive checkout state |
86
+ | `FloPayCardSetupError` | `FloPayCardSetupError` | `FloPayCardSetupError` |
87
+ | `dropThirdPartyOnlyError` | `dropThirdPartyOnlyError` | `dropThirdPartyOnlyError` |
88
+
89
+ React `children` and custom layouts are slots. `FloPayCheckout`'s `layout` slot replaces the built-in form, and a `SplitCardForm` inside it receives the session, nonce and `submitLabel` unless it sets them itself.
90
+
91
+ Entry points: `@flopay/vue`, `@flopay/vue/card-setup` and `@flopay/vue/payment-method-setup`.
92
+
93
+ ## Errors
94
+
95
+ Errors are `FloPayError` instances from `@flopay/shared`, emitted through `@error`.
96
+
97
+ | Code | Meaning |
98
+ |------|---------|
99
+ | `UnsupportedBackendVaultCapability` | The session has no hosted vault card form and no other usable method. |
100
+ | `stored_payment_method_unsupported` | The buyer's saved method cannot be charged; ask for another method. |
101
+ | `MissingCheckoutSessionToken` | A session id was given without its `nonce`. |
102
+
103
+ Setup surfaces emit `FloPayCardSetupError`, whose `retryable` says whether trying again can help.