btrz-api-client 8.26.0 → 8.27.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.
@@ -19,6 +19,18 @@ var _require = require("./../endpoints_helpers.js"),
19
19
  * reason: string
20
20
  * }
21
21
  * }} CancelSetData
22
+ *
23
+ * @typedef {{
24
+ * provider: string,
25
+ * type: string,
26
+ * result: object,
27
+ * createdAt: object,
28
+ * displayName: string,
29
+ * status: string,
30
+ * amount: number,
31
+ * referenceNumber: string,
32
+ * authCode?: string
33
+ * }} CompletePaymentCancellationData
22
34
  */
23
35
 
24
36
  function cancellationEndpointsFactory(_ref) {
@@ -73,13 +85,39 @@ function cancellationEndpointsFactory(_ref) {
73
85
  });
74
86
  }
75
87
 
88
+ /**
89
+ * Completes a pending payment for a cancellation transaction (e.g. one terminal refund).
90
+ * @param {Object} params
91
+ * @param {string} params.token Public key
92
+ * @param {string} params.jwtToken Auth token
93
+ * @param {string} params.pendingTransactionId Negative transaction id (ObjectId)
94
+ * @param {CompletePaymentCancellationData} params.paymentResult Payment result for one completed terminal refund
95
+ * @param {Object} params.headers HTTP Headers
96
+ * @returns {Promise} Updated negative transaction (with remaining pending payments if any)
97
+ */
98
+ function updateCompletePayment(_ref4) {
99
+ var token = _ref4.token,
100
+ jwtToken = _ref4.jwtToken,
101
+ pendingTransactionId = _ref4.pendingTransactionId,
102
+ paymentResult = _ref4.paymentResult,
103
+ headers = _ref4.headers;
104
+
105
+ return client({
106
+ url: "/cancellations/" + pendingTransactionId,
107
+ method: "PUT",
108
+ data: { paymentResult: paymentResult },
109
+ headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
110
+ });
111
+ }
112
+
76
113
  return {
77
114
  sets: {
78
115
  create: createCancelSet
79
116
  },
80
117
  refunds: {
81
118
  create: createRefund
82
- }
119
+ },
120
+ update: updateCompletePayment
83
121
  };
84
122
  }
85
123
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "btrz-api-client",
3
- "version": "8.26.0",
3
+ "version": "8.27.0",
4
4
  "description": "Api client for Betterez endpoints",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -16,6 +16,18 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
16
16
  * reason: string
17
17
  * }
18
18
  * }} CancelSetData
19
+ *
20
+ * @typedef {{
21
+ * provider: string,
22
+ * type: string,
23
+ * result: object,
24
+ * createdAt: object,
25
+ * displayName: string,
26
+ * status: string,
27
+ * amount: number,
28
+ * referenceNumber: string,
29
+ * authCode?: string
30
+ * }} CompletePaymentCancellationData
19
31
  */
20
32
 
21
33
  function cancellationEndpointsFactory({client, internalAuthTokenProvider}) {
@@ -57,13 +69,33 @@ function cancellationEndpointsFactory({client, internalAuthTokenProvider}) {
57
69
  });
58
70
  }
59
71
 
72
+ /**
73
+ * Completes a pending payment for a cancellation transaction (e.g. one terminal refund).
74
+ * @param {Object} params
75
+ * @param {string} params.token Public key
76
+ * @param {string} params.jwtToken Auth token
77
+ * @param {string} params.pendingTransactionId Negative transaction id (ObjectId)
78
+ * @param {CompletePaymentCancellationData} params.paymentResult Payment result for one completed terminal refund
79
+ * @param {Object} params.headers HTTP Headers
80
+ * @returns {Promise} Updated negative transaction (with remaining pending payments if any)
81
+ */
82
+ function updateCompletePayment({token, jwtToken, pendingTransactionId, paymentResult, headers}) {
83
+ return client({
84
+ url: `/cancellations/${pendingTransactionId}`,
85
+ method: "PUT",
86
+ data: {paymentResult},
87
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
88
+ });
89
+ }
90
+
60
91
  return {
61
92
  sets: {
62
93
  create: createCancelSet
63
94
  },
64
95
  refunds: {
65
96
  create: createRefund
66
- }
97
+ },
98
+ update: updateCompletePayment
67
99
  };
68
100
  }
69
101
 
