# Nuevos lineamientos para los microservicios
## Contenido
[microservicio blacklist](#BLACKLIST)
[nanoservicio card hasher](#CARD-HASHER)
[microservicio tokens](#TOKENS)
[microservicio geolocation](#GEOLOCATION)
[microservicio bin](#BIN)
[microservicio card data](#CARD-DATA)
[microservicio orquestino](#ORQUESTINO)
# ORQUESTINO
#### request `POST` `orquestino/tokens`
- `metadata` es opcional
```json
{
"meta":{
"traceId":"123",
"timestamp":"2019-08-14T10:36:00.123Z-0500",
"serviceId":"agw-default",
"ip":"161.132.125.10",
"path":"/tokens",
"method":"post"
},
"data":{
"cardNumber":"4111111111111111",
"expirationMonth":"09",
"expirationYear":"2020",
"email":"richard@piedpiper.com",
"cvv":"123",
"metadata":{
"dni":"12345673"
}
}
}
```
#### response status code **200**
```json
{
"meta": {
"traceId": "123",
"timestamp": "2019-09-05T17:57:41.346Z-0500",
"serviceId": "or-tokenq37RdZH6EG5cNt",
"ip": "::1",
"path": "/tokens",
"method": "POST"
},
"data": {
"object": "token",
"type": "card",
"email": "richard@piedpiper.com",
"creation_date": "",
"card_number": "411111******1111",
"last_four": "1111",
"active": "",
"iin": {
"object": "iin",
"bin": "411111",
"cardBrand": "VISA",
"cardType": "CREDIT",
"cardCategory": "",
"issuer": {
"name": "JPMORGAN CHASE BANK, N.A.",
"country": "UNITED STATES",
"countryCode": "US",
"website": "http://www.jpmorganchase.com",
"phoneNumber": "1-212-270-6000"
},
"installmentsAllowed": [2,4,8,12,24,42]
},
"client": {
"ip": "72.229.28.185",
"ip_country": "United States",
"ip_country_code": "US",
"browser": "Google Chrome 56.0.2924.87",
"device_fingerprint": "6rITdVTYkWfOrss8",
"device_type": "escritorio"
},
"metadata": {
"dni":"5831543"
}
}
}
````
# CARD HASHER
#### request `POST` `card-hasher/`
```json
{
"meta": {
"traceId": "123",
"timestamp": "",
"serviceId": "or-tokens" # caller <- package.json
},
"data": {
"cardNumber": "4444333322221111"
}
}
```
#### response status code **200**
```json
{
"meta": {
"traceId": "123321",
"timestamp": "2019-08-23T15:20:01.499Z-0500",
"serviceId": "42d3fDaHQhg8Xp"
},
"data": {
"hash": "c8f50254f0ae62604a179d9c292720afb1236a4f88ae10bd814eb619cdc5ee50",
"mask": "455788******1530",
"bin": "455788",
"lastFour": "1530"
}
}
```
# BLACKLIST
- Durante la generación del token se puede invocar dos veces a este ms.
#### request 1 `POST` `blacklist/validate`
```json
{
"meta": {
"traceId": "1234567890",
"timestamp": "2019-08-20T14:06:02.271Z-0500",
"serviceId": "4XpndaSBMngQXu"
},
"data": {
"array": [
{
"subject":"email",
"value":"christos.otarola@culqi.com"
},
{
"subject":"cardHash",
"value":"g88f7dg9sdfy7g9sf78oyg8aohs88sy98xf7azd9"
},
{
"subject":"bin",
"value":"444433"
}
]
}
}
```
#### request 2 `POST` `blacklist/validate`
```json
{
"meta": {
"traceId": "1234567890",
"timestamp": "2019-08-20T14:06:02.271Z-0500",
"serviceId": "4XpndaSBMngQXu"
},
"data": {
"array": [
{
"subject": "country",
"value": "UNITED STATES"
},
{
"subject": "issuer",
"value": "JPMORGAN CHASE BANK, N.A."
},
{
"subject": "cardBrand",
"value": "VISA"
}
]
}
}
````
#### Response status code **200**
- la respuesta varía de acuerdo a los datos enviados
```json
{
"meta": {
"traceId": "1234567890",
"timestamp": "2019-09-05T17:17:40.027Z-0500",
"serviceId": "ms-blacklist"
},
"data": {
"subject": "country",
"value": "UNITED STATES",
"match": false
}
}
```
#### Request `POST` `blacklist/bulk`
- carga masiva
- `data1`, `data2`, `data3` es el nombre del colección a agregar, desde 1 o más colecciones
- los datos dentro del array son los datos para esa nueva colección
```json
{
"meta": {
"traceId": "123321",
"timestamp": "2019-09-15T11:13:20.123Z-0500",
"serviceId": "asdasdsad"
},
"data": {
"data1": [
"emerson.beltran@culqi.com",
"emerson.beltran@stripe.com"
],
"data2": [
"873612334",
"645823446"
],
"data3": [
"873612334",
"645823446"
]
}
}
```
#### response status code **200**
```json
{
"meta": {
"traceId": "1234567890",
"timestamp": "2019-08-20T14:06:02.271Z-0500",
"serviceId": "4XpndaSBMngQXu"
},
"data": {
"message": "ok"
}
}
```
# BIN
- Los `installmentsAllowed` no se obtiene de la comunicación con `neutrino`
- path: `post` y `patch`
#### request `POST` `bin/`
```json
{
"meta": {
"timestamp": "2019-08-20T12:16:32.942Z-0500",
"serviceId": "4XpndaSBMngQXu",
"traceId": "1234567890"
},
"data": {
"binNumber":"455788"
}
}
```
#### response status code **200**
```json
{
"meta": {
"traceId": "1234567890",
"timestamp": "2019-09-05T17:24:34.113Z-0500",
"serviceId": "aua9nEMDM7JujB"
},
"data": {
"installmentsAllowed": [],
"country": "PERU",
"countryCode": "PE",
"cardType": "DEBIT",
"cardBrand": "VISA",
"cardCategory": "GOLD",
"issuerPhone": "311-9898",
"currencyCode": "PEN",
"countryCode3": "PER",
"issuer": "BANCO DE CREDITO DEL PERU",
"issuerWebsite": "http://www.viabcp.com/",
"binNumber": "455788"
}
}
```
#### request `PATCH` `bin/{bin}`
- actualización de cualquier dato actual vía `bin`
```json
{
"meta": {
"timestamp": "2019-08-20T12:16:32.942Z-0500",
"serviceId": "4XpndaSBMngQXu",
"traceId": "1234567890"
},
"data": {
"installmentsAllowed": [
2,
4,
8,
12,
24,
42
]
}
}
```
#### response status code **200**
```json
{
"meta": {
"traceId": "1234567890",
"timestamp": "2019-09-05T17:24:34.113Z-0500",
"serviceId": "aua9nEMDM7JujB"
},
"data": {
"installmentsAllowed": [
2,
4,
8,
12,
24,
42
]
"country": "PERU",
"countryCode": "PE",
"cardType": "DEBIT",
"cardBrand": "VISA",
"cardCategory": "GOLD",
"issuerPhone": "311-9898",
"currencyCode": "PEN",
"countryCode3": "PER",
"issuer": "BANCO DE CREDITO DEL PERU",
"issuerWebsite": "http://www.viabcp.com/",
"binNumber": "455788"
}
}
```
#### request `POST` `bin/bulk`
```json
{
"meta": {
"traceId": "123321",
"timestamp": "2019-09-15T11:13:20.123Z-0500",
"serviceId": "asdasdsad"
},
"data": {
"binCards": [
{
"binNumber": "447409",
"country": "PERU2",
"countryCode": "PE",
"cardType": "CREDIT",
"cardBrand": "VISA",
"cardCategory": "CLASSIC",
"issuerPhone": "51-1-6180000",
"currencyCode": "PEN",
"countryCode3": "PER",
"issuer": "BANCO FALABELLA PERU, S.A.",
"issuerWebsite": ""
}, {
"binNumber": "455788",
"country": "PERU",
"countryCode": "PE",
"cardType": "DEBIT",
"cardBrand": "VISA",
"cardCategory": "GOLD",
"issuerPhone": "311-9898",
"currencyCode": "PEN",
"countryCode3": "PER",
"issuer": "BANCO DE CREDITO DEL PERU",
"issuerWebsite": "http://www.viabcp.com/"
}
]
}
}
```
#### response status code **200**
```json
{
"meta": {
"traceId": "1234567890",
"timestamp": "2019-08-20T14:06:02.271Z-0500",
"serviceId": "4XpndaSBMngQXu"
},
"data": {
"message": "ok"
}
}
```
# GEOLOCATION
- path: `post` y `patch`
#### request`POST` `geolocation/`
```json
{
"meta": {
"timestamp": "2019-08-20T12:16:32.942Z-0500",
"serviceId": "4XpndaSBMngQXu",
"traceId": "1234567890"
},
"data": {
"ip":"179.60.193.3"
}
}
```
#### response status code 200
```json
{
"meta": {
"traceId": "1234567890",
"timestamp": "2019-08-20T14:06:02.271Z-0500",
"serviceId": "4XpndaSBMngQXu"
},
"data": {
"ip": "179.60.193.3",
"country": "United States",
"countryCode": "US"
}
}
```
#### request `PATCH` `geolocation/{ip}`
- actualización de cualquier dato actual vía `ip`
```json
{
"meta": {
"timestamp": "2019-08-20T12:16:32.942Z-0500",
"serviceId": "4XpndaSBMngQXu",
"traceId": "1234567890"
},
"data": {
"country":"VENEZUELA"
}
}
```
#### response status code **200**
```json
{
"meta": {
"traceId": "1234567890",
"timestamp": "2019-08-20T14:06:02.271Z-0500",
"serviceId": "4XpndaSBMngQXu"
},
"data": {
"ip": "179.60.193.3",
"country": "VENEZUELA",
"countryCode": "US"
}
}
```
#### request `POST` `geolocation/bulk`
- carga masiva
```json
{
"meta": {
"traceId": "123321",
"timestamp": "2019-09-15T11:13:20.123Z-0500",
"serviceId": "asdasdsad"
},
"data": {
"records": [
{
"ip": "161.132.125.10",
"country": "Peru",
"countryCode": "PE"
}, {
"ip": "181.224.246.2",
"country": "Venezuela",
"countryCode": "PE"
}
]
}
}
```
#### response status code **200**
```json
{
"meta": {
"traceId": "1234567890",
"timestamp": "2019-08-20T14:06:02.271Z-0500",
"serviceId": "4XpndaSBMngQXu"
},
"data": {
"message": "ok"
}
}
```
# CARD DATA
#### request `POST` `card-data/set`
```json
{
"meta": {
"traceId": "123",
"timestamp": "2019-08-14T10:36:00.123Z-0500",
"serviceId": "or-tokens"
},
"data": {
"token": "tkn_live_87f6d9g7sdfsg6f8",
"card":{
"cardNumber": "4444333322221111",
"cvv": "005",
"expirationMonth": "10",
"expirationYear": "2020"
}
}
}
````
#### response status code 200
```json
{
"meta": {
"traceId": "123",
"timestamp": "2019-08-26T16:34:41.595Z-0500",
"serviceId": "ms-tokenizer"
},
"data": {
"message": "ok"
}
}
```
# TOKENS
#### request `POST` `tokens/tokens`
```json
{
"meta":{
"traceId": "uy26t12he",
"timestamp": "2019-08-16T14:45:43.060Z-0500",
"serviceId": "postman"
},
"data": {
"token": "tkn_live_b762eyhdkjlkjdlac" ,
"cardHash": "BHGSIHLSJÑLKHDSDS",
"object": "token",
"type": "token",
"mask": "444411******1111",
"bin": "444411",
"lastFour":"1111"
}
}
````
#### response status code 200
```json
{
"meta": {
"traceId": "uy26t12he",
"timestamp": "2019-08-26T16:01:28.723Z-0500",
"serviceId": "ms-tokens"
},
"data": {
"cardHash": "BHGSIHLSJÑLKHDSDS",
"object": "token",
"type": "token",
"mask": "444411******1111",
"bin": "444411",
"lastFour": "1111",
"_id": "tkn_live_b762eyhdkjlkjdlac",
"createdAt": "2019-08-26T21:01:28.608Z",
"updatedAt": "2019-08-26T21:01:28.608Z",
"__v": 0
}
}
```