karibou-wallet 0.5.23 → 2.9.9
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/README.md +21 -3
- 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 +18 -0
- package/dist/config.js +103 -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 +52 -0
- package/dist/customer.js +323 -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 +55 -0
- package/dist/payments.js +243 -0
- package/dist/payments.js.map +1 -0
- package/dist/transaction.d.ts +50 -0
- package/dist/transaction.js +315 -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 +32 -22
- package/.npmignore +0 -5
- 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 -130
- package/lib/wallet.driver.mongoose.js +0 -1238
- package/lib/wallet.js +0 -267
- package/lib/wallet.transaction.js +0 -115
- package/lib/wallet.transfer.js +0 -89
- 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 -51
- 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 -131
- package/test/wallet.0.driver.race.transfer.js +0 -124
- package/test/wallet.0.driver.transaction.credit.js +0 -176
- package/test/wallet.0.driver.transaction.js +0 -259
- package/test/wallet.0.driver.transfer.cancel.js +0 -229
- package/test/wallet.0.driver.transfer.js +0 -251
- package/test/wallet.1.js +0 -208
- package/test/wallet.1.transaction.js +0 -251
package/README.md
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
|
+
[](https://david-dm.org/karibou-ch/karibou-wallet)
|
|
2
|
+
[](https://travis-ci.org/karibou-ch/karibou-wallet)
|
|
3
|
+
[](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
|
-
|
|
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
|
-
-
|
|
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
|
+
}
|
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;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3
|
+
private stripePrivatekey;
|
|
4
|
+
private debug;
|
|
5
|
+
private allowMaxAmount;
|
|
6
|
+
private sandbox;
|
|
7
|
+
private apikey;
|
|
8
|
+
private secret;
|
|
9
|
+
private currency;
|
|
10
|
+
private allowedCurrencies;
|
|
11
|
+
private allowMultipleSetOption;
|
|
12
|
+
private static settings;
|
|
13
|
+
private constructor();
|
|
14
|
+
static reset(): void;
|
|
15
|
+
static configure(opts: any): any;
|
|
16
|
+
static option(option: string, value?: any): any;
|
|
17
|
+
}
|
|
18
|
+
export declare const $config: any;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.$config = void 0;
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
class Config {
|
|
6
|
+
constructor(opts) {
|
|
7
|
+
this.debug = false;
|
|
8
|
+
this.allowMaxAmount = 1000.00;
|
|
9
|
+
this.sandbox = false;
|
|
10
|
+
this.debug = false;
|
|
11
|
+
this.allowMultipleSetOption = false;
|
|
12
|
+
Object.keys(opts).forEach(function (key) {
|
|
13
|
+
Config.option(key, opts[key]);
|
|
14
|
+
});
|
|
15
|
+
Config.settings.isConfigured = true;
|
|
16
|
+
}
|
|
17
|
+
static reset() {
|
|
18
|
+
if (process.env.NODE_ENV == 'test') {
|
|
19
|
+
Config.settings.allowMultipleSetOption = true;
|
|
20
|
+
}
|
|
21
|
+
else
|
|
22
|
+
throw new Error('Reset is not possible here');
|
|
23
|
+
}
|
|
24
|
+
static configure(opts) {
|
|
25
|
+
if (Config.settings) {
|
|
26
|
+
return Config.settings;
|
|
27
|
+
}
|
|
28
|
+
Config.settings = { isConfigured: false };
|
|
29
|
+
if (!opts.apikey) {
|
|
30
|
+
throw new Error('Incomplete Wallet API credentials');
|
|
31
|
+
}
|
|
32
|
+
return new Config(opts);
|
|
33
|
+
}
|
|
34
|
+
static option(option, value) {
|
|
35
|
+
if (typeof value !== 'undefined') {
|
|
36
|
+
if (Config.settings.isConfigured && !Config.settings.allowMultipleSetOption) {
|
|
37
|
+
throw new Error('Option is already locked');
|
|
38
|
+
}
|
|
39
|
+
switch (option) {
|
|
40
|
+
case 'stripeApiVersion':
|
|
41
|
+
case 'stripePrivatekey':
|
|
42
|
+
case 'grantSecret':
|
|
43
|
+
case 'webhookSecret':
|
|
44
|
+
case 'karibouApikey':
|
|
45
|
+
case 'apikey':
|
|
46
|
+
case 'currency':
|
|
47
|
+
case 'secret':
|
|
48
|
+
case 'shaSecret':
|
|
49
|
+
Config.settings[option] = value;
|
|
50
|
+
break;
|
|
51
|
+
case 'allowMaxAmount':
|
|
52
|
+
case 'reservedAmount':
|
|
53
|
+
Config.settings[option] = parseFloat(value);
|
|
54
|
+
break;
|
|
55
|
+
case 'sandbox':
|
|
56
|
+
case 'debug':
|
|
57
|
+
case 'allowMultipleSetOption':
|
|
58
|
+
Config.settings[option] = Boolean(value);
|
|
59
|
+
break;
|
|
60
|
+
case 'allowedCurrencies':
|
|
61
|
+
if (!Array.isArray(value)) {
|
|
62
|
+
throw new Error('Allowed currencies must be an array');
|
|
63
|
+
}
|
|
64
|
+
if (value.indexOf(Config.settings.currency) < 0) {
|
|
65
|
+
value.push(Config.settings.currency);
|
|
66
|
+
}
|
|
67
|
+
Config.settings[option] = value;
|
|
68
|
+
break;
|
|
69
|
+
default:
|
|
70
|
+
throw new Error('Unrecognized configuration option');
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return Config.settings[option];
|
|
74
|
+
}
|
|
75
|
+
;
|
|
76
|
+
}
|
|
77
|
+
exports.default = Config;
|
|
78
|
+
const env = (process.env.NODE_ENV || 'test'), path = require('path'), rootPath = path.normalize(__dirname + '/..'), test = (env === 'test') ? '-test' : '';
|
|
79
|
+
const loadConfig = (direnames) => {
|
|
80
|
+
for (let from of direnames) {
|
|
81
|
+
let cfg = from + '/config-' + env + '.js';
|
|
82
|
+
console.log('----- ', cfg);
|
|
83
|
+
if (fs.existsSync(cfg)) {
|
|
84
|
+
return cfg;
|
|
85
|
+
}
|
|
86
|
+
cfg = from + '/config-developpement.js';
|
|
87
|
+
if (fs.existsSync(cfg)) {
|
|
88
|
+
return cfg;
|
|
89
|
+
}
|
|
90
|
+
cfg = from + '/config-production.js';
|
|
91
|
+
if (fs.existsSync(cfg)) {
|
|
92
|
+
return cfg;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
let cfg = loadConfig([__dirname, __dirname + '/..', __dirname + '/.']);
|
|
97
|
+
if (!cfg) {
|
|
98
|
+
throw "Config file is mandatory!";
|
|
99
|
+
}
|
|
100
|
+
const config = require(cfg);
|
|
101
|
+
console.log(' load configuration for payment module using: ', cfg);
|
|
102
|
+
exports.$config = Config.configure(config.wallet || config.payment);
|
|
103
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../lib/config.ts"],"names":[],"mappings":";;;AAKA,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAGzB,MAAqB,MAAM;IAczB,YAAoB,IAAI;QAXhB,UAAK,GAAS,KAAK,CAAC;QAY1B,IAAI,CAAC,cAAc,GAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,sBAAsB,GAAG,KAAK,CAAC;QAEpC,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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AEzB,IAAG,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAC;YACpB,OAAO,GAAG,CAAC;SACZ;QACD,GAAG,GAAG,IAAI,GAAC,0BAA0B,CAAC;QACtC,IAAG,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAC;YACpB,OAAO,GAAG,CAAC;SACZ;QAED,GAAG,GAAG,IAAI,GAAC,uBAAuB,CAAC;QACnC,IAAG,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAC;YACpB,OAAO,GAAG,CAAC;SACZ;KACF;AAEH,CAAC,CAAA;AACD,IAAI,GAAG,GAAG,UAAU,CAAC,CAAC,SAAS,EAAC,SAAS,GAAC,KAAK,EAAC,SAAS,GAAC,IAAI,CAAC,CAAC,CAAC;AACjE,IAAG,CAAC,GAAG,EAAE;IACP,MAAM,2BAA2B,CAAA;CAClC;AAID,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;AAC5B,OAAO,CAAC,GAAG,CAAC,gDAAgD,EAAC,GAAG,CAAC,CAAC;AACrD,QAAA,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,IAAE,MAAM,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import Stripe from 'stripe';
|
|
2
|
+
import { Customer } from './customer';
|
|
3
|
+
import { Address, Card } 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 Address {
|
|
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: Card): Promise<this>;
|
|
71
|
+
static create(customer: Customer, card: Card, 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
|
+
}
|