@infrab4a/connect 5.3.1-beta.2 → 5.3.1
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 +671 -6
- package/index.esm.js +669 -7
- package/package.json +1 -1
- package/src/domain/catalog/models/product-base.d.ts +3 -1
- package/src/domain/catalog/models/types/brands-shop-menu.type.d.ts +13 -0
- package/src/domain/catalog/models/types/index.d.ts +1 -0
- package/src/domain/catalog/repositories/category.repository.d.ts +1 -0
- package/src/domain/catalog/repositories/product.repository.d.ts +3 -0
- package/src/domain/catalog/repositories/variant.repository.d.ts +1 -0
- package/src/domain/shopping/enums/index.d.ts +2 -0
- package/src/domain/shopping/enums/pagarme-v5-payment-status.enum.d.ts +24 -0
- package/src/domain/shopping/enums/transaction-payment-methods.enum.d.ts +5 -0
- package/src/domain/shopping/interfaces/payment-provider-card.interface.d.ts +10 -2
- package/src/domain/shopping/models/enums/order-status.enum.d.ts +1 -1
- package/src/domain/shopping/models/payment-transaction.d.ts +17 -2
- package/src/domain/shopping/models/payment.d.ts +2 -1
- package/src/domain/shopping/types/card-info.type.d.ts +1 -0
- package/src/domain/shopping/types/index.d.ts +1 -0
- package/src/domain/shopping/types/pagarme-card.type.d.ts +9 -3
- package/src/domain/shopping/types/pagarme-credentials-v5.type.d.ts +4 -0
- package/src/domain/shopping/types/pagarme-credentials.type.d.ts +9 -3
- package/src/domain/users/models/user-payment-method.d.ts +2 -0
- package/src/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +1 -0
- package/src/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +4 -1
- package/src/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.d.ts +1 -0
- package/src/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +1 -0
- package/src/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +3 -0
- package/src/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.d.ts +1 -0
- package/src/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.d.ts +1 -0
- package/src/infra/pagarme/adapters/helpers/index.d.ts +2 -0
- package/src/infra/pagarme/adapters/helpers/pagarme-v5-request.helper.d.ts +12 -0
- package/src/infra/pagarme/adapters/helpers/pagarme-v5-response.helper.d.ts +10 -0
- package/src/infra/pagarme/adapters/index.d.ts +2 -3
- package/src/infra/pagarme/adapters/v4/index.d.ts +3 -0
- package/src/infra/pagarme/adapters/{pagarme-bank-slip-payment-axios.adapter.d.ts → v4/pagarme-bank-slip-payment-axios.adapter.d.ts} +4 -4
- package/src/infra/pagarme/adapters/{pagarme-card-payment-axios.adapter.d.ts → v4/pagarme-card-payment-axios.adapter.d.ts} +7 -6
- package/src/infra/pagarme/adapters/v4/pagarme-pix-payment-axios.adapter.d.ts +11 -0
- package/src/infra/pagarme/adapters/v5/index.d.ts +3 -0
- package/src/infra/pagarme/adapters/v5/pagarmev5-bank-slip-payment-axios.adapter.d.ts +11 -0
- package/src/infra/pagarme/adapters/v5/pagarmev5-card-payment-axios.adapter.d.ts +24 -0
- package/src/infra/pagarme/adapters/v5/pagarmev5-pix-payment-axios.adapter.d.ts +10 -0
- package/src/infra/pagarme/index.d.ts +1 -0
- package/src/infra/pagarme/types/index.d.ts +1 -0
- package/src/infra/pagarme/types/v5/index.d.ts +4 -0
- package/src/infra/pagarme/types/v5/pagarmev5-customer.type.d.ts +19 -0
- package/src/infra/pagarme/types/v5/pagarmev5-order-request-payload.type.d.ts +89 -0
- package/src/infra/pagarme/types/v5/pagarmev5-order-response.type.d.ts +126 -0
- package/src/infra/pagarme/types/v5/pagarmev5-postback-response.type.d.ts +11 -0
- package/src/infra/pagarme/adapters/pagarme-pix-payment-axios.adapter.d.ts +0 -11
package/index.esm.js
CHANGED
|
@@ -48,6 +48,33 @@ var PagarmePaymentStatus;
|
|
|
48
48
|
PagarmePaymentStatus["Chargedback"] = "chargedback";
|
|
49
49
|
})(PagarmePaymentStatus || (PagarmePaymentStatus = {}));
|
|
50
50
|
|
|
51
|
+
var PagarMeV5PaymentStatus;
|
|
52
|
+
(function (PagarMeV5PaymentStatus) {
|
|
53
|
+
PagarMeV5PaymentStatus["Em processamento"] = "processing";
|
|
54
|
+
PagarMeV5PaymentStatus["Gerado"] = "generated";
|
|
55
|
+
PagarMeV5PaymentStatus["Visualizado"] = "viewed";
|
|
56
|
+
PagarMeV5PaymentStatus["Pago a menor"] = "underpaid";
|
|
57
|
+
PagarMeV5PaymentStatus["Pago a maior"] = "overpaid";
|
|
58
|
+
PagarMeV5PaymentStatus["Aguardando pagamento"] = "waiting_payment";
|
|
59
|
+
PagarMeV5PaymentStatus["Pago"] = "paid";
|
|
60
|
+
PagarMeV5PaymentStatus["Aguardando estorno"] = "pending_refund";
|
|
61
|
+
PagarMeV5PaymentStatus["Autorizada pendente de captura"] = "authorized_pending_capture";
|
|
62
|
+
PagarMeV5PaymentStatus["N\u00E3o autorizada"] = "not_authorized";
|
|
63
|
+
PagarMeV5PaymentStatus["Capturada"] = "captured";
|
|
64
|
+
PagarMeV5PaymentStatus["Aguardando captura"] = "waiting_capture";
|
|
65
|
+
PagarMeV5PaymentStatus["Com erro"] = "with_error";
|
|
66
|
+
PagarMeV5PaymentStatus["Estornado"] = "refunded";
|
|
67
|
+
PagarMeV5PaymentStatus["Cancelado"] = "voided";
|
|
68
|
+
PagarMeV5PaymentStatus["Falha"] = "failed";
|
|
69
|
+
})(PagarMeV5PaymentStatus || (PagarMeV5PaymentStatus = {}));
|
|
70
|
+
var PagarMeV5OrderStatus;
|
|
71
|
+
(function (PagarMeV5OrderStatus) {
|
|
72
|
+
PagarMeV5OrderStatus["Pendente"] = "pending";
|
|
73
|
+
PagarMeV5OrderStatus["Pago"] = "paid";
|
|
74
|
+
PagarMeV5OrderStatus["Cancelado"] = "canceled";
|
|
75
|
+
PagarMeV5OrderStatus["Falha"] = "failed";
|
|
76
|
+
})(PagarMeV5OrderStatus || (PagarMeV5OrderStatus = {}));
|
|
77
|
+
|
|
51
78
|
var PaymentMethods;
|
|
52
79
|
(function (PaymentMethods) {
|
|
53
80
|
PaymentMethods["CARD"] = "card";
|
|
@@ -63,6 +90,13 @@ var PaymentProviders;
|
|
|
63
90
|
PaymentProviders["GLAMPOINTS"] = "glampoints";
|
|
64
91
|
})(PaymentProviders || (PaymentProviders = {}));
|
|
65
92
|
|
|
93
|
+
var TransactionPaymentMethods;
|
|
94
|
+
(function (TransactionPaymentMethods) {
|
|
95
|
+
TransactionPaymentMethods["CARD"] = "credit_card";
|
|
96
|
+
TransactionPaymentMethods["BANKSLIP"] = "boleto";
|
|
97
|
+
TransactionPaymentMethods["PIX"] = "pix";
|
|
98
|
+
})(TransactionPaymentMethods || (TransactionPaymentMethods = {}));
|
|
99
|
+
|
|
66
100
|
class BasePaymentMethodFactory {
|
|
67
101
|
constructor(methods) {
|
|
68
102
|
this.methods = methods;
|
|
@@ -1567,7 +1601,7 @@ var OrderStatus;
|
|
|
1567
1601
|
OrderStatus["ENVIADO"] = "Enviado";
|
|
1568
1602
|
OrderStatus["ENTREGUE"] = "Entregue";
|
|
1569
1603
|
OrderStatus["CANCELADO"] = "Cancelado";
|
|
1570
|
-
OrderStatus["
|
|
1604
|
+
OrderStatus["PENDENTE_REENVIO"] = "Pendente reenvio";
|
|
1571
1605
|
})(OrderStatus || (OrderStatus = {}));
|
|
1572
1606
|
|
|
1573
1607
|
class Order extends Checkout {
|
|
@@ -4776,6 +4810,9 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
4776
4810
|
isChild(_id, _parentId) {
|
|
4777
4811
|
return;
|
|
4778
4812
|
}
|
|
4813
|
+
async getBrandsWithProducts() {
|
|
4814
|
+
return;
|
|
4815
|
+
}
|
|
4779
4816
|
}
|
|
4780
4817
|
__decorate([
|
|
4781
4818
|
Log(),
|
|
@@ -4866,6 +4903,9 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
|
|
|
4866
4903
|
productVariantFullReport() {
|
|
4867
4904
|
return;
|
|
4868
4905
|
}
|
|
4906
|
+
getByEAN(EAN, options) {
|
|
4907
|
+
return;
|
|
4908
|
+
}
|
|
4869
4909
|
}
|
|
4870
4910
|
__decorate([
|
|
4871
4911
|
Log(),
|
|
@@ -4891,6 +4931,9 @@ class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirest
|
|
|
4891
4931
|
});
|
|
4892
4932
|
this.parentRepository = parentRepository;
|
|
4893
4933
|
}
|
|
4934
|
+
getByEAN(EAN) {
|
|
4935
|
+
return;
|
|
4936
|
+
}
|
|
4894
4937
|
}
|
|
4895
4938
|
|
|
4896
4939
|
class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
@@ -6127,7 +6170,8 @@ class CategoryProductOperationsHelper {
|
|
|
6127
6170
|
'isKit',
|
|
6128
6171
|
'sku',
|
|
6129
6172
|
'rate',
|
|
6130
|
-
'
|
|
6173
|
+
'tagsProfile',
|
|
6174
|
+
'tagsCollection',
|
|
6131
6175
|
'type',
|
|
6132
6176
|
'shoppingCount',
|
|
6133
6177
|
'gender',
|
|
@@ -6867,6 +6911,19 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6867
6911
|
categoryFilterRepository: this.categoryFilterRepository,
|
|
6868
6912
|
});
|
|
6869
6913
|
}
|
|
6914
|
+
async getBrandsWithProducts() {
|
|
6915
|
+
const fields = ['id', 'name', 'slug', 'brand_category', 'published', 'images'];
|
|
6916
|
+
const { brands_with_products_query: data, } = await this.query('brands_with_products_query', fields);
|
|
6917
|
+
return data.map((brand) => Category.toInstance({
|
|
6918
|
+
id: brand.id,
|
|
6919
|
+
name: brand.name,
|
|
6920
|
+
slug: brand.slug,
|
|
6921
|
+
brandCategory: brand.brand_category,
|
|
6922
|
+
shops: brand.shops,
|
|
6923
|
+
published: brand.published,
|
|
6924
|
+
images: brand.images,
|
|
6925
|
+
}));
|
|
6926
|
+
}
|
|
6870
6927
|
}
|
|
6871
6928
|
__decorate([
|
|
6872
6929
|
Log(),
|
|
@@ -7348,7 +7405,6 @@ const commonFields = [
|
|
|
7348
7405
|
'weight',
|
|
7349
7406
|
'gender',
|
|
7350
7407
|
{ intGender: { columnName: 'int_gender' } },
|
|
7351
|
-
{ tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
|
|
7352
7408
|
{ filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
|
|
7353
7409
|
{ isKit: { columnName: 'is_kit' } },
|
|
7354
7410
|
{ createdAt: { columnName: 'created_at' } },
|
|
@@ -7366,6 +7422,9 @@ const commonFields = [
|
|
|
7366
7422
|
},
|
|
7367
7423
|
'group',
|
|
7368
7424
|
'validity',
|
|
7425
|
+
{ tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
|
|
7426
|
+
{ tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
|
|
7427
|
+
{ daysOfUse: { columnName: 'days_of_use' } },
|
|
7369
7428
|
];
|
|
7370
7429
|
const fieldsConfiguration$2 = [
|
|
7371
7430
|
...commonFields,
|
|
@@ -7423,6 +7482,74 @@ const fieldsConfiguration$2 = [
|
|
|
7423
7482
|
}),
|
|
7424
7483
|
},
|
|
7425
7484
|
},
|
|
7485
|
+
{
|
|
7486
|
+
variants: {
|
|
7487
|
+
columnName: 'variants',
|
|
7488
|
+
foreignKeyColumn: { product_id: 'id' },
|
|
7489
|
+
fields: [
|
|
7490
|
+
'id',
|
|
7491
|
+
'ean',
|
|
7492
|
+
{
|
|
7493
|
+
grade: {
|
|
7494
|
+
columnName: 'grade',
|
|
7495
|
+
type: HasuraGraphQLColumnType.Jsonb,
|
|
7496
|
+
},
|
|
7497
|
+
},
|
|
7498
|
+
{
|
|
7499
|
+
price: {
|
|
7500
|
+
columnName: 'price',
|
|
7501
|
+
from: (price, data) => ({
|
|
7502
|
+
price,
|
|
7503
|
+
fullPrice: data.full_price,
|
|
7504
|
+
subscriberDiscountPercentage: data.subscriber_discount_percentage,
|
|
7505
|
+
subscriberPrice: data.subscriber_price,
|
|
7506
|
+
fullPriceDiscountPercentage: data.full_price_discount_percentage,
|
|
7507
|
+
}),
|
|
7508
|
+
bindFindFilter: (sentence) => {
|
|
7509
|
+
const filters = Object.values(sentence).shift();
|
|
7510
|
+
return {
|
|
7511
|
+
...((filters?.price || filters?.price === 0) && { price: filters.price }),
|
|
7512
|
+
...((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice }),
|
|
7513
|
+
...((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
|
|
7514
|
+
subscriber_discount_percentage: filters.subscriberDiscountPercentage,
|
|
7515
|
+
}),
|
|
7516
|
+
...((filters.subscriberPrice || filters.subscriberPrice === 0) && {
|
|
7517
|
+
subscriber_price: filters.subscriberPrice,
|
|
7518
|
+
}),
|
|
7519
|
+
...((filters.fullPriceDiscountPercentage || filters.fullPriceDiscountPercentage === 0) && {
|
|
7520
|
+
full_price_discount_percentage: filters.fullPriceDiscountPercentage,
|
|
7521
|
+
}),
|
|
7522
|
+
};
|
|
7523
|
+
},
|
|
7524
|
+
bindPersistData: (priceData) => ({
|
|
7525
|
+
...((priceData?.price || 0) >= 0 && { price: priceData.price }),
|
|
7526
|
+
...((priceData?.fullPrice || 0) >= 0 && { full_price: priceData.fullPrice }),
|
|
7527
|
+
...((priceData?.subscriberDiscountPercentage || 0) >= 0 && {
|
|
7528
|
+
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
7529
|
+
}),
|
|
7530
|
+
...((priceData?.subscriberPrice || 0) >= 0 && { subscriber_price: priceData.subscriberPrice }),
|
|
7531
|
+
...(priceData.fullPriceDiscountPercentage >= 0 && {
|
|
7532
|
+
full_price_discount_percentage: priceData.fullPriceDiscountPercentage,
|
|
7533
|
+
}),
|
|
7534
|
+
}),
|
|
7535
|
+
},
|
|
7536
|
+
},
|
|
7537
|
+
'published',
|
|
7538
|
+
{
|
|
7539
|
+
stock: {
|
|
7540
|
+
columnName: 'stock',
|
|
7541
|
+
from: (quantity) => ({ quantity }),
|
|
7542
|
+
to: (value) => (isNil(value?.quantity) ? value : value?.quantity),
|
|
7543
|
+
},
|
|
7544
|
+
},
|
|
7545
|
+
'description',
|
|
7546
|
+
'images',
|
|
7547
|
+
'miniatures',
|
|
7548
|
+
{ tagsProfile: { columnName: 'tags_profile' } },
|
|
7549
|
+
{ tagsCollection: { columnName: 'tags_collection' } },
|
|
7550
|
+
],
|
|
7551
|
+
},
|
|
7552
|
+
},
|
|
7426
7553
|
];
|
|
7427
7554
|
class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
7428
7555
|
get reviewsFields() {
|
|
@@ -7548,6 +7675,39 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
7548
7675
|
}
|
|
7549
7676
|
return product;
|
|
7550
7677
|
}
|
|
7678
|
+
async getByEAN(EAN, options) {
|
|
7679
|
+
if (this.cache?.cacheAdapter && options?.cache?.enabled) {
|
|
7680
|
+
const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
|
|
7681
|
+
const cachedData = await this.cache.cacheAdapter.get(cacheKey);
|
|
7682
|
+
if (cachedData) {
|
|
7683
|
+
this.logger.log(`Dados recuperados do cache: ${cacheKey}`);
|
|
7684
|
+
return this.model.toInstance(deserialize(cachedData));
|
|
7685
|
+
}
|
|
7686
|
+
}
|
|
7687
|
+
const result = await this.find({
|
|
7688
|
+
filters: {
|
|
7689
|
+
EAN,
|
|
7690
|
+
},
|
|
7691
|
+
fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
|
|
7692
|
+
options: {
|
|
7693
|
+
enableCount: false,
|
|
7694
|
+
},
|
|
7695
|
+
});
|
|
7696
|
+
if (!result.data.length)
|
|
7697
|
+
return null;
|
|
7698
|
+
const product = result?.data?.shift();
|
|
7699
|
+
RoundProductPricesHelper.roundProductPrices(product);
|
|
7700
|
+
if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
|
|
7701
|
+
const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
|
|
7702
|
+
await this.cache.cacheAdapter.set({
|
|
7703
|
+
key: cacheKey,
|
|
7704
|
+
data: serialize(product),
|
|
7705
|
+
expirationInSeconds: options?.cache?.ttl || this.cache.ttlDefault,
|
|
7706
|
+
});
|
|
7707
|
+
this.logger.log(`Dados salvos no cache: ${cacheKey}`);
|
|
7708
|
+
}
|
|
7709
|
+
return product;
|
|
7710
|
+
}
|
|
7551
7711
|
async update(params) {
|
|
7552
7712
|
const { kitProducts, reviews, id: checkId, metadata, ...data } = omit(params, ['categories', 'rate']);
|
|
7553
7713
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
@@ -7792,6 +7952,12 @@ __decorate([
|
|
|
7792
7952
|
__metadata("design:paramtypes", [String, Object]),
|
|
7793
7953
|
__metadata("design:returntype", Promise)
|
|
7794
7954
|
], ProductHasuraGraphQLRepository.prototype, "getBySlug", null);
|
|
7955
|
+
__decorate([
|
|
7956
|
+
Log(),
|
|
7957
|
+
__metadata("design:type", Function),
|
|
7958
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
7959
|
+
__metadata("design:returntype", Promise)
|
|
7960
|
+
], ProductHasuraGraphQLRepository.prototype, "getByEAN", null);
|
|
7795
7961
|
__decorate([
|
|
7796
7962
|
Log(),
|
|
7797
7963
|
__metadata("design:type", Function),
|
|
@@ -7847,6 +8013,13 @@ class ProductReviewHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHas
|
|
|
7847
8013
|
{ orderId: { columnName: 'order_id' } },
|
|
7848
8014
|
{ createdAt: { columnName: 'created_at' } },
|
|
7849
8015
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
8016
|
+
{
|
|
8017
|
+
product: {
|
|
8018
|
+
columnName: 'product',
|
|
8019
|
+
foreignKeyColumn: { id: 'productId' },
|
|
8020
|
+
fields: ['id', 'ean', 'sku', 'name', 'brand', 'slug', 'images', 'grade', 'gender'],
|
|
8021
|
+
},
|
|
8022
|
+
},
|
|
7850
8023
|
],
|
|
7851
8024
|
cache,
|
|
7852
8025
|
});
|
|
@@ -8038,8 +8211,12 @@ const fieldsConfiguration$1 = [
|
|
|
8038
8211
|
},
|
|
8039
8212
|
'group',
|
|
8040
8213
|
'validity',
|
|
8041
|
-
{ tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
|
|
8042
8214
|
'published',
|
|
8215
|
+
{ tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
|
|
8216
|
+
{ tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
|
|
8217
|
+
{ daysOfUse: { columnName: 'days_of_use' } },
|
|
8218
|
+
'images',
|
|
8219
|
+
'miniatures',
|
|
8043
8220
|
];
|
|
8044
8221
|
class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
8045
8222
|
constructor({ endpoint, authOptions, interceptors, cache, }) {
|
|
@@ -8068,6 +8245,17 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
8068
8245
|
const { filters, ...options } = params || {};
|
|
8069
8246
|
return super.find({ ...options, filters: { productId: { operator: Where.ISNOTNULL }, ...filters } });
|
|
8070
8247
|
}
|
|
8248
|
+
async getByEAN(EAN) {
|
|
8249
|
+
const { data } = await this.find({
|
|
8250
|
+
filters: {
|
|
8251
|
+
EAN,
|
|
8252
|
+
},
|
|
8253
|
+
options: {
|
|
8254
|
+
enableCount: false,
|
|
8255
|
+
},
|
|
8256
|
+
});
|
|
8257
|
+
return data.at(0);
|
|
8258
|
+
}
|
|
8071
8259
|
async update(params) {
|
|
8072
8260
|
const { productId, id: checkId, ...data } = params;
|
|
8073
8261
|
const dataWithProductId = this.paramsToPlain({ id: checkId, productId });
|
|
@@ -8395,6 +8583,9 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
8395
8583
|
productId: +productId,
|
|
8396
8584
|
});
|
|
8397
8585
|
}
|
|
8586
|
+
async getBrandsWithProducts() {
|
|
8587
|
+
return;
|
|
8588
|
+
}
|
|
8398
8589
|
}
|
|
8399
8590
|
__decorate([
|
|
8400
8591
|
Log(),
|
|
@@ -8561,6 +8752,201 @@ class PagarmePaymentOperationsHelper {
|
|
|
8561
8752
|
}
|
|
8562
8753
|
}
|
|
8563
8754
|
|
|
8755
|
+
class PagarMeV5RequestHelper {
|
|
8756
|
+
static build(checkout, method, card) {
|
|
8757
|
+
return {
|
|
8758
|
+
items: this.buildItems(checkout),
|
|
8759
|
+
customer: this.buildCustomer(checkout),
|
|
8760
|
+
shipping: this.buildShipping(checkout),
|
|
8761
|
+
payments: this.buildPayment(checkout, method, card),
|
|
8762
|
+
};
|
|
8763
|
+
}
|
|
8764
|
+
static buildItems(checkout) {
|
|
8765
|
+
return checkout.lineItems
|
|
8766
|
+
.filter((item) => !item.isGift)
|
|
8767
|
+
.map((item) => {
|
|
8768
|
+
return {
|
|
8769
|
+
amount: Math.floor(item.pricePaid * 100),
|
|
8770
|
+
description: item.name,
|
|
8771
|
+
quantity: item.quantity,
|
|
8772
|
+
code: item.EAN,
|
|
8773
|
+
};
|
|
8774
|
+
});
|
|
8775
|
+
}
|
|
8776
|
+
static buildCustomer(checkout) {
|
|
8777
|
+
return {
|
|
8778
|
+
name: checkout.user.displayName,
|
|
8779
|
+
email: checkout.user.email,
|
|
8780
|
+
type: 'individual',
|
|
8781
|
+
document: checkout.user.cpf,
|
|
8782
|
+
phones: {
|
|
8783
|
+
home_phone: {
|
|
8784
|
+
country_code: '55',
|
|
8785
|
+
number: checkout.user.phone.slice(2),
|
|
8786
|
+
area_code: checkout.user.phone.slice(0, 2),
|
|
8787
|
+
},
|
|
8788
|
+
mobile_phone: {
|
|
8789
|
+
country_code: '55',
|
|
8790
|
+
number: checkout.user.phone.slice(2),
|
|
8791
|
+
area_code: checkout.user.phone.slice(0, 2),
|
|
8792
|
+
},
|
|
8793
|
+
},
|
|
8794
|
+
address: {
|
|
8795
|
+
line_1: `${checkout.billingAddress.number}, ${checkout.billingAddress.street}, ${checkout.billingAddress.district}`,
|
|
8796
|
+
line_2: `${checkout.billingAddress.extension}`,
|
|
8797
|
+
zip_code: checkout.shippingAddress.zip,
|
|
8798
|
+
city: checkout.billingAddress.city,
|
|
8799
|
+
state: checkout.billingAddress.state,
|
|
8800
|
+
country: 'BR',
|
|
8801
|
+
},
|
|
8802
|
+
};
|
|
8803
|
+
}
|
|
8804
|
+
static buildShipping(checkout) {
|
|
8805
|
+
return {
|
|
8806
|
+
amount: Math.floor(checkout.shipping.ShippingPrice * 100),
|
|
8807
|
+
description: `${checkout.shipping.ShippingCompanyName} - ${checkout.shipping.description}`,
|
|
8808
|
+
recipient_name: checkout.shippingAddress.recipient,
|
|
8809
|
+
recipient_phone: checkout.user.phone,
|
|
8810
|
+
address: {
|
|
8811
|
+
line_1: `${checkout.shippingAddress.number}, ${checkout.shippingAddress.street}, ${checkout.shippingAddress.district}`,
|
|
8812
|
+
line_2: `${checkout.shippingAddress.extension}`,
|
|
8813
|
+
zip_code: checkout.shippingAddress.zip,
|
|
8814
|
+
city: checkout.shippingAddress.city,
|
|
8815
|
+
state: checkout.shippingAddress.state,
|
|
8816
|
+
country: 'BR',
|
|
8817
|
+
},
|
|
8818
|
+
};
|
|
8819
|
+
}
|
|
8820
|
+
static buildPayment(checkout, method, card) {
|
|
8821
|
+
return [
|
|
8822
|
+
{
|
|
8823
|
+
payment_method: method,
|
|
8824
|
+
amount: Math.floor(checkout.totalPrice * 100),
|
|
8825
|
+
...(method === 'pix' && {
|
|
8826
|
+
pix: this.getPixOrder(),
|
|
8827
|
+
}),
|
|
8828
|
+
...(method === 'boleto' && {
|
|
8829
|
+
boleto: this.getBoletoOrder(),
|
|
8830
|
+
}),
|
|
8831
|
+
...(method === 'credit_card' && {
|
|
8832
|
+
credit_card: this.getCardOrder(checkout, card),
|
|
8833
|
+
}),
|
|
8834
|
+
},
|
|
8835
|
+
];
|
|
8836
|
+
}
|
|
8837
|
+
static getPixOrder() {
|
|
8838
|
+
return {
|
|
8839
|
+
expires_at: format(addDays(new Date(), 1), 'yyyy-MM-dd'),
|
|
8840
|
+
};
|
|
8841
|
+
}
|
|
8842
|
+
static getBoletoOrder() {
|
|
8843
|
+
return {
|
|
8844
|
+
due_at: format(addDays(new Date(), 3), 'yyyy-MM-dd'),
|
|
8845
|
+
instructions: 'Sr. Caixa, NÃO aceitar o pagamento após o vencimento.',
|
|
8846
|
+
type: 'DM',
|
|
8847
|
+
document_number: new Date().getTime().toString(),
|
|
8848
|
+
};
|
|
8849
|
+
}
|
|
8850
|
+
static getCardOrder(checkout, card) {
|
|
8851
|
+
return {
|
|
8852
|
+
installments: card.installments,
|
|
8853
|
+
statement_descriptor: checkout.shop === Shops.GLAMSHOP ? 'Glam' : 'Mens Market',
|
|
8854
|
+
card_id: card.cardId,
|
|
8855
|
+
card: {
|
|
8856
|
+
cvv: card.cardCvv,
|
|
8857
|
+
billing_address: {
|
|
8858
|
+
line_1: `${checkout.billingAddress.number}, ${checkout.billingAddress.street}, ${checkout.billingAddress.district}`,
|
|
8859
|
+
zip_code: checkout.billingAddress.zip,
|
|
8860
|
+
city: checkout.billingAddress.city,
|
|
8861
|
+
state: checkout.billingAddress.state,
|
|
8862
|
+
country: 'BR',
|
|
8863
|
+
},
|
|
8864
|
+
},
|
|
8865
|
+
};
|
|
8866
|
+
}
|
|
8867
|
+
}
|
|
8868
|
+
|
|
8869
|
+
class PagarMeV5ResponseHelper {
|
|
8870
|
+
static build(method, checkout, response) {
|
|
8871
|
+
return Payment.toInstance({
|
|
8872
|
+
createdAt: new Date(),
|
|
8873
|
+
updatedAt: new Date(),
|
|
8874
|
+
userId: checkout.user.id,
|
|
8875
|
+
checkoutId: checkout.id,
|
|
8876
|
+
totalPrice: checkout.totalPrice,
|
|
8877
|
+
paymentProvider: PaymentProviders.PAGARME,
|
|
8878
|
+
pagarMeOrderId: response.id,
|
|
8879
|
+
transaction: this.buildPaymentTransaction(method, response),
|
|
8880
|
+
});
|
|
8881
|
+
}
|
|
8882
|
+
static buildPaymentTransaction(method, response) {
|
|
8883
|
+
const charger = response.charges.at(0);
|
|
8884
|
+
const transaction = charger.last_transaction;
|
|
8885
|
+
return PaymentTransaction.toInstance({
|
|
8886
|
+
acquirer_name: 'pagar_me',
|
|
8887
|
+
amount: charger.amount,
|
|
8888
|
+
currency: charger.currency,
|
|
8889
|
+
gateway_id: charger.gateway_id,
|
|
8890
|
+
status: this.getPaymentStatus(transaction.status),
|
|
8891
|
+
payment_method: charger.payment_method,
|
|
8892
|
+
date_created: charger.created_at,
|
|
8893
|
+
date_updated: charger.updated_at,
|
|
8894
|
+
paid_amount: charger.paid_amount,
|
|
8895
|
+
paid_at: charger.paid_at,
|
|
8896
|
+
order_id: response.id,
|
|
8897
|
+
charger_id: charger.id,
|
|
8898
|
+
tid: charger.id,
|
|
8899
|
+
id: charger.id,
|
|
8900
|
+
...(method == TransactionPaymentMethods.BANKSLIP && this.getBoletoReponse(transaction)),
|
|
8901
|
+
...(method == TransactionPaymentMethods.PIX && this.getPixReponse(transaction)),
|
|
8902
|
+
...(method == TransactionPaymentMethods.CARD && this.getCardReponse(transaction)),
|
|
8903
|
+
});
|
|
8904
|
+
}
|
|
8905
|
+
static getPaymentStatus(status) {
|
|
8906
|
+
if (status == PagarMeV5PaymentStatus.Gerado)
|
|
8907
|
+
return PagarMeV5PaymentStatus['Aguardando pagamento'];
|
|
8908
|
+
if (status == PagarMeV5PaymentStatus.Capturada)
|
|
8909
|
+
return PagarMeV5PaymentStatus.Pago;
|
|
8910
|
+
return status;
|
|
8911
|
+
}
|
|
8912
|
+
static getBoletoReponse(transaction) {
|
|
8913
|
+
return {
|
|
8914
|
+
boleto_url: transaction.url?.toString(),
|
|
8915
|
+
boleto_barcode: transaction.line?.toString(),
|
|
8916
|
+
boleto_qr_code: transaction.qr_code?.toString(),
|
|
8917
|
+
boleto_expiration_date: transaction.due_at?.toString(),
|
|
8918
|
+
boleto_instructions: transaction.instructions?.toString(),
|
|
8919
|
+
boleto_nosso_numero: transaction.nosso_numero?.toString(),
|
|
8920
|
+
boleto_type: transaction.type?.toString(),
|
|
8921
|
+
boleto_document_number: transaction.document_number?.toString(),
|
|
8922
|
+
};
|
|
8923
|
+
}
|
|
8924
|
+
static getPixReponse(transaction) {
|
|
8925
|
+
return {
|
|
8926
|
+
pix_qr_code: transaction.qr_code?.toString(),
|
|
8927
|
+
pix_qr_code_url: transaction.qr_code_url?.toString(),
|
|
8928
|
+
pix_expiration_date: transaction.expires_at?.toString(),
|
|
8929
|
+
};
|
|
8930
|
+
}
|
|
8931
|
+
static getCardReponse(transaction) {
|
|
8932
|
+
return {
|
|
8933
|
+
soft_descriptor: transaction.statement_descriptor?.toString(),
|
|
8934
|
+
acquirer_name: transaction.acquirer_name?.toString(),
|
|
8935
|
+
acquirer_id: transaction.acquirer_tid?.toString(),
|
|
8936
|
+
acquirer_nsu: transaction.acquirer_nsu?.toString(),
|
|
8937
|
+
acquirer_auth_code: transaction.acquirer_auth_code?.toString(),
|
|
8938
|
+
acquirer_message: transaction.acquirer_message?.toString(),
|
|
8939
|
+
acquirer_return_code: transaction.acquirer_return_code?.toString(),
|
|
8940
|
+
installments: transaction.installments ?? null,
|
|
8941
|
+
card_holder_name: transaction.card?.holder_name?.toString(),
|
|
8942
|
+
card_last_digits: transaction.card?.last_four_digits?.toString(),
|
|
8943
|
+
card_first_digits: transaction.card?.first_six_digits?.toString(),
|
|
8944
|
+
card_brand: transaction.card?.brand?.toString(),
|
|
8945
|
+
card_id: transaction.card?.id?.toString(),
|
|
8946
|
+
};
|
|
8947
|
+
}
|
|
8948
|
+
}
|
|
8949
|
+
|
|
8564
8950
|
class PagarmeCardAxiosAdapter {
|
|
8565
8951
|
constructor(credentials, paymentRepository, orderBlockedRepository) {
|
|
8566
8952
|
this.credentials = credentials;
|
|
@@ -8617,8 +9003,9 @@ class PagarmeCardAxiosAdapter {
|
|
|
8617
9003
|
});
|
|
8618
9004
|
}
|
|
8619
9005
|
}
|
|
8620
|
-
async createCardHash(bu) {
|
|
8621
|
-
const
|
|
9006
|
+
async createCardHash(bu, shop) {
|
|
9007
|
+
const credentials = shop && shop == Shops.MENSMARKET ? this.credentials[Shops.MENSMARKET] : this.credentials[Shops.GLAMSHOP];
|
|
9008
|
+
const key = bu === BusinessUnitEnum.SHOP ? credentials.SHOP_API_KEY : credentials.SUBSCRIPTION_API_KEY;
|
|
8622
9009
|
try {
|
|
8623
9010
|
const { data } = await axios({
|
|
8624
9011
|
method: 'GET',
|
|
@@ -8781,6 +9168,281 @@ class PagarmePixAxiosAdapter {
|
|
|
8781
9168
|
}
|
|
8782
9169
|
}
|
|
8783
9170
|
|
|
9171
|
+
class PagarmeV5BankSlipAxiosAdapter {
|
|
9172
|
+
constructor(credentials, paymentRepository) {
|
|
9173
|
+
this.credentials = credentials;
|
|
9174
|
+
this.paymentRepository = paymentRepository;
|
|
9175
|
+
}
|
|
9176
|
+
async pay(checkout) {
|
|
9177
|
+
try {
|
|
9178
|
+
const payload = PagarMeV5RequestHelper.build(checkout, 'boleto');
|
|
9179
|
+
console.warn('[PAGARME BOLETO DATA TO SEND]', JSON.stringify(payload));
|
|
9180
|
+
const { data } = await axios({
|
|
9181
|
+
method: 'POST',
|
|
9182
|
+
url: `${this.credentials.URL}/orders`,
|
|
9183
|
+
headers: {
|
|
9184
|
+
Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
|
|
9185
|
+
'Content-Type': 'application/json',
|
|
9186
|
+
},
|
|
9187
|
+
data: payload,
|
|
9188
|
+
});
|
|
9189
|
+
console.warn('[PAGARME RESPONSE BOLETO DATA]', JSON.stringify(data));
|
|
9190
|
+
if (data.status === PagarMeV5OrderStatus.Falha ||
|
|
9191
|
+
data.charges.at(0).status === PagarMeV5OrderStatus.Falha ||
|
|
9192
|
+
(data.charges.at(0).last_transaction.status !== PagarMeV5PaymentStatus.Gerado &&
|
|
9193
|
+
data.charges.at(0).last_transaction.status !== PagarMeV5PaymentStatus['Em processamento'])) {
|
|
9194
|
+
return Promise.reject(new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
9195
|
+
checkoutId: checkout.id,
|
|
9196
|
+
userEmail: checkout.user.email,
|
|
9197
|
+
info: data.charges.at(0).last_transaction?.gateway_response,
|
|
9198
|
+
}));
|
|
9199
|
+
}
|
|
9200
|
+
const payment = await this.paymentRepository.create(PagarMeV5ResponseHelper.build(TransactionPaymentMethods.BANKSLIP, checkout, data));
|
|
9201
|
+
return payment;
|
|
9202
|
+
}
|
|
9203
|
+
catch (error) {
|
|
9204
|
+
if (error instanceof AxiosError) {
|
|
9205
|
+
console.error('error data: ', JSON.stringify(error.response?.data));
|
|
9206
|
+
}
|
|
9207
|
+
throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
9208
|
+
checkoutId: checkout.id,
|
|
9209
|
+
userEmail: checkout.user.email,
|
|
9210
|
+
info: error.response?.data,
|
|
9211
|
+
});
|
|
9212
|
+
}
|
|
9213
|
+
}
|
|
9214
|
+
async getBoletoTransaction(paymentId) {
|
|
9215
|
+
try {
|
|
9216
|
+
const { data } = await axios({
|
|
9217
|
+
method: 'GET',
|
|
9218
|
+
url: `${this.credentials.URL}/charges/${paymentId}`,
|
|
9219
|
+
headers: {
|
|
9220
|
+
Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
|
|
9221
|
+
'Content-Type': 'application/json',
|
|
9222
|
+
},
|
|
9223
|
+
});
|
|
9224
|
+
const payment = await this.paymentRepository.get({
|
|
9225
|
+
id: data.id,
|
|
9226
|
+
});
|
|
9227
|
+
return payment.transaction;
|
|
9228
|
+
}
|
|
9229
|
+
catch (error) {
|
|
9230
|
+
throw new BusinessError('Houve uma falha buscar o boleto com paymentId: ' + paymentId, {
|
|
9231
|
+
paymentId,
|
|
9232
|
+
info: error.response.data,
|
|
9233
|
+
});
|
|
9234
|
+
}
|
|
9235
|
+
}
|
|
9236
|
+
}
|
|
9237
|
+
|
|
9238
|
+
class PagarmeV5CardAxiosAdapter {
|
|
9239
|
+
constructor(credentials, paymentRepository, orderBlockedRepository) {
|
|
9240
|
+
this.credentials = credentials;
|
|
9241
|
+
this.paymentRepository = paymentRepository;
|
|
9242
|
+
this.orderBlockedRepository = orderBlockedRepository;
|
|
9243
|
+
}
|
|
9244
|
+
async pay(checkout, card) {
|
|
9245
|
+
try {
|
|
9246
|
+
const payload = PagarMeV5RequestHelper.build(checkout, 'credit_card', card);
|
|
9247
|
+
console.warn('[PAGARME CARD DATA TO SEND]', JSON.stringify(payload));
|
|
9248
|
+
const { data } = await axios({
|
|
9249
|
+
method: 'POST',
|
|
9250
|
+
url: `${this.credentials.URL}/orders`,
|
|
9251
|
+
headers: {
|
|
9252
|
+
Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
|
|
9253
|
+
'Content-Type': 'application/json',
|
|
9254
|
+
},
|
|
9255
|
+
data: payload,
|
|
9256
|
+
});
|
|
9257
|
+
console.warn('[RESPONSE PAGARME CARD DATA]', JSON.stringify(data));
|
|
9258
|
+
if (data.status == PagarMeV5OrderStatus.Falha ||
|
|
9259
|
+
data.charges.at(0).status !== PagarMeV5OrderStatus.Pago ||
|
|
9260
|
+
data.charges.at(0).last_transaction.status !== PagarMeV5PaymentStatus.Capturada) {
|
|
9261
|
+
await PagarmeBlockedOrderHelper.createBlockedOrderForUnauthorizedCard({
|
|
9262
|
+
checkout,
|
|
9263
|
+
card,
|
|
9264
|
+
orderBlockedRepository: this.orderBlockedRepository,
|
|
9265
|
+
});
|
|
9266
|
+
throw PagarmeBlockedOrderHelper.createPaymentError(checkout, data);
|
|
9267
|
+
}
|
|
9268
|
+
const payment = await this.paymentRepository.create(PagarMeV5ResponseHelper.build(TransactionPaymentMethods.CARD, checkout, data));
|
|
9269
|
+
return payment;
|
|
9270
|
+
}
|
|
9271
|
+
catch (error) {
|
|
9272
|
+
if (error instanceof PaymentError) {
|
|
9273
|
+
throw error;
|
|
9274
|
+
}
|
|
9275
|
+
if (error instanceof AxiosError) {
|
|
9276
|
+
console.error('error data: ', JSON.stringify(error.response?.data));
|
|
9277
|
+
}
|
|
9278
|
+
throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, error.response?.data);
|
|
9279
|
+
}
|
|
9280
|
+
}
|
|
9281
|
+
async addCard(card, customer) {
|
|
9282
|
+
try {
|
|
9283
|
+
const { id } = await this.createOrUpdateCustomer(customer);
|
|
9284
|
+
const { data } = await axios({
|
|
9285
|
+
method: 'POST',
|
|
9286
|
+
url: `${this.credentials.URL}/customers/${id}/cards`,
|
|
9287
|
+
headers: {
|
|
9288
|
+
Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
|
|
9289
|
+
'Content-Type': 'application/json',
|
|
9290
|
+
},
|
|
9291
|
+
data: {
|
|
9292
|
+
number: card.number,
|
|
9293
|
+
holder_name: card.name,
|
|
9294
|
+
holder_document: card.cpf,
|
|
9295
|
+
exp_month: card.expirationDate.split('/').at(0),
|
|
9296
|
+
exp_year: card.expirationDate.split('/').at(1),
|
|
9297
|
+
cvv: card.cvv,
|
|
9298
|
+
billing_address: {
|
|
9299
|
+
line_1: `${customer.billingAddress.number}, ${customer.billingAddress.street}, ${customer.billingAddress.district}`,
|
|
9300
|
+
line_2: `${customer.billingAddress.extension}`,
|
|
9301
|
+
zip_code: customer.billingAddress.zip,
|
|
9302
|
+
city: customer.billingAddress.city,
|
|
9303
|
+
state: customer.billingAddress.state,
|
|
9304
|
+
country: 'BR',
|
|
9305
|
+
},
|
|
9306
|
+
},
|
|
9307
|
+
});
|
|
9308
|
+
return data;
|
|
9309
|
+
}
|
|
9310
|
+
catch (error) {
|
|
9311
|
+
console.warn(JSON.stringify(error));
|
|
9312
|
+
throw error;
|
|
9313
|
+
}
|
|
9314
|
+
}
|
|
9315
|
+
async createCardHash(bu, shop) {
|
|
9316
|
+
const credentials = shop && shop == Shops.MENSMARKET ? this.credentials[Shops.MENSMARKET] : this.credentials[Shops.GLAMSHOP];
|
|
9317
|
+
const key = bu === BusinessUnitEnum.SHOP ? credentials.SHOP_API_KEY : credentials.SUBSCRIPTION_API_KEY;
|
|
9318
|
+
try {
|
|
9319
|
+
const { data } = await axios({
|
|
9320
|
+
method: 'GET',
|
|
9321
|
+
headers: {
|
|
9322
|
+
'content-type': 'application/json',
|
|
9323
|
+
},
|
|
9324
|
+
url: `${this.credentials.URL}/transactions/card_hash_key`,
|
|
9325
|
+
data: JSON.stringify({
|
|
9326
|
+
api_key: key,
|
|
9327
|
+
}),
|
|
9328
|
+
});
|
|
9329
|
+
return data;
|
|
9330
|
+
}
|
|
9331
|
+
catch (error) {
|
|
9332
|
+
throw new BusinessError('Houve uma falha gerar o hash', {
|
|
9333
|
+
info: error.response.data,
|
|
9334
|
+
});
|
|
9335
|
+
}
|
|
9336
|
+
}
|
|
9337
|
+
async getCardByToken(customerId, token) {
|
|
9338
|
+
try {
|
|
9339
|
+
const { data } = await axios({
|
|
9340
|
+
method: 'GET',
|
|
9341
|
+
url: `${this.credentials.URL}/cards/${token}`,
|
|
9342
|
+
data: {
|
|
9343
|
+
api_key: this.credentials.API_KEY,
|
|
9344
|
+
},
|
|
9345
|
+
});
|
|
9346
|
+
return data;
|
|
9347
|
+
}
|
|
9348
|
+
catch (error) {
|
|
9349
|
+
throw new BusinessError('Houve uma falha buscar o cartão com id: ' + token, {
|
|
9350
|
+
info: error.response.data,
|
|
9351
|
+
});
|
|
9352
|
+
}
|
|
9353
|
+
}
|
|
9354
|
+
async createTransaction(info) {
|
|
9355
|
+
return info;
|
|
9356
|
+
}
|
|
9357
|
+
async createOrUpdateCustomer(customer) {
|
|
9358
|
+
try {
|
|
9359
|
+
const { data } = await axios({
|
|
9360
|
+
method: 'POST',
|
|
9361
|
+
url: `${this.credentials.URL}/customers`,
|
|
9362
|
+
headers: {
|
|
9363
|
+
Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
|
|
9364
|
+
'Content-Type': 'application/json',
|
|
9365
|
+
},
|
|
9366
|
+
data: {
|
|
9367
|
+
name: customer.displayName,
|
|
9368
|
+
email: customer.email,
|
|
9369
|
+
document: customer.cpf,
|
|
9370
|
+
type: 'individual',
|
|
9371
|
+
document_type: 'CPF',
|
|
9372
|
+
address: {
|
|
9373
|
+
line_1: `${customer.billingAddress.number}, ${customer.billingAddress.street}, ${customer.billingAddress.district}`,
|
|
9374
|
+
line_2: `${customer.billingAddress.extension}`,
|
|
9375
|
+
zip_code: customer.billingAddress.zip,
|
|
9376
|
+
city: customer.billingAddress.city,
|
|
9377
|
+
state: customer.billingAddress.state,
|
|
9378
|
+
country: 'BR',
|
|
9379
|
+
},
|
|
9380
|
+
birthdate: format(new Date(customer.birthday), 'MM/dd/yyyy'),
|
|
9381
|
+
phones: {
|
|
9382
|
+
home_phone: {
|
|
9383
|
+
country_code: '55',
|
|
9384
|
+
number: customer.phone.slice(2),
|
|
9385
|
+
area_code: customer.phone.slice(0, 2),
|
|
9386
|
+
},
|
|
9387
|
+
mobile_phone: {
|
|
9388
|
+
country_code: '55',
|
|
9389
|
+
number: customer.phone.slice(2),
|
|
9390
|
+
area_code: customer.phone.slice(0, 2),
|
|
9391
|
+
},
|
|
9392
|
+
},
|
|
9393
|
+
},
|
|
9394
|
+
});
|
|
9395
|
+
return data;
|
|
9396
|
+
}
|
|
9397
|
+
catch (error) {
|
|
9398
|
+
console.warn(error);
|
|
9399
|
+
throw error;
|
|
9400
|
+
}
|
|
9401
|
+
}
|
|
9402
|
+
}
|
|
9403
|
+
|
|
9404
|
+
class PagarmeV5PixAxiosAdapter {
|
|
9405
|
+
constructor(credentials, paymentRepository) {
|
|
9406
|
+
this.credentials = credentials;
|
|
9407
|
+
this.paymentRepository = paymentRepository;
|
|
9408
|
+
}
|
|
9409
|
+
async pay(checkout) {
|
|
9410
|
+
try {
|
|
9411
|
+
const payload = PagarMeV5RequestHelper.build(checkout, 'pix');
|
|
9412
|
+
console.warn('[PAGARME PIX DATA TO SEND]', JSON.stringify(payload));
|
|
9413
|
+
const { data } = await axios({
|
|
9414
|
+
method: 'POST',
|
|
9415
|
+
url: `${this.credentials.URL}/orders`,
|
|
9416
|
+
headers: {
|
|
9417
|
+
Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
|
|
9418
|
+
'Content-Type': 'application/json',
|
|
9419
|
+
},
|
|
9420
|
+
data: payload,
|
|
9421
|
+
});
|
|
9422
|
+
console.warn('[RESPONSE PAGARME PIX DATA]', JSON.stringify(data));
|
|
9423
|
+
if (data.status == PagarMeV5OrderStatus.Falha || data.status == PagarMeV5OrderStatus.Cancelado) {
|
|
9424
|
+
throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
|
|
9425
|
+
checkoutId: checkout.id,
|
|
9426
|
+
userEmail: checkout.user.email,
|
|
9427
|
+
info: data.charges.at(0).last_transaction?.gateway_response,
|
|
9428
|
+
});
|
|
9429
|
+
}
|
|
9430
|
+
const payment = await this.paymentRepository.create(PagarMeV5ResponseHelper.build(TransactionPaymentMethods.PIX, checkout, data));
|
|
9431
|
+
return payment;
|
|
9432
|
+
}
|
|
9433
|
+
catch (error) {
|
|
9434
|
+
if (error instanceof AxiosError) {
|
|
9435
|
+
console.error('error data: ', JSON.stringify(error.response?.data));
|
|
9436
|
+
}
|
|
9437
|
+
throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
|
|
9438
|
+
checkoutId: checkout.id,
|
|
9439
|
+
userEmail: checkout.user.email,
|
|
9440
|
+
info: error.response?.data,
|
|
9441
|
+
});
|
|
9442
|
+
}
|
|
9443
|
+
}
|
|
9444
|
+
}
|
|
9445
|
+
|
|
8784
9446
|
class VertexAxiosAdapter {
|
|
8785
9447
|
constructor(config) {
|
|
8786
9448
|
this.config = config;
|
|
@@ -8934,4 +9596,4 @@ class ProductsVertexSearch {
|
|
|
8934
9596
|
}
|
|
8935
9597
|
}
|
|
8936
9598
|
|
|
8937
|
-
export { AccessoryImportances, Address, AdyenCardAxiosAdapter, AdyenPaymentMethodFactory, AntifraudBankSlipService, AntifraudCardService, AntifraudGlampointsService, AntifraudPixService, AntifraudProviderFactory, AntifraudProviders, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, BrandEquityOptions, BusinessError, BusinessUnitEnum, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, CategoryProduct, CategoryProductHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, ConnectBaseDocumentSnapshot, ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, Coupon, CouponCategories, CouponCategory, CouponChannels, CouponFirestoreRepository, CouponOldCategories, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FirebaseFileUploaderService, FragranceImportances, FraudValidationError, GenderDestination, GlampointsPaymentMethodFactory, GlampointsPaymentService, Group, GroupFirestoreRepository, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, LogDocument, LogFirestoreRepository, Logger, NotFoundError, ObsEmitter, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderBlockedType, OrderFirestoreRepository, OrderStatus, PagarmeBankSlipAxiosAdapter, PagarmeCardAxiosAdapter, PagarmePaymentMethodFactory, PagarmePaymentStatus, PagarmePixAxiosAdapter, Payment, PaymentError, PaymentFirestoreRepository, PaymentMethods, PaymentProviderFactory, PaymentProviders, PaymentTransaction, PaymentType, PersonTypes, Plans, Product, ProductErrors, ProductErrorsHasuraGraphQL, ProductErrorsHasuraGraphQLRepository, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductLabelEnum, ProductReview, ProductReviewHasuraGraphQLRepository, ProductSpents, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, ProductsVertexSearch, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RestCacheAdapter, RoundProductPricesHelper, Sequence, SequenceFirestoreRepository, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, StockLimitError, StockOutError, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionSummary, SubscriptionSummaryFirestoreRepository, Trace, UnauthorizedError, UpdateOptionActions, UpdateUserImage, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, VertexAxiosAdapter, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, WishlistLogType, deserialize, getClass, is, isDebuggable, isUUID, parseDateTime, registerClass, resolveClass, serialize, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
|
9599
|
+
export { AccessoryImportances, Address, AdyenCardAxiosAdapter, AdyenPaymentMethodFactory, AntifraudBankSlipService, AntifraudCardService, AntifraudGlampointsService, AntifraudPixService, AntifraudProviderFactory, AntifraudProviders, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, BrandEquityOptions, BusinessError, BusinessUnitEnum, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, CategoryProduct, CategoryProductHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, ConnectBaseDocumentSnapshot, ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, Coupon, CouponCategories, CouponCategory, CouponChannels, CouponFirestoreRepository, CouponOldCategories, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FirebaseFileUploaderService, FragranceImportances, FraudValidationError, GenderDestination, GlampointsPaymentMethodFactory, GlampointsPaymentService, Group, GroupFirestoreRepository, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, LogDocument, LogFirestoreRepository, Logger, NotFoundError, ObsEmitter, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderBlockedType, OrderFirestoreRepository, OrderStatus, PagarMeV5OrderStatus, PagarMeV5PaymentStatus, PagarmeBankSlipAxiosAdapter, PagarmeCardAxiosAdapter, PagarmePaymentMethodFactory, PagarmePaymentStatus, PagarmePixAxiosAdapter, PagarmeV5BankSlipAxiosAdapter, PagarmeV5CardAxiosAdapter, PagarmeV5PixAxiosAdapter, Payment, PaymentError, PaymentFirestoreRepository, PaymentMethods, PaymentProviderFactory, PaymentProviders, PaymentTransaction, PaymentType, PersonTypes, Plans, Product, ProductErrors, ProductErrorsHasuraGraphQL, ProductErrorsHasuraGraphQLRepository, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductLabelEnum, ProductReview, ProductReviewHasuraGraphQLRepository, ProductSpents, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, ProductsVertexSearch, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RestCacheAdapter, RoundProductPricesHelper, Sequence, SequenceFirestoreRepository, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, StockLimitError, StockOutError, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionSummary, SubscriptionSummaryFirestoreRepository, Trace, TransactionPaymentMethods, UnauthorizedError, UpdateOptionActions, UpdateUserImage, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, VertexAxiosAdapter, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, WishlistLogType, deserialize, getClass, is, isDebuggable, isUUID, parseDateTime, registerClass, resolveClass, serialize, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|