diff --git a/headless-commerce/README.adoc b/headless-commerce/README.adoc
new file mode 100644
index 000000000..1fef6b4d0
--- /dev/null
+++ b/headless-commerce/README.adoc
@@ -0,0 +1,3 @@
+
+The files in this directory are used as templates for the ant create-component target, +
+please do not modify them without understanding the effect that it will have on that build target.
\ No newline at end of file
diff --git a/headless-commerce/api/headless-commerce.rest.xml b/headless-commerce/api/headless-commerce.rest.xml
new file mode 100644
index 000000000..f791b9cec
--- /dev/null
+++ b/headless-commerce/api/headless-commerce.rest.xml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/headless-commerce/build.gradle b/headless-commerce/build.gradle
new file mode 100644
index 000000000..0056e3fb9
--- /dev/null
+++ b/headless-commerce/build.gradle
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+dependencies {
+ //Examples of compile-time and runtime dependencies
+
+ //pluginLibsCompile 'junit:junit-dep:4.10'
+ //pluginLibsRuntime 'junit:junit-dep:4.10'
+}
+
+task install {
+ doLast {
+ // Install logic for this plugin
+ }
+}
+
+task uninstall {
+ doLast {
+ // uninstall logic for this plugin
+ }
+}
diff --git a/headless-commerce/config/HeadlessCommerceUiLabels.xml b/headless-commerce/config/HeadlessCommerceUiLabels.xml
new file mode 100644
index 000000000..6b127d138
--- /dev/null
+++ b/headless-commerce/config/HeadlessCommerceUiLabels.xml
@@ -0,0 +1,52 @@
+
+
+
+
+
+ HeadlessCommerce Application
+ HeadlessCommerce应用程序
+ HeadlessCommerce應用程式
+
+
+ OFBiz: HeadlessCommerce
+ OFBiz: HeadlessCommerce
+
+
+ Part of the Apache OFBiz Family of Open Source Software
+ Un modulo della famiglia di software open source Apache OFBiz
+ 开源软件OFBiz的组成部分
+ 開源軟體OFBiz的組成部分
+
+
+ You are not allowed to view this page.
+ 不允许你浏览这个页面。
+ 不允許您檢視這個頁面.
+
+
+ State [${stateCode}] does not in country [${countryCode}]
+
+
+ Invalid country [${countryCode}]
+
+
+ Access denied. Invalid user.
+
+
+
diff --git a/headless-commerce/data/HeadlessCommerceDemoData.xml b/headless-commerce/data/HeadlessCommerceDemoData.xml
new file mode 100644
index 000000000..b76e67e05
--- /dev/null
+++ b/headless-commerce/data/HeadlessCommerceDemoData.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/headless-commerce/data/HeadlessCommerceSecurityGroupDemoData.xml b/headless-commerce/data/HeadlessCommerceSecurityGroupDemoData.xml
new file mode 100644
index 000000000..2ac611fa3
--- /dev/null
+++ b/headless-commerce/data/HeadlessCommerceSecurityGroupDemoData.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/headless-commerce/data/HeadlessCommerceSecurityPermissionSeedData.xml b/headless-commerce/data/HeadlessCommerceSecurityPermissionSeedData.xml
new file mode 100644
index 000000000..fef790a8d
--- /dev/null
+++ b/headless-commerce/data/HeadlessCommerceSecurityPermissionSeedData.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/headless-commerce/data/HeadlessCommerceTypeData.xml b/headless-commerce/data/HeadlessCommerceTypeData.xml
new file mode 100644
index 000000000..b76e67e05
--- /dev/null
+++ b/headless-commerce/data/HeadlessCommerceTypeData.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/headless-commerce/entitydef/entitymodel.xml b/headless-commerce/entitydef/entitymodel.xml
new file mode 100644
index 000000000..adba0b411
--- /dev/null
+++ b/headless-commerce/entitydef/entitymodel.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+ Entity of HeadlessCommerce Component
+ None
+
+
+
+
\ No newline at end of file
diff --git a/headless-commerce/ofbiz-component.xml b/headless-commerce/ofbiz-component.xml
new file mode 100644
index 000000000..4ef2d97f9
--- /dev/null
+++ b/headless-commerce/ofbiz-component.xml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/headless-commerce/servicedef/services.xml b/headless-commerce/servicedef/services.xml
new file mode 100644
index 000000000..e2c85bd51
--- /dev/null
+++ b/headless-commerce/servicedef/services.xml
@@ -0,0 +1,249 @@
+
+
+
+
+ HeadlessCommerce Services
+
+ 1.0
+
+
+
+
+ Contains true if the if the requesting user is valid.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To get the customer's shipping addresses
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To create the postal address with purpose
+
+
+
+
+
+
+
+
+
+
+
+
+ To update the postal address and to add a purpose
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To remove the the party contact mech
+
+
+
+
+
+ creates credit card, gift card, eft account
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ updates credit card, gift card, eft account
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ delete payment method(credit card, giftt card, EFT account)
+
+
+
+
+
+
\ No newline at end of file
diff --git a/headless-commerce/src/main/java/org.apache.ofbiz.hc/api/common/CommonUtil.java b/headless-commerce/src/main/java/org.apache.ofbiz.hc/api/common/CommonUtil.java
new file mode 100644
index 000000000..90dc79c52
--- /dev/null
+++ b/headless-commerce/src/main/java/org.apache.ofbiz.hc/api/common/CommonUtil.java
@@ -0,0 +1,34 @@
+package org.apache.ofbiz.hc.api.common;
+
+import org.apache.ofbiz.base.util.UtilValidate;
+import org.apache.ofbiz.entity.Delegator;
+import org.apache.ofbiz.entity.GenericEntityException;
+import org.apache.ofbiz.entity.GenericValue;
+import org.apache.ofbiz.entity.util.EntityQuery;
+import org.apache.ofbiz.hc.api.customer.CustomerServices;
+
+public class CommonUtil {
+ public static final String MODULE = CommonUtil.class.getName();
+
+ public static GenericValue getProductStore (Delegator delegator, String webSiteId) throws GenericEntityException {
+ if (UtilValidate.isNotEmpty(webSiteId)) {
+ GenericValue webSite = EntityQuery.use(delegator).from("WebSite").where("webSiteId", webSiteId).queryOne();
+ if (webSite != null) {
+ String productStoreId = webSite.getString("productStoreId");
+ if (UtilValidate.isNotEmpty(productStoreId)) {
+ return EntityQuery.use(delegator).from("ProductStore").where("productStoreId", productStoreId).queryOne();
+ }
+ }
+ }
+ return null;
+ }
+ public static boolean isValidCutomer (Delegator delegator, GenericValue userLogin, String customerPartyId) throws GenericEntityException {
+ if (UtilValidate.isNotEmpty(customerPartyId) && userLogin != null && customerPartyId.equalsIgnoreCase(userLogin.getString("partyId"))) {
+ GenericValue partyRole = EntityQuery.use(delegator).from("PartyRole").where("partyId", customerPartyId, "roleTypeId", "CUSTOMER").queryOne();
+ if (partyRole != null) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/headless-commerce/src/main/java/org.apache.ofbiz.hc/api/customer/CustomerHelper.java b/headless-commerce/src/main/java/org.apache.ofbiz.hc/api/customer/CustomerHelper.java
new file mode 100644
index 000000000..fb44cb843
--- /dev/null
+++ b/headless-commerce/src/main/java/org.apache.ofbiz.hc/api/customer/CustomerHelper.java
@@ -0,0 +1,125 @@
+package org.apache.ofbiz.hc.api.customer;
+
+import jdk.nashorn.internal.runtime.logging.DebugLogger;
+import org.apache.ofbiz.base.util.Debug;
+import org.apache.ofbiz.base.util.UtilMisc;
+import org.apache.ofbiz.base.util.UtilProperties;
+import org.apache.ofbiz.base.util.UtilValidate;
+import org.apache.ofbiz.entity.Delegator;
+import org.apache.ofbiz.entity.GenericEntityException;
+import org.apache.ofbiz.entity.GenericValue;
+import org.apache.ofbiz.entity.condition.EntityCondition;
+import org.apache.ofbiz.entity.condition.EntityOperator;
+import org.apache.ofbiz.entity.util.EntityQuery;
+import org.apache.ofbiz.party.party.PartyHelper;
+import org.apache.ofbiz.service.GenericServiceException;
+import org.apache.ofbiz.service.LocalDispatcher;
+import org.apache.ofbiz.service.ServiceUtil;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class CustomerHelper {
+ public static final String MODULE = CustomerServices.class.getName();
+
+ public static Map getLoyaltyPoints(LocalDispatcher dispatcher, String customerPartyId, GenericValue userLogin) throws GenericServiceException {
+ Map loyaltyPointMap = new HashMap<>();
+ if (UtilValidate.isNotEmpty(customerPartyId)) {
+ //TODO: Need to make it configurable
+ int monthsToInclude = 12;
+ Map result = dispatcher.runSync("getOrderedSummaryInformation",
+ UtilMisc.toMap("partyId", customerPartyId, "roleTypeId", "PLACING_CUSTOMER",
+ "orderTypeId", "SALES_ORDER", "statusId", "ORDER_COMPLETED", "monthsToInclude", monthsToInclude, "userLogin", userLogin));
+ if (!ServiceUtil.isSuccess(result)) {
+ Debug.logError(ServiceUtil.getErrorMessage(result), MODULE);
+ return null;
+ }
+ loyaltyPointMap.put("points", result.get("totalSubRemainingAmount"));
+ loyaltyPointMap.put("totalOrders", result.get("totalOrders"));
+ loyaltyPointMap.put("monthsToInclude", monthsToInclude);
+ }
+ return loyaltyPointMap;
+ }
+ public static List