cloudcommerce 0.0.111 → 0.0.113
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/.gitmodules +1 -1
- package/CHANGELOG.md +11 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/.firebaserc +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/.github/renovate.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/.github/workflows/build-and-deploy.yml +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/.github/workflows/calibreapp-image-actions.yml +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/.vscode/extensions.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/.vscode/settings.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/LICENSE.md +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/README.md +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/README.pt-BR.md +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/config.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/core/index.js +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/core/package.json +1 -1
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/events/index.js +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/events/package.json +2 -2
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/example.env +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/modules/index.js +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/modules/package.json +2 -2
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/passport/index.js +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/passport/package.json +2 -2
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/astro.config.mjs +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/blog.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/brands.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/categories.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/code.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/collections.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/contacts.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/footer.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/header.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/home.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/info.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/maintenance.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/menu.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/pages/contato.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/pages/entrega.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/pages/faq.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/pages/pagamentos.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/pages/privacidade.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/pages/sobre-nos.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/pages/termos.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/pages/trocas.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/posts/esta-loja-e-um-pwa.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/products.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/search.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/settings.json +7 -7
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/social.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/widgets/analytics.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/widgets/compre-confie.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/widgets/ebit.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/widgets/fb-pixel.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/widgets/gmc-ratings.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/widgets/minicart.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/widgets/offers-notification.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/widgets/opinioes-verificadas.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/widgets/product-card.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/widgets/product.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/widgets/search-engine.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/widgets/search.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/widgets/tag-manager.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/widgets/tawkto.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/widgets/trustvox.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/content/widgets/user.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/index.js +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/package.json +4 -4
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/admin/config.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/assets/cms-preview.css +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/assets/cms.css +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/assets/cvv.png +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/assets/icons/bootstrap-icons/font/storefront-icons.woff2 +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/assets/icons/feather-icons/font/storefront-icons.woff2 +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/assets/icons/font-awesome/font/storefront-icons.woff2 +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/assets/icons/line-awesome/font/storefront-icons.woff2 +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/assets/icons/tabler-icons/font/storefront-icons.woff2 +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/assets/img-placeholder.png +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/assets/payments.png +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/assets/ssl-safe.png +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/img/icon.png +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/img/large-icon.png +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/img/uploads/banner1.png +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/img/uploads/banner2.png +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/img/uploads/banner2.webp +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/img/uploads/favicon.png +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/img/uploads/headless.png +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/img/uploads/headphone.png +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/img/uploads/headphone.webp +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/img/uploads/icon.png +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/img/uploads/large-icon.png +0 -0
- package/ecomplus-stores/monocard/functions/ssr/public/img/uploads/logo.png +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/img/uploads/og-image.png +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/img/uploads/passion.png +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/img/uploads/passion.webp +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/img/uploads/pwa-reliable.png +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/img/uploads/rect8589.png +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/img/uploads/rect859.png +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/img/uploads/rect89.png +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/img/uploads/rect89.webp +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/img/uploads/ssl-safe.png +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/public/robots.txt +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/src/env.d.ts +0 -0
- package/ecomplus-stores/monocard/functions/ssr/src/layouts/Pages.astro +23 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/src/pages/[...slug].astro +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/src/pages/fallback.astro +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/src/pages/index.astro +1 -3
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/src/scripts/InlineScripts.astro +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/tailwind.config.cjs +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/tsconfig.json +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/functions/ssr/uno.config.ts +0 -0
- package/{.ecomplus/stores → ecomplus-stores}/monocard/package.json +1 -1
- package/{.ecomplus/stores → ecomplus-stores}/monocard/scripts/install.sh +0 -0
- package/package.json +2 -1
- package/packages/api/package.json +1 -1
- package/packages/apps/correios/package.json +1 -1
- package/packages/apps/custom-shipping/package.json +1 -1
- package/packages/apps/discounts/package.json +1 -1
- package/packages/apps/frenet/package.json +1 -1
- package/packages/apps/mercadopago/CHANGELOG.md +1 -0
- package/packages/apps/mercadopago/README.md +1 -0
- package/packages/apps/mercadopago/assets/onload-expression.js +138 -0
- package/packages/apps/mercadopago/lib/index.d.ts +1 -0
- package/packages/apps/mercadopago/lib/index.js +3 -0
- package/packages/apps/mercadopago/lib/index.js.map +1 -0
- package/packages/apps/mercadopago/lib/mercadopago.d.ts +86 -0
- package/packages/apps/mercadopago/lib/mercadopago.js +15 -0
- package/packages/apps/mercadopago/lib/mercadopago.js.map +1 -0
- package/packages/apps/mercadopago/lib/mp-create-transaction.d.ts +85 -0
- package/packages/apps/mercadopago/lib/mp-create-transaction.js +270 -0
- package/packages/apps/mercadopago/lib/mp-create-transaction.js.map +1 -0
- package/packages/apps/mercadopago/lib/mp-list-payments.d.ts +7 -0
- package/packages/apps/mercadopago/lib/mp-list-payments.js +175 -0
- package/packages/apps/mercadopago/lib/mp-list-payments.js.map +1 -0
- package/packages/apps/mercadopago/lib/mp-webhook.d.ts +5 -0
- package/packages/apps/mercadopago/lib/mp-webhook.js +119 -0
- package/packages/apps/mercadopago/lib/mp-webhook.js.map +1 -0
- package/packages/apps/mercadopago/package.json +36 -0
- package/packages/apps/mercadopago/scripts/build.sh +5 -0
- package/packages/apps/mercadopago/src/index.ts +2 -0
- package/packages/apps/mercadopago/src/mercadopago.ts +16 -0
- package/packages/apps/mercadopago/src/mp-create-transaction.ts +290 -0
- package/packages/apps/mercadopago/src/mp-list-payments.ts +198 -0
- package/packages/apps/mercadopago/src/mp-webhook.ts +136 -0
- package/packages/apps/mercadopago/tsconfig.json +6 -0
- package/packages/apps/mercadopago/webhook.js +1 -0
- package/packages/apps/tiny-erp/package.json +1 -1
- package/packages/cli/lib/index.js +4 -0
- package/packages/cli/package.json +1 -1
- package/packages/cli/src/index.ts +5 -0
- package/packages/config/package.json +1 -1
- package/packages/events/lib/firebase.js +2 -0
- package/packages/events/lib/firebase.js.map +1 -1
- package/packages/events/package.json +2 -1
- package/packages/events/src/firebase.ts +2 -0
- package/packages/firebase/lib/config.d.ts +3 -0
- package/packages/firebase/lib/config.js +3 -0
- package/packages/firebase/lib/config.js.map +1 -1
- package/packages/firebase/package.json +1 -1
- package/packages/firebase/src/config.ts +3 -0
- package/packages/i18n/package.json +1 -1
- package/packages/modules/lib/firebase/call-app-module.js +14 -0
- package/packages/modules/lib/firebase/call-app-module.js.map +1 -1
- package/packages/modules/package.json +2 -1
- package/packages/modules/src/firebase/call-app-module.ts +14 -0
- package/packages/passport/package.json +1 -1
- package/packages/ssr/package.json +1 -1
- package/packages/storefront/dist/server/entry.mjs +6 -4
- package/packages/storefront/package.json +1 -1
- package/packages/storefront/src/lib/layouts/Pages.astro +4 -3
- package/packages/storefront/src/lib/layouts/PagesHeader.astro +3 -0
- package/packages/types/package.json +1 -1
- package/pnpm-workspace.yaml +3 -3
- package/.ecomplus/stores/monocard/functions/ssr/public/img/uploads/logo.png +0 -0
- package/.ecomplus/stores/monocard/functions/ssr/public/img/uploads/logo.webp +0 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import type { AppModuleBody } from '@cloudcommerce/types';
|
|
2
|
+
import type{ ListPaymentsParams } from '@cloudcommerce/types/modules/list_payments:params';
|
|
3
|
+
import type{ ListPaymentsResponse } from '@cloudcommerce/types/modules/list_payments:response';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import url from 'url';
|
|
7
|
+
|
|
8
|
+
type Gateway = ListPaymentsResponse['payment_gateways'][number]
|
|
9
|
+
type CodePaymentMethod = Gateway['payment_method']['code']
|
|
10
|
+
|
|
11
|
+
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
|
12
|
+
|
|
13
|
+
export default (data: AppModuleBody) => {
|
|
14
|
+
const { application } = data;
|
|
15
|
+
const params = data.params as ListPaymentsParams;
|
|
16
|
+
// https://apx-mods.e-com.plus/api/v1/list_payments/schema.json?store_id=100
|
|
17
|
+
const amount = params.amount || { total: undefined };
|
|
18
|
+
// const initialTotalAmount = amount.total;
|
|
19
|
+
|
|
20
|
+
const config = {
|
|
21
|
+
...application.data,
|
|
22
|
+
...application.hidden_data,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
if (!config.mp_public_key || !config.mp_access_token) {
|
|
26
|
+
// must have configured PayPal app ID and secret
|
|
27
|
+
return {
|
|
28
|
+
error: 'LIST_PAYMENTS_ERR',
|
|
29
|
+
message: 'MP Public Key or Access Token is unset on app hidden data (merchant must configure the app)',
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// start mounting response body
|
|
34
|
+
// https://apx-mods.e-com.plus/api/v1/list_payments/response_schema.json?store_id=100
|
|
35
|
+
const response: ListPaymentsResponse = {
|
|
36
|
+
payment_gateways: [],
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// calculate discount value
|
|
40
|
+
const { discount } = config;
|
|
41
|
+
if (discount && discount.value) {
|
|
42
|
+
if (discount.apply_at !== 'freight') {
|
|
43
|
+
// default discount option
|
|
44
|
+
const { value } = discount;
|
|
45
|
+
response.discount_option = {
|
|
46
|
+
label: config.discount_option_label,
|
|
47
|
+
value,
|
|
48
|
+
};
|
|
49
|
+
// specify the discount type and min amount is optional
|
|
50
|
+
const discountTypeMinAmount = ['type', 'min_amount'];
|
|
51
|
+
discountTypeMinAmount.forEach(
|
|
52
|
+
(prop) => {
|
|
53
|
+
if (response.discount_option && discount[prop]) {
|
|
54
|
+
response.discount_option[prop] = discount[prop];
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (amount.total) {
|
|
61
|
+
// check amount value to apply discount
|
|
62
|
+
if (amount.total < discount.min_amount) {
|
|
63
|
+
discount.value = 0;
|
|
64
|
+
} else {
|
|
65
|
+
delete discount.min_amount;
|
|
66
|
+
|
|
67
|
+
// fix local amount object
|
|
68
|
+
const maxDiscount = amount[discount.apply_at || 'subtotal'];
|
|
69
|
+
let discountValue:number;
|
|
70
|
+
if (discount.type === 'percentage') {
|
|
71
|
+
discountValue = (maxDiscount * discount.value) / 100;
|
|
72
|
+
} else {
|
|
73
|
+
discountValue = discount.value;
|
|
74
|
+
if (discountValue > maxDiscount) {
|
|
75
|
+
discountValue = maxDiscount;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (discountValue) {
|
|
79
|
+
amount.discount = (amount.discount || 0) + discountValue;
|
|
80
|
+
amount.total -= discountValue;
|
|
81
|
+
if (amount.total < 0) {
|
|
82
|
+
amount.total = 0;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// setup payment gateway objects
|
|
90
|
+
const intermediator = {
|
|
91
|
+
code: 'mercadopago',
|
|
92
|
+
link: 'https://www.mercadopago.com.br',
|
|
93
|
+
name: 'Mercado Pago',
|
|
94
|
+
};
|
|
95
|
+
const listPaymentMethods = ['banking_billet', 'credit_card'];
|
|
96
|
+
if (config.account_deposit && config.account_deposit.key_pix) {
|
|
97
|
+
// pix Configured
|
|
98
|
+
listPaymentMethods.push('account_deposit');
|
|
99
|
+
}
|
|
100
|
+
listPaymentMethods.forEach((paymentMethod) => {
|
|
101
|
+
const isCreditCard = paymentMethod === 'credit_card';
|
|
102
|
+
const methodConfig = isCreditCard ? config : config[paymentMethod];
|
|
103
|
+
const minAmount = methodConfig.min_amount || 0;
|
|
104
|
+
const methodEnable = methodConfig.enable || (isCreditCard && !methodConfig.disable);
|
|
105
|
+
if (methodConfig && methodEnable && (amount.total === undefined || amount.total >= minAmount)) {
|
|
106
|
+
let label: string;
|
|
107
|
+
if (methodConfig.label) {
|
|
108
|
+
label = methodConfig.label;
|
|
109
|
+
} else if (isCreditCard) {
|
|
110
|
+
label = 'Cartão de crédito';
|
|
111
|
+
} else {
|
|
112
|
+
label = paymentMethod === 'account_deposit' ? 'Pix' : 'Boleto bancário';
|
|
113
|
+
}
|
|
114
|
+
const gateway:Gateway = {
|
|
115
|
+
label,
|
|
116
|
+
icon: methodConfig.icon,
|
|
117
|
+
text: methodConfig.text,
|
|
118
|
+
payment_method: {
|
|
119
|
+
code: paymentMethod as CodePaymentMethod,
|
|
120
|
+
name: `${label} - ${intermediator.name}`,
|
|
121
|
+
},
|
|
122
|
+
intermediator,
|
|
123
|
+
type: 'payment',
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
if (isCreditCard) {
|
|
127
|
+
if (!gateway.icon) {
|
|
128
|
+
// gateway.icon = `${baseUri}/checkout-stamp.png`; // TODO: baseUri
|
|
129
|
+
gateway.icon = 'https://us-central1-mercadopago-ecom.cloudfunctions.net/app/checkout-stamp.png';
|
|
130
|
+
}
|
|
131
|
+
gateway.js_client = {
|
|
132
|
+
script_uri: 'https://secure.mlstatic.com/sdk/javascript/v1/mercadopago.js',
|
|
133
|
+
onload_expression: `window.Mercadopago.setPublishableKey("${config.mp_public_key}");${
|
|
134
|
+
fs.readFileSync(path.join(__dirname, '../../assets/onload-expression.min.js'), 'utf8')}`,
|
|
135
|
+
cc_brand: {
|
|
136
|
+
function: '_mpBrand',
|
|
137
|
+
is_promise: true,
|
|
138
|
+
},
|
|
139
|
+
cc_hash: {
|
|
140
|
+
function: '_mpHash',
|
|
141
|
+
is_promise: true,
|
|
142
|
+
},
|
|
143
|
+
cc_installments: {
|
|
144
|
+
function: '_mpInstallments',
|
|
145
|
+
is_promise: true,
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// default configured default installments option
|
|
150
|
+
const installmentsOption = config.installments_option;
|
|
151
|
+
if (installmentsOption && installmentsOption.max_number) {
|
|
152
|
+
response.installments_option = installmentsOption;
|
|
153
|
+
const minInstallment = installmentsOption.min_installment;
|
|
154
|
+
|
|
155
|
+
// optional configured installments list
|
|
156
|
+
if (amount.total && Array.isArray(config.installments) && config.installments.length) {
|
|
157
|
+
gateway.installment_options = [];
|
|
158
|
+
config.installments.forEach(({ number, interest }) => {
|
|
159
|
+
if (number >= 2) {
|
|
160
|
+
const value = amount.total / number;
|
|
161
|
+
if (gateway.installment_options && value >= minInstallment) {
|
|
162
|
+
gateway.installment_options.push({
|
|
163
|
+
number,
|
|
164
|
+
value: interest > 0 ? (value + value * interest) / 100 : value,
|
|
165
|
+
tax: Boolean(interest),
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// check available discount by payment method
|
|
175
|
+
if (discount && discount.value && discount[paymentMethod] !== false) {
|
|
176
|
+
gateway.discount = {
|
|
177
|
+
apply_at: 'total',
|
|
178
|
+
type: 'fixed',
|
|
179
|
+
value: 0,
|
|
180
|
+
};
|
|
181
|
+
['apply_at', 'type', 'value'].forEach(
|
|
182
|
+
(field) => {
|
|
183
|
+
if (gateway.discount && discount[field]) {
|
|
184
|
+
gateway.discount[field] = discount[field];
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
);
|
|
188
|
+
if (response.discount_option && !response.discount_option.label) {
|
|
189
|
+
response.discount_option.label = label;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
response.payment_gateways.push(gateway);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
return response;
|
|
198
|
+
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/* eslint-disable import/prefer-default-export */
|
|
2
|
+
import '@cloudcommerce/firebase/lib/init';
|
|
3
|
+
import { logger } from 'firebase-functions';
|
|
4
|
+
import axios from 'axios';
|
|
5
|
+
import api from '@cloudcommerce/api';
|
|
6
|
+
// eslint-disable-next-line import/no-unresolved
|
|
7
|
+
import { getFirestore } from 'firebase-admin/firestore';
|
|
8
|
+
// eslint-disable-next-line import/no-unresolved
|
|
9
|
+
import * as functions from 'firebase-functions/v1';
|
|
10
|
+
import config from '@cloudcommerce/firebase/lib/config';
|
|
11
|
+
import { parsePaymentStatus } from './mp-create-transaction';
|
|
12
|
+
|
|
13
|
+
const ECHO_SKIP = 'SKIP';
|
|
14
|
+
let ECHO_SUCCESS = 'OK';
|
|
15
|
+
|
|
16
|
+
export const mercadopago = {
|
|
17
|
+
webhook: functions
|
|
18
|
+
.region(config.get().httpsFunctionOptions.region)
|
|
19
|
+
.https.onRequest(async (req, res) => {
|
|
20
|
+
const { method } = req;
|
|
21
|
+
if (method === 'POST') {
|
|
22
|
+
const { body } = req;
|
|
23
|
+
logger.log('>> Webhook MP #', JSON.stringify(body), ' <<');
|
|
24
|
+
try {
|
|
25
|
+
const app = (await api.get(
|
|
26
|
+
'applications?app_id=111223&fields=hidden_data',
|
|
27
|
+
)).data.result;
|
|
28
|
+
const accessTokenMp = app[0].hidden_data?.mp_access_token;
|
|
29
|
+
if (accessTokenMp) {
|
|
30
|
+
const notification = req.body;
|
|
31
|
+
if (notification.type !== 'payment' || !notification.data || !notification.data.id) {
|
|
32
|
+
res.status(404).send(ECHO_SKIP);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// setTimeout(() => {
|
|
36
|
+
logger.log('> MP Notification for Payment #', notification.data.id);
|
|
37
|
+
|
|
38
|
+
const docRef = getFirestore().collection('mp_payments')
|
|
39
|
+
.doc(String(notification.data.id));
|
|
40
|
+
|
|
41
|
+
docRef.get()
|
|
42
|
+
.then(async (doc) => {
|
|
43
|
+
if (doc.exists) {
|
|
44
|
+
const data = doc.data();
|
|
45
|
+
const orderId = data?.order_id;
|
|
46
|
+
const order = (await api.get(
|
|
47
|
+
`orders/${orderId}`,
|
|
48
|
+
)).data;
|
|
49
|
+
logger.log('>order ', JSON.stringify(order), '<');
|
|
50
|
+
if (order && order.transactions) {
|
|
51
|
+
const payment = (await axios.get(
|
|
52
|
+
`https://api.mercadopago.com/v1/payments/${notification.data.id}`,
|
|
53
|
+
{
|
|
54
|
+
headers: {
|
|
55
|
+
Authorization: `Bearer ${accessTokenMp}`,
|
|
56
|
+
'Content-Type': 'application/json',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
)).data;
|
|
60
|
+
logger.log('>payment ', JSON.stringify(payment), ' <');
|
|
61
|
+
const methodPayment = payment.payment_method_id;
|
|
62
|
+
|
|
63
|
+
const transaction = order.transactions.find(({ intermediator }) => {
|
|
64
|
+
return intermediator
|
|
65
|
+
&& intermediator.transaction_code === notification.data.id;
|
|
66
|
+
});
|
|
67
|
+
const status = parsePaymentStatus(payment.status);
|
|
68
|
+
if (transaction) {
|
|
69
|
+
const bodyPaymentHistory = {
|
|
70
|
+
transaction_id: transaction._id,
|
|
71
|
+
date_time: new Date().toISOString(),
|
|
72
|
+
status,
|
|
73
|
+
notification_code: String(notification.id),
|
|
74
|
+
flags: [
|
|
75
|
+
'mercadopago',
|
|
76
|
+
],
|
|
77
|
+
} as any; // TODO: incompatible type=> amount and status
|
|
78
|
+
|
|
79
|
+
if (status !== order.financial_status?.current) {
|
|
80
|
+
// avoid unnecessary API request
|
|
81
|
+
await api.post(`orders/${orderId}/payments_history`, bodyPaymentHistory);
|
|
82
|
+
const updatedAt = new Date().toISOString();
|
|
83
|
+
docRef.set({ status, updatedAt }, { merge: true }).catch(logger.error);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if ((status === 'paid' && methodPayment === 'pix' && transaction)) {
|
|
87
|
+
let { notes } = transaction;
|
|
88
|
+
notes = notes?.replace('display:block', 'display:none'); // disable QR Code
|
|
89
|
+
notes = `${notes} # PIX Aprovado`;
|
|
90
|
+
|
|
91
|
+
// orders/${order._id}/transactions/${transactionId}.json { notes }
|
|
92
|
+
// Update to disable QR Code
|
|
93
|
+
try {
|
|
94
|
+
await api.patch(
|
|
95
|
+
`orders/${order._id}/transactions/${transaction._id}`,
|
|
96
|
+
{ notes },
|
|
97
|
+
);
|
|
98
|
+
ECHO_SUCCESS = 'SUCCESS';
|
|
99
|
+
} catch (e) {
|
|
100
|
+
logger.error(e);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
res.status(200).send(ECHO_SUCCESS);
|
|
105
|
+
} else {
|
|
106
|
+
// transaction not found
|
|
107
|
+
logger.log('> Transaction not found #', notification.data.id);
|
|
108
|
+
res.sendStatus(404);
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
// order or order transaction not found
|
|
112
|
+
logger.log('> Order Not Found #', orderId);
|
|
113
|
+
res.sendStatus(404);
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
logger.log('> Payment not found in Firestore #', notification.data.id);
|
|
117
|
+
res.sendStatus(404);
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
.catch((err) => {
|
|
121
|
+
logger.error(err);
|
|
122
|
+
res.sendStatus(503);
|
|
123
|
+
});
|
|
124
|
+
// }, 3000);
|
|
125
|
+
} else {
|
|
126
|
+
res.sendStatus(406);
|
|
127
|
+
}
|
|
128
|
+
} catch (e) {
|
|
129
|
+
logger.error(e);
|
|
130
|
+
res.sendStatus(500);
|
|
131
|
+
}
|
|
132
|
+
} else {
|
|
133
|
+
res.sendStatus(405);
|
|
134
|
+
}
|
|
135
|
+
}),
|
|
136
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/mp-webhook.js';
|
|
@@ -140,5 +140,9 @@ Finish by saving the following secrets to your GitHub repository:
|
|
|
140
140
|
-- More info at https://github.com/ecomplus/store#getting-started
|
|
141
141
|
`;
|
|
142
142
|
}
|
|
143
|
+
if (argv._.includes('dev') || !argv._.length) {
|
|
144
|
+
await $`npm run build -- --codebase ssr`;
|
|
145
|
+
return $`npm --prefix "${path.join(pwd, 'functions/ssr')}" run dev`;
|
|
146
|
+
}
|
|
143
147
|
return $`echo 'Hello from @cloudcommerce/cli'`;
|
|
144
148
|
};
|
|
@@ -171,5 +171,10 @@ Finish by saving the following secrets to your GitHub repository:
|
|
|
171
171
|
-- More info at https://github.com/ecomplus/store#getting-started
|
|
172
172
|
`;
|
|
173
173
|
}
|
|
174
|
+
|
|
175
|
+
if (argv._.includes('dev') || !argv._.length) {
|
|
176
|
+
await $`npm run build -- --codebase ssr`;
|
|
177
|
+
return $`npm --prefix "${path.join(pwd, 'functions/ssr')}" run dev`;
|
|
178
|
+
}
|
|
174
179
|
return $`echo 'Hello from @cloudcommerce/cli'`;
|
|
175
180
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firebase.js","sourceRoot":"","sources":["../src/firebase.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,OAAO,kCAAkC,CAAC;AAE1C,cAAc,6BAA6B,CAAC"}
|
|
1
|
+
{"version":3,"file":"firebase.js","sourceRoot":"","sources":["../src/firebase.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,OAAO,kCAAkC,CAAC;AAE1C,cAAc,6BAA6B,CAAC;AAE5C,cAAc,wCAAwC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/events",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.113",
|
|
5
5
|
"description": "E-Com Plus Cloud Commerce app events",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"exports": {
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@cloudcommerce/api": "workspace:*",
|
|
27
27
|
"@cloudcommerce/app-tiny-erp": "workspace:*",
|
|
28
|
+
"@cloudcommerce/app-mercadopago": "workspace:*",
|
|
28
29
|
"@cloudcommerce/firebase": "workspace:*",
|
|
29
30
|
"firebase-admin": "^11.0.1",
|
|
30
31
|
"firebase-functions": "^3.24.1",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,MAAsB,MAAM,uBAAuB,CAAC;AAE3D,MAAM,aAAa,GAAmB;IACpC,qBAAqB;IACrB,cAAc;IACd,mBAAmB;IACnB,sBAAsB;CACvB,CAAC;AAEF,MAAM,EACJ,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,0BAA0B,EAC1B,wBAAwB,GACzB,GAAG,OAAO,CAAC,GAAG,CAAC;AAEhB,MAAM,WAAW,GAAG;IAClB,KAAK,EAAE,8BAA8B;IACrC,oBAAoB,EAAE;QACpB,MAAM,EAAE,aAAa,IAAI,oBAAoB;KAC9C;IACD,kBAAkB,EAAE;QAClB,MAAM,EAAE,iBAAiB,IAAI,aAAa;QAC1C,MAAM,EAAG,iBAA6D,IAAI,QAAQ;QAClF,cAAc,EAAE,0BAA0B,CAAC,CAAC,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,EAAE;QACpF,YAAY,EAAE,wBAAwB,CAAC,CAAC,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,CA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,KAAK,EAAE,IAAI;SACZ;QACD,MAAM,EAAE;YACN,KAAK,EAAE,IAAI;SACZ;QACD,OAAO,EAAE;YACP,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,aAAa;SACtB;QACD,WAAW,EAAE;YACX,KAAK,EAAE,MAAM;SACd;KACF;CACF,CAAC;AACF,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AAExB,eAAe,MAId,CAAC"}
|
|
@@ -67,6 +67,20 @@ export default async (appId, modName, url, data, isBigTimeout) => {
|
|
|
67
67
|
.then(({ calculateShipping }) => calculateShipping(_data));
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
|
+
} else if (modName === 'list_payments') {
|
|
71
|
+
if (appId === apps.mercadoPago.appId) {
|
|
72
|
+
internalModuleFn = async (_data = data) => {
|
|
73
|
+
return import('@cloudcommerce/app-mercadopago')
|
|
74
|
+
.then(({ listPayments }) => listPayments(_data));
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
} else if (modName === 'create_transaction') {
|
|
78
|
+
if (appId === apps.mercadoPago.appId) {
|
|
79
|
+
internalModuleFn = async (_data = data) => {
|
|
80
|
+
return import('@cloudcommerce/app-mercadopago')
|
|
81
|
+
.then(({ createTransaction }) => createTransaction(_data));
|
|
82
|
+
};
|
|
83
|
+
}
|
|
70
84
|
}
|
|
71
85
|
if (internalModuleFn) {
|
|
72
86
|
/*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call-app-module.js","sourceRoot":"","sources":["../../src/firebase/call-app-module.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,KAAwB,MAAM,OAAO,CAAC;AAC7C,OAAO,MAAM,MAAM,oCAAoC,CAAC;AAExD,gDAAgD;AAChD,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB,eAAe,KAAK,EAClB,KAAa,EACb,OAAsB,EACtB,GAAW,EACX,IAAS,EACT,YAAqB,EAC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O,EAAE,CAAC;YACpD,IAAI,IAAI,EAAE;gBACR,GAAG,IAAI,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;aACtC;YACD,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAClB;QACD,MAAM,GAAG,CAAC;IACZ,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/modules",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.113",
|
|
5
5
|
"description": "E-Com Plus Cloud Commerce modules API",
|
|
6
6
|
"main": "lib/index.cjs",
|
|
7
7
|
"exports": {
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"@cloudcommerce/app-custom-shipping": "workspace:*",
|
|
30
30
|
"@cloudcommerce/app-discounts": "workspace:*",
|
|
31
31
|
"@cloudcommerce/app-frenet": "workspace:*",
|
|
32
|
+
"@cloudcommerce/app-mercadopago": "workspace:*",
|
|
32
33
|
"@cloudcommerce/firebase": "workspace:*",
|
|
33
34
|
"@ecomplus/utils": "^1.4.1",
|
|
34
35
|
"ajv": "^8.11.0",
|
|
@@ -77,6 +77,20 @@ export default async (
|
|
|
77
77
|
.then(({ calculateShipping }) => calculateShipping(_data));
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
|
+
} else if (modName === 'list_payments') {
|
|
81
|
+
if (appId === apps.mercadoPago.appId) {
|
|
82
|
+
internalModuleFn = async (_data: AppModuleBody = data) => {
|
|
83
|
+
return import('@cloudcommerce/app-mercadopago')
|
|
84
|
+
.then(({ listPayments }) => listPayments(_data));
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
} else if (modName === 'create_transaction') {
|
|
88
|
+
if (appId === apps.mercadoPago.appId) {
|
|
89
|
+
internalModuleFn = async (_data: AppModuleBody = data) => {
|
|
90
|
+
return import('@cloudcommerce/app-mercadopago')
|
|
91
|
+
.then(({ createTransaction }) => createTransaction(_data));
|
|
92
|
+
};
|
|
93
|
+
}
|
|
80
94
|
}
|
|
81
95
|
if (internalModuleFn) {
|
|
82
96
|
/*
|