@funkit/api-base 0.0.5 → 0.0.6
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/CHANGELOG.md +6 -0
- package/dist/src/services/index.d.ts +1 -0
- package/dist/src/services/index.js +1 -0
- package/dist/src/services/index.js.map +1 -1
- package/dist/src/services/stripe/endpoints.d.ts +7 -0
- package/dist/src/services/stripe/endpoints.js +58 -0
- package/dist/src/services/stripe/endpoints.js.map +1 -0
- package/dist/src/services/stripe/index.d.ts +2 -0
- package/dist/src/services/stripe/index.js +19 -0
- package/dist/src/services/stripe/index.js.map +1 -0
- package/dist/src/services/stripe/types.d.ts +46 -0
- package/dist/src/services/stripe/types.js +3 -0
- package/dist/src/services/stripe/types.js.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -19,6 +19,7 @@ __exportStar(require("./checkout"), exports);
|
|
|
19
19
|
__exportStar(require("./faucet"), exports);
|
|
20
20
|
__exportStar(require("./mesh"), exports);
|
|
21
21
|
__exportStar(require("./moonpay"), exports);
|
|
22
|
+
__exportStar(require("./stripe"), exports);
|
|
22
23
|
__exportStar(require("./support"), exports);
|
|
23
24
|
__exportStar(require("./turnkey"), exports);
|
|
24
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,6CAA0B;AAC1B,2CAAwB;AACxB,yCAAsB;AACtB,4CAAyB;AACzB,4CAAyB;AACzB,4CAAyB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,6CAA0B;AAC1B,2CAAwB;AACxB,yCAAsB;AACtB,4CAAyB;AACzB,2CAAwB;AACxB,4CAAyB;AACzB,4CAAyB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CreateStripeBuySessionBody, CreateStripeBuySessionResponse, GetStripeBuyQuoteRequest, GetStripeBuyQuoteResponse } from './types';
|
|
2
|
+
export declare function getStripeBuyQuote({ sourceCurrency, destinationAmount, destinationCurrency, destinationNetwork, isSandbox, apiKey, }: GetStripeBuyQuoteRequest): Promise<GetStripeBuyQuoteResponse>;
|
|
3
|
+
export declare function createStripeBuySession({ sourceCurrency, destinationAmount, destinationCurrency, destinationNetwork, walletAddress, customerIpAddress, isSandbox, apiKey, }: CreateStripeBuySessionBody): Promise<CreateStripeBuySessionResponse>;
|
|
4
|
+
export declare function getStripeBuySession({ sessionId, apiKey, }: {
|
|
5
|
+
sessionId: string;
|
|
6
|
+
apiKey: string;
|
|
7
|
+
}): Promise<CreateStripeBuySessionResponse>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getStripeBuyQuote = getStripeBuyQuote;
|
|
4
|
+
exports.createStripeBuySession = createStripeBuySession;
|
|
5
|
+
exports.getStripeBuySession = getStripeBuySession;
|
|
6
|
+
const consts_1 = require("../../consts");
|
|
7
|
+
const utils_1 = require("../../utils");
|
|
8
|
+
async function getStripeBuyQuote({ sourceCurrency, destinationAmount, destinationCurrency, destinationNetwork, isSandbox, apiKey, }) {
|
|
9
|
+
const params = new URLSearchParams({
|
|
10
|
+
isSandbox: isSandbox.toString(),
|
|
11
|
+
sourceCurrency,
|
|
12
|
+
destinationAmount: destinationAmount.toString(),
|
|
13
|
+
// Only allow one currency in this SDK
|
|
14
|
+
destinationCurrencies: destinationCurrency,
|
|
15
|
+
// Only allow one network in this SDK
|
|
16
|
+
destinationNetworks: destinationNetwork,
|
|
17
|
+
}).toString();
|
|
18
|
+
const buyQuoteResp = await (0, utils_1.sendGetRequest)({
|
|
19
|
+
uri: `${consts_1.API_BASE_URL}/on-ramp/stripe-buy-quote?${params}`,
|
|
20
|
+
retryOptions: { maxAttempts: 1 },
|
|
21
|
+
apiKey,
|
|
22
|
+
});
|
|
23
|
+
return buyQuoteResp;
|
|
24
|
+
}
|
|
25
|
+
async function createStripeBuySession({ sourceCurrency, destinationAmount, destinationCurrency, destinationNetwork, walletAddress, customerIpAddress, isSandbox, apiKey, }) {
|
|
26
|
+
const body = {
|
|
27
|
+
isSandbox: isSandbox.toString(),
|
|
28
|
+
sourceCurrency,
|
|
29
|
+
destinationAmount: destinationAmount.toString(),
|
|
30
|
+
// Only allow one currency in this SDK
|
|
31
|
+
destinationCurrency,
|
|
32
|
+
destinationCurrencies: [destinationCurrency],
|
|
33
|
+
// Only allow one network in this SDK
|
|
34
|
+
destinationNetwork,
|
|
35
|
+
destinationNetworks: [destinationNetwork],
|
|
36
|
+
// Only allow one wallet address in this SDK, and it must correspond to the destination network
|
|
37
|
+
walletAddresses: {
|
|
38
|
+
[destinationNetwork]: walletAddress,
|
|
39
|
+
},
|
|
40
|
+
...(customerIpAddress ? { customerIpAddress } : {}),
|
|
41
|
+
};
|
|
42
|
+
const newBuySessionResp = await (0, utils_1.sendPostRequest)({
|
|
43
|
+
uri: `${consts_1.API_BASE_URL}/on-ramp/stripe-checkout`,
|
|
44
|
+
body,
|
|
45
|
+
retryOptions: { maxAttempts: 1 },
|
|
46
|
+
apiKey,
|
|
47
|
+
});
|
|
48
|
+
return newBuySessionResp;
|
|
49
|
+
}
|
|
50
|
+
async function getStripeBuySession({ sessionId, apiKey, }) {
|
|
51
|
+
const buySessionResp = await (0, utils_1.sendGetRequest)({
|
|
52
|
+
uri: `${consts_1.API_BASE_URL}/on-ramp/stripe-checkout-session/${sessionId}`,
|
|
53
|
+
retryOptions: { maxAttempts: 1 },
|
|
54
|
+
apiKey,
|
|
55
|
+
});
|
|
56
|
+
return buySessionResp;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=endpoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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AAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACpD,CAAA;IACD,MAAM,iBAAiB,GAAG,MAAM,IAAA,uBAAe,EAAC;QAC9C,GAAG,EAAE,GAAG,qBAAY,0BAA0B;QAC9C,IAAI;QACJ,YAAY,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE;QAChC,MAAM;KACP,CAAC,CAAA;IACF,OAAO,iBAAmD,CAAA;AAC5D,CAAC;AAEM,KAAK,UAAU,mBAAmB,CAAC,EACxC,SAAS,EACT,MAAM,GAIP;IACC,MAAM,cAAc,GAAG,MAAM,IAAA,sBAAc,EAAC;QAC1C,GAAG,EAAE,GAAG,qBAAY,oCAAoC,SAAS,EAAE;QACnE,YAAY,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE;QAChC,MAAM;KACP,CAAC,CAAA;IACF,OAAO,cAAgD,CAAA;AACzD,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./endpoints"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/services/stripe/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA2B;AAC3B,0CAAuB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export interface GetStripeBuyQuoteRequest {
|
|
2
|
+
sourceCurrency: 'usd' | 'eur';
|
|
3
|
+
destinationAmount: number;
|
|
4
|
+
destinationCurrency: string;
|
|
5
|
+
destinationNetwork: string;
|
|
6
|
+
apiKey: string;
|
|
7
|
+
isSandbox: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface NetworkQuoteItem {
|
|
10
|
+
id: string;
|
|
11
|
+
destination_amount: string;
|
|
12
|
+
destination_currency: string;
|
|
13
|
+
destination_network: string;
|
|
14
|
+
fees: {
|
|
15
|
+
network_fee_monetary: string;
|
|
16
|
+
transaction_fee_monetary: string;
|
|
17
|
+
};
|
|
18
|
+
source_total_amount: string;
|
|
19
|
+
}
|
|
20
|
+
export interface GetStripeBuyQuoteResponse {
|
|
21
|
+
id: string;
|
|
22
|
+
object: string;
|
|
23
|
+
destination_network_quotes: {
|
|
24
|
+
[stripe_network: string]: null | NetworkQuoteItem[];
|
|
25
|
+
};
|
|
26
|
+
livemode: boolean;
|
|
27
|
+
rate_fetched_at: number;
|
|
28
|
+
source_amount: string;
|
|
29
|
+
source_currency: string;
|
|
30
|
+
}
|
|
31
|
+
export interface CreateStripeBuySessionBody extends GetStripeBuyQuoteRequest {
|
|
32
|
+
walletAddress: null | string;
|
|
33
|
+
customerIpAddress?: null | string;
|
|
34
|
+
}
|
|
35
|
+
export interface CreateStripeBuySessionResponse {
|
|
36
|
+
id: string;
|
|
37
|
+
object: string;
|
|
38
|
+
client_secret: string;
|
|
39
|
+
created: number;
|
|
40
|
+
kyc_details_provided: false;
|
|
41
|
+
livemode: boolean;
|
|
42
|
+
metadata: object;
|
|
43
|
+
redirect_url: string;
|
|
44
|
+
status: string;
|
|
45
|
+
transaction_details: object;
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/services/stripe/types.ts"],"names":[],"mappings":""}
|