@cloudcommerce/app-pagaleve 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -0
- package/lib/pagaleve-constructor.d.ts +7 -0
- package/lib/pagaleve-constructor.js +78 -0
- package/lib/pagaleve-constructor.js.map +1 -0
- package/lib/pagaleve-create-transaction.d.ts +7 -0
- package/lib/pagaleve-create-transaction.js +148 -0
- package/lib/pagaleve-create-transaction.js.map +1 -0
- package/lib/pagaleve-list-payments.d.ts +7 -0
- package/lib/pagaleve-list-payments.js +113 -0
- package/lib/pagaleve-list-payments.js.map +1 -0
- package/lib/pagaleve-webhook.d.ts +4 -0
- package/lib/pagaleve-webhook.js +135 -0
- package/lib/pagaleve-webhook.js.map +1 -0
- package/lib/pagaleve.d.ts +12 -0
- package/lib/pagaleve.js +12 -0
- package/lib/pagaleve.js.map +1 -0
- package/package.json +43 -0
- package/webhook.js +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 E-Com Club Softwares para E-commerce <ti@e-com.club>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# `@cloudcommerce/app-pagaleve`
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './pagaleve';
|
package/lib/index.js
ADDED
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { getFirestore, Timestamp } from 'firebase-admin/firestore';
|
|
3
|
+
import logger from 'firebase-functions/logger';
|
|
4
|
+
|
|
5
|
+
const createAxios = (token, isSandbox = false) => {
|
|
6
|
+
const headers = {
|
|
7
|
+
'Content-Type': 'application/json',
|
|
8
|
+
'Idempotency-Key': `${Date.now() + Math.random()}`,
|
|
9
|
+
Authorization: token,
|
|
10
|
+
};
|
|
11
|
+
const baseURL = isSandbox
|
|
12
|
+
? 'https://sandbox-api.pagaleve.io'
|
|
13
|
+
: 'https://api.pagaleve.com.br';
|
|
14
|
+
return axios.create({
|
|
15
|
+
baseURL,
|
|
16
|
+
headers,
|
|
17
|
+
validateStatus(status) {
|
|
18
|
+
return status >= 200 && status <= 301;
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
const createToken = (username, password, isSandbox = false) => {
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
// https://api-docs.addi-staging-br.com/#/Authentication/createAuthToken
|
|
25
|
+
const pagaleveAxios = createAxios(null, isSandbox);
|
|
26
|
+
const request = (isRetry = false) => {
|
|
27
|
+
pagaleveAxios.post('/v1/authentication', { username, password })
|
|
28
|
+
.then(({ data }) => resolve(data))
|
|
29
|
+
.catch((err) => {
|
|
30
|
+
if (!isRetry && err.response && err.response.status >= 429) {
|
|
31
|
+
setTimeout(() => request(true), 7000);
|
|
32
|
+
}
|
|
33
|
+
reject(err);
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
request();
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
const Pagaleve = function newPagaleve(username, password, isSandbox = false) {
|
|
40
|
+
const self = this;
|
|
41
|
+
const documentRef = getFirestore().doc('pagaleve/token');
|
|
42
|
+
this.preparing = new Promise((resolve, reject) => {
|
|
43
|
+
const authenticate = (token) => {
|
|
44
|
+
self.axios = createAxios(token, isSandbox);
|
|
45
|
+
resolve();
|
|
46
|
+
};
|
|
47
|
+
const handleAuth = () => {
|
|
48
|
+
createToken(username, password, isSandbox)
|
|
49
|
+
.then((data) => {
|
|
50
|
+
authenticate(data.token);
|
|
51
|
+
if (documentRef) {
|
|
52
|
+
documentRef.set({
|
|
53
|
+
...data,
|
|
54
|
+
isSandbox,
|
|
55
|
+
updatedAt: Timestamp.now(),
|
|
56
|
+
}).catch(logger.error);
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
.catch(reject);
|
|
60
|
+
};
|
|
61
|
+
documentRef.get()
|
|
62
|
+
.then((documentSnapshot) => {
|
|
63
|
+
const data = documentSnapshot.data();
|
|
64
|
+
if (data) {
|
|
65
|
+
const updatedAt = data.updatedAt.toMillis();
|
|
66
|
+
if (updatedAt && Date.now() - updatedAt <= 50 * 60 * 1000) {
|
|
67
|
+
authenticate(data.token);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
handleAuth();
|
|
72
|
+
})
|
|
73
|
+
.catch(logger.error);
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export default Pagaleve;
|
|
78
|
+
// # sourceMappingURL=pagaleve-constructor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagaleve-constructor.js","sourceRoot":"","sources":["../src/pagaleve-constructor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAE/C,MAAM,WAAW,GAAG,CAAC,KAAqB,EAAE,SAAS,GAAG,KAAK,EAAE,EAAE;IAC/D,MAAM,OAAO,GAAG;QACd,cAAc,EAAE,kBAAkB;QAClC,iBAAiB,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE;QAClD,aAAa,EAAE,KAAK;KACrB,CAAC;IACF,MAAM,OAAO,GAAG,SAAS;QACvB,CAAC,CAAC,iCAAiC;QACnC,CAAC,CAAC,6BAA6B,CAAC;IAClC,OAAO,KAAK,CAAC,MAAM,CAAC;QAClB,OAAO;QACP,OAAO;QACP,cAAc,CAAC,MAAM;YACnB,OAAO,MAAM,IAAI,GAAG,IAAI,MAAM,IAAI,GAAG,CAAC;QACxC,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,QAAgB,EAAE,QAAgB,EAAE,SAAS,GAAG,KAAK,EAAE,EAAE;IAC5E,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,yEAAyE;QACzE,MAAM,aAAa,GAAG,WAAW,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QACnD,MAAM,OA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AAK,CAAC,CAAC;gBACzB,IAAI,WAAW,EAAE,CAAC;oBAChB,WAAW,CAAC,GAAG,CAAC;wBACd,GAAG,IAAI;wBACP,SAAS;wBACT,SAAS,EAAE,SAAS,CAAC,GAAG,EAAE;qBAC3B,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACzB,CAAC;YACH,CAAC,CAAC;iBACD,KAAK,CAAC,MAAM,CAAC,CAAC;QACnB,CAAC,CAAC;QACF,WAAW,CAAC,GAAG,EAAE;aACd,IAAI,CAAC,CAAC,gBAAgB,EAAE,EAAE;YACzB,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,EAAE,CAAC;YACrC,IAAI,IAAI,EAAE,CAAC;gBACT,MAAM,SAAS,GAAI,IAAI,CAAC,SAAuB,CAAC,QAAQ,EAAE,CAAC;gBAC3D,IAAI,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;oBAC1D,YAAY,CAAC,IAAK,CAAC,KAAK,CAAC,CAAC;oBAC1B,OAAO;gBACT,CAAC;YACH,CAAC;YACD,UAAU,EAAE,CAAC;QACf,CAAC,CAAC;aACD,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AppModuleBody, CreateTransactionResponse } from '@cloudcommerce/types';
|
|
2
|
+
declare const pagaleveCreateTransaction: (body: AppModuleBody<'create_transaction'>) => Promise<CreateTransactionResponse | {
|
|
3
|
+
status: number;
|
|
4
|
+
error: string;
|
|
5
|
+
message: any;
|
|
6
|
+
}>;
|
|
7
|
+
export default pagaleveCreateTransaction;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { createHmac } from 'node:crypto';
|
|
2
|
+
import logger from 'firebase-functions/logger';
|
|
3
|
+
import { img as getImg } from '@ecomplus/utils';
|
|
4
|
+
import config from '@cloudcommerce/firebase/lib/config';
|
|
5
|
+
import Pagaleve from './pagaleve-constructor.js';
|
|
6
|
+
|
|
7
|
+
const { region } = config.get().httpsFunctionOptions;
|
|
8
|
+
const baseUri = `https://${region}-${process.env.GCLOUD_PROJECT}.cloudfunctions.net`;
|
|
9
|
+
const pagaleveCreateTransaction = async (body) => {
|
|
10
|
+
const { params, application } = body;
|
|
11
|
+
const appData = { ...application.data, ...application.hidden_data };
|
|
12
|
+
const { PAGALEVE_USERNAME, PAGALEVE_PASSWORD, PAGALEVE_SANDBOX } = process.env;
|
|
13
|
+
if (PAGALEVE_USERNAME) appData.username = PAGALEVE_USERNAME;
|
|
14
|
+
if (PAGALEVE_PASSWORD) appData.password = PAGALEVE_PASSWORD;
|
|
15
|
+
const isSandbox = !!PAGALEVE_SANDBOX;
|
|
16
|
+
const pagaleve = new Pagaleve(appData.username, appData.password, isSandbox);
|
|
17
|
+
const orderId = params.order_id || '';
|
|
18
|
+
const orderNumber = params.order_number;
|
|
19
|
+
const { amount, buyer, items } = params;
|
|
20
|
+
const isPix = params.payment_method.code === 'account_deposit';
|
|
21
|
+
const transaction = {
|
|
22
|
+
intermediator: {
|
|
23
|
+
payment_method: params.payment_method,
|
|
24
|
+
},
|
|
25
|
+
currency_id: params.currency_id,
|
|
26
|
+
currency_symbol: params.currency_symbol,
|
|
27
|
+
amount: amount.total,
|
|
28
|
+
status: {
|
|
29
|
+
current: 'pending',
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
const finalAmount = Math.floor(amount.total * 100);
|
|
33
|
+
const finalFreight = amount.freight ? Math.floor(amount.freight * 100) : 0;
|
|
34
|
+
const parseAddress = (_to) => ({
|
|
35
|
+
name: _to.name,
|
|
36
|
+
city: _to.city,
|
|
37
|
+
state: _to.province_code,
|
|
38
|
+
street: _to.street,
|
|
39
|
+
zip_code: _to.zip,
|
|
40
|
+
neighborhood: _to.borough,
|
|
41
|
+
number: String(_to.number) || 's/n',
|
|
42
|
+
complement: _to.complement || undefined,
|
|
43
|
+
});
|
|
44
|
+
const shippingAddr = params.to && parseAddress(params.to);
|
|
45
|
+
const billingAddr = params.billing_address
|
|
46
|
+
? parseAddress(params.billing_address)
|
|
47
|
+
: shippingAddr;
|
|
48
|
+
const hash = createHmac('sha256', appData.password)
|
|
49
|
+
.update(orderId).digest('hex');
|
|
50
|
+
const pagaleveTransaction = {
|
|
51
|
+
cancel_url: `https://${params.domain}/app/#/order/${orderNumber}/${orderId}`,
|
|
52
|
+
approve_url: `https://${params.domain}/app/#/order/${orderNumber}/${orderId}`,
|
|
53
|
+
webhook_url: `${baseUri}/pagaleve-webhook?order_id=${orderId}&hash=${hash}`,
|
|
54
|
+
is_pix_upfront: !!isPix,
|
|
55
|
+
order: {
|
|
56
|
+
reference: orderId,
|
|
57
|
+
description: `Order from e-com.plus ${orderNumber}`,
|
|
58
|
+
shipping: {
|
|
59
|
+
amount: finalFreight || 0,
|
|
60
|
+
address: shippingAddr,
|
|
61
|
+
},
|
|
62
|
+
amount: finalAmount,
|
|
63
|
+
items: [],
|
|
64
|
+
timestamp: new Date().toISOString(),
|
|
65
|
+
type: 'ORDINARY',
|
|
66
|
+
},
|
|
67
|
+
shopper: {
|
|
68
|
+
cpf: String(buyer.doc_number),
|
|
69
|
+
first_name: buyer.fullname.replace(/\s.*/, ''),
|
|
70
|
+
last_name: buyer.fullname.replace(/[^\s]+\s/, ''),
|
|
71
|
+
email: buyer.email,
|
|
72
|
+
phone: buyer.phone.number,
|
|
73
|
+
billing_address: billingAddr,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
let totalQuantity = 0;
|
|
77
|
+
items.forEach((item) => {
|
|
78
|
+
if (item.quantity > 0) {
|
|
79
|
+
totalQuantity += item.quantity;
|
|
80
|
+
const objImg = getImg(item);
|
|
81
|
+
pagaleveTransaction.order.items.push({
|
|
82
|
+
name: item.name || item.sku,
|
|
83
|
+
sku: item.sku,
|
|
84
|
+
quantity: item.quantity,
|
|
85
|
+
price: Math.floor((item.final_price || item.price) * 100),
|
|
86
|
+
url: `https://${params.domain}`,
|
|
87
|
+
reference: item.product_id,
|
|
88
|
+
image: objImg && objImg.url ? objImg.url : `https://${params.domain}`,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
const birthDate = buyer.birth_date;
|
|
93
|
+
if (birthDate && birthDate.year && birthDate.month && birthDate.day) {
|
|
94
|
+
pagaleveTransaction.birth_date = `${birthDate.year}-`
|
|
95
|
+
+ `${birthDate.month.toString().padStart(2, '0')}-`
|
|
96
|
+
+ birthDate.day.toString().padStart(2, '0');
|
|
97
|
+
}
|
|
98
|
+
if (totalQuantity > 0) {
|
|
99
|
+
try {
|
|
100
|
+
await pagaleve.preparing;
|
|
101
|
+
const { data } = pagaleve.axios.post('/v1/checkouts', pagaleveTransaction, {
|
|
102
|
+
maxRedirects: 0,
|
|
103
|
+
});
|
|
104
|
+
transaction.payment_link = data.redirect_url || data.checkout_url;
|
|
105
|
+
if (isPix && data.timestamp) {
|
|
106
|
+
transaction.account_deposit = {
|
|
107
|
+
valid_thru: data.timestamp,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
redirect_to_payment: true,
|
|
112
|
+
transaction,
|
|
113
|
+
};
|
|
114
|
+
} catch (error) {
|
|
115
|
+
const errCode = 'PAGALEVE_TRANSACTION_ERR';
|
|
116
|
+
let { message } = error;
|
|
117
|
+
const err = new Error(`${errCode} #${orderId} => ${message}`);
|
|
118
|
+
if (error.response) {
|
|
119
|
+
const { status, data } = error.response;
|
|
120
|
+
if (status !== 401 && status !== 403) {
|
|
121
|
+
err.transaction = transaction;
|
|
122
|
+
err.status = status;
|
|
123
|
+
if (typeof data === 'object' && data) {
|
|
124
|
+
err.response = JSON.stringify(data);
|
|
125
|
+
} else {
|
|
126
|
+
err.response = data;
|
|
127
|
+
}
|
|
128
|
+
} else if (Array.isArray(data?.errors) && data.errors[0]?.message) {
|
|
129
|
+
message = data.errors[0].message;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
logger.error(err);
|
|
133
|
+
return {
|
|
134
|
+
status: 409,
|
|
135
|
+
error: errCode,
|
|
136
|
+
message,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
status: 400,
|
|
142
|
+
error: 'PAGALEVE_TRANSACTION_INVALID',
|
|
143
|
+
message: 'Não há itens disponíveis no pedido',
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export default pagaleveCreateTransaction;
|
|
148
|
+
// # sourceMappingURL=pagaleve-create-transaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagaleve-create-transaction.js","sourceRoot":"","sources":["../src/pagaleve-create-transaction.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,EAAE,GAAG,IAAI,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,MAAM,MAAM,oCAAoC,CAAC;AACxD,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAE9C,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC;AACrD,MAAM,OAAO,GAAG,WAAW,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,qBAAqB,CAAC;AAErF,MAAM,yBAAyB,GAAG,KAAK,EAAE,IAAyC,EAAE,EAAE;IACpF,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;IACrC,MAAM,OAAO,GAAG,EAAE,GAAG,WAAW,CAAC,IAAI,EAAE,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC;IACpE,MAAM,EACJ,iBAAiB,EACjB,iBAAiB,EACjB,g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AM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;oBACrC,GAAG,CAAC,WAAW,GAAG,WAAW,CAAC;oBAC9B,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC;oBACpB,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,EAAE,CAAC;wBACrC,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;oBACtC,CAAC;yBAAM,CAAC;wBACN,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC;oBACtB,CAAC;gBACH,CAAC;qBAAM,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;oBAClE,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;gBACnC,CAAC;YACH,CAAC;YACD,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAClB,OAAO;gBACL,MAAM,EAAE,GAAG;gBACX,KAAK,EAAE,OAAO;gBACd,OAAO;aACR,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO;QACL,MAAM,EAAE,GAAG;QACX,KAAK,EAAE,8BAA8B;QACrC,OAAO,EAAE,oCAAoC;KAC9C,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AppModuleBody, ListPaymentsResponse } from '@cloudcommerce/types';
|
|
2
|
+
declare const pagaleveListPayments: (body: AppModuleBody<'list_payments'>) => ListPaymentsResponse | {
|
|
3
|
+
status: number;
|
|
4
|
+
error: string;
|
|
5
|
+
message: string;
|
|
6
|
+
};
|
|
7
|
+
export default pagaleveListPayments;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import logger from 'firebase-functions/logger';
|
|
2
|
+
|
|
3
|
+
const pagaleveListPayments = (body) => {
|
|
4
|
+
const { application } = body;
|
|
5
|
+
const params = body.params;
|
|
6
|
+
const response = {
|
|
7
|
+
payment_gateways: [],
|
|
8
|
+
};
|
|
9
|
+
const appData = { ...application.data, ...application.hidden_data };
|
|
10
|
+
const { PAGALEVE_USERNAME, PAGALEVE_PASSWORD } = process.env;
|
|
11
|
+
if (PAGALEVE_USERNAME) appData.username = PAGALEVE_USERNAME;
|
|
12
|
+
if (PAGALEVE_PASSWORD) appData.password = PAGALEVE_PASSWORD;
|
|
13
|
+
if (!appData.username || !appData.password) {
|
|
14
|
+
logger.warn('Missign Pagaleve username/password');
|
|
15
|
+
return {
|
|
16
|
+
status: 409,
|
|
17
|
+
error: 'NO_PAGALEVE_KEYS',
|
|
18
|
+
message: 'Usuário e/ou senha não configurados pelo lojista',
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const amount = params.amount || {};
|
|
22
|
+
const intermediator = {
|
|
23
|
+
name: 'Pagaleve',
|
|
24
|
+
link: 'https://api.pagaleve.com.br',
|
|
25
|
+
code: 'pagaleve',
|
|
26
|
+
};
|
|
27
|
+
const { discount } = appData;
|
|
28
|
+
if (discount && discount.value) {
|
|
29
|
+
if (discount.apply_at !== 'freight') {
|
|
30
|
+
const { value } = discount;
|
|
31
|
+
response.discount_option = {
|
|
32
|
+
label: 'Pix',
|
|
33
|
+
value,
|
|
34
|
+
};
|
|
35
|
+
['type', 'min_amount'].forEach((prop) => {
|
|
36
|
+
if (discount[prop]) {
|
|
37
|
+
response.discount_option[prop] = discount[prop];
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
if (amount.total) {
|
|
42
|
+
if (amount.total < discount.min_amount) {
|
|
43
|
+
discount.value = 0;
|
|
44
|
+
} else {
|
|
45
|
+
delete discount.min_amount;
|
|
46
|
+
const maxDiscount = amount[discount.apply_at || 'subtotal'];
|
|
47
|
+
let discountValue;
|
|
48
|
+
if (discount.type === 'percentage') {
|
|
49
|
+
discountValue = maxDiscount * (discount.value / 100);
|
|
50
|
+
} else {
|
|
51
|
+
discountValue = discount.value;
|
|
52
|
+
if (discountValue > maxDiscount) {
|
|
53
|
+
discountValue = maxDiscount;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (discountValue) {
|
|
57
|
+
amount.discount = (amount.discount || 0) + discountValue;
|
|
58
|
+
amount.total -= discountValue;
|
|
59
|
+
if (amount.total < 0) {
|
|
60
|
+
amount.total = 0;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const listPaymentMethods = ['payment_link', 'account_deposit'];
|
|
67
|
+
listPaymentMethods.forEach((paymentMethod) => {
|
|
68
|
+
const isLinkPayment = paymentMethod === 'payment_link';
|
|
69
|
+
const methodConfig = (appData[paymentMethod] || {});
|
|
70
|
+
const minAmount = Number(methodConfig.min_amount || 1);
|
|
71
|
+
let validateAmount = false;
|
|
72
|
+
if (amount.total && minAmount >= 0) {
|
|
73
|
+
validateAmount = amount.total >= minAmount;
|
|
74
|
+
}
|
|
75
|
+
// Workaround for showcase
|
|
76
|
+
const validatePayment = amount.total ? validateAmount : true;
|
|
77
|
+
const methodEnable = !methodConfig.disable;
|
|
78
|
+
if (validatePayment && methodEnable) {
|
|
79
|
+
const label = methodConfig.label || (isLinkPayment ? 'Pix Parcelado' : 'Pagar com Pix');
|
|
80
|
+
const gateway = {
|
|
81
|
+
label,
|
|
82
|
+
icon: methodConfig.icon,
|
|
83
|
+
text: methodConfig.text,
|
|
84
|
+
payment_method: {
|
|
85
|
+
code: isLinkPayment ? 'balance_on_intermediary' : paymentMethod,
|
|
86
|
+
name: `${label} - ${intermediator.name} `,
|
|
87
|
+
},
|
|
88
|
+
intermediator,
|
|
89
|
+
};
|
|
90
|
+
if (!gateway.icon) {
|
|
91
|
+
if (isLinkPayment) {
|
|
92
|
+
gateway.icon = 'https://ecom-pagaleve.web.app/pagaleve-parcelado.png';
|
|
93
|
+
} else {
|
|
94
|
+
gateway.icon = 'https://ecom-pagaleve.web.app/pagaleve-pix.png';
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if ((discount && discount.value && discount[paymentMethod] !== false)) {
|
|
98
|
+
gateway.discount = {};
|
|
99
|
+
['apply_at', 'type', 'value'].forEach((field) => {
|
|
100
|
+
gateway.discount[field] = discount[field];
|
|
101
|
+
});
|
|
102
|
+
if (response.discount_option && !response.discount_option.label) {
|
|
103
|
+
response.discount_option.label = label;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
response.payment_gateways.push(gateway);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
return response;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export default pagaleveListPayments;
|
|
113
|
+
// # sourceMappingURL=pagaleve-list-payments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagaleve-list-payments.js","sourceRoot":"","sources":["../src/pagaleve-list-payments.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAE/C,MAAM,oBAAoB,GAAG,CAAC,IAAoC,EAAE,EAAE;IACpE,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;IAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC3B,MAAM,QAAQ,GAAyB;QACrC,gBAAgB,EAAE,EAAE;KACrB,CAAC;IACF,MAAM,OAAO,GAAG,EAAE,GAAG,WAAW,CAAC,IAAI,EAAE,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC;IACpE,MAAM,EACJ,iBAAiB,EACjB,iBAAiB,GAClB,GAAG,OAAO,CAAC,GAAG,CAAC;IAChB,IAAI,iBAAiB;QAAE,OAAO,CAAC,QAAQ,GAAG,iBAAiB,CAAC;IAC5D,IAAI,iBAAiB;QAAE,OAAO,CAAC,QAAQ,GAAG,iBAAiB,CAAC;IAE5D,IAAI,CAAC,OAAO,CAAC,QAAQ,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C,eAAe,CAAC,KAAK,GAAG,KAAK,CAAC;gBACzC,CAAC;YACH,CAAC;YACD,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/* eslint-disable import/prefer-default-export */
|
|
2
|
+
import { createHmac, timingSafeEqual } from 'node:crypto';
|
|
3
|
+
import functions from 'firebase-functions/v1';
|
|
4
|
+
import logger from 'firebase-functions/logger';
|
|
5
|
+
import api from '@cloudcommerce/api';
|
|
6
|
+
import config from '@cloudcommerce/firebase/lib/config';
|
|
7
|
+
import Pagaleve from './pagaleve-constructor.js';
|
|
8
|
+
|
|
9
|
+
const { httpsFunctionOptions } = config.get();
|
|
10
|
+
const getAppHiddenData = async () => {
|
|
11
|
+
const { appId } = config.get().apps.pagaleve;
|
|
12
|
+
const { data } = await api.get(`applications?app_id=${appId}&fields=hidden_data`);
|
|
13
|
+
return data.result[0]?.hidden_data;
|
|
14
|
+
};
|
|
15
|
+
const parseStatusToEcom = (pagaleveTransactionStatus) => {
|
|
16
|
+
switch (pagaleveTransactionStatus.toLowerCase()) {
|
|
17
|
+
case 'pending':
|
|
18
|
+
case 'new':
|
|
19
|
+
case 'accepted':
|
|
20
|
+
return 'pending';
|
|
21
|
+
case 'authorized':
|
|
22
|
+
case 'completed':
|
|
23
|
+
return 'paid';
|
|
24
|
+
case 'expired':
|
|
25
|
+
case 'DECLINED':
|
|
26
|
+
case 'ABANDONED':
|
|
27
|
+
case 'canceled':
|
|
28
|
+
return 'voided';
|
|
29
|
+
default:
|
|
30
|
+
}
|
|
31
|
+
return 'unknown';
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const pagarme = {
|
|
35
|
+
webhook: functions
|
|
36
|
+
.region(httpsFunctionOptions.region)
|
|
37
|
+
.runWith(httpsFunctionOptions)
|
|
38
|
+
.https.onRequest(async (req, res) => {
|
|
39
|
+
const { body, query: { hash } } = req;
|
|
40
|
+
if (typeof hash !== 'string') {
|
|
41
|
+
res.sendStatus(403);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const {
|
|
45
|
+
id, orderReference, state, amount,
|
|
46
|
+
} = (body || {});
|
|
47
|
+
if (typeof orderReference !== 'string' || orderReference.length !== 24) {
|
|
48
|
+
res.sendStatus(400);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
let appData;
|
|
52
|
+
try {
|
|
53
|
+
appData = await getAppHiddenData();
|
|
54
|
+
} catch (err) {
|
|
55
|
+
logger.error(err);
|
|
56
|
+
res.sendStatus(500);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (!appData?.password) {
|
|
60
|
+
res.sendStatus(409);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const { PAGALEVE_USERNAME, PAGALEVE_PASSWORD, PAGALEVE_SANDBOX } = process.env;
|
|
64
|
+
if (PAGALEVE_USERNAME) appData.username = PAGALEVE_USERNAME;
|
|
65
|
+
if (PAGALEVE_PASSWORD) appData.password = PAGALEVE_PASSWORD;
|
|
66
|
+
const isSandbox = !!PAGALEVE_SANDBOX;
|
|
67
|
+
const validHash = createHmac('sha256', appData.password)
|
|
68
|
+
.update(orderReference).digest('hex');
|
|
69
|
+
if (validHash.length !== hash.length
|
|
70
|
+
|| !timingSafeEqual(Buffer.from(hash), Buffer.from(validHash))) {
|
|
71
|
+
res.sendStatus(401);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const orderEndpoint = `orders/${orderReference}`;
|
|
75
|
+
try {
|
|
76
|
+
const { data: order } = await api.get(orderEndpoint);
|
|
77
|
+
if (order?.transactions) {
|
|
78
|
+
const transactionIndex = order.transactions.findIndex(({ app }) => {
|
|
79
|
+
return app?.intermediator?.code === 'pagaleve';
|
|
80
|
+
});
|
|
81
|
+
const transactionId = order.transactions[transactionIndex]?._id;
|
|
82
|
+
if (!transactionId) {
|
|
83
|
+
res.sendStatus(404);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
await api.post(`${orderEndpoint}/payments_history`, {
|
|
87
|
+
date_time: new Date().toISOString(),
|
|
88
|
+
status: parseStatusToEcom(state),
|
|
89
|
+
transaction_id: transactionId,
|
|
90
|
+
flags: ['pagaleve'],
|
|
91
|
+
});
|
|
92
|
+
await api.patch(`${orderEndpoint}/transactions/${transactionId}`, {
|
|
93
|
+
intermediator: {
|
|
94
|
+
transaction_id: id || '',
|
|
95
|
+
transaction_code: id || '',
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
if (state.toLowerCase() === 'authorized') {
|
|
99
|
+
const pagaleve = new Pagaleve(appData.username, appData.password, isSandbox);
|
|
100
|
+
await pagaleve.preparing;
|
|
101
|
+
const pagalevePayment = {
|
|
102
|
+
checkout_id: id,
|
|
103
|
+
currency: 'BRL',
|
|
104
|
+
amount,
|
|
105
|
+
intent: 'CAPTURE',
|
|
106
|
+
};
|
|
107
|
+
await pagaleve.axios.post('/v1/payments', pagalevePayment, {
|
|
108
|
+
maxRedirects: 0,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
} catch (error) {
|
|
113
|
+
const { response } = error;
|
|
114
|
+
let status;
|
|
115
|
+
if (response) {
|
|
116
|
+
status = response.status;
|
|
117
|
+
const err = new Error(`Webhook failed with ${status} for #${orderReference}`);
|
|
118
|
+
err.url = error.config?.url;
|
|
119
|
+
err.body = error.config?.body;
|
|
120
|
+
err.status = status;
|
|
121
|
+
err.response = JSON.stringify(response.data);
|
|
122
|
+
logger.error(err);
|
|
123
|
+
} else {
|
|
124
|
+
logger.error(error);
|
|
125
|
+
}
|
|
126
|
+
if (!res.headersSent) {
|
|
127
|
+
res.send({
|
|
128
|
+
status: status || 500,
|
|
129
|
+
msg: `Pagaleve webhook error for ${orderReference}`,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}),
|
|
134
|
+
};
|
|
135
|
+
// # sourceMappingURL=pagaleve-webhook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagaleve-webhook.js","sourceRoot":"","sources":["../src/pagaleve-webhook.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,SAAS,MAAM,uBAAuB,CAAC;AAC9C,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,GAAG,MAAM,oBAAoB,CAAC;AACrC,OAAO,MAAM,MAAM,oCAAoC,CAAC;AACxD,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAE9C,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC;AAE9C,MAAM,gBAAgB,GAAG,KAAK,IAAI,EAAE;IAClC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC;IAC7C,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,uBAAuB,KAAK,qBAAqB,CAAC,CAAC;IAClF,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC;AACrC,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,yBAAiC,EAAE,EAAE;IAC9D,QAAQ,yBAAyB,CAAC,WAAW,EAAE,EAAE,CAAC;QAChD,KAAK,SAAS,CAAC;QACf,KAAK,KAAK,CAAC;QACX,KAAK,UAAU;YACb,OAAO,SAAS,CAAC;QACnB,KAAK,YAAY,CAAC;QAClB,KAAK,WAAW;YACd,OAAO,MAAM,CAAC;QAChB,KAAK,SAAS,CAAC;QACf,KAAK,UAAU,CAAC;QAChB,KAAK,WAAW,CAAC;QACjB,KAA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,CAAC,MAAM,EAAE,IAAI,CAAC;gBAC9B,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC;gBACpB,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;gBAC7C,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACpB,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACtB,CAAC;YACD,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;gBACrB,GAAG,CAAC,IAAI,CAAC;oBACP,MAAM,EAAE,MAAM,IAAI,GAAG;oBACrB,GAAG,EAAE,8BAA8B,cAAc,EAAE;iBACpD,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC,CAAC;CACL,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import '@cloudcommerce/firebase/lib/init';
|
|
2
|
+
import type { AppModuleBody } from '@cloudcommerce/types';
|
|
3
|
+
export declare const listPayments: (modBody: AppModuleBody<'list_payments'>) => Promise<import("@cloudcommerce/types").ListPaymentsResponse | {
|
|
4
|
+
status: number;
|
|
5
|
+
error: string;
|
|
6
|
+
message: string;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const createTransaction: (modBody: AppModuleBody<'create_transaction'>) => Promise<import("@cloudcommerce/types").CreateTransactionResponse | {
|
|
9
|
+
status: number;
|
|
10
|
+
error: string;
|
|
11
|
+
message: any;
|
|
12
|
+
}>;
|
package/lib/pagaleve.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import '@cloudcommerce/firebase/lib/init';
|
|
2
|
+
import handleListPayments from './pagaleve-list-payments.js';
|
|
3
|
+
import handleCreateTransaction from './pagaleve-create-transaction.js';
|
|
4
|
+
|
|
5
|
+
export const listPayments = async (modBody) => {
|
|
6
|
+
return handleListPayments(modBody);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const createTransaction = async (modBody) => {
|
|
10
|
+
return handleCreateTransaction(modBody);
|
|
11
|
+
};
|
|
12
|
+
// # sourceMappingURL=pagaleve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagaleve.js","sourceRoot":"","sources":["../src/pagaleve.ts"],"names":[],"mappings":"AAAA,OAAO,kCAAkC,CAAC;AAE1C,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAC1D,OAAO,uBAAuB,MAAM,+BAA+B,CAAC;AAEpE,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,OAAuC,EAAE,EAAE;IAC5E,OAAO,kBAAkB,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAAE,OAA4C,EAAE,EAAE;IACtF,OAAO,uBAAuB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cloudcommerce/app-pagaleve",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "2.12.0",
|
|
5
|
+
"description": "e-com.plus Cloud Commerce app to integrate Pagaleve",
|
|
6
|
+
"main": "lib/pagaleve.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./lib/pagaleve.js",
|
|
9
|
+
"./webhook": "./lib/pagaleve-webhook.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"/lib",
|
|
13
|
+
"/lib-mjs",
|
|
14
|
+
"/assets",
|
|
15
|
+
"/types",
|
|
16
|
+
"/*.{js,mjs,ts}"
|
|
17
|
+
],
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/ecomplus/cloud-commerce.git",
|
|
21
|
+
"directory": "packages/apps/pagaleve"
|
|
22
|
+
},
|
|
23
|
+
"author": "E-Com Club Softwares para E-commerce <ti@e-com.club>",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/ecomplus/cloud-commerce/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/ecomplus/cloud-commerce/tree/main/packages/apps/pagaleve#readme",
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@ecomplus/utils": "1.5.0-rc.6",
|
|
31
|
+
"axios": "^1.6.8",
|
|
32
|
+
"firebase-admin": "^12.0.0",
|
|
33
|
+
"firebase-functions": "^4.8.2",
|
|
34
|
+
"@cloudcommerce/api": "2.12.0",
|
|
35
|
+
"@cloudcommerce/firebase": "2.12.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@cloudcommerce/types": "2.12.0"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "bash ../../../scripts/build-lib.sh"
|
|
42
|
+
}
|
|
43
|
+
}
|
package/webhook.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/pagaleve-webhook';
|