@rebilly/instruments 3.40.0 → 3.40.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 +7 -0
- package/dist/index.js +9 -9
- package/dist/index.min.js +9 -9
- package/package.json +1 -1
- package/src/functions/mount/index.js +8 -1
- package/src/i18n/en.json +2 -1
- package/src/i18n/es.json +2 -1
- package/src/storefront/models/invoice-model.js +18 -1
- package/src/style/base/index.js +3 -0
- package/src/views/errors.js +13 -6
- package/src/views/form.js +5 -0
package/package.json
CHANGED
|
@@ -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
|
+
}
|
package/src/style/base/index.js
CHANGED
|
@@ -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;
|
package/src/views/errors.js
CHANGED
|
@@ -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
|
-
|
|
89
|
-
|
|
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