@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 +6 -0
- package/package.json +1 -1
- package/src/pages/TabbyPaymentGateway.tsx +25 -22
- package/src/utils/index.ts +10 -0
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -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:
|
|
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:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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 (
|
package/src/utils/index.ts
CHANGED
|
@@ -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
|
+
};
|