@infrab4a/connect 5.1.0-beta.2 → 5.1.0-beta.4
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
|
@@ -8604,6 +8604,7 @@ class PagarMeV5RequestHelper {
|
|
|
8604
8604
|
amount: Math.floor(item.pricePaid * 100),
|
|
8605
8605
|
description: item.name,
|
|
8606
8606
|
quantity: item.quantity,
|
|
8607
|
+
code: item.EAN,
|
|
8607
8608
|
};
|
|
8608
8609
|
});
|
|
8609
8610
|
}
|
|
@@ -8617,7 +8618,7 @@ class PagarMeV5RequestHelper {
|
|
|
8617
8618
|
mobile_phone: {
|
|
8618
8619
|
country_code: '55',
|
|
8619
8620
|
number: checkout.user.phone.slice(2),
|
|
8620
|
-
area_code: checkout.user.phone.slice(0,
|
|
8621
|
+
area_code: checkout.user.phone.slice(0, 2),
|
|
8621
8622
|
},
|
|
8622
8623
|
},
|
|
8623
8624
|
address: {
|
|
@@ -9050,14 +9051,15 @@ class PagarmeV5BankSlipAxiosAdapter {
|
|
|
9050
9051
|
return payment;
|
|
9051
9052
|
}
|
|
9052
9053
|
catch (error) {
|
|
9054
|
+
console.error('Full error: ', error);
|
|
9053
9055
|
if (error instanceof axios.AxiosError) {
|
|
9054
|
-
console.error(error.message);
|
|
9055
|
-
console.error(error.response.data);
|
|
9056
|
+
console.error('Error: ', error.message);
|
|
9057
|
+
console.error('Error response: ', error.response, 'error data: ', error.response?.data);
|
|
9056
9058
|
}
|
|
9057
9059
|
throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
9058
9060
|
checkoutId: checkout.id,
|
|
9059
9061
|
userEmail: checkout.user.email,
|
|
9060
|
-
info: error.response
|
|
9062
|
+
info: error.response?.data,
|
|
9061
9063
|
});
|
|
9062
9064
|
}
|
|
9063
9065
|
}
|
|
@@ -9122,9 +9124,10 @@ class PagarmeV5CardAxiosAdapter {
|
|
|
9122
9124
|
if (error instanceof PaymentError) {
|
|
9123
9125
|
throw error;
|
|
9124
9126
|
}
|
|
9127
|
+
console.error('Full error: ', error);
|
|
9125
9128
|
if (error instanceof axios.AxiosError) {
|
|
9126
|
-
console.error(error.message);
|
|
9127
|
-
console.error(error.response.data);
|
|
9129
|
+
console.error('Error: ', error.message);
|
|
9130
|
+
console.error('Error response: ', error.response, 'error data: ', error.response?.data);
|
|
9128
9131
|
}
|
|
9129
9132
|
throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, error.response?.data);
|
|
9130
9133
|
}
|
|
@@ -9237,6 +9240,36 @@ class PagarmeV5PixAxiosAdapter {
|
|
|
9237
9240
|
this.credentials = credentials;
|
|
9238
9241
|
this.paymentRepository = paymentRepository;
|
|
9239
9242
|
}
|
|
9243
|
+
async pay2(payload) {
|
|
9244
|
+
try {
|
|
9245
|
+
// const payload = PagarMeV5RequestHelper.build(checkout, 'pix')
|
|
9246
|
+
console.warn('[PAGARME PIX DATA TO SEND]', JSON.stringify(payload));
|
|
9247
|
+
const { data } = await axios__default["default"]({
|
|
9248
|
+
method: 'POST',
|
|
9249
|
+
url: `${this.credentials.URL}/orders`,
|
|
9250
|
+
headers: {
|
|
9251
|
+
Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
|
|
9252
|
+
'Content-Type': 'application/json',
|
|
9253
|
+
},
|
|
9254
|
+
data: payload,
|
|
9255
|
+
});
|
|
9256
|
+
console.warn('[RESPONSE PAGARME PIX DATA]', JSON.stringify(data));
|
|
9257
|
+
// const paymentData = PagarMeV5ResponseHelper.build(checkout, data)
|
|
9258
|
+
// const payment = await this.paymentRepository.create(paymentData)
|
|
9259
|
+
return data;
|
|
9260
|
+
}
|
|
9261
|
+
catch (error) {
|
|
9262
|
+
if (error instanceof axios.AxiosError) {
|
|
9263
|
+
console.error(error.message);
|
|
9264
|
+
console.error(error.response.data);
|
|
9265
|
+
}
|
|
9266
|
+
throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
|
|
9267
|
+
// checkoutId: checkout.id,
|
|
9268
|
+
// userEmail: checkout.user.email,
|
|
9269
|
+
info: error.response?.data,
|
|
9270
|
+
});
|
|
9271
|
+
}
|
|
9272
|
+
}
|
|
9240
9273
|
async pay(checkout) {
|
|
9241
9274
|
try {
|
|
9242
9275
|
const payload = PagarMeV5RequestHelper.build(checkout, 'pix');
|
|
@@ -9256,9 +9289,10 @@ class PagarmeV5PixAxiosAdapter {
|
|
|
9256
9289
|
return payment;
|
|
9257
9290
|
}
|
|
9258
9291
|
catch (error) {
|
|
9292
|
+
console.error('Full error: ', error);
|
|
9259
9293
|
if (error instanceof axios.AxiosError) {
|
|
9260
|
-
console.error(error.message);
|
|
9261
|
-
console.error(error.response.data);
|
|
9294
|
+
console.error('Error: ', error.message);
|
|
9295
|
+
console.error('Error response: ', error.response, 'error data: ', error.response?.data);
|
|
9262
9296
|
}
|
|
9263
9297
|
throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
|
|
9264
9298
|
checkoutId: checkout.id,
|
package/index.esm.js
CHANGED
|
@@ -8579,6 +8579,7 @@ class PagarMeV5RequestHelper {
|
|
|
8579
8579
|
amount: Math.floor(item.pricePaid * 100),
|
|
8580
8580
|
description: item.name,
|
|
8581
8581
|
quantity: item.quantity,
|
|
8582
|
+
code: item.EAN,
|
|
8582
8583
|
};
|
|
8583
8584
|
});
|
|
8584
8585
|
}
|
|
@@ -8592,7 +8593,7 @@ class PagarMeV5RequestHelper {
|
|
|
8592
8593
|
mobile_phone: {
|
|
8593
8594
|
country_code: '55',
|
|
8594
8595
|
number: checkout.user.phone.slice(2),
|
|
8595
|
-
area_code: checkout.user.phone.slice(0,
|
|
8596
|
+
area_code: checkout.user.phone.slice(0, 2),
|
|
8596
8597
|
},
|
|
8597
8598
|
},
|
|
8598
8599
|
address: {
|
|
@@ -9025,14 +9026,15 @@ class PagarmeV5BankSlipAxiosAdapter {
|
|
|
9025
9026
|
return payment;
|
|
9026
9027
|
}
|
|
9027
9028
|
catch (error) {
|
|
9029
|
+
console.error('Full error: ', error);
|
|
9028
9030
|
if (error instanceof AxiosError) {
|
|
9029
|
-
console.error(error.message);
|
|
9030
|
-
console.error(error.response.data);
|
|
9031
|
+
console.error('Error: ', error.message);
|
|
9032
|
+
console.error('Error response: ', error.response, 'error data: ', error.response?.data);
|
|
9031
9033
|
}
|
|
9032
9034
|
throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
9033
9035
|
checkoutId: checkout.id,
|
|
9034
9036
|
userEmail: checkout.user.email,
|
|
9035
|
-
info: error.response
|
|
9037
|
+
info: error.response?.data,
|
|
9036
9038
|
});
|
|
9037
9039
|
}
|
|
9038
9040
|
}
|
|
@@ -9097,9 +9099,10 @@ class PagarmeV5CardAxiosAdapter {
|
|
|
9097
9099
|
if (error instanceof PaymentError) {
|
|
9098
9100
|
throw error;
|
|
9099
9101
|
}
|
|
9102
|
+
console.error('Full error: ', error);
|
|
9100
9103
|
if (error instanceof AxiosError) {
|
|
9101
|
-
console.error(error.message);
|
|
9102
|
-
console.error(error.response.data);
|
|
9104
|
+
console.error('Error: ', error.message);
|
|
9105
|
+
console.error('Error response: ', error.response, 'error data: ', error.response?.data);
|
|
9103
9106
|
}
|
|
9104
9107
|
throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, error.response?.data);
|
|
9105
9108
|
}
|
|
@@ -9212,6 +9215,36 @@ class PagarmeV5PixAxiosAdapter {
|
|
|
9212
9215
|
this.credentials = credentials;
|
|
9213
9216
|
this.paymentRepository = paymentRepository;
|
|
9214
9217
|
}
|
|
9218
|
+
async pay2(payload) {
|
|
9219
|
+
try {
|
|
9220
|
+
// const payload = PagarMeV5RequestHelper.build(checkout, 'pix')
|
|
9221
|
+
console.warn('[PAGARME PIX DATA TO SEND]', JSON.stringify(payload));
|
|
9222
|
+
const { data } = await axios({
|
|
9223
|
+
method: 'POST',
|
|
9224
|
+
url: `${this.credentials.URL}/orders`,
|
|
9225
|
+
headers: {
|
|
9226
|
+
Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
|
|
9227
|
+
'Content-Type': 'application/json',
|
|
9228
|
+
},
|
|
9229
|
+
data: payload,
|
|
9230
|
+
});
|
|
9231
|
+
console.warn('[RESPONSE PAGARME PIX DATA]', JSON.stringify(data));
|
|
9232
|
+
// const paymentData = PagarMeV5ResponseHelper.build(checkout, data)
|
|
9233
|
+
// const payment = await this.paymentRepository.create(paymentData)
|
|
9234
|
+
return data;
|
|
9235
|
+
}
|
|
9236
|
+
catch (error) {
|
|
9237
|
+
if (error instanceof AxiosError) {
|
|
9238
|
+
console.error(error.message);
|
|
9239
|
+
console.error(error.response.data);
|
|
9240
|
+
}
|
|
9241
|
+
throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
|
|
9242
|
+
// checkoutId: checkout.id,
|
|
9243
|
+
// userEmail: checkout.user.email,
|
|
9244
|
+
info: error.response?.data,
|
|
9245
|
+
});
|
|
9246
|
+
}
|
|
9247
|
+
}
|
|
9215
9248
|
async pay(checkout) {
|
|
9216
9249
|
try {
|
|
9217
9250
|
const payload = PagarMeV5RequestHelper.build(checkout, 'pix');
|
|
@@ -9231,9 +9264,10 @@ class PagarmeV5PixAxiosAdapter {
|
|
|
9231
9264
|
return payment;
|
|
9232
9265
|
}
|
|
9233
9266
|
catch (error) {
|
|
9267
|
+
console.error('Full error: ', error);
|
|
9234
9268
|
if (error instanceof AxiosError) {
|
|
9235
|
-
console.error(error.message);
|
|
9236
|
-
console.error(error.response.data);
|
|
9269
|
+
console.error('Error: ', error.message);
|
|
9270
|
+
console.error('Error response: ', error.response, 'error data: ', error.response?.data);
|
|
9237
9271
|
}
|
|
9238
9272
|
throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
|
|
9239
9273
|
checkoutId: checkout.id,
|
package/package.json
CHANGED
|
@@ -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
|
}
|