cloudcommerce 0.8.7 → 0.9.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.
Files changed (158) hide show
  1. package/.github/renovate.json +1 -2
  2. package/CHANGELOG.md +44 -0
  3. package/ecomplus-stores/monocard/functions/core/package.json +1 -1
  4. package/ecomplus-stores/monocard/functions/events/package.json +2 -2
  5. package/ecomplus-stores/monocard/functions/modules/package.json +2 -2
  6. package/ecomplus-stores/monocard/functions/passport/package.json +2 -2
  7. package/ecomplus-stores/monocard/functions/ssr/content/layout.json +37 -0
  8. package/ecomplus-stores/monocard/functions/ssr/package.json +6 -6
  9. package/ecomplus-stores/monocard/functions/ssr/src/components/FeatureTabs.astro +1 -1
  10. package/ecomplus-stores/monocard/functions/ssr/src/components/FeatureTabs.vue +23 -10
  11. package/ecomplus-stores/monocard/functions/ssr/src/components/PitchBar.vue +2 -2
  12. package/ecomplus-stores/monocard/functions/ssr/src/components/ShopHeader.vue +11 -10
  13. package/ecomplus-stores/monocard/functions/ssr/src/components/ShopSidenavCategory.vue +2 -2
  14. package/ecomplus-stores/monocard/functions/ssr/src/layouts/Pages.astro +28 -14
  15. package/ecomplus-stores/monocard/functions/ssr/src/main/Home.astro +3 -3
  16. package/ecomplus-stores/monocard/functions/ssr/src/main/Wildcard.astro +9 -7
  17. package/ecomplus-stores/monocard/functions/ssr/src/pages/[...slug].astro +2 -2
  18. package/ecomplus-stores/monocard/functions/ssr/src/pages/fallback.astro +1 -1
  19. package/ecomplus-stores/monocard/functions/ssr/src/pages/index.astro +2 -2
  20. package/ecomplus-stores/monocard/package.json +1 -1
  21. package/package.json +10 -10
  22. package/packages/api/lib/api.d.ts +27 -11
  23. package/packages/api/package.json +1 -1
  24. package/packages/apps/correios/package.json +3 -3
  25. package/packages/apps/custom-payment/package.json +1 -1
  26. package/packages/apps/custom-shipping/package.json +1 -1
  27. package/packages/apps/datafrete/package.json +3 -3
  28. package/packages/apps/discounts/package.json +1 -1
  29. package/packages/apps/emails/lib/functios-lib/abandoned-carts.js +2 -1
  30. package/packages/apps/emails/lib/functios-lib/abandoned-carts.js.map +1 -1
  31. package/packages/apps/emails/package.json +2 -2
  32. package/packages/apps/emails/src/functios-lib/abandoned-carts.ts +2 -1
  33. package/packages/apps/fb-conversions/package.json +2 -2
  34. package/packages/apps/frenet/lib/functions-lib/tracking-codes.js +2 -1
  35. package/packages/apps/frenet/lib/functions-lib/tracking-codes.js.map +1 -1
  36. package/packages/apps/frenet/package.json +3 -3
  37. package/packages/apps/frenet/src/functions-lib/tracking-codes.ts +2 -1
  38. package/packages/apps/galaxpay/lib/functions-lib/ecom/events-to-galaxpay.js +1 -1
  39. package/packages/apps/galaxpay/lib/functions-lib/ecom/events-to-galaxpay.js.map +1 -1
  40. package/packages/apps/galaxpay/lib/functions-lib/galaxpay/webhook.js +101 -37
  41. package/packages/apps/galaxpay/lib/functions-lib/galaxpay/webhook.js.map +1 -1
  42. package/packages/apps/galaxpay/package.json +3 -3
  43. package/packages/apps/galaxpay/src/functions-lib/ecom/events-to-galaxpay.ts +1 -1
  44. package/packages/apps/galaxpay/src/functions-lib/galaxpay/webhook.ts +123 -39
  45. package/packages/apps/google-analytics/package.json +3 -3
  46. package/packages/apps/infinitepay/package.json +3 -3
  47. package/packages/apps/jadlog/package.json +2 -2
  48. package/packages/apps/loyalty-points/package.json +1 -1
  49. package/packages/apps/melhor-envio/lib/functions-lib/tracking-codes.js +1 -1
  50. package/packages/apps/melhor-envio/lib/functions-lib/tracking-codes.js.map +1 -1
  51. package/packages/apps/melhor-envio/package.json +3 -3
  52. package/packages/apps/melhor-envio/src/functions-lib/tracking-codes.ts +1 -1
  53. package/packages/apps/mercadopago/package.json +3 -3
  54. package/packages/apps/pagarme/package.json +3 -3
  55. package/packages/apps/paghiper/package.json +3 -3
  56. package/packages/apps/pix/package.json +3 -3
  57. package/packages/apps/tiny-erp/package.json +3 -3
  58. package/packages/apps/webhooks/package.json +3 -3
  59. package/packages/cli/package.json +1 -1
  60. package/packages/config/package.json +1 -1
  61. package/packages/emails/package.json +2 -2
  62. package/packages/events/package.json +2 -2
  63. package/packages/firebase/package.json +2 -2
  64. package/packages/i18n/package.json +1 -1
  65. package/packages/modules/package.json +3 -3
  66. package/packages/passport/package.json +2 -2
  67. package/packages/ssr/package.json +5 -5
  68. package/packages/storefront/client.d.ts +1 -1
  69. package/packages/storefront/config/storefront.cms.cjs +17 -12
  70. package/packages/storefront/config/storefront.cms.mjs +17 -12
  71. package/packages/storefront/dist/client/_astro/Carousel.dfb3f26a.js +1 -0
  72. package/packages/storefront/dist/client/_astro/HeroSlider.34436243.js +1 -0
  73. package/packages/storefront/dist/client/_astro/PitchBar.1c993792.js +1 -0
  74. package/packages/storefront/dist/client/_astro/Prices.70885f17.js +1 -0
  75. package/packages/storefront/dist/client/_astro/ShopHeader.e901fad5.js +4 -0
  76. package/packages/storefront/dist/client/_astro/_...slug_.9a31c59e.css +1 -0
  77. package/packages/storefront/dist/client/_astro/_plugin-vue_export-helper.0c2b7f88.js +1 -0
  78. package/packages/storefront/dist/client/_astro/client.4e825332.js +1 -0
  79. package/packages/storefront/dist/client/_astro/{firebase-app.d090c84e.js → firebase-app.247497b8.js} +22 -22
  80. package/packages/storefront/dist/client/_astro/{format-money.ab6b71eb.js → format-money.f09b89ed.js} +1 -1
  81. package/packages/storefront/dist/client/_astro/{hoisted.541b5c05.js → hoisted.56fa2eff.js} +1 -1
  82. package/packages/storefront/dist/client/_astro/index.1eaf97c3.css +1 -0
  83. package/packages/storefront/dist/client/_astro/index.9018a8da.js +1 -0
  84. package/packages/storefront/dist/client/_astro/{modules-info.06ac0727.js → modules-info.2a72e536.js} +1 -1
  85. package/packages/storefront/dist/client/_astro/runtime-dom.esm-bundler.1fd80976.js +1 -0
  86. package/packages/storefront/dist/client/_astro/session-utm.ac492493.js +1 -0
  87. package/packages/storefront/dist/client/img/uploads/ecom-icon.png +0 -0
  88. package/packages/storefront/dist/client/img/uploads/logo.png +0 -0
  89. package/packages/storefront/dist/client/manifest.webmanifest +1 -1
  90. package/packages/storefront/dist/client/sw.js +1 -1
  91. package/packages/storefront/dist/client/workbox-e0d788d4.js +1 -1
  92. package/packages/storefront/dist/server/chunks/{astro.9781c0a7.mjs → astro.39f7f387.mjs} +910 -295
  93. package/packages/storefront/dist/server/chunks/pages/{all.b355675e.mjs → all.b15cad2d.mjs} +408 -246
  94. package/packages/storefront/dist/server/entry.mjs +32 -19
  95. package/packages/storefront/dist/server/manifest.webmanifest +1 -1
  96. package/packages/storefront/package.json +15 -15
  97. package/packages/storefront/server.d.ts +1 -1
  98. package/packages/storefront/src/images/use-ssr-picture.ts +30 -10
  99. package/packages/storefront/src/lib/assets/base.css +4 -2
  100. package/packages/storefront/src/lib/cms.d.ts +14 -18
  101. package/packages/storefront/src/lib/components/Carousel.vue +16 -10
  102. package/packages/storefront/src/lib/components/CarouselControl.vue +2 -2
  103. package/packages/storefront/src/lib/components/Drawer.vue +5 -5
  104. package/packages/storefront/src/lib/components/HeroPicture.astro +54 -0
  105. package/packages/storefront/src/lib/components/LoginForm.vue +3 -2
  106. package/packages/storefront/src/lib/components/SocialNetworkLink.vue +2 -2
  107. package/packages/storefront/src/lib/components/_injection-keys.ts +5 -3
  108. package/packages/storefront/src/lib/components/globals/AImg.vue +4 -5
  109. package/packages/storefront/src/lib/components/globals/ALink.vue +2 -2
  110. package/packages/storefront/src/lib/components/globals/Fade.vue +5 -5
  111. package/packages/storefront/src/lib/composables/use-hero-slider.ts +38 -0
  112. package/packages/storefront/src/lib/composables/use-prices.ts +6 -3
  113. package/packages/storefront/src/lib/composables/use-shop-header.ts +30 -14
  114. package/packages/storefront/src/lib/composables/use-sticky-header.ts +15 -12
  115. package/packages/storefront/src/lib/layouts/Base.astro +1 -1
  116. package/packages/storefront/src/lib/layouts/BaseBody.astro +2 -2
  117. package/packages/storefront/src/lib/layouts/BaseHead.astro +2 -2
  118. package/packages/storefront/src/lib/layouts/sections/use-hero-section.ts +48 -0
  119. package/packages/storefront/src/lib/layouts/use-home-main.ts +16 -0
  120. package/packages/storefront/src/lib/layouts/use-page-layout.ts +41 -0
  121. package/packages/storefront/src/lib/pages/_vue.ts +1 -1
  122. package/packages/storefront/src/lib/scripts/modules-info-preset.ts +5 -2
  123. package/packages/storefront/src/lib/scripts/session-utm.ts +6 -1
  124. package/packages/storefront/src/lib/ssr-context.ts +24 -15
  125. package/packages/storefront/src/lib/state/customer-session.ts +14 -2
  126. package/packages/storefront/src/lib/state/shopping-cart/add-cart-item.ts +8 -10
  127. package/packages/storefront/src/lib/state/shopping-cart.ts +4 -3
  128. package/packages/storefront/src/vue-globals.d.ts +3 -2
  129. package/packages/storefront/tailwind.config.cjs +10 -3
  130. package/packages/storefront/tsconfig.json +3 -1
  131. package/packages/storefront/uno.config.cjs +8 -4
  132. package/packages/types/package.json +1 -1
  133. package/ecomplus-stores/monocard/functions/ssr/content/code.json +0 -5
  134. package/ecomplus-stores/monocard/functions/ssr/content/footer.json +0 -46
  135. package/ecomplus-stores/monocard/functions/ssr/content/header.json +0 -23
  136. package/ecomplus-stores/monocard/functions/ssr/content/menu.json +0 -6
  137. package/ecomplus-stores/monocard/functions/ssr/content/metatags.json +0 -5
  138. package/ecomplus-stores/monocard/functions/ssr/src/components/header/HeaderButtonLink.vue +0 -5
  139. package/ecomplus-stores/monocard/functions/ssr/src/components/header/HeaderButtons.vue +0 -39
  140. package/ecomplus-stores/monocard/functions/ssr/src/components/header/HeaderNav.vue +0 -61
  141. package/ecomplus-stores/monocard/functions/ssr/src/components/header/HeaderNavLink.vue +0 -5
  142. package/packages/storefront/dist/client/_astro/PitchBar.5d55c359.js +0 -1
  143. package/packages/storefront/dist/client/_astro/Prices.55399c72.js +0 -1
  144. package/packages/storefront/dist/client/_astro/ProductCard.7e891c08.js +0 -1
  145. package/packages/storefront/dist/client/_astro/ShopHeader.6bbe1a17.js +0 -4
  146. package/packages/storefront/dist/client/_astro/_...slug_.45f0edaf.css +0 -1
  147. package/packages/storefront/dist/client/_astro/_plugin-vue_export-helper.77ed7c18.js +0 -1
  148. package/packages/storefront/dist/client/_astro/client.0de2f274.js +0 -1
  149. package/packages/storefront/dist/client/_astro/index.ff4f0b30.js +0 -1
  150. package/packages/storefront/dist/client/_astro/runtime-dom.esm-bundler.d2f39f33.js +0 -1
  151. package/packages/storefront/dist/client/_astro/session-utm.72684b84.js +0 -1
  152. package/packages/storefront/dist/client/img/uploads/icon.png +0 -0
  153. package/packages/storefront/dist/client/img/uploads/large-icon.png +0 -0
  154. package/packages/storefront/dist/client/img/uploads/logo.webp +0 -0
  155. package/packages/storefront/src/lib/components/ProductCard.vue +0 -36
  156. package/packages/storefront/src/lib/layouts/PagesHeader.astro +0 -51
  157. /package/packages/storefront/dist/client/_astro/{index.0c833781.css → index.e56fc6b3.css} +0 -0
  158. /package/packages/storefront/dist/client/_astro/{server.1bc2fa51.css → server.1dabec03.css} +0 -0
