btrz-api-client 8.7.2 → 8.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40,8 +40,25 @@ function terminalPaymentsFactory(_ref) {
40
40
  }
41
41
  };
42
42
 
43
+ var webhooks = {
44
+ getnet: function getnet(_ref4) {
45
+ var data = _ref4.data,
46
+ providerId = _ref4.providerId,
47
+ _ref4$headers = _ref4.headers,
48
+ headers = _ref4$headers === undefined ? {} : _ref4$headers;
49
+
50
+ return client({
51
+ url: "/terminal-payments/webhooks/getnet/" + providerId,
52
+ method: "post",
53
+ headers: headers,
54
+ data: data
55
+ });
56
+ }
57
+ };
58
+
43
59
  return {
44
- mit: mit
60
+ mit: mit,
61
+ webhooks: webhooks
45
62
  };
46
63
  }
47
64
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "btrz-api-client",
3
- "version": "8.7.2",
3
+ "version": "8.8.0",
4
4
  "description": "Api client for Betterez endpoints",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -21,8 +21,20 @@ function terminalPaymentsFactory({client, internalAuthTokenProvider}) {
21
21
  }
22
22
  };
23
23
 
24
+ const webhooks = {
25
+ getnet({data, providerId, headers = {}}) {
26
+ return client({
27
+ url: `/terminal-payments/webhooks/getnet/${providerId}`,
28
+ method: "post",
29
+ headers,
30
+ data
31
+ });
32
+ }
33
+ };
34
+
24
35
  return {
25
- mit
36
+ mit,
37
+ webhooks
26
38
  };
27
39
  }
28
40
 
@@ -1,3 +1,4 @@
1
+ const {expect} = require("chai");
1
2
  const {
2
3
  axiosMock, expectRequest
3
4
  } = require("../../test-helpers.js");
@@ -6,42 +7,83 @@ const api = require("../../../src/client.js").createApiClient({
6
7
  });
7
8
 
8
9
  describe("btrzpay/terminal-payments", () => {
9
- const token = "token";
10
- const jwtToken = "I owe you a JWT token";
11
- const query = {providerId: "123"};
12
-
13
10
  afterEach(() => {
14
11
  axiosMock.reset();
15
12
  });
16
13
 
17
- it("should update a MIT terminal payment", () => {
18
- axiosMock.onPut("/terminal-payments/mit/1").reply(expectRequest({
19
- statusCode: 200, token, jwtToken, query
20
- }));
21
- return api.btrzpay.terminalPayments.mit.update({
22
- token,
23
- jwtToken,
24
- query,
25
- id: 1,
26
- terminalPayment: {
27
- referenceNumber: "1",
28
- result: {
29
- id: "1",
30
- paymentStatus: "CONFIRMED"
14
+ describe("MIT terminal payments", () => {
15
+ const token = "token";
16
+ const jwtToken = "I owe you a JWT token";
17
+ const query = {providerId: "123"};
18
+
19
+ it("should update a MIT terminal payment", () => {
20
+ axiosMock.onPut("/terminal-payments/mit/1").reply(expectRequest({
21
+ statusCode: 200, token, jwtToken, query
22
+ }));
23
+ return api.btrzpay.terminalPayments.mit.update({
24
+ token,
25
+ jwtToken,
26
+ query,
27
+ id: 1,
28
+ terminalPayment: {
29
+ referenceNumber: "1",
30
+ result: {
31
+ id: "1",
32
+ paymentStatus: "CONFIRMED"
33
+ }
31
34
  }
32
- }
35
+ });
36
+ });
37
+
38
+ it("should get the MIT terminal payment", () => {
39
+ axiosMock.onGet("/terminal-payments/mit/1", {params: query}).reply(expectRequest({
40
+ statusCode: 200, token, jwtToken, query
41
+ }));
42
+ return api.btrzpay.terminalPayments.mit.get({
43
+ token,
44
+ jwtToken,
45
+ query,
46
+ id: 1
47
+ });
33
48
  });
34
49
  });
35
50
 
36
- it("should get the MIT terminal payment", () => {
37
- axiosMock.onGet("/terminal-payments/mit/1", {params: query}).reply(expectRequest({
38
- statusCode: 200, token, jwtToken, query
39
- }));
40
- return api.btrzpay.terminalPayments.mit.get({
41
- token,
42
- jwtToken,
43
- query,
44
- id: 1
51
+ describe("Webhooks", () => {
52
+ it("should process a webhook from Getnet", () => {
53
+ const providerId = "5ad7804216b426412c19f06f";
54
+ const webhookData = {
55
+ TrxAID: "A0000000041010",
56
+ TrxAmount: "100.00",
57
+ TrxArqc: "**** D05D",
58
+ TrxAuth: "712009",
59
+ TrxCard: "**** 5628",
60
+ TrxCardBank: "SANTANDER",
61
+ TrxCardBrand: "MasterCard",
62
+ TrxCardInstrument: "CREDITO",
63
+ TrxCurrency: "MXN",
64
+ TrxDate: "15/06/2020",
65
+ TrxDescription: "",
66
+ TrxDevice: "PP35271909103698",
67
+ TrxMerchant: "7628597 VMC",
68
+ TrxOriginalNumber: "301268962",
69
+ TrxPaymentMode: "Contado",
70
+ TrxReference: "Ref 1",
71
+ TrxResult: "APPROVED",
72
+ TrxTime: "19:29:36",
73
+ TrxUrl: "/payment/sale",
74
+ TrxUser: "1234"
75
+ };
76
+
77
+ axiosMock.onPost(`/terminal-payments/webhooks/getnet/${providerId}`)
78
+ .reply((config) => {
79
+ expect(JSON.parse(config.data)).to.eql(webhookData);
80
+ return [200];
81
+ });
82
+
83
+ return api.btrzpay.terminalPayments.webhooks.getnet({
84
+ providerId,
85
+ data: webhookData
86
+ });
45
87
  });
46
88
  });
47
89
  });
package/types/client.d.ts CHANGED
@@ -5123,6 +5123,13 @@ export function createApiClient(options: {
5123
5123
  headers: any;
5124
5124
  }): any;
5125
5125
  };
5126
+ webhooks: {
5127
+ getnet({ data, providerId, headers }: {
5128
+ data: any;
5129
+ providerId: any;
5130
+ headers?: {};
5131
+ }): any;
5132
+ };
5126
5133
  };
5127
5134
  stripeTerminals: {
5128
5135
  all: ({ token, jwtToken, headers, query }: {
@@ -20,4 +20,11 @@ declare function terminalPaymentsFactory({ client, internalAuthTokenProvider }:
20
20
  headers: any;
21
21
  }): any;
22
22
  };
23
+ webhooks: {
24
+ getnet({ data, providerId, headers }: {
25
+ data: any;
26
+ providerId: any;
27
+ headers?: {};
28
+ }): any;
29
+ };
23
30
  };
@@ -5077,6 +5077,13 @@ declare const _exports: {
5077
5077
  headers: any;
5078
5078
  }): any;
5079
5079
  };
5080
+ webhooks: {
5081
+ getnet({ data, providerId, headers }: {
5082
+ data: any;
5083
+ providerId: any;
5084
+ headers?: {};
5085
+ }): any;
5086
+ };
5080
5087
  };
5081
5088
  stripeTerminals: {
5082
5089
  all: ({ token, jwtToken, headers, query }: {