Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ Se implementa primero db ya que el contenedor de la API en si depende de ella.
## Funcionamiento
Para realizar las acciones de la api basta con utilizar [Postman](https://www.postman.com/downloads/)

Si se quiere utilizar para pruebas en desarrollo o producción es necesario realizar cambios a las variables a utilizar en el archivo `src\payments\payments.controller.ts`
Las variables son:
```bash
URL_TOKEN_DEV <--> URL_TOKEN_PROD
URL_GET_PAYMENT_DEV <--> URL_GET_PAYMENT_PROD
URL_GET_PAYMENT_DEV <--> URL_GET_PAYMENT_PROD
```
Si se quiere utilizar para pruebas en desarrollo o producción es necesario cambiar de rama del repositorio, main correspondiente a producción y dev correspondiente a desarrollo

### Métodos
- Post:
Expand Down
9 changes: 3 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ services:
- DB_USERNAME=postgres
- DB_PASSWORD=postgres
- DATABASE=postgres
- URL_TOKEN_DEV=https://dev.developers-test.currencybird.cl/token?email=
- URL_GET_PAYMENT_DEV=https://dev.developers-test.currencybird.cl/getPayment?email=
- URL_MAKE_PAYMENT_DEV=https://dev.developers-test.currencybird.cl/payment?email=
- URL_TOKEN_PROD=https://prod.developers-test.currencybird.cl/token?email=
- URL_GET_PAYMENT_PROD=https://prod.developers-test.currencybird.cl/payment?email=
- URL_MAKE_PAYMENT_PROD=https://prod.developers-test.currencybird.cl/payment?email=
- URL_TOKEN=https://dev.developers-test.currencybird.cl/token?email=
- URL_GET_PAYMENT=https://dev.developers-test.currencybird.cl/getPayment?email=
- URL_MAKE_PAYMENT=https://dev.developers-test.currencybird.cl/payment?email=
depends_on:
- db
db:
Expand Down
7 changes: 4 additions & 3 deletions src/payments/payments.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class PaymentsController {
throw new InternalServerErrorException('Payment not made')
}
} catch (error) {
console.log(error);
throw new BadRequestException('Data respose: "'+error.response.data+'" Status response: '+error.response.status+' Status text: '+error.response.statusText+' Config URL: '+error.response.config.url+' Config method: '+error.response.config.method+' Config headers: '+error.response.config.headers+' Config data: '+error.response.config.data);
}
}
Expand Down Expand Up @@ -78,7 +79,7 @@ export class PaymentsController {

async getToken(email: string): Promise<string> {
try {
const response = await axios.get(process.env.URL_TOKEN_PROD+email)
const response = await axios.get(process.env.URL_TOKEN+email)
const data = response.data;
return data;
} catch (error) {
Expand All @@ -88,7 +89,7 @@ export class PaymentsController {

async getPayment(token: string, transferCode: string, email: string): Promise<string> {
try {
const response = await axios.get(process.env.URL_GET_PAYMENT_PROD+email+'&transferCode='+transferCode,{
const response = await axios.get(process.env.URL_GET_PAYMENT+email+'&transferCode='+transferCode,{
headers: {
'Authorization': token
}
Expand All @@ -107,7 +108,7 @@ export class PaymentsController {
}
console.log(data_payment);
try {
const response = await axios.post(process.env.URL_MAKE_PAYMENT_PROD+email+'&transferCode='+transferCode,data_payment,{
const response = await axios.post(process.env.URL_MAKE_PAYMENT+email+'&transferCode='+transferCode,data_payment,{
headers: {
'Authorization': token,
'Content-Type': 'application/json'
Expand Down