@infrab4a/connect-nestjs 1.8.0-beta.4 → 1.8.0-beta.5
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 +10 -7
- package/index.esm.js +10 -7
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -304,11 +304,12 @@ class PagarmeBankSlipAPIAdapter {
|
|
|
304
304
|
try {
|
|
305
305
|
const client = await pagarme__default["default"].client.connect({ api_key: this.credentials.API_KEY });
|
|
306
306
|
const result = client.transactions.create(Object.assign({}, this.createBoletoPayment(checkout)));
|
|
307
|
-
|
|
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,7 +319,7 @@ class PagarmeBankSlipAPIAdapter {
|
|
|
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
|
}
|
|
@@ -378,12 +379,13 @@ class PagarmeCardAPIAdapter {
|
|
|
378
379
|
try {
|
|
379
380
|
const client = await pagarme__default["default"].client.connect({ api_key: this.credentials.API_KEY });
|
|
380
381
|
const result = client.transactions.create(Object.assign({}, this.createCardPayment(checkout, card)));
|
|
381
|
-
|
|
382
|
+
console.log('result PagarmeCardAPIAdapter', result);
|
|
383
|
+
if (result.status !== connect.PagarmePaymentStatus.Pago) {
|
|
382
384
|
await this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'Card not authorized', 'Card', 'day', card);
|
|
383
385
|
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
386
|
checkoutId: checkout.id,
|
|
385
387
|
userEmail: checkout.user.email,
|
|
386
|
-
info: result
|
|
388
|
+
info: result,
|
|
387
389
|
}));
|
|
388
390
|
}
|
|
389
391
|
const payment = await this.paymentRepository.create(connect.Payment.toInstance({
|
|
@@ -393,7 +395,7 @@ class PagarmeCardAPIAdapter {
|
|
|
393
395
|
checkoutId: checkout.id,
|
|
394
396
|
totalPrice: checkout.totalPrice,
|
|
395
397
|
paymentProvider: connect.PaymentProviders.PAGARME,
|
|
396
|
-
transaction: Object.assign(Object.assign({}, result
|
|
398
|
+
transaction: Object.assign(Object.assign({}, result), { paidAt: new Date() }),
|
|
397
399
|
}));
|
|
398
400
|
return payment;
|
|
399
401
|
}
|
|
@@ -524,6 +526,7 @@ class PagarmePixAPIAdapter {
|
|
|
524
526
|
try {
|
|
525
527
|
const client = await pagarme__default["default"].client.connect({ api_key: this.credentials.API_KEY });
|
|
526
528
|
const result = client.transactions.create(Object.assign({}, this.createPixPayment(checkout)));
|
|
529
|
+
console.log('result PagarmePixAPIAdapter', result);
|
|
527
530
|
const payment = await this.paymentRepository.create(connect.Payment.toInstance({
|
|
528
531
|
createdAt: new Date(),
|
|
529
532
|
updatedAt: new Date(),
|
|
@@ -531,7 +534,7 @@ class PagarmePixAPIAdapter {
|
|
|
531
534
|
checkoutId: checkout.id,
|
|
532
535
|
totalPrice: checkout.totalPrice,
|
|
533
536
|
paymentProvider: 'pagarMe',
|
|
534
|
-
transaction: Object.assign(Object.assign({}, result
|
|
537
|
+
transaction: Object.assign(Object.assign({}, result), { paidAt: new Date() }),
|
|
535
538
|
}));
|
|
536
539
|
return payment;
|
|
537
540
|
}
|
package/index.esm.js
CHANGED
|
@@ -296,11 +296,12 @@ class PagarmeBankSlipAPIAdapter {
|
|
|
296
296
|
try {
|
|
297
297
|
const client = await pagarme.client.connect({ api_key: this.credentials.API_KEY });
|
|
298
298
|
const result = client.transactions.create(Object.assign({}, this.createBoletoPayment(checkout)));
|
|
299
|
-
|
|
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,7 +311,7 @@ class PagarmeBankSlipAPIAdapter {
|
|
|
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
|
}
|
|
@@ -370,12 +371,13 @@ class PagarmeCardAPIAdapter {
|
|
|
370
371
|
try {
|
|
371
372
|
const client = await pagarme.client.connect({ api_key: this.credentials.API_KEY });
|
|
372
373
|
const result = client.transactions.create(Object.assign({}, this.createCardPayment(checkout, card)));
|
|
373
|
-
|
|
374
|
+
console.log('result PagarmeCardAPIAdapter', result);
|
|
375
|
+
if (result.status !== PagarmePaymentStatus.Pago) {
|
|
374
376
|
await this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'Card not authorized', 'Card', 'day', card);
|
|
375
377
|
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
378
|
checkoutId: checkout.id,
|
|
377
379
|
userEmail: checkout.user.email,
|
|
378
|
-
info: result
|
|
380
|
+
info: result,
|
|
379
381
|
}));
|
|
380
382
|
}
|
|
381
383
|
const payment = await this.paymentRepository.create(Payment.toInstance({
|
|
@@ -385,7 +387,7 @@ class PagarmeCardAPIAdapter {
|
|
|
385
387
|
checkoutId: checkout.id,
|
|
386
388
|
totalPrice: checkout.totalPrice,
|
|
387
389
|
paymentProvider: PaymentProviders.PAGARME,
|
|
388
|
-
transaction: Object.assign(Object.assign({}, result
|
|
390
|
+
transaction: Object.assign(Object.assign({}, result), { paidAt: new Date() }),
|
|
389
391
|
}));
|
|
390
392
|
return payment;
|
|
391
393
|
}
|
|
@@ -516,6 +518,7 @@ class PagarmePixAPIAdapter {
|
|
|
516
518
|
try {
|
|
517
519
|
const client = await pagarme.client.connect({ api_key: this.credentials.API_KEY });
|
|
518
520
|
const result = client.transactions.create(Object.assign({}, this.createPixPayment(checkout)));
|
|
521
|
+
console.log('result PagarmePixAPIAdapter', result);
|
|
519
522
|
const payment = await this.paymentRepository.create(Payment.toInstance({
|
|
520
523
|
createdAt: new Date(),
|
|
521
524
|
updatedAt: new Date(),
|
|
@@ -523,7 +526,7 @@ class PagarmePixAPIAdapter {
|
|
|
523
526
|
checkoutId: checkout.id,
|
|
524
527
|
totalPrice: checkout.totalPrice,
|
|
525
528
|
paymentProvider: 'pagarMe',
|
|
526
|
-
transaction: Object.assign(Object.assign({}, result
|
|
529
|
+
transaction: Object.assign(Object.assign({}, result), { paidAt: new Date() }),
|
|
527
530
|
}));
|
|
528
531
|
return payment;
|
|
529
532
|
}
|