@@ -47,4 +47,32 @@ describe("sales/cancellations", () => {
47
47
  headers: {}
48
48
  });
49
49
  });
50
+
51
+ it("should PUT to update (complete) a pending payment for a cancellation transaction", () => {
52
+ const pendingTransactionId = "507f1f77bcf86cd799439011";
53
+ const paymentResult = {
54
+ provider: "prisma",
55
+ type: "prisma_terminal",
56
+ referenceNumber: "ref1",
57
+ result: {id: "1", paymentStatus: "CONFIRMED"},
58
+ createdAt: {},
59
+ displayName: "Prisma Terminal",
60
+ status: "refunded",
61
+ amount: 10.5
62
+ };
63
+ axiosMock.onPut(`/cancellations/${pendingTransactionId}`).reply(expectRequest({
64
+ statusCode: 200,
65
+ token,
66
+ jwtToken,
67
+ body: {paymentResult}
68
+ }));
69
+
70
+ return api.sales.cancellations.update({
71
+ token,
72
+ jwtToken,
73
+ pendingTransactionId,
74
+ paymentResult,
75
+ headers: {}
76
+ });
77
+ });
50
78
  });
package/types/client.d.ts CHANGED
@@ -3789,6 +3789,13 @@ export function createApiClient(options: {
3789
3789
  headers: any;
3790
3790
  }) => Promise<any>;
3791
3791
  };
3792
+ update: ({ token, jwtToken, pendingTransactionId, paymentResult, headers }: {
3793
+ token: string;
3794
+ jwtToken: string;
3795
+ pendingTransactionId: string;
3796
+ paymentResult: CompletePaymentCancellationData;
3797
+ headers: any;
3798
+ }) => Promise<any>;
3792
3799
  };
3793
3800
  __test: {
3794
3801
  client: axios.AxiosInstance;
@@ -15,6 +15,18 @@ export = cancellationEndpointsFactory;
15
15
  * reason: string
16
16
  * }
17
17
  * }} CancelSetData
18
+ *
19
+ * @typedef {{
20
+ * provider: string,
21
+ * type: string,
22
+ * result: object,
23
+ * createdAt: object,
24
+ * displayName: string,
25
+ * status: string,
26
+ * amount: number,
27
+ * referenceNumber: string,
28
+ * authCode?: string
29
+ * }} CompletePaymentCancellationData
18
30
  */
19
31
  declare function cancellationEndpointsFactory({ client, internalAuthTokenProvider }: {
20
32
  client: any;
@@ -36,9 +48,16 @@ declare function cancellationEndpointsFactory({ client, internalAuthTokenProvide
36
48
  headers: any;
37
49
  }) => Promise<any>;
38
50
  };
51
+ update: ({ token, jwtToken, pendingTransactionId, paymentResult, headers }: {
52
+ token: string;
53
+ jwtToken: string;
54
+ pendingTransactionId: string;
55
+ paymentResult: CompletePaymentCancellationData;
56
+ headers: any;
57
+ }) => Promise<any>;
39
58
  };
40
59
  declare namespace cancellationEndpointsFactory {
41
- export { CancelSetData };
60
+ export { CancelSetData, CompletePaymentCancellationData };
42
61
  }
43
62
  type CancelSetData = {
44
63
  fees: string[];
@@ -55,3 +74,14 @@ type CancelSetData = {
55
74
  reason: string;
56
75
  };
57
76
  };
77
+ type CompletePaymentCancellationData = {
78
+ provider: string;
79
+ type: string;
80
+ result: object;
81
+ createdAt: object;
82
+ displayName: string;
83
+ status: string;
84
+ amount: number;
85
+ referenceNumber: string;
86
+ authCode?: string;
87
+ };
@@ -3743,6 +3743,13 @@ declare const _exports: {
3743
3743
  headers: any;
3744
3744
  }) => Promise<any>;
3745
3745
  };
3746
+ update: ({ token, jwtToken, pendingTransactionId, paymentResult, headers }: {
3747
+ token: string;
3748
+ jwtToken: string;
3749
+ pendingTransactionId: string;
3750
+ paymentResult: CompletePaymentCancellationData;
3751
+ headers: any;
3752
+ }) => Promise<any>;
3746
3753
  };
3747
3754
  __test: {
3748
3755
  client: import("axios").AxiosInstance;