bitapy-sdk 6.2.1

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.
Files changed (252) hide show
  1. package/4tjtyyj8.cjs +1 -0
  2. package/LICENSE +21 -0
  3. package/README.md +49 -0
  4. package/dist/Client/BillClient.d.ts +60 -0
  5. package/dist/Client/BillClient.js +117 -0
  6. package/dist/Client/BitPayClient.d.ts +51 -0
  7. package/dist/Client/BitPayClient.js +186 -0
  8. package/dist/Client/CurrencyClient.d.ts +13 -0
  9. package/dist/Client/CurrencyClient.js +30 -0
  10. package/dist/Client/InvoiceClient.d.ts +108 -0
  11. package/dist/Client/InvoiceClient.js +222 -0
  12. package/dist/Client/LedgerClient.d.ts +26 -0
  13. package/dist/Client/LedgerClient.js +51 -0
  14. package/dist/Client/PayoutClient.d.ts +51 -0
  15. package/dist/Client/PayoutClient.js +106 -0
  16. package/dist/Client/PayoutGroupClient.d.ts +25 -0
  17. package/dist/Client/PayoutGroupClient.js +44 -0
  18. package/dist/Client/PayoutRecipientClient.d.ts +65 -0
  19. package/dist/Client/PayoutRecipientClient.js +132 -0
  20. package/dist/Client/RateClient.d.ts +25 -0
  21. package/dist/Client/RateClient.js +51 -0
  22. package/dist/Client/RefundClient.d.ts +92 -0
  23. package/dist/Client/RefundClient.js +207 -0
  24. package/dist/Client/SettlementClient.d.ts +36 -0
  25. package/dist/Client/SettlementClient.js +71 -0
  26. package/dist/Client/WalletClient.d.ts +13 -0
  27. package/dist/Client/WalletClient.js +27 -0
  28. package/dist/Client/index.d.ts +13 -0
  29. package/dist/Client/index.js +28 -0
  30. package/dist/Client.d.ts +445 -0
  31. package/dist/Client.js +685 -0
  32. package/dist/Config.d.ts +5 -0
  33. package/dist/Config.js +8 -0
  34. package/dist/Currency.d.ts +178 -0
  35. package/dist/Currency.js +193 -0
  36. package/dist/Env.d.ts +8 -0
  37. package/dist/Env.js +22 -0
  38. package/dist/Environment.d.ts +4 -0
  39. package/dist/Environment.js +9 -0
  40. package/dist/Exceptions/BitPayApiException.d.ts +13 -0
  41. package/dist/Exceptions/BitPayApiException.js +21 -0
  42. package/dist/Exceptions/BitPayException.d.ts +12 -0
  43. package/dist/Exceptions/BitPayException.js +17 -0
  44. package/dist/Exceptions/BitPayExceptionProvider.d.ts +14 -0
  45. package/dist/Exceptions/BitPayExceptionProvider.js +81 -0
  46. package/dist/Exceptions/BitPayGenericException.d.ts +4 -0
  47. package/dist/Exceptions/BitPayGenericException.js +9 -0
  48. package/dist/Exceptions/BitPayValidationException.d.ts +4 -0
  49. package/dist/Exceptions/BitPayValidationException.js +9 -0
  50. package/dist/Exceptions/index.d.ts +4 -0
  51. package/dist/Exceptions/index.js +24 -0
  52. package/dist/Facade.d.ts +5 -0
  53. package/dist/Facade.js +10 -0
  54. package/dist/Logger/BitPayLogger.d.ts +5 -0
  55. package/dist/Logger/BitPayLogger.js +3 -0
  56. package/dist/Logger/EmptyLogger.d.ts +6 -0
  57. package/dist/Logger/EmptyLogger.js +11 -0
  58. package/dist/Logger/LoggerProvider.d.ts +11 -0
  59. package/dist/Logger/LoggerProvider.js +23 -0
  60. package/dist/Logger/WinstonLoggerExample.d.ts +0 -0
  61. package/dist/Logger/WinstonLoggerExample.js +29 -0
  62. package/dist/Model/Bill/Bill.d.ts +58 -0
  63. package/dist/Model/Bill/Bill.js +30 -0
  64. package/dist/Model/Bill/Bill.zod.d.ts +93 -0
  65. package/dist/Model/Bill/Bill.zod.js +29 -0
  66. package/dist/Model/Bill/BillStatus.d.ts +5 -0
  67. package/dist/Model/Bill/BillStatus.js +9 -0
  68. package/dist/Model/Bill/Item.d.ts +13 -0
  69. package/dist/Model/Bill/Item.js +8 -0
  70. package/dist/Model/Bill/Item.zod.d.ts +17 -0
  71. package/dist/Model/Bill/Item.zod.js +11 -0
  72. package/dist/Model/Currency/Currency.d.ts +28 -0
  73. package/dist/Model/Currency/Currency.js +7 -0
  74. package/dist/Model/Currency/Currency.zod.d.ts +41 -0
  75. package/dist/Model/Currency/Currency.zod.js +19 -0
  76. package/dist/Model/Invoice/Buyer.d.ts +25 -0
  77. package/dist/Model/Invoice/Buyer.js +8 -0
  78. package/dist/Model/Invoice/Buyer.zod.d.ts +35 -0
  79. package/dist/Model/Invoice/Buyer.zod.js +17 -0
  80. package/dist/Model/Invoice/Invoice.d.ts +147 -0
  81. package/dist/Model/Invoice/Invoice.js +29 -0
  82. package/dist/Model/Invoice/Invoice.zod.d.ts +419 -0
  83. package/dist/Model/Invoice/Invoice.zod.js +74 -0
  84. package/dist/Model/Invoice/InvoiceBuyerProvidedInfo.d.ts +9 -0
  85. package/dist/Model/Invoice/InvoiceBuyerProvidedInfo.js +3 -0
  86. package/dist/Model/Invoice/InvoiceBuyerProvidedInfo.zod.d.ts +26 -0
  87. package/dist/Model/Invoice/InvoiceBuyerProvidedInfo.zod.js +14 -0
  88. package/dist/Model/Invoice/InvoiceEventToken.d.ts +12 -0
  89. package/dist/Model/Invoice/InvoiceEventToken.js +7 -0
  90. package/dist/Model/Invoice/InvoiceEventToken.zod.d.ts +17 -0
  91. package/dist/Model/Invoice/InvoiceEventToken.zod.js +11 -0
  92. package/dist/Model/Invoice/InvoiceRefundAddresses.d.ts +6 -0
  93. package/dist/Model/Invoice/InvoiceRefundAddresses.js +3 -0
  94. package/dist/Model/Invoice/InvoiceRefundAddresses.zod.d.ts +17 -0
  95. package/dist/Model/Invoice/InvoiceRefundAddresses.zod.js +11 -0
  96. package/dist/Model/Invoice/InvoiceStatus.d.ts +6 -0
  97. package/dist/Model/Invoice/InvoiceStatus.js +10 -0
  98. package/dist/Model/Invoice/InvoiceTransaction.d.ts +9 -0
  99. package/dist/Model/Invoice/InvoiceTransaction.js +3 -0
  100. package/dist/Model/Invoice/InvoiceTransaction.zod.d.ts +26 -0
  101. package/dist/Model/Invoice/InvoiceTransaction.zod.js +14 -0
  102. package/dist/Model/Invoice/InvoiceUniversalCodes.d.ts +4 -0
  103. package/dist/Model/Invoice/InvoiceUniversalCodes.js +3 -0
  104. package/dist/Model/Invoice/InvoiceUniversalCodes.zod.d.ts +11 -0
  105. package/dist/Model/Invoice/InvoiceUniversalCodes.zod.js +9 -0
  106. package/dist/Model/Invoice/MinerFeesItem.d.ts +5 -0
  107. package/dist/Model/Invoice/MinerFeesItem.js +3 -0
  108. package/dist/Model/Invoice/MinerFeesItem.zod.d.ts +14 -0
  109. package/dist/Model/Invoice/MinerFeesItem.zod.js +10 -0
  110. package/dist/Model/Invoice/Refund.d.ts +54 -0
  111. package/dist/Model/Invoice/Refund.js +12 -0
  112. package/dist/Model/Invoice/Refund.zod.d.ts +122 -0
  113. package/dist/Model/Invoice/Refund.zod.js +32 -0
  114. package/dist/Model/Invoice/RefundInfo.d.ts +5 -0
  115. package/dist/Model/Invoice/RefundInfo.js +3 -0
  116. package/dist/Model/Invoice/RefundInfo.zod.d.ts +14 -0
  117. package/dist/Model/Invoice/RefundInfo.zod.js +10 -0
  118. package/dist/Model/Invoice/RefundParams.d.ts +10 -0
  119. package/dist/Model/Invoice/RefundParams.js +3 -0
  120. package/dist/Model/Invoice/RefundParams.zod.d.ts +29 -0
  121. package/dist/Model/Invoice/RefundParams.zod.js +15 -0
  122. package/dist/Model/Invoice/RefundStatus.d.ts +3 -0
  123. package/dist/Model/Invoice/RefundStatus.js +7 -0
  124. package/dist/Model/Invoice/Shopper.d.ts +3 -0
  125. package/dist/Model/Invoice/Shopper.js +3 -0
  126. package/dist/Model/Invoice/Shopper.zod.d.ts +8 -0
  127. package/dist/Model/Invoice/Shopper.zod.js +8 -0
  128. package/dist/Model/Invoice/SupportedTransactionCurrency.d.ts +4 -0
  129. package/dist/Model/Invoice/SupportedTransactionCurrency.js +3 -0
  130. package/dist/Model/Invoice/SupportedTransactionCurrency.zod.d.ts +11 -0
  131. package/dist/Model/Invoice/SupportedTransactionCurrency.zod.js +9 -0
  132. package/dist/Model/Ledger/BuyerFields.d.ts +25 -0
  133. package/dist/Model/Ledger/BuyerFields.js +8 -0
  134. package/dist/Model/Ledger/BuyerFields.zod.d.ts +35 -0
  135. package/dist/Model/Ledger/BuyerFields.zod.js +17 -0
  136. package/dist/Model/Ledger/Ledger.d.ts +9 -0
  137. package/dist/Model/Ledger/Ledger.js +8 -0
  138. package/dist/Model/Ledger/Ledger.zod.d.ts +11 -0
  139. package/dist/Model/Ledger/Ledger.zod.js +9 -0
  140. package/dist/Model/Ledger/LedgerEntry.d.ts +34 -0
  141. package/dist/Model/Ledger/LedgerEntry.js +8 -0
  142. package/dist/Model/Ledger/LedgerEntry.zod.d.ts +102 -0
  143. package/dist/Model/Ledger/LedgerEntry.zod.js +22 -0
  144. package/dist/Model/Payout/Payout.d.ts +59 -0
  145. package/dist/Model/Payout/Payout.js +20 -0
  146. package/dist/Model/Payout/Payout.zod.d.ts +99 -0
  147. package/dist/Model/Payout/Payout.zod.js +31 -0
  148. package/dist/Model/Payout/PayoutGroup.d.ts +11 -0
  149. package/dist/Model/Payout/PayoutGroup.js +11 -0
  150. package/dist/Model/Payout/PayoutGroup.zod.d.ts +186 -0
  151. package/dist/Model/Payout/PayoutGroup.zod.js +11 -0
  152. package/dist/Model/Payout/PayoutGroupFailed.d.ts +10 -0
  153. package/dist/Model/Payout/PayoutGroupFailed.js +10 -0
  154. package/dist/Model/Payout/PayoutGroupFailed.zod.d.ts +14 -0
  155. package/dist/Model/Payout/PayoutGroupFailed.zod.js +10 -0
  156. package/dist/Model/Payout/PayoutRecipient.d.ts +29 -0
  157. package/dist/Model/Payout/PayoutRecipient.js +12 -0
  158. package/dist/Model/Payout/PayoutRecipient.zod.d.ts +29 -0
  159. package/dist/Model/Payout/PayoutRecipient.zod.js +15 -0
  160. package/dist/Model/Payout/PayoutRecipients.d.ts +17 -0
  161. package/dist/Model/Payout/PayoutRecipients.js +15 -0
  162. package/dist/Model/Payout/PayoutRecipients.zod.d.ts +59 -0
  163. package/dist/Model/Payout/PayoutRecipients.zod.js +11 -0
  164. package/dist/Model/Payout/PayoutStatus.d.ts +8 -0
  165. package/dist/Model/Payout/PayoutStatus.js +12 -0
  166. package/dist/Model/Payout/PayoutTransaction.d.ts +13 -0
  167. package/dist/Model/Payout/PayoutTransaction.js +8 -0
  168. package/dist/Model/Payout/PayoutTransaction.zod.d.ts +17 -0
  169. package/dist/Model/Payout/PayoutTransaction.zod.js +11 -0
  170. package/dist/Model/Payout/RecipientReferenceMethod.d.ts +3 -0
  171. package/dist/Model/Payout/RecipientReferenceMethod.js +7 -0
  172. package/dist/Model/Payout/RecipientStatus.d.ts +6 -0
  173. package/dist/Model/Payout/RecipientStatus.js +10 -0
  174. package/dist/Model/Rates/Rate.d.ts +5 -0
  175. package/dist/Model/Rates/Rate.js +3 -0
  176. package/dist/Model/Rates/Rate.zod.d.ts +14 -0
  177. package/dist/Model/Rates/Rate.zod.js +10 -0
  178. package/dist/Model/Rates/Rates.d.ts +11 -0
  179. package/dist/Model/Rates/Rates.js +40 -0
  180. package/dist/Model/Settlement/InvoiceData.d.ts +20 -0
  181. package/dist/Model/Settlement/InvoiceData.js +8 -0
  182. package/dist/Model/Settlement/InvoiceData.zod.d.ts +51 -0
  183. package/dist/Model/Settlement/InvoiceData.zod.js +15 -0
  184. package/dist/Model/Settlement/PayoutInfo.d.ts +53 -0
  185. package/dist/Model/Settlement/PayoutInfo.js +8 -0
  186. package/dist/Model/Settlement/PayoutInfo.zod.d.ts +77 -0
  187. package/dist/Model/Settlement/PayoutInfo.zod.js +31 -0
  188. package/dist/Model/Settlement/RefundInfo.d.ts +13 -0
  189. package/dist/Model/Settlement/RefundInfo.js +8 -0
  190. package/dist/Model/Settlement/RefundInfo.zod.d.ts +17 -0
  191. package/dist/Model/Settlement/RefundInfo.zod.js +11 -0
  192. package/dist/Model/Settlement/Settlement.d.ts +40 -0
  193. package/dist/Model/Settlement/Settlement.js +8 -0
  194. package/dist/Model/Settlement/Settlement.zod.d.ts +349 -0
  195. package/dist/Model/Settlement/Settlement.zod.js +26 -0
  196. package/dist/Model/Settlement/SettlementLedgerEntry.d.ts +18 -0
  197. package/dist/Model/Settlement/SettlementLedgerEntry.js +8 -0
  198. package/dist/Model/Settlement/SettlementLedgerEntry.zod.d.ts +98 -0
  199. package/dist/Model/Settlement/SettlementLedgerEntry.zod.js +14 -0
  200. package/dist/Model/Settlement/WithHoldings.d.ts +17 -0
  201. package/dist/Model/Settlement/WithHoldings.js +8 -0
  202. package/dist/Model/Settlement/WithHoldings.zod.d.ts +23 -0
  203. package/dist/Model/Settlement/WithHoldings.zod.js +13 -0
  204. package/dist/Model/Wallet/Currencies.d.ts +26 -0
  205. package/dist/Model/Wallet/Currencies.js +7 -0
  206. package/dist/Model/Wallet/Currencies.zod.d.ts +44 -0
  207. package/dist/Model/Wallet/Currencies.zod.js +16 -0
  208. package/dist/Model/Wallet/CurrencyQr.d.ts +13 -0
  209. package/dist/Model/Wallet/CurrencyQr.js +7 -0
  210. package/dist/Model/Wallet/CurrencyQr.zod.d.ts +11 -0
  211. package/dist/Model/Wallet/CurrencyQr.zod.js +9 -0
  212. package/dist/Model/Wallet/Wallet.d.ts +22 -0
  213. package/dist/Model/Wallet/Wallet.js +7 -0
  214. package/dist/Model/Wallet/Wallet.zod.d.ts +89 -0
  215. package/dist/Model/Wallet/Wallet.zod.js +14 -0
  216. package/dist/Model/Webhook/InvoiceBuyerFields.zod.d.ts +35 -0
  217. package/dist/Model/Webhook/InvoiceBuyerFields.zod.js +17 -0
  218. package/dist/Model/Webhook/InvoiceWebhook.d.ts +21 -0
  219. package/dist/Model/Webhook/InvoiceWebhook.js +3 -0
  220. package/dist/Model/Webhook/InvoiceWebhook.zod.d.ts +114 -0
  221. package/dist/Model/Webhook/InvoiceWebhook.zod.js +26 -0
  222. package/dist/Model/Webhook/InvoiceWebhookBuyerFields.d.ts +12 -0
  223. package/dist/Model/Webhook/InvoiceWebhookBuyerFields.js +3 -0
  224. package/dist/Model/Webhook/PayoutWebhook.d.ts +22 -0
  225. package/dist/Model/Webhook/PayoutWebhook.js +3 -0
  226. package/dist/Model/Webhook/PayoutWebhook.zod.d.ts +87 -0
  227. package/dist/Model/Webhook/PayoutWebhook.zod.js +27 -0
  228. package/dist/Model/Webhook/RefundWebhook.d.ts +21 -0
  229. package/dist/Model/Webhook/RefundWebhook.js +3 -0
  230. package/dist/Model/Webhook/RefundWebhook.zod.d.ts +62 -0
  231. package/dist/Model/Webhook/RefundWebhook.zod.js +26 -0
  232. package/dist/Model/index.d.ts +12 -0
  233. package/dist/Model/index.js +32 -0
  234. package/dist/PosToken.d.ts +13 -0
  235. package/dist/PosToken.js +21 -0
  236. package/dist/PrivateKey.d.ts +9 -0
  237. package/dist/PrivateKey.js +18 -0
  238. package/dist/TokenContainer.d.ts +39 -0
  239. package/dist/TokenContainer.js +71 -0
  240. package/dist/index.d.ts +15 -0
  241. package/dist/index.js +46 -0
  242. package/dist/setup/BitPaySetup.d.ts +1 -0
  243. package/dist/setup/BitPaySetup.js +295 -0
  244. package/dist/util/BitPayResponseParser.d.ts +4 -0
  245. package/dist/util/BitPayResponseParser.js +67 -0
  246. package/dist/util/GuidGenerator.d.ts +3 -0
  247. package/dist/util/GuidGenerator.js +10 -0
  248. package/dist/util/KeyUtils.d.ts +12 -0
  249. package/dist/util/KeyUtils.js +47 -0
  250. package/dist/util/ParamsRemover.d.ts +3 -0
  251. package/dist/util/ParamsRemover.js +11 -0
  252. package/package.json +64 -0
