@infrab4a/connect 5.1.0-beta.11 → 5.1.0-beta.12
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 +83 -3
- package/index.esm.js +83 -3
- package/package.json +1 -1
- package/src/domain/shopping/interfaces/payment-provider-card.interface.d.ts +4 -1
- package/src/domain/shopping/types/card-info.type.d.ts +1 -0
- package/src/infra/pagarme/adapters/v5/pagarmev5-card-payment-axios.adapter.d.ts +10 -4
- package/src/infra/pagarme/types/v5/index.d.ts +1 -0
- package/src/infra/pagarme/types/v5/pagarmev5-customer.type.d.ts +19 -0
- package/src/infra/pagarme/types/v5/pagarmev5-postback-response.type.d.ts +1 -1
package/index.cjs.js
CHANGED
|
@@ -9122,8 +9122,35 @@ class PagarmeV5CardAxiosAdapter {
|
|
|
9122
9122
|
throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, error.response?.data);
|
|
9123
9123
|
}
|
|
9124
9124
|
}
|
|
9125
|
-
async addCard(card) {
|
|
9126
|
-
|
|
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',
|
|
9150
|
+
},
|
|
9151
|
+
},
|
|
9152
|
+
});
|
|
9153
|
+
return data;
|
|
9127
9154
|
}
|
|
9128
9155
|
async createCardHash(bu, shop) {
|
|
9129
9156
|
const credentials = shop && shop == exports.Shops.MENSMARKET ? this.credentials[exports.Shops.MENSMARKET] : this.credentials[exports.Shops.GLAMSHOP];
|
|
@@ -9165,7 +9192,60 @@ class PagarmeV5CardAxiosAdapter {
|
|
|
9165
9192
|
}
|
|
9166
9193
|
}
|
|
9167
9194
|
async createTransaction(info) {
|
|
9168
|
-
return;
|
|
9195
|
+
return info;
|
|
9196
|
+
}
|
|
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
|
+
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',
|
|
9232
|
+
},
|
|
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),
|
|
9239
|
+
},
|
|
9240
|
+
mobile_phone: {
|
|
9241
|
+
country_code: '55',
|
|
9242
|
+
number: customer.phone.slice(2),
|
|
9243
|
+
area_code: customer.phone.slice(0, 2),
|
|
9244
|
+
},
|
|
9245
|
+
},
|
|
9246
|
+
},
|
|
9247
|
+
});
|
|
9248
|
+
return data;
|
|
9169
9249
|
}
|
|
9170
9250
|
}
|
|
9171
9251
|
|
package/index.esm.js
CHANGED
|
@@ -9097,8 +9097,35 @@ class PagarmeV5CardAxiosAdapter {
|
|
|
9097
9097
|
throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, error.response?.data);
|
|
9098
9098
|
}
|
|
9099
9099
|
}
|
|
9100
|
-
async addCard(card) {
|
|
9101
|
-
|
|
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',
|
|
9125
|
+
},
|
|
9126
|
+
},
|
|
9127
|
+
});
|
|
9128
|
+
return data;
|
|
9102
9129
|
}
|
|
9103
9130
|
async createCardHash(bu, shop) {
|
|
9104
9131
|
const credentials = shop && shop == Shops.MENSMARKET ? this.credentials[Shops.MENSMARKET] : this.credentials[Shops.GLAMSHOP];
|
|
@@ -9140,7 +9167,60 @@ class PagarmeV5CardAxiosAdapter {
|
|
|
9140
9167
|
}
|
|
9141
9168
|
}
|
|
9142
9169
|
async createTransaction(info) {
|
|
9143
|
-
return;
|
|
9170
|
+
return info;
|
|
9171
|
+
}
|
|
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
|
+
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',
|
|
9207
|
+
},
|
|
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),
|
|
9214
|
+
},
|
|
9215
|
+
mobile_phone: {
|
|
9216
|
+
country_code: '55',
|
|
9217
|
+
number: customer.phone.slice(2),
|
|
9218
|
+
area_code: customer.phone.slice(0, 2),
|
|
9219
|
+
},
|
|
9220
|
+
},
|
|
9221
|
+
},
|
|
9222
|
+
});
|
|
9223
|
+
return data;
|
|
9144
9224
|
}
|
|
9145
9225
|
}
|
|
9146
9226
|
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Shops } from '../../catalog';
|
|
2
|
+
import { User, UserAddress } from '../../users';
|
|
2
3
|
import { BusinessUnitEnum } from '../enums';
|
|
3
4
|
import { PaymentTransaction } from '../models';
|
|
4
5
|
import { Checkout } from '../models/checkout';
|
|
@@ -7,7 +8,9 @@ import { CardInfo, PaymentCardInfo } from '../types';
|
|
|
7
8
|
import { BaseCard } from '../types/base-card.type';
|
|
8
9
|
export interface PaymentProviderCard<Card extends BaseCard = BaseCard> {
|
|
9
10
|
pay(checkout: Checkout, card: PaymentCardInfo): Promise<Payment>;
|
|
10
|
-
addCard(card: CardInfo
|
|
11
|
+
addCard?(card: CardInfo, customer: User & {
|
|
12
|
+
billindAddress: Partial<UserAddress>;
|
|
13
|
+
}): Promise<Card>;
|
|
11
14
|
getCardByToken(token: string): Promise<Card>;
|
|
12
15
|
getCardByToken(customerId: string, token: string): Promise<Card>;
|
|
13
16
|
createCardHash<T>(bu: BusinessUnitEnum, shop: Shops, card?: CardInfo): Promise<string | T>;
|
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
import { Shops } from '../../../../domain';
|
|
1
|
+
import { Shops, User, UserAddress } from '../../../../domain';
|
|
2
2
|
import { BusinessUnitEnum } from '../../../../domain/shopping/enums';
|
|
3
3
|
import { PaymentProviderCard } from '../../../../domain/shopping/interfaces';
|
|
4
4
|
import { Checkout, Payment, PaymentTransaction } from '../../../../domain/shopping/models';
|
|
5
5
|
import { OrderBlockedRepository, PaymentRepository } from '../../../../domain/shopping/repositories';
|
|
6
|
-
import { CardInfo, PagarMeCard,
|
|
6
|
+
import { CardInfo, PagarMeCard, PagarmeCredentialsV5, PaymentCardInfo } from '../../../../domain/shopping/types';
|
|
7
|
+
import { PagarMeV5Customer } from '../../types';
|
|
7
8
|
export declare class PagarmeV5CardAxiosAdapter implements PaymentProviderCard<PagarMeCard> {
|
|
8
9
|
private credentials;
|
|
9
10
|
private paymentRepository;
|
|
10
11
|
private orderBlockedRepository;
|
|
11
|
-
constructor(credentials:
|
|
12
|
+
constructor(credentials: PagarmeCredentialsV5, paymentRepository: PaymentRepository, orderBlockedRepository: OrderBlockedRepository);
|
|
12
13
|
pay(checkout: Checkout, card: PaymentCardInfo): Promise<Payment>;
|
|
13
|
-
addCard(card: CardInfo
|
|
14
|
+
addCard(card: CardInfo, customer: User & {
|
|
15
|
+
billindAddress: Partial<UserAddress>;
|
|
16
|
+
}): Promise<PagarMeCard>;
|
|
14
17
|
createCardHash<PagarMeCardManualHash>(bu: BusinessUnitEnum, shop?: Shops): Promise<PagarMeCardManualHash>;
|
|
15
18
|
getCardByToken(token: string): Promise<PagarMeCard>;
|
|
16
19
|
getCardByToken(customerId: string, token: string): Promise<PagarMeCard>;
|
|
17
20
|
createTransaction(info: any): Promise<PaymentTransaction>;
|
|
21
|
+
createOrUpdateCustomer(customer: User & {
|
|
22
|
+
billindAddress: Partial<UserAddress>;
|
|
23
|
+
}): Promise<PagarMeV5Customer>;
|
|
18
24
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type PagarMeV5Customer = {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
email: string;
|
|
5
|
+
code: string;
|
|
6
|
+
document: string;
|
|
7
|
+
document_type: string;
|
|
8
|
+
type: string;
|
|
9
|
+
gender: string;
|
|
10
|
+
delinquent: boolean;
|
|
11
|
+
address: {
|
|
12
|
+
line_1: string;
|
|
13
|
+
line_2: string;
|
|
14
|
+
zip_code: string;
|
|
15
|
+
city: string;
|
|
16
|
+
state: string;
|
|
17
|
+
country: string;
|
|
18
|
+
};
|
|
19
|
+
};
|