@infrab4a/connect 5.1.0-beta.13 → 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,20 +9200,6 @@ 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
9204
  try {
9213
9205
  const { data } = await axios__default["default"]({
@@ -9224,11 +9216,11 @@ class PagarmeV5CardAxiosAdapter {
9224
9216
  type: 'individual',
9225
9217
  document_type: 'CPF',
9226
9218
  address: {
9227
- line_1: `${customer.billindAddress.number}, ${customer.billindAddress.street}, ${customer.billindAddress.district}`,
9228
- line_2: `${customer.billindAddress.extension}`,
9229
- zip_code: customer.billindAddress.zip,
9230
- city: customer.billindAddress.city,
9231
- state: customer.billindAddress.state,
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,
9232
9224
  country: 'BR',
9233
9225
  },
9234
9226
  birthdate: dateFns.format(customer.birthday, 'MM/dd/yyyy'),
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,20 +9175,6 @@ 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
9179
  try {
9188
9180
  const { data } = await axios({
@@ -9199,11 +9191,11 @@ class PagarmeV5CardAxiosAdapter {
9199
9191
  type: 'individual',
9200
9192
  document_type: 'CPF',
9201
9193
  address: {
9202
- line_1: `${customer.billindAddress.number}, ${customer.billindAddress.street}, ${customer.billindAddress.district}`,
9203
- line_2: `${customer.billindAddress.extension}`,
9204
- zip_code: customer.billindAddress.zip,
9205
- city: customer.billindAddress.city,
9206
- state: customer.billindAddress.state,
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,
9207
9199
  country: 'BR',
9208
9200
  },
9209
9201
  birthdate: format(customer.birthday, 'MM/dd/yyyy'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "5.1.0-beta.13",
3
+ "version": "5.1.0-beta.14",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -9,13 +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
- billindAddress: Partial<UserAddress>;
18
+ createOrUpdateCustomer?(customer: User & {
19
+ billingAddress: Partial<UserAddress>;
20
20
  }): any;
21
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
  }