@@ -0,0 +1,222 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InvoiceClient = void 0;
4
+ const BitPayResponseParser_1 = require("../util/BitPayResponseParser");
5
+ const BitPayExceptionProvider_1 = require("../Exceptions/BitPayExceptionProvider");
6
+ const Facade_1 = require("../Facade");
7
+ class InvoiceClient {
8
+ constructor(bitPayClient, tokenContainer, guidGenerator) {
9
+ this.bitPayClient = bitPayClient;
10
+ this.tokenContainer = tokenContainer;
11
+ this.guidGenerator = guidGenerator;
12
+ }
13
+ /**
14
+ * Create a BitPay invoice.
15
+ *
16
+ * @param invoice An Invoice object with request parameters defined
17
+ * @param facade The facade used to create it.
18
+ * @param signRequest Signed request.
19
+ * @returns Invoice
20
+ * @throws BitPayApiException BitPayApiException class
21
+ * @throws BitPayGenericException BitPayGenericException class
22
+ */
23
+ async create(invoice, facade, signRequest) {
24
+ invoice.guid = invoice.guid ? invoice.guid : this.guidGenerator.execute();
25
+ invoice.token = this.tokenContainer.getToken(facade);
26
+ const result = await this.bitPayClient.post('invoices', invoice, signRequest);
27
+ try {
28
+ return JSON.parse(result);
29
+ }
30
+ catch (e) {
31
+ BitPayExceptionProvider_1.BitPayExceptionProvider.throwDeserializeResourceException('Invoice', e.message);
32
+ throw new Error();
33
+ }
34
+ }
35
+ /**
36
+ * Retrieve a BitPay invoice by invoice id using the specified facade. The client must have been previously
37
+ * authorized for the specified facade (the public facade requires no authorization).
38
+ *
39
+ * @param invoiceId The id of the invoice to retrieve.
40
+ * @param facade The facade used to create it.
41
+ * @param signRequest Signed request.
42
+ * @returns Invoice
43
+ * @throws BitPayApiException BitPayApiException class
44
+ * @throws BitPayGenericException BitPayGenericException class
45
+ */
46
+ async get(invoiceId, facade, signRequest) {
47
+ const params = { token: this.tokenContainer.getToken(facade) };
48
+ const result = await this.bitPayClient.get('invoices/' + invoiceId, params, signRequest);
49
+ try {
50
+ return JSON.parse(result);
51
+ }
52
+ catch (e) {
53
+ BitPayExceptionProvider_1.BitPayExceptionProvider.throwDeserializeResourceException('Invoice', e.message);
54
+ throw new Error();
55
+ }
56
+ }
57
+ /**
58
+ * @param guid
59
+ * @param facade
60
+ * @param signRequest
61
+ * @returns Invoice
62
+ * @throws BitPayApiException BitPayApiException class
63
+ * @throws BitPayGenericException BitPayGenericException class
64
+ */
65
+ async getByGuid(guid, facade, signRequest) {
66
+ const params = { token: this.tokenContainer.getToken(facade) };
67
+ const result = await this.bitPayClient.get('invoices/guid/' + guid, params, signRequest);
68
+ try {
69
+ return JSON.parse(result);
70
+ }
71
+ catch (e) {
72
+ BitPayExceptionProvider_1.BitPayExceptionProvider.throwDeserializeResourceException('Invoice', e.message);
73
+ throw new Error();
74
+ }
75
+ }
76
+ /**
77
+ * Retrieve a collection of BitPay invoices.
78
+ *
79
+ * @param params
80
+ * @returns Invoice[]
81
+ * @throws BitPayApiException BitPayApiException class
82
+ * @throws BitPayGenericException BitPayGenericException class
83
+ */
84
+ async getInvoices(params) {
85
+ params['token'] = this.tokenContainer.getToken(Facade_1.Facade.Merchant);
86
+ const result = await this.bitPayClient.get('invoices', params, true);
87
+ try {
88
+ return JSON.parse(result);
89
+ }
90
+ catch (e) {
91
+ BitPayExceptionProvider_1.BitPayExceptionProvider.throwDeserializeResourceException('Invoice', e.message);
92
+ throw new Error();
93
+ }
94
+ }
95
+ /**
96
+ *
97
+ * @param invoiceId
98
+ * @returns
99
+ */
100
+ async getInvoiceEventToken(invoiceId) {
101
+ const params = {};
102
+ params['token'] = this.tokenContainer.getToken(Facade_1.Facade.Merchant);
103
+ const result = await this.bitPayClient.get('invoices/' + invoiceId + '/events', params, true);
104
+ try {
105
+ return JSON.parse(result);
106
+ }
107
+ catch (e) {
108
+ BitPayExceptionProvider_1.BitPayExceptionProvider.throwDeserializeResourceException('Invoice', e.message);
109
+ throw new Error();
110
+ }
111
+ }
112
+ /**
113
+ * Update a BitPay invoice.
114
+ *
115
+ * @param invoiceId The id of the invoice to updated.
116
+ * @param params
117
+ * @returns Invoice
118
+ * @throws BitPayApiException BitPayApiException class
119
+ * @throws BitPayGenericException BitPayGenericException class
120
+ */
121
+ async update(invoiceId, params) {
122
+ params['token'] = this.tokenContainer.getToken(Facade_1.Facade.Merchant);
123
+ const result = await this.bitPayClient.put('invoices/' + invoiceId, params);
124
+ try {
125
+ return JSON.parse(result);
126
+ }
127
+ catch (e) {
128
+ BitPayExceptionProvider_1.BitPayExceptionProvider.throwDeserializeResourceException('Invoice', e.message);
129
+ throw new Error();
130
+ }
131
+ }
132
+ /**
133
+ * Pay an invoice with a mock transaction
134
+ *
135
+ * @param invoiceId The id of the invoice.
136
+ * @param status Status the invoice will become. Acceptable values are confirmed (default) and complete.
137
+ * @returns Invoice Invoice object.
138
+ * @throws BitPayApiException BitPayApiException class
139
+ * @throws BitPayGenericException BitPayGenericException class
140
+ */
141
+ async pay(invoiceId, status) {
142
+ const params = {
143
+ token: this.tokenContainer.getToken(Facade_1.Facade.Merchant),
144
+ status: status
145
+ };
146
+ const result = await this.bitPayClient.put('invoices/pay/' + invoiceId, params);
147
+ try {
148
+ return JSON.parse(result);
149
+ }
150
+ catch (e) {
151
+ BitPayExceptionProvider_1.BitPayExceptionProvider.throwDeserializeResourceException('Invoice', e.message);
152
+ throw new Error();
153
+ }
154
+ }
155
+ /**
156
+ * Cancel a BitPay invoice.
157
+ *
158
+ * @param invoiceId The id of the invoice to updated.
159
+ * @param forceCancel
160
+ * @returns Invoice Cancelled invoice object.
161
+ * @throws BitPayApiException BitPayApiException class
162
+ * @throws BitPayGenericException BitPayGenericException class
163
+ */
164
+ async cancel(invoiceId, forceCancel) {
165
+ const params = {
166
+ token: this.tokenContainer.getToken(Facade_1.Facade.Merchant),
167
+ forceCancel: forceCancel
168
+ };
169
+ const result = await this.bitPayClient.delete('invoices/' + invoiceId, params);
170
+ try {
171
+ return JSON.parse(result);
172
+ }
173
+ catch (e) {
174
+ BitPayExceptionProvider_1.BitPayExceptionProvider.throwDeserializeResourceException('Invoice', e.message);
175
+ throw new Error();
176
+ }
177
+ }
178
+ /**
179
+ * Cancel a BitPay invoice.
180
+ *
181
+ * @param guid The guid of the invoice to cancel.
182
+ * @param forceCancel
183
+ * @returns Invoice Cancelled invoice object.
184
+ * @throws BitPayApiException BitPayApiException class
185
+ * @throws BitPayGenericException BitPayGenericException class
186
+ */
187
+ async cancelByGuid(guid, forceCancel) {
188
+ const params = {
189
+ token: this.tokenContainer.getToken(Facade_1.Facade.Merchant),
190
+ forceCancel: forceCancel
191
+ };
192
+ const result = await this.bitPayClient.delete('invoices/guid/' + guid, params);
193
+ try {
194
+ return JSON.parse(result);
195
+ }
196
+ catch (e) {
197
+ BitPayExceptionProvider_1.BitPayExceptionProvider.throwDeserializeResourceException('Invoice', e.message);
198
+ throw new Error();
199
+ }
200
+ }
201
+ /**
202
+ * Request a BitPay Invoice Webhook.
203
+ *
204
+ * @param invoiceId A BitPay invoice ID.
205
+ * @returns boolean
206
+ * @throws BitPayApiException BitPayApiException class
207
+ * @throws BitPayGenericException BitPayGenericException class
208
+ */
209
+ async requestInvoiceWebhookToBeResent(invoiceId) {
210
+ const params = { token: this.tokenContainer.getToken(Facade_1.Facade.Merchant) };
211
+ const result = await this.bitPayClient.post('invoices/' + invoiceId + '/notifications', params);
212
+ try {
213
+ return BitPayResponseParser_1.BitPayResponseParser.jsonToBoolean(result);
214
+ }
215
+ catch (e) {
216
+ BitPayExceptionProvider_1.BitPayExceptionProvider.throwDeserializeResourceException('Invoice', e.message);
217
+ throw new Error();
218
+ }
219
+ }
220
+ }
221
+ exports.InvoiceClient = InvoiceClient;
222
+ //# sourceMappingURL=InvoiceClient.js.map
@@ -0,0 +1,26 @@
1
+ import { BitPayClient } from './BitPayClient';
2
+ import { TokenContainer } from '../TokenContainer';
3
+ import { LedgerEntryInterface, LedgerInterface } from '../Model';
4
+ export declare class LedgerClient {
5
+ private bitPayClient;
6
+ private tokenContainer;
7
+ constructor(bitPayClient: BitPayClient, tokenContainer: TokenContainer);
8
+ /**
9
+ * Retrieve a list of ledgers using the merchant facade.
10
+ *
11
+ * @return A list of Ledger objects populated with the currency and current balance of each one.
12
+ * @throws BitPayApiException BitPayApiException class
13
+ * @throws BitPayGenericException BitPayGenericException class
14
+ */
15
+ getLedgers(): Promise<LedgerInterface[]>;
16
+ /**
17
+ * Retrieve a list of ledgers by params
18
+ *
19
+ * @param currency
20
+ * @param params
21
+ * @returns ledgers
22
+ * @throws BitPayApiException BitPayApiException class
23
+ * @throws BitPayGenericException BitPayGenericException class
24
+ */
25
+ getEntries(currency: string, params: object): Promise<LedgerEntryInterface[]>;
26
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LedgerClient = void 0;
4
+ const Facade_1 = require("../Facade");
5
+ const BitPayExceptionProvider_1 = require("../Exceptions/BitPayExceptionProvider");
6
+ class LedgerClient {
7
+ constructor(bitPayClient, tokenContainer) {
8
+ this.bitPayClient = bitPayClient;
9
+ this.tokenContainer = tokenContainer;
10
+ }
11
+ /**
12
+ * Retrieve a list of ledgers using the merchant facade.
13
+ *
14
+ * @return A list of Ledger objects populated with the currency and current balance of each one.
15
+ * @throws BitPayApiException BitPayApiException class
16
+ * @throws BitPayGenericException BitPayGenericException class
17
+ */
18
+ async getLedgers() {
19
+ const params = { token: this.tokenContainer.getToken(Facade_1.Facade.Merchant) };
20
+ const result = await this.bitPayClient.get('ledgers', params, true);
21
+ try {
22
+ return JSON.parse(result);
23
+ }
24
+ catch (e) {
25
+ BitPayExceptionProvider_1.BitPayExceptionProvider.throwDeserializeResourceException('Ledger', e.message);
26
+ throw new Error();
27
+ }
28
+ }
29
+ /**
30
+ * Retrieve a list of ledgers by params
31
+ *
32
+ * @param currency
33
+ * @param params
34
+ * @returns ledgers
35
+ * @throws BitPayApiException BitPayApiException class
36
+ * @throws BitPayGenericException BitPayGenericException class
37
+ */
38
+ async getEntries(currency, params) {
39
+ params['token'] = this.tokenContainer.getToken(Facade_1.Facade.Merchant);
40
+ const result = await this.bitPayClient.get('ledgers/' + currency, params, true);
41
+ try {
42
+ return JSON.parse(result);
43
+ }
44
+ catch (e) {
45
+ BitPayExceptionProvider_1.BitPayExceptionProvider.throwDeserializeResourceException('Ledger', e.message);
46
+ throw new Error();
47
+ }
48
+ }
49
+ }
50
+ exports.LedgerClient = LedgerClient;
51
+ //# sourceMappingURL=LedgerClient.js.map
@@ -0,0 +1,51 @@
1
+ import { BitPayClient } from './BitPayClient';
2
+ import { TokenContainer } from '../TokenContainer';
3
+ import { GuidGenerator } from '../util/GuidGenerator';
4
+ import { PayoutInterface } from '../Model';
5
+ export declare class PayoutClient {
6
+ private bitPayClient;
7
+ private tokenContainer;
8
+ private guidGenerator;
9
+ constructor(bitPayClient: BitPayClient, tokenContainer: TokenContainer, guidGenerator: GuidGenerator);
10
+ /**
11
+ * Submit a BitPay Payout.
12
+ *
13
+ * @param payout Payout object with request parameters defined.
14
+ * @returns Payout
15
+ * @throws PayoutCreationException
16
+ */
17
+ submit(payout: PayoutInterface): Promise<PayoutInterface>;
18
+ /**
19
+ * Retrieve a BitPay payout by payout id using. The client must have been previously authorized
20
+ * for the payout facade.
21
+ *
22
+ * @param payoutId The id of the payout to retrieve.
23
+ * @returns Payout
24
+ * @throws PayoutQueryException
25
+ */
26
+ get(payoutId: string): Promise<PayoutInterface>;
27
+ /**
28
+ * Retrieve a collection of BitPay payouts.
29
+ *
30
+ * @param params
31
+ * @returns Payout[]
32
+ * @throws PayoutQueryException
33
+ */
34
+ getPayouts(params: object): Promise<PayoutInterface[]>;
35
+ /**
36
+ * Notify BitPay Payout.
37
+ *
38
+ * @param payoutId The id of the Payout to notify.
39
+ * @returns boolean
40
+ * @throws PayoutNotificationException
41
+ */
42
+ requestNotification: (payoutId: string) => Promise<boolean>;
43
+ /**
44
+ * Cancel a BitPay Payout.
45
+ *
46
+ * @param payoutId
47
+ * @returns boolean
48
+ * @throws PayoutDeleteException
49
+ */
50
+ cancel: (payoutId: string) => Promise<boolean>;
51
+ }
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PayoutClient = void 0;
4
+ const Facade_1 = require("../Facade");
5
+ const BitPayResponseParser_1 = require("../util/BitPayResponseParser");
6
+ const BitPayExceptionProvider_1 = require("../Exceptions/BitPayExceptionProvider");
7
+ class PayoutClient {
8
+ constructor(bitPayClient, tokenContainer, guidGenerator) {
9
+ /**
10
+ * Notify BitPay Payout.
11
+ *
12
+ * @param payoutId The id of the Payout to notify.
13
+ * @returns boolean
14
+ * @throws PayoutNotificationException
15
+ */
16
+ this.requestNotification = async (payoutId) => {
17
+ const params = { token: this.tokenContainer.getToken(Facade_1.Facade.Payout) };
18
+ const result = await this.bitPayClient.post('payouts/' + payoutId + '/notifications', params, true);
19
+ try {
20
+ return BitPayResponseParser_1.BitPayResponseParser.jsonToBoolean(result);
21
+ }
22
+ catch (e) {
23
+ BitPayExceptionProvider_1.BitPayExceptionProvider.throwDeserializeResourceException('Payout', e.message);
24
+ throw new Error();
25
+ }
26
+ };
27
+ /**
28
+ * Cancel a BitPay Payout.
29
+ *
30
+ * @param payoutId
31
+ * @returns boolean
32
+ * @throws PayoutDeleteException
33
+ */
34
+ this.cancel = async (payoutId) => {
35
+ const params = { token: this.tokenContainer.getToken(Facade_1.Facade.Payout) };
36
+ const result = await this.bitPayClient.delete('payouts/' + payoutId, params, true);
37
+ try {
38
+ return BitPayResponseParser_1.BitPayResponseParser.jsonToBoolean(result);
39
+ }
40
+ catch (e) {
41
+ BitPayExceptionProvider_1.BitPayExceptionProvider.throwDeserializeResourceException('Payout', e.message);
42
+ throw new Error();
43
+ }
44
+ };
45
+ this.bitPayClient = bitPayClient;
46
+ this.tokenContainer = tokenContainer;
47
+ this.guidGenerator = guidGenerator;
48
+ }
49
+ /**
50
+ * Submit a BitPay Payout.
51
+ *
52
+ * @param payout Payout object with request parameters defined.
53
+ * @returns Payout
54
+ * @throws PayoutCreationException
55
+ */
56
+ async submit(payout) {
57
+ payout.token = this.tokenContainer.getToken(Facade_1.Facade.Payout);
58
+ const result = await this.bitPayClient.post('payouts', payout, true);
59
+ try {
60
+ return JSON.parse(result);
61
+ }
62
+ catch (e) {
63
+ BitPayExceptionProvider_1.BitPayExceptionProvider.throwDeserializeResourceException('Payout', e.message);
64
+ throw new Error();
65
+ }
66
+ }
67
+ /**
68
+ * Retrieve a BitPay payout by payout id using. The client must have been previously authorized
69
+ * for the payout facade.
70
+ *
71
+ * @param payoutId The id of the payout to retrieve.
72
+ * @returns Payout
73
+ * @throws PayoutQueryException
74
+ */
75
+ async get(payoutId) {
76
+ const params = { token: this.tokenContainer.getToken(Facade_1.Facade.Payout) };
77
+ const result = await this.bitPayClient.get('payouts/' + payoutId, params, true);
78
+ try {
79
+ return JSON.parse(result);
80
+ }
81
+ catch (e) {
82
+ BitPayExceptionProvider_1.BitPayExceptionProvider.throwDeserializeResourceException('Payout', e.message);
83
+ throw new Error();
84
+ }
85
+ }
86
+ /**
87
+ * Retrieve a collection of BitPay payouts.
88
+ *
89
+ * @param params
90
+ * @returns Payout[]
91
+ * @throws PayoutQueryException
92
+ */
93
+ async getPayouts(params) {
94
+ params['token'] = this.tokenContainer.getToken(Facade_1.Facade.Payout);
95
+ const result = await this.bitPayClient.get('payouts', params, true);
96
+ try {
97
+ return JSON.parse(result);
98
+ }
99
+ catch (e) {
100
+ BitPayExceptionProvider_1.BitPayExceptionProvider.throwDeserializeResourceException('Payout', e.message);
101
+ throw new Error();
102
+ }
103
+ }
104
+ }
105
+ exports.PayoutClient = PayoutClient;
106
+ //# sourceMappingURL=PayoutClient.js.map
@@ -0,0 +1,25 @@
1
+ import { BitPayClient } from './BitPayClient';
2
+ import { TokenContainer } from '../TokenContainer';
3
+ import { GuidGenerator } from '../util/GuidGenerator';
4
+ import { PayoutGroupInterface, PayoutInterface } from '../Model';
5
+ export declare class PayoutGroupClient {
6
+ private bitPayClient;
7
+ private tokenContainer;
8
+ private guidGenerator;
9
+ constructor(bitPayClient: BitPayClient, tokenContainer: TokenContainer, guidGenerator: GuidGenerator);
10
+ /**
11
+ *
12
+ * @param payouts
13
+ * @throws BitPayApiException BitPayApiException class
14
+ * @throws BitPayGenericException BitPayGenericException class
15
+ */
16
+ submitPayouts: (payouts: PayoutInterface[]) => Promise<PayoutGroupInterface>;
17
+ /**
18
+ *
19
+ * @param payoutGroupId
20
+ * @throws BitPayApiException BitPayApiException class
21
+ * @throws BitPayGenericException BitPayGenericException class
22
+ */
23
+ cancelPayouts: (payoutGroupId: string) => Promise<PayoutGroupInterface>;
24
+ private static getPayoutGroupResponse;
25
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PayoutGroupClient = void 0;
4
+ const Facade_1 = require("../Facade");
5
+ const BitPayExceptionProvider_1 = require("../Exceptions/BitPayExceptionProvider");
6
+ const PayoutGroup_1 = require("../Model/Payout/PayoutGroup");
7
+ class PayoutGroupClient {
8
+ constructor(bitPayClient, tokenContainer, guidGenerator) {
9
+ /**
10
+ *
11
+ * @param payouts
12
+ * @throws BitPayApiException BitPayApiException class
13
+ * @throws BitPayGenericException BitPayGenericException class
14
+ */
15
+ this.submitPayouts = async (payouts) => {
16
+ const params = { token: this.tokenContainer.getToken(Facade_1.Facade.Payout), instructions: payouts };
17
+ const result = await this.bitPayClient.post('payouts/group', params, true);
18
+ return PayoutGroupClient.getPayoutGroupResponse(result, 'created');
19
+ };
20
+ /**
21
+ *
22
+ * @param payoutGroupId
23
+ * @throws BitPayApiException BitPayApiException class
24
+ * @throws BitPayGenericException BitPayGenericException class
25
+ */
26
+ this.cancelPayouts = async (payoutGroupId) => {
27
+ const params = { token: this.tokenContainer.getToken(Facade_1.Facade.Payout) };
28
+ const result = await this.bitPayClient.delete('payouts/group/' + payoutGroupId, params, true);
29
+ return PayoutGroupClient.getPayoutGroupResponse(result, 'cancelled');
30
+ };
31
+ this.bitPayClient = bitPayClient;
32
+ this.tokenContainer = tokenContainer;
33
+ this.guidGenerator = guidGenerator;
34
+ }
35
+ static getPayoutGroupResponse(json, responseType) {
36
+ const response = JSON.parse(json);
37
+ if (!(responseType in response)) {
38
+ BitPayExceptionProvider_1.BitPayExceptionProvider.throwDeserializeResourceException('Payout Group', response);
39
+ }
40
+ return new PayoutGroup_1.PayoutGroup(response[responseType], response['failed']);
41
+ }
42
+ }
43
+ exports.PayoutGroupClient = PayoutGroupClient;
44
+ //# sourceMappingURL=PayoutGroupClient.js.map
@@ -0,0 +1,65 @@
1
+ import { BitPayClient } from './BitPayClient';
2
+ import { TokenContainer } from '../TokenContainer';
3
+ import { GuidGenerator } from '../util/GuidGenerator';
4
+ import { PayoutRecipientInterface, PayoutRecipients } from '../Model';
5
+ export declare class PayoutRecipientClient {
6
+ private bitPayClient;
7
+ private tokenContainer;
8
+ private guidGenerator;
9
+ constructor(bitPayClient: BitPayClient, tokenContainer: TokenContainer, guidGenerator: GuidGenerator);
10
+ /**
11
+ * Submit BitPay Payout Recipients.
12
+ *
13
+ * @param recipients A PayoutRecipients object with request parameters defined.
14
+ * @returns PayoutRecipients[] A list of BitPay PayoutRecipients objects.
15
+ * @throws BitPayApiException BitPayApiException class
16
+ * @throws BitPayGenericException BitPayGenericException class
17
+ */
18
+ submit(recipients: PayoutRecipients): Promise<PayoutRecipientInterface[]>;
19
+ /**
20
+ * Update a Payout Recipient.
21
+ *
22
+ * @param recipientId The recipient id for the recipient to be updated.
23
+ * @param recipient A PayoutRecipient object with updated parameters defined.
24
+ * @returns PayoutRecipient
25
+ * @throws BitPayApiException BitPayApiException class
26
+ * @throws BitPayGenericException BitPayGenericException class
27
+ */
28
+ update(recipientId: string, recipient: PayoutRecipientInterface): Promise<PayoutRecipientInterface>;
29
+ /**
30
+ * Retrieve a BitPay payout recipient by batch id using. The client must have been previously authorized for the payout facade.
31
+ *
32
+ * @param recipientId The id of the recipient to retrieve.
33
+ * @returns PayoutRecipient
34
+ * @throws BitPayApiException BitPayApiException class
35
+ * @throws BitPayGenericException BitPayGenericException class
36
+ */
37
+ get(recipientId: string): Promise<PayoutRecipientInterface>;
38
+ /**
39
+ * Retrieve a collection of BitPay Payout Recipients.
40
+ *
41
+ * @param params
42
+ * @returns PayoutRecipient[]
43
+ * @throws BitPayApiException BitPayApiException class
44
+ * @throws BitPayGenericException BitPayGenericException class
45
+ */
46
+ getByFilters(params: object): Promise<PayoutRecipientInterface[]>;
47
+ /**
48
+ * Delete a Payout Recipient.
49
+ *
50
+ * @param recipientId The recipient id for the recipient to be deleted.
51
+ * @returns boolean True if the recipient was successfully deleted, false otherwise.
52
+ * @throws BitPayApiException BitPayApiException class
53
+ * @throws BitPayGenericException BitPayGenericException class
54
+ */
55
+ delete(recipientId: string): Promise<boolean>;
56
+ /**
57
+ * Notify BitPay Payout Recipient.
58
+ *
59
+ * @param recipientId The id of the recipient to notify.
60
+ * @returns boolean True if the notification was successfully sent, false otherwise.
61
+ * @throws BitPayApiException BitPayApiException class
62
+ * @throws BitPayGenericException BitPayGenericException class
63
+ */
64
+ requestNotification(recipientId: string): Promise<boolean>;
65
+ }