@infrab4a/connect-nestjs 1.8.0-beta.1 → 1.8.0-beta.10
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/index.cjs.js +25 -16
- package/index.esm.js +23 -14
- package/package.json +2 -2
- package/src/infra/pagarme/adapters/index.d.ts +3 -0
- package/src/infra/pagarme/{services/pagarme-bank-slip-api.service.d.ts → adapters/pagarme-bank-slip-api.adapter.d.ts} +1 -1
- package/src/infra/pagarme/{services/pagarme-card-api.service.d.ts → adapters/pagarme-card-api.adapter.d.ts} +1 -1
- package/src/infra/pagarme/{services/pagarme-pix-api.service.d.ts → adapters/pagarme-pix-api.adapter.d.ts} +1 -1
- package/src/infra/pagarme/index.d.ts +1 -1
- package/src/infra/pagarme/services/index.d.ts +0 -3
package/index.cjs.js
CHANGED
|
@@ -295,7 +295,7 @@ class ConnectFirestoreService {
|
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
-
class
|
|
298
|
+
class PagarmeBankSlipAPIAdapter {
|
|
299
299
|
constructor(credentials, paymentRepository) {
|
|
300
300
|
this.credentials = credentials;
|
|
301
301
|
this.paymentRepository = paymentRepository;
|
|
@@ -303,12 +303,13 @@ class PagarmeBankSlipAPIService {
|
|
|
303
303
|
async pay(checkout) {
|
|
304
304
|
try {
|
|
305
305
|
const client = await pagarme__default["default"].client.connect({ api_key: this.credentials.API_KEY });
|
|
306
|
-
const result = client.transactions.create(Object.assign({}, this.createBoletoPayment(checkout)));
|
|
307
|
-
|
|
306
|
+
const result = await client.transactions.create(Object.assign({}, this.createBoletoPayment(checkout)));
|
|
307
|
+
console.log('result PagarmeBankSlipAPIAdapter', result);
|
|
308
|
+
if (result.status !== connect.PagarmePaymentStatus['Em processamento']) {
|
|
308
309
|
return Promise.reject(new connect.PaymentError(`Houve uma falha ao gerar o boleto. Tente novamente`, {
|
|
309
310
|
checkoutId: checkout.id,
|
|
310
311
|
userEmail: checkout.user.email,
|
|
311
|
-
info: result
|
|
312
|
+
info: result,
|
|
312
313
|
}));
|
|
313
314
|
}
|
|
314
315
|
const payment = await this.paymentRepository.create(connect.Payment.toInstance({
|
|
@@ -318,11 +319,12 @@ class PagarmeBankSlipAPIService {
|
|
|
318
319
|
checkoutId: checkout.id,
|
|
319
320
|
totalPrice: checkout.totalPrice,
|
|
320
321
|
paymentProvider: 'pagarMe',
|
|
321
|
-
transaction: result
|
|
322
|
+
transaction: result,
|
|
322
323
|
}));
|
|
323
324
|
return payment;
|
|
324
325
|
}
|
|
325
326
|
catch (error) {
|
|
327
|
+
console.log('Error PagarmeBankSlipAPIAdapter', JSON.stringify(error));
|
|
326
328
|
throw new connect.PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
327
329
|
checkoutId: checkout.id,
|
|
328
330
|
userEmail: checkout.user.email,
|
|
@@ -368,7 +370,7 @@ class PagarmeBankSlipAPIService {
|
|
|
368
370
|
}
|
|
369
371
|
}
|
|
370
372
|
|
|
371
|
-
class
|
|
373
|
+
class PagarmeCardAPIAdapter {
|
|
372
374
|
constructor(credentials, paymentRepository, orderBlockedRepository) {
|
|
373
375
|
this.credentials = credentials;
|
|
374
376
|
this.paymentRepository = paymentRepository;
|
|
@@ -377,13 +379,14 @@ class PagarmeCardAPIService {
|
|
|
377
379
|
async pay(checkout, card) {
|
|
378
380
|
try {
|
|
379
381
|
const client = await pagarme__default["default"].client.connect({ api_key: this.credentials.API_KEY });
|
|
380
|
-
const result = client.transactions.create(Object.assign({}, this.createCardPayment(checkout, card)));
|
|
381
|
-
|
|
382
|
+
const result = await client.transactions.create(Object.assign({}, this.createCardPayment(checkout, card)));
|
|
383
|
+
console.log('result PagarmeCardAPIAdapter', result);
|
|
384
|
+
if (result.status !== connect.PagarmePaymentStatus.Pago) {
|
|
382
385
|
await this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'Card not authorized', 'Card', 'day', card);
|
|
383
386
|
return Promise.reject(new connect.PaymentError(`Seu pagamento com cartão não foi autorizado. Para não perder seus produtos, pague com PIX ou outro cartão de crédito`, {
|
|
384
387
|
checkoutId: checkout.id,
|
|
385
388
|
userEmail: checkout.user.email,
|
|
386
|
-
info: result
|
|
389
|
+
info: result,
|
|
387
390
|
}));
|
|
388
391
|
}
|
|
389
392
|
const payment = await this.paymentRepository.create(connect.Payment.toInstance({
|
|
@@ -393,11 +396,12 @@ class PagarmeCardAPIService {
|
|
|
393
396
|
checkoutId: checkout.id,
|
|
394
397
|
totalPrice: checkout.totalPrice,
|
|
395
398
|
paymentProvider: connect.PaymentProviders.PAGARME,
|
|
396
|
-
transaction: Object.assign(Object.assign({}, result
|
|
399
|
+
transaction: Object.assign(Object.assign({}, result), { paidAt: new Date() }),
|
|
397
400
|
}));
|
|
398
401
|
return payment;
|
|
399
402
|
}
|
|
400
403
|
catch (error) {
|
|
404
|
+
console.log('Error PagarmeCardAPIAdapter', JSON.stringify(error));
|
|
401
405
|
throw new connect.PaymentError('Seu pagamento com cartão não foi autorizado. Para não perder seus produtos, pague com PIX ou outro cartão de crédito', {
|
|
402
406
|
checkoutId: checkout.id,
|
|
403
407
|
userEmail: checkout.user.email,
|
|
@@ -515,7 +519,7 @@ class PagarmeCardAPIService {
|
|
|
515
519
|
}
|
|
516
520
|
}
|
|
517
521
|
|
|
518
|
-
class
|
|
522
|
+
class PagarmePixAPIAdapter {
|
|
519
523
|
constructor(credentials, paymentRepository) {
|
|
520
524
|
this.credentials = credentials;
|
|
521
525
|
this.paymentRepository = paymentRepository;
|
|
@@ -523,7 +527,8 @@ class PagarmePixAPIService {
|
|
|
523
527
|
async pay(checkout) {
|
|
524
528
|
try {
|
|
525
529
|
const client = await pagarme__default["default"].client.connect({ api_key: this.credentials.API_KEY });
|
|
526
|
-
const result = client.transactions.create(Object.assign({}, this.createPixPayment(checkout)));
|
|
530
|
+
const result = await client.transactions.create(Object.assign({}, this.createPixPayment(checkout)));
|
|
531
|
+
console.log('result PagarmePixAPIAdapter', result);
|
|
527
532
|
const payment = await this.paymentRepository.create(connect.Payment.toInstance({
|
|
528
533
|
createdAt: new Date(),
|
|
529
534
|
updatedAt: new Date(),
|
|
@@ -531,11 +536,12 @@ class PagarmePixAPIService {
|
|
|
531
536
|
checkoutId: checkout.id,
|
|
532
537
|
totalPrice: checkout.totalPrice,
|
|
533
538
|
paymentProvider: 'pagarMe',
|
|
534
|
-
transaction: Object.assign(Object.assign({}, result
|
|
539
|
+
transaction: Object.assign(Object.assign({}, result), { paidAt: new Date() }),
|
|
535
540
|
}));
|
|
536
541
|
return payment;
|
|
537
542
|
}
|
|
538
543
|
catch (error) {
|
|
544
|
+
console.log('Error PagarmePixAPIAdapter', JSON.stringify(error));
|
|
539
545
|
throw new connect.PaymentError('Houve uma falha ao processar pagamento com pix', {
|
|
540
546
|
checkoutId: checkout.id,
|
|
541
547
|
userEmail: checkout.user.email,
|
|
@@ -1010,7 +1016,10 @@ exports.NestFirestoreModule = NestFirestoreModule_1 = __decorate([
|
|
|
1010
1016
|
'LegacyOrderRepository',
|
|
1011
1017
|
'ShopMenuRepository',
|
|
1012
1018
|
'OrderRepository',
|
|
1019
|
+
'OrderBlockedRepository',
|
|
1013
1020
|
'PaymentRepository',
|
|
1021
|
+
'SequenceRepository',
|
|
1022
|
+
'LogRepository',
|
|
1014
1023
|
connect.ProductFirestoreRepository,
|
|
1015
1024
|
'ShopSettingsRepository',
|
|
1016
1025
|
'SubscriptionPaymentRepository',
|
|
@@ -1237,8 +1246,8 @@ exports.ConnectFirestoreService = ConnectFirestoreService;
|
|
|
1237
1246
|
exports.ES_CONFIG = ES_CONFIG;
|
|
1238
1247
|
exports.FIREBASE_STORAGE = FIREBASE_STORAGE;
|
|
1239
1248
|
exports.HASURA_OPTIONS = HASURA_OPTIONS;
|
|
1240
|
-
exports.
|
|
1241
|
-
exports.
|
|
1242
|
-
exports.
|
|
1249
|
+
exports.PagarmeBankSlipAPIAdapter = PagarmeBankSlipAPIAdapter;
|
|
1250
|
+
exports.PagarmeCardAPIAdapter = PagarmeCardAPIAdapter;
|
|
1251
|
+
exports.PagarmePixAPIAdapter = PagarmePixAPIAdapter;
|
|
1243
1252
|
exports.ProductVertexHelper = ProductVertexHelper;
|
|
1244
1253
|
exports.VERTEX_CONFIG = VERTEX_CONFIG;
|
package/index.esm.js
CHANGED
|
@@ -287,7 +287,7 @@ class ConnectFirestoreService {
|
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
289
|
|
|
290
|
-
class
|
|
290
|
+
class PagarmeBankSlipAPIAdapter {
|
|
291
291
|
constructor(credentials, paymentRepository) {
|
|
292
292
|
this.credentials = credentials;
|
|
293
293
|
this.paymentRepository = paymentRepository;
|
|
@@ -295,12 +295,13 @@ class PagarmeBankSlipAPIService {
|
|
|
295
295
|
async pay(checkout) {
|
|
296
296
|
try {
|
|
297
297
|
const client = await pagarme.client.connect({ api_key: this.credentials.API_KEY });
|
|
298
|
-
const result = client.transactions.create(Object.assign({}, this.createBoletoPayment(checkout)));
|
|
299
|
-
|
|
298
|
+
const result = await client.transactions.create(Object.assign({}, this.createBoletoPayment(checkout)));
|
|
299
|
+
console.log('result PagarmeBankSlipAPIAdapter', result);
|
|
300
|
+
if (result.status !== PagarmePaymentStatus['Em processamento']) {
|
|
300
301
|
return Promise.reject(new PaymentError(`Houve uma falha ao gerar o boleto. Tente novamente`, {
|
|
301
302
|
checkoutId: checkout.id,
|
|
302
303
|
userEmail: checkout.user.email,
|
|
303
|
-
info: result
|
|
304
|
+
info: result,
|
|
304
305
|
}));
|
|
305
306
|
}
|
|
306
307
|
const payment = await this.paymentRepository.create(Payment.toInstance({
|
|
@@ -310,11 +311,12 @@ class PagarmeBankSlipAPIService {
|
|
|
310
311
|
checkoutId: checkout.id,
|
|
311
312
|
totalPrice: checkout.totalPrice,
|
|
312
313
|
paymentProvider: 'pagarMe',
|
|
313
|
-
transaction: result
|
|
314
|
+
transaction: result,
|
|
314
315
|
}));
|
|
315
316
|
return payment;
|
|
316
317
|
}
|
|
317
318
|
catch (error) {
|
|
319
|
+
console.log('Error PagarmeBankSlipAPIAdapter', JSON.stringify(error));
|
|
318
320
|
throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
319
321
|
checkoutId: checkout.id,
|
|
320
322
|
userEmail: checkout.user.email,
|
|
@@ -360,7 +362,7 @@ class PagarmeBankSlipAPIService {
|
|
|
360
362
|
}
|
|
361
363
|
}
|
|
362
364
|
|
|
363
|
-
class
|
|
365
|
+
class PagarmeCardAPIAdapter {
|
|
364
366
|
constructor(credentials, paymentRepository, orderBlockedRepository) {
|
|
365
367
|
this.credentials = credentials;
|
|
366
368
|
this.paymentRepository = paymentRepository;
|
|
@@ -369,13 +371,14 @@ class PagarmeCardAPIService {
|
|
|
369
371
|
async pay(checkout, card) {
|
|
370
372
|
try {
|
|
371
373
|
const client = await pagarme.client.connect({ api_key: this.credentials.API_KEY });
|
|
372
|
-
const result = client.transactions.create(Object.assign({}, this.createCardPayment(checkout, card)));
|
|
373
|
-
|
|
374
|
+
const result = await client.transactions.create(Object.assign({}, this.createCardPayment(checkout, card)));
|
|
375
|
+
console.log('result PagarmeCardAPIAdapter', result);
|
|
376
|
+
if (result.status !== PagarmePaymentStatus.Pago) {
|
|
374
377
|
await this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'Card not authorized', 'Card', 'day', card);
|
|
375
378
|
return Promise.reject(new PaymentError(`Seu pagamento com cartão não foi autorizado. Para não perder seus produtos, pague com PIX ou outro cartão de crédito`, {
|
|
376
379
|
checkoutId: checkout.id,
|
|
377
380
|
userEmail: checkout.user.email,
|
|
378
|
-
info: result
|
|
381
|
+
info: result,
|
|
379
382
|
}));
|
|
380
383
|
}
|
|
381
384
|
const payment = await this.paymentRepository.create(Payment.toInstance({
|
|
@@ -385,11 +388,12 @@ class PagarmeCardAPIService {
|
|
|
385
388
|
checkoutId: checkout.id,
|
|
386
389
|
totalPrice: checkout.totalPrice,
|
|
387
390
|
paymentProvider: PaymentProviders.PAGARME,
|
|
388
|
-
transaction: Object.assign(Object.assign({}, result
|
|
391
|
+
transaction: Object.assign(Object.assign({}, result), { paidAt: new Date() }),
|
|
389
392
|
}));
|
|
390
393
|
return payment;
|
|
391
394
|
}
|
|
392
395
|
catch (error) {
|
|
396
|
+
console.log('Error PagarmeCardAPIAdapter', JSON.stringify(error));
|
|
393
397
|
throw new PaymentError('Seu pagamento com cartão não foi autorizado. Para não perder seus produtos, pague com PIX ou outro cartão de crédito', {
|
|
394
398
|
checkoutId: checkout.id,
|
|
395
399
|
userEmail: checkout.user.email,
|
|
@@ -507,7 +511,7 @@ class PagarmeCardAPIService {
|
|
|
507
511
|
}
|
|
508
512
|
}
|
|
509
513
|
|
|
510
|
-
class
|
|
514
|
+
class PagarmePixAPIAdapter {
|
|
511
515
|
constructor(credentials, paymentRepository) {
|
|
512
516
|
this.credentials = credentials;
|
|
513
517
|
this.paymentRepository = paymentRepository;
|
|
@@ -515,7 +519,8 @@ class PagarmePixAPIService {
|
|
|
515
519
|
async pay(checkout) {
|
|
516
520
|
try {
|
|
517
521
|
const client = await pagarme.client.connect({ api_key: this.credentials.API_KEY });
|
|
518
|
-
const result = client.transactions.create(Object.assign({}, this.createPixPayment(checkout)));
|
|
522
|
+
const result = await client.transactions.create(Object.assign({}, this.createPixPayment(checkout)));
|
|
523
|
+
console.log('result PagarmePixAPIAdapter', result);
|
|
519
524
|
const payment = await this.paymentRepository.create(Payment.toInstance({
|
|
520
525
|
createdAt: new Date(),
|
|
521
526
|
updatedAt: new Date(),
|
|
@@ -523,11 +528,12 @@ class PagarmePixAPIService {
|
|
|
523
528
|
checkoutId: checkout.id,
|
|
524
529
|
totalPrice: checkout.totalPrice,
|
|
525
530
|
paymentProvider: 'pagarMe',
|
|
526
|
-
transaction: Object.assign(Object.assign({}, result
|
|
531
|
+
transaction: Object.assign(Object.assign({}, result), { paidAt: new Date() }),
|
|
527
532
|
}));
|
|
528
533
|
return payment;
|
|
529
534
|
}
|
|
530
535
|
catch (error) {
|
|
536
|
+
console.log('Error PagarmePixAPIAdapter', JSON.stringify(error));
|
|
531
537
|
throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
|
|
532
538
|
checkoutId: checkout.id,
|
|
533
539
|
userEmail: checkout.user.email,
|
|
@@ -1002,7 +1008,10 @@ NestFirestoreModule = NestFirestoreModule_1 = __decorate([
|
|
|
1002
1008
|
'LegacyOrderRepository',
|
|
1003
1009
|
'ShopMenuRepository',
|
|
1004
1010
|
'OrderRepository',
|
|
1011
|
+
'OrderBlockedRepository',
|
|
1005
1012
|
'PaymentRepository',
|
|
1013
|
+
'SequenceRepository',
|
|
1014
|
+
'LogRepository',
|
|
1006
1015
|
ProductFirestoreRepository,
|
|
1007
1016
|
'ShopSettingsRepository',
|
|
1008
1017
|
'SubscriptionPaymentRepository',
|
|
@@ -1223,4 +1232,4 @@ NestConnectModule = NestConnectModule_1 = __decorate([
|
|
|
1223
1232
|
Module({})
|
|
1224
1233
|
], NestConnectModule);
|
|
1225
1234
|
|
|
1226
|
-
export { ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, DiscoveryEngineVertexAdapter, ES_CONFIG, FIREBASE_STORAGE, HASURA_OPTIONS, NativeElasticSearchAdapter, NestConnectModule, NestElasticSeachModule, NestFirestoreModule, NestHasuraGraphQLModule, NestStorageModule,
|
|
1235
|
+
export { ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, DiscoveryEngineVertexAdapter, ES_CONFIG, FIREBASE_STORAGE, HASURA_OPTIONS, NativeElasticSearchAdapter, NestConnectModule, NestElasticSeachModule, NestFirestoreModule, NestHasuraGraphQLModule, NestStorageModule, PagarmeBankSlipAPIAdapter, PagarmeCardAPIAdapter, PagarmePixAPIAdapter, ProductVertexHelper, VERTEX_CONFIG };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infrab4a/connect-nestjs",
|
|
3
|
-
"version": "1.8.0-beta.
|
|
3
|
+
"version": "1.8.0-beta.10",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org"
|
|
6
6
|
},
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"url": "https://github.com/B4AGroup/b4a-firebase-libs"
|
|
10
10
|
},
|
|
11
11
|
"peerDependencies": {
|
|
12
|
-
"@infrab4a/connect": "
|
|
12
|
+
"@infrab4a/connect": "4.20.0-beta.8",
|
|
13
13
|
"@nestjs/common": "^10.3.3",
|
|
14
14
|
"@nestjs/core": "^10.3.3",
|
|
15
15
|
"firebase-admin": "^12.0.0"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Checkout, PagarmeCredentials, Payment, PaymentProviderBankSlip, PaymentRepository, PaymentTransaction } from '@infrab4a/connect';
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class PagarmeBankSlipAPIAdapter implements PaymentProviderBankSlip {
|
|
3
3
|
private credentials;
|
|
4
4
|
private paymentRepository;
|
|
5
5
|
constructor(credentials: PagarmeCredentials, paymentRepository: PaymentRepository);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BusinessUnitEnum, CardInfo, Checkout, OrderBlockedRepository, PagarMeCard, PagarmeCredentials, Payment, PaymentCardInfo, PaymentProviderCard, PaymentRepository, PaymentTransaction } from '@infrab4a/connect';
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class PagarmeCardAPIAdapter implements PaymentProviderCard<PagarMeCard> {
|
|
3
3
|
private credentials;
|
|
4
4
|
private paymentRepository;
|
|
5
5
|
private orderBlockedRepository;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Checkout, PagarmeCredentials, Payment, PaymentProviderPix, PaymentRepository } from '@infrab4a/connect';
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class PagarmePixAPIAdapter implements PaymentProviderPix {
|
|
3
3
|
private credentials;
|
|
4
4
|
private paymentRepository;
|
|
5
5
|
constructor(credentials: PagarmeCredentials, paymentRepository: PaymentRepository);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './adapters';
|