@rebilly/instruments 3.23.0-beta.0 → 3.24.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rebilly/instruments",
3
- "version": "3.23.0-beta.0",
3
+ "version": "3.24.0-beta.0",
4
4
  "author": "Rebilly",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -17,7 +17,6 @@
17
17
  "@babel/core": "^7.14.6",
18
18
  "@babel/preset-env": "^7.14.7",
19
19
  "@rebilly/risk-data-collector": "^2.3.0",
20
- "@vue-reactivity/watch": "^0.2.0",
21
20
  "@vue/reactivity": "^3.2.39",
22
21
  "jwt-decode": "^3.1.2",
23
22
  "lodash.camelcase": "^4.3.0",
@@ -111,7 +111,7 @@ export function handleApprovalUrl({fields, payload}) {
111
111
  model.purchase = fields;
112
112
  }
113
113
 
114
- state.data = new DataInstance({state, ...fields});
114
+ state.data = new DataInstance({...fields});
115
115
 
116
116
  mountModal({
117
117
  state,
@@ -18,12 +18,13 @@ export default (() => {
18
18
  toModel() {
19
19
  const model = {
20
20
  ...state,
21
- data: state.data.toPostmatesMode ? state.data.toPostmatesModel() : {},
21
+ data: state.data.toPostmatesModel ? state.data.toPostmatesModel() : {},
22
22
  };
23
23
 
24
24
  // remove functions from model
25
25
  delete model.toModel;
26
26
  delete model.updateModel;
27
+ delete model.reset;
27
28
 
28
29
  return JSON.parse(JSON.stringify(model));
29
30
  },
@@ -1,4 +1,5 @@
1
1
  import BaseIframe from './base-iframe';
2
+ import state from '../../../state';
2
3
 
3
4
  import { changeIframeSrcHandler } from './events/change-iframe-src-handler';
4
5
  import { resizeComponentHandler } from './events/resize-component-handler';
@@ -30,36 +31,36 @@ export class ModalIframe extends BaseIframe {
30
31
  // Close modal via postMessage (specifically during approval url flow)
31
32
  window.addEventListener('message', async (event) => {
32
33
  if(event.data === 'rebilly-instruments-approval-url-close') {
33
- if (this.state.options.transactionType === 'purchase') {
34
- this.state.storefront.setSessionToken(this.state.data.token || this.state.options.jwt);
34
+ if (state.options.transactionType === 'purchase') {
35
+ state.storefront.setSessionToken(state.data.token || state.options.jwt);
35
36
 
36
37
  const [
37
38
  {fields: transaction},
38
39
  {fields: invoice}
39
40
  ] = await Promise.all([
40
- this.state.storefront.transactions.get({id: this.state.data.transaction.id}),
41
- this.state.data.invoice?.id
42
- ? this.state.storefront.invoices.get({id: this.state.data.invoice.id})
41
+ state.storefront.transactions.get({id: state.data.transaction.id}),
42
+ state.data.invoice?.id
43
+ ? state.storefront.invoices.get({id: state.data.invoice.id})
43
44
  : {fields: null}
44
45
  ]);
45
46
 
46
47
  const updatedPurchase = {
47
- orderId: this.state.data.orderId,
48
- token: this.state.data.token,
48
+ orderId: state.data.orderId,
49
+ token: state.data.token,
49
50
  transaction,
50
51
  };
51
52
  if (invoice) {
52
53
  updatedPurchase.invoice = invoice;
53
54
  }
54
55
  close(updatedPurchase);
55
- } else if (this.state.options.transactionType === 'setup') {
56
- this.state.storefront.setSessionToken(this.state.data.instrument.token || this.state.options.jwt);
56
+ } else if (state.options.transactionType === 'setup') {
57
+ state.storefront.setSessionToken(state.data.instrument.token || state.options.jwt);
57
58
  const {
58
59
  fields: transaction
59
- } = await this.state.storefront.transactions.get({id: this.state.data.transaction.id});
60
+ } = await state.storefront.transactions.get({id: state.data.transaction.id});
60
61
  close({
61
62
  transaction,
62
- instrument: this.state.data.instrument
63
+ instrument: state.data.instrument
63
64
  });
64
65
  } else {
65
66
  close();
@@ -82,11 +82,11 @@ export async function mountMethodSelector() {
82
82
  iframe.bindEventListeners({loader: state.loader});
83
83
 
84
84
  iframe.component.on(`${name}-confirm-purchase`, (confirmedInstrument) => {
85
- purchase({ state, payload: confirmedInstrument });
85
+ purchase({ payload: confirmedInstrument });
86
86
  });
87
87
 
88
88
  iframe.component.on(`${name}-confirm-setup`, (confirmedInstrument) => {
89
- setup({ state, payload: confirmedInstrument });
89
+ setup({ payload: confirmedInstrument });
90
90
  });
91
91
 
92
92
  iframe.component.on('choose-another-method', () => {