@infrab4a/connect 5.1.0-beta.1 → 5.1.0-beta.3
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
CHANGED
|
@@ -8597,7 +8597,9 @@ class PagarMeV5RequestHelper {
|
|
|
8597
8597
|
};
|
|
8598
8598
|
}
|
|
8599
8599
|
static buildItems(checkout) {
|
|
8600
|
-
return checkout.lineItems
|
|
8600
|
+
return checkout.lineItems
|
|
8601
|
+
.filter((item) => !item.isGift)
|
|
8602
|
+
.map((item) => {
|
|
8601
8603
|
return {
|
|
8602
8604
|
amount: Math.floor(item.pricePaid * 100),
|
|
8603
8605
|
description: item.name,
|
|
@@ -8624,14 +8626,14 @@ class PagarMeV5RequestHelper {
|
|
|
8624
8626
|
zip_code: checkout.shippingAddress.zip,
|
|
8625
8627
|
city: checkout.billingAddress.city,
|
|
8626
8628
|
state: checkout.billingAddress.state,
|
|
8627
|
-
country:
|
|
8629
|
+
country: 'BR',
|
|
8628
8630
|
},
|
|
8629
8631
|
};
|
|
8630
8632
|
}
|
|
8631
8633
|
static buildShipping(checkout) {
|
|
8632
8634
|
return {
|
|
8633
|
-
amount: checkout.shipping.ShippingPrice,
|
|
8634
|
-
description:
|
|
8635
|
+
amount: Math.floor(checkout.shipping.ShippingPrice * 100),
|
|
8636
|
+
description: `${checkout.shipping.ShippingCompanyName} - ${checkout.shipping.description}`,
|
|
8635
8637
|
recipient_name: checkout.shippingAddress.recipient,
|
|
8636
8638
|
recipient_phone: checkout.user.phone,
|
|
8637
8639
|
address: {
|
|
@@ -8640,7 +8642,7 @@ class PagarMeV5RequestHelper {
|
|
|
8640
8642
|
zip_code: checkout.shippingAddress.zip,
|
|
8641
8643
|
city: checkout.shippingAddress.city,
|
|
8642
8644
|
state: checkout.shippingAddress.state,
|
|
8643
|
-
country:
|
|
8645
|
+
country: 'BR',
|
|
8644
8646
|
},
|
|
8645
8647
|
};
|
|
8646
8648
|
}
|
|
@@ -8984,6 +8986,43 @@ class PagarmeV5BankSlipAxiosAdapter {
|
|
|
8984
8986
|
this.credentials = credentials;
|
|
8985
8987
|
this.paymentRepository = paymentRepository;
|
|
8986
8988
|
}
|
|
8989
|
+
async pay2(payload) {
|
|
8990
|
+
try {
|
|
8991
|
+
console.warn('[PAGARME BOLETO DATA TO SEND]', JSON.stringify(payload));
|
|
8992
|
+
const { data } = await axios__default["default"]({
|
|
8993
|
+
method: 'POST',
|
|
8994
|
+
url: `${this.credentials.URL}/orders`,
|
|
8995
|
+
headers: {
|
|
8996
|
+
Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
|
|
8997
|
+
'Content-Type': 'application/json',
|
|
8998
|
+
},
|
|
8999
|
+
data: payload,
|
|
9000
|
+
});
|
|
9001
|
+
console.warn('[PAGARME RESPONSE BOLETO DATA]', JSON.stringify(data));
|
|
9002
|
+
if (data.charges.at(0).status !== exports.PagarMeV5OrderStatus['Em processamento'] ||
|
|
9003
|
+
data.charges.at(0).status !== exports.PagarMeV5PaymentStatus['Falha']) {
|
|
9004
|
+
return Promise.reject(new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
9005
|
+
// checkoutId: checkout.id,
|
|
9006
|
+
// userEmail: checkout.user.email,
|
|
9007
|
+
info: data,
|
|
9008
|
+
}));
|
|
9009
|
+
}
|
|
9010
|
+
// const paymentData = PagarMeV5ResponseHelper.build(checkout, data)
|
|
9011
|
+
// const payment = await this.paymentRepository.create(paymentData)
|
|
9012
|
+
return data;
|
|
9013
|
+
}
|
|
9014
|
+
catch (error) {
|
|
9015
|
+
if (error instanceof axios.AxiosError) {
|
|
9016
|
+
console.error(error.message);
|
|
9017
|
+
console.error(error.response.data);
|
|
9018
|
+
}
|
|
9019
|
+
throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
9020
|
+
// checkoutId: checkout.id,
|
|
9021
|
+
// userEmail: checkout.user.email,
|
|
9022
|
+
info: error.response.data,
|
|
9023
|
+
});
|
|
9024
|
+
}
|
|
9025
|
+
}
|
|
8987
9026
|
async pay(checkout) {
|
|
8988
9027
|
try {
|
|
8989
9028
|
const payload = PagarMeV5RequestHelper.build(checkout, 'boleto');
|
|
@@ -9011,9 +9050,12 @@ class PagarmeV5BankSlipAxiosAdapter {
|
|
|
9011
9050
|
return payment;
|
|
9012
9051
|
}
|
|
9013
9052
|
catch (error) {
|
|
9014
|
-
|
|
9015
|
-
|
|
9016
|
-
|
|
9053
|
+
if (error instanceof axios.AxiosError) {
|
|
9054
|
+
console.error(error.message);
|
|
9055
|
+
console.error(error.response);
|
|
9056
|
+
if ('data' in error.response)
|
|
9057
|
+
console.error(error.response?.data);
|
|
9058
|
+
}
|
|
9017
9059
|
throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
9018
9060
|
checkoutId: checkout.id,
|
|
9019
9061
|
userEmail: checkout.user.email,
|
|
@@ -9082,9 +9124,10 @@ class PagarmeV5CardAxiosAdapter {
|
|
|
9082
9124
|
if (error instanceof PaymentError) {
|
|
9083
9125
|
throw error;
|
|
9084
9126
|
}
|
|
9085
|
-
|
|
9086
|
-
|
|
9087
|
-
|
|
9127
|
+
if (error instanceof axios.AxiosError) {
|
|
9128
|
+
console.error(error.message);
|
|
9129
|
+
console.error(error.response.data);
|
|
9130
|
+
}
|
|
9088
9131
|
throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, error.response?.data);
|
|
9089
9132
|
}
|
|
9090
9133
|
}
|
|
@@ -9196,6 +9239,36 @@ class PagarmeV5PixAxiosAdapter {
|
|
|
9196
9239
|
this.credentials = credentials;
|
|
9197
9240
|
this.paymentRepository = paymentRepository;
|
|
9198
9241
|
}
|
|
9242
|
+
async pay2(payload) {
|
|
9243
|
+
try {
|
|
9244
|
+
// const payload = PagarMeV5RequestHelper.build(checkout, 'pix')
|
|
9245
|
+
console.warn('[PAGARME PIX DATA TO SEND]', JSON.stringify(payload));
|
|
9246
|
+
const { data } = await axios__default["default"]({
|
|
9247
|
+
method: 'POST',
|
|
9248
|
+
url: `${this.credentials.URL}/orders`,
|
|
9249
|
+
headers: {
|
|
9250
|
+
Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
|
|
9251
|
+
'Content-Type': 'application/json',
|
|
9252
|
+
},
|
|
9253
|
+
data: payload,
|
|
9254
|
+
});
|
|
9255
|
+
console.warn('[RESPONSE PAGARME PIX DATA]', JSON.stringify(data));
|
|
9256
|
+
// const paymentData = PagarMeV5ResponseHelper.build(checkout, data)
|
|
9257
|
+
// const payment = await this.paymentRepository.create(paymentData)
|
|
9258
|
+
return data;
|
|
9259
|
+
}
|
|
9260
|
+
catch (error) {
|
|
9261
|
+
if (error instanceof axios.AxiosError) {
|
|
9262
|
+
console.error(error.message);
|
|
9263
|
+
console.error(error.response.data);
|
|
9264
|
+
}
|
|
9265
|
+
throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
|
|
9266
|
+
// checkoutId: checkout.id,
|
|
9267
|
+
// userEmail: checkout.user.email,
|
|
9268
|
+
info: error.response?.data,
|
|
9269
|
+
});
|
|
9270
|
+
}
|
|
9271
|
+
}
|
|
9199
9272
|
async pay(checkout) {
|
|
9200
9273
|
try {
|
|
9201
9274
|
const payload = PagarMeV5RequestHelper.build(checkout, 'pix');
|
|
@@ -9215,9 +9288,12 @@ class PagarmeV5PixAxiosAdapter {
|
|
|
9215
9288
|
return payment;
|
|
9216
9289
|
}
|
|
9217
9290
|
catch (error) {
|
|
9218
|
-
|
|
9219
|
-
|
|
9220
|
-
|
|
9291
|
+
if (error instanceof axios.AxiosError) {
|
|
9292
|
+
console.error(error.message);
|
|
9293
|
+
console.error(error.response);
|
|
9294
|
+
if ('data' in error.response)
|
|
9295
|
+
console.error(error.response?.data);
|
|
9296
|
+
}
|
|
9221
9297
|
throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
|
|
9222
9298
|
checkoutId: checkout.id,
|
|
9223
9299
|
userEmail: checkout.user.email,
|
package/index.esm.js
CHANGED
|
@@ -8572,7 +8572,9 @@ class PagarMeV5RequestHelper {
|
|
|
8572
8572
|
};
|
|
8573
8573
|
}
|
|
8574
8574
|
static buildItems(checkout) {
|
|
8575
|
-
return checkout.lineItems
|
|
8575
|
+
return checkout.lineItems
|
|
8576
|
+
.filter((item) => !item.isGift)
|
|
8577
|
+
.map((item) => {
|
|
8576
8578
|
return {
|
|
8577
8579
|
amount: Math.floor(item.pricePaid * 100),
|
|
8578
8580
|
description: item.name,
|
|
@@ -8599,14 +8601,14 @@ class PagarMeV5RequestHelper {
|
|
|
8599
8601
|
zip_code: checkout.shippingAddress.zip,
|
|
8600
8602
|
city: checkout.billingAddress.city,
|
|
8601
8603
|
state: checkout.billingAddress.state,
|
|
8602
|
-
country:
|
|
8604
|
+
country: 'BR',
|
|
8603
8605
|
},
|
|
8604
8606
|
};
|
|
8605
8607
|
}
|
|
8606
8608
|
static buildShipping(checkout) {
|
|
8607
8609
|
return {
|
|
8608
|
-
amount: checkout.shipping.ShippingPrice,
|
|
8609
|
-
description:
|
|
8610
|
+
amount: Math.floor(checkout.shipping.ShippingPrice * 100),
|
|
8611
|
+
description: `${checkout.shipping.ShippingCompanyName} - ${checkout.shipping.description}`,
|
|
8610
8612
|
recipient_name: checkout.shippingAddress.recipient,
|
|
8611
8613
|
recipient_phone: checkout.user.phone,
|
|
8612
8614
|
address: {
|
|
@@ -8615,7 +8617,7 @@ class PagarMeV5RequestHelper {
|
|
|
8615
8617
|
zip_code: checkout.shippingAddress.zip,
|
|
8616
8618
|
city: checkout.shippingAddress.city,
|
|
8617
8619
|
state: checkout.shippingAddress.state,
|
|
8618
|
-
country:
|
|
8620
|
+
country: 'BR',
|
|
8619
8621
|
},
|
|
8620
8622
|
};
|
|
8621
8623
|
}
|
|
@@ -8959,6 +8961,43 @@ class PagarmeV5BankSlipAxiosAdapter {
|
|
|
8959
8961
|
this.credentials = credentials;
|
|
8960
8962
|
this.paymentRepository = paymentRepository;
|
|
8961
8963
|
}
|
|
8964
|
+
async pay2(payload) {
|
|
8965
|
+
try {
|
|
8966
|
+
console.warn('[PAGARME BOLETO DATA TO SEND]', JSON.stringify(payload));
|
|
8967
|
+
const { data } = await axios({
|
|
8968
|
+
method: 'POST',
|
|
8969
|
+
url: `${this.credentials.URL}/orders`,
|
|
8970
|
+
headers: {
|
|
8971
|
+
Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
|
|
8972
|
+
'Content-Type': 'application/json',
|
|
8973
|
+
},
|
|
8974
|
+
data: payload,
|
|
8975
|
+
});
|
|
8976
|
+
console.warn('[PAGARME RESPONSE BOLETO DATA]', JSON.stringify(data));
|
|
8977
|
+
if (data.charges.at(0).status !== PagarMeV5OrderStatus['Em processamento'] ||
|
|
8978
|
+
data.charges.at(0).status !== PagarMeV5PaymentStatus['Falha']) {
|
|
8979
|
+
return Promise.reject(new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
8980
|
+
// checkoutId: checkout.id,
|
|
8981
|
+
// userEmail: checkout.user.email,
|
|
8982
|
+
info: data,
|
|
8983
|
+
}));
|
|
8984
|
+
}
|
|
8985
|
+
// const paymentData = PagarMeV5ResponseHelper.build(checkout, data)
|
|
8986
|
+
// const payment = await this.paymentRepository.create(paymentData)
|
|
8987
|
+
return data;
|
|
8988
|
+
}
|
|
8989
|
+
catch (error) {
|
|
8990
|
+
if (error instanceof AxiosError) {
|
|
8991
|
+
console.error(error.message);
|
|
8992
|
+
console.error(error.response.data);
|
|
8993
|
+
}
|
|
8994
|
+
throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
8995
|
+
// checkoutId: checkout.id,
|
|
8996
|
+
// userEmail: checkout.user.email,
|
|
8997
|
+
info: error.response.data,
|
|
8998
|
+
});
|
|
8999
|
+
}
|
|
9000
|
+
}
|
|
8962
9001
|
async pay(checkout) {
|
|
8963
9002
|
try {
|
|
8964
9003
|
const payload = PagarMeV5RequestHelper.build(checkout, 'boleto');
|
|
@@ -8986,9 +9025,12 @@ class PagarmeV5BankSlipAxiosAdapter {
|
|
|
8986
9025
|
return payment;
|
|
8987
9026
|
}
|
|
8988
9027
|
catch (error) {
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
|
|
9028
|
+
if (error instanceof AxiosError) {
|
|
9029
|
+
console.error(error.message);
|
|
9030
|
+
console.error(error.response);
|
|
9031
|
+
if ('data' in error.response)
|
|
9032
|
+
console.error(error.response?.data);
|
|
9033
|
+
}
|
|
8992
9034
|
throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
8993
9035
|
checkoutId: checkout.id,
|
|
8994
9036
|
userEmail: checkout.user.email,
|
|
@@ -9057,9 +9099,10 @@ class PagarmeV5CardAxiosAdapter {
|
|
|
9057
9099
|
if (error instanceof PaymentError) {
|
|
9058
9100
|
throw error;
|
|
9059
9101
|
}
|
|
9060
|
-
|
|
9061
|
-
|
|
9062
|
-
|
|
9102
|
+
if (error instanceof AxiosError) {
|
|
9103
|
+
console.error(error.message);
|
|
9104
|
+
console.error(error.response.data);
|
|
9105
|
+
}
|
|
9063
9106
|
throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, error.response?.data);
|
|
9064
9107
|
}
|
|
9065
9108
|
}
|
|
@@ -9171,6 +9214,36 @@ class PagarmeV5PixAxiosAdapter {
|
|
|
9171
9214
|
this.credentials = credentials;
|
|
9172
9215
|
this.paymentRepository = paymentRepository;
|
|
9173
9216
|
}
|
|
9217
|
+
async pay2(payload) {
|
|
9218
|
+
try {
|
|
9219
|
+
// const payload = PagarMeV5RequestHelper.build(checkout, 'pix')
|
|
9220
|
+
console.warn('[PAGARME PIX DATA TO SEND]', JSON.stringify(payload));
|
|
9221
|
+
const { data } = await axios({
|
|
9222
|
+
method: 'POST',
|
|
9223
|
+
url: `${this.credentials.URL}/orders`,
|
|
9224
|
+
headers: {
|
|
9225
|
+
Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
|
|
9226
|
+
'Content-Type': 'application/json',
|
|
9227
|
+
},
|
|
9228
|
+
data: payload,
|
|
9229
|
+
});
|
|
9230
|
+
console.warn('[RESPONSE PAGARME PIX DATA]', JSON.stringify(data));
|
|
9231
|
+
// const paymentData = PagarMeV5ResponseHelper.build(checkout, data)
|
|
9232
|
+
// const payment = await this.paymentRepository.create(paymentData)
|
|
9233
|
+
return data;
|
|
9234
|
+
}
|
|
9235
|
+
catch (error) {
|
|
9236
|
+
if (error instanceof AxiosError) {
|
|
9237
|
+
console.error(error.message);
|
|
9238
|
+
console.error(error.response.data);
|
|
9239
|
+
}
|
|
9240
|
+
throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
|
|
9241
|
+
// checkoutId: checkout.id,
|
|
9242
|
+
// userEmail: checkout.user.email,
|
|
9243
|
+
info: error.response?.data,
|
|
9244
|
+
});
|
|
9245
|
+
}
|
|
9246
|
+
}
|
|
9174
9247
|
async pay(checkout) {
|
|
9175
9248
|
try {
|
|
9176
9249
|
const payload = PagarMeV5RequestHelper.build(checkout, 'pix');
|
|
@@ -9190,9 +9263,12 @@ class PagarmeV5PixAxiosAdapter {
|
|
|
9190
9263
|
return payment;
|
|
9191
9264
|
}
|
|
9192
9265
|
catch (error) {
|
|
9193
|
-
|
|
9194
|
-
|
|
9195
|
-
|
|
9266
|
+
if (error instanceof AxiosError) {
|
|
9267
|
+
console.error(error.message);
|
|
9268
|
+
console.error(error.response);
|
|
9269
|
+
if ('data' in error.response)
|
|
9270
|
+
console.error(error.response?.data);
|
|
9271
|
+
}
|
|
9196
9272
|
throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
|
|
9197
9273
|
checkoutId: checkout.id,
|
|
9198
9274
|
userEmail: checkout.user.email,
|
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@ export declare class PagarmeV5BankSlipAxiosAdapter implements PaymentProviderBan
|
|
|
6
6
|
private credentials;
|
|
7
7
|
private paymentRepository;
|
|
8
8
|
constructor(credentials: PagarmeCredentialsV5, paymentRepository: PaymentRepository);
|
|
9
|
+
pay2(payload: any): Promise<any>;
|
|
9
10
|
pay(checkout: Checkout): Promise<Payment>;
|
|
10
11
|
getBoletoTransaction(paymentId: number): Promise<PaymentTransaction>;
|
|
11
12
|
}
|
|
@@ -6,5 +6,6 @@ export declare class PagarmeV5PixAxiosAdapter implements PaymentProviderPix {
|
|
|
6
6
|
private credentials;
|
|
7
7
|
private paymentRepository;
|
|
8
8
|
constructor(credentials: PagarmeCredentialsV5, paymentRepository: PaymentRepository);
|
|
9
|
+
pay2(payload: any): Promise<any>;
|
|
9
10
|
pay(checkout: Checkout): Promise<Payment>;
|
|
10
11
|
}
|