@lancom/shared 0.0.323 → 0.0.325
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/assets/js/api/index.js +2 -2
- package/components/checkout/order/address-form/address-form.vue +9 -1
- package/components/checkout/order/order-payment-information/order-payment-information.vue +20 -8
- package/components/checkout/order/order.vue +10 -5
- package/components/common/product_side_with_print/product-side-with-print.vue +12 -6
- package/components/order/order_payment/order-payment.vue +21 -3
- package/components/order/order_product_prints_preview/order-product-prints-preview.vue +8 -0
- package/components/order/order_view/order_view_product/order-view-product.vue +3 -3
- package/components/quotes/quote_view/quote-view.mixin.js +5 -0
- package/mixins/payment.js +4 -2
- package/package.json +1 -1
- package/pages/checkout/order.vue +5 -0
- package/store/order.js +9 -1
package/assets/js/api/index.js
CHANGED
|
@@ -99,9 +99,9 @@ const api = {
|
|
|
99
99
|
const url = `shop/${shop}/payment-intent`;
|
|
100
100
|
return _post(url, { amount, currency, payment, description, order });
|
|
101
101
|
},
|
|
102
|
-
createOrderPayment(id, { card, shop, country, currency, invoice, payment, recaptchaToken }) {
|
|
102
|
+
createOrderPayment(id, { card, shop, country, currency, invoice, payment, recaptchaToken, path }) {
|
|
103
103
|
const url = invoice ? `shop/${shop}/order/${id}/invoice/${invoice}/payment` : `shop/${shop}/order/${id}/payment`;
|
|
104
|
-
return _post(url, { card, country, payment, currency, recaptchaToken });
|
|
104
|
+
return _post(url, { card, country, payment, currency, recaptchaToken, path });
|
|
105
105
|
},
|
|
106
106
|
addOrderTimeline(id, item) {
|
|
107
107
|
return _post(`order/${id}/timeline`, item);
|
|
@@ -188,7 +188,7 @@
|
|
|
188
188
|
<div class="form-row--cols">
|
|
189
189
|
<postcode-select
|
|
190
190
|
class="form-col col-half"
|
|
191
|
-
:suburb="suburb"
|
|
191
|
+
:suburb="address.suburb"
|
|
192
192
|
:labelless="true"
|
|
193
193
|
:required="true"
|
|
194
194
|
placeholder="Suburb"
|
|
@@ -279,6 +279,14 @@ export default {
|
|
|
279
279
|
if (!this.address.suburb && !this.suburb && this.user?.suburb) {
|
|
280
280
|
this.handleSuburbChange(this.user.suburb);
|
|
281
281
|
}
|
|
282
|
+
if (!this.address.suburb && this.address.state && this.address.postcode && this.address.city && this.address.country) {
|
|
283
|
+
this.handleSuburbChange({
|
|
284
|
+
state: this.address.state,
|
|
285
|
+
postcode: this.address.postcode,
|
|
286
|
+
locality: this.address.city,
|
|
287
|
+
country: this.address.country
|
|
288
|
+
});
|
|
289
|
+
}
|
|
282
290
|
if (!this.address.suburb) {
|
|
283
291
|
this.setAddressSuburb(this.suburb);
|
|
284
292
|
}
|
|
@@ -125,6 +125,15 @@ export default {
|
|
|
125
125
|
},
|
|
126
126
|
async mounted() {
|
|
127
127
|
await this.initOrderData();
|
|
128
|
+
if (this.$route.query.checkPayment) {
|
|
129
|
+
if (this.orderData.paid) {
|
|
130
|
+
this.onOrderSucces();
|
|
131
|
+
this.$emit('next');
|
|
132
|
+
} else if (this.orderData.failedCharge) {
|
|
133
|
+
this.handleErrors({ message: this.orderData.failedCharge });
|
|
134
|
+
this.showPaymentErrorInfo();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
128
137
|
},
|
|
129
138
|
methods: {
|
|
130
139
|
...mapActions('order', ['createOrder', 'saveOrder']),
|
|
@@ -208,14 +217,7 @@ export default {
|
|
|
208
217
|
if (!this.isFailedOrderCharge) {
|
|
209
218
|
this.$emit('next');
|
|
210
219
|
} else {
|
|
211
|
-
this
|
|
212
|
-
const message = `Unfortunately our payment gateway has reported the following error: '${this.errorMessage}'. Please check your card number and try again. Alternatively you can proceed with a 'pay later' order and receive an email confirmation now and pay via credit card or bank transfer`;
|
|
213
|
-
const options = { submitLabel: 'PAY LATER', cancelLabel: 'TRY AGAIN', warning: true };
|
|
214
|
-
const isSwitchToDeposit = await this.showConfirmationModal(message, options);
|
|
215
|
-
if (isSwitchToDeposit) {
|
|
216
|
-
this.updatePaymentType(true);
|
|
217
|
-
}
|
|
218
|
-
});
|
|
220
|
+
this.showPaymentErrorInfo();
|
|
219
221
|
}
|
|
220
222
|
} catch (e) {
|
|
221
223
|
const { message } = (e.response && e.response.data) || e;
|
|
@@ -224,6 +226,16 @@ export default {
|
|
|
224
226
|
this.creating = false;
|
|
225
227
|
}
|
|
226
228
|
},
|
|
229
|
+
showPaymentErrorInfo() {
|
|
230
|
+
this.$nextTick(async () => {
|
|
231
|
+
const message = `Unfortunately our payment gateway has reported the following error: '${this.errorMessage}'. Please check your card number and try again. Alternatively you can proceed with a 'pay later' order and receive an email confirmation now and pay via credit card or bank transfer`;
|
|
232
|
+
const options = { submitLabel: 'PAY LATER', cancelLabel: 'TRY AGAIN', warning: true };
|
|
233
|
+
const isSwitchToDeposit = await this.showConfirmationModal(message, options);
|
|
234
|
+
if (isSwitchToDeposit) {
|
|
235
|
+
this.updatePaymentType(true);
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
}
|
|
227
239
|
}
|
|
228
240
|
};
|
|
229
241
|
</script>
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
v-if="!isEmpty || orderData"
|
|
7
7
|
ref="progressSteps"
|
|
8
8
|
:steps="steps"
|
|
9
|
+
:start-step="startStep"
|
|
9
10
|
:visible-current-step="false"
|
|
10
11
|
:hidden-done-step-number="true"
|
|
11
12
|
:step-offset="1"
|
|
@@ -66,6 +67,7 @@ export default {
|
|
|
66
67
|
},
|
|
67
68
|
data() {
|
|
68
69
|
return {
|
|
70
|
+
startStep: null,
|
|
69
71
|
stepComponents: {
|
|
70
72
|
[ORDER_STEPS.CHECKOUT_METHOD]: 'order-checkout-method',
|
|
71
73
|
[ORDER_STEPS.BILLING_INFORMATION]: 'order-billing-information',
|
|
@@ -89,6 +91,9 @@ export default {
|
|
|
89
91
|
}
|
|
90
92
|
},
|
|
91
93
|
mounted() {
|
|
94
|
+
if (this.$route.query.checkPayment && (this.orderData?.paid || !!this.orderData?.failedCharge)) {
|
|
95
|
+
this.startStep = ORDER_STEPS.PAYMENT_INFORMATION;
|
|
96
|
+
}
|
|
92
97
|
const address = {
|
|
93
98
|
city: null,
|
|
94
99
|
phone: null,
|
|
@@ -106,8 +111,8 @@ export default {
|
|
|
106
111
|
this.order = {
|
|
107
112
|
paymentMethod: 'card',
|
|
108
113
|
billingAddress: {
|
|
109
|
-
...JSON.parse(JSON.stringify(address)),
|
|
110
|
-
...(this.user ? {
|
|
114
|
+
...JSON.parse(JSON.stringify(this.orderData?.billingAddress || address)),
|
|
115
|
+
...((!this.orderData && this.user) ? {
|
|
111
116
|
fullName: `${this.user.firstName} ${this.user.lastName}`,
|
|
112
117
|
phone: this.user.phone,
|
|
113
118
|
email: this.user.email,
|
|
@@ -115,8 +120,8 @@ export default {
|
|
|
115
120
|
} : {})
|
|
116
121
|
},
|
|
117
122
|
shippingAddress: {
|
|
118
|
-
...address,
|
|
119
|
-
...(this.user ? {
|
|
123
|
+
...JSON.parse(JSON.stringify(this.orderData?.shippingAddress || address)),
|
|
124
|
+
...((!this.orderData && this.user) ? {
|
|
120
125
|
fullName: `${this.user.firstName} ${this.user.lastName}`,
|
|
121
126
|
phone: this.user.phone,
|
|
122
127
|
email: this.user.email,
|
|
@@ -124,7 +129,7 @@ export default {
|
|
|
124
129
|
} : {})
|
|
125
130
|
}
|
|
126
131
|
};
|
|
127
|
-
this.setOrderData(null);
|
|
132
|
+
// this.setOrderData(null);
|
|
128
133
|
},
|
|
129
134
|
methods: {
|
|
130
135
|
...mapMutations('order', ['setOrderData']),
|
|
@@ -31,6 +31,9 @@ export default {
|
|
|
31
31
|
type: String,
|
|
32
32
|
required: true
|
|
33
33
|
},
|
|
34
|
+
color: {
|
|
35
|
+
type: Object
|
|
36
|
+
},
|
|
34
37
|
size: {
|
|
35
38
|
default: 'small',
|
|
36
39
|
validator(value) {
|
|
@@ -81,7 +84,7 @@ export default {
|
|
|
81
84
|
return this.print && this.getImageBackground(this.print);
|
|
82
85
|
},
|
|
83
86
|
image() {
|
|
84
|
-
const color = this.defaultPreview ? null : (this.product.color || (this.product.colors || [])[0]);
|
|
87
|
+
const color = this.defaultPreview ? null : (this.color || this.product.color || (this.product.colors || [])[0]);
|
|
85
88
|
const product = this.product?.product || this.product;
|
|
86
89
|
return getColorImage(product, this.size, this.side, color) || getProductCover(product, this.size, this.side, color);
|
|
87
90
|
},
|
|
@@ -102,11 +105,14 @@ export default {
|
|
|
102
105
|
this.$modal.show(
|
|
103
106
|
ImageViewer,
|
|
104
107
|
{
|
|
105
|
-
items: this.products.map(product =>
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
items: this.products.map(product => {
|
|
109
|
+
const p = product.product || product;
|
|
110
|
+
return {
|
|
111
|
+
src: getColorImage(p, 'large', this.side, this.color) || getProductCover(p, this.size, this.side, this.color),
|
|
112
|
+
print: this.print,
|
|
113
|
+
color: this.color?.rgb || product.color?.rgb
|
|
114
|
+
};
|
|
115
|
+
}),
|
|
110
116
|
index: this.products.indexOf(this.product)
|
|
111
117
|
},
|
|
112
118
|
{
|
|
@@ -82,6 +82,11 @@ export default {
|
|
|
82
82
|
return this.invoice || this.order;
|
|
83
83
|
}
|
|
84
84
|
},
|
|
85
|
+
mounted() {
|
|
86
|
+
if (this.$route.query.checkPayment && this.model.failedCharge) {
|
|
87
|
+
this.handleErrors({ error_description: this.model.failedCharge })
|
|
88
|
+
}
|
|
89
|
+
},
|
|
85
90
|
methods: {
|
|
86
91
|
handleErrors(err) {
|
|
87
92
|
// err.messages.forEach(({ message }) => this.$toastr.e(message));
|
|
@@ -96,9 +101,22 @@ export default {
|
|
|
96
101
|
if (card) {
|
|
97
102
|
const { _id: invoice } = this.invoice || {};
|
|
98
103
|
const recaptchaToken = await this.getRecaptcha('order_payment');
|
|
99
|
-
const payload = {
|
|
100
|
-
|
|
101
|
-
|
|
104
|
+
const payload = {
|
|
105
|
+
invoice,
|
|
106
|
+
card,
|
|
107
|
+
shop: this.shop._id,
|
|
108
|
+
country: this.country?._id,
|
|
109
|
+
payment: this.payment,
|
|
110
|
+
currency: this.currency?.isoCode,
|
|
111
|
+
recaptchaToken,
|
|
112
|
+
path: window.location.pathname
|
|
113
|
+
};
|
|
114
|
+
const result = await api.createOrderPayment(this.order._id, payload);
|
|
115
|
+
if (result.redirect_url) {
|
|
116
|
+
window.location.href = result.redirect_url;
|
|
117
|
+
} else {
|
|
118
|
+
this.model.paid = result.paid;
|
|
119
|
+
}
|
|
102
120
|
}
|
|
103
121
|
} catch (e) {
|
|
104
122
|
console.log('handleErrors: ', e);
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
<product-side-with-print
|
|
8
8
|
:product="product"
|
|
9
9
|
:side="side"
|
|
10
|
+
:color="color"
|
|
10
11
|
:default-preview="defaultPreview"
|
|
11
12
|
size="medium" />
|
|
12
13
|
</div>
|
|
@@ -31,6 +32,9 @@ export default {
|
|
|
31
32
|
type: Object,
|
|
32
33
|
required: true
|
|
33
34
|
},
|
|
35
|
+
defaultColor: {
|
|
36
|
+
type: Object
|
|
37
|
+
},
|
|
34
38
|
defaultPreview: {
|
|
35
39
|
type: Boolean,
|
|
36
40
|
default: true
|
|
@@ -39,6 +43,10 @@ export default {
|
|
|
39
43
|
computed: {
|
|
40
44
|
sides() {
|
|
41
45
|
return Object.keys(this.product.printsThumbnails || {});
|
|
46
|
+
},
|
|
47
|
+
color() {
|
|
48
|
+
const simpleProduct = this.product.simpleProducts?.find(sp => sp.amount > 0);
|
|
49
|
+
return this.defaultColor || simpleProduct?.color;
|
|
42
50
|
}
|
|
43
51
|
}
|
|
44
52
|
};
|
|
@@ -132,11 +132,11 @@ export default {
|
|
|
132
132
|
if ((print.products || []).indexOf(this.product.guid) > 0) {
|
|
133
133
|
isFreePricing = true;
|
|
134
134
|
}
|
|
135
|
-
const printCost = print.costType === 'setup only' ? 0 : print.printCost;
|
|
136
|
-
const setupCost = (print.costType === 'item cost only' || isFreePricing) ? 0 : print.setupCost;
|
|
135
|
+
const printCost = (print.costType === 'setup only' ? 0 : print.printCost) || 0;
|
|
136
|
+
const setupCost = ((print.costType === 'item cost only' || isFreePricing) ? 0 : print.setupCost) || 0;
|
|
137
137
|
return total + this.amount * printCost + setupCost;
|
|
138
138
|
}, 0);
|
|
139
|
-
const productsTotal = this.simpleProducts.reduce((total, { amount = 0, productCost = 0 }) => total + amount * productCost, 0);
|
|
139
|
+
const productsTotal = this.simpleProducts.reduce((total, { amount = 0, productCost = 0 }) => total + (amount || 0) * (productCost || 0), 0);
|
|
140
140
|
return this.amount > 0 ? (printsTotal + productsTotal) : 0;
|
|
141
141
|
}
|
|
142
142
|
}
|
|
@@ -22,6 +22,11 @@ export default {
|
|
|
22
22
|
errorMessage: null
|
|
23
23
|
};
|
|
24
24
|
},
|
|
25
|
+
created() {
|
|
26
|
+
if (this.quote.order) {
|
|
27
|
+
this.order = this.quote.order;
|
|
28
|
+
}
|
|
29
|
+
},
|
|
25
30
|
computed: {
|
|
26
31
|
...mapGetters(['MESSAGES']),
|
|
27
32
|
...mapGetters('quote', ['quote', 'option', 'proceedOption', 'selectedOption', 'depositInfo', 'shopContacts', 'quoteAddress', 'quoteId', 'options', 'gstTax']),
|
package/mixins/payment.js
CHANGED
|
@@ -52,8 +52,10 @@ export default {
|
|
|
52
52
|
currency: this.currency?.isoCode,
|
|
53
53
|
recaptchaToken: await this.getRecaptcha('order_payment')
|
|
54
54
|
};
|
|
55
|
-
await this.submitPayment(data);
|
|
56
|
-
|
|
55
|
+
const success = await this.submitPayment(data);
|
|
56
|
+
if (success) {
|
|
57
|
+
this.onOrderSucces();
|
|
58
|
+
}
|
|
57
59
|
} catch (e) {
|
|
58
60
|
const { message } = (e.response && e.response.data) || e;
|
|
59
61
|
this.handleErrors({ messages: [{ message }] });
|
package/package.json
CHANGED
package/pages/checkout/order.vue
CHANGED
|
@@ -24,6 +24,11 @@ export default {
|
|
|
24
24
|
CartPriceInfo: () => import('@lancom/shared/components/checkout/cart/cart_price_info/cart-price-info')
|
|
25
25
|
},
|
|
26
26
|
mixins: [metaInfo, CartMixin],
|
|
27
|
+
async asyncData({ store, query }) {
|
|
28
|
+
if (query.order) {
|
|
29
|
+
await store.dispatch('order/loadOrderData', query.order);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
27
32
|
computed: {
|
|
28
33
|
...mapGetters('cart', ['entities', 'coupon', 'cartPricing'])
|
|
29
34
|
},
|
package/store/order.js
CHANGED
|
@@ -13,6 +13,10 @@ export const getters = {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export const actions = {
|
|
16
|
+
async loadOrderData({ commit }, token) {
|
|
17
|
+
const response = await api.fetchOrderByToken(token);
|
|
18
|
+
commit('setOrderData', response);
|
|
19
|
+
},
|
|
16
20
|
async createOrder({ commit }, data) {
|
|
17
21
|
const { shop, products, pricing, recaptchaToken } = data;
|
|
18
22
|
const order = generateOrderData(data, products, pricing);
|
|
@@ -22,8 +26,12 @@ export const actions = {
|
|
|
22
26
|
async submitPayment({ commit, state: { orderData } }, { card, payment, country, shop, currency, recaptchaToken }) {
|
|
23
27
|
const { _id } = orderData || {};
|
|
24
28
|
const response = await api.createOrderPayment(_id, { card, shop, country, payment, currency, recaptchaToken });
|
|
29
|
+
if (response.redirect_url) {
|
|
30
|
+
window.location.href = response.redirect_url;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
25
33
|
commit('setOrderData', response);
|
|
26
|
-
return
|
|
34
|
+
return true;
|
|
27
35
|
},
|
|
28
36
|
async saveOrder({ commit }, data) {
|
|
29
37
|
const response = await api.updateOrder(data._id, data);
|