@rebilly/framepay-vue 2.1.0 → 3.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 ADDED
@@ -0,0 +1 @@
1
+ ## [3.0.1](https://github.com/Rebilly/rebilly/compare/framepay-vue-v3.0.0...framepay-vue-v3.0.1) (2023-03-20)
package/README.md CHANGED
@@ -2,9 +2,11 @@
2
2
 
3
3
  > Vue components for FramePay.js
4
4
 
5
- Supported: Vue 2.4+
5
+ Supported:
6
+ - framepay-vue < 3.0.0 supports Vue 2.4+
7
+ - framepay-vue >= 3.0.0 supports Vue 3
6
8
 
7
- This is the repo for the official Vue.js wrapper for Rebilly's [FramePay](https://www.rebilly.com/docs/developer-docs/framepay/). This package provides a flexible set of methods and components to allow drop-in support of FramePay in any Vue 2.4+ project.
9
+ This is the repo for the official Vue.js wrapper for Rebilly's [FramePay](https://www.rebilly.com/docs/dev-docs/framepay/). This package provides a flexible set of methods and components to allow drop-in support of FramePay in any Vue project.
8
10
 
9
11
  ## Table of Contents
10
12
  - [framepay-vue](#framepay-vue)
@@ -78,9 +80,9 @@ Add the plugin to Vue:
78
80
  // main.js
79
81
  import FramePay from '@rebilly/framepay-vue';
80
82
 
81
- Vue.use(FramePay);
83
+ app.use(FramePay);
82
84
  ```
83
- `Vue.use()` also accepts an optional argument for initialization options. See [Initialization](#initialization) below.
85
+ `app.use()` also accepts an optional argument for initialization options. See [Initialization](#initialization) below.
84
86
 
85
87
  ## Getting Started
86
88
 
@@ -100,7 +102,7 @@ const configuration = {
100
102
  publishableKey: 'pk_sandbox_1234567890',
101
103
  injectStyle: true,
102
104
  };
103
- Vue.use(FramePay, configuration);
105
+ app.use(FramePay, configuration);
104
106
  ```
105
107
 
106
108
  See [Built in Styling](#built-in-styling) for more information about the `injectStyle` option.
@@ -117,11 +119,11 @@ Add the `publishableKey` on only the first component in the template.
117
119
  </rebilly-form>
118
120
  ```
119
121
 
120
- *NOTE:* Do not include the `publishableKey` on a component if you have already passed it via the config object when calling `Vue.use(Framepay, config)`.
122
+ *NOTE:* Do not include the `publishableKey` on a component if you have already passed it via the config object when calling `app.use(Framepay, config)`.
121
123
 
122
124
  #### Lazy loading Framepay files
123
125
 
124
- The Framepay script files will be loaded as soon as `Vue.use(Framepay)` is called. This does not necessarily need to be done when the app loads, and can instead be done inside the Vue component which actually uses Framepay. In the following example, the Framepay script will not be fetched until the `created()` hook is called.
126
+ The Framepay script files will be loaded as soon as `app.use(Framepay)` is called. This does not necessarily need to be done when the app loads, and can instead be done inside the Vue component which actually uses Framepay. In the following example, the Framepay script will not be fetched until the `created()` hook is called.
125
127
 
126
128
  The script will only be loaded the first time `created()` is called, so you can safely call `created()` multiple times without worrying about duplicates.
127
129
 
@@ -139,7 +141,6 @@ The script will only be loaded the first time `created()` is called, so you can
139
141
  RebillyForm,
140
142
  RebillyCard,
141
143
  } from '@rebilly/framepay-vue';
142
- import Vue from 'vue';
143
144
 
144
145
  export default {
145
146
  components: {
@@ -152,7 +153,7 @@ The script will only be loaded the first time `created()` is called, so you can
152
153
  injectStyle: true,
153
154
  // etc
154
155
  };
155
- Vue.use(FramePay, config);
156
+ app.use(FramePay, config);
156
157
  },
157
158
  };
158
159
  </script>
@@ -379,7 +380,7 @@ const configuration = {
379
380
  publishableKey: 'pk_sandbox_1234567890',
380
381
  injectStyle: true,
381
382
  };
382
- Vue.use(FramePay, configuration);
383
+ app.use(FramePay, configuration);
383
384
  ```
384
385
 
385
386
  **OR**
@@ -0,0 +1,366 @@
1
+ import { openBlock as y, createElementBlock as p, createElementVNode as B, withModifiers as I, renderSlot as A, h as c, markRaw as s } from "vue";
2
+ function h({ message: e = "Could not mount FramePay to element.", details: t = null } = {}) {
3
+ this.message = e, this.details = t, this.name = "FramePayMountError";
4
+ }
5
+ function E({ message: e = "FramePay could not be initialized.", details: t = null } = {}) {
6
+ this.message = e, this.details = t, this.name = "FramePayInitializeError";
7
+ }
8
+ function u({ message: e = "FramePay could not be loaded.", details: t = null } = {}) {
9
+ this.message = e, this.details = t, this.name = "FramePayLoadError";
10
+ }
11
+ const P = window.process?.env?.FRAMEPAY_SCRIPT_LINK || "https://framepay.rebilly.com/rebilly.js", Y = window.process?.env?.FRAMEPAY_STYLE_LINK || "https://framepay.rebilly.com/rebilly.css", T = () => new Promise((e, t) => {
12
+ const n = document.createElement("script");
13
+ n.src = P, n.id = "rebilly-framepay-js", n.onload = () => e(Rebilly), n.onerror = () => t(), document.querySelector("head").appendChild(n);
14
+ }).catch((e) => {
15
+ throw new u({ details: e });
16
+ });
17
+ let _;
18
+ const N = new Promise((e) => {
19
+ _ = e;
20
+ }), $ = _, b = N.then(T);
21
+ function C() {
22
+ if (document.querySelector("link#rebilly-framepay-css"))
23
+ return;
24
+ const e = document.createElement("link");
25
+ e.href = Y, e.id = "rebilly-framepay-css", e.type = "text/css", e.rel = "stylesheet", e.onerror = (t) => {
26
+ throw new u({ details: t });
27
+ }, document.querySelector("head").appendChild(e);
28
+ }
29
+ function a(e = {}) {
30
+ return b.then(
31
+ (t) => new Promise((n) => {
32
+ t.on("ready", () => {
33
+ n(t);
34
+ }), t.on("error", (r) => {
35
+ throw new u({ details: r });
36
+ });
37
+ try {
38
+ e.injectStyle && C(), !t.initialized && (e.publishableKey || e.jwt) && t.initialize(e);
39
+ } catch (r) {
40
+ throw new E({ details: r });
41
+ }
42
+ })
43
+ );
44
+ }
45
+ const g = "card", w = "cardCvv", x = "cardNumber", U = "cardExpiration", S = "accountType", M = "routingNumber", k = "accountNumber", O = "iban", F = "googlePay", D = "applePay", v = "paypal", i = {
46
+ REBILLY_CARD: g,
47
+ REBILLY_CARD_CVV: w,
48
+ REBILLY_CARD_NUMBER: x,
49
+ REBILLY_CARD_EXPIRATION: U,
50
+ REBILLY_BBAN_ACCOUNT_TYPE: S,
51
+ REBILLY_BBAN_ROUTING_NUMBER: M,
52
+ REBILLY_BBAN_ACCOUNT_NUMBER: k,
53
+ REBILLY_IBAN: O,
54
+ REBILLY_GOOGLE_PAY: F,
55
+ REBILLY_APPLE_PAY: D,
56
+ REBILLY_PAYPAL: v
57
+ };
58
+ function G(e, t) {
59
+ return b.then((n) => {
60
+ if (!n.initialized)
61
+ throw new E({
62
+ message: "Please initialize Rebilly before creating a token"
63
+ });
64
+ return n.createToken(e, t);
65
+ });
66
+ }
67
+ function l(e) {
68
+ return a(e).then((t) => {
69
+ t.update({ ...e });
70
+ });
71
+ }
72
+ const L = (e, t) => {
73
+ const n = e.__vccOpts || e;
74
+ for (const [r, m] of t)
75
+ n[r] = m;
76
+ return n;
77
+ }, z = {
78
+ name: "rebilly-form",
79
+ emits: ["submit", "error"],
80
+ props: {
81
+ extraData: {},
82
+ configuration: {}
83
+ },
84
+ methods: {
85
+ handler(e) {
86
+ const t = e.target;
87
+ G(t, this.extraData).then((n) => {
88
+ this.$attrs.onSubmit ? this.$emit("submit", n, t) : t.submit();
89
+ }).catch((n) => {
90
+ this.$emit("error", n);
91
+ });
92
+ }
93
+ },
94
+ watch: {
95
+ configuration(e) {
96
+ e && l(e);
97
+ }
98
+ },
99
+ mounted() {
100
+ l(this.configuration);
101
+ }
102
+ }, j = { id: "stop-wrapper" };
103
+ function V(e, t, n, r, m, d) {
104
+ return y(), p("div", j, [
105
+ B("form", {
106
+ id: "rebilly-form",
107
+ onSubmit: t[0] || (t[0] = I((...R) => d.handler && d.handler(...R), ["stop", "prevent"]))
108
+ }, [
109
+ A(e.$slots, "default")
110
+ ], 32)
111
+ ]);
112
+ }
113
+ const J = /* @__PURE__ */ L(z, [["render", V]]), K = {
114
+ name: "rebilly-token"
115
+ }, q = {
116
+ id: "rebilly-token",
117
+ "data-rebilly": "token",
118
+ type: "hidden"
119
+ };
120
+ function X(e, t, n, r, m, d) {
121
+ return y(), p("input", q);
122
+ }
123
+ const Q = /* @__PURE__ */ L(K, [["render", X]]), o = {
124
+ render() {
125
+ return c("div", {
126
+ id: this.mountId,
127
+ domProps: { id: this.mountId }
128
+ });
129
+ },
130
+ props: {
131
+ id: {
132
+ type: String
133
+ },
134
+ configuration: {}
135
+ },
136
+ data() {
137
+ return {
138
+ element: null,
139
+ mountId: this.id ? this.id : `${this.$options.name}-mount`
140
+ };
141
+ },
142
+ methods: {
143
+ mountElement(e) {
144
+ a(this.configuration).then((t) => {
145
+ try {
146
+ this.elementType.startsWith("card") ? this.element = s(t.card.mount(e, this.elementType)) : this.elementType === "iban" ? this.element = s(t.iban.mount(e)) : [
147
+ i.REBILLY_BBAN_ACCOUNT_TYPE,
148
+ i.REBILLY_BBAN_ACCOUNT_NUMBER,
149
+ i.REBILLY_BBAN_ROUTING_NUMBER
150
+ ].includes(this.elementType) && (this.element = s(t.bban.mount(e, this.elementType))), this.element.on("ready", () => this.$emit("ready")), this.element.on("change", (n) => this.$emit("change", n)), this.element.on("focus", () => this.$emit("focus")), this.element.on("blur", () => this.$emit("blur"));
151
+ } catch {
152
+ throw new h();
153
+ }
154
+ });
155
+ },
156
+ destroyElement() {
157
+ this.element && this.element.destroy();
158
+ }
159
+ },
160
+ created() {
161
+ this.mountElement(`#${this.mountId}`);
162
+ },
163
+ // in vue 2 beforeDestroy is emitted but not in vue 3
164
+ beforeDestroy() {
165
+ this.destroyElement();
166
+ },
167
+ // in vue 3 beforeDestroy hook is replaced with beforeUnmount,
168
+ // we should keep both of them for compatibility purpose
169
+ beforeUnmount() {
170
+ this.destroyElement();
171
+ }
172
+ }, W = {
173
+ render() {
174
+ return c("div", {
175
+ id: this.mountId,
176
+ domProps: { id: this.mountId }
177
+ });
178
+ },
179
+ props: {
180
+ id: {
181
+ type: String
182
+ },
183
+ configuration: {}
184
+ },
185
+ data() {
186
+ return {
187
+ element: null,
188
+ mountId: this.id ? this.id : `${this.$options.name}-mount`
189
+ };
190
+ },
191
+ methods: {
192
+ mountElement(e) {
193
+ a(this.configuration).then((t) => {
194
+ try {
195
+ this.element = s(t.googlePay.mount(e)), this.element.on("ready", () => this.$emit("ready")), this.element.on("change", (n) => this.$emit("change", n)), 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", (n) => {
196
+ this.$emit("token-ready", n), this.$parent.$emit("token-ready", n);
197
+ });
198
+ } catch (n) {
199
+ throw new h({ details: n });
200
+ }
201
+ });
202
+ },
203
+ destroyElement() {
204
+ this.element && this.element.destroy();
205
+ }
206
+ },
207
+ watch: {
208
+ configuration(e) {
209
+ e && l(e);
210
+ }
211
+ },
212
+ created() {
213
+ this.mountElement(`#${this.mountId}`);
214
+ },
215
+ // in vue 2 beforeDestroy is emitted but not in vue 3
216
+ beforeDestroy() {
217
+ this.destroyElement();
218
+ },
219
+ // in vue 3 beforeDestroy hook is replaced with beforeUnmount,
220
+ // we should keep both of them for compatibility purpose
221
+ beforeUnmount() {
222
+ this.destroyElement();
223
+ }
224
+ }, f = {
225
+ render() {
226
+ return c("div", {
227
+ id: this.mountId,
228
+ domProps: { id: this.mountId }
229
+ });
230
+ },
231
+ props: {
232
+ id: {
233
+ type: String
234
+ },
235
+ configuration: {}
236
+ },
237
+ data() {
238
+ return {
239
+ element: null,
240
+ mountId: this.id ? this.id : `${this.$options.name}-mount`
241
+ };
242
+ },
243
+ methods: {
244
+ mountElement(e) {
245
+ a(this.configuration).then((t) => {
246
+ try {
247
+ let n = null;
248
+ this.elementType === i.REBILLY_APPLE_PAY ? n = t.applePay : this.elementType === i.REBILLY_PAYPAL && (n = t.paypal), this.element = s(n.mount(e)), t.on("token-ready", (r) => {
249
+ this.$emit("token-ready", r), this.$parent.$emit("token-ready", r);
250
+ });
251
+ } catch (n) {
252
+ throw new h({ details: n });
253
+ }
254
+ });
255
+ },
256
+ destroyElement() {
257
+ this.element && this.element.destroy();
258
+ }
259
+ },
260
+ watch: {
261
+ configuration(e) {
262
+ e && l(e);
263
+ }
264
+ },
265
+ created() {
266
+ this.mountElement(`#${this.mountId}`);
267
+ },
268
+ // in vue 2 beforeDestroy is emitted but not in vue 3
269
+ beforeDestroy() {
270
+ this.destroyElement();
271
+ },
272
+ // in vue 3 beforeDestroy hook is replaced with beforeUnmount,
273
+ // we should keep both of them for compatibility purpose
274
+ beforeUnmount() {
275
+ this.destroyElement();
276
+ }
277
+ }, Z = {
278
+ name: "rebilly-card",
279
+ data() {
280
+ return { elementType: i.REBILLY_CARD };
281
+ },
282
+ mixins: [o]
283
+ }, ee = {
284
+ name: "rebilly-card-cvv",
285
+ data() {
286
+ return { elementType: i.REBILLY_CARD_CVV };
287
+ },
288
+ mixins: [o]
289
+ }, te = {
290
+ name: "rebilly-card-expiration",
291
+ data() {
292
+ return { elementType: i.REBILLY_CARD_EXPIRATION };
293
+ },
294
+ mixins: [o]
295
+ }, ne = {
296
+ name: "rebilly-card-number",
297
+ data() {
298
+ return { elementType: i.REBILLY_CARD_NUMBER };
299
+ },
300
+ mixins: [o]
301
+ }, ie = {
302
+ name: "rebilly-bban-account-type",
303
+ data() {
304
+ return { elementType: i.REBILLY_BBAN_ACCOUNT_TYPE };
305
+ },
306
+ mixins: [o]
307
+ }, re = {
308
+ name: "rebilly-bban-routing-number",
309
+ data() {
310
+ return { elementType: i.REBILLY_BBAN_ROUTING_NUMBER };
311
+ },
312
+ mixins: [o]
313
+ }, oe = {
314
+ name: "rebilly-bban-account-number",
315
+ data() {
316
+ return { elementType: i.REBILLY_BBAN_ACCOUNT_NUMBER };
317
+ },
318
+ mixins: [o]
319
+ }, se = {
320
+ name: "rebilly-iban",
321
+ data() {
322
+ return { elementType: i.REBILLY_IBAN };
323
+ },
324
+ mixins: [o]
325
+ }, ae = {
326
+ name: "rebilly-google-pay",
327
+ data() {
328
+ return { elementType: i.REBILLY_GOOGLE_PAY };
329
+ },
330
+ mixins: [W]
331
+ }, le = {
332
+ name: "rebilly-apple-pay",
333
+ data() {
334
+ return { elementType: i.REBILLY_APPLE_PAY };
335
+ },
336
+ mixins: [f]
337
+ }, me = {
338
+ name: "rebilly-paypal",
339
+ data() {
340
+ return { elementType: i.REBILLY_PAYPAL };
341
+ },
342
+ mixins: [f]
343
+ }, de = {
344
+ install(e, t = {}) {
345
+ $(), a(t);
346
+ }
347
+ };
348
+ export {
349
+ le as RebillyApplePay,
350
+ oe as RebillyBbanAccountNumber,
351
+ ie as RebillyBbanAccountType,
352
+ re as RebillyBbanRoutingNumber,
353
+ Z as RebillyCard,
354
+ ee as RebillyCardCvv,
355
+ te as RebillyCardExpiration,
356
+ ne as RebillyCardNumber,
357
+ i as RebillyFieldTypes,
358
+ J as RebillyForm,
359
+ ae as RebillyGooglePay,
360
+ se as RebillyIban,
361
+ me as RebillyPaypal,
362
+ Q as RebillyToken,
363
+ G as createToken,
364
+ de as default,
365
+ l as updateConfig
366
+ };
@@ -0,0 +1 @@
1
+ (function(i,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],r):(i=typeof globalThis<"u"?globalThis:i||self,r(i.FramePayVue={},i.Vue))})(this,function(i,r){"use strict";function d({message:e="Could not mount FramePay to element.",details:t=null}={}){this.message=e,this.details=t,this.name="FramePayMountError"}function u({message:e="FramePay could not be initialized.",details:t=null}={}){this.message=e,this.details=t,this.name="FramePayInitializeError"}function c({message:e="FramePay could not be loaded.",details:t=null}={}){this.message=e,this.details=t,this.name="FramePayLoadError"}const L=window.process?.env?.FRAMEPAY_SCRIPT_LINK||"https://framepay.rebilly.com/rebilly.js",B=window.process?.env?.FRAMEPAY_STYLE_LINK||"https://framepay.rebilly.com/rebilly.css",f=()=>new Promise((e,t)=>{const n=document.createElement("script");n.src=L,n.id="rebilly-framepay-js",n.onload=()=>e(Rebilly),n.onerror=()=>t(),document.querySelector("head").appendChild(n)}).catch(e=>{throw new c({details:e})});let _;const I=new Promise(e=>{_=e}),A=_,p=I.then(f);function P(){if(document.querySelector("link#rebilly-framepay-css"))return;const e=document.createElement("link");e.href=B,e.id="rebilly-framepay-css",e.type="text/css",e.rel="stylesheet",e.onerror=t=>{throw new c({details:t})},document.querySelector("head").appendChild(e)}function s(e={}){return p.then(t=>new Promise(n=>{t.on("ready",()=>{n(t)}),t.on("error",a=>{throw new c({details:a})});try{e.injectStyle&&P(),!t.initialized&&(e.publishableKey||e.jwt)&&t.initialize(e)}catch(a){throw new u({details:a})}}))}const o={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 E(e,t){return p.then(n=>{if(!n.initialized)throw new u({message:"Please initialize Rebilly before creating a token"});return n.createToken(e,t)})}function m(e){return s(e).then(t=>{t.update({...e})})}const R=(e,t)=>{const n=e.__vccOpts||e;for(const[a,y]of t)n[a]=y;return n},Y={name:"rebilly-form",emits:["submit","error"],props:{extraData:{},configuration:{}},methods:{handler(e){const t=e.target;E(t,this.extraData).then(n=>{this.$attrs.onSubmit?this.$emit("submit",n,t):t.submit()}).catch(n=>{this.$emit("error",n)})}},watch:{configuration(e){e&&m(e)}},mounted(){m(this.configuration)}},N={id:"stop-wrapper"};function T(e,t,n,a,y,h){return r.openBlock(),r.createElementBlock("div",N,[r.createElementVNode("form",{id:"rebilly-form",onSubmit:t[0]||(t[0]=r.withModifiers((...q)=>h.handler&&h.handler(...q),["stop","prevent"]))},[r.renderSlot(e.$slots,"default")],32)])}const C=R(Y,[["render",T]]),g={name:"rebilly-token"},$={id:"rebilly-token","data-rebilly":"token",type:"hidden"};function w(e,t,n,a,y,h){return r.openBlock(),r.createElementBlock("input",$)}const U=R(g,[["render",w]]),l={render(){return r.h("div",{id:this.mountId,domProps:{id:this.mountId}})},props:{id:{type:String},configuration:{}},data(){return{element:null,mountId:this.id?this.id:`${this.$options.name}-mount`}},methods:{mountElement(e){s(this.configuration).then(t=>{try{this.elementType.startsWith("card")?this.element=r.markRaw(t.card.mount(e,this.elementType)):this.elementType==="iban"?this.element=r.markRaw(t.iban.mount(e)):[o.REBILLY_BBAN_ACCOUNT_TYPE,o.REBILLY_BBAN_ACCOUNT_NUMBER,o.REBILLY_BBAN_ROUTING_NUMBER].includes(this.elementType)&&(this.element=r.markRaw(t.bban.mount(e,this.elementType))),this.element.on("ready",()=>this.$emit("ready")),this.element.on("change",n=>this.$emit("change",n)),this.element.on("focus",()=>this.$emit("focus")),this.element.on("blur",()=>this.$emit("blur"))}catch{throw new d}})},destroyElement(){this.element&&this.element.destroy()}},created(){this.mountElement(`#${this.mountId}`)},beforeDestroy(){this.destroyElement()},beforeUnmount(){this.destroyElement()}},k={render(){return r.h("div",{id:this.mountId,domProps:{id:this.mountId}})},props:{id:{type:String},configuration:{}},data(){return{element:null,mountId:this.id?this.id:`${this.$options.name}-mount`}},methods:{mountElement(e){s(this.configuration).then(t=>{try{this.element=r.markRaw(t.googlePay.mount(e)),this.element.on("ready",()=>this.$emit("ready")),this.element.on("change",n=>this.$emit("change",n)),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",n=>{this.$emit("token-ready",n),this.$parent.$emit("token-ready",n)})}catch(n){throw new d({details:n})}})},destroyElement(){this.element&&this.element.destroy()}},watch:{configuration(e){e&&m(e)}},created(){this.mountElement(`#${this.mountId}`)},beforeDestroy(){this.destroyElement()},beforeUnmount(){this.destroyElement()}},b={render(){return r.h("div",{id:this.mountId,domProps:{id:this.mountId}})},props:{id:{type:String},configuration:{}},data(){return{element:null,mountId:this.id?this.id:`${this.$options.name}-mount`}},methods:{mountElement(e){s(this.configuration).then(t=>{try{let n=null;this.elementType===o.REBILLY_APPLE_PAY?n=t.applePay:this.elementType===o.REBILLY_PAYPAL&&(n=t.paypal),this.element=r.markRaw(n.mount(e)),t.on("token-ready",a=>{this.$emit("token-ready",a),this.$parent.$emit("token-ready",a)})}catch(n){throw new d({details:n})}})},destroyElement(){this.element&&this.element.destroy()}},watch:{configuration(e){e&&m(e)}},created(){this.mountElement(`#${this.mountId}`)},beforeDestroy(){this.destroyElement()},beforeUnmount(){this.destroyElement()}},M={name:"rebilly-card",data(){return{elementType:o.REBILLY_CARD}},mixins:[l]},O={name:"rebilly-card-cvv",data(){return{elementType:o.REBILLY_CARD_CVV}},mixins:[l]},S={name:"rebilly-card-expiration",data(){return{elementType:o.REBILLY_CARD_EXPIRATION}},mixins:[l]},D={name:"rebilly-card-number",data(){return{elementType:o.REBILLY_CARD_NUMBER}},mixins:[l]},F={name:"rebilly-bban-account-type",data(){return{elementType:o.REBILLY_BBAN_ACCOUNT_TYPE}},mixins:[l]},G={name:"rebilly-bban-routing-number",data(){return{elementType:o.REBILLY_BBAN_ROUTING_NUMBER}},mixins:[l]},V={name:"rebilly-bban-account-number",data(){return{elementType:o.REBILLY_BBAN_ACCOUNT_NUMBER}},mixins:[l]},x={name:"rebilly-iban",data(){return{elementType:o.REBILLY_IBAN}},mixins:[l]},j={name:"rebilly-google-pay",data(){return{elementType:o.REBILLY_GOOGLE_PAY}},mixins:[k]},z={name:"rebilly-apple-pay",data(){return{elementType:o.REBILLY_APPLE_PAY}},mixins:[b]},v={name:"rebilly-paypal",data(){return{elementType:o.REBILLY_PAYPAL}},mixins:[b]},K={install(e,t={}){A(),s(t)}};i.RebillyApplePay=z,i.RebillyBbanAccountNumber=V,i.RebillyBbanAccountType=F,i.RebillyBbanRoutingNumber=G,i.RebillyCard=M,i.RebillyCardCvv=O,i.RebillyCardExpiration=S,i.RebillyCardNumber=D,i.RebillyFieldTypes=o,i.RebillyForm=C,i.RebillyGooglePay=j,i.RebillyIban=x,i.RebillyPaypal=v,i.RebillyToken=U,i.createToken=E,i.default=K,i.updateConfig=m,Object.defineProperties(i,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,13 +1,25 @@
1
1
  {
2
2
  "name": "@rebilly/framepay-vue",
3
- "version": "2.1.0",
3
+ "type": "module",
4
+ "version": "3.0.1",
4
5
  "description": "Official Vue wrapper for Rebilly FramePay",
5
6
  "author": "Rebilly",
6
- "repository": "https://github.com/Rebilly/framepay-vue",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/Rebilly/rebilly"
10
+ },
7
11
  "license": "MIT",
8
- "main": "dist/build.js",
12
+ "main": "./dist/framepay-vue.umd.cjs",
13
+ "module": "./dist/framepay-vue.js",
14
+ "exports": {
15
+ ".": {
16
+ "import": "./dist/framepay-vue.js",
17
+ "require": "./dist/framepay-vue.umd.cjs"
18
+ }
19
+ },
9
20
  "files": [
10
- "dist"
21
+ "dist",
22
+ "CHANGELOG.md"
11
23
  ],
12
24
  "keywords": [
13
25
  "framepay",
@@ -18,70 +30,34 @@
18
30
  "framepay-vue"
19
31
  ],
20
32
  "scripts": {
21
- "build": "rollup -c",
22
- "cypress:headless": "cypress run",
23
- "cypress:gui": "cypress open",
24
- "lint": "vue-cli-service lint",
25
- "serve": "cd ./dev-app && vue-cli-service serve",
26
- "test": "run-s test:unit test:e2e",
27
- "test:e2e": "run-p -r serve cypress:headless",
28
- "test:e2e:gui": "run-p -r serve cypress:gui",
29
- "test:unit": "vue-cli-service test:unit"
33
+ "dev": "vite",
34
+ "build": "vite build",
35
+ "test": "npm run lint && npm run test:unit && npm run test:e2e",
36
+ "test:unit": "vitest run --environment jsdom --root src/",
37
+ "test:unit:watch": "vitest --environment jsdom --root src/",
38
+ "test:e2e": "start-server-and-test 'vite dev --port 4173' localhost:4173 'cypress run --e2e'",
39
+ "test:e2e:gui": "start-server-and-test 'vite dev --port 4173' localhost:4173 'cypress open --e2e'",
40
+ "lint:no-fix": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore"
30
41
  },
31
42
  "peerDependencies": {
32
- "vue": "^2.4.0"
33
- },
34
- "dependencies": {
35
- "core-js": "^3.8.0",
36
- "dotenv": "^8.0.0"
43
+ "vue": "^3.0.0"
37
44
  },
38
45
  "devDependencies": {
39
46
  "@testing-library/cypress": "^7.0.2",
40
- "@vue/cli-plugin-babel": "^4.5.19",
41
- "@vue/cli-plugin-eslint": "^4.5.19",
42
- "@vue/cli-plugin-unit-jest": "^4.5.19",
43
- "@vue/cli-service": "^4.5.19",
44
- "@vue/eslint-config-airbnb": "^5.1.0",
45
- "@vue/test-utils": "^1.1.1",
46
- "babel-core": "7.0.0-bridge.0",
47
- "babel-eslint": "^10.0.1",
48
- "babel-jest": "^26.6.3",
49
- "cypress": "^6.0.1",
47
+ "@vitejs/plugin-vue": "^4.0.0",
48
+ "@vue/eslint-config-prettier": "^7.0.0",
49
+ "@vue/test-utils": "^2.2.6",
50
+ "cypress": "12.3.0",
50
51
  "cypress-iframe": "^1.0.1",
51
- "eslint": "^7.14.0",
52
- "eslint-plugin-cypress": "^2.11.2",
53
- "eslint-plugin-vue": "^7.1.0",
54
- "npm-run-all": "^4.1.5",
55
- "rollup": "^2.33.3",
56
- "rollup-plugin-babel": "^4.3.2",
57
- "rollup-plugin-commonjs": "^10.0.0",
58
- "rollup-plugin-vue": "^5.1.9",
59
- "vue": "^2.7.10",
60
- "vue-template-compiler": "^2.7.10"
61
- },
62
- "eslintConfig": {
63
- "root": true,
64
- "env": {
65
- "node": true
66
- },
67
- "extends": [
68
- "plugin:vue/essential",
69
- "plugin:cypress/recommended",
70
- "@vue/airbnb"
71
- ],
72
- "rules": {
73
- "indent": [
74
- "error",
75
- 4
76
- ],
77
- "func-names": "off"
78
- },
79
- "parserOptions": {
80
- "parser": "babel-eslint"
81
- }
82
- },
83
- "browserslist": [
84
- "> 1%",
85
- "last 2 versions"
86
- ]
52
+ "eslint": "^8.22.0",
53
+ "eslint-plugin-cypress": "^2.12.1",
54
+ "eslint-plugin-vue": "^9.3.0",
55
+ "jsdom": "^20.0.3",
56
+ "prettier": "^2.7.1",
57
+ "start-server-and-test": "^1.15.2",
58
+ "vite": "^4.0.0",
59
+ "vite-plugin-mkcert": "^1.13.0",
60
+ "vitest": "^0.25.6",
61
+ "vue": "^3.2.45"
62
+ }
87
63
  }
package/dist/build.js DELETED
@@ -1,782 +0,0 @@
1
- import { h, markRaw } from 'vue';
2
-
3
- function MountError() {
4
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
5
- _ref$message = _ref.message,
6
- message = _ref$message === void 0 ? 'Could not mount FramePay to element.' : _ref$message,
7
- _ref$details = _ref.details,
8
- details = _ref$details === void 0 ? null : _ref$details;
9
-
10
- this.message = message;
11
- this.details = details;
12
- this.name = 'FramePayMountError';
13
- }
14
-
15
- function InitializeError() {
16
- var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
17
- _ref2$message = _ref2.message,
18
- message = _ref2$message === void 0 ? 'FramePay could not be initialized.' : _ref2$message,
19
- _ref2$details = _ref2.details,
20
- details = _ref2$details === void 0 ? null : _ref2$details;
21
-
22
- this.message = message;
23
- this.details = details;
24
- this.name = 'FramePayInitializeError';
25
- }
26
-
27
- function RemoteScriptError() {
28
- var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
29
- _ref3$message = _ref3.message,
30
- message = _ref3$message === void 0 ? 'FramePay could not be loaded.' : _ref3$message,
31
- _ref3$details = _ref3.details,
32
- details = _ref3$details === void 0 ? null : _ref3$details;
33
-
34
- this.message = message;
35
- this.details = details;
36
- this.name = 'FramePayLoadError';
37
- }
38
-
39
- // Link to FramePay library CDN
40
- var FRAMEPAY_SCRIPT_LINK = process.env.FRAMEPAY_SCRIPT_LINK || process.env.VUE_APP_DEBUG_FRAMEPAY_SCRIPT_LINK || 'https://framepay.rebilly.com/rebilly.js'; // Link to FramePay styles CDN
41
-
42
- var FRAMEPAY_STYLE_LINK = process.env.FRAMEPAY_STYLE_LINK || process.env.VUE_APP_DEBUG_FRAMEPAY_STYLE_LINK || 'https://framepay.rebilly.com/rebilly.css';
43
-
44
- var injectScript = function injectScript() {
45
- return new Promise(function (resolve, reject) {
46
- var script = document.createElement('script');
47
- script.src = FRAMEPAY_SCRIPT_LINK;
48
- script.id = 'rebilly-framepay-js'; // eslint-disable-next-line no-undef
49
-
50
- script.onload = function () {
51
- return resolve(Rebilly);
52
- };
53
-
54
- script.onerror = function () {
55
- return reject();
56
- };
57
-
58
- document.querySelector('head').appendChild(script);
59
- }).catch(function (err) {
60
- throw new RemoteScriptError({
61
- details: err
62
- });
63
- });
64
- };
65
-
66
- var resolver;
67
- var waitForInstall = new Promise(function (resolve) {
68
- resolver = resolve;
69
- });
70
- var loadScript = resolver;
71
- var scriptLoaded = waitForInstall.then(injectScript);
72
-
73
- function loadStyle () {
74
- if (document.querySelector('link#rebilly-framepay-css')) {
75
- return;
76
- }
77
-
78
- var style = document.createElement('link');
79
- style.href = FRAMEPAY_STYLE_LINK;
80
- style.id = 'rebilly-framepay-css';
81
- style.type = 'text/css';
82
- style.rel = 'stylesheet';
83
-
84
- style.onerror = function (err) {
85
- throw new RemoteScriptError({
86
- details: err
87
- });
88
- };
89
-
90
- document.querySelector('head').appendChild(style);
91
- }
92
-
93
- function initializeRebilly () {
94
- var configuration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
95
- return scriptLoaded.then(function (Rebilly) {
96
- return new Promise(function (resolve) {
97
- Rebilly.on('ready', function () {
98
- resolve(Rebilly);
99
- });
100
- Rebilly.on('error', function (err) {
101
- throw new RemoteScriptError({
102
- details: err
103
- });
104
- });
105
-
106
- try {
107
- if (configuration.injectStyle) {
108
- loadStyle();
109
- }
110
-
111
- if (!Rebilly.initialized && (configuration.publishableKey || configuration.jwt)) {
112
- Rebilly.initialize(configuration);
113
- }
114
- } catch (e) {
115
- throw new InitializeError({
116
- details: e
117
- });
118
- }
119
- });
120
- });
121
- }
122
-
123
- // Framepay element's types
124
- // Used to address form field related to current element
125
- var REBILLY_CARD = 'card';
126
- var REBILLY_CARD_CVV = 'cardCvv';
127
- var REBILLY_CARD_NUMBER = 'cardNumber';
128
- var REBILLY_CARD_EXPIRATION = 'cardExpiration';
129
- var REBILLY_BBAN_ACCOUNT_TYPE = 'accountType';
130
- var REBILLY_BBAN_ROUTING_NUMBER = 'routingNumber';
131
- var REBILLY_BBAN_ACCOUNT_NUMBER = 'accountNumber';
132
- var REBILLY_IBAN = 'iban';
133
- var REBILLY_GOOGLE_PAY = 'googlePay';
134
- var REBILLY_APPLE_PAY = 'applePay';
135
- var REBILLY_PAYPAL = 'paypal';
136
- var FIELD_TYPES = {
137
- REBILLY_CARD: REBILLY_CARD,
138
- REBILLY_CARD_CVV: REBILLY_CARD_CVV,
139
- REBILLY_CARD_NUMBER: REBILLY_CARD_NUMBER,
140
- REBILLY_CARD_EXPIRATION: REBILLY_CARD_EXPIRATION,
141
- REBILLY_BBAN_ACCOUNT_TYPE: REBILLY_BBAN_ACCOUNT_TYPE,
142
- REBILLY_BBAN_ROUTING_NUMBER: REBILLY_BBAN_ROUTING_NUMBER,
143
- REBILLY_BBAN_ACCOUNT_NUMBER: REBILLY_BBAN_ACCOUNT_NUMBER,
144
- REBILLY_IBAN: REBILLY_IBAN,
145
- REBILLY_GOOGLE_PAY: REBILLY_GOOGLE_PAY,
146
- REBILLY_APPLE_PAY: REBILLY_APPLE_PAY,
147
- REBILLY_PAYPAL: REBILLY_PAYPAL
148
- };
149
-
150
- function createToken (form, extraData) {
151
- return scriptLoaded.then(function (Rebilly) {
152
- if (!Rebilly.initialized) {
153
- throw new InitializeError({
154
- message: 'Please initialize Rebilly before creating a token'
155
- });
156
- }
157
-
158
- return Rebilly.createToken(form, extraData);
159
- });
160
- }
161
-
162
- function ownKeys(object, enumerableOnly) {
163
- var keys = Object.keys(object);
164
-
165
- if (Object.getOwnPropertySymbols) {
166
- var symbols = Object.getOwnPropertySymbols(object);
167
- enumerableOnly && (symbols = symbols.filter(function (sym) {
168
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
169
- })), keys.push.apply(keys, symbols);
170
- }
171
-
172
- return keys;
173
- }
174
-
175
- function _objectSpread2(target) {
176
- for (var i = 1; i < arguments.length; i++) {
177
- var source = null != arguments[i] ? arguments[i] : {};
178
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
179
- _defineProperty(target, key, source[key]);
180
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
181
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
182
- });
183
- }
184
-
185
- return target;
186
- }
187
-
188
- function _defineProperty(obj, key, value) {
189
- if (key in obj) {
190
- Object.defineProperty(obj, key, {
191
- value: value,
192
- enumerable: true,
193
- configurable: true,
194
- writable: true
195
- });
196
- } else {
197
- obj[key] = value;
198
- }
199
-
200
- return obj;
201
- }
202
-
203
- function updateConfig (configuration) {
204
- return initializeRebilly(configuration).then(function (Rebilly) {
205
- Rebilly.update(_objectSpread2({}, configuration));
206
- });
207
- }
208
-
209
- //
210
- var script$1 = {
211
- name: 'rebilly-form',
212
- props: {
213
- extraData: {},
214
- configuration: {}
215
- },
216
- methods: {
217
- handler: function handler(event) {
218
- var _this = this;
219
-
220
- var form = event.target;
221
- event.preventDefault();
222
- createToken(form, this.extraData).then(function (token) {
223
- if (_this.$listeners.submit) {
224
- _this.$emit('submit', token, form);
225
- } else {
226
- form.submit();
227
- }
228
- }).catch(function (error) {
229
- _this.$emit('error', error);
230
- });
231
- }
232
- },
233
- watch: {
234
- configuration: function configuration(value) {
235
- if (value) {
236
- updateConfig(value);
237
- }
238
- }
239
- },
240
- mounted: function mounted() {
241
- updateConfig(this.configuration);
242
- }
243
- };
244
-
245
- function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier
246
- /* server only */
247
- , shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
248
- if (typeof shadowMode !== 'boolean') {
249
- createInjectorSSR = createInjector;
250
- createInjector = shadowMode;
251
- shadowMode = false;
252
- } // Vue.extend constructor export interop.
253
-
254
-
255
- var options = typeof script === 'function' ? script.options : script; // render functions
256
-
257
- if (template && template.render) {
258
- options.render = template.render;
259
- options.staticRenderFns = template.staticRenderFns;
260
- options._compiled = true; // functional template
261
-
262
- if (isFunctionalTemplate) {
263
- options.functional = true;
264
- }
265
- } // scopedId
266
-
267
-
268
- if (scopeId) {
269
- options._scopeId = scopeId;
270
- }
271
-
272
- var hook;
273
-
274
- if (moduleIdentifier) {
275
- // server build
276
- hook = function hook(context) {
277
- // 2.3 injection
278
- context = context || // cached call
279
- this.$vnode && this.$vnode.ssrContext || // stateful
280
- this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext; // functional
281
- // 2.2 with runInNewContext: true
282
-
283
- if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
284
- context = __VUE_SSR_CONTEXT__;
285
- } // inject component styles
286
-
287
-
288
- if (style) {
289
- style.call(this, createInjectorSSR(context));
290
- } // register component module identifier for async chunk inference
291
-
292
-
293
- if (context && context._registeredComponents) {
294
- context._registeredComponents.add(moduleIdentifier);
295
- }
296
- }; // used by ssr in case component is cached and beforeCreate
297
- // never gets called
298
-
299
-
300
- options._ssrRegister = hook;
301
- } else if (style) {
302
- hook = shadowMode ? function (context) {
303
- style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot));
304
- } : function (context) {
305
- style.call(this, createInjector(context));
306
- };
307
- }
308
-
309
- if (hook) {
310
- if (options.functional) {
311
- // register for functional component in vue file
312
- var originalRender = options.render;
313
-
314
- options.render = function renderWithStyleInjection(h, context) {
315
- hook.call(context);
316
- return originalRender(h, context);
317
- };
318
- } else {
319
- // inject component registration as beforeCreate hook
320
- var existing = options.beforeCreate;
321
- options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
322
- }
323
- }
324
-
325
- return script;
326
- }
327
-
328
- /* script */
329
- const __vue_script__$1 = script$1;
330
-
331
- /* template */
332
- var __vue_render__$1 = function () {
333
- var _vm = this;
334
- var _h = _vm.$createElement;
335
- var _c = _vm._self._c || _h;
336
- return _c(
337
- "form",
338
- { attrs: { id: "rebilly-form" }, on: { submit: _vm.handler } },
339
- [_vm._t("default")],
340
- 2
341
- )
342
- };
343
- var __vue_staticRenderFns__$1 = [];
344
- __vue_render__$1._withStripped = true;
345
-
346
- /* style */
347
- const __vue_inject_styles__$1 = undefined;
348
- /* scoped */
349
- const __vue_scope_id__$1 = undefined;
350
- /* module identifier */
351
- const __vue_module_identifier__$1 = undefined;
352
- /* functional template */
353
- const __vue_is_functional_template__$1 = false;
354
- /* style inject */
355
-
356
- /* style inject SSR */
357
-
358
- /* style inject shadow dom */
359
-
360
-
361
-
362
- const __vue_component__$1 = /*#__PURE__*/normalizeComponent(
363
- { render: __vue_render__$1, staticRenderFns: __vue_staticRenderFns__$1 },
364
- __vue_inject_styles__$1,
365
- __vue_script__$1,
366
- __vue_scope_id__$1,
367
- __vue_is_functional_template__$1,
368
- __vue_module_identifier__$1,
369
- false,
370
- undefined,
371
- undefined,
372
- undefined
373
- );
374
-
375
- //
376
- //
377
- //
378
- //
379
- //
380
- //
381
- //
382
- var script = {
383
- name: 'rebilly-token'
384
- };
385
-
386
- /* script */
387
- const __vue_script__ = script;
388
-
389
- /* template */
390
- var __vue_render__ = function () {
391
- var _vm = this;
392
- var _h = _vm.$createElement;
393
- var _c = _vm._self._c || _h;
394
- return _c("input", {
395
- attrs: { id: "rebilly-token", "data-rebilly": "token", type: "hidden" },
396
- })
397
- };
398
- var __vue_staticRenderFns__ = [];
399
- __vue_render__._withStripped = true;
400
-
401
- /* style */
402
- const __vue_inject_styles__ = undefined;
403
- /* scoped */
404
- const __vue_scope_id__ = undefined;
405
- /* module identifier */
406
- const __vue_module_identifier__ = undefined;
407
- /* functional template */
408
- const __vue_is_functional_template__ = false;
409
- /* style inject */
410
-
411
- /* style inject SSR */
412
-
413
- /* style inject shadow dom */
414
-
415
-
416
-
417
- const __vue_component__ = /*#__PURE__*/normalizeComponent(
418
- { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
419
- __vue_inject_styles__,
420
- __vue_script__,
421
- __vue_scope_id__,
422
- __vue_is_functional_template__,
423
- __vue_module_identifier__,
424
- false,
425
- undefined,
426
- undefined,
427
- undefined
428
- );
429
-
430
- var BaseElementMixin = {
431
- render: function render() {
432
- return h('div', {
433
- id: this.mountId,
434
- domProps: {
435
- id: this.mountId
436
- }
437
- });
438
- },
439
- props: {
440
- id: {
441
- type: String
442
- },
443
- configuration: {}
444
- },
445
- data: function data() {
446
- return {
447
- element: null,
448
- mountId: this.id ? this.id : "".concat(this.$options.name, "-mount")
449
- };
450
- },
451
- methods: {
452
- mountElement: function mountElement(selector) {
453
- var _this = this;
454
-
455
- initializeRebilly(this.configuration).then(function (Rebilly) {
456
- try {
457
- if (_this.elementType.startsWith('card')) {
458
- _this.element = markRaw(Rebilly.card.mount(selector, _this.elementType));
459
- } else if (_this.elementType === 'iban') {
460
- _this.element = markRaw(Rebilly.iban.mount(selector));
461
- } else if ([FIELD_TYPES.REBILLY_BBAN_ACCOUNT_TYPE, FIELD_TYPES.REBILLY_BBAN_ACCOUNT_NUMBER, FIELD_TYPES.REBILLY_BBAN_ROUTING_NUMBER].includes(_this.elementType)) {
462
- _this.element = markRaw(Rebilly.bban.mount(selector, _this.elementType));
463
- }
464
-
465
- _this.element.on('ready', function () {
466
- return _this.$emit('ready');
467
- });
468
-
469
- _this.element.on('change', function (e) {
470
- return _this.$emit('change', e);
471
- });
472
-
473
- _this.element.on('focus', function () {
474
- return _this.$emit('focus');
475
- });
476
-
477
- _this.element.on('blur', function () {
478
- return _this.$emit('blur');
479
- });
480
- } catch (e) {
481
- throw new MountError();
482
- }
483
- });
484
- },
485
- destroyElement: function destroyElement() {
486
- if (this.element) {
487
- this.element.destroy();
488
- }
489
- }
490
- },
491
- created: function created() {
492
- this.mountElement("#".concat(this.mountId));
493
- },
494
- // in vue 2 beforeDestroy is emitted but not in vue 3
495
- beforeDestroy: function beforeDestroy() {
496
- this.destroyElement();
497
- },
498
- // in vue 3 beforeDestroy hook is replaced with beforeUnmount,
499
- // we should keep both of them for compatibility purpose
500
- beforeUnmount: function beforeUnmount() {
501
- this.destroyElement();
502
- }
503
- };
504
-
505
- var GooglePayMixin = {
506
- render: function render() {
507
- return h('div', {
508
- id: this.mountId,
509
- domProps: {
510
- id: this.mountId
511
- }
512
- });
513
- },
514
- props: {
515
- id: {
516
- type: String
517
- },
518
- configuration: {}
519
- },
520
- data: function data() {
521
- return {
522
- element: null,
523
- mountId: this.id ? this.id : "".concat(this.$options.name, "-mount")
524
- };
525
- },
526
- methods: {
527
- mountElement: function mountElement(selector) {
528
- var _this = this;
529
-
530
- initializeRebilly(this.configuration).then(function (Rebilly) {
531
- try {
532
- _this.element = markRaw(Rebilly.googlePay.mount(selector));
533
-
534
- _this.element.on('ready', function () {
535
- return _this.$emit('ready');
536
- });
537
-
538
- _this.element.on('change', function (e) {
539
- return _this.$emit('change', e);
540
- });
541
-
542
- _this.element.on('focus', function () {
543
- return _this.$emit('focus');
544
- });
545
-
546
- _this.element.on('blur', function () {
547
- return _this.$emit('blur');
548
- });
549
-
550
- _this.element.on('error', function () {
551
- return _this.$emit('error');
552
- });
553
-
554
- Rebilly.on('token-ready', function (token) {
555
- // https://github.com/vuejs/vue/issues/4332#issuecomment-263444492
556
- // Emit token on the element level:
557
- _this.$emit('token-ready', token); // Emit token on the RebillyForm level:
558
-
559
-
560
- _this.$parent.$emit('token-ready', token);
561
- });
562
- } catch (e) {
563
- throw new MountError({
564
- details: e
565
- });
566
- }
567
- });
568
- },
569
- destroyElement: function destroyElement() {
570
- if (this.element) {
571
- this.element.destroy();
572
- }
573
- }
574
- },
575
- watch: {
576
- configuration: function configuration(value) {
577
- if (value) {
578
- updateConfig(value);
579
- }
580
- }
581
- },
582
- created: function created() {
583
- this.mountElement("#".concat(this.mountId));
584
- },
585
- // in vue 2 beforeDestroy is emitted but not in vue 3
586
- beforeDestroy: function beforeDestroy() {
587
- this.destroyElement();
588
- },
589
- // in vue 3 beforeDestroy hook is replaced with beforeUnmount,
590
- // we should keep both of them for compatibility purpose
591
- beforeUnmount: function beforeUnmount() {
592
- this.destroyElement();
593
- }
594
- };
595
-
596
- var NonIframeElementMixin = {
597
- render: function render() {
598
- return h('div', {
599
- id: this.mountId,
600
- domProps: {
601
- id: this.mountId
602
- }
603
- });
604
- },
605
- props: {
606
- id: {
607
- type: String
608
- },
609
- configuration: {}
610
- },
611
- data: function data() {
612
- return {
613
- element: null,
614
- mountId: this.id ? this.id : "".concat(this.$options.name, "-mount")
615
- };
616
- },
617
- methods: {
618
- mountElement: function mountElement(selector) {
619
- var _this = this;
620
-
621
- initializeRebilly(this.configuration).then(function (Rebilly) {
622
- try {
623
- var namespace = null;
624
-
625
- if (_this.elementType === FIELD_TYPES.REBILLY_APPLE_PAY) {
626
- namespace = Rebilly.applePay;
627
- } else if (_this.elementType === FIELD_TYPES.REBILLY_PAYPAL) {
628
- namespace = Rebilly.paypal;
629
- }
630
-
631
- _this.element = markRaw(namespace.mount(selector));
632
- Rebilly.on('token-ready', function (token) {
633
- // https://github.com/vuejs/vue/issues/4332#issuecomment-263444492
634
- // Emit token on the element level:
635
- _this.$emit('token-ready', token); // Emit token on the RebillyForm level:
636
-
637
-
638
- _this.$parent.$emit('token-ready', token);
639
- });
640
- } catch (e) {
641
- throw new MountError({
642
- details: e
643
- });
644
- }
645
- });
646
- },
647
- destroyElement: function destroyElement() {
648
- if (this.element) {
649
- this.element.destroy();
650
- }
651
- }
652
- },
653
- watch: {
654
- configuration: function configuration(value) {
655
- if (value) {
656
- updateConfig(value);
657
- }
658
- }
659
- },
660
- created: function created() {
661
- this.mountElement("#".concat(this.mountId));
662
- },
663
- // in vue 2 beforeDestroy is emitted but not in vue 3
664
- beforeDestroy: function beforeDestroy() {
665
- this.destroyElement();
666
- },
667
- // in vue 3 beforeDestroy hook is replaced with beforeUnmount,
668
- // we should keep both of them for compatibility purpose
669
- beforeUnmount: function beforeUnmount() {
670
- this.destroyElement();
671
- }
672
- };
673
-
674
- var RebillyCard = {
675
- name: 'rebilly-card',
676
- data: function data() {
677
- return {
678
- elementType: FIELD_TYPES.REBILLY_CARD
679
- };
680
- },
681
- mixins: [BaseElementMixin]
682
- };
683
- var RebillyCardCvv = {
684
- name: 'rebilly-card-cvv',
685
- data: function data() {
686
- return {
687
- elementType: FIELD_TYPES.REBILLY_CARD_CVV
688
- };
689
- },
690
- mixins: [BaseElementMixin]
691
- };
692
- var RebillyCardExpiration = {
693
- name: 'rebilly-card-expiration',
694
- data: function data() {
695
- return {
696
- elementType: FIELD_TYPES.REBILLY_CARD_EXPIRATION
697
- };
698
- },
699
- mixins: [BaseElementMixin]
700
- };
701
- var RebillyCardNumber = {
702
- name: 'rebilly-card-number',
703
- data: function data() {
704
- return {
705
- elementType: FIELD_TYPES.REBILLY_CARD_NUMBER
706
- };
707
- },
708
- mixins: [BaseElementMixin]
709
- };
710
- var RebillyBbanAccountType = {
711
- name: 'rebilly-bban-account-type',
712
- data: function data() {
713
- return {
714
- elementType: FIELD_TYPES.REBILLY_BBAN_ACCOUNT_TYPE
715
- };
716
- },
717
- mixins: [BaseElementMixin]
718
- };
719
- var RebillyBbanRoutingNumber = {
720
- name: 'rebilly-bban-routing-number',
721
- data: function data() {
722
- return {
723
- elementType: FIELD_TYPES.REBILLY_BBAN_ROUTING_NUMBER
724
- };
725
- },
726
- mixins: [BaseElementMixin]
727
- };
728
- var RebillyBbanAccountNumber = {
729
- name: 'rebilly-bban-account-number',
730
- data: function data() {
731
- return {
732
- elementType: FIELD_TYPES.REBILLY_BBAN_ACCOUNT_NUMBER
733
- };
734
- },
735
- mixins: [BaseElementMixin]
736
- };
737
- var RebillyIban = {
738
- name: 'rebilly-iban',
739
- data: function data() {
740
- return {
741
- elementType: FIELD_TYPES.REBILLY_IBAN
742
- };
743
- },
744
- mixins: [BaseElementMixin]
745
- };
746
- var RebillyGooglePay = {
747
- name: 'rebilly-google-pay',
748
- data: function data() {
749
- return {
750
- elementType: FIELD_TYPES.REBILLY_GOOGLE_PAY
751
- };
752
- },
753
- mixins: [GooglePayMixin]
754
- };
755
- var RebillyApplePay = {
756
- name: 'rebilly-apple-pay',
757
- data: function data() {
758
- return {
759
- elementType: FIELD_TYPES.REBILLY_APPLE_PAY
760
- };
761
- },
762
- mixins: [NonIframeElementMixin]
763
- };
764
- var RebillyPaypal = {
765
- name: 'rebilly-paypal',
766
- data: function data() {
767
- return {
768
- elementType: FIELD_TYPES.REBILLY_PAYPAL
769
- };
770
- },
771
- mixins: [NonIframeElementMixin]
772
- };
773
-
774
- var FramePay = {
775
- install: function install(Vue) {
776
- var configuration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
777
- loadScript();
778
- initializeRebilly(configuration);
779
- }
780
- };
781
-
782
- export { RebillyApplePay, RebillyBbanAccountNumber, RebillyBbanAccountType, RebillyBbanRoutingNumber, RebillyCard, RebillyCardCvv, RebillyCardExpiration, RebillyCardNumber, FIELD_TYPES as RebillyFieldTypes, __vue_component__$1 as RebillyForm, RebillyGooglePay, RebillyIban, RebillyPaypal, __vue_component__ as RebillyToken, createToken, FramePay as default, updateConfig };