@lancom/shared 0.0.236 → 0.0.237

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.
@@ -95,9 +95,9 @@ const api = {
95
95
  fetchOrderByToken(token, params) {
96
96
  return _get(`order/token/${token}`, params);
97
97
  },
98
- createOrderPayment(id, { card, shop, country, invoice, payment }) {
98
+ createOrderPayment(id, { card, shop, country, invoice, payment, recaptchaToken }) {
99
99
  const url = invoice ? `shop/${shop}/order/${id}/invoice/${invoice}/payment` : `shop/${shop}/order/${id}/payment`;
100
- return _post(url, { card, country, payment });
100
+ return _post(url, { card, country, payment, recaptchaToken });
101
101
  },
102
102
  addOrderTimeline(id, item) {
103
103
  return _post(`order/${id}/timeline`, item);
@@ -155,8 +155,10 @@ export default {
155
155
  try {
156
156
  this.creating = true;
157
157
  if (!this.orderData) {
158
+ const recaptchaToken = await this.getRecaptcha('create_order');
158
159
  await this.createOrder({
159
160
  ...this.order,
161
+ recaptchaToken,
160
162
  products: this.entities,
161
163
  pricing: this.cartPricing,
162
164
  shop: this.shop._id,
@@ -92,8 +92,10 @@ export default {
92
92
  try {
93
93
  this.processing = true;
94
94
  if (!this.orderData) {
95
+ const recaptchaToken = await this.getRecaptcha('create_order');
95
96
  await this.createOrder({
96
97
  ...this.order,
98
+ recaptchaToken,
97
99
  products: this.entities,
98
100
  pricing: this.cartPricing,
99
101
  shop: this.shop._id,
@@ -336,7 +336,9 @@ export default {
336
336
  async submit() {
337
337
  try {
338
338
  this.processing = true;
339
+ const recaptchaToken = await this.getRecaptcha('create_order');
339
340
  await this.createOrder({
341
+ recaptchaToken,
340
342
  currency: this.currency?._id,
341
343
  country: this.country?._id,
342
344
  billingAddress: this.form,
@@ -161,7 +161,13 @@ export default {
161
161
  },
162
162
  async proceedPayment(card) {
163
163
  try {
164
- const data = { card, shop: this.shop._id, country: this.country?._id, payment: this.payment };
164
+ const data = {
165
+ card,
166
+ shop: this.shop._id,
167
+ country: this.country?._id,
168
+ payment: this.payment,
169
+ recaptchaToken: await this.getRecaptcha('order_payment')
170
+ };
165
171
  await this.submitPayment(data);
166
172
  this.clearCart();
167
173
  this.clearTemplate();
@@ -95,7 +95,8 @@ export default {
95
95
  const card = await this.$refs.paymentCart.tokenize();
96
96
  if (card) {
97
97
  const { _id: invoice } = this.invoice || {};
98
- const payload = { invoice, card, shop: this.shop._id, country: this.country?._id, payment: this.payment };
98
+ const recaptchaToken = await this.getRecaptcha('order_payment');
99
+ const payload = { invoice, card, shop: this.shop._id, country: this.country?._id, payment: this.payment, recaptchaToken };
99
100
  const { paid } = await api.createOrderPayment(this.order._id, payload);
100
101
  this.model.paid = paid;
101
102
  }
@@ -35,7 +35,8 @@ export default {
35
35
  async convertToOrder(option) {
36
36
  try {
37
37
  this.processing = true;
38
- this.order = await this.createOrder(option);
38
+ const recaptchaToken = await this.getRecaptcha('create_order');
39
+ this.order = await this.createOrder({ ...option, recaptchaToken });
39
40
  this.setOrder(this.order);
40
41
  gtm.purchase(this.order);
41
42
  gapis.surveyOptin(this.order, this.shop);
@@ -47,14 +48,16 @@ export default {
47
48
  this.processing = false;
48
49
  }
49
50
  },
50
- createOrder(option) {
51
+ async createOrder(option) {
52
+ const recaptchaToken = await this.getRecaptcha('create_order');
51
53
  const orderData = {
54
+ recaptchaToken,
52
55
  shop: this.shop._id,
53
56
  country: this.country?._id,
54
57
  currency: this.currency?._id,
55
58
  ...convertQuoteToOrder(this.quote, option)
56
59
  };
57
- return api.createOrder(orderData, this.shop._id);
60
+ return await api.createOrder(orderData, this.shop._id);
58
61
  }
59
62
  }
60
63
  };
package/mixins/payment.js CHANGED
@@ -44,7 +44,13 @@ export default {
44
44
  async proceedPayment(card) {
45
45
  try {
46
46
  this.clearFailedCharge();
47
- const data = { card, shop: this.shop._id, country: this.country, payment: this.payment };
47
+ const data = {
48
+ card,
49
+ shop: this.shop._id,
50
+ country: this.country,
51
+ payment: this.payment,
52
+ recaptchaToken: await this.getRecaptcha('order_payment')
53
+ };
48
54
  await this.submitPayment(data);
49
55
  this.onOrderSucces();
50
56
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lancom/shared",
3
- "version": "0.0.236",
3
+ "version": "0.0.237",
4
4
  "description": "lancom common scripts",
5
5
  "author": "e.tokovenko <e.tokovenko@gmail.com>",
6
6
  "repository": {
package/store/order.js CHANGED
@@ -14,15 +14,14 @@ export const getters = {
14
14
 
15
15
  export const actions = {
16
16
  async createOrder({ commit }, data) {
17
- const { shop, products, pricing } = data;
17
+ const { shop, products, pricing, recaptchaToken } = data;
18
18
  const order = generateOrderData(data, products, pricing);
19
- const response = await api.createOrder(order, shop);
19
+ const response = await api.createOrder({ ...order, recaptchaToken }, shop);
20
20
  commit('setOrderData', response);
21
21
  },
22
- async submitPayment({ commit, state: { orderData } }, { card, payment, country, shop }) {
22
+ async submitPayment({ commit, state: { orderData } }, { card, payment, country, shop, recaptchaToken }) {
23
23
  const { _id } = orderData || {};
24
- debugger;
25
- const response = await api.createOrderPayment(_id, { card, shop, country, payment });
24
+ const response = await api.createOrderPayment(_id, { card, shop, country, payment, recaptchaToken });
26
25
  commit('setOrderData', response);
27
26
  return {};
28
27
  },