karibou-wallet 0.5.23 → 2.9.8

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 (59) hide show
  1. package/README.md +21 -3
  2. package/dist/account.d.ts +148 -0
  3. package/dist/account.js +44 -0
  4. package/dist/account.js.map +1 -0
  5. package/dist/config.d.ts +7 -0
  6. package/dist/config.js +73 -0
  7. package/dist/config.js.map +1 -0
  8. package/dist/contract.subscription.d.ts +75 -0
  9. package/dist/contract.subscription.js +260 -0
  10. package/dist/contract.subscription.js.map +1 -0
  11. package/dist/customer.d.ts +57 -0
  12. package/dist/customer.js +407 -0
  13. package/dist/customer.js.map +1 -0
  14. package/dist/index.d.ts +6 -0
  15. package/dist/index.js +23 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/payments.d.ts +98 -0
  18. package/dist/payments.js +248 -0
  19. package/dist/payments.js.map +1 -0
  20. package/dist/transaction.d.ts +57 -0
  21. package/dist/transaction.js +437 -0
  22. package/dist/transaction.js.map +1 -0
  23. package/dist/transfer.d.ts +19 -0
  24. package/dist/transfer.js +121 -0
  25. package/dist/transfer.js.map +1 -0
  26. package/dist/webhook.d.ts +16 -0
  27. package/dist/webhook.js +68 -0
  28. package/dist/webhook.js.map +1 -0
  29. package/package.json +32 -22
  30. package/.npmignore +0 -5
  31. package/index.js +0 -30
  32. package/lib/check.js +0 -333
  33. package/lib/config.js +0 -168
  34. package/lib/error.js +0 -37
  35. package/lib/messages.js +0 -21
  36. package/lib/tools.js +0 -130
  37. package/lib/wallet.driver.mongoose.js +0 -1238
  38. package/lib/wallet.js +0 -267
  39. package/lib/wallet.transaction.js +0 -115
  40. package/lib/wallet.transfer.js +0 -89
  41. package/lib/xmlutils.js +0 -120
  42. package/test/check.js +0 -117
  43. package/test/config.js +0 -115
  44. package/test/error.js +0 -34
  45. package/test/fixtures/Wallets.js +0 -53
  46. package/test/fixtures/dbtools.js +0 -51
  47. package/test/fixtures/helpers.js +0 -64
  48. package/test/mocha.opts +0 -4
  49. package/test/tools.js +0 -32
  50. package/test/wallet.0.driver.js +0 -231
  51. package/test/wallet.0.driver.race.js +0 -68
  52. package/test/wallet.0.driver.race.transaction.js +0 -131
  53. package/test/wallet.0.driver.race.transfer.js +0 -124
  54. package/test/wallet.0.driver.transaction.credit.js +0 -176
  55. package/test/wallet.0.driver.transaction.js +0 -259
  56. package/test/wallet.0.driver.transfer.cancel.js +0 -229
  57. package/test/wallet.0.driver.transfer.js +0 -251
  58. package/test/wallet.1.js +0 -208
  59. package/test/wallet.1.transaction.js +0 -251
