├── src ├── interfaces │ ├── endpoint.interface.ts │ ├── gnCredentials.interface.ts │ └── gnConfig.interface.ts ├── auth.ts ├── endpoints.ts └── constants.ts ├── jest.config.js ├── .npmignore ├── .gitignore ├── .prettierrc.json ├── examples ├── package.json ├── credentials.ts ├── exclusives │ ├── key │ │ ├── pixListEvp.ts │ │ ├── pixCreateEvp.ts │ │ └── pixDeleteEvp.ts │ ├── account │ │ ├── getAccountBalance.ts │ │ ├── listAccountConfig.ts │ │ └── updateAccountConfig.ts │ └── report │ │ ├── detailReport.ts │ │ └── createReport.ts ├── open-finance │ ├── config │ │ ├── ofConfigDetail.ts │ │ └── ofConfigUpdate.ts │ ├── participants │ │ └── ofListParticipants.ts │ └── payment │ │ ├── ofListPixPayment.ts │ │ ├── ofDevolutionPix.ts │ │ └── ofStartPixPayment.ts ├── charges │ ├── card │ │ ├── cancelCard.ts │ │ ├── detailCard.ts │ │ ├── getInstallments.ts │ │ ├── createCardHistory.ts │ │ ├── updateCardMetadata.ts │ │ ├── createCharge.ts │ │ ├── defineCardPayMethod.ts │ │ └── createOneStepCard.ts │ ├── billet │ │ ├── detailBillet.ts │ │ ├── settleBillet.ts │ │ ├── cancelBillet.ts │ │ ├── updateBillet.ts │ │ ├── sendBilletEmail.ts │ │ ├── createBilletHistory.ts │ │ ├── updateBilletMetadata.ts │ │ ├── createCharge.ts │ │ ├── defineBilletPayMethod.ts │ │ ├── createOneStepBillet.ts │ │ └── defineBalanceSheetBillet.ts │ ├── carnet │ │ ├── cancelCarnet.ts │ │ ├── detailCarnet.ts │ │ ├── settleCarnet.ts │ │ ├── cancelCarnetParcel.ts │ │ ├── settleCarnetParcel.ts │ │ ├── sendCarnetEmail.ts │ │ ├── updateCarnetParcel.ts │ │ ├── createCarnetHistory.ts │ │ ├── sendCarnetParcelEmail.ts │ │ ├── updateCarnetMetadata.ts │ │ └── createCarnet.ts │ ├── payment-link │ │ ├── cancelLink.ts │ │ ├── detailLink.ts │ │ ├── sendLinkEmail.ts │ │ ├── createChargeLinkHistory.ts │ │ ├── updateLinkMetadata.ts │ │ ├── createCharge.ts │ │ ├── updateLink.ts │ │ ├── defineLinkPayMethod.ts │ │ └── createOneStepLink.ts │ ├── subscription │ │ ├── deletePlan.ts │ │ ├── cancelSubscription.ts │ │ ├── detailSubscription.ts │ │ ├── listPlans.ts │ │ ├── updatePlan.ts │ │ ├── createPlan.ts │ │ ├── sendSubscriptionLinkEmail.ts │ │ ├── createSubscriptionHistory.ts │ │ ├── updateSubscriptionMetadata.ts │ │ ├── createOneStepSubscriptionLink.ts │ │ ├── defineSubscriptionBillet.ts │ │ ├── createCharge.ts │ │ ├── createOneStepBilletSubscription.ts │ │ ├── defineSubscriptionCard.ts │ │ └── createOneStepCardSubscription.ts │ ├── notification │ │ └── getNotification.ts │ └── marketplace │ │ ├── createOneStepBilletMarketplace.ts │ │ └── createOneStepCardMarketplace.ts ├── pix │ ├── send │ │ ├── pixSendDetail.ts │ │ ├── pixSendList.ts │ │ └── pixSend.ts │ ├── location │ │ ├── pixDetailLocation.ts │ │ ├── pixGenerateQRCode.ts │ │ ├── pixCreateLocation.ts │ │ ├── pixUnlinkTxidLocation.ts │ │ └── pixLocationList.ts │ ├── webhooks │ │ ├── pixDeleteWebhook.ts │ │ ├── pixDetailWebhook.ts │ │ ├── pixListWebhook.ts │ │ └── pixConfigWebhook.ts │ ├── cob │ │ ├── pixDetailCharge.ts │ │ ├── pixListCharges.ts │ │ ├── pixCreateImmediateCharge.ts │ │ ├── pixCreateCharge.ts │ │ └── pixUpdateCharge.ts │ ├── pix │ │ ├── pixDetailReceived.ts │ │ ├── pixReceivedList.ts │ │ ├── pixDetailDevolution.ts │ │ └── pixDevolution.ts │ └── cobv │ │ ├── pixDetailDueCharge.ts │ │ ├── pixListDueCharges.ts │ │ ├── pixUpdateDueCharge.ts │ │ └── pixCreateDueCharge.ts └── payments │ └── billets │ ├── payDetailBarCode.ts │ ├── payDetailPayment.ts │ ├── payListPayments.ts │ └── payRequestBarCode.ts ├── .eslintrc.json ├── index.ts ├── package.json ├── tests ├── auth.test.ts └── endpoints.test.ts ├── README.md └── tsconfig.json /src/interfaces/endpoint.interface.ts: -------------------------------------------------------------------------------- 1 | export interface EndpointInterface { 2 | route: string; 3 | method: string; 4 | } 5 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest').JestConfigWithTsJest} */ 2 | module.exports = { 3 | preset: 'ts-jest', 4 | testEnvironment: 'node', 5 | }; 6 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .eslint.json 2 | .gitignore 3 | .npmignore 4 | .prettierrc.json 5 | package.json 6 | README.md 7 | tsconfig.json 8 | jest.config.js 9 | *.p12 10 | *.pem -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.p12 3 | *.pem 4 | simulaMod.ts 5 | teste.ts 6 | npm-debug.log 7 | coverage/ 8 | .idea/ 9 | examples/open-accounts/ 10 | examples/pix/split/ -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all", 4 | "semi": true, 5 | "tabWidth": 4, 6 | "useTabs": true, 7 | "printWidth": 300 8 | } -------------------------------------------------------------------------------- /examples/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "gn-api-sdk-typescript": "https://github.com/gerencianet/gn-api-sdk-typescript.git", 4 | "ts-node": "^9.1.1" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/credentials.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | // PRODUÇÃO = false 3 | // HOMOLOGAÇÃO = true 4 | sandbox: false, 5 | client_id: 'seuClientId', 6 | client_secret: 'seuClientSecret', 7 | certificate: 'caminhoAteOCertificadoPix', 8 | validateMtls: false, 9 | }; 10 | -------------------------------------------------------------------------------- /examples/exclusives/key/pixListEvp.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const gerencianet = new Gerencianet(options); 6 | 7 | gerencianet 8 | .pixListEvp() 9 | .then((resposta: Promise) => { 10 | console.log(resposta); 11 | }) 12 | .catch((error: Promise) => { 13 | console.log(error); 14 | }); 15 | -------------------------------------------------------------------------------- /examples/exclusives/key/pixCreateEvp.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const gerencianet = new Gerencianet(options); 6 | 7 | gerencianet 8 | .pixCreateEvp() 9 | .then((resposta: Promise) => { 10 | console.log(resposta); 11 | }) 12 | .catch((error: Promise) => { 13 | console.log(error); 14 | }); 15 | -------------------------------------------------------------------------------- /src/interfaces/gnCredentials.interface.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable camelcase */ 2 | import { PathLike } from 'fs'; 3 | 4 | export interface GnCredentials { 5 | client_id: string; 6 | client_secret: string; 7 | certificate?: PathLike | string; 8 | pix_cert?: PathLike | string; 9 | pathCert?: PathLike | string; 10 | pemKey?: PathLike | string; 11 | sandbox: boolean; 12 | validateMtls?: boolean; 13 | partnerToken?: string; 14 | } 15 | -------------------------------------------------------------------------------- /examples/open-finance/config/ofConfigDetail.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const gerencianet = new Gerencianet(options); 6 | 7 | gerencianet 8 | .ofConfigDetail() 9 | .then((resposta: Promise) => { 10 | console.log(resposta); 11 | }) 12 | .catch((error: Promise) => { 13 | console.log(error); 14 | }); 15 | -------------------------------------------------------------------------------- /examples/exclusives/account/getAccountBalance.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const gerencianet = new Gerencianet(options); 6 | 7 | gerencianet 8 | .getAccountBalance() 9 | .then((resposta: Promise) => { 10 | console.log(resposta); 11 | }) 12 | .catch((error: Promise) => { 13 | console.log(error); 14 | }); 15 | -------------------------------------------------------------------------------- /examples/exclusives/account/listAccountConfig.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const gerencianet = new Gerencianet(options); 6 | 7 | gerencianet 8 | .listAccountConfig() 9 | .then((resposta: Promise) => { 10 | console.log(resposta); 11 | }) 12 | .catch((error: Promise) => { 13 | console.log(error); 14 | }); 15 | -------------------------------------------------------------------------------- /examples/charges/card/cancelCard.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 0, 7 | }; 8 | 9 | const gerencianet = new Gerencianet(options); 10 | 11 | gerencianet 12 | .cancelCharge(params) 13 | .then((resposta: Promise) => { 14 | console.log(resposta); 15 | }) 16 | .catch((error: Promise) => { 17 | console.log(error); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/charges/card/detailCard.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 0, 7 | }; 8 | 9 | const gerencianet = new Gerencianet(options); 10 | 11 | gerencianet 12 | .detailCharge(params) 13 | .then((resposta: Promise) => { 14 | console.log(resposta); 15 | }) 16 | .catch((error: Promise) => { 17 | console.log(error); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/charges/billet/detailBillet.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 0, 7 | }; 8 | 9 | const gerencianet = new Gerencianet(options); 10 | 11 | gerencianet 12 | .detailCharge(params) 13 | .then((resposta: Promise) => { 14 | console.log(resposta); 15 | }) 16 | .catch((error: Promise) => { 17 | console.log(error); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/charges/carnet/cancelCarnet.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 0, 7 | }; 8 | 9 | const gerencianet = new Gerencianet(options); 10 | 11 | gerencianet 12 | .cancelCarnet(params) 13 | .then((resposta: Promise) => { 14 | console.log(resposta); 15 | }) 16 | .catch((error: Promise) => { 17 | console.log(error); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/charges/carnet/detailCarnet.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 0, 7 | }; 8 | 9 | const gerencianet = new Gerencianet(options); 10 | 11 | gerencianet 12 | .detailCarnet(params) 13 | .then((resposta: Promise) => { 14 | console.log(resposta); 15 | }) 16 | .catch((error: Promise) => { 17 | console.log(error); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/charges/carnet/settleCarnet.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 26812, 7 | }; 8 | 9 | const gerencianet = new Gerencianet(options); 10 | 11 | gerencianet 12 | .settleCarnet(params) 13 | .then((resposta: Promise) => { 14 | console.log(resposta); 15 | }) 16 | .catch((error: Promise) => { 17 | console.log(error); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/charges/payment-link/cancelLink.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 0, 7 | }; 8 | 9 | const gerencianet = new Gerencianet(options); 10 | 11 | gerencianet 12 | .cancelCharge(params) 13 | .then((resposta: Promise) => { 14 | console.log(resposta); 15 | }) 16 | .catch((error: Promise) => { 17 | console.log(error); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/charges/payment-link/detailLink.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 0, 7 | }; 8 | 9 | const gerencianet = new Gerencianet(options); 10 | 11 | gerencianet 12 | .detailCharge(params) 13 | .then((resposta: Promise) => { 14 | console.log(resposta); 15 | }) 16 | .catch((error: Promise) => { 17 | console.log(error); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/charges/subscription/deletePlan.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 0, 7 | }; 8 | 9 | const gerencianet = new Gerencianet(options); 10 | 11 | gerencianet 12 | .deletePlan(params) 13 | .then((resposta: Promise) => { 14 | console.log(resposta); 15 | }) 16 | .catch((error: Promise) => { 17 | console.log(error); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/pix/send/pixSendDetail.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | e2eid: '', 7 | }; 8 | 9 | const gerencianet = new Gerencianet(options); 10 | 11 | gerencianet 12 | .pixSendDetail(params, []) 13 | .then((resposta: Promise) => { 14 | console.log(resposta); 15 | }) 16 | .catch((error: Promise) => { 17 | console.log(error); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/charges/billet/settleBillet.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 553834, 7 | }; 8 | 9 | const gerencianet = new Gerencianet(options); 10 | 11 | gerencianet 12 | .settleCharge(params) 13 | .then((resposta: Promise) => { 14 | console.log(resposta); 15 | }) 16 | .catch((error: Promise) => { 17 | console.log(error); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/exclusives/report/detailReport.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 1, 7 | }; 8 | 9 | const gerencianet = new Gerencianet(options); 10 | 11 | gerencianet 12 | .detailReport(params, []) 13 | .then((resposta: Promise) => { 14 | console.log(resposta); 15 | }) 16 | .catch((error: Promise) => { 17 | console.log(error); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/pix/location/pixDetailLocation.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: '95', 7 | }; 8 | 9 | const gerencianet = new Gerencianet(options); 10 | 11 | gerencianet 12 | .pixDetailLocation(params) 13 | .then((resposta: Promise) => { 14 | console.log(resposta); 15 | }) 16 | .catch((error: Promise) => { 17 | console.log(error); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/pix/location/pixGenerateQRCode.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: '95', 7 | }; 8 | 9 | const gerencianet = new Gerencianet(options); 10 | 11 | gerencianet 12 | .pixGenerateQRCode(params) 13 | .then((resposta: Promise) => { 14 | console.log(resposta); 15 | }) 16 | .catch((error: Promise) => { 17 | console.log(error); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/charges/subscription/cancelSubscription.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 0, 7 | }; 8 | 9 | const gerencianet = new Gerencianet(options); 10 | 11 | gerencianet 12 | .cancelSubscription(params) 13 | .then((resposta: Promise) => { 14 | console.log(resposta); 15 | }) 16 | .catch((error: Promise) => { 17 | console.log(error); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/charges/subscription/detailSubscription.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 0, 7 | }; 8 | 9 | const gerencianet = new Gerencianet(options); 10 | 11 | gerencianet 12 | .detailSubscription(params) 13 | .then((resposta: Promise) => { 14 | console.log(resposta); 15 | }) 16 | .catch((error: Promise) => { 17 | console.log(error); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/exclusives/key/pixDeleteEvp.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | chave: 'SUACHAVEPIX', 7 | }; 8 | 9 | const gerencianet = new Gerencianet(options); 10 | 11 | gerencianet 12 | .pixDeleteEvp(params) 13 | .then((resposta: Promise) => { 14 | console.log(resposta); 15 | }) 16 | .catch((error: Promise) => { 17 | console.log(error); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/pix/location/pixCreateLocation.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const body = { 6 | tipoCob: 'cob', 7 | }; 8 | 9 | const gerencianet = new Gerencianet(options); 10 | 11 | gerencianet 12 | .pixCreateLocation([], body) 13 | .then((resposta: Promise) => { 14 | console.log(resposta); 15 | }) 16 | .catch((error: Promise) => { 17 | console.log(error); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/pix/location/pixUnlinkTxidLocation.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: '95', 7 | }; 8 | 9 | const gerencianet = new Gerencianet(options); 10 | 11 | gerencianet 12 | .pixUnlinkTxidLocation(params) 13 | .then((resposta: Promise) => { 14 | console.log(resposta); 15 | }) 16 | .catch((error: Promise) => { 17 | console.log(error); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/payments/billets/payDetailBarCode.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const gerencianet = new Gerencianet(options); 6 | 7 | const params = { 8 | codBarras: '', 9 | }; 10 | 11 | gerencianet 12 | .payDetailBarCode(params, []) 13 | .then((resposta: Promise) => { 14 | console.log(resposta); 15 | }) 16 | .catch((error: Promise) => { 17 | console.log(error); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/pix/webhooks/pixDeleteWebhook.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | chave: 'SUACHAVEPIX', 7 | }; 8 | 9 | const gerencianet = new Gerencianet(options); 10 | 11 | gerencianet 12 | .pixDeleteWebhook(params) 13 | .then((resposta: Promise) => { 14 | console.log(resposta); 15 | }) 16 | .catch((error: Promise) => { 17 | console.log(error); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/pix/webhooks/pixDetailWebhook.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | chave: 'SUACHAVEPIX', 7 | }; 8 | 9 | const gerencianet = new Gerencianet(options); 10 | 11 | gerencianet 12 | .pixDetailWebhook(params) 13 | .then((resposta: Promise) => { 14 | console.log(resposta); 15 | }) 16 | .catch((error: Promise) => { 17 | console.log(error); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/charges/carnet/cancelCarnetParcel.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 0, 7 | parcel: 1, 8 | }; 9 | 10 | const gerencianet = new Gerencianet(options); 11 | 12 | gerencianet 13 | .cancelCarnetParcel(params) 14 | .then((resposta: Promise) => { 15 | console.log(resposta); 16 | }) 17 | .catch((error: Promise) => { 18 | console.log(error); 19 | }); 20 | -------------------------------------------------------------------------------- /examples/payments/billets/payDetailPayment.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const gerencianet = new Gerencianet(options); 6 | 7 | const params = { 8 | idPagamento: '0000', 9 | }; 10 | 11 | gerencianet 12 | .payDetailPayment(params, []) 13 | .then((resposta: Promise) => { 14 | console.log(resposta); 15 | }) 16 | .catch((error: Promise) => { 17 | console.log(error); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/charges/card/getInstallments.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | brand: 'visa', 7 | total: 5000, 8 | }; 9 | 10 | const gerencianet = new Gerencianet(options); 11 | 12 | gerencianet 13 | .getInstallments(params) 14 | .then((resposta: Promise) => { 15 | console.log(resposta); 16 | }) 17 | .catch((error: Promise) => { 18 | console.log(error); 19 | }); 20 | -------------------------------------------------------------------------------- /examples/charges/carnet/settleCarnetParcel.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 26812, 7 | parcel: 5, 8 | }; 9 | 10 | const gerencianet = new Gerencianet(options); 11 | 12 | gerencianet 13 | .settleCarnetParcel(params) 14 | .then((resposta: Promise) => { 15 | console.log(resposta); 16 | }) 17 | .catch((error: Promise) => { 18 | console.log(error); 19 | }); 20 | -------------------------------------------------------------------------------- /examples/pix/cob/pixDetailCharge.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | txid: 'dt9BHlyzrb5jrFNAdfEDVpHgiOmDbVqVxd', 7 | }; 8 | 9 | const gerencianet = new Gerencianet(options); 10 | 11 | gerencianet 12 | .pixDetailCharge(params) 13 | .then((resposta: Promise) => { 14 | console.log(resposta); 15 | }) 16 | .catch((error: Promise) => { 17 | console.log(error); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/pix/pix/pixDetailReceived.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | e2eId: 'E18236120202104191813s0326120V4K', 7 | }; 8 | 9 | const gerencianet = new Gerencianet(options); 10 | 11 | gerencianet 12 | .pixDetailReceived(params) 13 | .then((resposta: Promise) => { 14 | console.log(resposta); 15 | }) 16 | .catch((error: Promise) => { 17 | console.log(error); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/charges/subscription/listPlans.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | name: 'My Plan', 7 | limit: 20, 8 | offset: 0, 9 | }; 10 | 11 | const gerencianet = new Gerencianet(options); 12 | 13 | gerencianet 14 | .listPlans(params) 15 | .then((resposta: Promise) => { 16 | console.log(resposta); 17 | }) 18 | .catch((error: Promise) => { 19 | console.log(error); 20 | }); 21 | -------------------------------------------------------------------------------- /examples/open-finance/participants/ofListParticipants.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const gerencianet = new Gerencianet(options); 6 | 7 | const params = { 8 | nome: 'Gerencianet', 9 | }; 10 | 11 | gerencianet 12 | .ofListParticipants(params, []) 13 | .then((resposta: Promise) => { 14 | console.log(resposta); 15 | }) 16 | .catch((error: Promise) => { 17 | console.log(error); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/pix/cobv/pixDetailDueCharge.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | txid: 'dt9BHlyzrb5jrFNAdfEDVpHgiOmDbVqVxd', 7 | }; 8 | 9 | const gerencianet = new Gerencianet(options); 10 | 11 | gerencianet 12 | .pixDetailDueCharge(params) 13 | .then((resposta: Promise) => { 14 | console.log(resposta); 15 | }) 16 | .catch((error: Promise) => { 17 | console.log(error); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/charges/billet/cancelBillet.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/no-unresolved */ 2 | /* eslint-disable import/extensions */ 3 | import Gerencianet from 'gn-api-sdk-typescript'; 4 | import options from '../../credentials'; 5 | 6 | const params = { 7 | id: 0, 8 | }; 9 | 10 | const gerencianet = new Gerencianet(options); 11 | 12 | gerencianet 13 | .cancelCharge(params) 14 | .then((resposta: Promise) => { 15 | console.log(resposta); 16 | }) 17 | .catch((error: Promise) => { 18 | console.log(error); 19 | }); 20 | -------------------------------------------------------------------------------- /examples/charges/notification/getNotification.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | token: '252948279264ee47e117cb099ef81', 7 | }; 8 | 9 | const gerencianet = new Gerencianet(options); 10 | 11 | gerencianet 12 | .getNotification(params) 13 | .then((resposta: Promise) => { 14 | console.log(resposta); 15 | }) 16 | .catch((error: Promise) => { 17 | console.log(error); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/pix/send/pixSendList.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | inicio: '2023-01-22T16:01:35Z', 7 | fim: '2023-11-30T20:10:00Z', 8 | }; 9 | 10 | const gerencianet = new Gerencianet(options); 11 | 12 | gerencianet 13 | .pixSendList(params) 14 | .then((resposta: Promise) => { 15 | console.log(resposta); 16 | }) 17 | .catch((error: Promise) => { 18 | console.log(error); 19 | }); 20 | -------------------------------------------------------------------------------- /examples/open-finance/payment/ofListPixPayment.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const gerencianet = new Gerencianet(options); 6 | 7 | const params = { 8 | inicio: '2022-01-01', 9 | fim: '2022-06-30', 10 | }; 11 | 12 | gerencianet 13 | .ofListPixPayment(params, []) 14 | .then((resposta: Promise) => { 15 | console.log(resposta); 16 | }) 17 | .catch((error: Promise) => { 18 | console.log(error); 19 | }); 20 | -------------------------------------------------------------------------------- /examples/pix/cob/pixListCharges.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | inicio: '2022-01-22T16:01:35Z', 7 | fim: '2022-11-30T20:10:00Z', 8 | }; 9 | 10 | const gerencianet = new Gerencianet(options); 11 | 12 | gerencianet 13 | .pixListCharges(params) 14 | .then((resposta: Promise) => { 15 | console.log(resposta); 16 | }) 17 | .catch((error: Promise) => { 18 | console.log(error); 19 | }); 20 | -------------------------------------------------------------------------------- /examples/pix/pix/pixReceivedList.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | inicio: '2022-01-22T16:01:35Z', 7 | fim: '2022-11-30T20:10:00Z', 8 | }; 9 | 10 | const gerencianet = new Gerencianet(options); 11 | 12 | gerencianet 13 | .pixReceivedList(params) 14 | .then((resposta: Promise) => { 15 | console.log(resposta); 16 | }) 17 | .catch((error: Promise) => { 18 | console.log(error); 19 | }); 20 | -------------------------------------------------------------------------------- /examples/payments/billets/payListPayments.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const gerencianet = new Gerencianet(options); 6 | 7 | const params = { 8 | dataInicio: '2022-01-01', 9 | dataFim: '2022-06-30', 10 | }; 11 | 12 | gerencianet 13 | .payListPayments(params, []) 14 | .then((resposta: Promise) => { 15 | console.log(resposta); 16 | }) 17 | .catch((error: Promise) => { 18 | console.log(error); 19 | }); 20 | -------------------------------------------------------------------------------- /examples/pix/cobv/pixListDueCharges.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | inicio: '2023-01-22T16:01:35Z', 7 | fim: '2023-11-30T20:10:00Z', 8 | }; 9 | 10 | const gerencianet = new Gerencianet(options); 11 | 12 | gerencianet 13 | .pixListDueCharges(params) 14 | .then((resposta: Promise) => { 15 | console.log(resposta); 16 | }) 17 | .catch((error: Promise) => { 18 | console.log(error); 19 | }); 20 | -------------------------------------------------------------------------------- /examples/pix/location/pixLocationList.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | inicio: '2022-01-22T16:01:35Z', 7 | fim: '2022-11-30T20:10:00Z', 8 | }; 9 | 10 | const gerencianet = new Gerencianet(options); 11 | 12 | gerencianet 13 | .pixLocationList(params) 14 | .then((resposta: Promise) => { 15 | console.log(resposta); 16 | }) 17 | .catch((error: Promise) => { 18 | console.log(error); 19 | }); 20 | -------------------------------------------------------------------------------- /examples/pix/webhooks/pixListWebhook.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | inicio: '2022-01-22T16:01:35Z', 7 | fim: '2022-11-30T20:10:00Z', 8 | }; 9 | 10 | const gerencianet = new Gerencianet(options); 11 | 12 | gerencianet 13 | .pixListWebhook(params) 14 | .then((resposta: Promise) => { 15 | console.log(resposta); 16 | }) 17 | .catch((error: Promise) => { 18 | console.log(error); 19 | }); 20 | -------------------------------------------------------------------------------- /examples/charges/billet/updateBillet.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 1008, 7 | }; 8 | 9 | const body = { 10 | expire_at: '2024-12-12', 11 | }; 12 | 13 | const gerencianet = new Gerencianet(options); 14 | 15 | gerencianet 16 | .updateBillet(params, body) 17 | .then((resposta: Promise) => { 18 | console.log(resposta); 19 | }) 20 | .catch((error: Promise) => { 21 | console.log(error); 22 | }); 23 | -------------------------------------------------------------------------------- /examples/charges/subscription/updatePlan.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 1008, 7 | }; 8 | 9 | const body = { 10 | name: 'My new plan', 11 | }; 12 | 13 | const gerencianet = new Gerencianet(options); 14 | 15 | gerencianet 16 | .updatePlan(params, body) 17 | .then((resposta: Promise) => { 18 | console.log(resposta); 19 | }) 20 | .catch((error: Promise) => { 21 | console.log(error); 22 | }); 23 | -------------------------------------------------------------------------------- /examples/pix/pix/pixDetailDevolution.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | e2eId: 'E18236120202104191813s0326120V4K', 7 | id: '607dc88bb83bf', 8 | }; 9 | 10 | const gerencianet = new Gerencianet(options); 11 | 12 | gerencianet 13 | .pixDetailDevolution(params) 14 | .then((resposta: Promise) => { 15 | console.log(resposta); 16 | }) 17 | .catch((error: Promise) => { 18 | console.log(error); 19 | }); 20 | -------------------------------------------------------------------------------- /src/interfaces/gnConfig.interface.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | /* eslint-disable camelcase */ 3 | import { PathLike } from 'fs'; 4 | import { EndpointInterface } from './endpoint.interface'; 5 | 6 | export interface GnConfig { 7 | client_id: string; 8 | client_secret: string; 9 | certificate?: PathLike | string; 10 | pemKey?: PathLike | string; 11 | sandbox: boolean; 12 | partnerToken?: string; 13 | rawResponse?: any; 14 | baseUrl?: string; 15 | validateMtls?: boolean; 16 | authRoute?: EndpointInterface; 17 | agent?: any; 18 | } 19 | -------------------------------------------------------------------------------- /examples/charges/billet/sendBilletEmail.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 1000, 7 | }; 8 | 9 | const body = { 10 | email: 'oldbuck@gerencianet.com.br', 11 | }; 12 | 13 | const gerencianet = new Gerencianet(options); 14 | 15 | gerencianet 16 | .sendBilletEmail(params, body) 17 | .then((resposta: Promise) => { 18 | console.log(resposta); 19 | }) 20 | .catch((error: Promise) => { 21 | console.log(error); 22 | }); 23 | -------------------------------------------------------------------------------- /examples/charges/carnet/sendCarnetEmail.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 1002, 7 | }; 8 | 9 | const body = { 10 | email: 'oldbuck@gerencianet.com.br', 11 | }; 12 | 13 | const gerencianet = new Gerencianet(options); 14 | 15 | gerencianet 16 | .sendCarnetEmail(params, body) 17 | .then((resposta: Promise) => { 18 | console.log(resposta); 19 | }) 20 | .catch((error: Promise) => { 21 | console.log(error); 22 | }); 23 | -------------------------------------------------------------------------------- /examples/charges/payment-link/sendLinkEmail.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 1000, 7 | }; 8 | 9 | const body = { 10 | email: 'oldbuck@gerencianet.com.br', 11 | }; 12 | 13 | const gerencianet = new Gerencianet(options); 14 | 15 | gerencianet 16 | .sendLinkEmail(params, body) 17 | .then((resposta: Promise) => { 18 | console.log(resposta); 19 | }) 20 | .catch((error: Promise) => { 21 | console.log(error); 22 | }); 23 | -------------------------------------------------------------------------------- /examples/charges/subscription/createPlan.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = {}; 6 | 7 | const body = { 8 | name: 'My first plan', 9 | repeats: 24, 10 | interval: 2, 11 | }; 12 | 13 | const gerencianet = new Gerencianet(options); 14 | 15 | gerencianet 16 | .createPlan(params, body) 17 | .then((resposta: Promise) => { 18 | console.log(resposta); 19 | }) 20 | .catch((error: Promise) => { 21 | console.log(error); 22 | }); 23 | -------------------------------------------------------------------------------- /examples/open-finance/config/ofConfigUpdate.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const gerencianet = new Gerencianet(options); 6 | 7 | const body = { 8 | redirectURL: 'https:/suaUrl.com.br/redirect', 9 | webhookURL: 'https://suaUrl.com.br/webhook', 10 | }; 11 | 12 | gerencianet 13 | .ofConfigUpdate([], body) 14 | .then((resposta: Promise) => { 15 | console.log(resposta); 16 | }) 17 | .catch((error: Promise) => { 18 | console.log(error); 19 | }); 20 | -------------------------------------------------------------------------------- /examples/charges/card/createCardHistory.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 1001, 7 | }; 8 | 9 | const body = { 10 | description: 'This charge was not fully paid', 11 | }; 12 | 13 | const gerencianet = new Gerencianet(options); 14 | 15 | gerencianet 16 | .createChargeHistory(params, body) 17 | .then((resposta: Promise) => { 18 | console.log(resposta); 19 | }) 20 | .catch((error: Promise) => { 21 | console.log(error); 22 | }); 23 | -------------------------------------------------------------------------------- /examples/charges/carnet/updateCarnetParcel.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 25093006, 7 | parcel: 1, 8 | }; 9 | 10 | const body = { 11 | expire_at: '2023-12-12', 12 | }; 13 | 14 | const gerencianet = new Gerencianet(options); 15 | 16 | gerencianet 17 | .updateCarnetParcel(params, body) 18 | .then((resposta: Promise) => { 19 | console.log(resposta); 20 | }) 21 | .catch((error: Promise) => { 22 | console.log(error); 23 | }); 24 | -------------------------------------------------------------------------------- /examples/pix/pix/pixDevolution.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const body = { 6 | valor: '7.89', 7 | }; 8 | 9 | const params = { 10 | e2eId: 'E18236120202104191813s0326120V4K', 11 | id: '101', 12 | }; 13 | 14 | const gerencianet = new Gerencianet(options); 15 | 16 | gerencianet 17 | .pixDevolution(params, body) 18 | .then((resposta: Promise) => { 19 | console.log(resposta); 20 | }) 21 | .catch((error: Promise) => { 22 | console.log(error); 23 | }); 24 | -------------------------------------------------------------------------------- /examples/charges/billet/createBilletHistory.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 1001, 7 | }; 8 | 9 | const body = { 10 | description: 'This charge was not fully paid', 11 | }; 12 | 13 | const gerencianet = new Gerencianet(options); 14 | 15 | gerencianet 16 | .createChargeHistory(params, body) 17 | .then((resposta: Promise) => { 18 | console.log(resposta); 19 | }) 20 | .catch((error: Promise) => { 21 | console.log(error); 22 | }); 23 | -------------------------------------------------------------------------------- /examples/charges/carnet/createCarnetHistory.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 1001, 7 | }; 8 | 9 | const body = { 10 | description: 'This carnet is about a service', 11 | }; 12 | 13 | const gerencianet = new Gerencianet(options); 14 | 15 | gerencianet 16 | .createCarnetHistory(params, body) 17 | .then((resposta: Promise) => { 18 | console.log(resposta); 19 | }) 20 | .catch((error: Promise) => { 21 | console.log(error); 22 | }); 23 | -------------------------------------------------------------------------------- /examples/charges/carnet/sendCarnetParcelEmail.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 1002, 7 | parcel: 1, 8 | }; 9 | 10 | const body = { 11 | email: 'oldbuck@gerencianet.com.br', 12 | }; 13 | 14 | const gerencianet = new Gerencianet(options); 15 | 16 | gerencianet 17 | .resendParcel(params, body) 18 | .then((resposta: Promise) => { 19 | console.log(resposta); 20 | }) 21 | .catch((error: Promise) => { 22 | console.log(error); 23 | }); 24 | -------------------------------------------------------------------------------- /examples/charges/subscription/sendSubscriptionLinkEmail.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 1000, 7 | }; 8 | 9 | const body = { 10 | email: 'oldbuck@gerencianet.com.br', 11 | }; 12 | 13 | const gerencianet = new Gerencianet(options); 14 | 15 | gerencianet 16 | .sendSubscriptionLinkEmail(params, body) 17 | .then((resposta: Promise) => { 18 | console.log(resposta); 19 | }) 20 | .catch((error: Promise) => { 21 | console.log(error); 22 | }); 23 | -------------------------------------------------------------------------------- /examples/charges/payment-link/createChargeLinkHistory.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 1001, 7 | }; 8 | 9 | const body = { 10 | description: 'This charge was not fully paid', 11 | }; 12 | 13 | const gerencianet = new Gerencianet(options); 14 | 15 | gerencianet 16 | .createChargeHistory(params, body) 17 | .then((resposta: Promise) => { 18 | console.log(resposta); 19 | }) 20 | .catch((error: Promise) => { 21 | console.log(error); 22 | }); 23 | -------------------------------------------------------------------------------- /examples/charges/card/updateCardMetadata.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 1008, 7 | }; 8 | 9 | const body = { 10 | notification_url: 'http://yourdomain.com', 11 | custom_id: 'my_new_id', 12 | }; 13 | 14 | const gerencianet = new Gerencianet(options); 15 | 16 | gerencianet 17 | .updateChargeMetadata(params, body) 18 | .then((resposta: Promise) => { 19 | console.log(resposta); 20 | }) 21 | .catch((error: Promise) => { 22 | console.log(error); 23 | }); 24 | -------------------------------------------------------------------------------- /examples/charges/subscription/createSubscriptionHistory.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 1001, 7 | }; 8 | 9 | const body = { 10 | description: 'This subscription is about a service', 11 | }; 12 | 13 | const gerencianet = new Gerencianet(options); 14 | 15 | gerencianet 16 | .createSubscriptionHistory(params, body) 17 | .then((resposta: Promise) => { 18 | console.log(resposta); 19 | }) 20 | .catch((error: Promise) => { 21 | console.log(error); 22 | }); 23 | -------------------------------------------------------------------------------- /examples/charges/billet/updateBilletMetadata.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 1008, 7 | }; 8 | 9 | const body = { 10 | notification_url: 'http://yourdomain.com', 11 | custom_id: 'my_new_id', 12 | }; 13 | 14 | const gerencianet = new Gerencianet(options); 15 | 16 | gerencianet 17 | .updateChargeMetadata(params, body) 18 | .then((resposta: Promise) => { 19 | console.log(resposta); 20 | }) 21 | .catch((error: Promise) => { 22 | console.log(error); 23 | }); 24 | -------------------------------------------------------------------------------- /examples/charges/carnet/updateCarnetMetadata.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 1004, 7 | }; 8 | 9 | const body = { 10 | notification_url: 'http://yourdomain.com', 11 | custom_id: 'my_new_id', 12 | }; 13 | 14 | const gerencianet = new Gerencianet(options); 15 | 16 | gerencianet 17 | .updateCarnetMetadata(params, body) 18 | .then((resposta: Promise) => { 19 | console.log(resposta); 20 | }) 21 | .catch((error: Promise) => { 22 | console.log(error); 23 | }); 24 | -------------------------------------------------------------------------------- /examples/charges/payment-link/updateLinkMetadata.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 1008, 7 | }; 8 | 9 | const body = { 10 | notification_url: 'http://yourdomain.com', 11 | custom_id: 'my_new_id', 12 | }; 13 | 14 | const gerencianet = new Gerencianet(options); 15 | 16 | gerencianet 17 | .updateChargeMetadata(params, body) 18 | .then((resposta: Promise) => { 19 | console.log(resposta); 20 | }) 21 | .catch((error: Promise) => { 22 | console.log(error); 23 | }); 24 | -------------------------------------------------------------------------------- /examples/open-finance/payment/ofDevolutionPix.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const gerencianet = new Gerencianet(options); 6 | 7 | const body = { 8 | valor: '0.01', 9 | }; 10 | 11 | const params = { 12 | identificadorPagamento: 'urn:gerencianet:ea807997-9c28-47a7-8ebc-eeb672ea59f0', 13 | }; 14 | 15 | gerencianet 16 | .ofDevolutionPix(params, body) 17 | .then((resposta: Promise) => { 18 | console.log(resposta); 19 | }) 20 | .catch((error: Promise) => { 21 | console.log(error); 22 | }); 23 | -------------------------------------------------------------------------------- /examples/pix/webhooks/pixConfigWebhook.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | options.validateMtls = false; 6 | 7 | const body = { 8 | webhookUrl: 'https://exemplo-pix/webhook', 9 | }; 10 | 11 | const params = { 12 | chave: 'SUACHAVEPIX', 13 | }; 14 | 15 | const gerencianet = new Gerencianet(options); 16 | 17 | gerencianet 18 | .pixConfigWebhook(params, body) 19 | .then((resposta: Promise) => { 20 | console.log(resposta); 21 | }) 22 | .catch((error: Promise) => { 23 | console.log(error); 24 | }); 25 | -------------------------------------------------------------------------------- /examples/charges/subscription/updateSubscriptionMetadata.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 1009, 7 | }; 8 | 9 | const body = { 10 | notification_url: 'http://yourdomain.com', 11 | custom_id: 'my_new_id', 12 | }; 13 | 14 | const gerencianet = new Gerencianet(options); 15 | 16 | gerencianet 17 | .updateSubscriptionMetadata(params, body) 18 | .then((resposta: Promise) => { 19 | console.log(resposta); 20 | }) 21 | .catch((error: Promise) => { 22 | console.log(error); 23 | }); 24 | -------------------------------------------------------------------------------- /examples/payments/billets/payRequestBarCode.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const gerencianet = new Gerencianet(options); 6 | 7 | const params = { 8 | codBarras: '', 9 | }; 10 | 11 | const body = { 12 | valor: 0, 13 | dataPagamento: '2022-03-10', 14 | descricao: 'Pagamento de boleto, teste API Pagamentos', 15 | }; 16 | 17 | gerencianet 18 | .payRequestBarCode(params, body) 19 | .then((resposta: Promise) => { 20 | console.log(resposta); 21 | }) 22 | .catch((error: Promise) => { 23 | console.log(error); 24 | }); 25 | -------------------------------------------------------------------------------- /examples/pix/send/pixSend.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | idEnvio: '01', 7 | }; 8 | 9 | const body = { 10 | valor: '12.34', 11 | pagador: { 12 | chave: 'SUACHAVEPIX', 13 | }, 14 | favorecido: { 15 | chave: 'ChavePixDeDestino', 16 | }, 17 | }; 18 | 19 | const gerencianet = new Gerencianet(options); 20 | 21 | gerencianet 22 | .pixSend(params, body) 23 | .then((resposta: Promise) => { 24 | console.log(resposta); 25 | }) 26 | .catch((error: Promise) => { 27 | console.log(error); 28 | }); 29 | -------------------------------------------------------------------------------- /examples/charges/billet/createCharge.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const body = { 6 | items: [ 7 | { 8 | name: 'Product 1', 9 | value: 1000, 10 | amount: 2, 11 | }, 12 | ], 13 | shippings: [ 14 | { 15 | name: 'Default Shipping Cost', 16 | value: 100, 17 | }, 18 | ], 19 | }; 20 | 21 | const gerencianet = new Gerencianet(options); 22 | 23 | gerencianet 24 | .createCharge({}, body) 25 | .then((resposta: Promise) => { 26 | console.log(resposta); 27 | }) 28 | .catch((error: Promise) => { 29 | console.log(error); 30 | }); 31 | -------------------------------------------------------------------------------- /examples/charges/card/createCharge.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const body = { 6 | items: [ 7 | { 8 | name: 'Product 1', 9 | value: 1000, 10 | amount: 2, 11 | }, 12 | ], 13 | shippings: [ 14 | { 15 | name: 'Default Shipping Cost', 16 | value: 100, 17 | }, 18 | ], 19 | }; 20 | 21 | const gerencianet = new Gerencianet(options); 22 | 23 | gerencianet 24 | .createCharge({}, body) 25 | .then((resposta: Promise) => { 26 | console.log(resposta); 27 | }) 28 | .catch((error: Promise) => { 29 | console.log(error); 30 | }); 31 | -------------------------------------------------------------------------------- /examples/charges/payment-link/createCharge.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const body = { 6 | items: [ 7 | { 8 | name: 'Product 1', 9 | value: 1000, 10 | amount: 2, 11 | }, 12 | ], 13 | shippings: [ 14 | { 15 | name: 'Default Shipping Cost', 16 | value: 100, 17 | }, 18 | ], 19 | }; 20 | 21 | const gerencianet = new Gerencianet(options); 22 | 23 | gerencianet 24 | .createCharge({}, body) 25 | .then((resposta: Promise) => { 26 | console.log(resposta); 27 | }) 28 | .catch((error: Promise) => { 29 | console.log(error); 30 | }); 31 | -------------------------------------------------------------------------------- /examples/charges/payment-link/updateLink.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 0, 7 | }; 8 | 9 | const body = { 10 | billet_discount: 0, 11 | card_discount: 0, 12 | message: '', 13 | expire_at: '2024-12-01', 14 | request_delivery_address: false, 15 | payment_method: 'all', 16 | }; 17 | 18 | const gerencianet = new Gerencianet(options); 19 | 20 | gerencianet 21 | .updateChargeLink(params, body) 22 | .then((resposta: Promise) => { 23 | console.log(resposta); 24 | }) 25 | .catch((error: Promise) => { 26 | console.log(error); 27 | }); 28 | -------------------------------------------------------------------------------- /examples/charges/payment-link/defineLinkPayMethod.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 0, 7 | }; 8 | 9 | const body = { 10 | billet_discount: 0, 11 | card_discount: 0, 12 | message: '', 13 | expire_at: '2022-12-01', 14 | request_delivery_address: false, 15 | payment_method: 'all', 16 | }; 17 | 18 | const gerencianet = new Gerencianet(options); 19 | 20 | gerencianet 21 | .defineLinkPayMethod(params, body) 22 | .then((resposta: Promise) => { 23 | console.log(resposta); 24 | }) 25 | .catch((error: Promise) => { 26 | console.log(error); 27 | }); 28 | -------------------------------------------------------------------------------- /examples/exclusives/account/updateAccountConfig.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const body = { 6 | pix: { 7 | receberSemChave: true, 8 | chaves: { 9 | SUACHAVEPIX: { 10 | recebimento: { 11 | txidObrigatorio: false, 12 | qrCodeEstatico: { 13 | recusarTodos: false, 14 | }, 15 | }, 16 | }, 17 | }, 18 | }, 19 | }; 20 | 21 | const gerencianet = new Gerencianet(options); 22 | 23 | gerencianet 24 | .updateAccountConfig([], body) 25 | .then((resposta: Promise) => { 26 | console.log(resposta); 27 | }) 28 | .catch((error: Promise) => { 29 | console.log(error); 30 | }); 31 | -------------------------------------------------------------------------------- /examples/charges/subscription/createOneStepSubscriptionLink.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 0, 7 | }; 8 | 9 | const body = { 10 | items: [ 11 | { 12 | name: 'Product One', 13 | value: 600, 14 | amount: 1, 15 | }, 16 | ], 17 | settings: { 18 | payment_method: 'all', 19 | expire_at: '2022-12-15', 20 | request_delivery_address: false, 21 | }, 22 | }; 23 | 24 | const gerencianet = new Gerencianet(options); 25 | 26 | gerencianet 27 | .oneStepSubscriptionLink(params, body) 28 | .then((resposta: Promise) => { 29 | console.log(resposta); 30 | }) 31 | .catch((error: Promise) => { 32 | console.log(error); 33 | }); 34 | -------------------------------------------------------------------------------- /examples/charges/payment-link/createOneStepLink.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 0, 7 | }; 8 | 9 | const body = { 10 | settings: { 11 | billet_discount: 1, 12 | message: '', 13 | expire_at: '2023-12-01', 14 | request_delivery_address: false, 15 | payment_method: 'all', 16 | }, 17 | items: [ 18 | { 19 | name: 'Product 1', 20 | value: 500, 21 | amount: 1, 22 | }, 23 | ], 24 | }; 25 | 26 | const gerencianet = new Gerencianet(options); 27 | 28 | gerencianet 29 | .createOneStepLink(params, body) 30 | .then((resposta: Promise) => { 31 | console.log(resposta); 32 | }) 33 | .catch((error: Promise) => { 34 | console.log(error); 35 | }); 36 | -------------------------------------------------------------------------------- /examples/charges/billet/defineBilletPayMethod.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 0, 7 | }; 8 | 9 | const body = { 10 | payment: { 11 | banking_billet: { 12 | expire_at: '2023-12-01', 13 | customer: { 14 | name: 'Gorbadoc Oldbuck', 15 | email: 'oldbuck@gerencianet.com.br', 16 | cpf: '94271564656', 17 | birth: '1977-01-15', 18 | phone_number: '5144916523', 19 | }, 20 | }, 21 | }, 22 | }; 23 | 24 | const gerencianet = new Gerencianet(options); 25 | 26 | gerencianet 27 | .definePayMethod(params, body) 28 | .then((resposta: Promise) => { 29 | console.log(resposta); 30 | }) 31 | .catch((error: Promise) => { 32 | console.log(error); 33 | }); 34 | -------------------------------------------------------------------------------- /examples/open-finance/payment/ofStartPixPayment.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const gerencianet = new Gerencianet(options); 6 | 7 | const body = { 8 | pagador: { 9 | idParticipante: '', 10 | cpf: '', 11 | }, 12 | valor: '0.01', 13 | favorecido: { 14 | contaBanco: { 15 | codigoBanco: '', 16 | agencia: '', 17 | documento: '', 18 | nome: '', 19 | conta: '', 20 | tipoConta: '', 21 | }, 22 | }, 23 | codigoCidadeIBGE: '', 24 | infoPagador: 'Cobrança referente ao pedido X', 25 | }; 26 | 27 | gerencianet 28 | .ofStartPixPayment([], body) 29 | .then((resposta: Promise) => { 30 | console.log(resposta); 31 | }) 32 | .catch((error: Promise) => { 33 | console.log(error); 34 | }); 35 | -------------------------------------------------------------------------------- /examples/charges/carnet/createCarnet.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const body = { 6 | items: [ 7 | { 8 | name: 'Carnet Item 1', 9 | value: 1000, 10 | amount: 2, 11 | }, 12 | ], 13 | customer: { 14 | name: 'Gorbadoc Oldbuck', 15 | email: 'oldbuck@gerencianet.com.br', 16 | cpf: '94271564656', 17 | birth: '1977-01-15', 18 | phone_number: '5144916523', 19 | }, 20 | repeats: 12, 21 | split_items: false, 22 | expire_at: '2023-01-01', 23 | }; 24 | 25 | const gerencianet = new Gerencianet(options); 26 | 27 | gerencianet 28 | .createCarnet({}, body) 29 | .then((resposta: Promise) => { 30 | console.log(resposta); 31 | }) 32 | .catch((error: Promise) => { 33 | console.log(error); 34 | }); 35 | -------------------------------------------------------------------------------- /examples/charges/subscription/defineSubscriptionBillet.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 0, 7 | }; 8 | 9 | const body = { 10 | payment: { 11 | banking_billet: { 12 | expire_at: '2024-09-20', 13 | customer: { 14 | name: 'Gorbadoc Oldbuck', 15 | email: 'oldbuck@gerencianet.com.br', 16 | cpf: '94271564656', 17 | birth: '1977-01-15', 18 | phone_number: '5144916523', 19 | }, 20 | }, 21 | }, 22 | }; 23 | 24 | const gerencianet = new Gerencianet(options); 25 | 26 | gerencianet 27 | .defineSubscriptionPayMethod(params, body) 28 | .then((resposta: Promise) => { 29 | console.log(resposta); 30 | }) 31 | .catch((error: Promise) => { 32 | console.log(error); 33 | }); 34 | -------------------------------------------------------------------------------- /examples/charges/subscription/createCharge.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const planBody = { 6 | name: 'My first plan', 7 | repeats: 24, 8 | interval: 2, 9 | }; 10 | 11 | const subscriptionBody = { 12 | items: [ 13 | { 14 | name: 'Product 1', 15 | value: 1000, 16 | amount: 2, 17 | }, 18 | ], 19 | }; 20 | 21 | const gerencianet = new Gerencianet(options); 22 | 23 | function createSubscription(response) { 24 | const params = { 25 | id: response.data.plan_id, 26 | }; 27 | 28 | return gerencianet.createSubscription(params, subscriptionBody); 29 | } 30 | 31 | gerencianet 32 | .createPlan({}, planBody) 33 | .then(createSubscription) 34 | .then((resposta: Promise) => { 35 | console.log(resposta); 36 | }) 37 | .catch((error: Promise) => { 38 | console.log(error); 39 | }); 40 | -------------------------------------------------------------------------------- /examples/charges/subscription/createOneStepBilletSubscription.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 0, 7 | }; 8 | 9 | const body = { 10 | items: [ 11 | { 12 | name: 'Product One', 13 | value: 600, 14 | amount: 1, 15 | }, 16 | ], 17 | payment: { 18 | banking_billet: { 19 | expire_at: '2024-09-20', 20 | customer: { 21 | name: 'Gorbadoc Oldbuck', 22 | email: 'oldbuck@gerencianet.com.br', 23 | cpf: '94271564656', 24 | birth: '1977-01-15', 25 | phone_number: '5144916523', 26 | }, 27 | }, 28 | }, 29 | }; 30 | 31 | const gerencianet = new Gerencianet(options); 32 | 33 | gerencianet 34 | .oneStepSubscription(params, body) 35 | .then((resposta: Promise) => { 36 | console.log(resposta); 37 | }) 38 | .catch((error: Promise) => { 39 | console.log(error); 40 | }); 41 | -------------------------------------------------------------------------------- /examples/pix/cob/pixCreateImmediateCharge.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const body = { 6 | calendario: { 7 | expiracao: 3600, 8 | }, 9 | devedor: { 10 | cpf: '94271564656', 11 | nome: 'Gorbadock Oldbuck', 12 | }, 13 | valor: { 14 | original: '123.45', 15 | }, 16 | chave: 'SUACHAVEPIX', // Informe sua chave Pix cadastrada na gerencianet 17 | infoAdicionais: [ 18 | { 19 | nome: 'Pagamento em', 20 | valor: 'NOME DO SEU ESTABELECIMENTO', 21 | }, 22 | { 23 | nome: 'Pedido', 24 | valor: 'NUMERO DO PEDIDO DO CLIENTE', 25 | }, 26 | ], 27 | }; 28 | 29 | const gerencianet = new Gerencianet(options); 30 | 31 | gerencianet 32 | .pixCreateImmediateCharge([], body) 33 | .then((resposta: Promise) => { 34 | console.log(resposta); 35 | }) 36 | .catch((error: Promise) => { 37 | console.log(error); 38 | }); 39 | -------------------------------------------------------------------------------- /examples/charges/billet/createOneStepBillet.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const body = { 6 | payment: { 7 | banking_billet: { 8 | expire_at: '2024-09-20', 9 | customer: { 10 | name: 'Gorbadoc Oldbuck', 11 | email: 'oldbuck@gerencianet.com.br', 12 | cpf: '94271564656', 13 | birth: '1977-01-15', 14 | phone_number: '5144916523', 15 | }, 16 | }, 17 | }, 18 | 19 | items: [ 20 | { 21 | name: 'Product 1', 22 | value: 500, 23 | amount: 1, 24 | }, 25 | ], 26 | shippings: [ 27 | { 28 | name: 'Default Shipping Cost', 29 | value: 100, 30 | }, 31 | ], 32 | }; 33 | 34 | const gerencianet = new Gerencianet(options); 35 | 36 | gerencianet 37 | .createOneStepCharge([], body) 38 | .then((resposta: Promise) => { 39 | console.log(resposta); 40 | }) 41 | .catch((error: Promise) => { 42 | console.log(error); 43 | }); 44 | -------------------------------------------------------------------------------- /examples/pix/cobv/pixUpdateDueCharge.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | // Informe no body somente os dados que deseja atualizar 6 | const body = { 7 | loc: { 8 | id: 789, 9 | }, 10 | devedor: { 11 | logradouro: 'Alameda Souza, Numero 80, Bairro Braz', 12 | cidade: 'Recife', 13 | uf: 'PE', 14 | cep: '70011750', 15 | cpf: '12345678909', 16 | nome: 'Francisco da Silva', 17 | }, 18 | valor: { 19 | original: '123.45', 20 | }, 21 | solicitacaoPagador: 'Cobrança dos serviços prestados.', 22 | }; 23 | 24 | const params = { 25 | txid: 'dt9BHlyzrb5jrFNAdfEDVpHgiOmDbVqVxd', // Informe o TxId da cobrança 26 | }; 27 | 28 | const gerencianet = new Gerencianet(options); 29 | 30 | gerencianet 31 | .pixUpdateDueCharge(params, body) 32 | .then((resposta: Promise) => { 33 | console.log(resposta); 34 | }) 35 | .catch((error: Promise) => { 36 | console.log(error); 37 | }); 38 | -------------------------------------------------------------------------------- /examples/pix/cob/pixCreateCharge.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const body = { 6 | calendario: { 7 | expiracao: 3600, 8 | }, 9 | devedor: { 10 | cpf: '94271564656', 11 | nome: 'Gorbadock Oldbuck', 12 | }, 13 | valor: { 14 | original: '123.45', 15 | }, 16 | chave: 'SUACHAVEPIX', // Informe sua chave Pix cadastrada na gerencianet //o campo abaixo é opcional 17 | infoAdicionais: [ 18 | { 19 | nome: 'Pagamento em', 20 | valor: 'NOME DO SEU ESTABELECIMENTO', 21 | }, 22 | { 23 | nome: 'Pedido', 24 | valor: 'NUMERO DO PEDIDO DO CLIENTE', 25 | }, 26 | ], 27 | }; 28 | 29 | const params = { 30 | txid: 'dt9BHlyzrb5jrFNAdfEDVpHgiOmDbVq111', 31 | }; 32 | 33 | const gerencianet = new Gerencianet(options); 34 | 35 | gerencianet 36 | .pixCreateCharge(params, body) 37 | .then((resposta: Promise) => { 38 | console.log(resposta); 39 | }) 40 | .catch((error: Promise) => { 41 | console.log(error); 42 | }); 43 | -------------------------------------------------------------------------------- /examples/charges/subscription/defineSubscriptionCard.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 0, 7 | }; 8 | 9 | const body = { 10 | payment: { 11 | credit_card: { 12 | payment_token: '33ffd6d982cd63f767fb2ee5c458cd39e8fc0ea0', 13 | billing_address: { 14 | street: 'Av. JK', 15 | number: 909, 16 | neighborhood: 'Bauxita', 17 | zipcode: '35400000', 18 | city: 'Ouro Preto', 19 | state: 'MG', 20 | }, 21 | customer: { 22 | name: 'Gorbadoc Oldbuck', 23 | email: 'oldbuck@gerencianet.com.br', 24 | cpf: '94271564656', 25 | birth: '1977-01-15', 26 | phone_number: '5144916523', 27 | }, 28 | }, 29 | }, 30 | }; 31 | 32 | const gerencianet = new Gerencianet(options); 33 | 34 | gerencianet 35 | .defineSubscriptionPayMethod(params, body) 36 | .then((resposta: Promise) => { 37 | console.log(resposta); 38 | }) 39 | .catch((error: Promise) => { 40 | console.log(error); 41 | }); 42 | -------------------------------------------------------------------------------- /examples/charges/card/defineCardPayMethod.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const body = { 6 | payment: { 7 | credit_card: { 8 | installments: 1, 9 | payment_token: '6426f3abd8688639c6772963669bbb8e0eb3c319', 10 | billing_address: { 11 | street: 'Av. JK', 12 | number: 909, 13 | neighborhood: 'Bauxita', 14 | zipcode: '35400000', 15 | city: 'Ouro Preto', 16 | state: 'MG', 17 | }, 18 | customer: { 19 | name: 'Gorbadoc Oldbuck', 20 | email: 'oldbuck@gerencianet.com.br', 21 | cpf: '94271564656', 22 | birth: '1977-01-15', 23 | phone_number: '5144916523', 24 | }, 25 | }, 26 | }, 27 | }; 28 | 29 | const params = { 30 | id: 1000, 31 | }; 32 | 33 | const gerencianet = new Gerencianet(options); 34 | 35 | gerencianet 36 | .definePayMethod(params, body) 37 | .then((resposta: Promise) => { 38 | console.log(resposta); 39 | }) 40 | .catch((error: Promise) => { 41 | console.log(error); 42 | }); 43 | -------------------------------------------------------------------------------- /examples/exclusives/report/createReport.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const body = { 6 | dataMovimento: '2023-04-24', 7 | tipoRegistros: { 8 | pixRecebido: true, 9 | pixEnviadoChave: true, 10 | pixEnviadoDadosBancarios: true, 11 | estornoPixEnviado: true, 12 | pixDevolucaoEnviada: true, 13 | pixDevolucaoRecebida: true, 14 | tarifaPixEnviado: true, 15 | tarifaPixRecebido: true, 16 | estornoTarifaPixEnviado: true, 17 | saldoDiaAnterior: true, 18 | saldoDia: true, 19 | transferenciaEnviada: true, 20 | transferenciaRecebida: true, 21 | estornoTransferenciaEnviada: true, 22 | tarifaTransferenciaEnviada: true, 23 | estornoTarifaTransferenciaEnviada: true, 24 | }, 25 | }; 26 | 27 | const gerencianet = new Gerencianet(options); 28 | 29 | gerencianet 30 | .createReport([], body) 31 | .then((resposta: Promise) => { 32 | console.log(resposta); 33 | }) 34 | .catch((error: Promise) => { 35 | console.log(error); 36 | }); 37 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es2021": true, 5 | "node": true, 6 | "jest": true 7 | }, 8 | "extends": [ 9 | "airbnb-base", 10 | "plugin:prettier/recommended", 11 | "prettier" 12 | ], 13 | "globals": { 14 | "Atomics": "readonly", 15 | "SharedArrayBuffer": "readonly" 16 | }, 17 | "parser": "@typescript-eslint/parser", 18 | "parserOptions": { 19 | "ecmaVersion": 12, 20 | "sourceType": "module" 21 | }, 22 | "plugins": [ 23 | "@typescript-eslint", 24 | "prettier" 25 | ], 26 | "rules": { 27 | 28 | }, 29 | "settings": { 30 | "import/resolver": { 31 | "node": { 32 | "paths": [ 33 | "src", 34 | "examples" 35 | ], 36 | "extensions": [ 37 | ".js", 38 | ".jsx", 39 | ".ts", 40 | ".tsx" 41 | ] 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /examples/pix/cob/pixUpdateCharge.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | // Informe no body somente os dados que deseja atualizar 6 | const body = { 7 | calendario: { 8 | expiracao: 3600, 9 | }, 10 | devedor: { 11 | cpf: '94271564656', 12 | nome: 'Gorbadock Oldbuck', 13 | }, 14 | valor: { 15 | original: '123.45', 16 | }, 17 | chave: 'SUACHAVEPIX', // Informe sua chave Pix cadastrada na gerencianet 18 | infoAdicionais: [ 19 | { 20 | nome: 'Pagamento em', 21 | valor: 'NOME DO SEU ESTABELECIMENTO', 22 | }, 23 | { 24 | nome: 'Pedido', 25 | valor: 'NUMERO DO PEDIDO DO CLIENTE', 26 | }, 27 | ], 28 | }; 29 | 30 | const params = { 31 | txid: 'dt9BHlyzrb5jrFNAdfEDVpHgiOmDbVqVxd', // Informe o TxId da cobrança 32 | }; 33 | 34 | const gerencianet = new Gerencianet(options); 35 | 36 | gerencianet 37 | .pixUpdateCharge(params, body) 38 | .then((resposta: Promise) => { 39 | console.log(resposta); 40 | }) 41 | .catch((error: Promise) => { 42 | console.log(error); 43 | }); 44 | -------------------------------------------------------------------------------- /examples/charges/subscription/createOneStepCardSubscription.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 0, 7 | }; 8 | 9 | const body = { 10 | items: [ 11 | { 12 | name: 'Product One', 13 | value: 600, 14 | amount: 1, 15 | }, 16 | ], 17 | payment: { 18 | credit_card: { 19 | installments: 1, 20 | payment_token: '83d52dbd590d9ebc991938c711ddd31f65df89a5', 21 | billing_address: { 22 | street: 'Street 3', 23 | number: 10, 24 | neighborhood: 'Bauxita', 25 | zipcode: '35400000', 26 | city: 'Ouro Preto', 27 | state: 'MG', 28 | }, 29 | customer: { 30 | name: 'Gorbadoc Oldbuck', 31 | email: 'oldbuck@gerencianet.com.br', 32 | cpf: '94271564656', 33 | birth: '1977-01-15', 34 | phone_number: '5144916523', 35 | }, 36 | }, 37 | }, 38 | }; 39 | 40 | const gerencianet = new Gerencianet(options); 41 | 42 | gerencianet 43 | .oneStepSubscription(params, body) 44 | .then((resposta: Promise) => { 45 | console.log(resposta); 46 | }) 47 | .catch((error: Promise) => { 48 | console.log(error); 49 | }); 50 | -------------------------------------------------------------------------------- /examples/charges/card/createOneStepCard.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const body = { 6 | payment: { 7 | credit_card: { 8 | installments: 1, 9 | payment_token: '83d52dbd590d9ebc991938c711ddd31f65df89a5', 10 | billing_address: { 11 | street: 'Street 3', 12 | number: 10, 13 | neighborhood: 'Bauxita', 14 | zipcode: '35400000', 15 | city: 'Ouro Preto', 16 | state: 'MG', 17 | }, 18 | customer: { 19 | name: 'Gorbadoc Oldbuck', 20 | email: 'oldbuck@gerencianet.com.br', 21 | cpf: '94271564656', 22 | birth: '1977-01-15', 23 | phone_number: '5144916523', 24 | }, 25 | }, 26 | }, 27 | 28 | items: [ 29 | { 30 | name: 'Product 1', 31 | value: 1000, 32 | amount: 2, 33 | }, 34 | ], 35 | shippings: [ 36 | { 37 | name: 'Default Shipping Cost', 38 | value: 100, 39 | }, 40 | ], 41 | }; 42 | 43 | const gerencianet = new Gerencianet(options); 44 | 45 | gerencianet 46 | .createOneStepCharge([], body) 47 | .then((resposta: Promise) => { 48 | console.log(resposta); 49 | }) 50 | .catch((error: Promise) => { 51 | console.log(error); 52 | }); 53 | -------------------------------------------------------------------------------- /examples/pix/cobv/pixCreateDueCharge.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const body = { 6 | calendario: { 7 | dataDeVencimento: '2022-12-01', 8 | validadeAposVencimento: 30, 9 | }, 10 | devedor: { 11 | logradouro: 'Alameda Souza, Numero 80, Bairro Braz', 12 | cidade: 'Recife', 13 | uf: 'PE', 14 | cep: '70011750', 15 | cpf: '12345678909', 16 | nome: 'Francisco da Silva', 17 | }, 18 | valor: { 19 | original: '123.45', 20 | multa: { 21 | modalidade: 2, 22 | valorPerc: '15.00', 23 | }, 24 | juros: { 25 | modalidade: 2, 26 | valorPerc: '2.00', 27 | }, 28 | desconto: { 29 | modalidade: 1, 30 | descontoDataFixa: [ 31 | { 32 | data: '2022 - 11 - 30', 33 | valorPerc: '30.00', 34 | }, 35 | ], 36 | }, 37 | }, 38 | chave: 'suaChavePix', 39 | }; 40 | 41 | const params = { 42 | txid: 'dt9BHlyzrb5jrFNAdfEDVpHgiOmDbVq111', 43 | }; 44 | 45 | const gerencianet = new Gerencianet(options); 46 | 47 | gerencianet 48 | .pixCreateDueCharge(params, body) 49 | .then((resposta: Promise) => { 50 | console.log(resposta); 51 | }) 52 | .catch((error: Promise) => { 53 | console.log(error); 54 | }); 55 | -------------------------------------------------------------------------------- /index.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-param-reassign */ 2 | /* eslint-disable import/extensions */ 3 | import Endpoints from './src/endpoints'; 4 | import constants from './src/constants'; 5 | import { GnConfig } from './src/interfaces/gnConfig.interface'; 6 | import { GnCredentials } from './src/interfaces/gnCredentials.interface'; 7 | 8 | class Gerencianet { 9 | // eslint-disable-next-line no-undef 10 | [index: string]: any; 11 | 12 | constructor(options: GnCredentials) { 13 | if (options.pathCert || options.pix_cert) { 14 | options.certificate = options.pathCert || options.pix_cert; 15 | } 16 | 17 | const credentials: GnConfig = { 18 | client_id: options.client_id, 19 | client_secret: options.client_secret, 20 | certificate: options.certificate, 21 | sandbox: options.sandbox, 22 | }; 23 | 24 | if(options.pemKey){ 25 | credentials.pemKey = options.pemKey 26 | } 27 | 28 | const methods = {}; 29 | Object.keys(constants.APIS).forEach((endpoint) => { 30 | const key = endpoint as keyof typeof constants.APIS; 31 | Object.assign(methods, constants.APIS[key].ENDPOINTS); 32 | }); 33 | 34 | Object.keys(methods).forEach((api) => { 35 | this[api] = (params: any, body: any) => { 36 | const endpoints = new Endpoints(credentials, constants); 37 | return endpoints.run(api, params, body); 38 | }; 39 | }); 40 | } 41 | } 42 | 43 | export default Gerencianet; 44 | export { GnCredentials }; 45 | -------------------------------------------------------------------------------- /examples/charges/marketplace/createOneStepBilletMarketplace.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const body = { 6 | payment: { 7 | banking_billet: { 8 | expire_at: '2024-09-20', 9 | customer: { 10 | name: 'Gorbadoc Oldbuck', 11 | email: 'oldbuck@gerencianet.com.br', 12 | cpf: '94271564656', 13 | birth: '1977-01-15', 14 | phone_number: '5144916523', 15 | }, 16 | }, 17 | }, 18 | 19 | items: [ 20 | { 21 | name: 'Product 1', 22 | value: 500, 23 | amount: 1, 24 | marketplace: { 25 | // Defina 1, para a tarifa ser descontada apenas da conta que emitiu a cobrança 26 | // Defina 2 para a tarifa ser descontada proporcionalmente ao percentual definido para cada conta que receberá o repasse 27 | mode: 2, 28 | repasses: [ 29 | { 30 | payee_code: 'Insira_aqui_o_indentificador_da_conta_destino', 31 | percentage: 2500, 32 | }, 33 | { 34 | payee_code: 'Insira_aqui_o_indentificador_da_conta_destino', 35 | percentage: 1500, 36 | }, 37 | ], 38 | }, 39 | }, 40 | ], 41 | shippings: [ 42 | { 43 | name: 'Default Shipping Cost', 44 | value: 100, 45 | }, 46 | ], 47 | }; 48 | 49 | const gerencianet = new Gerencianet(options); 50 | 51 | gerencianet 52 | .createOneStepCharge([], body) 53 | .then((resposta: Promise) => { 54 | console.log(resposta); 55 | }) 56 | .catch((error: Promise) => { 57 | console.log(error); 58 | }); 59 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gn-api-sdk-typescript", 3 | "version": "2.0.1", 4 | "description": "Module for integration with Gerencianet API\"", 5 | "main": "dist/index.js", 6 | "types": "dist/index.d.ts", 7 | "scripts": { 8 | "build": "npx tsc -p ./tsconfig.json", 9 | "prepare": "npm run build", 10 | "postversion": "git push --tags", 11 | "test": "./node_modules/.bin/jest", 12 | "test-cov": "./node_modules/.bin/jest --coverage" 13 | }, 14 | "author": "Gerencianet - Consultoria Tecnica | Palloma Brito | João Vitor Oliveira", 15 | "license": "MIT", 16 | "repository": "gerencianet/gn-api-sdk-typescript", 17 | "homepage": "https://github.com/gerencianet/gn-api-sdk-typescript", 18 | "files": [ 19 | "dist/*", 20 | "examples" 21 | ], 22 | "keywords": [ 23 | "gerencianet", 24 | "pagamentos", 25 | "payment", 26 | "sdk", 27 | "integração", 28 | "integration", 29 | "api", 30 | "bank slip", 31 | "boleto bancario", 32 | "credit card", 33 | "cartao de credito", 34 | "pix" 35 | ], 36 | "devDependencies": { 37 | "@types/jest": "^29.2.4", 38 | "@types/node": "^15.14.9", 39 | "@typescript-eslint/eslint-plugin": "^4.22.0", 40 | "@typescript-eslint/parser": "^4.22.0", 41 | "eslint": "^7.25.0", 42 | "eslint-config-airbnb-base": "^14.2.1", 43 | "eslint-config-prettier": "^8.3.0", 44 | "eslint-plugin-import": "^2.22.1", 45 | "eslint-plugin-prettier": "^3.4.0", 46 | "jest": "^29.3.1", 47 | "prettier": "^2.2.1", 48 | "ts-jest": "^29.0.3", 49 | "ts-node": "^9.1.1", 50 | "typescript": "^4.2.4" 51 | }, 52 | "dependencies": { 53 | "axios": "^1.2.1", 54 | "fs": "*" 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /examples/charges/marketplace/createOneStepCardMarketplace.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const body = { 6 | payment: { 7 | credit_card: { 8 | installments: 1, 9 | payment_token: 'InsiraAquiUmPayeementeCode', 10 | billing_address: { 11 | street: 'Street 3', 12 | number: 10, 13 | neighborhood: 'Bauxita', 14 | zipcode: '35400000', 15 | city: 'Ouro Preto', 16 | state: 'MG', 17 | }, 18 | customer: { 19 | name: 'Gorbadoc Oldbuck', 20 | email: 'oldbuck@gerencianet.com.br', 21 | cpf: '94271564656', 22 | birth: '1977-01-15', 23 | phone_number: '5144916523', 24 | }, 25 | }, 26 | }, 27 | 28 | items: [ 29 | { 30 | name: 'Product 1', 31 | value: 500, 32 | amount: 1, 33 | marketplace: { 34 | // Defina 1, para a tarifa ser descontada apenas da conta que emitiu a cobrança 35 | // Defina 2 para a tarifa ser descontada proporcionalmente ao percentual definido para cada conta que receberá o repasse 36 | mode: 2, 37 | repasses: [ 38 | { 39 | payee_code: 'Insira_aqui_o_indentificador_da_conta_destino', 40 | percentage: 2500, 41 | }, 42 | { 43 | payee_code: 'Insira_aqui_o_indentificador_da_conta_destino', 44 | percentage: 1500, 45 | }, 46 | ], 47 | }, 48 | }, 49 | ], 50 | shippings: [ 51 | { 52 | name: 'Default Shipping Cost', 53 | value: 100, 54 | }, 55 | ], 56 | }; 57 | 58 | const gerencianet = new Gerencianet(options); 59 | 60 | gerencianet 61 | .createOneStepCharge([], body) 62 | .then((resposta: Promise) => { 63 | console.log(resposta); 64 | }) 65 | .catch((error: Promise) => { 66 | console.log(error); 67 | }); 68 | -------------------------------------------------------------------------------- /examples/charges/billet/defineBalanceSheetBillet.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import Gerencianet from 'gn-api-sdk-typescript'; 3 | import options from '../../credentials'; 4 | 5 | const params = { 6 | id: 0, 7 | }; 8 | 9 | const body = { 10 | title: 'Balancete Demonstrativo', 11 | body: [ 12 | { 13 | header: 'Demonstrativo de Consumo', 14 | tables: [ 15 | { 16 | rows: [ 17 | [ 18 | { 19 | align: 'left', 20 | color: '#000000', 21 | style: 'bold', 22 | text: 'Exemplo de despesa', 23 | colspan: 2, 24 | }, 25 | { 26 | align: 'left', 27 | color: '#000000', 28 | style: 'bold', 29 | text: 'Total lançado', 30 | colspan: 2, 31 | }, 32 | ], 33 | [ 34 | { 35 | align: 'left', 36 | color: '#000000', 37 | style: 'normal', 38 | text: 'Instalação', 39 | colspan: 2, 40 | }, 41 | { 42 | align: 'left', 43 | color: '#000000', 44 | style: 'normal', 45 | text: 'R$ 100,00', 46 | colspan: 2, 47 | }, 48 | ], 49 | ], 50 | }, 51 | ], 52 | }, 53 | { 54 | header: 'Balancete Geral', 55 | tables: [ 56 | { 57 | rows: [ 58 | [ 59 | { 60 | align: 'left', 61 | color: '#000000', 62 | style: 'normal', 63 | text: 'Confira na documentação da Gerencianet todas as configurações possíveis de um boleto balancete.', 64 | colspan: 4, 65 | }, 66 | ], 67 | ], 68 | }, 69 | ], 70 | }, 71 | ], 72 | }; 73 | 74 | const gerencianet = new Gerencianet(options); 75 | 76 | gerencianet 77 | .defineBalanceSheetBillet(params, body) 78 | .then((resposta: Promise) => { 79 | console.log(resposta); 80 | }) 81 | .catch((error: Promise) => { 82 | console.log(error); 83 | }); 84 | -------------------------------------------------------------------------------- /tests/auth.test.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import axios from 'axios'; 3 | import fs from 'fs'; 4 | import Auth from '../src/auth'; 5 | import constants from '../src/constants'; 6 | import { GnConfig } from '../src/interfaces/gnConfig.interface'; 7 | 8 | jest.mock('fs'); 9 | const mockFs = fs as jest.Mocked; 10 | mockFs.readFileSync.mockReturnValueOnce(''); 11 | 12 | jest.mock('axios', () => 13 | jest 14 | .fn() 15 | .mockResolvedValueOnce({ 16 | status: 200, 17 | data: { 18 | access_token: 'RfSfS9AJkLu7jPjOp2IbrI', 19 | token_type: 'Bearer', 20 | expires_in: 3600, 21 | scope: 'cob.read', 22 | }, 23 | }) 24 | .mockResolvedValueOnce({ 25 | status: 200, 26 | data: { 27 | access_token: '1723ad73', 28 | refresh_token: '36accb15', 29 | expires_in: 600, 30 | expire_at: '1656012603684', 31 | token_type: 'Bearer', 32 | }, 33 | }), 34 | ); 35 | 36 | const credentialsPix: GnConfig = { 37 | sandbox: false, 38 | client_id: 'Client_Id', 39 | client_secret: 'Client_Secret', 40 | certificate: 'Certificado_Pix', 41 | authRoute: { route: '/oauth/token', method: 'post' }, 42 | baseUrl: 'https://api-pix.gerencianet.com.br', 43 | }; 44 | 45 | const credentials: GnConfig = { 46 | sandbox: false, 47 | client_id: 'Client_Id', 48 | client_secret: 'Client_Secret', 49 | authRoute: { route: '/oauth/token', method: 'post' }, 50 | baseUrl: 'https://api.gerencianet.com.br/v1', 51 | }; 52 | 53 | describe('Auth Tests', () => { 54 | it.each([ 55 | { 56 | description: 'Should get Access_Token with pix certificate', 57 | options: credentialsPix, 58 | expected: { access_token: expect.any(String), token_type: 'Bearer', expires_in: 3600, scope: 'cob.read' }, 59 | }, 60 | { 61 | description: 'Should get Access_Token without pix certificate [API EMISSÕES]', 62 | options: credentials, 63 | expected: { access_token: '1723ad73', refresh_token: '36accb15', expires_in: 600, expire_at: '1656012603684', token_type: 'Bearer' }, 64 | }, 65 | ])('TEST $# : $description', async ({ options, expected }) => { 66 | const auth = new Auth(options, constants); 67 | const res = await auth.getAccessToken(); 68 | expect(res).toMatchObject(expected); 69 | expect(axios).toHaveBeenCalled(); 70 | }); 71 | }); 72 | -------------------------------------------------------------------------------- /src/auth.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable camelcase */ 2 | /* eslint-disable import/extensions */ 3 | import axios from 'axios'; 4 | import https from 'https'; 5 | import sdkPackage from '../package.json'; 6 | import { GnConfig } from './interfaces/gnConfig.interface'; 7 | import { EndpointInterface } from './interfaces/endpoint.interface'; 8 | 9 | class Auth { 10 | private constants: any; 11 | 12 | private client_id: String; 13 | 14 | private client_secret: String; 15 | 16 | private baseUrl?: String; 17 | 18 | private agent!: https.Agent; 19 | 20 | private authRoute!: EndpointInterface; 21 | 22 | constructor(options: GnConfig, constants: any) { 23 | this.constants = constants; 24 | this.client_id = options.client_id; 25 | this.client_secret = options.client_secret; 26 | this.baseUrl = options.baseUrl; 27 | 28 | if (options.agent) { 29 | this.agent = options.agent; 30 | } 31 | if (options.authRoute) { 32 | this.authRoute = options.authRoute; 33 | } 34 | } 35 | 36 | public getAccessToken(): Promise { 37 | let postParams: any; 38 | 39 | if (this.constants.APIS.DEFAULT.URL.PRODUCTION === this.baseUrl || this.constants.APIS.DEFAULT.URL.SANDBOX === this.baseUrl) { 40 | postParams = { 41 | method: 'POST', 42 | url: this.baseUrl + this.constants.APIS.DEFAULT.ENDPOINTS.authorize.route, 43 | headers: { 44 | 'api-sdk': `typescript-${sdkPackage.version}`, 45 | }, 46 | data: { 47 | grant_type: 'client_credentials', 48 | }, 49 | auth: { 50 | username: this.client_id, 51 | password: this.client_secret, 52 | }, 53 | }; 54 | } else { 55 | const data_credentials = `${this.client_id}:${this.client_secret}`; 56 | const auth = Buffer.from(data_credentials).toString('base64'); 57 | 58 | postParams = { 59 | method: 'POST', 60 | url: this.baseUrl + this.authRoute.route, 61 | headers: { 62 | Authorization: `Basic ${auth}`, 63 | 'Content-Type': 'application/json', 64 | 'api-sdk': `typescript-${sdkPackage.version}`, 65 | }, 66 | httpsAgent: this.agent, 67 | data: { 68 | grant_type: 'client_credentials', 69 | }, 70 | }; 71 | } 72 | 73 | const response = axios(postParams) 74 | .then((res: any) => { 75 | return res.data; 76 | }) 77 | .catch((error: any) => { 78 | return error.response.data; 79 | }); 80 | 81 | return response; 82 | } 83 | } 84 | 85 | export default Auth; 86 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gn-api-sdk-typescript 2 | 3 | > A Typescript module for integration of your backend with the payment services provided by [Gerencianet](http://gerencianet.com.br). 4 | 5 | > Um módulo Typescript para integrar seu backend com os serviços de pagamento da [Gerencianet](http://gerencianet.com.br). 6 | 7 | ## Instalação 8 | 9 | ```bash 10 | $ npm install gn-api-sdk-typescript 11 | ``` 12 | 13 | ## Uso Básico 14 | 15 | Importe o módulo: 16 | 17 | ```typescript 18 | import Gerencianet from 'gn-api-sdk-typescript'; 19 | ``` 20 | 21 | Insira suas credenciais e defina se deseja usar o sandbox ou não. 22 | Você também pode usar o arquivo [examples/config.ts](examples/config.ts) de modelo. 23 | 24 | ```typescript 25 | export = { 26 | // PRODUÇÃO = false 27 | // HOMOLOGAÇÃO = true 28 | sandbox: false, 29 | client_id: 'seuclient_id', 30 | client_secret: 'seuclient_secret', 31 | certificate: 'caminhoAteOCertificadoPix', 32 | }; 33 | ``` 34 | 35 | Instancie o módulo passando as options: 36 | 37 | ```typescript 38 | const gerencianet = Gerencianet(options); 39 | ``` 40 | 41 | Crie uma cobrança: 42 | 43 | ```typescript 44 | var body = { 45 | items: [ 46 | { 47 | name: 'Product A', 48 | value: 1000, 49 | amount: 2, 50 | }, 51 | ], 52 | }; 53 | 54 | gerencianet 55 | .createCharge({}, body) 56 | .then((resposta: any) => { 57 | console.log(resposta); 58 | }) 59 | .catch((error: Promise) => { 60 | console.log(error); 61 | }) 62 | .done(); 63 | ``` 64 | 65 | ## Exemplos 66 | 67 | Para executar os exemplos, clone este repo e instale as dependências: 68 | 69 | ```bash 70 | $ git clone git@github.com:gerencianet/gn-api-sdk-typescript.git 71 | $ cd gn-api-sdk-typescript/examples 72 | $ npm install 73 | ``` 74 | 75 | Defina suas credenciais em config.ts: 76 | 77 | ```typescript 78 | export = { 79 | // PRODUÇÃO = false 80 | // HOMOLOGAÇÃO = true 81 | sandbox: false, 82 | client_id: 'seuclient_id', 83 | client_secret: 'seuclient_secret', 84 | certificate: 'caminhoAteOCertificadoPix', 85 | }; 86 | ``` 87 | 88 | Em seguida, execute o exemplo que você deseja: 89 | 90 | ```bash 91 | $ ts-node createCharge.ts 92 | ``` 93 | 94 | ## Documentação 95 | 96 | A documentação completa com todos os endpoints disponíveis você encontra em: https://dev.gerencianet.com.br/. 97 | 98 | ## License 99 | 100 | [MIT](LICENSE) 101 | -------------------------------------------------------------------------------- /tests/endpoints.test.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import fs from 'fs'; 3 | import Auth from '../src/auth'; 4 | import constants from '../src/constants'; 5 | import Endpoints from '../src/endpoints'; 6 | 7 | const options = { 8 | sandbox: false, 9 | client_id: 'Client_Id', 10 | client_secret: 'Client_Secret', 11 | certificate: 'Certificado_Pix', 12 | authRoute: { route: '/oauth/token', method: 'post' }, 13 | baseUrl: 'https://api-pix.gerencianet.com.br', 14 | }; 15 | 16 | const pixChargeCreated = { 17 | calendario: { 18 | criacao: '2020-09-09T20:15:00.358Z', 19 | expiracao: 3600, 20 | }, 21 | txid: '7978c0c97ea847e78e8849634473c1f1', 22 | revisao: 0, 23 | loc: { 24 | id: 789, 25 | location: 'pix.example.com/qr/v2/9d36b84fc70b478fb95c12729b90ca25', 26 | tipoCob: 'cob', 27 | }, 28 | location: 'pix.example.com/qr/v2/9d36b84fc70b478fb95c12729b90ca25', 29 | status: 'ATIVA', 30 | devedor: { 31 | cnpj: '12345678000195', 32 | nome: 'Empresa de Serviços SA', 33 | }, 34 | valor: { 35 | original: '567.89', 36 | }, 37 | chave: 'a1f4102e-a446-4a57-bcce-6fa48899c1d1', 38 | solicitacaoPagador: 'Informe o número ou identificador do pedido.', 39 | }; 40 | 41 | jest.spyOn(Endpoints.prototype, 'req') 42 | .mockResolvedValueOnce(pixChargeCreated) 43 | .mockImplementationOnce(async () => { 44 | return new Error('FALHA AO LER O CERTIFICADO'); 45 | }) 46 | .mockResolvedValueOnce(''); 47 | 48 | jest.spyOn(Auth.prototype, 'getAccessToken').mockImplementation(() => { 49 | return Promise.resolve({ 50 | access_token: 'RfSfS9AJkLu7jPjOp2IbrI', 51 | token_type: 'Bearer', 52 | expires_in: 3600, 53 | scope: 'cob.read', 54 | }); 55 | }); 56 | 57 | jest.mock('fs'); 58 | const mockFs = fs as jest.Mocked; 59 | mockFs.readFileSync.mockReturnValueOnce(''); 60 | 61 | // eslint-disable-next-line prettier/prettier 62 | jest.mock('axios', () =>jest.fn() 63 | .mockResolvedValueOnce({ 64 | status: 200, 65 | data: { 66 | access_token: 'RfSfS9AJkLu7jPjOp2IbrI', 67 | token_type: 'Bearer', 68 | expires_in: 3600, 69 | scope: 'cob.read', 70 | }, 71 | }) 72 | .mockResolvedValueOnce({ 73 | status: 200, 74 | data: { 75 | access_token: '1723ad73', 76 | refresh_token: '36accb15', 77 | expires_in: 600, 78 | expire_at: '1656012603684', 79 | token_type: 'Bearer', 80 | }, 81 | }), 82 | ); 83 | 84 | describe('Endpoints Tests', () => { 85 | const pixEndpoint = { 86 | name: 'pixCreateCharge', 87 | params: { txid: 'dt9BHlyzrb5jrFNAdfEDVpHgiOmDbVq111' }, 88 | body: { 89 | calendario: { 90 | expiracao: 3600, 91 | }, 92 | valor: { 93 | original: '0.01', 94 | }, 95 | chave: 'CHAVEPIX', 96 | }, 97 | }; 98 | it('TEST 0: Shoud get Access Token', async () => { 99 | const endpoints = new Endpoints(options, constants); 100 | const res = await endpoints.getAccessToken(); 101 | 102 | expect(res).toBe('RfSfS9AJkLu7jPjOp2IbrI'); 103 | }); 104 | 105 | it.each([ 106 | { 107 | description: 'should create a charge', 108 | body: pixEndpoint, 109 | expected: pixChargeCreated, 110 | }, 111 | { 112 | description: 'should throw "FALHA AO LER O CERTIFICADO"', 113 | body: pixEndpoint, 114 | expected: new Error('FALHA AO LER O CERTIFICADO'), 115 | }, 116 | ])('TEST $# : $description', async ({ body, expected }) => { 117 | const endpoints = new Endpoints(options, constants); 118 | const res = await endpoints.run(body.name, body.params, body.body); 119 | 120 | expect(res).toStrictEqual(expected); 121 | }); 122 | 123 | it.each([ 124 | { 125 | description: 'shoud get the request params [createRequest][PIX]', 126 | name: 'listAccountConfig', 127 | route: '/v2/gn/config', 128 | params: [], 129 | expected: { 130 | method: 'get', 131 | url: 'https://api-pix.gerencianet.com.br/v2/gn/config', 132 | headers: expect.anything(), 133 | data: expect.anything(), 134 | httpsAgent: expect.anything(), 135 | }, 136 | }, 137 | { 138 | description: 'shoud get the request params [listPlans][SUBSCRIPTION]', 139 | name: 'listPlans', 140 | route: '/plans', 141 | params: [], 142 | expected: { 143 | method: 'get', 144 | url: 'https://api.gerencianet.com.br/v1/plans', 145 | headers: expect.anything(), 146 | data: [], 147 | }, 148 | }, 149 | ])('TEST $# : $description', async ({ name, route, params, expected }) => { 150 | const endpoints = new Endpoints(options, constants); 151 | await endpoints.run(name, params, []); 152 | const res = await endpoints.createRequest(route); 153 | expect(res).toStrictEqual(expected); 154 | }); 155 | }); 156 | -------------------------------------------------------------------------------- /src/endpoints.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/extensions */ 2 | import fs from 'fs'; 3 | import https from 'https'; 4 | import axios from 'axios'; 5 | import Auth from './auth'; 6 | import sdkPackage from '../package.json'; 7 | import { GnConfig } from './interfaces/gnConfig.interface'; 8 | import { EndpointInterface } from './interfaces/endpoint.interface'; 9 | 10 | class Endpoints { 11 | private options: GnConfig; 12 | 13 | private constants: any; 14 | 15 | private agent!: https.Agent; 16 | 17 | private endpoint!: EndpointInterface; 18 | 19 | private body: any; 20 | 21 | private params: any; 22 | 23 | constructor(options: GnConfig, constants: any) { 24 | this.options = options; 25 | this.constants = constants; 26 | } 27 | 28 | public run(name: any, params: any, body: any): Promise { 29 | if (Object.keys(this.constants.APIS.DEFAULT.ENDPOINTS).includes(name)) { 30 | this.endpoint = this.constants.APIS.DEFAULT.ENDPOINTS[name]; 31 | this.options.baseUrl = this.options.sandbox ? this.constants.APIS.DEFAULT.URL.SANDBOX : this.constants.APIS.DEFAULT.URL.PRODUCTION; 32 | } else { 33 | Object.keys(this.constants.APIS).forEach((api) => { 34 | if (Object.keys(this.constants.APIS[api].ENDPOINTS).includes(name)) { 35 | this.endpoint = this.constants.APIS[api].ENDPOINTS[name]; 36 | this.options.baseUrl = this.options.sandbox ? this.constants.APIS[api].URL.SANDBOX : this.constants.APIS[api].URL.PRODUCTION; 37 | this.options.authRoute = this.constants.APIS[api].ENDPOINTS.authorize; 38 | } 39 | }); 40 | 41 | try { 42 | if (this.options.certificate) { 43 | if(this.options.pemKey){ 44 | this.agent = new https.Agent({ 45 | cert: fs.readFileSync(this.options.certificate), 46 | key: fs.readFileSync(this.options.pemKey), 47 | passphrase: '', 48 | }); 49 | }else{ 50 | this.agent = new https.Agent({ 51 | pfx: fs.readFileSync(this.options.certificate), 52 | passphrase: '', 53 | }); 54 | } 55 | this.options.agent = this.agent; 56 | } 57 | } catch (error) { 58 | throw new Error(`FALHA AO LER O CERTIFICADO`); 59 | } 60 | } 61 | 62 | this.body = body; 63 | this.params = [params]; 64 | 65 | return this.req(); 66 | } 67 | 68 | public getAccessToken(): Promise { 69 | const gnAuth = new Auth(this.options, this.constants); 70 | return gnAuth 71 | .getAccessToken() 72 | .then((response) => { 73 | return response.access_token; 74 | }) 75 | .catch((err) => { 76 | return err; 77 | }); 78 | } 79 | 80 | public async req() { 81 | const req = await this.createRequest(this.endpoint.route); 82 | 83 | return axios(req) 84 | .then((res: any) => { 85 | return res.data; 86 | }) 87 | .catch((error: any) => { 88 | throw error.response.data; 89 | }); 90 | } 91 | 92 | public async createRequest(route: any): Promise { 93 | // eslint-disable-next-line no-useless-escape 94 | const regex = /\:(\w+)/g; 95 | let query = ''; 96 | const placeholders = route.match(regex) || []; 97 | const params: any = {}; 98 | 99 | if (this.params) { 100 | this.params.forEach((obj: any) => { 101 | if (obj) { 102 | Object.entries(obj).forEach((entrie: any) => { 103 | // eslint-disable-next-line prefer-destructuring 104 | params[entrie[0]] = entrie[1]; 105 | }); 106 | } 107 | }); 108 | } 109 | 110 | const getVariables = () => { 111 | return placeholders.map((item: any) => { 112 | return item.replace(':', ''); 113 | }); 114 | }; 115 | 116 | const updateRoute = () => { 117 | const variables = getVariables(); 118 | variables.forEach((value: any, index: any) => { 119 | if (params[value]) { 120 | // eslint-disable-next-line no-param-reassign 121 | route = route.replace(placeholders[index], params[value]); 122 | delete params[value]; 123 | } 124 | }); 125 | }; 126 | 127 | const getQueryString = () => { 128 | const keys = Object.keys(params); 129 | const initial = keys.length >= 1 ? '?' : ''; 130 | return keys.reduce((previous, current, index, array) => { 131 | const next = index === array.length - 1 ? '' : '&'; 132 | return [previous, current, '=', params[current], next].join(''); 133 | }, initial); 134 | }; 135 | 136 | updateRoute(); 137 | query = getQueryString(); 138 | 139 | const accessToken = await this.getAccessToken(); 140 | 141 | const headers: any = { 142 | 'api-sdk': `typescript-${sdkPackage.version}`, 143 | 'Content-Type': 'application/json', 144 | authorization: `Bearer ${accessToken}`, 145 | }; 146 | 147 | headers['x-skip-mtls-checking'] = !this.options.validateMtls; 148 | 149 | if (this.options.partnerToken) { 150 | headers['partner-token'] = this.options.partnerToken; 151 | } 152 | 153 | const req: any = { 154 | method: this.endpoint.method, 155 | url: [this.options.baseUrl, route, query].join(''), 156 | headers, 157 | data: this.body, 158 | }; 159 | 160 | if (this.options.baseUrl !== this.constants.APIS.DEFAULT.URL.PRODUCTION && this.options.baseUrl !== this.constants.APIS.DEFAULT.URL.SANDBOX) { 161 | req.httpsAgent = this.agent; 162 | } 163 | 164 | return req; 165 | } 166 | } 167 | export default Endpoints; 168 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig.json to read more about this file */ 4 | 5 | /* Basic Options */ 6 | // "incremental": true, /* Enable incremental compilation */ 7 | "target": "ES6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ 8 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ 9 | // "lib": [], /* Specify library files to be included in the compilation. */ 10 | // "allowJs": true, /* Allow javascript files to be compiled. */ 11 | // "checkJs": true, /* Report errors in .js files. */ 12 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */ 13 | "declaration": true, /* Generates corresponding '.d.ts' file. */ 14 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ 15 | // "sourceMap": true, /* Generates corresponding '.map' file. */ 16 | // "outFile": "./", /* Concatenate and emit output to single file. */ 17 | "outDir": "./dist", /* Redirect output structure to the directory. */ 18 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 19 | // "composite": true, /* Enable project compilation */ 20 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ 21 | // "removeComments": true, /* Do not emit comments to output. */ 22 | // "noEmit": true, /* Do not emit outputs. */ 23 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 24 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 25 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 26 | 27 | /* Strict Type-Checking Options */ 28 | "strict": true, /* Enable all strict type-checking options. */ 29 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 30 | // "strictNullChecks": true, /* Enable strict null checks. */ 31 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 32 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ 33 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 34 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 35 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 36 | 37 | /* Additional Checks */ 38 | // "noUnusedLocals": true, /* Report errors on unused locals. */ 39 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 40 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 41 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 42 | // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ 43 | // "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */ 44 | 45 | /* Module Resolution Options */ 46 | // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ 47 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 48 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 49 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ 50 | // "typeRoots": [], /* List of folders to include type definitions from. */ 51 | // "types": [], /* Type declaration files to be included in compilation. */ 52 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 53 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 54 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 55 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 56 | 57 | /* Source Map Options */ 58 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 59 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 60 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 61 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 62 | 63 | /* Experimental Options */ 64 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 65 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 66 | 67 | /* Advanced Options */ 68 | "skipLibCheck": true, /* Skip type checking of declaration files. */ 69 | "forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */ 70 | "resolveJsonModule": true 71 | }, 72 | "exclude": [ 73 | "examples" 74 | ] 75 | } 76 | -------------------------------------------------------------------------------- /src/constants.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | APIS: { 3 | DEFAULT: { 4 | URL: { 5 | PRODUCTION: 'https://api.gerencianet.com.br/v1', 6 | SANDBOX: 'https://sandbox.gerencianet.com.br/v1', 7 | }, 8 | ENDPOINTS: { 9 | authorize: { 10 | route: '/authorize', 11 | method: 'post', 12 | }, 13 | sendSubscriptionLinkEmail: { 14 | route: '/charge/:id/subscription/resend', 15 | method: 'post', 16 | }, 17 | oneStepSubscription: { 18 | route: '/plan/:id/subscription/one-step', 19 | method: 'post', 20 | }, 21 | settleCarnet: { 22 | route: '/carnet/:id/settle', 23 | method: 'put', 24 | }, 25 | oneStepSubscriptionLink: { 26 | route: '/plan/:id/subscription/one-step/link', 27 | method: 'post', 28 | }, 29 | sendLinkEmail: { 30 | route: '/charge/:id/link/resend', 31 | method: 'post', 32 | }, 33 | createOneStepLink: { 34 | route: '/charge/one-step/link', 35 | method: 'post', 36 | }, 37 | createCharge: { 38 | route: '/charge', 39 | method: 'post', 40 | }, 41 | detailCharge: { 42 | route: '/charge/:id', 43 | method: 'get', 44 | }, 45 | updateChargeMetadata: { 46 | route: '/charge/:id/metadata', 47 | method: 'put', 48 | }, 49 | updateBillet: { 50 | route: '/charge/:id/billet', 51 | method: 'put', 52 | }, 53 | definePayMethod: { 54 | route: '/charge/:id/pay', 55 | method: 'post', 56 | }, 57 | cancelCharge: { 58 | route: '/charge/:id/cancel', 59 | method: 'put', 60 | }, 61 | createCarnet: { 62 | route: '/carnet', 63 | method: 'post', 64 | }, 65 | detailCarnet: { 66 | route: '/carnet/:id', 67 | method: 'get', 68 | }, 69 | updateCarnetParcel: { 70 | route: '/carnet/:id/parcel/:parcel', 71 | method: 'put', 72 | }, 73 | updateCarnetMetadata: { 74 | route: '/carnet/:id/metadata', 75 | method: 'put', 76 | }, 77 | getNotification: { 78 | route: '/notification/:token', 79 | method: 'get', 80 | }, 81 | listPlans: { 82 | route: '/plans', 83 | method: 'get', 84 | }, 85 | createPlan: { 86 | route: '/plan', 87 | method: 'post', 88 | }, 89 | deletePlan: { 90 | route: '/plan/:id', 91 | method: 'delete', 92 | }, 93 | createSubscription: { 94 | route: '/plan/:id/subscription', 95 | method: 'post', 96 | }, 97 | detailSubscription: { 98 | route: '/subscription/:id', 99 | method: 'get', 100 | }, 101 | defineSubscriptionPayMethod: { 102 | route: '/subscription/:id/pay', 103 | method: 'post', 104 | }, 105 | cancelSubscription: { 106 | route: '/subscription/:id/cancel', 107 | method: 'put', 108 | }, 109 | updateSubscriptionMetadata: { 110 | route: '/subscription/:id/metadata', 111 | method: 'put', 112 | }, 113 | getInstallments: { 114 | route: '/installments', 115 | method: 'get', 116 | }, 117 | sendBilletEmail: { 118 | route: '/charge/:id/billet/resend', 119 | method: 'post', 120 | }, 121 | createChargeHistory: { 122 | route: '/charge/:id/history', 123 | method: 'post', 124 | }, 125 | sendCarnetEmail: { 126 | route: '/carnet/:id/resend', 127 | method: 'post', 128 | }, 129 | sendCarnetParcelEmail: { 130 | route: '/carnet/:id/parcel/:parcel/resend', 131 | method: 'post', 132 | }, 133 | createCarnetHistory: { 134 | route: '/carnet/:id/history', 135 | method: 'post', 136 | }, 137 | cancelCarnet: { 138 | route: '/carnet/:id/cancel', 139 | method: 'put', 140 | }, 141 | cancelCarnetParcel: { 142 | route: '/carnet/:id/parcel/:parcel/cancel', 143 | method: 'put', 144 | }, 145 | linkCharge: { 146 | route: '/charge/:id/link', 147 | method: 'post', 148 | }, 149 | defineLinkPayMethod: { 150 | route: '/charge/:id/link', 151 | method: 'post', 152 | }, 153 | updateChargeLink: { 154 | route: '/charge/:id/link', 155 | method: 'put', 156 | }, 157 | updatePlan: { 158 | route: '/plan/:id', 159 | method: 'put', 160 | }, 161 | createSubscriptionHistory: { 162 | route: '/subscription/:id/history', 163 | method: 'post', 164 | }, 165 | defineBalanceSheetBillet: { 166 | route: '/charge/:id/balance-sheet', 167 | method: 'post', 168 | }, 169 | settleCharge: { 170 | route: '/charge/:id/settle', 171 | method: 'put', 172 | }, 173 | settleCarnetParcel: { 174 | route: '/carnet/:id/parcel/:parcel/settle', 175 | method: 'put', 176 | }, 177 | createOneStepCharge: { 178 | route: '/charge/one-step', 179 | method: 'post', 180 | }, 181 | }, 182 | }, 183 | PIX: { 184 | URL: { 185 | PRODUCTION: 'https://api-pix.gerencianet.com.br', 186 | SANDBOX: 'https://api-pix-h.gerencianet.com.br', 187 | }, 188 | ENDPOINTS: { 189 | authorize: { 190 | route: '/oauth/token', 191 | method: 'post', 192 | }, 193 | pixCreateDueCharge: { 194 | route: '/v2/cobv/:txid', 195 | method: 'put', 196 | }, 197 | pixUpdateDueCharge: { 198 | route: '/v2/cobv/:txid', 199 | method: 'patch', 200 | }, 201 | pixDetailDueCharge: { 202 | route: '/v2/cobv/:txid', 203 | method: 'get', 204 | }, 205 | pixListDueCharges: { 206 | route: '/v2/cobv/', 207 | method: 'get', 208 | }, 209 | createReport: { 210 | route: '/v2/gn/relatorios/extrato-conciliacao', 211 | method: 'post', 212 | }, 213 | detailReport: { 214 | route: '/v2/gn/relatorios/:id', 215 | method: 'get', 216 | }, 217 | pixCreateCharge: { 218 | route: '/v2/cob/:txid', 219 | method: 'put', 220 | }, 221 | pixUpdateCharge: { 222 | route: '/v2/cob/:txid', 223 | method: 'patch', 224 | }, 225 | pixCreateImmediateCharge: { 226 | route: '/v2/cob', 227 | method: 'post', 228 | }, 229 | pixDetailCharge: { 230 | route: '/v2/cob/:txid', 231 | method: 'get', 232 | }, 233 | pixListCharges: { 234 | route: '/v2/cob', 235 | method: 'get', 236 | }, 237 | pixDetailReceived: { 238 | route: '/v2/pix/:e2eId', 239 | method: 'get', 240 | }, 241 | pixReceivedList: { 242 | route: '/v2/pix', 243 | method: 'get', 244 | }, 245 | pixSend: { 246 | route: '/v2/pix/:idEnvio', 247 | method: 'put', 248 | }, 249 | pixSendDetail: { 250 | route: '/v2/gn/pix/enviados/:e2eid', 251 | method: 'get', 252 | }, 253 | pixSendList: { 254 | route: '/v2/gn/pix/enviados', 255 | method: 'get', 256 | }, 257 | pixDevolution: { 258 | route: '/v2/pix/:e2eId/devolucao/:id', 259 | method: 'put', 260 | }, 261 | pixDetailDevolution: { 262 | route: '/v2/pix/:e2eId/devolucao/:id', 263 | method: 'get', 264 | }, 265 | pixConfigWebhook: { 266 | route: '/v2/webhook/:chave', 267 | method: 'put', 268 | }, 269 | pixDetailWebhook: { 270 | route: '/v2/webhook/:chave', 271 | method: 'get', 272 | }, 273 | pixListWebhook: { 274 | route: '/v2/webhook', 275 | method: 'get', 276 | }, 277 | pixDeleteWebhook: { 278 | route: '/v2/webhook/:chave', 279 | method: 'delete', 280 | }, 281 | pixCreateLocation: { 282 | route: '/v2/loc', 283 | method: 'post', 284 | }, 285 | pixLocationList: { 286 | route: '/v2/loc', 287 | method: 'get', 288 | }, 289 | pixDetailLocation: { 290 | route: '/v2/loc/:id', 291 | method: 'get', 292 | }, 293 | pixGenerateQRCode: { 294 | route: '/v2/loc/:id/qrcode', 295 | method: 'get', 296 | }, 297 | pixUnlinkTxidLocation: { 298 | route: '/v2/loc/:id/txid', 299 | method: 'delete', 300 | }, 301 | pixCreateEvp: { 302 | route: '/v2/gn/evp', 303 | method: 'post', 304 | }, 305 | pixListEvp: { 306 | route: '/v2/gn/evp', 307 | method: 'get', 308 | }, 309 | pixDeleteEvp: { 310 | route: '/v2/gn/evp/:chave', 311 | method: 'delete', 312 | }, 313 | getAccountBalance: { 314 | route: '/v2/gn/saldo', 315 | method: 'get', 316 | }, 317 | updateAccountConfig: { 318 | route: '/v2/gn/config', 319 | method: 'put', 320 | }, 321 | listAccountConfig: { 322 | route: '/v2/gn/config', 323 | method: 'get', 324 | }, 325 | pixSplitDetailCharge: { 326 | route: '/v2/gn/split/cob/:txid', 327 | method: 'get', 328 | }, 329 | pixSplitLinkCharge: { 330 | route: '/v2/gn/split/cob/:txid/vinculo/:splitConfigId', 331 | method: 'put', 332 | }, 333 | pixSplitUnlinkCharge: { 334 | route: '/v2/gn/split/cob/:txid/vinculo/:splitConfigId', 335 | method: 'delete', 336 | }, 337 | pixSplitDetailDueCharge: { 338 | route: '/v2/gn/split/cobv/:txid', 339 | method: 'get', 340 | }, 341 | pixSplitLinkDueCharge: { 342 | route: '/v2/gn/split/cobv/:txid/vinculo/:splitConfigId', 343 | method: 'put', 344 | }, 345 | pixSplitUnlinkDueCharge: { 346 | route: '/v2/gn/split/cobv/:txid/vinculo/:splitConfigId', 347 | method: 'delete', 348 | }, 349 | pixSplitConfig: { 350 | route: '/v2/gn/split/config', 351 | method: 'post', 352 | }, 353 | pixSplitConfigId: { 354 | route: '/v2/gn/split/config/:id', 355 | method: 'put', 356 | }, 357 | pixSplitDetailConfig: { 358 | route: '/v2/gn/split/config/:id', 359 | method: 'get', 360 | }, 361 | }, 362 | }, 363 | OPENFINANCE: { 364 | URL: { 365 | PRODUCTION: 'https://apis.gerencianet.com.br/open-finance', 366 | SANDBOX: 'https://apis-h.gerencianet.com.br/open-finance', 367 | }, 368 | ENDPOINTS: { 369 | authorize: { 370 | route: '/oauth/token', 371 | method: 'post', 372 | }, 373 | ofListParticipants: { 374 | route: '/participantes/', 375 | method: 'GET', 376 | }, 377 | ofStartPixPayment: { 378 | route: '/pagamentos/pix', 379 | method: 'POST', 380 | }, 381 | ofListPixPayment: { 382 | route: '/pagamentos/pix', 383 | method: 'GET', 384 | }, 385 | ofConfigUpdate: { 386 | route: '/config', 387 | method: 'PUT', 388 | }, 389 | ofConfigDetail: { 390 | route: '/config', 391 | method: 'GET', 392 | }, 393 | ofDevolutionPix: { 394 | route: '/pagamentos/pix/:identificadorPagamento/devolver', 395 | method: 'post', 396 | }, 397 | }, 398 | }, 399 | PAGAMENTOS: { 400 | URL: { 401 | PRODUCTION: 'https://apis.gerencianet.com.br/pagamento', 402 | SANDBOX: 'https://apis-h.gerencianet.com.br/pagamento', 403 | }, 404 | ENDPOINTS: { 405 | authorize: { 406 | route: '/oauth/token', 407 | method: 'post', 408 | }, 409 | payDetailBarCode: { 410 | route: '/codBarras/:codBarras', 411 | method: 'GET', 412 | }, 413 | payRequestBarCode: { 414 | route: '/codBarras/:codBarras', 415 | method: 'POST', 416 | }, 417 | payDetailPayment: { 418 | route: '/:idPagamento', 419 | method: 'GET', 420 | }, 421 | payListPayments: { 422 | route: '/resumo', 423 | method: 'GET', 424 | }, 425 | }, 426 | }, 427 | CONTAS: { 428 | URL: { 429 | PRODUCTION: 'https://apis.gerencianet.com.br', 430 | SANDBOX: 'https://apis-h.gerencianet.com.br', 431 | }, 432 | ENDPOINTS: { 433 | authorize: { 434 | route: '/oauth/token', 435 | method: 'post', 436 | }, 437 | createAccount: { 438 | route: '/cadastro/conta-simplificada', 439 | method: 'post', 440 | }, 441 | getAccountCertificate: { 442 | route: '/cadastro/conta-simplificada/:identificador/certificado', 443 | method: 'get', 444 | }, 445 | getAccountCredentials: { 446 | route: '/cadastro/conta-simplificada/:identificador/credenciais', 447 | method: 'get', 448 | }, 449 | accountConfigWebhook: { 450 | route: '/cadastro/webhook', 451 | method: 'post', 452 | }, 453 | accountDeleteWebhook: { 454 | route: '/cadastro/webhook/:identificadorWebhook', 455 | method: 'delete', 456 | }, 457 | accountDetailWebhook: { 458 | route: '/cadastro/webhook/:identificadorWebhook', 459 | method: 'get', 460 | }, 461 | accountListWebhook: { 462 | route: '/cadastro/webhooks', 463 | method: 'get', 464 | }, 465 | }, 466 | }, 467 | }, 468 | }; 469 | --------------------------------------------------------------------------------