Skip to content

Commit 4783a80

Browse files
committed
fix(paghiper): Fix reading PagHiper notifications on webhooks process
1 parent e637b5f commit 4783a80

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

packages/apps/paghiper/src/functions-lib/create-axios.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ export default (isPix?: boolean) => axios.create({
88
: 'https://api.paghiper.com/',
99
headers: {
1010
'Content-Type': 'application/json;charset=UTF-8',
11-
Accept: 'application/json',
11+
'Accept': 'application/json',
1212
'Accept-Charset': 'UTF-8',
1313
'Accept-Encoding': 'application/json',
1414
},
1515
// wait up to 30s
1616
timeout: 30000,
1717
validateStatus(status) {
18-
// success only when received 201
19-
return status === 201;
18+
return status === 200 || status === 201;
2019
},
2120
});

packages/apps/paghiper/src/functions-lib/handle-webhook.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { Request, Response } from 'firebase-functions/v1';
33
import api from '@cloudcommerce/api';
44
import { Endpoint } from '@cloudcommerce/api/types';
55
import config, { logger } from '@cloudcommerce/firebase/lib/config';
6-
import Axios from './create-axios';
6+
import createAxios from './create-axios';
77

88
const { apps } = config.get();
99

@@ -24,7 +24,7 @@ const readNotification = async (readNotificationBody: { [x: string]: any }, isPi
2424
// https://dev.paghiper.com/reference#qq
2525
// returns request promise
2626
const endpoint = `/${(isPix ? 'invoice' : 'transaction')}/notification/`;
27-
const { data } = await Axios(isPix).post(endpoint, readNotificationBody);
27+
const { data } = await createAxios(isPix).post(endpoint, readNotificationBody);
2828
return data;
2929
};
3030

packages/apps/paghiper/src/paghiper-create-transaction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type {
55
} from '@cloudcommerce/types';
66
import type { PagHiperApp } from '../types/config-app';
77
import config, { logger } from '@cloudcommerce/firebase/lib/config';
8-
import axios from './functions-lib/create-axios';
8+
import createAxios from './functions-lib/create-axios';
99

1010
type ItemsPagHiper = {
1111
description: string,
@@ -37,7 +37,7 @@ const createTransactionPagHiper = async (
3737
// returns request promise
3838
const endpoint = `/${(isPix ? 'invoice' : 'transaction')}/create/`;
3939
return new Promise((resolve, reject) => {
40-
axios(isPix).post(endpoint, body)
40+
createAxios(isPix).post(endpoint, body)
4141
.then(({ data }) => {
4242
// save transaction ID on database first
4343
let createRequest: any;

0 commit comments

Comments
 (0)