package/README.md CHANGED
@@ -1,6 +1,16 @@
1
+ [![David](https://img.shields.io/david/karibou-ch/karibou-wallet.svg?style=flat)](https://david-dm.org/karibou-ch/karibou-wallet)
2
+ [![Build Status](https://travis-ci.org/karibou-ch/karibou-wallet.svg?branch=master)](https://travis-ci.org/karibou-ch/karibou-wallet)
3
+ [![Join the chat at https://gitter.im/karibou-ch/karibou-wallet](https://badges.gitter.im/karibou-ch/karibou-wallet.svg)](https://gitter.im/karibou-ch/karibou-wallet?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
+
1
5
  ## Main usage
6
+
2
7
  The purpose of this project is to provide a simple and intiutive API to handle a simple Wallet manager for your e-commerce. It has bean designed to work on server side.
3
8
 
9
+ ## Prerequisites
10
+ install node.js with [NVM](https://github.com/creationix/nvm) (required).
11
+
12
+ nvm install v6.9.5
13
+ nvm use v6.9.5
4
14
 
5
15
  ## Installation
6
16
  From github,
@@ -23,14 +33,22 @@ and [should.js](https://github.com/visionmedia/should.js). The tests are run sim
23
33
  Do not run tests with your live processor. Make sure you are running in a
24
34
  sandbox.
25
35
 
36
+ ## Wallet specification 1.0
37
+ * [specifications of our wallet with Stripe](../../wiki/Wallet-1.0-Specifications-(Stripe-backend))
26
38
 
27
- ##Overview
39
+ ### Overview
28
40
  When using the karibou-wallet api, you basically deal with 3 separate concepts:
29
41
  - wallet (the container of an amount of money),
30
- - wallet can be a giftcard, it's a kind of floating wallet, it has been designed to be transfered in to a personal wallet
31
42
  - transaction (helper to manage charges)
32
- - transfer (helper to transfer money from/to BANK/Wallet)
43
+ - smartcontract (multiple destinations)
44
+ - transfer information
45
+
46
+
47
+ ## Authors & spcial thanks :heart:
33
48
 
49
+ - David Pate, https://github.com/patedavid
50
+ - Evalet Olivier, https://github.com/evaletolab
51
+ - Noria Foukia Enseignante en mathématiques @HEPIA
34
52
 
35
53
 
36
54
  ## License
@@ -0,0 +1,148 @@
1
+ /// <reference types="stripe/types/crypto/crypto" />
2
+ /// <reference types="stripe/types/shared" />
3
+ /// <reference types="stripe/types/Errors" />
4
+ /// <reference types="stripe/types/OAuth" />
5
+ /// <reference types="stripe/types/Webhooks" />
6
+ /// <reference types="stripe/types/2020-08-27/AccountLinks" />
7
+ /// <reference types="stripe/types/2020-08-27/Accounts" />
8
+ /// <reference types="stripe/types/2020-08-27/AlipayAccounts" />
9
+ /// <reference types="stripe/types/2020-08-27/ApplePayDomains" />
10
+ /// <reference types="stripe/types/2020-08-27/ApplicationFees" />
11
+ /// <reference types="stripe/types/2020-08-27/Applications" />
12
+ /// <reference types="stripe/types/2020-08-27/Apps/Secrets" />
13
+ /// <reference types="stripe/types/2020-08-27/Balance" />
14
+ /// <reference types="stripe/types/2020-08-27/BalanceTransactions" />
15
+ /// <reference types="stripe/types/2020-08-27/BankAccounts" />
16
+ /// <reference types="stripe/types/2020-08-27/BillingPortal/Configurations" />
17
+ /// <reference types="stripe/types/2020-08-27/BillingPortal/Sessions" />
18
+ /// <reference types="stripe/types/2020-08-27/BitcoinReceivers" />
19
+ /// <reference types="stripe/types/2020-08-27/BitcoinTransactions" />
20
+ /// <reference types="stripe/types/2020-08-27/Capabilities" />
21
+ /// <reference types="stripe/types/2020-08-27/Cards" />
22
+ /// <reference types="stripe/types/2020-08-27/CashBalances" />
23
+ /// <reference types="stripe/types/2020-08-27/Charges" />
24
+ /// <reference types="stripe/types/2020-08-27/Checkout/Sessions" />
25
+ /// <reference types="stripe/types/2020-08-27/ConnectCollectionTransfers" />
26
+ /// <reference types="stripe/types/2020-08-27/CountrySpecs" />
27
+ /// <reference types="stripe/types/2020-08-27/Coupons" />
28
+ /// <reference types="stripe/types/2020-08-27/CreditNoteLineItems" />
29
+ /// <reference types="stripe/types/2020-08-27/CreditNotes" />
30
+ /// <reference types="stripe/types/2020-08-27/CustomerBalanceTransactions" />
31
+ /// <reference types="stripe/types/2020-08-27/CustomerSources" />
32
+ /// <reference types="stripe/types/2020-08-27/Customers" />
33
+ /// <reference types="stripe/types/2020-08-27/Discounts" />
34
+ /// <reference types="stripe/types/2020-08-27/Disputes" />
35
+ /// <reference types="stripe/types/2020-08-27/EphemeralKeys" />
36
+ /// <reference types="stripe/types/2020-08-27/Events" />
37
+ /// <reference types="stripe/types/2020-08-27/ExchangeRates" />
38
+ /// <reference types="stripe/types/2020-08-27/ExternalAccounts" />
39
+ /// <reference types="stripe/types/2020-08-27/FeeRefunds" />
40
+ /// <reference types="stripe/types/2020-08-27/FileLinks" />
41
+ /// <reference types="stripe/types/2020-08-27/Files" />
42
+ /// <reference types="stripe/types/2020-08-27/FinancialConnections/AccountOwners" />
43
+ /// <reference types="stripe/types/2020-08-27/FinancialConnections/AccountOwnerships" />
44
+ /// <reference types="stripe/types/2020-08-27/FinancialConnections/Accounts" />
45
+ /// <reference types="stripe/types/2020-08-27/FinancialConnections/Sessions" />
46
+ /// <reference types="stripe/types/2020-08-27/FundingInstructions" />
47
+ /// <reference types="stripe/types/2020-08-27/Identity/VerificationReports" />
48
+ /// <reference types="stripe/types/2020-08-27/Identity/VerificationSessions" />
49
+ /// <reference types="stripe/types/2020-08-27/InvoiceItems" />
50
+ /// <reference types="stripe/types/2020-08-27/InvoiceLineItems" />
51
+ /// <reference types="stripe/types/2020-08-27/Invoices" />
52
+ /// <reference types="stripe/types/2020-08-27/IssuerFraudRecords" />
53
+ /// <reference types="stripe/types/2020-08-27/Issuing/Authorizations" />
54
+ /// <reference types="stripe/types/2020-08-27/Issuing/CardDetails" />
55
+ /// <reference types="stripe/types/2020-08-27/Issuing/Cardholders" />
56
+ /// <reference types="stripe/types/2020-08-27/Issuing/Cards" />
57
+ /// <reference types="stripe/types/2020-08-27/Issuing/Disputes" />
58
+ /// <reference types="stripe/types/2020-08-27/Issuing/Transactions" />
59
+ /// <reference types="stripe/types/2020-08-27/LineItems" />
60
+ /// <reference types="stripe/types/2020-08-27/LoginLinks" />
61
+ /// <reference types="stripe/types/2020-08-27/Mandates" />
62
+ /// <reference types="stripe/types/2020-08-27/Orders" />
63
+ /// <reference types="stripe/types/2020-08-27/PaymentIntents" />
64
+ /// <reference types="stripe/types/2020-08-27/PaymentLinks" />
65
+ /// <reference types="stripe/types/2020-08-27/PaymentMethods" />
66
+ /// <reference types="stripe/types/2020-08-27/Payouts" />
67
+ /// <reference types="stripe/types/2020-08-27/Persons" />
68
+ /// <reference types="stripe/types/2020-08-27/Plans" />
69
+ /// <reference types="stripe/types/2020-08-27/PlatformTaxFees" />
70
+ /// <reference types="stripe/types/2020-08-27/Prices" />
71
+ /// <reference types="stripe/types/2020-08-27/Products" />
72
+ /// <reference types="stripe/types/2020-08-27/PromotionCodes" />
73
+ /// <reference types="stripe/types/2020-08-27/Quotes" />
74
+ /// <reference types="stripe/types/2020-08-27/Radar/EarlyFraudWarnings" />
75
+ /// <reference types="stripe/types/2020-08-27/Radar/ValueListItems" />
76
+ /// <reference types="stripe/types/2020-08-27/Radar/ValueLists" />
77
+ /// <reference types="stripe/types/2020-08-27/Recipients" />
78
+ /// <reference types="stripe/types/2020-08-27/Refunds" />
79
+ /// <reference types="stripe/types/2020-08-27/Reporting/ReportRuns" />
80
+ /// <reference types="stripe/types/2020-08-27/Reporting/ReportTypes" />
81
+ /// <reference types="stripe/types/2020-08-27/ReserveTransactions" />
82
+ /// <reference types="stripe/types/2020-08-27/Reviews" />
83
+ /// <reference types="stripe/types/2020-08-27/SKUs" />
84
+ /// <reference types="stripe/types/2020-08-27/SetupAttempts" />
85
+ /// <reference types="stripe/types/2020-08-27/SetupIntents" />
86
+ /// <reference types="stripe/types/2020-08-27/ShippingRates" />
87
+ /// <reference types="stripe/types/2020-08-27/Sigma/ScheduledQueryRuns" />
88
+ /// <reference types="stripe/types/2020-08-27/SourceMandateNotifications" />
89
+ /// <reference types="stripe/types/2020-08-27/SourceTransactions" />
90
+ /// <reference types="stripe/types/2020-08-27/Sources" />
91
+ /// <reference types="stripe/types/2020-08-27/SubscriptionItems" />
92
+ /// <reference types="stripe/types/2020-08-27/SubscriptionSchedules" />
93
+ /// <reference types="stripe/types/2020-08-27/Subscriptions" />
94
+ /// <reference types="stripe/types/2020-08-27/TaxCodes" />
95
+ /// <reference types="stripe/types/2020-08-27/TaxDeductedAtSources" />
96
+ /// <reference types="stripe/types/2020-08-27/TaxIds" />
97
+ /// <reference types="stripe/types/2020-08-27/TaxRates" />
98
+ /// <reference types="stripe/types/2020-08-27/Terminal/Configurations" />
99
+ /// <reference types="stripe/types/2020-08-27/Terminal/ConnectionTokens" />
100
+ /// <reference types="stripe/types/2020-08-27/Terminal/Locations" />
101
+ /// <reference types="stripe/types/2020-08-27/Terminal/Readers" />
102
+ /// <reference types="stripe/types/2020-08-27/TestHelpers/Customers" />
103
+ /// <reference types="stripe/types/2020-08-27/TestHelpers/Issuing/Cards" />
104
+ /// <reference types="stripe/types/2020-08-27/TestHelpers/Refunds" />
105
+ /// <reference types="stripe/types/2020-08-27/TestHelpers/Terminal/Readers" />
106
+ /// <reference types="stripe/types/2020-08-27/TestHelpers/TestClocks" />
107
+ /// <reference types="stripe/types/2020-08-27/TestHelpers/Treasury/InboundTransfers" />
108
+ /// <reference types="stripe/types/2020-08-27/TestHelpers/Treasury/OutboundPayments" />
109
+ /// <reference types="stripe/types/2020-08-27/TestHelpers/Treasury/OutboundTransfers" />
110
+ /// <reference types="stripe/types/2020-08-27/TestHelpers/Treasury/ReceivedCredits" />
111
+ /// <reference types="stripe/types/2020-08-27/TestHelpers/Treasury/ReceivedDebits" />
112
+ /// <reference types="stripe/types/2020-08-27/Tokens" />
113
+ /// <reference types="stripe/types/2020-08-27/Topups" />
114
+ /// <reference types="stripe/types/2020-08-27/TransferReversals" />
115
+ /// <reference types="stripe/types/2020-08-27/Transfers" />
116
+ /// <reference types="stripe/types/2020-08-27/Treasury/CreditReversals" />
117
+ /// <reference types="stripe/types/2020-08-27/Treasury/DebitReversals" />
118
+ /// <reference types="stripe/types/2020-08-27/Treasury/FinancialAccountFeatures" />
119
+ /// <reference types="stripe/types/2020-08-27/Treasury/FinancialAccounts" />
120
+ /// <reference types="stripe/types/2020-08-27/Treasury/InboundTransfers" />
121
+ /// <reference types="stripe/types/2020-08-27/Treasury/OutboundPayments" />
122
+ /// <reference types="stripe/types/2020-08-27/Treasury/OutboundTransfers" />
123
+ /// <reference types="stripe/types/2020-08-27/Treasury/ReceivedCredits" />
124
+ /// <reference types="stripe/types/2020-08-27/Treasury/ReceivedDebits" />
125
+ /// <reference types="stripe/types/2020-08-27/Treasury/TransactionEntries" />
126
+ /// <reference types="stripe/types/2020-08-27/Treasury/Transactions" />
127
+ /// <reference types="stripe/types/2020-08-27/UsageRecordSummaries" />
128
+ /// <reference types="stripe/types/2020-08-27/UsageRecords" />
129
+ /// <reference types="stripe/types/2020-08-27/WebhookEndpoints" />
130
+ /// <reference types="stripe" />
131
+ /// <reference types="stripe/types/lib" />
132
+ /// <reference types="stripe/types/net/net" />
133
+ export declare class Account {
134
+ private _id;
135
+ private _email;
136
+ private _lastname;
137
+ private _firstname;
138
+ private _address;
139
+ private _postalCode;
140
+ private _city;
141
+ private _company;
142
+ private constructor();
143
+ get id(): any;
144
+ static create(id: string): void;
145
+ save(): string;
146
+ getTransferList(limit?: number, transferOffset?: any): Promise<void | import("stripe").Stripe.Response<import("stripe").Stripe.ApiList<import("stripe").Stripe.Transfer>>>;
147
+ getId(): any;
148
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Account = void 0;
4
+ const payments_1 = require("./payments");
5
+ class Account {
6
+ constructor(params) {
7
+ if ("email" in params)
8
+ this._email = params.email;
9
+ else
10
+ throw new Error("Missing parameter: email");
11
+ if ("id" in params)
12
+ this._id = params.id;
13
+ else
14
+ throw new Error("Missing parameter: Stripe account id");
15
+ this._lastname = params.lastname;
16
+ this._firstname = params.firstname;
17
+ this._address = params.address;
18
+ this._city = params.city;
19
+ this._postalCode = params.postalCode;
20
+ this._company = params.company;
21
+ }
22
+ get id() {
23
+ return this.id;
24
+ }
25
+ static create(id) {
26
+ }
27
+ save() {
28
+ return JSON.stringify(this);
29
+ }
30
+ getTransferList(limit = 10, transferOffset) {
31
+ if (transferOffset != undefined)
32
+ return payments_1.$stripe.transfers.list({ destination: this.id, limit: limit, starting_after: transferOffset }).catch(parseError);
33
+ else
34
+ return payments_1.$stripe.transfers.list({ destination: this.id, limit: limit }).catch(parseError);
35
+ }
36
+ getId() {
37
+ return this.id;
38
+ }
39
+ }
40
+ exports.Account = Account;
41
+ function parseError(err) {
42
+ throw new Error(err);
43
+ }
44
+ //# sourceMappingURL=account.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.js","sourceRoot":"","sources":["../lib/account.ts"],"names":[],"mappings":";;;AAMA,yCAAqC;AAErC,MAAe,OAAO;IAepB,YAAoB,MAAU;QAC5B,IAAI,OAAO,IAAI,MAAM;YAAE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC;;YAC7C,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAEjD,IAAI,IAAI,IAAI,MAAM;YAAE,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,EAAE,CAAC;;YACpC,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAE7D,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC;IACjC,CAAC;IAGD,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,EAAE,CAAC;IACjB,CAAC;IASD,MAAM,CAAC,MAAM,CAAC,EAAS;IAcvB,CAAC;IAOD,IAAI;QACF,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAUD,eAAe,CAAC,QAAa,EAAE,EAAE,cAAmB;QAClD,IAAI,cAAc,IAAI,SAAS;YAC7B,OAAO,kBAAO,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,WAAW,EAAC,IAAI,CAAC,EAAE,EAAE,KAAK,EAAC,KAAK,EAAE,cAAc,EAAC,cAAc,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;;YAErH,OAAO,kBAAO,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,WAAW,EAAC,IAAI,CAAC,EAAE,EAAE,KAAK,EAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC1F,CAAC;IAOD,KAAK;QACH,OAAO,IAAI,CAAC,EAAE,CAAC;IACjB,CAAC;CACF;AA1FD,0BA0FC;AAED,SAAS,UAAU,CAAC,GAAG;IACrB,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC"}
@@ -0,0 +1,7 @@
1
+ export default class Config {
2
+ private static settings;
3
+ private constructor();
4
+ static reset(): void;
5
+ static configure(opts: any): any;
6
+ static option(option: string, value?: any): any;
7
+ }
package/dist/config.js ADDED
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class Config {
4
+ constructor(opts) {
5
+ Object.keys(opts).forEach(function (key) {
6
+ Config.option(key, opts[key]);
7
+ });
8
+ Config.settings.isConfigured = true;
9
+ }
10
+ static reset() {
11
+ if (process.env.NODE_ENV == 'test') {
12
+ Config.settings.allowMultipleSetOption = true;
13
+ }
14
+ else
15
+ throw new Error('Reset is not possible here');
16
+ }
17
+ static configure(opts) {
18
+ if (Config.settings) {
19
+ return Config.settings;
20
+ }
21
+ Config.settings = { isConfigured: false };
22
+ if (!opts.apikey) {
23
+ throw new Error('Incomplete Wallet API credentials');
24
+ }
25
+ return new Config(opts);
26
+ }
27
+ static option(option, value) {
28
+ if (typeof value !== 'undefined') {
29
+ if (Config.settings.isConfigured && !Config.settings.allowMultipleSetOption) {
30
+ throw new Error('Option is already locked');
31
+ }
32
+ switch (option) {
33
+ case 'stripeApiVersion':
34
+ case 'stripePrivatekey':
35
+ case 'grantSecret':
36
+ case 'webhookSecret':
37
+ case 'karibouApikey':
38
+ case 'apikey':
39
+ case 'provider':
40
+ case 'currency':
41
+ case 'secret':
42
+ case 'shaSecret':
43
+ Config.settings[option] = value;
44
+ break;
45
+ case 'allowMaxAmount':
46
+ case 'allowMaxCredit':
47
+ case 'reservedAmount':
48
+ Config.settings[option] = parseFloat(value);
49
+ break;
50
+ case 'sandbox':
51
+ case 'debug':
52
+ case 'allowMultipleSetOption':
53
+ Config.settings[option] = Boolean(value);
54
+ break;
55
+ case 'allowedCurrencies':
56
+ if (!Array.isArray(value)) {
57
+ throw new Error('Allowed currencies must be an array');
58
+ }
59
+ if (value.indexOf(Config.settings.currency) < 0) {
60
+ value.push(Config.settings.currency);
61
+ }
62
+ Config.settings[option] = value;
63
+ break;
64
+ default:
65
+ throw new Error('Unrecognized configuration option');
66
+ }
67
+ }
68
+ return Config.settings[option];
69
+ }
70
+ ;
71
+ }
72
+ exports.default = Config;
73
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../lib/config.ts"],"names":[],"mappings":";;AASA,MAAqB,MAAM;IAIzB,YAAoB,IAAI;QAEtB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,UAAS,GAAG;YACpC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,QAAQ,CAAC,YAAY,GAAG,IAAI,CAAC;IACtC,CAAC;IAID,MAAM,CAAC,KAAK;QACV,IAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAE,MAAM,EAAC;YAC9B,MAAM,CAAC,QAAQ,CAAC,sBAAsB,GAAC,IAAI,CAAC;SAC7C;;YACI,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;IACpD,CAAC;IAID,MAAM,CAAC,SAAS,CAAC,IAAS;QACxB,IAAG,MAAM,CAAC,QAAQ,EAAE;YAClB,OAAO,MAAM,CAAC,QAAQ,CAAC;SACxB;QAED,MAAM,CAAC,QAAQ,GAAG,EAAE,YAAY,EAAG,KAAK,EAAE,CAAC;QAG3C,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;SACtD;QACD,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAKD,MAAM,CAAC,MAAM,CAAC,MAAa,EAAE,KAAM;QACjC,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;YAGhC,IAAI,MAAM,CAAC,QAAQ,CAAC,YAAY,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,sBAAsB,EAAG;gBAC1E,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;aAC/C;YAED,QAAQ,MAAM,EAAE;gBACd,KAAK,kBAAkB,CAAC;gBACxB,KAAK,kBAAkB,CAAC;gBACxB,KAAK,aAAa,CAAC;gBACnB,KAAK,eAAe,CAAC;gBACrB,KAAK,eAAe,CAAC;gBACrB,KAAK,QAAQ,CAAC;gBACd,KAAK,UAAU,CAAC;gBAChB,KAAK,UAAU,CAAC;gBAChB,KAAK,QAAQ,CAAC;gBACd,KAAK,WAAW;oBACd,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;oBAAA,MAAM;gBACxC,KAAK,gBAAgB,CAAC;gBACtB,KAAK,gBAAgB,CAAC;gBACtB,KAAK,gBAAgB;oBACjB,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;oBAAA,MAAM;gBACtD,KAAK,SAAS,CAAC;gBACf,KAAK,OAAO,CAAC;gBACb,KAAK,wBAAwB;oBAC3B,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;oBAAA,MAAM;gBACjD,KAAK,mBAAmB;oBACtB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;wBACzB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;qBACxD;oBACD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;wBAC/C,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;qBACtC;oBACD,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;oBAChC,MAAM;gBACR;oBAEE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;aACxD;SACF;QACD,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAAA,CAAC;CAEH;AAtFD,yBAsFC"}
@@ -0,0 +1,75 @@
1
+ import Stripe from 'stripe';
2
+ import { Customer } from './customer';
3
+ import { KngPaymentAddress, KngCard } from './payments';
4
+ export type Interval = Stripe.Plan.Interval;
5
+ export interface SubscriptionMetaItem {
6
+ sku: string | number;
7
+ quantity: number;
8
+ title: string;
9
+ part: string;
10
+ hub: string;
11
+ note: string;
12
+ fees: number;
13
+ }
14
+ export interface SubscriptionItem {
15
+ currency: string;
16
+ unit_amount: number;
17
+ product: string;
18
+ recurring: {
19
+ interval: Interval;
20
+ interval_count: number;
21
+ };
22
+ metadata?: SubscriptionMetaItem;
23
+ }
24
+ export declare enum SchedulerStatus {
25
+ active = 1,
26
+ paused = 2,
27
+ pending = 3,
28
+ closed = 4
29
+ }
30
+ export declare enum SchedulerItemFrequency {
31
+ RECURRENT_NONE = 0,
32
+ RECURRENT_DAY = 1,
33
+ RECURRENT_WEEK = 2,
34
+ RECURRENT_2WEEKS = 3,
35
+ RECURRENT_MONTH = 4
36
+ }
37
+ export interface SubscriptionAddress extends KngPaymentAddress {
38
+ price: number;
39
+ dayOfWeek?: number;
40
+ }
41
+ export declare class SubscriptionContract {
42
+ private _subscription;
43
+ private _status;
44
+ private _id;
45
+ private _interval;
46
+ private _interval_count;
47
+ private constructor();
48
+ get id(): string;
49
+ get interval(): {
50
+ start: Date;
51
+ bill: Stripe.Plan.Interval;
52
+ count: number;
53
+ };
54
+ get status(): "paused" | Stripe.Subscription.Status;
55
+ get description(): any;
56
+ get pausedUntil(): number;
57
+ get shipping(): SubscriptionAddress;
58
+ get paymentMethodID(): string;
59
+ get billing_cycle_anchor(): Date;
60
+ get items(): any[];
61
+ getNextBillingDay(): {
62
+ billing: Date;
63
+ dayOfWeek: number;
64
+ };
65
+ customer(): Promise<Customer>;
66
+ cancel(): Promise<void>;
67
+ updateItemsAndPrice(cardTtems: any): Promise<void>;
68
+ pause(to: Date): Promise<void>;
69
+ resumeManualy(): Promise<void>;
70
+ updatePaymentMethod(card: KngCard): Promise<this>;
71
+ static create(customer: Customer, card: KngCard, interval: Interval, start_from: any, shipping: SubscriptionAddress, cartItems: any, dayOfWeek: any, fees: any): Promise<SubscriptionContract>;
72
+ static get(id: any): Promise<SubscriptionContract>;
73
+ static list(customer: Customer): Promise<SubscriptionContract[]>;
74
+ static listAll(options: any): Promise<SubscriptionContract[]>;
75
+ }