@rebilly/framepay-vue 12.267.8 → 13.0.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/CHANGELOG.md +2 -2
- package/README.md +63 -18
- package/dist/framepay-vue.js +207 -285
- package/dist/framepay-vue.umd.cjs +1 -1
- package/dist/index.d.ts +283 -0
- package/package.json +5 -5
- package/types/index.d.ts +0 -184
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -43,6 +43,7 @@ This is the repo for the official Vue.js wrapper for Rebilly's [FramePay](https:
|
|
|
43
43
|
- [Available Components and Methods](#available-components-and-methods)
|
|
44
44
|
- [Methods](#methods)
|
|
45
45
|
- [`createToken` Proxy Method](#createtoken-proxy-method)
|
|
46
|
+
- [`updateConfig` Method](#updateconfig-method)
|
|
46
47
|
- [The `Rebilly` Object](#the-rebilly-object)
|
|
47
48
|
- [Components](#components)
|
|
48
49
|
- [`RebillyForm`](#rebillyform)
|
|
@@ -185,9 +186,10 @@ app.use(FramePay, {}, { loader: () => framepayLoaded });
|
|
|
185
186
|
|
|
186
187
|
With a `loader`, `framepay-vue` injects no script and no stylesheet, and the components mount on the instance the loader resolves with.
|
|
187
188
|
|
|
188
|
-
- The loader is
|
|
189
|
+
- The plugin calls the loader when it is installed and keeps the instance it resolves with, however many times `app.use()` runs. As with the default loading, the first call wins: a loader passed to a later `app.use()` is ignored.
|
|
190
|
+
- A loader that rejected is called again by the next field that mounts or the next `createToken()` call, so a host that retries a failed load gets its fields back.
|
|
189
191
|
- The page initializes FramePay itself. Pass no `publishableKey` or `jwt` to `framepay-vue`: it only waits for FramePay's `ready` event, which FramePay also reports to listeners added after it fired, so the order of the host's `initialize()` and the loader does not matter.
|
|
190
|
-
- If the loader rejects, throws, or resolves with anything but the FramePay instance,
|
|
192
|
+
- If the loader rejects, throws, or resolves with anything but the FramePay instance, the fields waiting on it emit `error` with a `FramePayLoadError`, and `createToken()` rejects with it. A field without an `@error` listener leaves the failure as an unhandled rejection.
|
|
191
193
|
- A field created while FramePay is in a failed state, after an `initialize()` that failed and before a successful retry, stays unmounted. Recreate it once FramePay is ready.
|
|
192
194
|
|
|
193
195
|
### Usage
|
|
@@ -206,15 +208,16 @@ Two more components are also offered for convenience:
|
|
|
206
208
|
|
|
207
209
|
#### Google Pay and Apple Pay
|
|
208
210
|
|
|
209
|
-
`RebillyGooglePay` and `
|
|
211
|
+
`RebillyGooglePay`, `RebillyApplePay`, and `RebillyPaypal` are used like so:
|
|
210
212
|
|
|
211
213
|
```html
|
|
212
|
-
<rebilly-apple-pay @token-ready="handleToken" />
|
|
214
|
+
<rebilly-apple-pay @token-ready="handleToken" @error="onError" />
|
|
213
215
|
```
|
|
214
216
|
|
|
215
217
|
whereas:
|
|
216
218
|
|
|
217
219
|
- `@token-ready` is an event emitted once the payment token has been generated and its payload contains the token object.
|
|
220
|
+
- `@error` is emitted when FramePay fails to load or initialize, when the button fails to mount, or when a changed `configuration` cannot be applied. See [Events](#events).
|
|
218
221
|
|
|
219
222
|
#### With rebilly-form
|
|
220
223
|
|
|
@@ -241,7 +244,7 @@ The default behavior of `RebillyForm` is to intercept the regular submit event,
|
|
|
241
244
|
|
|
242
245
|
Any DOM attributes you attach to `RebillyForm` will automatically be passed to the base `form` element.
|
|
243
246
|
|
|
244
|
-
`@error` will expose the error message returned if the `Framepay.createToken()` request failed. You can inspect `error.message` and `error.code`.
|
|
247
|
+
`@error` will expose the error message returned if the `Framepay.createToken()` request failed. You can inspect `error.message` and `error.code`. `RebillyForm` also emits `error` when the update for its `configuration` prop fails: FramePay did not load or initialize, or rejected the update. Without an `@error` listener, a failed update is left as an unhandled rejection, as on the payment method components.
|
|
245
248
|
|
|
246
249
|
`@token-ready` will expose the token object, if a Google/Apple Pay element was mounted in the form.
|
|
247
250
|
|
|
@@ -399,11 +402,32 @@ It is possible to use `v-show` instead, which will allow you to preserve the use
|
|
|
399
402
|
|
|
400
403
|
#### `rebilly-form`
|
|
401
404
|
|
|
402
|
-
As covered above, `rebilly-form` emits `error` and `submit` events.
|
|
405
|
+
As covered above, `rebilly-form` emits `error` and `submit` events. `error` carries a failed `createToken()` on submit, or a failed update for the `configuration` prop; see [`updateConfig`](#updateconfig-method).
|
|
403
406
|
|
|
404
407
|
#### on payment method components
|
|
405
408
|
|
|
406
|
-
|
|
409
|
+
The card, bank account, and IBAN components emit the events of their FramePay field: `ready`, `change`, `focus` and `blur`.
|
|
410
|
+
|
|
411
|
+
They also emit `error` when FramePay fails to load or initialize, when the field fails to mount, or when the field's frame cannot connect, so it never becomes ready. The payload is a `FramePayLoadError`, `FramePayInitializeError`, `FramePayMountError`, or `FramePayElementError`. Each is an `Error` that the package exports, so `instanceof` tells them apart, and `cause` holds the underlying error, such as FramePay's own error for a `FramePayElementError`.
|
|
412
|
+
|
|
413
|
+
The Google Pay, Apple Pay, and PayPal components emit `token-ready` with the token, and `error` when FramePay fails to load or initialize, when the button fails to mount, or when a changed `configuration` cannot be applied. Their FramePay elements take no subscriptions, so they emit no field events.
|
|
414
|
+
|
|
415
|
+
```html
|
|
416
|
+
<rebilly-card-cvv @error="onFieldError" />
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
```javascript
|
|
420
|
+
import { FramePayLoadError } from '@rebilly/framepay-vue';
|
|
421
|
+
|
|
422
|
+
function onFieldError(error) {
|
|
423
|
+
if (error instanceof FramePayLoadError) {
|
|
424
|
+
// The FramePay script, or the host's loader, failed.
|
|
425
|
+
}
|
|
426
|
+
console.error(error, error.cause);
|
|
427
|
+
}
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
Without an `@error` listener, a component leaves the failure as an unhandled rejection, so it still reaches the console and your error tracking.
|
|
407
431
|
|
|
408
432
|
See details: https://www.rebilly.com/docs/dev-docs/element
|
|
409
433
|
|
|
@@ -433,11 +457,18 @@ See details: https://www.rebilly.com/docs/dev-docs/element
|
|
|
433
457
|
|
|
434
458
|
### Element IDs
|
|
435
459
|
|
|
436
|
-
|
|
460
|
+
A payment method component's element has no ID unless you pass `id` as a prop to `<rebilly-card>`, `<rebilly-bban-account-number>` etc. Pass one to connect a label: FramePay focuses the field when the `<label>` right before it, with a `for` that matches the ID, is clicked.
|
|
437
461
|
|
|
438
|
-
|
|
462
|
+
```html
|
|
463
|
+
<rebilly-form>
|
|
464
|
+
<label for="card-cvv">CVV</label>
|
|
465
|
+
<rebilly-card-cvv id="card-cvv" />
|
|
466
|
+
</rebilly-form>
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
The ID is only that of the element you mount FramePay to, so it does not interfere with the default or custom FramePay styling.
|
|
439
470
|
|
|
440
|
-
|
|
471
|
+
FramePay mounts each field on the component's own element rather than looking the ID up, so IDs need not be unique on the page. Two fields with the same ID, for example in two custom elements, each mount in their own place.
|
|
441
472
|
|
|
442
473
|
## Available Components and Methods
|
|
443
474
|
|
|
@@ -445,10 +476,24 @@ Because this will only change the ID of the element you are mounting Framepay to
|
|
|
445
476
|
|
|
446
477
|
#### `createToken` Proxy Method
|
|
447
478
|
|
|
448
|
-
`
|
|
479
|
+
`createToken()` simply wraps `Framepay.createToken()` in a promise to ensure that the Framepay script has loaded and the object is available. Be sure to import `createToken` from `@rebilly/framepay-vue` instead of using `Framepay.createToken()`, otherwise you may run into errors due to race conditions.
|
|
449
480
|
|
|
450
481
|
Again, you don't need to use `createToken` at all if you choose to use the `RebillyForm` component.
|
|
451
482
|
|
|
483
|
+
#### `updateConfig` Method
|
|
484
|
+
|
|
485
|
+
`updateConfig(configuration)` waits for Framepay to be ready, then returns `Framepay.update()` with a copy of the configuration, for example to change the locale or the amount of the mounted elements. The promise resolves once Framepay has accepted the configuration, and rejects when Framepay fails to initialize or rejects the update. It does not wait for the mounted elements to use the new configuration.
|
|
486
|
+
|
|
487
|
+
Updates are not queued: Framepay applies them in the order of the calls, so two `updateConfig()` calls in one tick both apply, the second on top of the first. A failed update does not stop the ones after it.
|
|
488
|
+
|
|
489
|
+
```javascript
|
|
490
|
+
import { updateConfig } from '@rebilly/framepay-vue';
|
|
491
|
+
|
|
492
|
+
await updateConfig({ locale: 'es-ES' });
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
`RebillyForm` calls `updateConfig()` when it mounts and when its `configuration` prop changes, unless the prop is missing or has no keys: such an update would change nothing, but Framepay would still set up its PayPal, Apple Pay and Klarna elements again. It emits `error` when the update fails. The Google Pay, Apple Pay, and PayPal components call `updateConfig()` when their `configuration` prop changes.
|
|
496
|
+
|
|
452
497
|
#### The `Framepay` Object
|
|
453
498
|
|
|
454
499
|
As mentioned above, Framepay will expose the `Framepay` object in the global namespace after it has loaded. We recommend that you never call the `Framepay` object directly, as `framepay-vue` is designed to either expose or abstract away all the methods you need to use Framepay.
|
|
@@ -463,7 +508,7 @@ RebillyForm accepts the following props:
|
|
|
463
508
|
|
|
464
509
|
- `@submit`
|
|
465
510
|
- `@error`
|
|
466
|
-
- the `configuration` object
|
|
511
|
+
- the `configuration` object, passed to [`updateConfig()`](#updateconfig-method) when the form mounts and whenever it changes, unless it has no keys
|
|
467
512
|
- `extraData` for passing additional information to `createToken()`
|
|
468
513
|
- any attributes from a standard HTML form will be passed properly
|
|
469
514
|
|
|
@@ -473,7 +518,7 @@ See: [Usage example](#with-rebilly-form)
|
|
|
473
518
|
|
|
474
519
|
RebillyToken accepts no arguments. It simply adds a hidden `<input>` element to the form, with the property `data-rebilly="token"` set.
|
|
475
520
|
|
|
476
|
-
See: [Source code](./src/components/RebillyToken.
|
|
521
|
+
See: [Source code](./src/components/RebillyToken.ts) and [Usage example](#with-rebilly-token)
|
|
477
522
|
|
|
478
523
|
#### Payment Method Components
|
|
479
524
|
|
|
@@ -507,9 +552,9 @@ These elements must all be mounted in the same form in order to successfully cre
|
|
|
507
552
|
|
|
508
553
|
Payment method components all accept the same props:
|
|
509
554
|
|
|
510
|
-
- `id
|
|
511
|
-
- `@ready`, `@change`, `@focus`, `@blur`
|
|
512
|
-
- the `configuration` object for initialization
|
|
555
|
+
- `id`, the ID of the element that contains the mounted field. The element has no ID without it.
|
|
556
|
+
- `@error`, and `@ready`, `@change`, `@focus`, `@blur` on the card, bank account, and IBAN components, or `@token-ready` on the wallets. See [Events](#events).
|
|
557
|
+
- the `configuration` object for initialization. The wallets also pass a changed `configuration` to `Framepay.update()`, for a new amount or button style; the card, bank account, and IBAN components read it only when they mount.
|
|
513
558
|
|
|
514
559
|
The card components (`RebillyCard`, `RebillyCardNumber`, `RebillyCardExpiration`, `RebillyCardCvv`) also accept:
|
|
515
560
|
|
|
@@ -521,7 +566,7 @@ The card components (`RebillyCard`, `RebillyCardNumber`, `RebillyCardExpiration`
|
|
|
521
566
|
|
|
522
567
|
##### The mounted element
|
|
523
568
|
|
|
524
|
-
Each payment method component keeps the FramePay element it mounted as its `element` property. It is `null` until the field has mounted and is set before `@ready` fires. Reach it through a template ref when you need a method of the element, such as `focus()` or `invalidate()`:
|
|
569
|
+
Each payment method component keeps the FramePay element it mounted as its `element` property. It is `null` until the field has mounted and is set before `@ready` fires. A field removed before FramePay is ready never mounts, so it leaves no element behind. A field removed later, while it is still loading or after it is ready, is destroyed when the component unmounts. Reach it through a template ref when you need a method of the element, such as `focus()` or `invalidate()`:
|
|
525
570
|
|
|
526
571
|
```html
|
|
527
572
|
<rebilly-card-cvv ref="cvv" @ready="$refs.cvv.element.focus()" />
|
|
@@ -537,7 +582,7 @@ See the element methods here: https://www.rebilly.com/docs/dev-docs/element
|
|
|
537
582
|
|
|
538
583
|
## TypeScript
|
|
539
584
|
|
|
540
|
-
The package ships declarations
|
|
585
|
+
The package is written in TypeScript and ships the declarations generated from its source: the plugin, the components with their props, events, and `element`, `createToken()`, `updateConfig()`, and the error classes. The FramePay types come from `@rebilly/framepay`, which is a dependency of this package.
|
|
541
586
|
|
|
542
587
|
```typescript
|
|
543
588
|
import FramePay, { RebillyCardCvv } from '@rebilly/framepay-vue';
|
package/dist/framepay-vue.js
CHANGED
|
@@ -1,64 +1,78 @@
|
|
|
1
|
-
import {
|
|
2
|
-
//#region src/errors.js
|
|
3
|
-
function s({ message: e = "Could not mount FramePay to element.", details: t = null } = {}) {
|
|
4
|
-
this.message = e, this.details = t, this.name = "FramePayMountError";
|
|
5
|
-
}
|
|
6
|
-
function c({ message: e = "FramePay could not be initialized.", details: t = null } = {}) {
|
|
7
|
-
this.message = e, this.details = t, this.name = "FramePayInitializeError";
|
|
8
|
-
}
|
|
9
|
-
function l({ message: e = "FramePay could not be loaded.", details: t = null } = {}) {
|
|
10
|
-
this.message = e, this.details = t, this.name = "FramePayLoadError";
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
13
|
-
//#region src/constants/links.js
|
|
14
|
-
var u = window.process?.env?.FRAMEPAY_SCRIPT_LINK;
|
|
15
|
-
window.process?.env?.FRAMEPAY_STYLE_LINK;
|
|
16
|
-
//#endregion
|
|
1
|
+
import { defineComponent as e, h as t, inject as n, markRaw as r, provide as i, withModifiers as a } from "vue";
|
|
17
2
|
//#region ../framepay-npm/dist/index.es.js
|
|
18
|
-
var
|
|
19
|
-
async function
|
|
3
|
+
var o = "https://framepay.rebilly.com/framepay.js", s = "https://framepay.rebilly.com/framepay.css";
|
|
4
|
+
async function c({ scriptLink: e, styleLink: t } = {}) {
|
|
20
5
|
return new Promise((n, r) => {
|
|
21
6
|
if (window.Framepay) n(window.Framepay);
|
|
22
7
|
else {
|
|
23
8
|
if (t !== "no-style-script") {
|
|
24
9
|
let e = document.createElement("link");
|
|
25
|
-
e.setAttribute("href", t ||
|
|
10
|
+
e.setAttribute("href", t || s), e.setAttribute("rel", "stylesheet"), document.head.prepend(e);
|
|
26
11
|
}
|
|
27
12
|
let i = document.createElement("script");
|
|
28
|
-
i.setAttribute("src", e ||
|
|
13
|
+
i.setAttribute("src", e || o), i.onload = () => n(window.Framepay), i.onerror = () => r(/* @__PURE__ */ Error("@rebilly/framepay npm package: Failed to load FramePay script")), document.head.append(i);
|
|
29
14
|
}
|
|
30
15
|
});
|
|
31
16
|
}
|
|
32
17
|
//#endregion
|
|
33
|
-
//#region src/
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
18
|
+
//#region src/errors.ts
|
|
19
|
+
var l = (e) => e === void 0 ? void 0 : { cause: e }, u = class extends Error {
|
|
20
|
+
constructor({ message: e = "FramePay could not be loaded.", cause: t } = {}) {
|
|
21
|
+
super(e, l(t)), this.name = "FramePayLoadError";
|
|
22
|
+
}
|
|
23
|
+
}, d = class extends Error {
|
|
24
|
+
constructor({ message: e = "FramePay could not be initialized.", cause: t } = {}) {
|
|
25
|
+
super(e, l(t)), this.name = "FramePayInitializeError";
|
|
26
|
+
}
|
|
27
|
+
}, f = class extends Error {
|
|
28
|
+
constructor({ message: e = "Could not mount FramePay to element.", cause: t } = {}) {
|
|
29
|
+
super(e, l(t)), this.name = "FramePayMountError";
|
|
30
|
+
}
|
|
31
|
+
}, p = class extends Error {
|
|
32
|
+
constructor({ message: e = "The FramePay field could not be loaded.", cause: t } = {}) {
|
|
33
|
+
super(e, l(t)), this.name = "FramePayElementError";
|
|
34
|
+
}
|
|
35
|
+
}, m = window.process?.env, h = m?.FRAMEPAY_SCRIPT_LINK;
|
|
36
|
+
m?.FRAMEPAY_STYLE_LINK;
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/install/load-script.ts
|
|
39
|
+
var g = (e) => {
|
|
40
|
+
throw new u({ cause: e });
|
|
41
|
+
}, _ = () => c({ scriptLink: h }).catch(g), v = (e) => {
|
|
42
|
+
if (typeof e?.on != "function") throw new u({ message: "The FramePay loader must resolve with the FramePay instance." });
|
|
38
43
|
return e;
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
}),
|
|
44
|
+
}, y = (e) => new Promise((t) => t(e())).catch(g).then(v), b = () => {}, x = new Promise((e) => {
|
|
45
|
+
b = e;
|
|
46
|
+
}), S = (e) => b(e), C = () => x.then((e) => typeof e == "function" ? y(e) : _()).catch((e) => {
|
|
47
|
+
throw w = null, e;
|
|
48
|
+
}), w = C(), T = () => (w ||= C(), w);
|
|
42
49
|
//#endregion
|
|
43
|
-
//#region src/helpers/initialize-framepay.
|
|
44
|
-
function
|
|
45
|
-
return
|
|
46
|
-
let
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
//#region src/helpers/initialize-framepay.ts
|
|
51
|
+
function E(e = {}) {
|
|
52
|
+
return T().then((t) => {
|
|
53
|
+
let n = () => {}, r = () => {};
|
|
54
|
+
return new Promise((i, a) => {
|
|
55
|
+
let o = !1;
|
|
56
|
+
n = () => {
|
|
57
|
+
i(t);
|
|
58
|
+
}, r = (e) => {
|
|
59
|
+
o = !0, a(new d({ cause: e }));
|
|
60
|
+
}, t.on("ready", n), t.on("error", r);
|
|
61
|
+
try {
|
|
62
|
+
!o && !t.initialized && (e.publishableKey || e.jwt) && t.initialize(e).catch((e) => {
|
|
63
|
+
a(new d({ cause: e }));
|
|
64
|
+
});
|
|
65
|
+
} catch (e) {
|
|
66
|
+
throw new d({ cause: e });
|
|
67
|
+
}
|
|
68
|
+
}).finally(() => {
|
|
69
|
+
t.off("ready", n), t.off("error", r);
|
|
51
70
|
});
|
|
52
|
-
|
|
53
|
-
!i && !t.initialized && (e.publishableKey || e.jwt) && t.initialize(e).catch((e) => {
|
|
54
|
-
r(new c({ details: e }));
|
|
55
|
-
});
|
|
56
|
-
} catch (e) {
|
|
57
|
-
throw new c({ details: e });
|
|
58
|
-
}
|
|
59
|
-
}));
|
|
71
|
+
});
|
|
60
72
|
}
|
|
61
|
-
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/constants/types.ts
|
|
75
|
+
var D = {
|
|
62
76
|
REBILLY_CARD: "card",
|
|
63
77
|
REBILLY_CARD_CVV: "cardCvv",
|
|
64
78
|
REBILLY_CARD_NUMBER: "cardNumber",
|
|
@@ -72,27 +86,132 @@ var C = {
|
|
|
72
86
|
REBILLY_PAYPAL: "paypal"
|
|
73
87
|
};
|
|
74
88
|
//#endregion
|
|
75
|
-
//#region src/helpers/
|
|
76
|
-
function
|
|
77
|
-
return
|
|
78
|
-
|
|
79
|
-
|
|
89
|
+
//#region src/helpers/update-config.ts
|
|
90
|
+
function O(e) {
|
|
91
|
+
return E(e).then((t) => t.update(e));
|
|
92
|
+
}
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/helpers/listeners.ts
|
|
95
|
+
function k(e, t) {
|
|
96
|
+
let n = `on${t.charAt(0).toUpperCase()}${t.slice(1)}`, r = e.$.vnode.props ?? {};
|
|
97
|
+
return !!(r[n] || r[`${n}Once`]);
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/helpers/report-error.ts
|
|
101
|
+
function A(e, t) {
|
|
102
|
+
if (!k(e, "error")) return Promise.reject(t);
|
|
103
|
+
e.$emit("error", t);
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region src/constants/injection-keys.ts
|
|
107
|
+
var j = Symbol("framepay-vue form token-ready"), M = [
|
|
108
|
+
D.REBILLY_GOOGLE_PAY,
|
|
109
|
+
D.REBILLY_APPLE_PAY,
|
|
110
|
+
D.REBILLY_PAYPAL
|
|
111
|
+
], N = (e) => M.includes(e);
|
|
112
|
+
function P(e, t, n, r) {
|
|
113
|
+
switch (t) {
|
|
114
|
+
case D.REBILLY_IBAN: return e.iban.mount(n);
|
|
115
|
+
case D.REBILLY_BBAN_ACCOUNT_TYPE:
|
|
116
|
+
case D.REBILLY_BBAN_ACCOUNT_NUMBER:
|
|
117
|
+
case D.REBILLY_BBAN_ROUTING_NUMBER: return e.bban.mount(n, t);
|
|
118
|
+
default: return e.card.mount(n, t, r);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function F(e, t, n) {
|
|
122
|
+
switch (t) {
|
|
123
|
+
case D.REBILLY_GOOGLE_PAY: return e.googlePay.mount(n);
|
|
124
|
+
case D.REBILLY_APPLE_PAY: return e.applePay.mount(n);
|
|
125
|
+
case D.REBILLY_PAYPAL: return e.paypal.mount(n);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function I(e) {
|
|
129
|
+
try {
|
|
130
|
+
return e();
|
|
131
|
+
} catch (e) {
|
|
132
|
+
throw new f({ cause: e });
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
var L = {
|
|
136
|
+
ready: () => !0,
|
|
137
|
+
change: () => !0,
|
|
138
|
+
focus: () => !0,
|
|
139
|
+
blur: () => !0,
|
|
140
|
+
error: () => !0
|
|
141
|
+
}, R = {
|
|
142
|
+
error: () => !0,
|
|
143
|
+
"token-ready": () => !0
|
|
144
|
+
};
|
|
145
|
+
function z(i, a) {
|
|
146
|
+
let o = N(a);
|
|
147
|
+
return e({
|
|
148
|
+
name: i,
|
|
149
|
+
render() {
|
|
150
|
+
return t("div", { id: this.id });
|
|
151
|
+
},
|
|
152
|
+
emits: o ? R : L,
|
|
153
|
+
props: {
|
|
154
|
+
id: { type: String },
|
|
155
|
+
configuration: { type: Object },
|
|
156
|
+
extraData: { type: Object }
|
|
157
|
+
},
|
|
158
|
+
setup() {
|
|
159
|
+
return { emitFormToken: n(j, null) };
|
|
160
|
+
},
|
|
161
|
+
data: () => ({
|
|
162
|
+
element: null,
|
|
163
|
+
isDestroyed: !1,
|
|
164
|
+
stopListeningForTokens: null
|
|
165
|
+
}),
|
|
166
|
+
methods: {
|
|
167
|
+
mountElement(e) {
|
|
168
|
+
E(this.configuration).then((t) => {
|
|
169
|
+
if (!this.isDestroyed) {
|
|
170
|
+
if (N(a)) this.element = r(I(() => F(t, a, e))), this.listenForTokens(t);
|
|
171
|
+
else {
|
|
172
|
+
let n = r(I(() => P(t, a, e, this.extraData)));
|
|
173
|
+
this.element = n, this.listenToField(n);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}).catch((e) => A(this, e));
|
|
177
|
+
},
|
|
178
|
+
listenToField(e) {
|
|
179
|
+
e.on("ready", () => this.$emit("ready")), e.on("change", (e) => this.$emit("change", e)), e.on("focus", () => this.$emit("focus")), e.on("blur", () => this.$emit("blur")), e.on("error", (e) => {
|
|
180
|
+
A(this, new p({ cause: e }));
|
|
181
|
+
});
|
|
182
|
+
},
|
|
183
|
+
listenForTokens(e) {
|
|
184
|
+
let t = (e) => {
|
|
185
|
+
this.$emit("token-ready", e), this.emitFormToken?.(e);
|
|
186
|
+
};
|
|
187
|
+
e.on("token-ready", t), this.stopListeningForTokens = () => e.off("token-ready", t);
|
|
188
|
+
},
|
|
189
|
+
destroyElement() {
|
|
190
|
+
this.isDestroyed = !0, this.stopListeningForTokens?.(), this.element && this.element.destroy();
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
watch: { configuration(e) {
|
|
194
|
+
o && e && O(e).catch((e) => A(this, e));
|
|
195
|
+
} },
|
|
196
|
+
mounted() {
|
|
197
|
+
this.mountElement(this.$el);
|
|
198
|
+
},
|
|
199
|
+
beforeUnmount() {
|
|
200
|
+
this.destroyElement();
|
|
201
|
+
}
|
|
80
202
|
});
|
|
81
203
|
}
|
|
82
204
|
//#endregion
|
|
83
|
-
//#region src/helpers/
|
|
84
|
-
function
|
|
85
|
-
return
|
|
86
|
-
|
|
205
|
+
//#region src/helpers/create-token.ts
|
|
206
|
+
function B(e, t) {
|
|
207
|
+
return T().then((n) => {
|
|
208
|
+
if (!n.initialized) throw new d({ message: "Please initialize Framepay before creating a token" });
|
|
209
|
+
return n.createToken(e, t);
|
|
87
210
|
});
|
|
88
211
|
}
|
|
89
212
|
//#endregion
|
|
90
|
-
//#region
|
|
91
|
-
var
|
|
92
|
-
let n = e.__vccOpts || e;
|
|
93
|
-
for (let [e, r] of t) n[e] = r;
|
|
94
|
-
return n;
|
|
95
|
-
}, D = {
|
|
213
|
+
//#region src/components/RebillyForm.ts
|
|
214
|
+
var V = e({
|
|
96
215
|
name: "RebillyForm",
|
|
97
216
|
props: {
|
|
98
217
|
extraData: {
|
|
@@ -104,243 +223,46 @@ var E = (e, t) => {
|
|
|
104
223
|
default: () => ({})
|
|
105
224
|
}
|
|
106
225
|
},
|
|
107
|
-
emits:
|
|
226
|
+
emits: {
|
|
227
|
+
submit: () => !0,
|
|
228
|
+
error: () => !0,
|
|
229
|
+
"token-ready": () => !0
|
|
230
|
+
},
|
|
231
|
+
setup(e, { emit: t }) {
|
|
232
|
+
i(j, (e) => t("token-ready", e));
|
|
233
|
+
},
|
|
108
234
|
watch: { configuration(e) {
|
|
109
|
-
|
|
235
|
+
this.updateConfiguration(e);
|
|
110
236
|
} },
|
|
111
237
|
mounted() {
|
|
112
|
-
|
|
113
|
-
},
|
|
114
|
-
methods: { handler(e) {
|
|
115
|
-
let t = e.target;
|
|
116
|
-
w(t, this.extraData).then((e) => {
|
|
117
|
-
this.$attrs.onSubmit ? this.$emit("submit", e, t) : t.submit();
|
|
118
|
-
}).catch((e) => {
|
|
119
|
-
this.$emit("error", e);
|
|
120
|
-
});
|
|
121
|
-
} }
|
|
122
|
-
}, O = { id: "stop-wrapper" };
|
|
123
|
-
function k(n, r, s, c, l, u) {
|
|
124
|
-
return i(), e("div", O, [t("form", {
|
|
125
|
-
id: "rebilly-form",
|
|
126
|
-
onSubmit: r[0] ||= o((...e) => u.handler && u.handler(...e), ["stop", "prevent"])
|
|
127
|
-
}, [a(n.$slots, "default")], 32)]);
|
|
128
|
-
}
|
|
129
|
-
var A = /*#__PURE__*/ E(D, [["render", k]]), j = { name: "RebillyToken" }, M = {
|
|
130
|
-
id: "rebilly-token",
|
|
131
|
-
"data-rebilly": "token",
|
|
132
|
-
type: "hidden"
|
|
133
|
-
};
|
|
134
|
-
function N(t, n, r, a, o, s) {
|
|
135
|
-
return i(), e("input", M);
|
|
136
|
-
}
|
|
137
|
-
var P = /*#__PURE__*/ E(j, [["render", N]]), F = {
|
|
138
|
-
render() {
|
|
139
|
-
return n("div", {
|
|
140
|
-
id: this.mountId,
|
|
141
|
-
domProps: { id: this.mountId }
|
|
142
|
-
});
|
|
143
|
-
},
|
|
144
|
-
props: {
|
|
145
|
-
id: { type: String },
|
|
146
|
-
configuration: {},
|
|
147
|
-
extraData: {
|
|
148
|
-
type: Object,
|
|
149
|
-
default: void 0
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
data() {
|
|
153
|
-
return {
|
|
154
|
-
element: null,
|
|
155
|
-
mountId: this.id ? this.id : `${this.$options.name}-mount`
|
|
156
|
-
};
|
|
238
|
+
this.updateConfiguration(this.configuration);
|
|
157
239
|
},
|
|
158
240
|
methods: {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
try {
|
|
162
|
-
this.elementType.startsWith("card") ? this.element = r(t.card.mount(e, this.elementType, this.extraData)) : this.elementType === "iban" ? this.element = r(t.iban.mount(e)) : [
|
|
163
|
-
C.REBILLY_BBAN_ACCOUNT_TYPE,
|
|
164
|
-
C.REBILLY_BBAN_ACCOUNT_NUMBER,
|
|
165
|
-
C.REBILLY_BBAN_ROUTING_NUMBER
|
|
166
|
-
].includes(this.elementType) && (this.element = r(t.bban.mount(e, this.elementType))), this.element.on("ready", () => this.$emit("ready")), this.element.on("change", (e) => this.$emit("change", e)), this.element.on("focus", () => this.$emit("focus")), this.element.on("blur", () => this.$emit("blur"));
|
|
167
|
-
} catch {
|
|
168
|
-
throw new s();
|
|
169
|
-
}
|
|
170
|
-
});
|
|
241
|
+
updateConfiguration(e) {
|
|
242
|
+
e && Object.keys(e).length > 0 && O(e).catch((e) => A(this, e));
|
|
171
243
|
},
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
},
|
|
179
|
-
beforeDestroy() {
|
|
180
|
-
this.destroyElement();
|
|
181
|
-
},
|
|
182
|
-
beforeUnmount() {
|
|
183
|
-
this.destroyElement();
|
|
184
|
-
}
|
|
185
|
-
}, I = {
|
|
186
|
-
render() {
|
|
187
|
-
return n("div", {
|
|
188
|
-
id: this.mountId,
|
|
189
|
-
domProps: { id: this.mountId }
|
|
190
|
-
});
|
|
191
|
-
},
|
|
192
|
-
props: {
|
|
193
|
-
id: { type: String },
|
|
194
|
-
configuration: {}
|
|
195
|
-
},
|
|
196
|
-
data() {
|
|
197
|
-
return {
|
|
198
|
-
element: null,
|
|
199
|
-
mountId: this.id ? this.id : `${this.$options.name}-mount`
|
|
200
|
-
};
|
|
201
|
-
},
|
|
202
|
-
methods: {
|
|
203
|
-
mountElement(e) {
|
|
204
|
-
S(this.configuration).then((t) => {
|
|
205
|
-
try {
|
|
206
|
-
this.element = r(t.googlePay.mount(e)), this.element.on("ready", () => this.$emit("ready")), this.element.on("change", (e) => this.$emit("change", e)), this.element.on("focus", () => this.$emit("focus")), this.element.on("blur", () => this.$emit("blur")), this.element.on("error", () => this.$emit("error")), t.on("token-ready", (e) => {
|
|
207
|
-
this.$emit("token-ready", e), this.$parent.$emit("token-ready", e);
|
|
208
|
-
});
|
|
209
|
-
} catch (e) {
|
|
210
|
-
throw new s({ details: e });
|
|
211
|
-
}
|
|
244
|
+
handler(e) {
|
|
245
|
+
let t = e.target;
|
|
246
|
+
B(t, this.extraData).then((e) => {
|
|
247
|
+
k(this, "submit") ? this.$emit("submit", e, t) : t.submit();
|
|
248
|
+
}).catch((e) => {
|
|
249
|
+
this.$emit("error", e);
|
|
212
250
|
});
|
|
213
|
-
},
|
|
214
|
-
destroyElement() {
|
|
215
|
-
this.element && this.element.destroy();
|
|
216
251
|
}
|
|
217
252
|
},
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
} },
|
|
221
|
-
created() {
|
|
222
|
-
this.mountElement(`#${this.mountId}`);
|
|
223
|
-
},
|
|
224
|
-
beforeDestroy() {
|
|
225
|
-
this.destroyElement();
|
|
226
|
-
},
|
|
227
|
-
beforeUnmount() {
|
|
228
|
-
this.destroyElement();
|
|
253
|
+
render() {
|
|
254
|
+
return t("form", { onSubmit: a(this.handler, ["stop", "prevent"]) }, this.$slots.default?.());
|
|
229
255
|
}
|
|
230
|
-
},
|
|
256
|
+
}), H = e({
|
|
257
|
+
name: "RebillyToken",
|
|
231
258
|
render() {
|
|
232
|
-
return
|
|
233
|
-
|
|
234
|
-
|
|
259
|
+
return t("input", {
|
|
260
|
+
"data-rebilly": "token",
|
|
261
|
+
type: "hidden"
|
|
235
262
|
});
|
|
236
|
-
},
|
|
237
|
-
props: {
|
|
238
|
-
id: { type: String },
|
|
239
|
-
configuration: {}
|
|
240
|
-
},
|
|
241
|
-
data() {
|
|
242
|
-
return {
|
|
243
|
-
element: null,
|
|
244
|
-
mountId: this.id ? this.id : `${this.$options.name}-mount`
|
|
245
|
-
};
|
|
246
|
-
},
|
|
247
|
-
methods: {
|
|
248
|
-
mountElement(e) {
|
|
249
|
-
S(this.configuration).then((t) => {
|
|
250
|
-
try {
|
|
251
|
-
let n = null;
|
|
252
|
-
this.elementType === C.REBILLY_APPLE_PAY ? n = t.applePay : this.elementType === C.REBILLY_PAYPAL && (n = t.paypal), this.element = r(n.mount(e)), t.on("token-ready", (e) => {
|
|
253
|
-
this.$emit("token-ready", e), this.$parent.$emit("token-ready", e);
|
|
254
|
-
});
|
|
255
|
-
} catch (e) {
|
|
256
|
-
throw new s({ details: e });
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
},
|
|
260
|
-
destroyElement() {
|
|
261
|
-
this.element && this.element.destroy();
|
|
262
|
-
}
|
|
263
|
-
},
|
|
264
|
-
watch: { configuration(e) {
|
|
265
|
-
e && T(e);
|
|
266
|
-
} },
|
|
267
|
-
created() {
|
|
268
|
-
this.mountElement(`#${this.mountId}`);
|
|
269
|
-
},
|
|
270
|
-
beforeDestroy() {
|
|
271
|
-
this.destroyElement();
|
|
272
|
-
},
|
|
273
|
-
beforeUnmount() {
|
|
274
|
-
this.destroyElement();
|
|
275
263
|
}
|
|
276
|
-
},
|
|
277
|
-
|
|
278
|
-
data() {
|
|
279
|
-
return { elementType: C.REBILLY_CARD };
|
|
280
|
-
},
|
|
281
|
-
mixins: [F]
|
|
282
|
-
}, z = {
|
|
283
|
-
name: "rebilly-card-cvv",
|
|
284
|
-
data() {
|
|
285
|
-
return { elementType: C.REBILLY_CARD_CVV };
|
|
286
|
-
},
|
|
287
|
-
mixins: [F]
|
|
288
|
-
}, B = {
|
|
289
|
-
name: "rebilly-card-expiration",
|
|
290
|
-
data() {
|
|
291
|
-
return { elementType: C.REBILLY_CARD_EXPIRATION };
|
|
292
|
-
},
|
|
293
|
-
mixins: [F]
|
|
294
|
-
}, V = {
|
|
295
|
-
name: "rebilly-card-number",
|
|
296
|
-
data() {
|
|
297
|
-
return { elementType: C.REBILLY_CARD_NUMBER };
|
|
298
|
-
},
|
|
299
|
-
mixins: [F]
|
|
300
|
-
}, H = {
|
|
301
|
-
name: "rebilly-bban-account-type",
|
|
302
|
-
data() {
|
|
303
|
-
return { elementType: C.REBILLY_BBAN_ACCOUNT_TYPE };
|
|
304
|
-
},
|
|
305
|
-
mixins: [F]
|
|
306
|
-
}, U = {
|
|
307
|
-
name: "rebilly-bban-routing-number",
|
|
308
|
-
data() {
|
|
309
|
-
return { elementType: C.REBILLY_BBAN_ROUTING_NUMBER };
|
|
310
|
-
},
|
|
311
|
-
mixins: [F]
|
|
312
|
-
}, W = {
|
|
313
|
-
name: "rebilly-bban-account-number",
|
|
314
|
-
data() {
|
|
315
|
-
return { elementType: C.REBILLY_BBAN_ACCOUNT_NUMBER };
|
|
316
|
-
},
|
|
317
|
-
mixins: [F]
|
|
318
|
-
}, G = {
|
|
319
|
-
name: "rebilly-iban",
|
|
320
|
-
data() {
|
|
321
|
-
return { elementType: C.REBILLY_IBAN };
|
|
322
|
-
},
|
|
323
|
-
mixins: [F]
|
|
324
|
-
}, K = {
|
|
325
|
-
name: "rebilly-google-pay",
|
|
326
|
-
data() {
|
|
327
|
-
return { elementType: C.REBILLY_GOOGLE_PAY };
|
|
328
|
-
},
|
|
329
|
-
mixins: [I]
|
|
330
|
-
}, q = {
|
|
331
|
-
name: "rebilly-apple-pay",
|
|
332
|
-
data() {
|
|
333
|
-
return { elementType: C.REBILLY_APPLE_PAY };
|
|
334
|
-
},
|
|
335
|
-
mixins: [L]
|
|
336
|
-
}, J = {
|
|
337
|
-
name: "rebilly-paypal",
|
|
338
|
-
data() {
|
|
339
|
-
return { elementType: C.REBILLY_PAYPAL };
|
|
340
|
-
},
|
|
341
|
-
mixins: [L]
|
|
342
|
-
}, Y = { install(e, t = {}, n = {}) {
|
|
343
|
-
b(n?.loader), S(t).catch(() => {});
|
|
264
|
+
}), U = z("rebilly-card", D.REBILLY_CARD), W = z("rebilly-card-cvv", D.REBILLY_CARD_CVV), G = z("rebilly-card-expiration", D.REBILLY_CARD_EXPIRATION), K = z("rebilly-card-number", D.REBILLY_CARD_NUMBER), q = z("rebilly-bban-account-type", D.REBILLY_BBAN_ACCOUNT_TYPE), J = z("rebilly-bban-routing-number", D.REBILLY_BBAN_ROUTING_NUMBER), Y = z("rebilly-bban-account-number", D.REBILLY_BBAN_ACCOUNT_NUMBER), X = z("rebilly-iban", D.REBILLY_IBAN), Z = z("rebilly-google-pay", D.REBILLY_GOOGLE_PAY), Q = z("rebilly-apple-pay", D.REBILLY_APPLE_PAY), $ = z("rebilly-paypal", D.REBILLY_PAYPAL), ee = { install(e, t = {}, n = {}) {
|
|
265
|
+
S(n?.loader), E(t).catch(() => {});
|
|
344
266
|
} };
|
|
345
267
|
//#endregion
|
|
346
|
-
export {
|
|
268
|
+
export { p as FramePayElementError, d as FramePayInitializeError, u as FramePayLoadError, f as FramePayMountError, Q as RebillyApplePay, Y as RebillyBbanAccountNumber, q as RebillyBbanAccountType, J as RebillyBbanRoutingNumber, U as RebillyCard, W as RebillyCardCvv, G as RebillyCardExpiration, K as RebillyCardNumber, D as RebillyFieldTypes, V as RebillyForm, Z as RebillyGooglePay, X as RebillyIban, $ as RebillyPaypal, H as RebillyToken, B as createToken, ee as default, O as updateConfig };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("vue")):typeof define==`function`&&define.amd?define([`exports`,`vue`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.FramePayVue={},e.Vue))})(this,function(e,t){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("vue")):typeof define==`function`&&define.amd?define([`exports`,`vue`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.FramePayVue={},e.Vue))})(this,function(e,t){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var n=`https://framepay.rebilly.com/framepay.js`,r=`https://framepay.rebilly.com/framepay.css`;async function i({scriptLink:e,styleLink:t}={}){return new Promise((i,a)=>{if(window.Framepay)i(window.Framepay);else{if(t!==`no-style-script`){let e=document.createElement(`link`);e.setAttribute(`href`,t||r),e.setAttribute(`rel`,`stylesheet`),document.head.prepend(e)}let o=document.createElement(`script`);o.setAttribute(`src`,e||n),o.onload=()=>i(window.Framepay),o.onerror=()=>a(Error(`@rebilly/framepay npm package: Failed to load FramePay script`)),document.head.append(o)}})}var a=e=>e===void 0?void 0:{cause:e},o=class extends Error{constructor({message:e=`FramePay could not be loaded.`,cause:t}={}){super(e,a(t)),this.name=`FramePayLoadError`}},s=class extends Error{constructor({message:e=`FramePay could not be initialized.`,cause:t}={}){super(e,a(t)),this.name=`FramePayInitializeError`}},c=class extends Error{constructor({message:e=`Could not mount FramePay to element.`,cause:t}={}){super(e,a(t)),this.name=`FramePayMountError`}},l=class extends Error{constructor({message:e=`The FramePay field could not be loaded.`,cause:t}={}){super(e,a(t)),this.name=`FramePayElementError`}},u=window.process?.env,d=u?.FRAMEPAY_SCRIPT_LINK;u?.FRAMEPAY_STYLE_LINK;var f=e=>{throw new o({cause:e})},p=()=>i({scriptLink:d}).catch(f),m=e=>{if(typeof e?.on!=`function`)throw new o({message:`The FramePay loader must resolve with the FramePay instance.`});return e},h=e=>new Promise(t=>t(e())).catch(f).then(m),g=()=>{},_=new Promise(e=>{g=e}),v=e=>g(e),y=()=>_.then(e=>typeof e==`function`?h(e):p()).catch(e=>{throw b=null,e}),b=y(),x=()=>(b||=y(),b);function S(e={}){return x().then(t=>{let n=()=>{},r=()=>{};return new Promise((i,a)=>{let o=!1;n=()=>{i(t)},r=e=>{o=!0,a(new s({cause:e}))},t.on(`ready`,n),t.on(`error`,r);try{!o&&!t.initialized&&(e.publishableKey||e.jwt)&&t.initialize(e).catch(e=>{a(new s({cause:e}))})}catch(e){throw new s({cause:e})}}).finally(()=>{t.off(`ready`,n),t.off(`error`,r)})})}var C={REBILLY_CARD:`card`,REBILLY_CARD_CVV:`cardCvv`,REBILLY_CARD_NUMBER:`cardNumber`,REBILLY_CARD_EXPIRATION:`cardExpiration`,REBILLY_BBAN_ACCOUNT_TYPE:`accountType`,REBILLY_BBAN_ROUTING_NUMBER:`routingNumber`,REBILLY_BBAN_ACCOUNT_NUMBER:`accountNumber`,REBILLY_IBAN:`iban`,REBILLY_GOOGLE_PAY:`googlePay`,REBILLY_APPLE_PAY:`applePay`,REBILLY_PAYPAL:`paypal`};function w(e){return S(e).then(t=>t.update(e))}function T(e,t){let n=`on${t.charAt(0).toUpperCase()}${t.slice(1)}`,r=e.$.vnode.props??{};return!!(r[n]||r[`${n}Once`])}function E(e,t){if(!T(e,`error`))return Promise.reject(t);e.$emit(`error`,t)}var D=Symbol(`framepay-vue form token-ready`),O=[C.REBILLY_GOOGLE_PAY,C.REBILLY_APPLE_PAY,C.REBILLY_PAYPAL],k=e=>O.includes(e);function A(e,t,n,r){switch(t){case C.REBILLY_IBAN:return e.iban.mount(n);case C.REBILLY_BBAN_ACCOUNT_TYPE:case C.REBILLY_BBAN_ACCOUNT_NUMBER:case C.REBILLY_BBAN_ROUTING_NUMBER:return e.bban.mount(n,t);default:return e.card.mount(n,t,r)}}function j(e,t,n){switch(t){case C.REBILLY_GOOGLE_PAY:return e.googlePay.mount(n);case C.REBILLY_APPLE_PAY:return e.applePay.mount(n);case C.REBILLY_PAYPAL:return e.paypal.mount(n)}}function M(e){try{return e()}catch(e){throw new c({cause:e})}}var N={ready:()=>!0,change:()=>!0,focus:()=>!0,blur:()=>!0,error:()=>!0},P={error:()=>!0,"token-ready":()=>!0};function F(e,n){let r=k(n);return(0,t.defineComponent)({name:e,render(){return(0,t.h)(`div`,{id:this.id})},emits:r?P:N,props:{id:{type:String},configuration:{type:Object},extraData:{type:Object}},setup(){return{emitFormToken:(0,t.inject)(D,null)}},data:()=>({element:null,isDestroyed:!1,stopListeningForTokens:null}),methods:{mountElement(e){S(this.configuration).then(r=>{if(!this.isDestroyed){if(k(n))this.element=(0,t.markRaw)(M(()=>j(r,n,e))),this.listenForTokens(r);else{let i=(0,t.markRaw)(M(()=>A(r,n,e,this.extraData)));this.element=i,this.listenToField(i)}}}).catch(e=>E(this,e))},listenToField(e){e.on(`ready`,()=>this.$emit(`ready`)),e.on(`change`,e=>this.$emit(`change`,e)),e.on(`focus`,()=>this.$emit(`focus`)),e.on(`blur`,()=>this.$emit(`blur`)),e.on(`error`,e=>{E(this,new l({cause:e}))})},listenForTokens(e){let t=e=>{this.$emit(`token-ready`,e),this.emitFormToken?.(e)};e.on(`token-ready`,t),this.stopListeningForTokens=()=>e.off(`token-ready`,t)},destroyElement(){this.isDestroyed=!0,this.stopListeningForTokens?.(),this.element&&this.element.destroy()}},watch:{configuration(e){r&&e&&w(e).catch(e=>E(this,e))}},mounted(){this.mountElement(this.$el)},beforeUnmount(){this.destroyElement()}})}function I(e,t){return x().then(n=>{if(!n.initialized)throw new s({message:`Please initialize Framepay before creating a token`});return n.createToken(e,t)})}var L=(0,t.defineComponent)({name:`RebillyForm`,props:{extraData:{type:Object,default:()=>({})},configuration:{type:Object,default:()=>({})}},emits:{submit:()=>!0,error:()=>!0,"token-ready":()=>!0},setup(e,{emit:n}){(0,t.provide)(D,e=>n(`token-ready`,e))},watch:{configuration(e){this.updateConfiguration(e)}},mounted(){this.updateConfiguration(this.configuration)},methods:{updateConfiguration(e){e&&Object.keys(e).length>0&&w(e).catch(e=>E(this,e))},handler(e){let t=e.target;I(t,this.extraData).then(e=>{T(this,`submit`)?this.$emit(`submit`,e,t):t.submit()}).catch(e=>{this.$emit(`error`,e)})}},render(){return(0,t.h)(`form`,{onSubmit:(0,t.withModifiers)(this.handler,[`stop`,`prevent`])},this.$slots.default?.())}}),R=(0,t.defineComponent)({name:`RebillyToken`,render(){return(0,t.h)(`input`,{"data-rebilly":`token`,type:`hidden`})}}),z=F(`rebilly-card`,C.REBILLY_CARD),B=F(`rebilly-card-cvv`,C.REBILLY_CARD_CVV),V=F(`rebilly-card-expiration`,C.REBILLY_CARD_EXPIRATION),H=F(`rebilly-card-number`,C.REBILLY_CARD_NUMBER),U=F(`rebilly-bban-account-type`,C.REBILLY_BBAN_ACCOUNT_TYPE),W=F(`rebilly-bban-routing-number`,C.REBILLY_BBAN_ROUTING_NUMBER),G=F(`rebilly-bban-account-number`,C.REBILLY_BBAN_ACCOUNT_NUMBER),K=F(`rebilly-iban`,C.REBILLY_IBAN),q=F(`rebilly-google-pay`,C.REBILLY_GOOGLE_PAY),J=F(`rebilly-apple-pay`,C.REBILLY_APPLE_PAY),Y=F(`rebilly-paypal`,C.REBILLY_PAYPAL);e.FramePayElementError=l,e.FramePayInitializeError=s,e.FramePayLoadError=o,e.FramePayMountError=c,e.RebillyApplePay=J,e.RebillyBbanAccountNumber=G,e.RebillyBbanAccountType=U,e.RebillyBbanRoutingNumber=W,e.RebillyCard=z,e.RebillyCardCvv=B,e.RebillyCardExpiration=V,e.RebillyCardNumber=H,e.RebillyFieldTypes=C,e.RebillyForm=L,e.RebillyGooglePay=q,e.RebillyIban=K,e.RebillyPaypal=Y,e.RebillyToken=R,e.createToken=I,e.default={install(e,t={},n={}){v(n?.loader),S(t).catch(()=>{})}},e.updateConfig=w});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
import { ApplePayElement } from '@rebilly/framepay';
|
|
3
|
+
import { BankElement } from '@rebilly/framepay';
|
|
4
|
+
import { CardElement } from '@rebilly/framepay';
|
|
5
|
+
import { ComponentOptionsMixin } from 'vue';
|
|
6
|
+
import { ComponentProvideOptions } from 'vue';
|
|
7
|
+
import { DefineComponent } from 'vue';
|
|
8
|
+
import { EmitsOptions } from 'vue';
|
|
9
|
+
import { FieldExtraData } from '@rebilly/framepay';
|
|
10
|
+
import { FramePay } from '@rebilly/framepay';
|
|
11
|
+
import { FramepayError } from '@rebilly/framepay';
|
|
12
|
+
import { FramepayInitializeParams } from '@rebilly/framepay';
|
|
13
|
+
import { GooglePayElement } from '@rebilly/framepay';
|
|
14
|
+
import { IbanElement } from '@rebilly/framepay';
|
|
15
|
+
import { IframeElementEventMap } from '@rebilly/framepay';
|
|
16
|
+
import { PayPalElement } from '@rebilly/framepay';
|
|
17
|
+
import { PublicProps } from 'vue';
|
|
18
|
+
import { Raw } from 'vue';
|
|
19
|
+
import { TokenData } from '@rebilly/framepay';
|
|
20
|
+
import { ExtraData as TokenExtraData } from '@rebilly/framepay';
|
|
21
|
+
|
|
22
|
+
export declare type ApplePayComponent = FieldComponent<FieldProps, ApplePayElement, WalletEmits>;
|
|
23
|
+
|
|
24
|
+
export declare type BbanFieldComponent = FieldComponent<FieldProps, BankElement, FieldEmits>;
|
|
25
|
+
|
|
26
|
+
export declare type CardFieldComponent = FieldComponent<CardFieldProps, CardElement, FieldEmits>;
|
|
27
|
+
|
|
28
|
+
export declare interface CardFieldProps extends FieldProps {
|
|
29
|
+
/**
|
|
30
|
+
* Forwarded to `Framepay.card.mount()`, for example `{ cardType }`. Read once
|
|
31
|
+
* when the field mounts; recreate the component to change it.
|
|
32
|
+
*/
|
|
33
|
+
extraData?: FieldExtraData;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Waits for FramePay to load, then calls `Framepay.createToken()`. Rejects
|
|
38
|
+
* with a `FramePayLoadError` or `FramePayInitializeError` when FramePay is not
|
|
39
|
+
* loaded or not initialized, and otherwise with FramePay's own error.
|
|
40
|
+
*/
|
|
41
|
+
export declare function createToken(form: Element | object | null, extraData?: CreateTokenExtraData): Promise<TokenData>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Extra data for `createToken()`. FramePay's `ExtraData` lists the known keys
|
|
45
|
+
* and takes any other key, so any object is accepted here.
|
|
46
|
+
*/
|
|
47
|
+
export declare type CreateTokenExtraData = TokenExtraData | Record<string, unknown>;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Vue's object `emits` option for an emits interface: a validator per event,
|
|
51
|
+
* typed by the event's payload, so that `$emit()` is checked against it.
|
|
52
|
+
*/
|
|
53
|
+
export declare type EmitsOption<Emits> = {
|
|
54
|
+
[Event in keyof Emits]: Emits[Event] extends (...args: infer Payload) => void ? (...args: Payload) => boolean : never;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/** The payload of a field's `change` event. */
|
|
58
|
+
export declare type FieldChangeEvent = IframeElementEventMap['change'][0];
|
|
59
|
+
|
|
60
|
+
export declare type FieldComponent<Props, Element, Emits extends EmitsOptions> = DefineComponent<Props, {}, FieldInstance<Element>, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Emits>;
|
|
61
|
+
|
|
62
|
+
/** The events of the card, bank account, and IBAN components. */
|
|
63
|
+
export declare type FieldEmits = {
|
|
64
|
+
ready: () => void;
|
|
65
|
+
change: (event: FieldChangeEvent) => void;
|
|
66
|
+
focus: () => void;
|
|
67
|
+
blur: () => void;
|
|
68
|
+
/**
|
|
69
|
+
* FramePay failed to load or initialize, the field failed to mount, or the
|
|
70
|
+
* field's frame could not connect. Without a listener, the failure is left
|
|
71
|
+
* as an unhandled rejection.
|
|
72
|
+
*/
|
|
73
|
+
error: (error: FramePayVueError) => void;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export { FieldExtraData }
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The mounted FramePay element, `null` until the field has mounted. Set
|
|
80
|
+
* before the `ready` event, so it is available from `@ready` on. Marked raw,
|
|
81
|
+
* as the component stores it.
|
|
82
|
+
*/
|
|
83
|
+
export declare interface FieldInstance<Element> {
|
|
84
|
+
readonly element: Raw<Element> | null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export declare interface FieldProps {
|
|
88
|
+
/**
|
|
89
|
+
* The id of the element FramePay mounts into. The element has no id
|
|
90
|
+
* without one. FramePay focuses the field when the `<label>` right before
|
|
91
|
+
* it, with a `for` that matches this id, is clicked. FramePay mounts on the
|
|
92
|
+
* element itself, so the id need not be unique on the page.
|
|
93
|
+
*/
|
|
94
|
+
id?: string;
|
|
95
|
+
/** Initializes FramePay when the plugin was not given a key. */
|
|
96
|
+
configuration?: FramepayInitializeParams;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export { FramePay }
|
|
100
|
+
|
|
101
|
+
declare const FramePay_2: FramePayPlugin;
|
|
102
|
+
export default FramePay_2;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The mounted FramePay element reported an error, such as a field frame that
|
|
106
|
+
* could not connect. `cause` is FramePay's error.
|
|
107
|
+
*/
|
|
108
|
+
export declare class FramePayElementError extends Error {
|
|
109
|
+
name: "FramePayElementError";
|
|
110
|
+
constructor({ message, cause, }?: FramePayVueErrorOptions);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export { FramepayError }
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* `Framepay.initialize()` failed, FramePay reported an error before it was
|
|
117
|
+
* ready, or `createToken()` was called before FramePay was initialized.
|
|
118
|
+
*/
|
|
119
|
+
export declare class FramePayInitializeError extends Error {
|
|
120
|
+
name: "FramePayInitializeError";
|
|
121
|
+
constructor({ message, cause, }?: FramePayVueErrorOptions);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export { FramepayInitializeParams }
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Loads FramePay on behalf of framepay-vue and resolves with the page's
|
|
128
|
+
* FramePay instance. framepay-vue then injects no script or stylesheet.
|
|
129
|
+
*/
|
|
130
|
+
export declare type FramePayLoader = () => Promise<FramePay>;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* FramePay could not be loaded: the script failed to load, or the host
|
|
134
|
+
* `loader` rejected, threw, or resolved with no FramePay instance.
|
|
135
|
+
*/
|
|
136
|
+
export declare class FramePayLoadError extends Error {
|
|
137
|
+
name: "FramePayLoadError";
|
|
138
|
+
constructor({ message, cause, }?: FramePayVueErrorOptions);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** FramePay threw when the field was mounted. */
|
|
142
|
+
export declare class FramePayMountError extends Error {
|
|
143
|
+
name: "FramePayMountError";
|
|
144
|
+
constructor({ message, cause, }?: FramePayVueErrorOptions);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export declare interface FramePayPlugin {
|
|
148
|
+
/**
|
|
149
|
+
* @param configuration FramePay initialization options. Leave out the
|
|
150
|
+
* publishable key and JWT when the host initializes FramePay itself.
|
|
151
|
+
* @param options `loader` hands FramePay loading to the host.
|
|
152
|
+
*/
|
|
153
|
+
install(app: App, configuration?: FramepayInitializeParams, options?: FramePayPluginOptions): void;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export declare interface FramePayPluginOptions {
|
|
157
|
+
loader?: FramePayLoader;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* A failure of framepay-vue itself: the payload of a payment method
|
|
162
|
+
* component's `error` event, and a rejection of `createToken()` before
|
|
163
|
+
* FramePay is called. Each is an `Error`; tell them apart with `instanceof`
|
|
164
|
+
* or `name`. `cause` holds the underlying error, if any.
|
|
165
|
+
*/
|
|
166
|
+
export declare type FramePayVueError = FramePayLoadError | FramePayInitializeError | FramePayMountError | FramePayElementError;
|
|
167
|
+
|
|
168
|
+
export declare interface FramePayVueErrorOptions {
|
|
169
|
+
/** Replaces the default message. */
|
|
170
|
+
message?: string;
|
|
171
|
+
/** The underlying error. */
|
|
172
|
+
cause?: unknown;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export declare type GooglePayComponent = FieldComponent<FieldProps, GooglePayElement, GooglePayEmits>;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Google Pay emits the same events as the other wallets. FramePay's Google
|
|
179
|
+
* Pay element takes no subscriptions, so there are no field events.
|
|
180
|
+
*/
|
|
181
|
+
export declare type GooglePayEmits = WalletEmits;
|
|
182
|
+
|
|
183
|
+
export declare type IbanFieldComponent = FieldComponent<FieldProps, IbanElement, FieldEmits>;
|
|
184
|
+
|
|
185
|
+
export declare type PaypalComponent = FieldComponent<FieldProps, PayPalElement, WalletEmits>;
|
|
186
|
+
|
|
187
|
+
export declare const RebillyApplePay: ApplePayComponent;
|
|
188
|
+
|
|
189
|
+
export declare const RebillyBbanAccountNumber: BbanFieldComponent;
|
|
190
|
+
|
|
191
|
+
export declare const RebillyBbanAccountType: BbanFieldComponent;
|
|
192
|
+
|
|
193
|
+
export declare const RebillyBbanRoutingNumber: BbanFieldComponent;
|
|
194
|
+
|
|
195
|
+
export declare const RebillyCard: CardFieldComponent;
|
|
196
|
+
|
|
197
|
+
export declare const RebillyCardCvv: CardFieldComponent;
|
|
198
|
+
|
|
199
|
+
export declare const RebillyCardExpiration: CardFieldComponent;
|
|
200
|
+
|
|
201
|
+
export declare const RebillyCardNumber: CardFieldComponent;
|
|
202
|
+
|
|
203
|
+
export declare const RebillyFieldTypes: {
|
|
204
|
+
readonly REBILLY_CARD: "card";
|
|
205
|
+
readonly REBILLY_CARD_CVV: "cardCvv";
|
|
206
|
+
readonly REBILLY_CARD_NUMBER: "cardNumber";
|
|
207
|
+
readonly REBILLY_CARD_EXPIRATION: "cardExpiration";
|
|
208
|
+
readonly REBILLY_BBAN_ACCOUNT_TYPE: "accountType";
|
|
209
|
+
readonly REBILLY_BBAN_ROUTING_NUMBER: "routingNumber";
|
|
210
|
+
readonly REBILLY_BBAN_ACCOUNT_NUMBER: "accountNumber";
|
|
211
|
+
readonly REBILLY_IBAN: "iban";
|
|
212
|
+
readonly REBILLY_GOOGLE_PAY: "googlePay";
|
|
213
|
+
readonly REBILLY_APPLE_PAY: "applePay";
|
|
214
|
+
readonly REBILLY_PAYPAL: "paypal";
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
export declare const RebillyForm: RebillyFormComponent;
|
|
218
|
+
|
|
219
|
+
declare type RebillyFormComponent = DefineComponent<RebillyFormProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, RebillyFormEmits>;
|
|
220
|
+
|
|
221
|
+
export declare type RebillyFormEmits = {
|
|
222
|
+
/**
|
|
223
|
+
* The token is created. With a listener, the form is not submitted: submit
|
|
224
|
+
* it yourself, or send the token another way. Without one, the form
|
|
225
|
+
* submits with the token in its `<rebilly-token>` input.
|
|
226
|
+
*/
|
|
227
|
+
submit: (token: TokenData, form: HTMLFormElement) => void;
|
|
228
|
+
/**
|
|
229
|
+
* `createToken()` failed on submit, or the `updateConfig()` call for
|
|
230
|
+
* `configuration` failed: FramePay did not load or initialize, or rejected
|
|
231
|
+
* the update. Without a listener, a failed update is left as an unhandled
|
|
232
|
+
* rejection.
|
|
233
|
+
*/
|
|
234
|
+
error: (error: FramepayError | FramePayVueError) => void;
|
|
235
|
+
/** A token from a Google Pay, Apple Pay, or PayPal component inside the form. */
|
|
236
|
+
'token-ready': (token: TokenData) => void;
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
export declare interface RebillyFormProps {
|
|
240
|
+
/** Passed to `createToken()` on submit. */
|
|
241
|
+
extraData?: CreateTokenExtraData;
|
|
242
|
+
/**
|
|
243
|
+
* Passed to `updateConfig()` when the form mounts and whenever it changes,
|
|
244
|
+
* unless it has no keys.
|
|
245
|
+
*/
|
|
246
|
+
configuration?: FramepayInitializeParams;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export declare const RebillyGooglePay: GooglePayComponent;
|
|
250
|
+
|
|
251
|
+
export declare const RebillyIban: IbanFieldComponent;
|
|
252
|
+
|
|
253
|
+
export declare const RebillyPaypal: PaypalComponent;
|
|
254
|
+
|
|
255
|
+
/** A hidden input that `createToken()` fills with the token's id. */
|
|
256
|
+
export declare const RebillyToken: DefineComponent< {}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
257
|
+
|
|
258
|
+
export { TokenData }
|
|
259
|
+
|
|
260
|
+
export { TokenExtraData }
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Waits for FramePay to be ready, then returns `Framepay.update()`: the
|
|
264
|
+
* promise resolves once FramePay has accepted the update and rejects with
|
|
265
|
+
* FramePay's error, or with the initialization failure. Not queued: FramePay
|
|
266
|
+
* applies concurrent updates in call order itself, so two calls in one tick
|
|
267
|
+
* both apply. Not copied: FramePay copies the configuration as soon as it is
|
|
268
|
+
* called, so a reactive object is safe to pass.
|
|
269
|
+
*/
|
|
270
|
+
export declare function updateConfig(configuration: FramepayInitializeParams): Promise<void>;
|
|
271
|
+
|
|
272
|
+
/** The events of the Google Pay, Apple Pay, and PayPal components. */
|
|
273
|
+
export declare type WalletEmits = {
|
|
274
|
+
/**
|
|
275
|
+
* FramePay failed to load or initialize, the button failed to mount, or
|
|
276
|
+
* the `updateConfig()` call for a changed `configuration` failed. Without
|
|
277
|
+
* a listener, the failure is left as an unhandled rejection.
|
|
278
|
+
*/
|
|
279
|
+
error: (error: FramePayVueError) => void;
|
|
280
|
+
'token-ready': (token: TokenData) => void;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
export { }
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebilly/framepay-vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "13.0.1",
|
|
5
5
|
"description": "Official Vue wrapper for Rebilly FramePay",
|
|
6
6
|
"author": "Rebilly",
|
|
7
7
|
"repository": {
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"url": "https://github.com/Rebilly/rebilly"
|
|
10
10
|
},
|
|
11
11
|
"license": "MIT",
|
|
12
|
-
"types": "./
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
|
-
"types": "./
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
16
|
"import": "./dist/framepay-vue.js",
|
|
17
17
|
"require": "./dist/framepay-vue.umd.cjs",
|
|
18
18
|
"default": "./dist/framepay-vue.js"
|
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
22
|
"dist",
|
|
23
|
-
"types",
|
|
24
23
|
"CHANGELOG.md"
|
|
25
24
|
],
|
|
26
25
|
"keywords": [
|
|
@@ -49,13 +48,14 @@
|
|
|
49
48
|
"jsdom": "^24.0.0",
|
|
50
49
|
"typescript": "^6.0.3",
|
|
51
50
|
"vite": "^8.3.3",
|
|
51
|
+
"vite-plugin-dts": "^4.5.0",
|
|
52
52
|
"vite-plugin-mkcert": "^1.17.8",
|
|
53
53
|
"vitest": "^5.0.5",
|
|
54
54
|
"vue": "3.5.44"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"dev": "vite",
|
|
58
|
-
"build": "vite build",
|
|
58
|
+
"build": "vite build && tsc -p tests/types/check-build-types.tsconfig.json",
|
|
59
59
|
"type:check": "tsc --noEmit -p tsconfig.json",
|
|
60
60
|
"type:check:e2e": "tsc --noEmit -p tsconfig.e2e.json",
|
|
61
61
|
"test:unit": "vitest run",
|
package/types/index.d.ts
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import type { App, ComponentOptionsMixin, DefineComponent, Raw } from 'vue';
|
|
2
|
-
import type {
|
|
3
|
-
ApplePayElement,
|
|
4
|
-
BankElement,
|
|
5
|
-
CardElement,
|
|
6
|
-
ExtraData as TokenExtraData,
|
|
7
|
-
FieldExtraData,
|
|
8
|
-
FramePay,
|
|
9
|
-
FramepayError,
|
|
10
|
-
FramepayInitializeParams,
|
|
11
|
-
GooglePayElement,
|
|
12
|
-
IbanElement,
|
|
13
|
-
IframeElementEventMap,
|
|
14
|
-
PayPalElement,
|
|
15
|
-
TokenData,
|
|
16
|
-
} from '@rebilly/framepay';
|
|
17
|
-
|
|
18
|
-
export type {
|
|
19
|
-
FieldExtraData,
|
|
20
|
-
FramePay,
|
|
21
|
-
FramepayError,
|
|
22
|
-
FramepayInitializeParams,
|
|
23
|
-
TokenData,
|
|
24
|
-
TokenExtraData,
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Loads FramePay on behalf of framepay-vue and resolves with the page's
|
|
29
|
-
* FramePay instance. framepay-vue then injects no script or stylesheet.
|
|
30
|
-
*/
|
|
31
|
-
export type FramePayLoader = () => Promise<FramePay>;
|
|
32
|
-
|
|
33
|
-
export interface FramePayPluginOptions {
|
|
34
|
-
loader?: FramePayLoader;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface FramePayPlugin {
|
|
38
|
-
/**
|
|
39
|
-
* @param configuration FramePay initialization options. Leave out the
|
|
40
|
-
* publishable key and JWT when the host initializes FramePay itself.
|
|
41
|
-
* @param options `loader` hands FramePay loading to the host.
|
|
42
|
-
*/
|
|
43
|
-
install(
|
|
44
|
-
app: App,
|
|
45
|
-
configuration?: FramepayInitializeParams,
|
|
46
|
-
options?: FramePayPluginOptions,
|
|
47
|
-
): void;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
declare const FramePayVue: FramePayPlugin;
|
|
51
|
-
export default FramePayVue;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Extra data for `createToken()`. FramePay's `ExtraData` lists the known keys
|
|
55
|
-
* and takes any other key, so any object is accepted here.
|
|
56
|
-
*/
|
|
57
|
-
export type CreateTokenExtraData = TokenExtraData | Record<string, unknown>;
|
|
58
|
-
|
|
59
|
-
/** The payload of a field's `change` event. */
|
|
60
|
-
export type FieldChangeEvent = IframeElementEventMap['change'][0];
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* The rejection of `createToken()` and of the internal loading and mounting
|
|
64
|
-
* chains. Plain objects, not `Error` instances.
|
|
65
|
-
*/
|
|
66
|
-
export interface FramePayVueError {
|
|
67
|
-
name: 'FramePayLoadError' | 'FramePayInitializeError' | 'FramePayMountError';
|
|
68
|
-
message: string;
|
|
69
|
-
details: unknown;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export interface FieldProps {
|
|
73
|
-
/** The id of the element FramePay mounts into. Defaults to `<component name>-mount`. */
|
|
74
|
-
id?: string;
|
|
75
|
-
/** Initializes FramePay when the plugin was not given a key. */
|
|
76
|
-
configuration?: FramepayInitializeParams;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export interface CardFieldProps extends FieldProps {
|
|
80
|
-
/**
|
|
81
|
-
* Forwarded to `Framepay.card.mount()`, for example `{ cardType }`. Read once
|
|
82
|
-
* when the field mounts; recreate the component to change it.
|
|
83
|
-
*/
|
|
84
|
-
extraData?: FieldExtraData;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export interface FieldEmits {
|
|
88
|
-
ready: () => void;
|
|
89
|
-
change: (event: FieldChangeEvent) => void;
|
|
90
|
-
focus: () => void;
|
|
91
|
-
blur: () => void;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export interface GooglePayEmits extends FieldEmits {
|
|
95
|
-
error: () => void;
|
|
96
|
-
'token-ready': (token: TokenData) => void;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export interface WalletEmits {
|
|
100
|
-
'token-ready': (token: TokenData) => void;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* The mounted FramePay element, `null` until the field has mounted. Set
|
|
105
|
-
* before the `ready` event, so it is available from `@ready` on. Marked raw,
|
|
106
|
-
* as the component stores it.
|
|
107
|
-
*/
|
|
108
|
-
export interface FieldInstance<Element> {
|
|
109
|
-
readonly element: Raw<Element> | null;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export type FieldComponent<Props, Element, Emits> = DefineComponent<
|
|
113
|
-
Props,
|
|
114
|
-
{},
|
|
115
|
-
FieldInstance<Element>,
|
|
116
|
-
{},
|
|
117
|
-
{},
|
|
118
|
-
ComponentOptionsMixin,
|
|
119
|
-
ComponentOptionsMixin,
|
|
120
|
-
Emits
|
|
121
|
-
>;
|
|
122
|
-
|
|
123
|
-
export type CardFieldComponent = FieldComponent<CardFieldProps, CardElement, FieldEmits>;
|
|
124
|
-
export type BbanFieldComponent = FieldComponent<FieldProps, BankElement, FieldEmits>;
|
|
125
|
-
export type IbanFieldComponent = FieldComponent<FieldProps, IbanElement, FieldEmits>;
|
|
126
|
-
|
|
127
|
-
export const RebillyCard: CardFieldComponent;
|
|
128
|
-
export const RebillyCardCvv: CardFieldComponent;
|
|
129
|
-
export const RebillyCardExpiration: CardFieldComponent;
|
|
130
|
-
export const RebillyCardNumber: CardFieldComponent;
|
|
131
|
-
export const RebillyBbanAccountType: BbanFieldComponent;
|
|
132
|
-
export const RebillyBbanRoutingNumber: BbanFieldComponent;
|
|
133
|
-
export const RebillyBbanAccountNumber: BbanFieldComponent;
|
|
134
|
-
export const RebillyIban: IbanFieldComponent;
|
|
135
|
-
export const RebillyGooglePay: FieldComponent<FieldProps, GooglePayElement, GooglePayEmits>;
|
|
136
|
-
export const RebillyApplePay: FieldComponent<FieldProps, ApplePayElement, WalletEmits>;
|
|
137
|
-
export const RebillyPaypal: FieldComponent<FieldProps, PayPalElement, WalletEmits>;
|
|
138
|
-
|
|
139
|
-
export interface RebillyFormProps {
|
|
140
|
-
/** Passed to `createToken()` on submit. */
|
|
141
|
-
extraData?: CreateTokenExtraData;
|
|
142
|
-
configuration?: FramepayInitializeParams;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export interface RebillyFormEmits {
|
|
146
|
-
submit: (token: TokenData, form: HTMLFormElement) => void;
|
|
147
|
-
error: (error: FramepayError | FramePayVueError) => void;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export const RebillyForm: DefineComponent<
|
|
151
|
-
RebillyFormProps,
|
|
152
|
-
{},
|
|
153
|
-
{},
|
|
154
|
-
{},
|
|
155
|
-
{},
|
|
156
|
-
ComponentOptionsMixin,
|
|
157
|
-
ComponentOptionsMixin,
|
|
158
|
-
RebillyFormEmits
|
|
159
|
-
>;
|
|
160
|
-
|
|
161
|
-
export const RebillyToken: DefineComponent<{}>;
|
|
162
|
-
|
|
163
|
-
export const RebillyFieldTypes: {
|
|
164
|
-
readonly REBILLY_CARD: 'card';
|
|
165
|
-
readonly REBILLY_CARD_CVV: 'cardCvv';
|
|
166
|
-
readonly REBILLY_CARD_NUMBER: 'cardNumber';
|
|
167
|
-
readonly REBILLY_CARD_EXPIRATION: 'cardExpiration';
|
|
168
|
-
readonly REBILLY_BBAN_ACCOUNT_TYPE: 'accountType';
|
|
169
|
-
readonly REBILLY_BBAN_ROUTING_NUMBER: 'routingNumber';
|
|
170
|
-
readonly REBILLY_BBAN_ACCOUNT_NUMBER: 'accountNumber';
|
|
171
|
-
readonly REBILLY_IBAN: 'iban';
|
|
172
|
-
readonly REBILLY_GOOGLE_PAY: 'googlePay';
|
|
173
|
-
readonly REBILLY_APPLE_PAY: 'applePay';
|
|
174
|
-
readonly REBILLY_PAYPAL: 'paypal';
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
/** Waits for FramePay to load, then calls `Framepay.createToken()`. */
|
|
178
|
-
export function createToken(
|
|
179
|
-
form: Element | object | null,
|
|
180
|
-
extraData?: CreateTokenExtraData,
|
|
181
|
-
): Promise<TokenData>;
|
|
182
|
-
|
|
183
|
-
/** Waits for FramePay to be ready, then calls `Framepay.update()`. */
|
|
184
|
-
export function updateConfig(configuration: FramepayInitializeParams): Promise<void>;
|