@lancom/shared 0.0.354 → 0.0.355
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/utils/shop.js +4 -0
- package/components/checkout/order/order-payment-information/order-payment-information.vue +19 -7
- package/components/common/payment/payment_card/googlepay/googlepay.scss +73 -0
- package/components/common/payment/payment_card/googlepay/googlepay.vue +185 -0
- package/components/common/payment/payment_card/payment-card.vue +7 -0
- package/mixins/payment.js +1 -1
- package/package.json +1 -1
- package/store/index.js +4 -1
package/assets/js/utils/shop.js
CHANGED
|
@@ -4,6 +4,10 @@ export function getShopCountrySettings(shop, country) {
|
|
|
4
4
|
|
|
5
5
|
return {
|
|
6
6
|
...shop.settings,
|
|
7
|
+
contacts: {
|
|
8
|
+
...(shop.settings.app || {}),
|
|
9
|
+
...settingsValues(countrySetting?.settings?.app)
|
|
10
|
+
},
|
|
7
11
|
contacts: {
|
|
8
12
|
...shop.settings.contacts,
|
|
9
13
|
...settingsValues(countrySetting?.settings?.contacts)
|
|
@@ -11,23 +11,31 @@
|
|
|
11
11
|
<div class="form-row OrderPaymentInformation__form">
|
|
12
12
|
<label
|
|
13
13
|
class="form-label OrderPaymentInformation__checkbox"
|
|
14
|
-
@click="updatePaymentType(
|
|
15
|
-
<checked-icon :checked="
|
|
14
|
+
@click="updatePaymentType('card')">
|
|
15
|
+
<checked-icon :checked="paymentMethod === 'card'" />
|
|
16
16
|
<span class="lc_regular12 lc__grey1 OrderPaymentInformation__checkbox-label">
|
|
17
17
|
Credit Card
|
|
18
18
|
</span>
|
|
19
19
|
</label>
|
|
20
20
|
<label
|
|
21
21
|
class="form-label OrderPaymentInformation__checkbox"
|
|
22
|
-
@click="updatePaymentType(
|
|
23
|
-
<checked-icon :checked="
|
|
22
|
+
@click="updatePaymentType('deposit')">
|
|
23
|
+
<checked-icon :checked="paymentMethod === 'deposit'" />
|
|
24
24
|
<span class="lc_regular12 lc__grey1 OrderPaymentInformation__checkbox-label">
|
|
25
25
|
Bank Transfer
|
|
26
26
|
</span>
|
|
27
27
|
</label>
|
|
28
|
+
<label
|
|
29
|
+
class="form-label OrderPaymentInformation__checkbox"
|
|
30
|
+
@click="updatePaymentType('google')">
|
|
31
|
+
<checked-icon :checked="paymentMethod === 'google'" />
|
|
32
|
+
<span class="lc_regular12 lc__grey1 OrderPaymentInformation__checkbox-label">
|
|
33
|
+
Google Pay
|
|
34
|
+
</span>
|
|
35
|
+
</label>
|
|
28
36
|
</div>
|
|
29
37
|
<div
|
|
30
|
-
v-if="
|
|
38
|
+
v-if="paymentMethod === 'deposit'"
|
|
31
39
|
class="OrderPaymentInformation__direct-deposit">
|
|
32
40
|
<div
|
|
33
41
|
class="OrderPaymentInformation__direct-deposit-info"
|
|
@@ -60,6 +68,8 @@
|
|
|
60
68
|
<payment-card
|
|
61
69
|
v-if="orderData"
|
|
62
70
|
ref="paymentCart"
|
|
71
|
+
:key="paymentMethod"
|
|
72
|
+
:google="paymentMethod === 'google'"
|
|
63
73
|
:amount="cartPricing.totalPrice"
|
|
64
74
|
:order="orderData"
|
|
65
75
|
@inited="initedCard">
|
|
@@ -108,6 +118,7 @@ export default {
|
|
|
108
118
|
creating: false,
|
|
109
119
|
submitting: false,
|
|
110
120
|
loadingCard: true,
|
|
121
|
+
paymentMethod: this.order.paymentMethod || ORDER_PAYMENT_METHOD.CARD,
|
|
111
122
|
isDepositPayment: this.order.paymentMethod === ORDER_PAYMENT_METHOD.DEPOSIT
|
|
112
123
|
};
|
|
113
124
|
},
|
|
@@ -162,8 +173,9 @@ export default {
|
|
|
162
173
|
}
|
|
163
174
|
}
|
|
164
175
|
},
|
|
165
|
-
updatePaymentType(
|
|
166
|
-
this.isDepositPayment =
|
|
176
|
+
updatePaymentType(paymentMethod) {
|
|
177
|
+
this.isDepositPayment = paymentMethod === ORDER_PAYMENT_METHOD.DEPOSIT;
|
|
178
|
+
this.paymentMethod = paymentMethod;
|
|
167
179
|
this.errorMessage = null;
|
|
168
180
|
},
|
|
169
181
|
depositInfo(info) {
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
@import "@/assets/scss/ui_kit";
|
|
2
|
+
@import "@/assets/scss/variables";
|
|
3
|
+
|
|
4
|
+
.example {
|
|
5
|
+
margin: 5px;
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: row;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.example > .title {
|
|
11
|
+
width: 250px;
|
|
12
|
+
align-items: center;
|
|
13
|
+
display: inherit;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.example > .demo {
|
|
17
|
+
flex: 1 0 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.example > .demo > * {
|
|
21
|
+
margin: 1px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.Payment {
|
|
25
|
+
&__wrapper {
|
|
26
|
+
.pin-form-field {
|
|
27
|
+
// @extend .form-field;
|
|
28
|
+
// @extend .labelless;
|
|
29
|
+
border-radius: 0px;
|
|
30
|
+
background-color: #F4F4F4;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
&__field-container {
|
|
34
|
+
width: 100%;
|
|
35
|
+
}
|
|
36
|
+
&__message {
|
|
37
|
+
padding: 50px 140px;
|
|
38
|
+
}
|
|
39
|
+
&__content {
|
|
40
|
+
position: relative;
|
|
41
|
+
min-height: 100px;
|
|
42
|
+
}
|
|
43
|
+
&__fileds-spinner {
|
|
44
|
+
background-color: white;
|
|
45
|
+
}
|
|
46
|
+
&__terms {
|
|
47
|
+
margin-top: 20px;
|
|
48
|
+
}
|
|
49
|
+
&__label-with-checkbox {
|
|
50
|
+
display: flex !important;
|
|
51
|
+
align-items: center;
|
|
52
|
+
margin-bottom: 3px !important;
|
|
53
|
+
a {
|
|
54
|
+
color: $green;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.form-row--cols {
|
|
60
|
+
@media (max-width: $bp-extra-small-max) {
|
|
61
|
+
flex-direction: column;
|
|
62
|
+
}
|
|
63
|
+
.col-half {
|
|
64
|
+
@media (max-width: $bp-extra-small-max) {
|
|
65
|
+
flex-basis: 100%;
|
|
66
|
+
width: 100%;
|
|
67
|
+
margin-left: 0 !important;
|
|
68
|
+
&:nth-child(2) {
|
|
69
|
+
margin-top: 20px;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="Payment__wrapper">
|
|
3
|
+
<div v-if="(hasSpinner && processing) || loading">
|
|
4
|
+
<spinner />
|
|
5
|
+
</div>
|
|
6
|
+
<div
|
|
7
|
+
:style="{
|
|
8
|
+
opacity: loading ? 0 : 1
|
|
9
|
+
}">
|
|
10
|
+
<div
|
|
11
|
+
v-if="amount"
|
|
12
|
+
class="form-row">
|
|
13
|
+
<label
|
|
14
|
+
for="payment-amount"
|
|
15
|
+
class="form-label">
|
|
16
|
+
Amount to Pay
|
|
17
|
+
</label>
|
|
18
|
+
<input
|
|
19
|
+
id="payment-amount"
|
|
20
|
+
:value="`${amount} AUD`"
|
|
21
|
+
name="payment-amount"
|
|
22
|
+
placeholder="payment-amount"
|
|
23
|
+
disabled
|
|
24
|
+
type="text"
|
|
25
|
+
class="form-field labelless" />
|
|
26
|
+
</div>
|
|
27
|
+
<div class="examples">
|
|
28
|
+
<div>
|
|
29
|
+
<div class="example">
|
|
30
|
+
<div class="demo">
|
|
31
|
+
<google-pay-button
|
|
32
|
+
v-if="!loading"
|
|
33
|
+
environment="TEST"
|
|
34
|
+
button-type="plain"
|
|
35
|
+
button-color="black"
|
|
36
|
+
v-bind:paymentRequest.prop="{
|
|
37
|
+
apiVersion: 2,
|
|
38
|
+
apiVersionMinor: 0,
|
|
39
|
+
allowedPaymentMethods: [
|
|
40
|
+
{
|
|
41
|
+
type: 'CARD',
|
|
42
|
+
parameters: {
|
|
43
|
+
allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],
|
|
44
|
+
allowedCardNetworks: ['MASTERCARD', 'VISA'],
|
|
45
|
+
},
|
|
46
|
+
tokenizationSpecification: {
|
|
47
|
+
type: 'PAYMENT_GATEWAY',
|
|
48
|
+
parameters: {
|
|
49
|
+
gateway: 'pinpayments',
|
|
50
|
+
gatewayMerchantId: app.PAYMENT_GOOGLE_GATEWAY,
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
merchantInfo: {
|
|
56
|
+
merchantId: app.PAYMENT_GOOGLE_MERCHANT_ID,
|
|
57
|
+
merchantName: app.PAYMENT_GOOGLE_MERCHANT_NAME,
|
|
58
|
+
},
|
|
59
|
+
transactionInfo: {
|
|
60
|
+
totalPriceStatus: 'FINAL',
|
|
61
|
+
totalPriceLabel: 'Total',
|
|
62
|
+
totalPrice: amountString,
|
|
63
|
+
currencyCode: currencyCode,
|
|
64
|
+
countryCode: countryCode
|
|
65
|
+
},
|
|
66
|
+
}"
|
|
67
|
+
@loadpaymentdata="onLoadPaymentData"
|
|
68
|
+
@error="onError" />
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
<slot v-if="!loading" name="controls" v-bind="{ processing }"></slot>
|
|
75
|
+
</div>
|
|
76
|
+
</template>
|
|
77
|
+
|
|
78
|
+
<script>
|
|
79
|
+
import { mapGetters } from 'vuex';
|
|
80
|
+
import '@google-pay/button-element';
|
|
81
|
+
|
|
82
|
+
let timer = null;
|
|
83
|
+
let googlepayStartLoaded = false;
|
|
84
|
+
|
|
85
|
+
export default {
|
|
86
|
+
name: 'Googlepay',
|
|
87
|
+
props: {
|
|
88
|
+
order: {
|
|
89
|
+
type: Object,
|
|
90
|
+
required: true
|
|
91
|
+
},
|
|
92
|
+
amount: {
|
|
93
|
+
type: Number
|
|
94
|
+
},
|
|
95
|
+
hasSpinner: {
|
|
96
|
+
type: Boolean,
|
|
97
|
+
default: true
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
data() {
|
|
101
|
+
return {
|
|
102
|
+
paymentData: null,
|
|
103
|
+
paymentError: null,
|
|
104
|
+
processing: false,
|
|
105
|
+
loading: false,
|
|
106
|
+
fields: null
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
async mounted() {
|
|
110
|
+
this.loading = true;
|
|
111
|
+
await this.loadGooglepay();
|
|
112
|
+
this.loading = false;
|
|
113
|
+
},
|
|
114
|
+
destroyed() {
|
|
115
|
+
clearInterval(timer);
|
|
116
|
+
},
|
|
117
|
+
computed: {
|
|
118
|
+
...mapGetters(['country', 'currency', 'app']),
|
|
119
|
+
amountString() {
|
|
120
|
+
return `${this.amount.toFixed(2)}`;
|
|
121
|
+
},
|
|
122
|
+
currencyCode() {
|
|
123
|
+
return this.currency?.isoCode || 'AUSD';
|
|
124
|
+
},
|
|
125
|
+
countryCode() {
|
|
126
|
+
return this.country?.isoCode || 'AU';
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
methods: {
|
|
130
|
+
onLoadPaymentData(event) {
|
|
131
|
+
const token = JSON.parse(event.detail.paymentMethodData.tokenizationData.token);
|
|
132
|
+
this.paymentData = { google: true, token }
|
|
133
|
+
},
|
|
134
|
+
onError(event) {
|
|
135
|
+
this.paymentError = event.error;
|
|
136
|
+
console.log('this.paymentError: ', this.paymentError);
|
|
137
|
+
},
|
|
138
|
+
tokenize() {
|
|
139
|
+
this.processing = true;
|
|
140
|
+
return new Promise((resolve, reject) => {
|
|
141
|
+
if (this.paymentError || !this.paymentData) {
|
|
142
|
+
reject(!this.paymentData ? 'Payment Failed. Need to choose card' : 'Payment Failed')
|
|
143
|
+
} else {
|
|
144
|
+
resolve(this.paymentData);
|
|
145
|
+
}
|
|
146
|
+
this.processing = false;
|
|
147
|
+
});
|
|
148
|
+
},
|
|
149
|
+
async loadGooglepay() {
|
|
150
|
+
if (process.browser) {
|
|
151
|
+
await (new Promise((resolve, reject) => {
|
|
152
|
+
if (!googlepayStartLoaded) {
|
|
153
|
+
googlepayStartLoaded = true;
|
|
154
|
+
resolve();
|
|
155
|
+
googlepayStartLoaded = false;
|
|
156
|
+
// let domElement = document.createElement('script');
|
|
157
|
+
// domElement.type = "text/javascript";
|
|
158
|
+
// domElement.setAttribute('src', 'https://cdn.pinpayments.com/pin.hosted_fields.v1.js');
|
|
159
|
+
// domElement.onload = () => {
|
|
160
|
+
// resolve();
|
|
161
|
+
// };
|
|
162
|
+
// domElement.onerror = () => {
|
|
163
|
+
// setTimeout(() => this.loadPinpayments(), 1000);
|
|
164
|
+
// };
|
|
165
|
+
// document.body.appendChild(domElement);
|
|
166
|
+
} else {
|
|
167
|
+
let repeated = 0;
|
|
168
|
+
timer = setInterval(() => {
|
|
169
|
+
if (!googlepayStartLoaded || repeated++ > 40) {
|
|
170
|
+
clearInterval(timer);
|
|
171
|
+
resolve();
|
|
172
|
+
}
|
|
173
|
+
}, 500);
|
|
174
|
+
}
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
</script>
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
<style lang="scss" scoped>
|
|
184
|
+
@import 'googlepay.scss';
|
|
185
|
+
</style>
|
|
@@ -17,6 +17,7 @@ import { mapGetters } from 'vuex';
|
|
|
17
17
|
export default {
|
|
18
18
|
name: 'PaymentCard',
|
|
19
19
|
components: {
|
|
20
|
+
Googlepay: () => import('./googlepay/googlepay'),
|
|
20
21
|
Pinpayment: () => import('./pinpayment/pinpayment'),
|
|
21
22
|
Stripe: () => import('./stripe_card/stripe-card'),
|
|
22
23
|
StripePayment: () => import('./stripe_payment/stripe-payment')
|
|
@@ -28,11 +29,17 @@ export default {
|
|
|
28
29
|
},
|
|
29
30
|
amount: {
|
|
30
31
|
type: Number
|
|
32
|
+
},
|
|
33
|
+
google: {
|
|
34
|
+
type: Boolean
|
|
31
35
|
}
|
|
32
36
|
},
|
|
33
37
|
computed: {
|
|
34
38
|
...mapGetters(['payment']),
|
|
35
39
|
cardComponent() {
|
|
40
|
+
if (this.google) {
|
|
41
|
+
return 'googlepay';
|
|
42
|
+
}
|
|
36
43
|
return this.payment?.type || 'stripe-payment';
|
|
37
44
|
}
|
|
38
45
|
},
|
package/mixins/payment.js
CHANGED
|
@@ -38,7 +38,7 @@ export default {
|
|
|
38
38
|
...mapMutations('layers', ['resetLayers']),
|
|
39
39
|
handleErrors(err) {
|
|
40
40
|
// err.messages.forEach(({ message }) => this.$toastr.e(message));
|
|
41
|
-
const defaultMessage = 'Payment error';
|
|
41
|
+
const defaultMessage = typeof err === 'string' ? err : 'Payment error';
|
|
42
42
|
this.errorMessage = (err.messages ? err.messages.map(({ message }) => message).join(', ') : (err.error_description)) || err.message || defaultMessage;
|
|
43
43
|
},
|
|
44
44
|
async proceedPayment(card) {
|
package/package.json
CHANGED
package/store/index.js
CHANGED
|
@@ -13,6 +13,7 @@ export const state = () => ({
|
|
|
13
13
|
payment: null,
|
|
14
14
|
shop: {},
|
|
15
15
|
menus: [],
|
|
16
|
+
app: {},
|
|
16
17
|
contacts: {},
|
|
17
18
|
orderInfo: {},
|
|
18
19
|
pricing: {},
|
|
@@ -23,6 +24,7 @@ export const state = () => ({
|
|
|
23
24
|
});
|
|
24
25
|
|
|
25
26
|
export const getters = {
|
|
27
|
+
app: ({ app }) => app,
|
|
26
28
|
stockCountry: ({ stockCountry }) => stockCountry,
|
|
27
29
|
country: ({ country }) => country,
|
|
28
30
|
countries: ({ shop }) => (shop.countries || []).map(({ country }) => country).filter(c => !!c),
|
|
@@ -147,7 +149,8 @@ export const mutations = {
|
|
|
147
149
|
setCurrency(state, currency) {
|
|
148
150
|
state.currency = currency;
|
|
149
151
|
},
|
|
150
|
-
setSettings(state, { contacts, notificationBar, discountPopup, order, depositInfo, pricing }) {
|
|
152
|
+
setSettings(state, { contacts, notificationBar, discountPopup, order, depositInfo, pricing, app }) {
|
|
153
|
+
state.app = app;
|
|
151
154
|
state.contacts = contacts;
|
|
152
155
|
state.orderInfo = order;
|
|
153
156
|
state.notificationBar = notificationBar;
|