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,138 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
(function () {
|
|
3
|
+
window.Mercadopago.getIdentificationTypes();
|
|
4
|
+
|
|
5
|
+
window._mpHash = function (data) {
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
window
|
|
8
|
+
._mpBrand(data.number)
|
|
9
|
+
.then(() => {
|
|
10
|
+
return setMPForm(data);
|
|
11
|
+
})
|
|
12
|
+
.then((res) => {
|
|
13
|
+
window
|
|
14
|
+
.Mercadopago
|
|
15
|
+
.getIssuers(window.mpPaymentMethodId, (status, issuer) => {
|
|
16
|
+
console.log(issuer);
|
|
17
|
+
const token = `${res.id} // ${JSON.stringify({ payment_method_id: window.mpPaymentMethodId, issuer })}`;
|
|
18
|
+
return resolve(token);
|
|
19
|
+
});
|
|
20
|
+
})
|
|
21
|
+
.catch(reject);
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
window._mpInstallments = function (data) {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
window
|
|
28
|
+
._mpBrand(data.number)
|
|
29
|
+
.then((paymentMethodId) => {
|
|
30
|
+
const options = {
|
|
31
|
+
payment_method_id: paymentMethodId,
|
|
32
|
+
amount: data.amount,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return window
|
|
36
|
+
.Mercadopago
|
|
37
|
+
.getInstallments(options, (status, data) => {
|
|
38
|
+
if (status === 200) {
|
|
39
|
+
const installmentList = [];
|
|
40
|
+
for (let i = 0; i < data[0].payer_costs.length; i++) {
|
|
41
|
+
const opt = data[0].payer_costs[i];
|
|
42
|
+
installmentList.push({
|
|
43
|
+
number: opt.installments,
|
|
44
|
+
tax: (opt.installment_rate > 0),
|
|
45
|
+
value: opt.installment_amount,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
resolve(installmentList);
|
|
50
|
+
} else {
|
|
51
|
+
console.log('installments method info error:', response);
|
|
52
|
+
reject(response);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
})
|
|
56
|
+
.catch(reject);
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
window._mpBrand = function (number) {
|
|
61
|
+
return new Promise((resolve, reject) => {
|
|
62
|
+
let bin = String(number);
|
|
63
|
+
bin = bin.substring(0, 6);
|
|
64
|
+
if (bin.length >= 6) {
|
|
65
|
+
return window
|
|
66
|
+
.Mercadopago
|
|
67
|
+
.getPaymentMethod({
|
|
68
|
+
bin,
|
|
69
|
+
}, (status, resp) => {
|
|
70
|
+
if (status === 200) {
|
|
71
|
+
window.mpPaymentMethodId = resp[0].id;
|
|
72
|
+
resolve(resp[0].id);
|
|
73
|
+
} else {
|
|
74
|
+
console.log('payment method info error:', resp);
|
|
75
|
+
reject(resp);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
reject(new Error('Failed trying installments with card number yet imcomplete'));
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
function setMPForm(data) {
|
|
84
|
+
return new Promise((resolve, reject) => {
|
|
85
|
+
const { customer } = window.storefrontApp;
|
|
86
|
+
const mpParams = {};
|
|
87
|
+
mpParams.cardNumber = data.number;
|
|
88
|
+
mpParams.cardholderName = data.name;
|
|
89
|
+
mpParams.cardExpirationMonth = data.month;
|
|
90
|
+
mpParams.cardExpirationYear = data.year;
|
|
91
|
+
mpParams.securityCode = data.cvc;
|
|
92
|
+
|
|
93
|
+
if (data.doc) {
|
|
94
|
+
mpParams.docNumber = data.doc;
|
|
95
|
+
} else {
|
|
96
|
+
mpParams.docNumber = customer.doc_number;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
mpParams.email = customer.main_email;
|
|
100
|
+
mpParams.payment_method_id = window.mpPaymentMethodId;
|
|
101
|
+
|
|
102
|
+
const $form = document.createElement('form');
|
|
103
|
+
|
|
104
|
+
for (const key in mpParams) {
|
|
105
|
+
if (mpParams[key]) {
|
|
106
|
+
const value = mpParams[key];
|
|
107
|
+
const $input = document.createElement('input');
|
|
108
|
+
$input.setAttribute('type', 'text');
|
|
109
|
+
$input.setAttribute('id', key);
|
|
110
|
+
$input.setAttribute('data-checkout', key);
|
|
111
|
+
$input.setAttribute('value', value);
|
|
112
|
+
$form.appendChild($input);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// todo
|
|
117
|
+
// - select typeDoc
|
|
118
|
+
const $typeDoc = document.createElement('select');
|
|
119
|
+
$typeDoc.setAttribute('data-checkout', 'docType');
|
|
120
|
+
const $typeDocOption = document.createElement('option');
|
|
121
|
+
$typeDocOption.text = customer.registry_type === 'j' ? 'CNPJ' : 'CPF';
|
|
122
|
+
$typeDocOption.value = customer.registry_type === 'j' ? 'CNPJ' : 'CPF';
|
|
123
|
+
$typeDocOption.setAttribute('selected', true);
|
|
124
|
+
$typeDoc.add($typeDocOption);
|
|
125
|
+
|
|
126
|
+
$form.appendChild($typeDoc);
|
|
127
|
+
// - select installments
|
|
128
|
+
|
|
129
|
+
window.Mercadopago.createToken($form, (status, resp) => {
|
|
130
|
+
if (status === 200) {
|
|
131
|
+
resolve(resp);
|
|
132
|
+
} else {
|
|
133
|
+
reject(resp);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}());
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './mercadopago';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import '@cloudcommerce/firebase/lib/init';
|
|
2
|
+
import type { AppModuleBody } from '@cloudcommerce/types';
|
|
3
|
+
export declare const listPayments: (modBody: AppModuleBody) => Promise<import("@cloudcommerce/types").ListPaymentsResponse | {
|
|
4
|
+
error: string;
|
|
5
|
+
message: string;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const createTransaction: (modBody: AppModuleBody) => Promise<{
|
|
8
|
+
status: number;
|
|
9
|
+
redirect_to_payment: boolean;
|
|
10
|
+
transaction: {
|
|
11
|
+
payment_link?: string | undefined;
|
|
12
|
+
payment_instructions?: string | undefined;
|
|
13
|
+
intermediator?: {
|
|
14
|
+
transaction_id?: string | undefined;
|
|
15
|
+
transaction_code?: string | undefined;
|
|
16
|
+
transaction_reference?: string | undefined;
|
|
17
|
+
payment_method?: {
|
|
18
|
+
code: string;
|
|
19
|
+
name?: string | undefined;
|
|
20
|
+
} | undefined;
|
|
21
|
+
buyer_id?: string | undefined;
|
|
22
|
+
} | undefined;
|
|
23
|
+
credit_card?: {
|
|
24
|
+
holder_name?: string | undefined;
|
|
25
|
+
avs_result_code?: string | null | undefined;
|
|
26
|
+
cvv_result_code?: string | null | undefined;
|
|
27
|
+
bin?: number | undefined;
|
|
28
|
+
company?: string | undefined;
|
|
29
|
+
last_digits?: string | undefined;
|
|
30
|
+
token?: string | undefined;
|
|
31
|
+
error_code?: "incorrect_number" | "invalid_number" | "invalid_expiry_date" | "invalid_cvc" | "expired_card" | "incorrect_cvc" | "incorrect_zip" | "incorrect_address" | "card_declined" | "processing_error" | "call_issuer" | "pick_up_card" | undefined;
|
|
32
|
+
} | undefined;
|
|
33
|
+
banking_billet?: {
|
|
34
|
+
code?: string | undefined;
|
|
35
|
+
valid_thru?: string | undefined;
|
|
36
|
+
text_lines?: string[] | undefined;
|
|
37
|
+
link?: string | undefined;
|
|
38
|
+
} | undefined;
|
|
39
|
+
loyalty_points?: {
|
|
40
|
+
name?: string | undefined;
|
|
41
|
+
program_id: string;
|
|
42
|
+
points_value: number;
|
|
43
|
+
ratio?: number | undefined;
|
|
44
|
+
} | undefined;
|
|
45
|
+
currency_id?: string | undefined;
|
|
46
|
+
currency_symbol?: string | undefined;
|
|
47
|
+
discount?: number | undefined;
|
|
48
|
+
amount: number;
|
|
49
|
+
installments?: {
|
|
50
|
+
number: number;
|
|
51
|
+
value?: number | undefined;
|
|
52
|
+
tax?: boolean | undefined;
|
|
53
|
+
total?: number | undefined;
|
|
54
|
+
} | undefined;
|
|
55
|
+
creditor_fees?: {
|
|
56
|
+
installment?: number | undefined;
|
|
57
|
+
operational?: number | undefined;
|
|
58
|
+
intermediation?: number | undefined;
|
|
59
|
+
other?: number | undefined;
|
|
60
|
+
} | undefined;
|
|
61
|
+
status?: {
|
|
62
|
+
updated_at?: string | undefined;
|
|
63
|
+
current: "voided" | "under_analysis" | "paid" | "pending" | "authorized" | "unauthorized" | "in_dispute" | "refunded" | "unknown";
|
|
64
|
+
} | undefined;
|
|
65
|
+
flags?: string[] | undefined;
|
|
66
|
+
custom_fields?: {
|
|
67
|
+
field: string;
|
|
68
|
+
value: string;
|
|
69
|
+
}[] | undefined;
|
|
70
|
+
notes?: string | undefined;
|
|
71
|
+
};
|
|
72
|
+
message?: undefined;
|
|
73
|
+
error?: undefined;
|
|
74
|
+
} | {
|
|
75
|
+
status: number;
|
|
76
|
+
message: string;
|
|
77
|
+
redirect_to_payment?: undefined;
|
|
78
|
+
transaction?: undefined;
|
|
79
|
+
error?: undefined;
|
|
80
|
+
} | {
|
|
81
|
+
status: number;
|
|
82
|
+
error: string;
|
|
83
|
+
message: any;
|
|
84
|
+
redirect_to_payment?: undefined;
|
|
85
|
+
transaction?: undefined;
|
|
86
|
+
}>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import '@cloudcommerce/firebase/lib/init';
|
|
2
|
+
// eslint-disable-next-line import/no-unresolved
|
|
3
|
+
import { getFirestore } from 'firebase-admin/firestore';
|
|
4
|
+
// eslint-disable-next-line import/no-unresolved
|
|
5
|
+
import handleListPayments from './mp-list-payments.js';
|
|
6
|
+
import handleCreateTransaction from './mp-create-transaction.js';
|
|
7
|
+
|
|
8
|
+
export const listPayments = async (modBody) => {
|
|
9
|
+
return handleListPayments(modBody);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const createTransaction = async (modBody) => {
|
|
13
|
+
return handleCreateTransaction(modBody, getFirestore());
|
|
14
|
+
};
|
|
15
|
+
// # sourceMappingURL=mercadopago.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mercadopago.js","sourceRoot":"","sources":["../src/mercadopago.ts"],"names":[],"mappings":"AAAA,OAAO,kCAAkC,CAAC;AAG1C,gDAAgD;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,gDAAgD;AAChD,OAAO,kBAAkB,MAAM,oBAAoB,CAAC;AACpD,OAAO,uBAAuB,MAAM,yBAAyB,CAAC;AAE9D,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,OAAsB,EAAE,EAAE;IAC3D,OAAO,kBAAkB,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAAE,OAAsB,EAAE,EAAE;IAChE,OAAO,uBAAuB,CAAC,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC;AAC1D,CAAC,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { AppModuleBody } from '@cloudcommerce/types';
|
|
2
|
+
import type { Firestore } from 'firebase-admin/firestore';
|
|
3
|
+
declare const parsePaymentStatus: (status: string) => "voided" | "under_analysis" | "paid" | "pending";
|
|
4
|
+
declare const _default: (appData: AppModuleBody, firestore: Firestore) => Promise<{
|
|
5
|
+
status: number;
|
|
6
|
+
redirect_to_payment: boolean;
|
|
7
|
+
transaction: {
|
|
8
|
+
payment_link?: string | undefined;
|
|
9
|
+
payment_instructions?: string | undefined;
|
|
10
|
+
intermediator?: {
|
|
11
|
+
transaction_id?: string | undefined;
|
|
12
|
+
transaction_code?: string | undefined;
|
|
13
|
+
transaction_reference?: string | undefined;
|
|
14
|
+
payment_method?: {
|
|
15
|
+
code: string;
|
|
16
|
+
name?: string | undefined;
|
|
17
|
+
} | undefined;
|
|
18
|
+
buyer_id?: string | undefined;
|
|
19
|
+
} | undefined;
|
|
20
|
+
credit_card?: {
|
|
21
|
+
holder_name?: string | undefined;
|
|
22
|
+
avs_result_code?: string | null | undefined;
|
|
23
|
+
cvv_result_code?: string | null | undefined;
|
|
24
|
+
bin?: number | undefined;
|
|
25
|
+
company?: string | undefined;
|
|
26
|
+
last_digits?: string | undefined;
|
|
27
|
+
token?: string | undefined;
|
|
28
|
+
error_code?: "incorrect_number" | "invalid_number" | "invalid_expiry_date" | "invalid_cvc" | "expired_card" | "incorrect_cvc" | "incorrect_zip" | "incorrect_address" | "card_declined" | "processing_error" | "call_issuer" | "pick_up_card" | undefined;
|
|
29
|
+
} | undefined;
|
|
30
|
+
banking_billet?: {
|
|
31
|
+
code?: string | undefined;
|
|
32
|
+
valid_thru?: string | undefined;
|
|
33
|
+
text_lines?: string[] | undefined;
|
|
34
|
+
link?: string | undefined;
|
|
35
|
+
} | undefined;
|
|
36
|
+
loyalty_points?: {
|
|
37
|
+
name?: string | undefined;
|
|
38
|
+
program_id: string;
|
|
39
|
+
points_value: number;
|
|
40
|
+
ratio?: number | undefined;
|
|
41
|
+
} | undefined;
|
|
42
|
+
currency_id?: string | undefined;
|
|
43
|
+
currency_symbol?: string | undefined;
|
|
44
|
+
discount?: number | undefined;
|
|
45
|
+
amount: number;
|
|
46
|
+
installments?: {
|
|
47
|
+
number: number;
|
|
48
|
+
value?: number | undefined;
|
|
49
|
+
tax?: boolean | undefined;
|
|
50
|
+
total?: number | undefined;
|
|
51
|
+
} | undefined;
|
|
52
|
+
creditor_fees?: {
|
|
53
|
+
installment?: number | undefined;
|
|
54
|
+
operational?: number | undefined;
|
|
55
|
+
intermediation?: number | undefined;
|
|
56
|
+
other?: number | undefined;
|
|
57
|
+
} | undefined;
|
|
58
|
+
status?: {
|
|
59
|
+
updated_at?: string | undefined;
|
|
60
|
+
current: "voided" | "under_analysis" | "paid" | "pending" | "authorized" | "unauthorized" | "in_dispute" | "refunded" | "unknown";
|
|
61
|
+
} | undefined;
|
|
62
|
+
flags?: string[] | undefined;
|
|
63
|
+
custom_fields?: {
|
|
64
|
+
field: string;
|
|
65
|
+
value: string;
|
|
66
|
+
}[] | undefined;
|
|
67
|
+
notes?: string | undefined;
|
|
68
|
+
};
|
|
69
|
+
message?: undefined;
|
|
70
|
+
error?: undefined;
|
|
71
|
+
} | {
|
|
72
|
+
status: number;
|
|
73
|
+
message: string;
|
|
74
|
+
redirect_to_payment?: undefined;
|
|
75
|
+
transaction?: undefined;
|
|
76
|
+
error?: undefined;
|
|
77
|
+
} | {
|
|
78
|
+
status: number;
|
|
79
|
+
error: string;
|
|
80
|
+
message: any;
|
|
81
|
+
redirect_to_payment?: undefined;
|
|
82
|
+
transaction?: undefined;
|
|
83
|
+
}>;
|
|
84
|
+
export default _default;
|
|
85
|
+
export { parsePaymentStatus, };
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { logger } from 'firebase-functions';
|
|
2
|
+
import config from '@cloudcommerce/firebase/lib/config';
|
|
3
|
+
import axios from 'axios';
|
|
4
|
+
|
|
5
|
+
const parsePaymentStatus = (status) => {
|
|
6
|
+
switch (status) {
|
|
7
|
+
case 'rejected':
|
|
8
|
+
return 'voided';
|
|
9
|
+
case 'in_process':
|
|
10
|
+
return 'under_analysis';
|
|
11
|
+
case 'approved':
|
|
12
|
+
return 'paid';
|
|
13
|
+
default:
|
|
14
|
+
return 'pending';
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default async (appData, firestore) => {
|
|
19
|
+
const locationId = config.get().httpsFunctionOptions.region;
|
|
20
|
+
const baseUri = `https://${locationId}-${process.env.GCLOUD_PROJECT}.cloudfunctions.net`;
|
|
21
|
+
// body was already pre-validated on @/bin/web.js
|
|
22
|
+
// treat module request body
|
|
23
|
+
const { application, storeId } = appData;
|
|
24
|
+
const { params } = appData;
|
|
25
|
+
// app configured options
|
|
26
|
+
const configApp = { ...application.data, ...application.hidden_data };
|
|
27
|
+
const notificationUrl = `${baseUri}/mercadopago-webhook`;
|
|
28
|
+
let token;
|
|
29
|
+
let paymentMethodId;
|
|
30
|
+
const isPix = params.payment_method.code === 'account_deposit';
|
|
31
|
+
if (params.credit_card && params.credit_card.hash) {
|
|
32
|
+
const hashParts = params.credit_card.hash.split(' // ');
|
|
33
|
+
[token] = hashParts;
|
|
34
|
+
try {
|
|
35
|
+
paymentMethodId = JSON.parse(hashParts[1]).payment_method_id;
|
|
36
|
+
} catch (e) {
|
|
37
|
+
paymentMethodId = params.credit_card.company || 'visa';
|
|
38
|
+
}
|
|
39
|
+
} else if (params.payment_method.code === 'banking_billet') {
|
|
40
|
+
paymentMethodId = 'bolbradesco';
|
|
41
|
+
} else if (params.payment_method.code === 'account_deposit') {
|
|
42
|
+
paymentMethodId = 'pix';
|
|
43
|
+
} else {
|
|
44
|
+
return {
|
|
45
|
+
status: 400,
|
|
46
|
+
error: 'NO_CARD_ERR',
|
|
47
|
+
message: 'Credit card hash is required',
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const { buyer } = params;
|
|
51
|
+
const orderId = params.order_id;
|
|
52
|
+
logger.log('> MP Transaction #', storeId, orderId);
|
|
53
|
+
// https://www.mercadopago.com.br/developers/pt/reference/payments/_payments/post/
|
|
54
|
+
const payerPhone = {
|
|
55
|
+
area_code: buyer.phone.number.substring(0, 2),
|
|
56
|
+
number: buyer.phone.number.substring(2, 11),
|
|
57
|
+
};
|
|
58
|
+
const additionalInfo = {
|
|
59
|
+
items: [],
|
|
60
|
+
payer: {
|
|
61
|
+
first_name: buyer.fullname.replace(/\s.*/, ''),
|
|
62
|
+
last_name: buyer.fullname.replace(/[^\s]+\s/, ''),
|
|
63
|
+
phone: payerPhone,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
if (params.to && params.to.street) {
|
|
67
|
+
additionalInfo.shipments = {
|
|
68
|
+
receiver_address: {
|
|
69
|
+
zip_code: params.to.zip,
|
|
70
|
+
street_name: params.to.street,
|
|
71
|
+
street_number: params.to.number || 0,
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if (params.billing_address && params.billing_address.street) {
|
|
76
|
+
additionalInfo.payer.address = {
|
|
77
|
+
zip_code: params.billing_address.zip,
|
|
78
|
+
street_name: params.billing_address.street,
|
|
79
|
+
street_number: params.billing_address.number || 0,
|
|
80
|
+
};
|
|
81
|
+
} else if (additionalInfo.shipments) {
|
|
82
|
+
additionalInfo.payer.address = additionalInfo.shipments.receiver_address;
|
|
83
|
+
}
|
|
84
|
+
if (Array.isArray(params.items)) {
|
|
85
|
+
params.items.forEach((item) => {
|
|
86
|
+
additionalInfo.items.push({
|
|
87
|
+
id: item.sku || item.variation_id || item.product_id,
|
|
88
|
+
title: item.name || item.sku,
|
|
89
|
+
description: item.name || item.sku,
|
|
90
|
+
quantity: item.quantity,
|
|
91
|
+
unit_price: item.final_price || item.price,
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
const payerOrBuyer = {
|
|
96
|
+
...buyer,
|
|
97
|
+
...params.payer,
|
|
98
|
+
};
|
|
99
|
+
Object.keys(payerOrBuyer).forEach((field) => {
|
|
100
|
+
if (!payerOrBuyer[field] && buyer[field]) {
|
|
101
|
+
payerOrBuyer[field] = buyer[field];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
const payment = {
|
|
105
|
+
payer: {
|
|
106
|
+
type: 'customer',
|
|
107
|
+
email: buyer.email,
|
|
108
|
+
first_name: payerOrBuyer.fullname.replace(/\s.*/, ''),
|
|
109
|
+
last_name: payerOrBuyer.fullname.replace(/[^\s]+\s/, ''),
|
|
110
|
+
identification: {
|
|
111
|
+
type: payerOrBuyer.registry_type === 'j' ? 'CNPJ' : 'CPF',
|
|
112
|
+
number: String(payerOrBuyer.doc_number),
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
external_reference: String(params.order_number),
|
|
116
|
+
transaction_amount: params.amount.total,
|
|
117
|
+
description: `Pedido #${params.order_number} de ${buyer.fullname}`.substring(0, 60),
|
|
118
|
+
payment_method_id: paymentMethodId,
|
|
119
|
+
token,
|
|
120
|
+
statement_descriptor: configApp.statement_descriptor || `${params.domain}_MercadoPago`,
|
|
121
|
+
installments: params.installments_number || 1,
|
|
122
|
+
notification_url: notificationUrl,
|
|
123
|
+
additional_info: additionalInfo,
|
|
124
|
+
metadata: {
|
|
125
|
+
ecom_store_id: storeId,
|
|
126
|
+
ecom_order_id: orderId,
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
logger.log('>data: ', JSON.stringify(payment));
|
|
130
|
+
try {
|
|
131
|
+
// https://www.mercadopago.com.br/developers/pt/reference/payments/_payments/post
|
|
132
|
+
const { data } = await axios({
|
|
133
|
+
url: 'https://api.mercadopago.com/v1/payments',
|
|
134
|
+
method: 'post',
|
|
135
|
+
headers: {
|
|
136
|
+
Authorization: `Bearer ${configApp.mp_access_token}`,
|
|
137
|
+
'Content-Type': 'application/json',
|
|
138
|
+
},
|
|
139
|
+
data: payment,
|
|
140
|
+
});
|
|
141
|
+
if (data) {
|
|
142
|
+
logger.log('> MP Checkout #', storeId, orderId);
|
|
143
|
+
const statusPayment = parsePaymentStatus(data.status);
|
|
144
|
+
let isSaveRetry = false;
|
|
145
|
+
const saveToDb = () => {
|
|
146
|
+
return new Promise((resolve, reject) => {
|
|
147
|
+
firestore.collection('mp_payments')
|
|
148
|
+
.doc(String(data.id))
|
|
149
|
+
.set({
|
|
150
|
+
transaction_code: data.id,
|
|
151
|
+
store_id: storeId,
|
|
152
|
+
order_id: orderId,
|
|
153
|
+
status: statusPayment,
|
|
154
|
+
paymentMethod: paymentMethodId,
|
|
155
|
+
notificationUrl,
|
|
156
|
+
}, {
|
|
157
|
+
merge: true,
|
|
158
|
+
})
|
|
159
|
+
.then(() => {
|
|
160
|
+
logger.log('> Payment #', String(data.id));
|
|
161
|
+
resolve(true);
|
|
162
|
+
})
|
|
163
|
+
.catch((err) => {
|
|
164
|
+
if (err.code === 13 && !isSaveRetry) {
|
|
165
|
+
isSaveRetry = true;
|
|
166
|
+
setTimeout(saveToDb, 500);
|
|
167
|
+
} else {
|
|
168
|
+
logger.error('PAYMENT_SAVE_ERR', err);
|
|
169
|
+
reject(err);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
await saveToDb();
|
|
175
|
+
const transaction = {
|
|
176
|
+
amount: data.transaction_details.total_paid_amount,
|
|
177
|
+
currency_id: data.currency_id,
|
|
178
|
+
intermediator: {
|
|
179
|
+
payment_method: {
|
|
180
|
+
code: paymentMethodId || params.payment_method.code,
|
|
181
|
+
},
|
|
182
|
+
transaction_id: String(data.id),
|
|
183
|
+
transaction_code: String(data.id),
|
|
184
|
+
transaction_reference: data.external_reference,
|
|
185
|
+
},
|
|
186
|
+
status: {
|
|
187
|
+
current: statusPayment,
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
if (params.payment_method.code === 'credit_card') {
|
|
191
|
+
if (data.card) {
|
|
192
|
+
transaction.credit_card = {
|
|
193
|
+
holder_name: data.card.cardholder.name,
|
|
194
|
+
last_digits: data.card.last_four_digits,
|
|
195
|
+
token,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
if (data.installments) {
|
|
199
|
+
transaction.installments = {
|
|
200
|
+
number: data.installments,
|
|
201
|
+
tax: (data.transaction_details.total_paid_amount > data.transaction_amount),
|
|
202
|
+
total: data.transaction_details.total_paid_amount,
|
|
203
|
+
value: data.transaction_details.installment_amount,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
} else if (!isPix && data.transaction_details
|
|
207
|
+
&& data.transaction_details.external_resource_url) {
|
|
208
|
+
transaction.payment_link = data.transaction_details.external_resource_url;
|
|
209
|
+
transaction.banking_billet = {
|
|
210
|
+
link: transaction.payment_link,
|
|
211
|
+
};
|
|
212
|
+
if (data.date_of_expiration) {
|
|
213
|
+
const dateValidThru = new Date(data.date_of_expiration);
|
|
214
|
+
if (dateValidThru.getTime() > 0) {
|
|
215
|
+
transaction.banking_billet.valid_thru = dateValidThru.toISOString();
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
} else if (isPix && data.point_of_interaction && data.point_of_interaction.transaction_data) {
|
|
219
|
+
// https://www.mercadopago.com.br/developers/pt/docs/checkout-api/integration-configuration/integrate-with-pix#bookmark_visualiza%C3%A7%C3%A3o_de_pagamento
|
|
220
|
+
const qrCode = data.point_of_interaction.transaction_data.qr_code;
|
|
221
|
+
const qrCodeBase64 = data.point_of_interaction.transaction_data.qr_code_base64;
|
|
222
|
+
transaction.notes = '<div style="display:block;margin:0 auto"> '
|
|
223
|
+
+ `<img width="280" height="280" style="margin:5px auto" src='data:image/jpeg;base64,${qrCodeBase64}'/> `
|
|
224
|
+
+ `<lable> ${qrCode} </label></div>`;
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
status: 200,
|
|
228
|
+
redirect_to_payment: false,
|
|
229
|
+
transaction,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
return {
|
|
233
|
+
status: 409,
|
|
234
|
+
message: `CREATE_TRANSACTION_ERR #${storeId} - ${orderId} => MP not response`,
|
|
235
|
+
};
|
|
236
|
+
} catch (error) {
|
|
237
|
+
let { message } = error;
|
|
238
|
+
//
|
|
239
|
+
const err = {
|
|
240
|
+
message: `CREATE_TRANSACTION_ERR #${storeId} - ${orderId} => ${message}`,
|
|
241
|
+
payment: '',
|
|
242
|
+
status: 0,
|
|
243
|
+
response: '',
|
|
244
|
+
};
|
|
245
|
+
if (error.response) {
|
|
246
|
+
const { status, data } = error.response;
|
|
247
|
+
if (status !== 401 && status !== 403) {
|
|
248
|
+
err.payment = JSON.stringify(payment);
|
|
249
|
+
err.status = status;
|
|
250
|
+
if (typeof data === 'object' && data) {
|
|
251
|
+
err.response = JSON.stringify(data);
|
|
252
|
+
} else {
|
|
253
|
+
err.response = data;
|
|
254
|
+
}
|
|
255
|
+
if (typeof data.message === 'string' && data.message) {
|
|
256
|
+
message = data.message;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
logger.error(err);
|
|
261
|
+
return {
|
|
262
|
+
status: 409,
|
|
263
|
+
error: 'CREATE_TRANSACTION_ERR',
|
|
264
|
+
message,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
export { parsePaymentStatus };
|
|
270
|
+
// # sourceMappingURL=mp-create-transaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mp-create-transaction.js","sourceRoot":"","sources":["../src/mp-create-transaction.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,MAAM,MAAM,oCAAoC,CAAC;AACxD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,kBAAkB,GAAG,CAAC,MAAc,EAAE,EAAE;IAC5C,QAAQ,MAAM,EAAE;QACd,KAAK,UAAU;YACb,OAAO,QAAQ,CAAC;QAClB,KAAK,YAAY;YACf,OAAO,gBAAgB,CAAC;QAC1B,KAAK,UAAU;YACb,OAAO,MAAM,CAAC;QAChB;YACE,OAAO,SAAS,CAAC;KACpB;AACH,CAAC,CAAC;AAEF,eAAe,KAAK,EAAE,OAAsB,EAAE,SAAmB,EAAE,EAAE;IACnE,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC,MAAM,CAAC;IAC5D,MAAM,OAAO,GAAG,WAAW,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,qBAAqB,CAAC;IACzF,iDAAiD;IACjD,4BAA4B;IAC5B,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IACzC,MAAM,MAAM,G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G,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;iBACrC;qBAAM;oBACL,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC;iBACrB;gBACD,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,IAAI,IAAI,CAAC,OAAO,EAAE;oBACpD,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;iBACxB;aACF;SACF;QACD,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAClB,OAAO;YACL,MAAM,EAAE,GAAG;YACX,KAAK,EAAE,wBAAwB;YAC/B,OAAO;SACR,CAAC;KACH;AACH,CAAC,CAAC;AAEF,OAAO,EACL,kBAAkB,GACnB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AppModuleBody } from '@cloudcommerce/types';
|
|
2
|
+
import type { ListPaymentsResponse } from '@cloudcommerce/types/modules/list_payments:response';
|
|
3
|
+
declare const _default: (data: AppModuleBody) => ListPaymentsResponse | {
|
|
4
|
+
error: string;
|
|
5
|
+
message: string;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|