@akinon/pz-tabby-extension 1.81.0 → 1.82.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @akinon/pz-tabby-extension
2
2
 
3
+ ## 1.82.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 9db58ad: ZERO-3230: add default values to tabby payment gateway
8
+
3
9
  ## 1.81.0
4
10
 
5
11
  ## 1.80.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/pz-tabby-extension",
3
- "version": "1.81.0",
3
+ "version": "1.82.0",
4
4
  "license": "MIT",
5
5
  "main": "src/index.tsx",
6
6
  "peerDependencies": {
@@ -6,6 +6,7 @@ import FormComponent from '../components/FormComponent';
6
6
  import {
7
7
  fetchData,
8
8
  generateHash,
9
+ getISODateWithMicroseconds,
9
10
  getOrderStatus,
10
11
  getRandomString,
11
12
  groupByProductId
@@ -77,30 +78,32 @@ export const TabbyPaymentGateway = async ({
77
78
  category: item.product.category.name
78
79
  })),
79
80
  buyer_history: {
80
- registered_since: userProfile.date_joined,
81
- loyalty_level: successOrders.count,
82
- wishlist_count: wishlist.count,
83
- is_email_verified: userProfile.is_email_verified,
84
- is_social_networks_connected: userProfile.is_social_networks_connected,
81
+ registered_since: userProfile.date_joined ?? getISODateWithMicroseconds(),
82
+ loyalty_level: successOrders.count ?? 0,
83
+ wishlist_count: wishlist.count ?? 0,
84
+ is_email_verified: userProfile.is_email_verified ?? false,
85
+ is_social_networks_connected:
86
+ userProfile.is_social_networks_connected ?? false,
85
87
  is_phone_number_verified: userProfile.attributes?.verified_phone ?? false
86
88
  },
87
- order_history: orderHistory.results.map((order_history: any) => ({
88
- purchased_at: order_history.created_date,
89
- amount: order_history.amount,
90
- payment_method: order_history.card === null ? 'cod' : 'card',
91
- status: getOrderStatus(order_history.status.value),
92
- buyer: {
93
- phone: order_history.billing_address.phone_number,
94
- email: order_history.billing_address.email,
95
- name: `${order_history.billing_address.first_name} ${order_history.billing_address.last_name}`
96
- },
97
- shipping_address: {
98
- city: order_history.shipping_address.city.name,
99
- address: order_history.shipping_address.line,
100
- zip: order_history.shipping_address.postcode ?? '0'
101
- },
102
- order_items: groupByProductId(order_history.orderitem_set)
103
- }))
89
+ order_history:
90
+ orderHistory?.results?.map((order_history: any) => ({
91
+ purchased_at: order_history.created_date,
92
+ amount: order_history.amount,
93
+ payment_method: order_history.card === null ? 'cod' : 'card',
94
+ status: getOrderStatus(order_history.status.value),
95
+ buyer: {
96
+ phone: order_history.billing_address.phone_number,
97
+ email: order_history.billing_address.email,
98
+ name: `${order_history.billing_address.first_name} ${order_history.billing_address.last_name}`
99
+ },
100
+ shipping_address: {
101
+ city: order_history.shipping_address.city.name,
102
+ address: order_history.shipping_address.line,
103
+ zip: order_history.shipping_address.postcode ?? '0'
104
+ },
105
+ order_items: groupByProductId(order_history.orderitem_set)
106
+ })) ?? []
104
107
  };
105
108
 
106
109
  return (
@@ -64,3 +64,13 @@ export const getOrderStatus = (
64
64
  return OrderServiceStatus.Unknown;
65
65
  }
66
66
  };
67
+
68
+ export const getISODateWithMicroseconds = () => {
69
+ const now = new Date();
70
+ const isoString = now.toISOString();
71
+
72
+ const milliseconds = now.getMilliseconds().toString().padStart(3, '0');
73
+ const microseconds = milliseconds + '650';
74
+
75
+ return isoString.replace(/\.\d{3}Z$/, `.${microseconds}Z`);
76
+ };