@foxtware/mineral 0.1.8 → 0.1.10
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/.creds.yml.sample +43 -1
- package/AGENTS.md +6 -1
- package/README.md +1 -1
- package/api/bleckmann/.gitkeep +0 -0
- package/api/bleckmann/bleckmann.constants.js +8 -0
- package/api/bleckmann/bleckmann.utils.js +32 -0
- package/api/bleckmann/bleckmannAsnGet.js +52 -0
- package/api/bleckmann/bleckmannAsnsGet.js +65 -0
- package/api/constants.js +2 -1
- package/api/github/github.constants.js +11 -0
- package/api/github/github.utils.js +65 -0
- package/api/github/githubGet.js +144 -0
- package/api/github/githubIssueCreate.js +71 -0
- package/api/github/githubIssueGet.js +65 -0
- package/api/github/githubIssueUpdate.js +71 -0
- package/api/github/githubIssuesGet.js +74 -0
- package/api/github/githubPullRequestCreate.js +74 -0
- package/api/github/githubPullRequestGet.js +65 -0
- package/api/github/githubPullRequestMerge.js +77 -0
- package/api/github/githubPullRequestUpdate.js +72 -0
- package/api/github/githubPullRequestsGet.js +74 -0
- package/api/github/githubRepoCreate.js +80 -0
- package/api/github/githubRepoDelete.js +60 -0
- package/api/github/githubRepoGet.js +61 -0
- package/api/github/githubRepoUpdate.js +68 -0
- package/api/github/githubReposGet.js +69 -0
- package/api/github/githubUserGet.js +64 -0
- package/api/linear/linear.utils.js +9 -14
- package/api/linear/linearIssuesGet.js +9 -9
- package/api/logiwa/logiwa.utils.js +27 -25
- package/api/logiwa/logiwaInventoriesGet.js +5 -3
- package/api/logiwa/logiwaOrderGet.js +4 -2
- package/api/logiwa/logiwaOrdersGet.js +5 -3
- package/api/logiwa/logiwaProductGet.js +4 -2
- package/api/logiwa/logiwaProductsGet.js +5 -3
- package/api/logiwa/logiwaReportGetAvailableToPromise.js +5 -3
- package/api/logiwa/logiwaReportGetInventoryCalculation.js +5 -3
- package/api/logiwa/logiwaReportGetInventorySnapshot.js +5 -3
- package/api/logiwa/logiwaReportGetTotalInventory.js +5 -3
- package/api/logiwa/logiwaWebhookStatusGet.js +4 -2
- package/api/logiwa/logiwaWebhookSubscribe.js +8 -6
- package/api/logiwa/logiwaWebhookUnsubscribe.js +4 -2
- package/api/logiwa/logiwaWebhooksGet.js +4 -2
- package/api/loop/loop.constants.js +7 -0
- package/api/loop/loop.utils.js +37 -0
- package/api/loop/loopAllowlistItemsGet.js +42 -0
- package/api/loop/loopBlocklistItemsGet.js +46 -0
- package/api/loop/loopDestinationsGet.js +42 -0
- package/api/loop/loopGet.js +139 -0
- package/api/loop/loopReturnGet.js +73 -0
- package/api/loop/loopReturnsGet.js +46 -0
- package/api/peoplevox/peoplevox.constants.js +1 -1
- package/api/peoplevox/peoplevox.sessions.js +54 -0
- package/api/peoplevox/peoplevox.utils.js +67 -31
- package/api/peoplevox/peoplevoxGetSingle.js +7 -5
- package/api/peoplevox/peoplevoxOrderEdit.js +7 -5
- package/api/peoplevox/peoplevoxReportGet.js +11 -9
- package/api/pipelineSteps.js +49 -0
- package/api/shopify/shopify.utils.js +18 -24
- package/api/shopify/shopifyBulkMutationDo.js +211 -0
- package/api/shopify/shopifyBulkOperationGet.js +86 -0
- package/api/shopify/shopifyBulkOperationRunMutation.js +83 -0
- package/api/shopify/shopifyCheckoutAndAccountsConfigurationUpdate.js +79 -0
- package/api/shopify/shopifyCollectionGet.js +7 -7
- package/api/shopify/shopifyCustomerGet.js +6 -6
- package/api/shopify/shopifyGet.js +18 -13
- package/api/shopify/shopifyGetSingle.js +9 -9
- package/api/shopify/shopifyMutationDo.js +6 -6
- package/api/shopify/shopifyOrdersGet.js +11 -11
- package/api/shopify/shopifyStagedUploadCreate.js +96 -0
- package/api/shopify/shopifyTagsAdd.js +1 -1
- package/api/shopify/shopifyTagsAddBulk.js +90 -0
- package/api/shopify/shopifyTagsRemove.js +1 -1
- package/api/slack/slack.utils.js +10 -19
- package/api/slack/slackMessagePost.js +11 -11
- package/api/starshipit/starshipit.constants.js +8 -0
- package/api/starshipit/starshipit.utils.js +71 -0
- package/api/starshipit/starshipitAddressCreate.js +77 -0
- package/api/starshipit/starshipitAddressDelete.js +55 -0
- package/api/starshipit/starshipitAddressUpdate.js +69 -0
- package/api/starshipit/starshipitAddressesGet.js +52 -0
- package/api/starshipit/starshipitGet.js +146 -0
- package/api/starshipit/starshipitOrderDelete.js +102 -0
- package/api/starshipit/starshipitOrderGet.js +74 -0
- package/api/starshipit/starshipitOrderUpdate.js +109 -0
- package/api/starshipit/starshipitOrdersListShipped.js +64 -0
- package/api/starshipit/starshipitProductAdd.js +100 -0
- package/api/starshipit/starshipitProductsDelete.js +57 -0
- package/api/starshipit/starshipitProductsGet.js +49 -0
- package/api/starshipit/starshipitTrackingGet.js +69 -0
- package/api/stripe/_example.js +48 -0
- package/api/stripe/stripe.constants.js +5 -0
- package/api/stripe/stripe.utils.js +42 -0
- package/api/stripe/stripeCardCharge.js +98 -0
- package/api/stripe/stripeCardTokenCreate.js +70 -0
- package/api/stripe/stripeChargeCapture.js +63 -0
- package/api/stripe/stripeChargeCreate.js +70 -0
- package/api/stripe/stripeChargeGet.js +51 -0
- package/api/stripe/stripeChargesGet.js +52 -0
- package/api/stripe/stripeRefundCreate.js +64 -0
- package/api/stripe/stripeRefundGet.js +51 -0
- package/api/stripe/stripeRefundsGet.js +52 -0
- package/api/stripe/stripeTokenGet.js +51 -0
- package/api/stylearcade/stylearcade.constants.js +5 -0
- package/api/stylearcade/stylearcade.utils.js +40 -0
- package/api/stylearcade/stylearcadeDataGet.js +62 -0
- package/api/stylearcade/stylearcadeGet.js +133 -0
- package/api/stylearcade/stylearcadeMetadataGet.js +47 -0
- package/api/supabase/supabase.utils.js +52 -0
- package/api/supabase/supabaseRowDelete.js +95 -0
- package/api/supabase/supabaseRowGet.js +58 -0
- package/api/supabase/supabaseRowInsert.js +56 -0
- package/api/supabase/supabaseRowUpdate.js +58 -0
- package/api/supabase/supabaseRpc.js +61 -0
- package/api/supabase/supabaseTableGet.js +44 -0
- package/api/supabase/supabaseTableGetAll.js +86 -0
- package/api/threeclicks/threeclicks.constants.js +8 -0
- package/api/threeclicks/threeclicks.utils.js +119 -0
- package/api/threeclicks/threeclicksCollectionsGet.js +40 -0
- package/api/threeclicks/threeclicksGet.js +138 -0
- package/api/threeclicks/threeclicksKeycodeCreate.js +55 -0
- package/api/threeclicks/threeclicksKeycodeGet.js +47 -0
- package/api/threeclicks/threeclicksPurchaseOrderCreate.js +34 -0
- package/api/threeclicks/threeclicksPurchaseOrderCreateBulk.js +34 -0
- package/api/threeclicks/threeclicksPurchaseOrderGet.js +33 -0
- package/api/threeclicks/threeclicksPurchaseOrderQuantitiesGet.js +33 -0
- package/api/threeclicks/threeclicksPurchaseOrderQuantityCreate.js +34 -0
- package/api/threeclicks/threeclicksPurchaseOrderQuantityCreateBulk.js +34 -0
- package/api/threeclicks/threeclicksPurchaseOrderQuantityUpdate.js +46 -0
- package/api/threeclicks/threeclicksPurchaseOrderQuantityUpdateBulk.js +46 -0
- package/api/threeclicks/threeclicksPurchaseOrderUpdate.js +35 -0
- package/api/threeclicks/threeclicksPurchaseOrdersGet.js +30 -0
- package/api/threeclicks/threeclicksShipmentCreate.js +34 -0
- package/api/threeclicks/threeclicksShipmentGet.js +33 -0
- package/api/threeclicks/threeclicksShipmentOrderAdd.js +38 -0
- package/api/threeclicks/threeclicksShipmentOrderQuantityCreate.js +35 -0
- package/api/threeclicks/threeclicksShipmentQuantityUpdate.js +35 -0
- package/api/threeclicks/threeclicksShipmentStatusUpdate.js +45 -0
- package/api/threeclicks/threeclicksShipmentsGet.js +52 -0
- package/api/threeclicks/threeclicksSignatureCalculate.js +73 -0
- package/api/threeclicks/threeclicksStyleCodesGet.js +46 -0
- package/api/threeclicks/threeclicksStyleColourCreate.js +47 -0
- package/api/threeclicks/threeclicksStyleColourDelete.js +34 -0
- package/api/threeclicks/threeclicksStyleCreate.js +44 -0
- package/api/threeclicks/threeclicksStyleDelete.js +33 -0
- package/api/threeclicks/threeclicksStyleGet.js +43 -0
- package/api/threeclicks/threeclicksStylePriceUpdate.js +70 -0
- package/api/threeclicks/threeclicksStyleUpdate.js +47 -0
- package/api/threeclicks/threeclicksStylesGet.js +45 -0
- package/api/upstash/upstash.utils.js +36 -0
- package/api/upstash/upstashDel.js +46 -0
- package/api/upstash/upstashExists.js +46 -0
- package/api/upstash/upstashGet.js +46 -0
- package/api/upstash/upstashSet.js +64 -0
- package/api/utils.js +90 -76
- package/api/validators.js +1 -1
- package/api/workable/workable.constants.js +3 -0
- package/api/workable/workable.utils.js +41 -0
- package/api/workable/workableGet.js +151 -0
- package/api/workable/workableJobCandidateCreate.js +87 -0
- package/api/workable/workableJobGet.js +52 -0
- package/api/workable/workableJobMembersGet.js +52 -0
- package/api/workable/workableJobStagesGet.js +52 -0
- package/api/workable/workableJobsGet.js +78 -0
- package/api/yotpo/yotpo.utils.js +17 -22
- package/api/yotpo/yotpoCampaignsGet.js +6 -6
- package/api/yotpo/yotpoCustomerActionRecord.js +7 -7
- package/api/yotpo/yotpoCustomerAnniversaryGet.js +7 -7
- package/api/yotpo/yotpoCustomerAnniversarySet.js +7 -7
- package/api/yotpo/yotpoCustomerBirthdaySet.js +7 -7
- package/api/yotpo/yotpoCustomerGet.js +6 -6
- package/api/yotpo/yotpoCustomerPointsAdjust.js +7 -7
- package/api/yotpo/yotpoCustomerUpsert.js +7 -7
- package/api/yotpo/yotpoCustomersRecentGet.js +6 -6
- package/api/yotpo/yotpoRedemptionCreate.js +7 -7
- package/api/yotpo/yotpoRedemptionOptionsGet.js +6 -6
- package/api/yotpo/yotpoVipTiersGet.js +5 -5
- package/api/youtube/youtube.constants.js +5 -0
- package/api/youtube/youtube.utils.js +77 -0
- package/api/youtube/youtubeChannelVideosGet.js +25 -70
- package/hosting/.hosting.yml.sample +9 -11
- package/hosting/copyCredsToEnv.js +58 -2
- package/hosting/deployFromHostingYml.js +9 -2
- package/hosting/hosting.utils.js +3 -2
- package/package.json +3 -1
- package/server.utils.js +1 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// https://api-docs.starshipit.com/#05a846b9-0128-4dd3-80e4-e6008aef9b94
|
|
2
|
+
|
|
3
|
+
const { objHasAny, ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { starshipitClient } = require('../starshipit/starshipit.utils');
|
|
6
|
+
|
|
7
|
+
const trackingIdentifierValidator = (trackingIdentifier) => {
|
|
8
|
+
return objHasAny(trackingIdentifier, [
|
|
9
|
+
'trackingNumber',
|
|
10
|
+
'orderNumber',
|
|
11
|
+
]);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const argsWarden = new ArgsWarden([
|
|
15
|
+
['credsPayload', credsValidator],
|
|
16
|
+
['trackingIdentifier', trackingIdentifierValidator],
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
const starshipitTrackingGet = async (
|
|
20
|
+
credsPayload,
|
|
21
|
+
trackingIdentifier,
|
|
22
|
+
) => {
|
|
23
|
+
|
|
24
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
25
|
+
credsPayload,
|
|
26
|
+
trackingIdentifier,
|
|
27
|
+
});
|
|
28
|
+
if (rejectResponse) {
|
|
29
|
+
return rejectResponse;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const {
|
|
33
|
+
trackingNumber,
|
|
34
|
+
orderNumber,
|
|
35
|
+
} = trackingIdentifier;
|
|
36
|
+
|
|
37
|
+
const response = await starshipitClient.fetch({
|
|
38
|
+
requestPayload: {
|
|
39
|
+
url: '/track',
|
|
40
|
+
params: {
|
|
41
|
+
...trackingNumber && { tracking_number: trackingNumber },
|
|
42
|
+
...orderNumber && { order_number: orderNumber },
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
context: {
|
|
46
|
+
credsPayload,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
return response;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const funcApiConfig = {
|
|
54
|
+
argsWarden,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
module.exports = {
|
|
58
|
+
starshipitTrackingGet,
|
|
59
|
+
funcApiConfig,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/*
|
|
63
|
+
curl -X POST "http://localhost:8000/starshipitTrackingGet" \
|
|
64
|
+
-H "Content-Type: application/json" \
|
|
65
|
+
-d '{
|
|
66
|
+
"credsPayload": { "credsPath": "starshipit.wf" },
|
|
67
|
+
"trackingIdentifier": { "orderNumber": "7726760919112" }
|
|
68
|
+
}'
|
|
69
|
+
*/
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const { ArgsWarden } = require('../utils');
|
|
2
|
+
const { credsValidator } = require('../validators');
|
|
3
|
+
const { stripeClient } = require('../stripe/stripe.utils');
|
|
4
|
+
|
|
5
|
+
const argsWarden = new ArgsWarden([
|
|
6
|
+
['credsPayload', credsValidator],
|
|
7
|
+
['arg'],
|
|
8
|
+
]);
|
|
9
|
+
|
|
10
|
+
const FUNC = async (
|
|
11
|
+
credsPayload,
|
|
12
|
+
arg,
|
|
13
|
+
) => {
|
|
14
|
+
|
|
15
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload, arg });
|
|
16
|
+
if (rejectResponse) {
|
|
17
|
+
return rejectResponse;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const response = await stripeClient.fetch({
|
|
21
|
+
requestPayload: {
|
|
22
|
+
url: '/things',
|
|
23
|
+
method: 'post',
|
|
24
|
+
body: { arg },
|
|
25
|
+
},
|
|
26
|
+
context: { credsPayload },
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return response;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const funcApiConfig = {
|
|
33
|
+
argsWarden,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
module.exports = {
|
|
37
|
+
FUNC,
|
|
38
|
+
funcApiConfig,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/*
|
|
42
|
+
curl -X POST "http://localhost:8000/FUNC" \
|
|
43
|
+
-H "Content-Type: application/json" \
|
|
44
|
+
-d '{
|
|
45
|
+
"credsPayload": { "credsPath": "stripe" },
|
|
46
|
+
"arg": "1234"
|
|
47
|
+
}'
|
|
48
|
+
*/
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const { BASE_URL } = require('../stripe/stripe.constants');
|
|
2
|
+
const { resolveCreds, useBaseUrl } = require('../pipelineSteps');
|
|
3
|
+
const {
|
|
4
|
+
FetchClient,
|
|
5
|
+
fetchClientCommonSteps,
|
|
6
|
+
} = require('../utils');
|
|
7
|
+
|
|
8
|
+
const useAuthHeaders = async (state) => {
|
|
9
|
+
const { requestPayload, context } = state;
|
|
10
|
+
const { creds } = context;
|
|
11
|
+
const { API_KEY } = creds;
|
|
12
|
+
|
|
13
|
+
const body = requestPayload.body
|
|
14
|
+
? new URLSearchParams(requestPayload.body).toString()
|
|
15
|
+
: undefined;
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
requestPayload: {
|
|
19
|
+
...requestPayload,
|
|
20
|
+
headers: {
|
|
21
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
22
|
+
Authorization: `Bearer ${ API_KEY }`,
|
|
23
|
+
...requestPayload.headers,
|
|
24
|
+
},
|
|
25
|
+
...(body && { body }),
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const stripeClient = new FetchClient({
|
|
31
|
+
pipeline: [
|
|
32
|
+
resolveCreds,
|
|
33
|
+
useBaseUrl(BASE_URL),
|
|
34
|
+
useAuthHeaders,
|
|
35
|
+
'fetch',
|
|
36
|
+
fetchClientCommonSteps.exitEarlyOnNotOk,
|
|
37
|
+
],
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
module.exports = {
|
|
41
|
+
stripeClient,
|
|
42
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
const { ArgsWarden } = require('../utils');
|
|
2
|
+
const { credsValidator } = require('../validators');
|
|
3
|
+
const { stripeCardTokenCreate } = require('../stripe/stripeCardTokenCreate');
|
|
4
|
+
const { stripeChargeCreate } = require('../stripe/stripeChargeCreate');
|
|
5
|
+
|
|
6
|
+
const argsWarden = new ArgsWarden([
|
|
7
|
+
['credsPayload', credsValidator],
|
|
8
|
+
['cardNumber'],
|
|
9
|
+
['expiryMonth'],
|
|
10
|
+
['expiryYear'],
|
|
11
|
+
['cvc'],
|
|
12
|
+
['amountCents'],
|
|
13
|
+
['currency'],
|
|
14
|
+
['description'],
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
const stripeCardCharge = async (
|
|
18
|
+
credsPayload,
|
|
19
|
+
cardNumber,
|
|
20
|
+
expiryMonth,
|
|
21
|
+
expiryYear,
|
|
22
|
+
cvc,
|
|
23
|
+
amountCents,
|
|
24
|
+
currency,
|
|
25
|
+
description,
|
|
26
|
+
) => {
|
|
27
|
+
|
|
28
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
29
|
+
credsPayload,
|
|
30
|
+
cardNumber,
|
|
31
|
+
expiryMonth,
|
|
32
|
+
expiryYear,
|
|
33
|
+
cvc,
|
|
34
|
+
amountCents,
|
|
35
|
+
currency,
|
|
36
|
+
description,
|
|
37
|
+
});
|
|
38
|
+
if (rejectResponse) {
|
|
39
|
+
return rejectResponse;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const cardTokenResponse = await stripeCardTokenCreate(
|
|
43
|
+
credsPayload,
|
|
44
|
+
cardNumber,
|
|
45
|
+
expiryMonth,
|
|
46
|
+
expiryYear,
|
|
47
|
+
cvc,
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
if (!cardTokenResponse?.ok) {
|
|
51
|
+
return cardTokenResponse;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const cardToken = cardTokenResponse?.data?.id;
|
|
55
|
+
|
|
56
|
+
if (!cardToken) {
|
|
57
|
+
return {
|
|
58
|
+
ok: false,
|
|
59
|
+
error: {
|
|
60
|
+
message: 'Failed to create card token',
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const chargeResponse = await stripeChargeCreate(
|
|
66
|
+
credsPayload,
|
|
67
|
+
amountCents,
|
|
68
|
+
currency,
|
|
69
|
+
cardToken,
|
|
70
|
+
description,
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
return chargeResponse;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const funcApiConfig = {
|
|
77
|
+
argsWarden,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
module.exports = {
|
|
81
|
+
stripeCardCharge,
|
|
82
|
+
funcApiConfig,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/*
|
|
86
|
+
curl -X POST "http://localhost:8000/stripeCardCharge" \
|
|
87
|
+
-H "Content-Type: application/json" \
|
|
88
|
+
-d '{
|
|
89
|
+
"credsPayload": { "credsPath": "stripe" },
|
|
90
|
+
"cardNumber": "4242424242424242",
|
|
91
|
+
"expiryMonth": "01",
|
|
92
|
+
"expiryYear": "2026",
|
|
93
|
+
"cvc": "123",
|
|
94
|
+
"currency": "AUD",
|
|
95
|
+
"description": "Transaction helper",
|
|
96
|
+
"amountCents": "50"
|
|
97
|
+
}'
|
|
98
|
+
*/
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// https://docs.stripe.com/api/tokens/create_card
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { stripeClient } = require('../stripe/stripe.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['cardNumber'],
|
|
10
|
+
['expiryMonth'],
|
|
11
|
+
['expiryYear'],
|
|
12
|
+
['cvc'],
|
|
13
|
+
]);
|
|
14
|
+
|
|
15
|
+
const stripeCardTokenCreate = async (
|
|
16
|
+
credsPayload,
|
|
17
|
+
cardNumber,
|
|
18
|
+
expiryMonth,
|
|
19
|
+
expiryYear,
|
|
20
|
+
cvc,
|
|
21
|
+
) => {
|
|
22
|
+
|
|
23
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
24
|
+
credsPayload,
|
|
25
|
+
cardNumber,
|
|
26
|
+
expiryMonth,
|
|
27
|
+
expiryYear,
|
|
28
|
+
cvc,
|
|
29
|
+
});
|
|
30
|
+
if (rejectResponse) {
|
|
31
|
+
return rejectResponse;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const response = await stripeClient.fetch({
|
|
35
|
+
requestPayload: {
|
|
36
|
+
url: '/tokens',
|
|
37
|
+
method: 'post',
|
|
38
|
+
body: {
|
|
39
|
+
'card[number]': cardNumber,
|
|
40
|
+
'card[exp_month]': expiryMonth,
|
|
41
|
+
'card[exp_year]': expiryYear,
|
|
42
|
+
'card[cvc]': cvc,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
context: { credsPayload },
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return response;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const funcApiConfig = {
|
|
52
|
+
argsWarden,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
module.exports = {
|
|
56
|
+
stripeCardTokenCreate,
|
|
57
|
+
funcApiConfig,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/*
|
|
61
|
+
curl -X POST "http://localhost:8000/stripeCardTokenCreate" \
|
|
62
|
+
-H "Content-Type: application/json" \
|
|
63
|
+
-d '{
|
|
64
|
+
"credsPayload": { "credsPath": "stripe" },
|
|
65
|
+
"cardNumber": "4242424242424242",
|
|
66
|
+
"expiryMonth": "01",
|
|
67
|
+
"expiryYear": "2030",
|
|
68
|
+
"cvc": "123"
|
|
69
|
+
}'
|
|
70
|
+
*/
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// https://docs.stripe.com/api/charges/capture
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { stripeClient } = require('../stripe/stripe.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['chargeId'],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const stripeChargeCapture = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
chargeId,
|
|
15
|
+
{
|
|
16
|
+
amountCents,
|
|
17
|
+
} = {},
|
|
18
|
+
) => {
|
|
19
|
+
|
|
20
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
21
|
+
credsPayload,
|
|
22
|
+
chargeId,
|
|
23
|
+
});
|
|
24
|
+
if (rejectResponse) {
|
|
25
|
+
return rejectResponse;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const response = await stripeClient.fetch({
|
|
29
|
+
requestPayload: {
|
|
30
|
+
url: `/charges/${ chargeId }/capture`,
|
|
31
|
+
method: 'post',
|
|
32
|
+
...(amountCents && {
|
|
33
|
+
body: {
|
|
34
|
+
amount: amountCents,
|
|
35
|
+
},
|
|
36
|
+
}),
|
|
37
|
+
},
|
|
38
|
+
context: { credsPayload },
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return response;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const funcApiConfig = {
|
|
45
|
+
argsWarden,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
module.exports = {
|
|
49
|
+
stripeChargeCapture,
|
|
50
|
+
funcApiConfig,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/*
|
|
54
|
+
curl -X POST "http://localhost:8000/stripeChargeCapture" \
|
|
55
|
+
-H "Content-Type: application/json" \
|
|
56
|
+
-d '{
|
|
57
|
+
"credsPayload": { "credsPath": "stripe" },
|
|
58
|
+
"chargeId": "ch_123",
|
|
59
|
+
"options": {
|
|
60
|
+
"amountCents": "100"
|
|
61
|
+
}
|
|
62
|
+
}'
|
|
63
|
+
*/
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// https://docs.stripe.com/api/charges/create
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { stripeClient } = require('../stripe/stripe.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['amountCents'],
|
|
10
|
+
['currency'],
|
|
11
|
+
['source'],
|
|
12
|
+
['description'],
|
|
13
|
+
]);
|
|
14
|
+
|
|
15
|
+
const stripeChargeCreate = async (
|
|
16
|
+
credsPayload,
|
|
17
|
+
amountCents,
|
|
18
|
+
currency,
|
|
19
|
+
source,
|
|
20
|
+
description,
|
|
21
|
+
) => {
|
|
22
|
+
|
|
23
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
24
|
+
credsPayload,
|
|
25
|
+
amountCents,
|
|
26
|
+
currency,
|
|
27
|
+
source,
|
|
28
|
+
description,
|
|
29
|
+
});
|
|
30
|
+
if (rejectResponse) {
|
|
31
|
+
return rejectResponse;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const response = await stripeClient.fetch({
|
|
35
|
+
requestPayload: {
|
|
36
|
+
url: '/charges',
|
|
37
|
+
method: 'post',
|
|
38
|
+
body: {
|
|
39
|
+
amount: amountCents,
|
|
40
|
+
currency,
|
|
41
|
+
source,
|
|
42
|
+
description,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
context: { credsPayload },
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return response;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const funcApiConfig = {
|
|
52
|
+
argsWarden,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
module.exports = {
|
|
56
|
+
stripeChargeCreate,
|
|
57
|
+
funcApiConfig,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/*
|
|
61
|
+
curl -X POST "http://localhost:8000/stripeChargeCreate" \
|
|
62
|
+
-H "Content-Type: application/json" \
|
|
63
|
+
-d '{
|
|
64
|
+
"credsPayload": { "credsPath": "stripe" },
|
|
65
|
+
"amountCents": "100",
|
|
66
|
+
"currency": "AUD",
|
|
67
|
+
"source": "tok_visa",
|
|
68
|
+
"description": "small charge"
|
|
69
|
+
}'
|
|
70
|
+
*/
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// https://docs.stripe.com/api/charges/retrieve
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { stripeClient } = require('../stripe/stripe.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['chargeId'],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const stripeChargeGet = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
chargeId,
|
|
15
|
+
) => {
|
|
16
|
+
|
|
17
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
18
|
+
credsPayload,
|
|
19
|
+
chargeId,
|
|
20
|
+
});
|
|
21
|
+
if (rejectResponse) {
|
|
22
|
+
return rejectResponse;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const response = await stripeClient.fetch({
|
|
26
|
+
requestPayload: {
|
|
27
|
+
url: `/charges/${ chargeId }`,
|
|
28
|
+
},
|
|
29
|
+
context: { credsPayload },
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return response;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const funcApiConfig = {
|
|
36
|
+
argsWarden,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
module.exports = {
|
|
40
|
+
stripeChargeGet,
|
|
41
|
+
funcApiConfig,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/*
|
|
45
|
+
curl -X POST "http://localhost:8000/stripeChargeGet" \
|
|
46
|
+
-H "Content-Type: application/json" \
|
|
47
|
+
-d '{
|
|
48
|
+
"credsPayload": { "credsPath": "stripe" },
|
|
49
|
+
"chargeId": "ch_123"
|
|
50
|
+
}'
|
|
51
|
+
*/
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// https://docs.stripe.com/api/charges/list
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { stripeClient } = require('../stripe/stripe.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
const stripeChargesGet = async (
|
|
12
|
+
credsPayload,
|
|
13
|
+
{
|
|
14
|
+
params,
|
|
15
|
+
} = {},
|
|
16
|
+
) => {
|
|
17
|
+
|
|
18
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
|
|
19
|
+
if (rejectResponse) {
|
|
20
|
+
return rejectResponse;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const response = await stripeClient.fetch({
|
|
24
|
+
requestPayload: {
|
|
25
|
+
url: '/charges',
|
|
26
|
+
params,
|
|
27
|
+
},
|
|
28
|
+
context: { credsPayload },
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
return response;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const funcApiConfig = {
|
|
35
|
+
argsWarden,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
module.exports = {
|
|
39
|
+
stripeChargesGet,
|
|
40
|
+
funcApiConfig,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/*
|
|
44
|
+
curl -X POST "http://localhost:8000/stripeChargesGet" \
|
|
45
|
+
-H "Content-Type: application/json" \
|
|
46
|
+
-d '{
|
|
47
|
+
"credsPayload": { "credsPath": "stripe" },
|
|
48
|
+
"options": {
|
|
49
|
+
"params": { "limit": 10 }
|
|
50
|
+
}
|
|
51
|
+
}'
|
|
52
|
+
*/
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// https://docs.stripe.com/api/refunds/create
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { stripeClient } = require('../stripe/stripe.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['chargeId'],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const stripeRefundCreate = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
chargeId,
|
|
15
|
+
{
|
|
16
|
+
amountCents,
|
|
17
|
+
reason,
|
|
18
|
+
} = {},
|
|
19
|
+
) => {
|
|
20
|
+
|
|
21
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
22
|
+
credsPayload,
|
|
23
|
+
chargeId,
|
|
24
|
+
});
|
|
25
|
+
if (rejectResponse) {
|
|
26
|
+
return rejectResponse;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const response = await stripeClient.fetch({
|
|
30
|
+
requestPayload: {
|
|
31
|
+
url: '/refunds',
|
|
32
|
+
method: 'post',
|
|
33
|
+
body: {
|
|
34
|
+
charge: chargeId,
|
|
35
|
+
...amountCents && { amount: amountCents },
|
|
36
|
+
...reason && { reason },
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
context: { credsPayload },
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return response;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const funcApiConfig = {
|
|
46
|
+
argsWarden,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
module.exports = {
|
|
50
|
+
stripeRefundCreate,
|
|
51
|
+
funcApiConfig,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/*
|
|
55
|
+
curl -X POST "http://localhost:8000/stripeRefundCreate" \
|
|
56
|
+
-H "Content-Type: application/json" \
|
|
57
|
+
-d '{
|
|
58
|
+
"credsPayload": { "credsPath": "stripe" },
|
|
59
|
+
"chargeId": "ch_123",
|
|
60
|
+
"options": {
|
|
61
|
+
"amountCents": "100"
|
|
62
|
+
}
|
|
63
|
+
}'
|
|
64
|
+
*/
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// https://docs.stripe.com/api/refunds/retrieve
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { stripeClient } = require('../stripe/stripe.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['refundId'],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const stripeRefundGet = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
refundId,
|
|
15
|
+
) => {
|
|
16
|
+
|
|
17
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
18
|
+
credsPayload,
|
|
19
|
+
refundId,
|
|
20
|
+
});
|
|
21
|
+
if (rejectResponse) {
|
|
22
|
+
return rejectResponse;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const response = await stripeClient.fetch({
|
|
26
|
+
requestPayload: {
|
|
27
|
+
url: `/refunds/${ refundId }`,
|
|
28
|
+
},
|
|
29
|
+
context: { credsPayload },
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return response;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const funcApiConfig = {
|
|
36
|
+
argsWarden,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
module.exports = {
|
|
40
|
+
stripeRefundGet,
|
|
41
|
+
funcApiConfig,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/*
|
|
45
|
+
curl -X POST "http://localhost:8000/stripeRefundGet" \
|
|
46
|
+
-H "Content-Type: application/json" \
|
|
47
|
+
-d '{
|
|
48
|
+
"credsPayload": { "credsPath": "stripe" },
|
|
49
|
+
"refundId": "re_123"
|
|
50
|
+
}'
|
|
51
|
+
*/
|