karibou-wallet 0.6.0 → 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.
- package/dist/account.d.ts +148 -0
- package/dist/account.js +44 -0
- package/dist/account.js.map +1 -0
- package/dist/config.d.ts +7 -0
- package/dist/config.js +73 -0
- package/dist/config.js.map +1 -0
- package/dist/contract.subscription.d.ts +75 -0
- package/dist/contract.subscription.js +260 -0
- package/dist/contract.subscription.js.map +1 -0
- package/dist/customer.d.ts +57 -0
- package/dist/customer.js +407 -0
- package/dist/customer.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/payments.d.ts +98 -0
- package/dist/payments.js +248 -0
- package/dist/payments.js.map +1 -0
- package/dist/transaction.d.ts +57 -0
- package/dist/transaction.js +437 -0
- package/dist/transaction.js.map +1 -0
- package/dist/transfer.d.ts +19 -0
- package/dist/transfer.js +121 -0
- package/dist/transfer.js.map +1 -0
- package/dist/webhook.d.ts +16 -0
- package/dist/webhook.js +68 -0
- package/dist/webhook.js.map +1 -0
- package/package.json +30 -23
- package/.npmignore +0 -5
- package/.travis.yml +0 -20
- package/index.js +0 -30
- package/lib/check.js +0 -333
- package/lib/config.js +0 -168
- package/lib/error.js +0 -37
- package/lib/messages.js +0 -21
- package/lib/tools.js +0 -155
- package/lib/wallet.driver.mongoose.js +0 -1265
- package/lib/wallet.js +0 -267
- package/lib/wallet.transaction.js +0 -116
- package/lib/wallet.transfer.js +0 -90
- package/lib/xmlutils.js +0 -120
- package/test/check.js +0 -117
- package/test/config.js +0 -115
- package/test/error.js +0 -34
- package/test/fixtures/Wallets.js +0 -53
- package/test/fixtures/dbtools.js +0 -52
- package/test/fixtures/helpers.js +0 -64
- package/test/mocha.opts +0 -4
- package/test/tools.js +0 -32
- package/test/wallet.0.driver.js +0 -231
- package/test/wallet.0.driver.race.js +0 -68
- package/test/wallet.0.driver.race.transaction.js +0 -132
- package/test/wallet.0.driver.race.transfer.js +0 -129
- package/test/wallet.0.driver.transaction.credit.js +0 -176
- package/test/wallet.0.driver.transaction.js +0 -263
- package/test/wallet.0.driver.transfer.cancel.js +0 -236
- package/test/wallet.0.driver.transfer.js +0 -255
- package/test/wallet.1.js +0 -208
- package/test/wallet.1.transaction.js +0 -252
|
@@ -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
|
+
}
|
package/dist/account.js
ADDED
|
@@ -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,C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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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,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
|
+
}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SubscriptionContract = exports.SchedulerItemFrequency = exports.SchedulerStatus = void 0;
|
|
13
|
+
const assert_1 = require("assert");
|
|
14
|
+
const customer_1 = require("./customer");
|
|
15
|
+
const payments_1 = require("./payments");
|
|
16
|
+
const config_1 = require("./config");
|
|
17
|
+
var SchedulerStatus;
|
|
18
|
+
(function (SchedulerStatus) {
|
|
19
|
+
SchedulerStatus[SchedulerStatus["active"] = 1] = "active";
|
|
20
|
+
SchedulerStatus[SchedulerStatus["paused"] = 2] = "paused";
|
|
21
|
+
SchedulerStatus[SchedulerStatus["pending"] = 3] = "pending";
|
|
22
|
+
SchedulerStatus[SchedulerStatus["closed"] = 4] = "closed";
|
|
23
|
+
})(SchedulerStatus = exports.SchedulerStatus || (exports.SchedulerStatus = {}));
|
|
24
|
+
var SchedulerItemFrequency;
|
|
25
|
+
(function (SchedulerItemFrequency) {
|
|
26
|
+
SchedulerItemFrequency[SchedulerItemFrequency["RECURRENT_NONE"] = 0] = "RECURRENT_NONE";
|
|
27
|
+
SchedulerItemFrequency[SchedulerItemFrequency["RECURRENT_DAY"] = 1] = "RECURRENT_DAY";
|
|
28
|
+
SchedulerItemFrequency[SchedulerItemFrequency["RECURRENT_WEEK"] = 2] = "RECURRENT_WEEK";
|
|
29
|
+
SchedulerItemFrequency[SchedulerItemFrequency["RECURRENT_2WEEKS"] = 3] = "RECURRENT_2WEEKS";
|
|
30
|
+
SchedulerItemFrequency[SchedulerItemFrequency["RECURRENT_MONTH"] = 4] = "RECURRENT_MONTH";
|
|
31
|
+
})(SchedulerItemFrequency = exports.SchedulerItemFrequency || (exports.SchedulerItemFrequency = {}));
|
|
32
|
+
class SubscriptionContract {
|
|
33
|
+
constructor(subs) {
|
|
34
|
+
this._subscription = subs;
|
|
35
|
+
this._interval = this._subscription.items.data[0].plan.interval;
|
|
36
|
+
this._interval_count = this._subscription.items.data[0].plan.interval_count;
|
|
37
|
+
}
|
|
38
|
+
get id() { return this._subscription.id; }
|
|
39
|
+
get interval() {
|
|
40
|
+
return {
|
|
41
|
+
start: this.billing_cycle_anchor,
|
|
42
|
+
bill: this._interval,
|
|
43
|
+
count: this._interval_count
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
get status() {
|
|
47
|
+
if (this._subscription.pause_collection) {
|
|
48
|
+
return 'paused';
|
|
49
|
+
}
|
|
50
|
+
return this._subscription.status;
|
|
51
|
+
}
|
|
52
|
+
get description() { return this._subscription.description; }
|
|
53
|
+
get pausedUntil() {
|
|
54
|
+
if (this._subscription.pause_collection && this._subscription.pause_collection.resumes_at) {
|
|
55
|
+
return (this._subscription.pause_collection.resumes_at) || 0;
|
|
56
|
+
}
|
|
57
|
+
return 0;
|
|
58
|
+
}
|
|
59
|
+
get shipping() {
|
|
60
|
+
return parseShipping(this._subscription.metadata);
|
|
61
|
+
}
|
|
62
|
+
get paymentMethodID() {
|
|
63
|
+
return (0, payments_1.xor)(this._subscription.default_payment_method);
|
|
64
|
+
}
|
|
65
|
+
get billing_cycle_anchor() {
|
|
66
|
+
return new Date(this._subscription.billing_cycle_anchor * 1000);
|
|
67
|
+
}
|
|
68
|
+
get items() {
|
|
69
|
+
const elements = this._subscription.items.data.map(parseItem);
|
|
70
|
+
return elements;
|
|
71
|
+
}
|
|
72
|
+
getNextBillingDay() {
|
|
73
|
+
const dayOfBilling = this.billing_cycle_anchor;
|
|
74
|
+
const today = new Date();
|
|
75
|
+
const month = (today.getDate() > dayOfBilling.getDate()) ? today.getMonth() + 1 : today.getMonth();
|
|
76
|
+
const billing = new Date(today.getFullYear(), month, dayOfBilling.getDate());
|
|
77
|
+
return { billing, dayOfWeek: this.shipping.dayOfWeek };
|
|
78
|
+
}
|
|
79
|
+
customer() {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
return customer_1.Customer.get(this._subscription.customer);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
cancel() {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
this._subscription = yield payments_1.$stripe.subscriptions.update(this._subscription.id, { cancel_at_period_end: true });
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
updateItemsAndPrice(cardTtems) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
pause(to) {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
const customer = this._subscription.customer;
|
|
96
|
+
const metadata = this._subscription.metadata;
|
|
97
|
+
const behavior = {
|
|
98
|
+
behavior: 'void'
|
|
99
|
+
};
|
|
100
|
+
if (to) {
|
|
101
|
+
if (!to.toDateString)
|
|
102
|
+
throw new Error("resume date is incorrect");
|
|
103
|
+
metadata.to = to.getTime() + '';
|
|
104
|
+
behavior.resumes_at = to.getTime();
|
|
105
|
+
}
|
|
106
|
+
metadata.from = Date.now() + '';
|
|
107
|
+
this._subscription = yield payments_1.$stripe.subscriptions.update(this._subscription.id, { pause_collection: behavior });
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
resumeManualy() {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
const metadata = this._subscription.metadata;
|
|
113
|
+
metadata.from = null;
|
|
114
|
+
metadata.to = null;
|
|
115
|
+
this._subscription = yield payments_1.$stripe.subscriptions.update(this._subscription.id, { pause_collection: '', metadata });
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
updatePaymentMethod(card) {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
this._subscription = yield payments_1.$stripe.subscriptions.update(this.id, {
|
|
121
|
+
default_payment_method: (0, payments_1.unxor)(card.id)
|
|
122
|
+
});
|
|
123
|
+
return this;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
static create(customer, card, interval, start_from, shipping, cartItems, dayOfWeek, fees) {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
(0, assert_1.strict)(start_from && start_from.toDateString);
|
|
129
|
+
(0, assert_1.strict)(shipping.price);
|
|
130
|
+
(0, assert_1.strict)(shipping.lat);
|
|
131
|
+
(0, assert_1.strict)(shipping.lng);
|
|
132
|
+
for (let item of cartItems) {
|
|
133
|
+
item.product = yield findOrCreateProductFromItem(item);
|
|
134
|
+
}
|
|
135
|
+
const items = createItemsFromCart(cartItems, fees);
|
|
136
|
+
const metadata = { address: JSON.stringify(shipping, null, 0), dayOfWeek };
|
|
137
|
+
const description = "Contrat : " + interval;
|
|
138
|
+
const options = {
|
|
139
|
+
customer: customer.id,
|
|
140
|
+
payment_behavior: 'allow_incomplete',
|
|
141
|
+
default_payment_method: (0, payments_1.unxor)(card.id),
|
|
142
|
+
off_session: true,
|
|
143
|
+
description,
|
|
144
|
+
billing_cycle_anchor: start_from,
|
|
145
|
+
items: items[interval],
|
|
146
|
+
metadata
|
|
147
|
+
};
|
|
148
|
+
try {
|
|
149
|
+
const subscription = yield payments_1.$stripe.subscriptions.create(options);
|
|
150
|
+
return new SubscriptionContract(subscription);
|
|
151
|
+
}
|
|
152
|
+
catch (err) {
|
|
153
|
+
throw parseError(err);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
static get(id) {
|
|
158
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
159
|
+
try {
|
|
160
|
+
const stripe = yield payments_1.$stripe.subscriptions.retrieve(id);
|
|
161
|
+
const subscription = new SubscriptionContract(stripe);
|
|
162
|
+
return subscription;
|
|
163
|
+
}
|
|
164
|
+
catch (err) {
|
|
165
|
+
throw parseError(err);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
static list(customer) {
|
|
170
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
171
|
+
const subscriptions = yield payments_1.$stripe.subscriptions.list({
|
|
172
|
+
customer: customer.id
|
|
173
|
+
});
|
|
174
|
+
return subscriptions.data.map(sub => new SubscriptionContract(sub));
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
static listAll(options) {
|
|
178
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
179
|
+
if (!options.active && !options.unpaid && !options.incomplete && !options.paused) {
|
|
180
|
+
throw new Error("Subscription list params error");
|
|
181
|
+
}
|
|
182
|
+
const subscriptions = yield payments_1.$stripe.subscriptions.list(options);
|
|
183
|
+
return subscriptions.data.map(sub => new SubscriptionContract(sub));
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
exports.SubscriptionContract = SubscriptionContract;
|
|
188
|
+
function findOrCreateProductFromItem(item) {
|
|
189
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
190
|
+
const product = yield payments_1.$stripe.products.search({
|
|
191
|
+
query: "active:'true' AND name:'" + item.sku + "'", limit: 1
|
|
192
|
+
});
|
|
193
|
+
if (product && product.data.length) {
|
|
194
|
+
return product.data[0].id;
|
|
195
|
+
}
|
|
196
|
+
const created = yield payments_1.$stripe.products.create({
|
|
197
|
+
name: item.sku,
|
|
198
|
+
description: item.title + "(" + item.part + ")"
|
|
199
|
+
});
|
|
200
|
+
return created.id;
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
function createItemsFromCart(cartItems, fees) {
|
|
204
|
+
const itemCreation = (item, interval) => {
|
|
205
|
+
const interval_count = {
|
|
206
|
+
'week': 1,
|
|
207
|
+
'month': 1
|
|
208
|
+
};
|
|
209
|
+
const metadata = {
|
|
210
|
+
sku: item.sku,
|
|
211
|
+
quantity: item.quantity,
|
|
212
|
+
title: item.title,
|
|
213
|
+
part: item.part,
|
|
214
|
+
hub: item.hub,
|
|
215
|
+
note: item.note,
|
|
216
|
+
fees
|
|
217
|
+
};
|
|
218
|
+
const price = (item.price * (1 + fees) * 100).toFixed(0);
|
|
219
|
+
const instance = {
|
|
220
|
+
currency: 'CHF',
|
|
221
|
+
unit_amount: parseInt(price),
|
|
222
|
+
product: item.product,
|
|
223
|
+
recurring: { interval, interval_count: interval_count[interval] }
|
|
224
|
+
};
|
|
225
|
+
return { metadata, quantity: item.quantity, price_data: instance };
|
|
226
|
+
};
|
|
227
|
+
const week = cartItems.filter(item => item.frequency == SchedulerItemFrequency.RECURRENT_WEEK).map(i => itemCreation(i, 'week'));
|
|
228
|
+
const month = cartItems.filter(item => item.frequency == SchedulerItemFrequency.RECURRENT_MONTH).map(i => itemCreation(i, 'month'));
|
|
229
|
+
return { week, month };
|
|
230
|
+
}
|
|
231
|
+
function parseItem(item) {
|
|
232
|
+
return {
|
|
233
|
+
unit_amount: item.price.unit_amount,
|
|
234
|
+
currency: item.price.currency,
|
|
235
|
+
quantity: (item.quantity),
|
|
236
|
+
dayOfWeek: parseInt(item.metadata.dayOfWeek),
|
|
237
|
+
fees: parseFloat(item.metadata.fees),
|
|
238
|
+
hub: item.metadata.hub,
|
|
239
|
+
note: item.metadata.note,
|
|
240
|
+
part: item.metadata.part,
|
|
241
|
+
sku: item.metadata.sku,
|
|
242
|
+
title: item.metadata.title
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
function parseShipping(metadata) {
|
|
246
|
+
try {
|
|
247
|
+
const address = JSON.parse(metadata['address']);
|
|
248
|
+
address.dayOfWeek = parseInt(metadata['dayOfWeek']);
|
|
249
|
+
return address;
|
|
250
|
+
}
|
|
251
|
+
catch (err) {
|
|
252
|
+
console.log('---- DBG error parseAddress', err);
|
|
253
|
+
throw err;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
function parseError(err) {
|
|
257
|
+
config_1.default.option('debug') && console.log('---- DBG error', err);
|
|
258
|
+
return new Error(err);
|
|
259
|
+
}
|
|
260
|
+
//# sourceMappingURL=contract.subscription.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.subscription.js","sourceRoot":"","sources":["../lib/contract.subscription.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAA0C;AAE1C,yCAAsC;AACtC,yCAA6E;AAC7E,qCAA8B;AA0B9B,IAAY,eAEX;AAFD,WAAY,eAAe;IACzB,yDAAU,CAAA;IAAE,yDAAM,CAAA;IAAE,2DAAO,CAAA;IAAE,yDAAM,CAAA;AACrC,CAAC,EAFW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAE1B;AAGD,IAAY,sBAMX;AAND,WAAY,sBAAsB;IAChC,uFAAuB,CAAA;IACvB,qFAAuB,CAAA;IACvB,uFAAuB,CAAA;IACvB,2FAAuB,CAAA;IACvB,yFAAuB,CAAA;AACzB,CAAC,EANW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAMjC;AAcD,MAAa,oBAAoB;IAQ/B,YAAoB,IAAwB;QAC1C,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;QAChE,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC;IAC9E,CAAC;IAED,IAAI,EAAE,KAAM,OAAO,IAAI,CAAC,aAAa,CAAC,EAAE,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