@infrab4a/connect 5.1.0-beta.2 → 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
@@ -9052,7 +9052,9 @@ class PagarmeV5BankSlipAxiosAdapter {
9052
9052
  catch (error) {
9053
9053
  if (error instanceof axios.AxiosError) {
9054
9054
  console.error(error.message);
9055
- console.error(error.response.data);
9055
+ console.error(error.response);
9056
+ if ('data' in error.response)
9057
+ console.error(error.response?.data);
9056
9058
  }
9057
9059
  throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
9058
9060
  checkoutId: checkout.id,
@@ -9237,6 +9239,36 @@ class PagarmeV5PixAxiosAdapter {
9237
9239
  this.credentials = credentials;
9238
9240
  this.paymentRepository = paymentRepository;
9239
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
+ }
9240
9272
  async pay(checkout) {
9241
9273
  try {
9242
9274
  const payload = PagarMeV5RequestHelper.build(checkout, 'pix');
@@ -9258,7 +9290,9 @@ class PagarmeV5PixAxiosAdapter {
9258
9290
  catch (error) {
9259
9291
  if (error instanceof axios.AxiosError) {
9260
9292
  console.error(error.message);
9261
- console.error(error.response.data);
9293
+ console.error(error.response);
9294
+ if ('data' in error.response)
9295
+ console.error(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
@@ -9027,7 +9027,9 @@ class PagarmeV5BankSlipAxiosAdapter {
9027
9027
  catch (error) {
9028
9028
  if (error instanceof AxiosError) {
9029
9029
  console.error(error.message);
9030
- console.error(error.response.data);
9030
+ console.error(error.response);
9031
+ if ('data' in error.response)
9032
+ console.error(error.response?.data);
9031
9033
  }
9032
9034
  throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
9033
9035
  checkoutId: checkout.id,
@@ -9212,6 +9214,36 @@ class PagarmeV5PixAxiosAdapter {
9212
9214
  this.credentials = credentials;
9213
9215
  this.paymentRepository = paymentRepository;
9214
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
+ }
9215
9247
  async pay(checkout) {
9216
9248
  try {
9217
9249
  const payload = PagarMeV5RequestHelper.build(checkout, 'pix');
@@ -9233,7 +9265,9 @@ class PagarmeV5PixAxiosAdapter {
9233
9265
  catch (error) {
9234
9266
  if (error instanceof AxiosError) {
9235
9267
  console.error(error.message);
9236
- console.error(error.response.data);
9268
+ console.error(error.response);
9269
+ if ('data' in error.response)
9270
+ console.error(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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "5.1.0-beta.2",
3
+ "version": "5.1.0-beta.3",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -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
  }