@infrab4a/connect 5.1.0-beta.12 → 5.1.0-beta.14

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
@@ -9123,34 +9123,40 @@ class PagarmeV5CardAxiosAdapter {
9123
9123
  }
9124
9124
  }
9125
9125
  async addCard(card, customer) {
9126
- const { id } = await this.createOrUpdateCustomer(customer);
9127
- const { data } = await axios__default["default"]({
9128
- method: 'POST',
9129
- url: `${this.credentials.URL}/customers/${id}/cards`,
9130
- headers: {
9131
- Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
9132
- 'Content-Type': 'application/json',
9133
- },
9134
- data: {
9135
- number: card.number,
9136
- holder_name: card.name,
9137
- holder_document: card.cpf,
9138
- exp_month: card.expirationDate.split('/').at(0),
9139
- exp_year: card.expirationDate.split('/').at(1),
9140
- cvv: card.cvv,
9141
- brand: card.flag,
9142
- label: card.flag,
9143
- billing_address: {
9144
- line_1: `${customer.billindAddress.number}, ${customer.billindAddress.street}, ${customer.billindAddress.district}`,
9145
- line_2: `${customer.billindAddress.extension}`,
9146
- zip_code: customer.billindAddress.zip,
9147
- city: customer.billindAddress.city,
9148
- state: customer.billindAddress.state,
9149
- country: 'BR',
9126
+ try {
9127
+ const { id } = await this.createOrUpdateCustomer(customer);
9128
+ const { data } = await axios__default["default"]({
9129
+ method: 'POST',
9130
+ url: `${this.credentials.URL}/customers/${id}/cards`,
9131
+ headers: {
9132
+ Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
9133
+ 'Content-Type': 'application/json',
9150
9134
  },
9151
- },
9152
- });
9153
- return data;
9135
+ data: {
9136
+ number: card.number,
9137
+ holder_name: card.name,
9138
+ holder_document: card.cpf,
9139
+ exp_month: card.expirationDate.split('/').at(0),
9140
+ exp_year: card.expirationDate.split('/').at(1),
9141
+ cvv: card.cvv,
9142
+ brand: card.flag,
9143
+ label: card.flag,
9144
+ billing_address: {
9145
+ line_1: `${customer.billingAddress.number}, ${customer.billingAddress.street}, ${customer.billingAddress.district}`,
9146
+ line_2: `${customer.billingAddress.extension}`,
9147
+ zip_code: customer.billingAddress.zip,
9148
+ city: customer.billingAddress.city,
9149
+ state: customer.billingAddress.state,
9150
+ country: 'BR',
9151
+ },
9152
+ },
9153
+ });
9154
+ return data;
9155
+ }
9156
+ catch (error) {
9157
+ console.warn(error);
9158
+ throw error;
9159
+ }
9154
9160
  }
9155
9161
  async createCardHash(bu, shop) {
9156
9162
  const credentials = shop && shop == exports.Shops.MENSMARKET ? this.credentials[exports.Shops.MENSMARKET] : this.credentials[exports.Shops.GLAMSHOP];
@@ -9194,58 +9200,50 @@ class PagarmeV5CardAxiosAdapter {
9194
9200
  async createTransaction(info) {
9195
9201
  return info;
9196
9202
  }
9197
- // async getCustomerByCpf(cpf: string) {
9198
- // const { data }: { data: any } = await axios({
9199
- // method: 'GET',
9200
- // url: `${this.credentials.URL}/customers`,
9201
- // headers: {
9202
- // Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
9203
- // 'Content-Type': 'application/json',
9204
- // },
9205
- // params: {
9206
- // document: cpf,
9207
- // },
9208
- // })
9209
- // return data
9210
- // }
9211
9203
  async createOrUpdateCustomer(customer) {
9212
- const { data } = await axios__default["default"]({
9213
- method: 'POST',
9214
- url: `${this.credentials.URL}/customers`,
9215
- headers: {
9216
- Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
9217
- 'Content-Type': 'application/json',
9218
- },
9219
- data: {
9220
- name: customer.displayName,
9221
- email: customer.email,
9222
- document: customer.cpf,
9223
- type: 'individual',
9224
- document_type: 'CPF',
9225
- address: {
9226
- line_1: `${customer.billindAddress.number}, ${customer.billindAddress.street}, ${customer.billindAddress.district}`,
9227
- line_2: `${customer.billindAddress.extension}`,
9228
- zip_code: customer.billindAddress.zip,
9229
- city: customer.billindAddress.city,
9230
- state: customer.billindAddress.state,
9231
- country: 'BR',
9204
+ try {
9205
+ const { data } = await axios__default["default"]({
9206
+ method: 'POST',
9207
+ url: `${this.credentials.URL}/customers`,
9208
+ headers: {
9209
+ Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
9210
+ 'Content-Type': 'application/json',
9232
9211
  },
9233
- birthdate: dateFns.format(customer.birthday, 'mm/dd/AAAA'),
9234
- phones: {
9235
- home_phone: {
9236
- country_code: '55',
9237
- number: customer.phone.slice(2),
9238
- area_code: customer.phone.slice(0, 2),
9212
+ data: {
9213
+ name: customer.displayName,
9214
+ email: customer.email,
9215
+ document: customer.cpf,
9216
+ type: 'individual',
9217
+ document_type: 'CPF',
9218
+ address: {
9219
+ line_1: `${customer.billingAddress.number}, ${customer.billingAddress.street}, ${customer.billingAddress.district}`,
9220
+ line_2: `${customer.billingAddress.extension}`,
9221
+ zip_code: customer.billingAddress.zip,
9222
+ city: customer.billingAddress.city,
9223
+ state: customer.billingAddress.state,
9224
+ country: 'BR',
9239
9225
  },
9240
- mobile_phone: {
9241
- country_code: '55',
9242
- number: customer.phone.slice(2),
9243
- area_code: customer.phone.slice(0, 2),
9226
+ birthdate: dateFns.format(customer.birthday, 'MM/dd/yyyy'),
9227
+ phones: {
9228
+ home_phone: {
9229
+ country_code: '55',
9230
+ number: customer.phone.slice(2),
9231
+ area_code: customer.phone.slice(0, 2),
9232
+ },
9233
+ mobile_phone: {
9234
+ country_code: '55',
9235
+ number: customer.phone.slice(2),
9236
+ area_code: customer.phone.slice(0, 2),
9237
+ },
9244
9238
  },
9245
9239
  },
9246
- },
9247
- });
9248
- return data;
9240
+ });
9241
+ return data;
9242
+ }
9243
+ catch (error) {
9244
+ console.warn(error);
9245
+ throw error;
9246
+ }
9249
9247
  }
9250
9248
  }
9251
9249
 
package/index.esm.js CHANGED
@@ -9098,34 +9098,40 @@ class PagarmeV5CardAxiosAdapter {
9098
9098
  }
9099
9099
  }
9100
9100
  async addCard(card, customer) {
9101
- const { id } = await this.createOrUpdateCustomer(customer);
9102
- const { data } = await axios({
9103
- method: 'POST',
9104
- url: `${this.credentials.URL}/customers/${id}/cards`,
9105
- headers: {
9106
- Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
9107
- 'Content-Type': 'application/json',
9108
- },
9109
- data: {
9110
- number: card.number,
9111
- holder_name: card.name,
9112
- holder_document: card.cpf,
9113
- exp_month: card.expirationDate.split('/').at(0),
9114
- exp_year: card.expirationDate.split('/').at(1),
9115
- cvv: card.cvv,
9116
- brand: card.flag,
9117
- label: card.flag,
9118
- billing_address: {
9119
- line_1: `${customer.billindAddress.number}, ${customer.billindAddress.street}, ${customer.billindAddress.district}`,
9120
- line_2: `${customer.billindAddress.extension}`,
9121
- zip_code: customer.billindAddress.zip,
9122
- city: customer.billindAddress.city,
9123
- state: customer.billindAddress.state,
9124
- country: 'BR',
9101
+ try {
9102
+ const { id } = await this.createOrUpdateCustomer(customer);
9103
+ const { data } = await axios({
9104
+ method: 'POST',
9105
+ url: `${this.credentials.URL}/customers/${id}/cards`,
9106
+ headers: {
9107
+ Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
9108
+ 'Content-Type': 'application/json',
9125
9109
  },
9126
- },
9127
- });
9128
- return data;
9110
+ data: {
9111
+ number: card.number,
9112
+ holder_name: card.name,
9113
+ holder_document: card.cpf,
9114
+ exp_month: card.expirationDate.split('/').at(0),
9115
+ exp_year: card.expirationDate.split('/').at(1),
9116
+ cvv: card.cvv,
9117
+ brand: card.flag,
9118
+ label: card.flag,
9119
+ billing_address: {
9120
+ line_1: `${customer.billingAddress.number}, ${customer.billingAddress.street}, ${customer.billingAddress.district}`,
9121
+ line_2: `${customer.billingAddress.extension}`,
9122
+ zip_code: customer.billingAddress.zip,
9123
+ city: customer.billingAddress.city,
9124
+ state: customer.billingAddress.state,
9125
+ country: 'BR',
9126
+ },
9127
+ },
9128
+ });
9129
+ return data;
9130
+ }
9131
+ catch (error) {
9132
+ console.warn(error);
9133
+ throw error;
9134
+ }
9129
9135
  }
9130
9136
  async createCardHash(bu, shop) {
9131
9137
  const credentials = shop && shop == Shops.MENSMARKET ? this.credentials[Shops.MENSMARKET] : this.credentials[Shops.GLAMSHOP];
@@ -9169,58 +9175,50 @@ class PagarmeV5CardAxiosAdapter {
9169
9175
  async createTransaction(info) {
9170
9176
  return info;
9171
9177
  }
9172
- // async getCustomerByCpf(cpf: string) {
9173
- // const { data }: { data: any } = await axios({
9174
- // method: 'GET',
9175
- // url: `${this.credentials.URL}/customers`,
9176
- // headers: {
9177
- // Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
9178
- // 'Content-Type': 'application/json',
9179
- // },
9180
- // params: {
9181
- // document: cpf,
9182
- // },
9183
- // })
9184
- // return data
9185
- // }
9186
9178
  async createOrUpdateCustomer(customer) {
9187
- const { data } = await axios({
9188
- method: 'POST',
9189
- url: `${this.credentials.URL}/customers`,
9190
- headers: {
9191
- Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
9192
- 'Content-Type': 'application/json',
9193
- },
9194
- data: {
9195
- name: customer.displayName,
9196
- email: customer.email,
9197
- document: customer.cpf,
9198
- type: 'individual',
9199
- document_type: 'CPF',
9200
- address: {
9201
- line_1: `${customer.billindAddress.number}, ${customer.billindAddress.street}, ${customer.billindAddress.district}`,
9202
- line_2: `${customer.billindAddress.extension}`,
9203
- zip_code: customer.billindAddress.zip,
9204
- city: customer.billindAddress.city,
9205
- state: customer.billindAddress.state,
9206
- country: 'BR',
9179
+ try {
9180
+ const { data } = await axios({
9181
+ method: 'POST',
9182
+ url: `${this.credentials.URL}/customers`,
9183
+ headers: {
9184
+ Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
9185
+ 'Content-Type': 'application/json',
9207
9186
  },
9208
- birthdate: format(customer.birthday, 'mm/dd/AAAA'),
9209
- phones: {
9210
- home_phone: {
9211
- country_code: '55',
9212
- number: customer.phone.slice(2),
9213
- area_code: customer.phone.slice(0, 2),
9187
+ data: {
9188
+ name: customer.displayName,
9189
+ email: customer.email,
9190
+ document: customer.cpf,
9191
+ type: 'individual',
9192
+ document_type: 'CPF',
9193
+ address: {
9194
+ line_1: `${customer.billingAddress.number}, ${customer.billingAddress.street}, ${customer.billingAddress.district}`,
9195
+ line_2: `${customer.billingAddress.extension}`,
9196
+ zip_code: customer.billingAddress.zip,
9197
+ city: customer.billingAddress.city,
9198
+ state: customer.billingAddress.state,
9199
+ country: 'BR',
9214
9200
  },
9215
- mobile_phone: {
9216
- country_code: '55',
9217
- number: customer.phone.slice(2),
9218
- area_code: customer.phone.slice(0, 2),
9201
+ birthdate: format(customer.birthday, 'MM/dd/yyyy'),
9202
+ phones: {
9203
+ home_phone: {
9204
+ country_code: '55',
9205
+ number: customer.phone.slice(2),
9206
+ area_code: customer.phone.slice(0, 2),
9207
+ },
9208
+ mobile_phone: {
9209
+ country_code: '55',
9210
+ number: customer.phone.slice(2),
9211
+ area_code: customer.phone.slice(0, 2),
9212
+ },
9219
9213
  },
9220
9214
  },
9221
- },
9222
- });
9223
- return data;
9215
+ });
9216
+ return data;
9217
+ }
9218
+ catch (error) {
9219
+ console.warn(error);
9220
+ throw error;
9221
+ }
9224
9222
  }
9225
9223
  }
9226
9224
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "5.1.0-beta.12",
3
+ "version": "5.1.0-beta.14",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -9,10 +9,13 @@ import { BaseCard } from '../types/base-card.type';
9
9
  export interface PaymentProviderCard<Card extends BaseCard = BaseCard> {
10
10
  pay(checkout: Checkout, card: PaymentCardInfo): Promise<Payment>;
11
11
  addCard?(card: CardInfo, customer: User & {
12
- billindAddress: Partial<UserAddress>;
12
+ billingAddress: Partial<UserAddress>;
13
13
  }): Promise<Card>;
14
14
  getCardByToken(token: string): Promise<Card>;
15
15
  getCardByToken(customerId: string, token: string): Promise<Card>;
16
16
  createCardHash<T>(bu: BusinessUnitEnum, shop: Shops, card?: CardInfo): Promise<string | T>;
17
17
  createTransaction(info: any): Promise<PaymentTransaction>;
18
+ createOrUpdateCustomer?(customer: User & {
19
+ billingAddress: Partial<UserAddress>;
20
+ }): any;
18
21
  }
@@ -12,13 +12,13 @@ export declare class PagarmeV5CardAxiosAdapter implements PaymentProviderCard<Pa
12
12
  constructor(credentials: PagarmeCredentialsV5, paymentRepository: PaymentRepository, orderBlockedRepository: OrderBlockedRepository);
13
13
  pay(checkout: Checkout, card: PaymentCardInfo): Promise<Payment>;
14
14
  addCard(card: CardInfo, customer: User & {
15
- billindAddress: Partial<UserAddress>;
15
+ billingAddress: Partial<UserAddress>;
16
16
  }): Promise<PagarMeCard>;
17
17
  createCardHash<PagarMeCardManualHash>(bu: BusinessUnitEnum, shop?: Shops): Promise<PagarMeCardManualHash>;
18
18
  getCardByToken(token: string): Promise<PagarMeCard>;
19
19
  getCardByToken(customerId: string, token: string): Promise<PagarMeCard>;
20
20
  createTransaction(info: any): Promise<PaymentTransaction>;
21
21
  createOrUpdateCustomer(customer: User & {
22
- billindAddress: Partial<UserAddress>;
22
+ billingAddress: Partial<UserAddress>;
23
23
  }): Promise<PagarMeV5Customer>;
24
24
  }