@rebilly/instruments 3.40.0 → 3.41.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.40.0",
3
+ "version": "3.41.0",
4
4
  "author": "Rebilly",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -205,7 +205,18 @@ export default {
205
205
  default: [],
206
206
  items: {
207
207
  type: 'string',
208
- enum: ['email', 'organization', 'phoneNumber', 'city', 'country', 'region', 'postalCode']
208
+ enum: [
209
+ 'all',
210
+ 'email',
211
+ 'organization',
212
+ 'phoneNumber',
213
+ 'city',
214
+ 'country',
215
+ 'region',
216
+ 'postalCode',
217
+ 'address',
218
+ 'address2'
219
+ ]
209
220
  }
210
221
  },
211
222
  hide: {
@@ -213,7 +224,18 @@ export default {
213
224
  default: [],
214
225
  items: {
215
226
  type: 'string',
216
- enum: ['address2']
227
+ enum: [
228
+ 'all',
229
+ 'email',
230
+ 'organization',
231
+ 'phoneNumber',
232
+ 'city',
233
+ 'country',
234
+ 'region',
235
+ 'postalCode',
236
+ 'address',
237
+ 'address2'
238
+ ]
217
239
  }
218
240
  },
219
241
  require: {
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable max-len */
2
2
  import state from '../../state';
3
3
  import { mountSummary } from '../../views/summary';
4
- import { mountForm, determineFirstView } from '../../views/form';
4
+ import { mountForm, determineFirstView, removeForm } from '../../views/form';
5
5
  import { fetchData } from './fetch-data';
6
6
  import Events from '../../events';
7
7
  import setupElement from './setup-element';
@@ -77,6 +77,13 @@ export async function mount({
77
77
  state.i18n({state});
78
78
  state.hasMounted = true;
79
79
 
80
+ const invoiceId = state.options?.invoiceId || state.data?.transaction?.invoiceId;
81
+ if(invoiceId && state.data.invoice.isPaid) {
82
+ state.loader.stopLoading({id: 'rebilly-instruments-form'});
83
+ removeForm();
84
+ showError(state.translate.getTranslation('form.error.invoiceIsPaid'), false);
85
+ }
86
+
80
87
  if (!data.readyToPay?.length) {
81
88
  state.loader.stopLoading({id: 'rebilly-instruments-form'});
82
89
  showError(state.translate.getTranslation('form.error.noPaymentMethods'))
package/src/i18n/en.json CHANGED
@@ -16,7 +16,8 @@
16
16
  "popupOverlayText": "Click here to show popup window",
17
17
  "andMore": "and more",
18
18
  "error": {
19
- "noPaymentMethods": "No payment methods available for this transaction, please contact support."
19
+ "noPaymentMethods": "No payment methods available for this transaction, please contact support.",
20
+ "invoiceIsPaid": "The invoice has been fully paid."
20
21
  },
21
22
  "loaderMessages": {
22
23
  "processingPayment": "Processing payment instrument."
package/src/i18n/es.json CHANGED
@@ -16,7 +16,8 @@
16
16
  "andMore": "y más",
17
17
  "popupOverlayText": "Haga clic aquí para mostrar la ventana emergente",
18
18
  "error": {
19
- "noPaymentMethods": "No hay métodos de pago disponibles para esta transacción, por favor, póngase en contacto con el servicio de asistencia."
19
+ "noPaymentMethods": "No hay métodos de pago disponibles para esta transacción, por favor, póngase en contacto con el servicio de asistencia.",
20
+ "invoiceIsPaid": "La factura ha sido completamente pagada."
20
21
  },
21
22
  "bumpOffer": {
22
23
  "title": "¡Sí, me gustaría actualizar!",
@@ -1,3 +1,20 @@
1
1
  import BaseModel from './base-model';
2
2
 
3
- export default class InvoiceModel extends BaseModel {}
3
+ export default class InvoiceModel extends BaseModel {
4
+ static Status = {
5
+ draft: 'draft',
6
+ unpaid: 'unpaid',
7
+ paid: 'paid',
8
+ partiallyPaid: 'partially-paid',
9
+ pastDue: 'past-due',
10
+ abandoned: 'abandoned',
11
+ voided: 'voided',
12
+ partiallyRefunded: 'partially-refunded',
13
+ refunded: 'refunded',
14
+ disputed: 'disputed',
15
+ }
16
+
17
+ get isPaid() {
18
+ return this.status === InvoiceModel.Status.paid;
19
+ }
20
+ }
@@ -552,6 +552,9 @@ export const vars = (theme) => `
552
552
  padding: var(--rebilly-spacingS);
553
553
  margin-bottom: var(--rebilly-spacingL);
554
554
  }
555
+ .rebilly-instruments-error-card.not-closeable {
556
+ margin-bottom: 0;
557
+ }
555
558
 
556
559
  .rebilly-instruments-error-card-header {
557
560
  display: -webkit-box;
@@ -59,16 +59,13 @@ export function clearError() {
59
59
  errorContainer.innerHTML = '';
60
60
  }
61
61
 
62
- export function showError(error) {
62
+ export function showError(error, isCloseable = true) {
63
63
  if (!error) return;
64
64
  const errorContainer = document.querySelector('#rebilly-instruments-error');
65
65
  if (!errorContainer) return ;
66
66
 
67
67
  errorContainer.innerHTML = errorTemplate(error);
68
68
 
69
- const closeButton = document.querySelector('.rebilly-instruments-error-card-close-button');
70
- closeButton.addEventListener('click', clearError);
71
-
72
69
  function clickOutsideError(e) {
73
70
  if (errorContainer.contains(e.target)) return;
74
71
 
@@ -85,8 +82,18 @@ export function showError(error) {
85
82
  });
86
83
  }
87
84
 
88
- window.addEventListener('click', clickOutsideError);
89
- window.addEventListener('blur', windowBlur, { once: true });
85
+ const closeButton = document.querySelector('.rebilly-instruments-error-card-close-button');
86
+
87
+ if(isCloseable) {
88
+ closeButton.addEventListener('click', clearError);
89
+
90
+ window.addEventListener('click', clickOutsideError);
91
+ window.addEventListener('blur', windowBlur, { once: true });
92
+ } else {
93
+ const errorBox = document.querySelector('.rebilly-instruments-error-card');
94
+ errorBox.classList.add('not-closeable');
95
+ closeButton.remove();
96
+ }
90
97
 
91
98
  errorContainer.scrollIntoView({behavior: 'smooth', block: 'end', inline: 'nearest'});
92
99
  console.error('Rebilly Instruments Error', error);
package/src/views/form.js CHANGED
@@ -49,4 +49,9 @@ export function determineFirstView() {
49
49
  } else {
50
50
  mountMethodSelector();
51
51
  }
52
+ }
53
+
54
+ export function removeForm() {
55
+ const container = document.querySelector('[data-rebilly-instruments="form"]');
56
+ container.remove();
52
57
  }