@@ -1,4 +1,4 @@
1
- import type { ResourceOpQuery, Endpoint, Config, ResponseBody, RequestBody, ErrorBody } from './types';
1
+ import type { Endpoint, Config, ResponseBody, RequestBody, ErrorBody } from './types';
2
2
  declare global {
3
3
  var __apiCache: Record<string, {
4
4
  timestamp: number;
@@ -37,15 +37,20 @@ declare const api: {
37
37
  }>;
38
38
  get: <E extends Endpoint, C extends AbstractedConfig>(endpoint: E, config?: C | undefined) => Promise<Response & {
39
39
  config: Config;
40
- data: E extends `${string}/${string}/${string}` ? any : E extends `products/${string}` ? import("./types").Products : E extends `categories/${string}` ? import("./types").Categories : E extends `brands/${string}` ? import("./types").Brands : E extends `collections/${string}` ? import("./types").Collections : E extends `grids/${string}` ? import("./types").Grids : E extends `carts/${string}` ? import("./types").Carts : E extends `orders/${string}` ? import("./types").Orders : E extends `customers/${string}` ? import("./types").Customers : E extends `stores/${string}` ? import("./types").Stores : E extends `applications/${string}` ? import("./types").Applications : E extends `authentications/${string}` ? import("./types").Authentications : E extends ResourceOpQuery ? import("./types").ResourceListResult<E> : E extends "events/products" | "events/categories" | "events/brands" | "events/collections" | "events/grids" | "events/carts" | "events/orders" | "events/customers" | "events/stores" | "events/applications" | "events/authentications" | `events/products/${string}` | `events/categories/${string}` | `events/brands/${string}` | `events/collections/${string}` | `events/grids/${string}` | `events/carts/${string}` | `events/orders/${string}` | `events/customers/${string}` | `events/stores/${string}` | `events/applications/${string}` | `events/authentications/${string}` | "events/me" ? import("./types").EventsResult<E> : any;
40
+ data: ResponseBody<{
41
+ endpoint: E;
42
+ }>;
41
43
  }>;
42
- post: <E_1 extends Endpoint, C_1 extends AbstractedConfig>(endpoint: E_1, body: E_1 extends "products" | `products/${string}` ? import("./types").ProductSet : E_1 extends "categories" | `categories/${string}` ? import("./types").CategorySet : E_1 extends "brands" | `brands/${string}` ? import("./types").BrandSet : E_1 extends "collections" | `collections/${string}` ? import("./types").CollectionSet : E_1 extends "grids" | `grids/${string}` ? import("./types").GridSet : E_1 extends "carts" | `carts/${string}` ? import("./types").CartSet : E_1 extends "orders" | `orders/${string}` ? import("./types").OrderSet : E_1 extends "customers" | `customers/${string}` ? import("./types").CustomerSet : E_1 extends "stores" | `stores/${string}` ? import("./types").StoreSet : E_1 extends "applications" | `applications/${string}` ? import("./types").ApplicationSet : E_1 extends "authentications" | `authentications/${string}` ? import("./types").AuthenticationSet : any, config?: (E_1 extends "login" | "authenticate" ? AbstractedConfig : C_1) | undefined) => Promise<Response & {
44
+ post: <E extends Endpoint, C extends AbstractedConfig>(endpoint: E, body: RequestBody<{
45
+ endpoint: E;
46
+ method: 'post';
47
+ }>, config?: (E extends "login" | "authenticate" ? AbstractedConfig : C) | undefined) => Promise<Response & {
43
48
  config: Config;
44
- data: E_1 extends "login" ? {
49
+ data: E extends "login" ? {
45
50
  _id: import("./types").ResourceId;
46
51
  store_ids: number[];
47
52
  api_key: string;
48
- } : E_1 extends "authenticate" ? {
53
+ } : E extends "authenticate" ? {
49
54
  my_id: string;
50
55
  access_token: string;
51
56
  expires: string;
@@ -53,7 +58,10 @@ declare const api: {
53
58
  _id: import("./types").ResourceId;
54
59
  };
55
60
  }>;
56
- put: <E_2 extends `products/${string}` | `categories/${string}` | `brands/${string}` | `collections/${string}` | `grids/${string}` | `carts/${string}` | `orders/${string}` | `customers/${string}` | `stores/${string}` | `applications/${string}` | `authentications/${string}` | ("events/products" | "events/categories" | "events/brands" | "events/collections" | "events/grids" | "events/carts" | "events/orders" | "events/customers" | "events/stores" | "events/applications" | "events/authentications" | `events/products/${string}` | `events/categories/${string}` | `events/brands/${string}` | `events/collections/${string}` | `events/grids/${string}` | `events/carts/${string}` | `events/orders/${string}` | `events/customers/${string}` | `events/stores/${string}` | `events/applications/${string}` | `events/authentications/${string}` | "events/me") | `products/${string}/${string}` | `categories/${string}/${string}` | `brands/${string}/${string}` | `collections/${string}/${string}` | `grids/${string}/${string}` | `carts/${string}/${string}` | `orders/${string}/${string}` | `customers/${string}/${string}` | `stores/${string}/${string}` | `applications/${string}/${string}` | `authentications/${string}/${string}` | `slugs/${string}` | "$aggregate/products" | "$aggregate/categories" | "$aggregate/brands" | "$aggregate/collections" | "$aggregate/grids" | "$aggregate/carts" | "$aggregate/orders" | "$aggregate/customers" | "schemas/products" | "schemas/categories" | "schemas/brands" | "schemas/collections" | "schemas/grids" | "schemas/carts" | "schemas/orders" | "schemas/customers" | "schemas/stores" | "schemas/applications" | "schemas/authentications" | "search/v1" | "login" | "authenticate" | "ask-auth-callback" | "check-username", C_2 extends AbstractedConfig>(endpoint: E_2, body: E_2 extends "products" | `products/${string}` ? import("./types").ProductSet : E_2 extends "categories" | `categories/${string}` ? import("./types").CategorySet : E_2 extends "brands" | `brands/${string}` ? import("./types").BrandSet : E_2 extends "collections" | `collections/${string}` ? import("./types").CollectionSet : E_2 extends "grids" | `grids/${string}` ? import("./types").GridSet : E_2 extends "carts" | `carts/${string}` ? import("./types").CartSet : E_2 extends "orders" | `orders/${string}` ? import("./types").OrderSet : E_2 extends "customers" | `customers/${string}` ? import("./types").CustomerSet : E_2 extends "stores" | `stores/${string}` ? import("./types").StoreSet : E_2 extends "applications" | `applications/${string}` ? import("./types").ApplicationSet : E_2 extends "authentications" | `authentications/${string}` ? import("./types").AuthenticationSet : any, config?: C_2 | undefined) => Promise<Response & {
61
+ put: <E_1 extends `products/${string}` | `categories/${string}` | `brands/${string}` | `collections/${string}` | `grids/${string}` | `carts/${string}` | `orders/${string}` | `customers/${string}` | `stores/${string}` | `applications/${string}` | `authentications/${string}` | ("events/products" | "events/categories" | "events/brands" | "events/collections" | "events/grids" | "events/carts" | "events/orders" | "events/customers" | "events/stores" | "events/applications" | "events/authentications" | `events/products/${string}` | `events/categories/${string}` | `events/brands/${string}` | `events/collections/${string}` | `events/grids/${string}` | `events/carts/${string}` | `events/orders/${string}` | `events/customers/${string}` | `events/stores/${string}` | `events/applications/${string}` | `events/authentications/${string}` | "events/me") | `products/${string}/${string}` | `categories/${string}/${string}` | `brands/${string}/${string}` | `collections/${string}/${string}` | `grids/${string}/${string}` | `carts/${string}/${string}` | `orders/${string}/${string}` | `customers/${string}/${string}` | `stores/${string}/${string}` | `applications/${string}/${string}` | `authentications/${string}/${string}` | `slugs/${string}` | "$aggregate/products" | "$aggregate/categories" | "$aggregate/brands" | "$aggregate/collections" | "$aggregate/grids" | "$aggregate/carts" | "$aggregate/orders" | "$aggregate/customers" | "schemas/products" | "schemas/categories" | "schemas/brands" | "schemas/collections" | "schemas/grids" | "schemas/carts" | "schemas/orders" | "schemas/customers" | "schemas/stores" | "schemas/applications" | "schemas/authentications" | "search/v1" | "login" | "authenticate" | "ask-auth-callback" | "check-username", C_1 extends AbstractedConfig>(endpoint: E_1, body: RequestBody<{
62
+ endpoint: E_1;
63
+ method: 'put';
64
+ }>, config?: C_1 | undefined) => Promise<Response & {
57
65
  config: Config;
58
66
  data: null;
59
67
  }>;
@@ -73,15 +81,20 @@ declare const api: {
73
81
  type AbstractedConfig = Omit<Config, 'endpoint' | 'method'>;
74
82
  declare const get: <E extends Endpoint, C extends AbstractedConfig>(endpoint: E, config?: C | undefined) => Promise<Response & {
75
83
  config: Config;
76
- data: E extends `${string}/${string}/${string}` ? any : E extends `products/${string}` ? import("./types").Products : E extends `categories/${string}` ? import("./types").Categories : E extends `brands/${string}` ? import("./types").Brands : E extends `collections/${string}` ? import("./types").Collections : E extends `grids/${string}` ? import("./types").Grids : E extends `carts/${string}` ? import("./types").Carts : E extends `orders/${string}` ? import("./types").Orders : E extends `customers/${string}` ? import("./types").Customers : E extends `stores/${string}` ? import("./types").Stores : E extends `applications/${string}` ? import("./types").Applications : E extends `authentications/${string}` ? import("./types").Authentications : E extends ResourceOpQuery ? import("./types").ResourceListResult<E> : E extends "events/products" | "events/categories" | "events/brands" | "events/collections" | "events/grids" | "events/carts" | "events/orders" | "events/customers" | "events/stores" | "events/applications" | "events/authentications" | `events/products/${string}` | `events/categories/${string}` | `events/brands/${string}` | `events/collections/${string}` | `events/grids/${string}` | `events/carts/${string}` | `events/orders/${string}` | `events/customers/${string}` | `events/stores/${string}` | `events/applications/${string}` | `events/authentications/${string}` | "events/me" ? import("./types").EventsResult<E> : any;
84
+ data: ResponseBody<{
85
+ endpoint: E;
86
+ }>;
77
87
  }>;
78
- declare const post: <E extends Endpoint, C extends AbstractedConfig>(endpoint: E, body: E extends "products" | `products/${string}` ? import("./types").ProductSet : E extends "categories" | `categories/${string}` ? import("./types").CategorySet : E extends "brands" | `brands/${string}` ? import("./types").BrandSet : E extends "collections" | `collections/${string}` ? import("./types").CollectionSet : E extends "grids" | `grids/${string}` ? import("./types").GridSet : E extends "carts" | `carts/${string}` ? import("./types").CartSet : E extends "orders" | `orders/${string}` ? import("./types").OrderSet : E extends "customers" | `customers/${string}` ? import("./types").CustomerSet : E extends "stores" | `stores/${string}` ? import("./types").StoreSet : E extends "applications" | `applications/${string}` ? import("./types").ApplicationSet : E extends "authentications" | `authentications/${string}` ? import("./types").AuthenticationSet : any, config?: (E extends "login" | "authenticate" ? AbstractedConfig : C) | undefined) => Promise<Response & {
88
+ declare const post: <E extends Endpoint, C extends AbstractedConfig>(endpoint: E, body: RequestBody<{
89
+ endpoint: E;
90
+ method: 'post';
91
+ }>, config?: (E extends "login" | "authenticate" ? AbstractedConfig : C) | undefined) => Promise<Response & {
79
92
  config: Config;
80
- data: E_1 extends "login" ? {
93
+ data: E extends "login" ? {
81
94
  _id: import("./types").ResourceId;
82
95
  store_ids: number[];
83
96
  api_key: string;
84
- } : E_1 extends "authenticate" ? {
97
+ } : E extends "authenticate" ? {
85
98
  my_id: string;
86
99
  access_token: string;
87
100
  expires: string;
@@ -89,7 +102,10 @@ declare const post: <E extends Endpoint, C extends AbstractedConfig>(endpoint: E
89
102
  _id: import("./types").ResourceId;
90
103
  };
91
104
  }>;
92
- declare const put: <E extends `products/${string}` | `categories/${string}` | `brands/${string}` | `collections/${string}` | `grids/${string}` | `carts/${string}` | `orders/${string}` | `customers/${string}` | `stores/${string}` | `applications/${string}` | `authentications/${string}` | ("events/products" | "events/categories" | "events/brands" | "events/collections" | "events/grids" | "events/carts" | "events/orders" | "events/customers" | "events/stores" | "events/applications" | "events/authentications" | `events/products/${string}` | `events/categories/${string}` | `events/brands/${string}` | `events/collections/${string}` | `events/grids/${string}` | `events/carts/${string}` | `events/orders/${string}` | `events/customers/${string}` | `events/stores/${string}` | `events/applications/${string}` | `events/authentications/${string}` | "events/me") | `products/${string}/${string}` | `categories/${string}/${string}` | `brands/${string}/${string}` | `collections/${string}/${string}` | `grids/${string}/${string}` | `carts/${string}/${string}` | `orders/${string}/${string}` | `customers/${string}/${string}` | `stores/${string}/${string}` | `applications/${string}/${string}` | `authentications/${string}/${string}` | `slugs/${string}` | "$aggregate/products" | "$aggregate/categories" | "$aggregate/brands" | "$aggregate/collections" | "$aggregate/grids" | "$aggregate/carts" | "$aggregate/orders" | "$aggregate/customers" | "schemas/products" | "schemas/categories" | "schemas/brands" | "schemas/collections" | "schemas/grids" | "schemas/carts" | "schemas/orders" | "schemas/customers" | "schemas/stores" | "schemas/applications" | "schemas/authentications" | "search/v1" | "login" | "authenticate" | "ask-auth-callback" | "check-username", C extends AbstractedConfig>(endpoint: E, body: E extends "products" | `products/${string}` ? import("./types").ProductSet : E extends "categories" | `categories/${string}` ? import("./types").CategorySet : E extends "brands" | `brands/${string}` ? import("./types").BrandSet : E extends "collections" | `collections/${string}` ? import("./types").CollectionSet : E extends "grids" | `grids/${string}` ? import("./types").GridSet : E extends "carts" | `carts/${string}` ? import("./types").CartSet : E extends "orders" | `orders/${string}` ? import("./types").OrderSet : E extends "customers" | `customers/${string}` ? import("./types").CustomerSet : E extends "stores" | `stores/${string}` ? import("./types").StoreSet : E extends "applications" | `applications/${string}` ? import("./types").ApplicationSet : E extends "authentications" | `authentications/${string}` ? import("./types").AuthenticationSet : any, config?: C | undefined) => Promise<Response & {
105
+ declare const put: <E extends `products/${string}` | `categories/${string}` | `brands/${string}` | `collections/${string}` | `grids/${string}` | `carts/${string}` | `orders/${string}` | `customers/${string}` | `stores/${string}` | `applications/${string}` | `authentications/${string}` | ("events/products" | "events/categories" | "events/brands" | "events/collections" | "events/grids" | "events/carts" | "events/orders" | "events/customers" | "events/stores" | "events/applications" | "events/authentications" | `events/products/${string}` | `events/categories/${string}` | `events/brands/${string}` | `events/collections/${string}` | `events/grids/${string}` | `events/carts/${string}` | `events/orders/${string}` | `events/customers/${string}` | `events/stores/${string}` | `events/applications/${string}` | `events/authentications/${string}` | "events/me") | `products/${string}/${string}` | `categories/${string}/${string}` | `brands/${string}/${string}` | `collections/${string}/${string}` | `grids/${string}/${string}` | `carts/${string}/${string}` | `orders/${string}/${string}` | `customers/${string}/${string}` | `stores/${string}/${string}` | `applications/${string}/${string}` | `authentications/${string}/${string}` | `slugs/${string}` | "$aggregate/products" | "$aggregate/categories" | "$aggregate/brands" | "$aggregate/collections" | "$aggregate/grids" | "$aggregate/carts" | "$aggregate/orders" | "$aggregate/customers" | "schemas/products" | "schemas/categories" | "schemas/brands" | "schemas/collections" | "schemas/grids" | "schemas/carts" | "schemas/orders" | "schemas/customers" | "schemas/stores" | "schemas/applications" | "schemas/authentications" | "search/v1" | "login" | "authenticate" | "ask-auth-callback" | "check-username", C extends AbstractedConfig>(endpoint: E, body: RequestBody<{
106
+ endpoint: E;
107
+ method: 'put';
108
+ }>, config?: C | undefined) => Promise<Response & {
93
109
  config: Config;
94
110
  data: null;
95
111
  }>;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/api",
3
3
  "type": "module",
4
- "version": "0.8.7",
4
+ "version": "0.9.0",
5
5
  "description": "E-Com Plus Cloud Commerce APIs client/adapter",
6
6
  "main": "lib/api.js",
7
7
  "types": "lib/api.d.ts",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-correios",
3
3
  "type": "module",
4
- "version": "0.8.7",
4
+ "version": "0.9.0",
5
5
  "description": "E-Com Plus Cloud Commerce app for Correios shipping calculation",
6
6
  "main": "lib/correios.js",
7
7
  "repository": {
@@ -20,8 +20,8 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@cloudcommerce/api": "workspace:*",
23
- "axios": "^1.3.4",
24
- "xml2js": "^0.4.23"
23
+ "axios": "^1.3.5",
24
+ "xml2js": "^0.5.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@cloudcommerce/types": "workspace:*"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-custom-payment",
3
3
  "type": "module",
4
- "version": "0.8.7",
4
+ "version": "0.9.0",
5
5
  "description": "E-Com Plus Cloud Commerce app for simple custom payment methods",
6
6
  "main": "lib/index.js",
7
7
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-custom-shipping",
3
3
  "type": "module",
4
- "version": "0.8.7",
4
+ "version": "0.9.0",
5
5
  "description": "E-Com Plus Cloud Commerce app for custom shipping methods",
6
6
  "main": "lib/custom-shipping.js",
7
7
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-datafrete",
3
3
  "type": "module",
4
- "version": "0.8.7",
4
+ "version": "0.9.0",
5
5
  "description": "E-Com Plus Cloud Commerce app to integrate Datafrete shipping gateway ",
6
6
  "main": "lib/datafrete.js",
7
7
  "exports": {
@@ -26,8 +26,8 @@
26
26
  "@cloudcommerce/api": "workspace:*",
27
27
  "@cloudcommerce/firebase": "workspace:*",
28
28
  "@ecomplus/utils": "1.5.0-rc.3",
29
- "axios": "^1.3.4",
30
- "firebase-admin": "^11.5.0",
29
+ "axios": "^1.3.5",
30
+ "firebase-admin": "^11.6.0",
31
31
  "firebase-functions": "^4.2.1"
32
32
  },
33
33
  "devDependencies": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-discounts",
3
3
  "type": "module",
4
- "version": "0.8.7",
4
+ "version": "0.9.0",
5
5
  "description": "E-Com Plus Cloud Commerce app for complex discount rules",
6
6
  "main": "lib/discounts.js",
7
7
  "repository": {
@@ -3,13 +3,14 @@ import api from '@cloudcommerce/api';
3
3
  import transactionalMails from '@ecomplus/transactional-mails';
4
4
  import { getFirestore } from 'firebase-admin/firestore';
5
5
  import email from '@cloudcommerce/emails';
6
+ import config from '@cloudcommerce/firebase/lib/config';
6
7
  import triggerActions from './trigger-actions.js';
7
8
  import { getStore } from './utils.js';
8
9
 
9
10
  export default async () => {
10
11
  try {
11
12
  // logger.log('# Check abandoned carts');
12
- const [application] = (await api.get('applications?app_id=1243&fields=hidden_data,data')).data.result;
13
+ const [application] = (await api.get(`applications?app_id=${config.get().apps.emails.appId}&fields=hidden_data,data`)).data.result;
13
14
  const store = getStore();
14
15
  const appData = {
15
16
  ...application.data,
@@ -1 +1 @@
1
- {"version":3,"file":"abandoned-carts.js","sourceRoot":"","sources":["../../src/functios-lib/abandoned-carts.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,+BAA+B,CAAC;AACnD,OAAO,GAAG,MAAM,oBAAoB,CAAC;AACrC,OAAO,kBAAkB,MAAM,+BAA+B,CAAC;AAC/D,OAAO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,GAAG,OAAO,CAAC,aAAa,CAAC;wBAE7C,8DAA8D;wBAC9D,wCAAwC;wBAExC,IAAI,IAAI,IAAI,OAAO,IAAI,EAAE,EAAE;4BACzB,4CAA4C;4BAC5C,MAAM,KAAK,CAAC,IAAI,CAAC;gCACf,EAAE;gCACF,OAAO;gCACP,IAAI;gCACJ,UAAU;gCACV,YAAY,EAAE;oCACZ,KAAK;oCACL,QAAQ;oCACR,IAAI;oCACJ,IAAI;iCACL;gCACD,WAAW;6BACZ,CAAC,CAAC;4BAEH,iBAAiB;4BACjB,YAAY,EAAE;iCACX,GAAG,CAAC,qBAAqB,CAAC;iCAC1B,GAAG,CAAC;gCACH,IAAI,EAAE,IAAI,CAAC,UAAU;6BACtB,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;yBAC1B;qBACF;iBACF;aACF;SACF;KACF;IAAC,OAAO,GAAG,EAAE;QACZ,MAAM,CAAC,KAAK,CAAC,wBAAwB,EAAE,GAAG,CAAC,CAAC;KAC7C;AACH,CAAC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-emails",
3
3
  "type": "module",
4
- "version": "0.8.7",
4
+ "version": "0.9.0",
5
5
  "description": "E-Com Plus Cloud Commerce default transactional email app",
6
6
  "main": "lib/index.js",
7
7
  "repository": {
@@ -23,7 +23,7 @@
23
23
  "@cloudcommerce/emails": "workspace:*",
24
24
  "@cloudcommerce/firebase": "workspace:*",
25
25
  "@ecomplus/transactional-mails": "^2.0.0",
26
- "firebase-admin": "^11.5.0",
26
+ "firebase-admin": "^11.6.0",
27
27
  "firebase-functions": "^3.24.1"
28
28
  },
29
29
  "devDependencies": {
@@ -3,6 +3,7 @@ import api from '@cloudcommerce/api';
3
3
  import transactionalMails from '@ecomplus/transactional-mails';
4
4
  import { getFirestore } from 'firebase-admin/firestore';
5
5
  import email from '@cloudcommerce/emails';
6
+ import config from '@cloudcommerce/firebase/lib/config';
6
7
  import triggerActions from './trigger-actions';
7
8
  import { getStore } from './utils';
8
9
 
@@ -10,7 +11,7 @@ export default async () => {
10
11
  try {
11
12
  // logger.log('# Check abandoned carts');
12
13
  const [application] = (await api.get(
13
- 'applications?app_id=1243&fields=hidden_data,data',
14
+ `applications?app_id=${config.get().apps.emails.appId}&fields=hidden_data,data`,
14
15
  )).data.result;
15
16
 
16
17
  const store = getStore();
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-fb-conversions",
3
3
  "type": "module",
4
- "version": "0.8.7",
4
+ "version": "0.9.0",
5
5
  "description": "E-Com Plus Cloud Commerce app to send carts/orders to Facebook Conversions API",
6
6
  "main": "lib/index.js",
7
7
  "repository": {
@@ -22,7 +22,7 @@
22
22
  "@cloudcommerce/api": "workspace:*",
23
23
  "@cloudcommerce/firebase": "workspace:*",
24
24
  "facebook-nodejs-business-sdk": "^15.0.2",
25
- "firebase-admin": "^11.5.0",
25
+ "firebase-admin": "^11.6.0",
26
26
  "firebase-functions": "^4.2.1"
27
27
  },
28
28
  "devDependencies": {
@@ -1,5 +1,6 @@
1
1
  import api from '@cloudcommerce/api';
2
2
  import logger from 'firebase-functions/logger';
3
+ import config from '@cloudcommerce/firebase/lib/config';
3
4
  import db from './database.js';
4
5
  import updateOrderfulfilllment from './update-fulfillments.js';
5
6
  import fetchTrackingEvents from './fetch-tracking-code.js';
@@ -7,7 +8,7 @@ import removeDeliveredToFirestore from './remove-delivered.js';
7
8
 
8
9
  const getConfig = async () => {
9
10
  try {
10
- const app = (await api.get('applications?app_id=1244&fields=hidden_data')).data.result;
11
+ const app = (await api.get(`applications?app_id=${config.get().apps.frenet.appId}&fields=hidden_data`)).data.result;
11
12
  return app[0].hidden_data;
12
13
  } catch (err) {
13
14
  logger.error('(App Frenet) Error =>', err);
@@ -1 +1 @@
1
- {"version":3,"file":"tracking-codes.js","sourceRoot":"","sources":["../../src/functions-lib/tracking-codes.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,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,EAAE,OAAO,CAAC,CAAC;iCACnD;qCAAM;oCACL,MAAM,CAAC,KAAK,CAAC,0BAA0B,EAAE,GAAG,CAAC,CAAC;iCAC/C;6BACF;yBACF;qBACF;iBACF;gBAED,OAAO,CAAC,IAAI,CAAC,CAAC;YAChB,CAAC,CAAC,CAAC;SACJ;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,SAAS,IAAI,SAAS,CAAC,mBAAmB,EAAE;QAC9C,MAAM,kBAAkB,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACrC,MAAM,CAAC,KAAK,CAAC,0BAA0B,EAAE,GAAG,CAAC,CAAC;QAChD,CAAC,CAAC,CAAC;QAEH,MAAM,0BAA0B,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YAC/C,MAAM,CAAC,KAAK,CAAC,0DAA0D,EAAE,GAAG,CAAC,CAAC;QAChF,CAAC,CAAC,CAAC;QAEH,IAAI,IAAI,IAAI,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;YAChC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBAC7B,MAAM,CAAC,KAAK,CAAC,sDAAsD,EAAE,GAAG,CAAC,CAAC;YAC5E,CAAC,CAAC,CAAC;SACJ;KACF;AACH,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-frenet",
3
3
  "type": "module",
4
- "version": "0.8.7",
4
+ "version": "0.9.0",
5
5
  "description": "E-Com Plus Cloud Commerce app for Frenet shipping calculation",
6
6
  "main": "lib/frenet.js",
7
7
  "exports": {
@@ -25,8 +25,8 @@
25
25
  "dependencies": {
26
26
  "@cloudcommerce/api": "workspace:*",
27
27
  "@cloudcommerce/firebase": "workspace:*",
28
- "axios": "^1.3.4",
29
- "firebase-admin": "^11.5.0",
28
+ "axios": "^1.3.5",
29
+ "firebase-admin": "^11.6.0",
30
30
  "firebase-functions": "^4.2.1"
31
31
  },
32
32
  "devDependencies": {
@@ -1,6 +1,7 @@
1
1
  import type { TrackingDoc } from './database';
2
2
  import api from '@cloudcommerce/api';
3
3
  import logger from 'firebase-functions/logger';
4
+ import config from '@cloudcommerce/firebase/lib/config';
4
5
  import db from './database';
5
6
  import updateOrderfulfilllment from './update-fulfillments';
6
7
  import fetchTrackingEvents from './fetch-tracking-code';
@@ -9,7 +10,7 @@ import removeDeliveredToFirestore from './remove-delivered';
9
10
  const getConfig = async () => {
10
11
  try {
11
12
  const app = (await api.get(
12
- 'applications?app_id=1244&fields=hidden_data',
13
+ `applications?app_id=${config.get().apps.frenet.appId}&fields=hidden_data`,
13
14
  )).data.result;
14
15
 
15
16
  return app[0].hidden_data;
@@ -3,7 +3,7 @@ import { getFirestore } from 'firebase-admin/firestore';
3
3
  import config from '@cloudcommerce/firebase/lib/config';
4
4
  import GalaxpayAxios from '../galaxpay/auth/create-access.js';
5
5
 
6
- const collectionSubscription = getFirestore().collection('subscriptions');
6
+ const collectionSubscription = getFirestore().collection('galaxpaySubscriptions');
7
7
  const handleApiEvent = async ({
8
8
  evName, apiEvent, apiDoc, app,
9
9
  }) => {
@@ -1 +1 @@
1
- {"version":3,"file":"events-to-galaxpay.js","sourceRoot":"","sources":["../../../src/functions-lib/ecom/events-to-galaxpay.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,MAAM,MAAM,oCAAoC,CAAC;AACxD,OAAO,aAAa,MAAM,gCAAgC,CAAC;AAE3D,MAAM,sBAAsB,GAAG,YAAY,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;AAE1E,MAAM,cAAc,GAAoB,KAAK,EAAE,EAC7C,MAAM,EACN,QAAQ,EACR,MAAM,EACN,GAAG,GACJ,EAAE,EAAE;IACH,MAAM,UAAU,G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,CAAC;iCACb;gCACD,IAAI,UAAU,KAAK,GAAG,IAAI,UAAU,KAAK,GAAG,EAAE;oCAC5C,MAAM,CAAC,IAAI,CAAC,8DAA8D,CAAC,CAAC;oCAC5E,OAAO,IAAI,CAAC;iCACb;gCACD,MAAM,GAAG,CAAC;6BACX;yBACF;qBACF;oBACD,MAAM,CAAC,IAAI,CAAC,uDAAuD,CAAC,CAAC;iBACtE;aACF;YACD,OAAO,IAAI,CAAC;SACb;QACD,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC,MAAM,CAAC;QAC5D,MAAM,UAAU,GAAG,WAAW,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,qCAAqC,CAAC;QAE5G,OAAO,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE;YAC5B,GAAG,EAAE,UAAU;YACf,MAAM,EAAE,CAAC,6BAA6B,EAAE,0BAA0B,CAAC;SACpE,CAAC,CAAC;KACJ;IACD,MAAM,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;IACjD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -3,6 +3,7 @@ import { getFirestore } from 'firebase-admin/firestore';
3
3
  import logger from 'firebase-functions/logger';
4
4
  import config from '@cloudcommerce/firebase/lib/config';
5
5
  import { parseStatus, parsePeriodicityToEcom, gerateId } from '../all-parses.js';
6
+ import GalaxpayAxios from './auth/create-access.js';
6
7
  import { updateValueSubscription, checkAmountItemsOrder } from './update-subscription.js';
7
8
 
8
9
  const collectionSubscription = getFirestore().collection('galaxpaySubscriptions');
@@ -17,20 +18,16 @@ const getApp = async () => {
17
18
  });
18
19
  });
19
20
  };
20
- const checkStatus = (financialStatus, GalaxPayTransaction) => {
21
- if (financialStatus.current === parseStatus(GalaxPayTransaction.status)) {
22
- return true;
23
- }
24
- if ((financialStatus.current === 'paid' || financialStatus.current === 'authorized')
25
- && parseStatus(GalaxPayTransaction.status) !== 'refunded') {
21
+ const checkStatusIsEqual = (financialStatus, galaxPayTransactionStatus) => {
22
+ if (financialStatus.current === parseStatus(galaxPayTransactionStatus)) {
26
23
  return true;
27
24
  }
28
25
  return false;
29
26
  };
30
- const checkStatusNotValid = (status) => {
27
+ const checkStatusPaid = (status) => {
31
28
  const parsedStatus = parseStatus(status);
32
- // logger.log('>> Status (', status, ')=> ', parsedStatus);
33
- if (parsedStatus === 'unauthorized' || parsedStatus === 'refunded' || parsedStatus === 'voided') {
29
+ logger.log(`>> Status is ${status} => ${parsedStatus}`);
30
+ if (parsedStatus === 'paid') {
34
31
  return true;
35
32
  }
36
33
  return false;
@@ -55,9 +52,10 @@ const findOrderByTransactionId = (transactionId) => {
55
52
  });
56
53
  };
57
54
  const findOrderById = async (orderId) => new Promise((resolve) => {
58
- api.get(`orders/${orderId}?fields=transactions,financial_status`).then(({ data: order }) => {
59
- resolve(order);
60
- });
55
+ api.get(`orders/${orderId}`)
56
+ .then(({ data: order }) => {
57
+ resolve(order);
58
+ });
61
59
  });
62
60
  const createTransaction = async (res, subscriptionLabel, plan, orderNumber, galaxpayFristTransactionId, GalaxPayTransaction, GalaxPaySubscription, GalaxPayTransactionValue, originalOrderId) => {
63
61
  if (galaxpayFristTransactionId !== GalaxPayTransaction.galaxPayId) {
@@ -153,9 +151,6 @@ const handleWehook = async (req, res) => {
153
151
  const GalaxPayTransactionValue = GalaxPayTransaction.value / 100;
154
152
  logger.log(`> (App GalaxPay) WebHook ${type}, Body ${JSON.stringify(galaxpayHook)}, quantity:
155
153
  ${GalaxPaySubscriptionQuantity}, status: ${GalaxPayTransaction.status} <`);
156
- // if (galaxpayHook.confirmHash) {
157
- // logger.log('> ', galaxpayHook.confirmHash);
158
- // }
159
154
  try {
160
155
  if (type === 'transaction.updateStatus') {
161
156
  const documentSnapshot = await collectionSubscription.doc(originalOrderId).get();
@@ -165,30 +160,69 @@ const handleWehook = async (req, res) => {
165
160
  const {
166
161
  galaxpayFristTransactionId, plan, orderNumber, subscriptionLabel,
167
162
  } = docSubscription.data();
163
+ let galaxPayTransactionStatus;
164
+ let galaxpaySubscriptionStatus;
165
+ let transactionCreatedAt;
166
+ const app = await getApp();
167
+ try {
168
+ // check subscription and transaction status before in galaxpay
169
+ const galaxpayAxios = new GalaxpayAxios({
170
+ galaxpayId: app.hidden_data?.galaxpay_id,
171
+ galaxpayHash: app.hidden_data?.galaxpay_hash,
172
+ });
173
+ await galaxpayAxios.preparing;
174
+ if (galaxpayAxios.axios) {
175
+ let { data } = await galaxpayAxios.axios
176
+ .get(`/transactions?galaxPayIds=${GalaxPayTransaction.galaxPayId}&startAt=0&limit=1`);
177
+ galaxPayTransactionStatus = data.Transactions[0]?.status;
178
+ const dateTimeTransaction = data.Transactions[0]?.createdAt;
179
+ transactionCreatedAt = dateTimeTransaction && new Date(`${dateTimeTransaction} UTC-3`);
180
+ logger.log(`>> Transaction status: ${galaxPayTransactionStatus}`);
181
+ data = (await galaxpayAxios.axios
182
+ .get(`/subscriptions?myIds=${originalOrderId}&startAt=0&limit=1`)).data;
183
+ galaxpaySubscriptionStatus = data.Subscriptions[0]?.status;
184
+ logger.log(`>> Subscription status: ${galaxpaySubscriptionStatus}`);
185
+ }
186
+ } catch (err) {
187
+ logger.warn(`galaxpay webhook Error: get Transaction/Subscription in Galaxpay => ${err?.message}`);
188
+ }
168
189
  if (galaxpayFristTransactionId === GalaxPayTransaction.galaxPayId) {
169
190
  // update frist payment
170
191
  const order = await findOrderById(originalOrderId);
171
192
  // Update value Subscription in GalaxPay
172
193
  // logger.log('plan-> ', JSON.stringify(plan));
173
- // not update subscripton canceled
174
- if (!checkStatusNotValid(GalaxPayTransaction.status) && order.items) {
175
- const app = await getApp();
176
- await updateValueSubscription(app, originalOrderId, order.amount, order.items, plan);
194
+ // subscripton is paid
195
+ if (checkStatusPaid(galaxPayTransactionStatus) && order.items) {
196
+ const oldSubscriptionValue = docSubscription.data()?.value
197
+ || ({ ...order.amount }.total * 100);
198
+ const newValue = checkAmountItemsOrder({ ...order.amount }, [...order.items], { ...plan });
199
+ if (newValue && newValue !== oldSubscriptionValue) {
200
+ await updateValueSubscription(app, originalOrderId, order.amount, order.items, plan);
201
+ collectionSubscription.doc(originalOrderId)
202
+ .set({
203
+ updatedAt: new Date().toISOString(),
204
+ value: newValue,
205
+ }, { merge: true })
206
+ .catch(logger.error);
207
+ }
177
208
  }
178
209
  // logger.log('ORDER: ', JSON.stringify(order.amount), ' **');
179
210
  // logger.log('> order ', order)
180
211
  if (order.financial_status
181
- && checkStatus(order.financial_status, GalaxPayTransaction)) {
212
+ && checkStatusIsEqual(order.financial_status, galaxPayTransactionStatus)) {
213
+ // check status is equal
182
214
  return res.sendStatus(200);
183
215
  }
184
216
  if (order.transactions) {
185
217
  // update payment
186
218
  const transactionId = order.transactions[0]._id;
219
+ let notificationCode = `;${GalaxPayTransaction.tid || ''};`;
220
+ notificationCode += `${GalaxPayTransaction.authorizationCode || ''}`;
187
221
  const bodyPaymentHistory = {
188
- date_time: new Date().toISOString(),
189
- status: parseStatus(GalaxPayTransaction.status),
222
+ date_time: transactionCreatedAt || new Date().toISOString(),
223
+ status: parseStatus(galaxPayTransactionStatus),
190
224
  transaction_id: transactionId,
191
- notification_code: `${type};${galaxpayHook.webhookId}`,
225
+ notification_code: `${type};${galaxpayHook.webhookId}${notificationCode}`,
192
226
  flags: ['GalaxPay'],
193
227
  }; // TODO: incompatible type=> amount and status;;
194
228
  await api.post(`orders/${order._id}/payments_history`, bodyPaymentHistory);
@@ -202,36 +236,66 @@ const handleWehook = async (req, res) => {
202
236
  }
203
237
  } else {
204
238
  /*
205
- add order, because recurrence creates all transactions in the
206
- first transaction when quantity is non-zero,search for the order by ID,
207
- if not found, create the transaction, and if found, check if it will be
208
- necessary to update the transaction status
209
- */
239
+ add order, because recurrence creates all transactions in the
240
+ first transaction when quantity is non-zero,search for the order by ID,
241
+ if not found, create the transaction, and if found, check if it will be
242
+ necessary to update the transaction status
243
+ */
210
244
  const transactionId = String(gerateId(GalaxPayTransaction.galaxPayId));
211
245
  const { result } = await findOrderByTransactionId(transactionId);
212
246
  if (!result || !result.length) {
213
247
  // logger.log('> Not found Transaction in API')
214
- if (!checkStatusNotValid(GalaxPayTransaction.status)
248
+ if (checkStatusPaid(galaxPayTransactionStatus)
215
249
  && checkPayDay(GalaxPayTransaction.payday)) {
216
250
  // necessary to create order
217
251
  return createTransaction(res, subscriptionLabel, plan, orderNumber, galaxpayFristTransactionId, GalaxPayTransaction, GalaxPaySubscription, GalaxPayTransactionValue, originalOrderId);
218
252
  }
219
- // TODO: status 400 or 500?
220
- return res.status(404).send('Status or checkPayDay invalid');
253
+ // fetches the original order again to avoid delay from other webhooks
254
+ let originalOrder;
255
+ try {
256
+ originalOrder = await findOrderById(originalOrderId);
257
+ } catch (err) {
258
+ logger.warn(`Original Order not found (${originalOrderId}) `);
259
+ res.status(404).send({ message: 'Original Order not found' });
260
+ }
261
+ logger.log(`>> Status Original Order: ${originalOrder?.status} `);
262
+ if (originalOrder && galaxpaySubscriptionStatus === 'canceled'
263
+ && originalOrder?.status !== 'cancelled') {
264
+ // console.log('>> galaxpay webhook: Subscription canceled at galapay');
265
+ try {
266
+ await api.patch(`orders/${originalOrderId}`, { status: 'cancelled' });
267
+ collectionSubscription.doc(originalOrderId)
268
+ .set({
269
+ status: 'cancelled',
270
+ updatedAt: new Date().toISOString(),
271
+ }, { merge: true })
272
+ .catch(logger.error);
273
+ return res.sendStatus(200);
274
+ } catch (err) {
275
+ logger.error(err);
276
+ return res.sendStatus(400);
277
+ }
278
+ } else {
279
+ logger.log(`>> galaxpay webhook: Status or checkPayDay invalid => Payday: ${GalaxPayTransaction.payday} now: ${new Date().toISOString()}`);
280
+ return res.status(404).send('Status or checkPayDay invalid');
281
+ }
221
282
  }
222
283
  const order = result[0];
223
284
  if (order.financial_status
224
- && checkStatus(order.financial_status, GalaxPayTransaction)) {
285
+ && checkStatusIsEqual(order.financial_status, galaxPayTransactionStatus)) {
286
+ // check status is equal
225
287
  // logger.log('> Equals Status')
226
288
  return res.sendStatus(200);
227
289
  }
228
290
  // logger.log('> Order id ')
229
291
  // update payment
292
+ let notificationCode = `;${GalaxPayTransaction.tid || ''};`;
293
+ notificationCode += `${GalaxPayTransaction.authorizationCode || ''}`;
230
294
  const bodyPaymentHistory = {
231
- date_time: new Date().toISOString(),
232
- status: parseStatus(GalaxPayTransaction.status),
295
+ date_time: transactionCreatedAt || new Date().toISOString(),
296
+ status: parseStatus(galaxPayTransactionStatus),
233
297
  transaction_id: transactionId,
234
- notification_code: `${type};${galaxpayHook.webhookId}`,
298
+ notification_code: `${type};${galaxpayHook.webhookId}${notificationCode}`,
235
299
  flags: ['GalaxPay'],
236
300
  }; // TODO: incompatible type=> amount and status;
237
301
  await api.post(`orders/${order._id}/payments_history`, bodyPaymentHistory);
@@ -242,8 +306,8 @@ const handleWehook = async (req, res) => {
242
306
  transaction_code: GalaxPayTransaction.authorizationCode || '',
243
307
  },
244
308
  });
245
- if (parseStatus(GalaxPayTransaction.status) === 'voided'
246
- || parseStatus(GalaxPayTransaction.status) === 'refunded') {
309
+ if (parseStatus(galaxPayTransactionStatus) === 'voided'
310
+ || parseStatus(galaxPayTransactionStatus) === 'refunded') {
247
311
  await api.patch(`orders/${order._id}`, { status: 'cancelled' });
248
312
  // logger.log('> UPDATE ORDER OK')
249
313
  return res.sendStatus(200);