chore: address review comments
This commit is contained in:
@@ -1,13 +1,9 @@
|
|||||||
import { IGlobalVariable } from '@automatisch/types';
|
import { IGlobalVariable } from '@automatisch/types';
|
||||||
|
|
||||||
const verifyCredentials = async ($: IGlobalVariable) => {
|
const verifyCredentials = async ($: IGlobalVariable) => {
|
||||||
try {
|
|
||||||
await $.http.get(
|
await $.http.get(
|
||||||
`/v1/events`,
|
`/v1/events`,
|
||||||
);
|
);
|
||||||
} catch (e) {
|
|
||||||
throw new Error('Invalid secret key')
|
|
||||||
}
|
|
||||||
await $.auth.set({
|
await $.auth.set({
|
||||||
screenName: $.auth.data?.displayName,
|
screenName: $.auth.data?.displayName,
|
||||||
});
|
});
|
||||||
|
@@ -1,34 +0,0 @@
|
|||||||
import {IGlobalVariable, IJSONObject} from "@automatisch/types";
|
|
||||||
import {URLSearchParams} from "url";
|
|
||||||
import {isEmpty, omitBy} from "lodash";
|
|
||||||
|
|
||||||
const getBalanceTransactions = async ($: IGlobalVariable) => {
|
|
||||||
let response;
|
|
||||||
let lastId = undefined;
|
|
||||||
|
|
||||||
do {
|
|
||||||
const params: IJSONObject = {
|
|
||||||
starting_after: lastId,
|
|
||||||
ending_before: $.flow.lastInternalId
|
|
||||||
}
|
|
||||||
const queryParams = new URLSearchParams(omitBy(params, isEmpty))
|
|
||||||
const requestPath = `/v1/balance_transactions${
|
|
||||||
queryParams.toString() ? `?${queryParams.toString()}` : ''
|
|
||||||
}`;
|
|
||||||
|
|
||||||
response = (await $.http.get(requestPath)).data
|
|
||||||
for (const entry of response.data) {
|
|
||||||
$.pushTriggerItem({
|
|
||||||
raw: entry,
|
|
||||||
meta: {
|
|
||||||
internalId: entry.id as string
|
|
||||||
}
|
|
||||||
})
|
|
||||||
lastId = entry.id
|
|
||||||
}
|
|
||||||
} while (response.has_more)
|
|
||||||
|
|
||||||
return $.triggerOutput;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default getBalanceTransactions;
|
|
@@ -1,34 +0,0 @@
|
|||||||
import {IGlobalVariable, IJSONObject} from "@automatisch/types";
|
|
||||||
import {URLSearchParams} from "url";
|
|
||||||
import {isEmpty, omitBy} from "lodash";
|
|
||||||
|
|
||||||
const getPayouts = async ($: IGlobalVariable) => {
|
|
||||||
let response;
|
|
||||||
let lastId = undefined;
|
|
||||||
|
|
||||||
do {
|
|
||||||
const params: IJSONObject = {
|
|
||||||
starting_after: lastId,
|
|
||||||
ending_before: $.flow.lastInternalId
|
|
||||||
}
|
|
||||||
const queryParams = new URLSearchParams(omitBy(params, isEmpty))
|
|
||||||
const requestPath = `/v1/payouts${
|
|
||||||
queryParams.toString() ? `?${queryParams.toString()}` : ''
|
|
||||||
}`;
|
|
||||||
|
|
||||||
response = (await $.http.get(requestPath)).data
|
|
||||||
for (const entry of response.data) {
|
|
||||||
$.pushTriggerItem({
|
|
||||||
raw: entry,
|
|
||||||
meta: {
|
|
||||||
internalId: entry.id as string
|
|
||||||
}
|
|
||||||
})
|
|
||||||
lastId = entry.id
|
|
||||||
}
|
|
||||||
} while (response.has_more)
|
|
||||||
|
|
||||||
return $.triggerOutput;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default getPayouts;
|
|
@@ -0,0 +1,32 @@
|
|||||||
|
import {IGlobalVariable, IJSONObject} from "@automatisch/types";
|
||||||
|
import {URLSearchParams} from "url";
|
||||||
|
import {isEmpty, omitBy} from "lodash";
|
||||||
|
|
||||||
|
const getBalanceTransactions = async ($: IGlobalVariable) => {
|
||||||
|
let response;
|
||||||
|
let lastId = undefined;
|
||||||
|
|
||||||
|
do {
|
||||||
|
const params: IJSONObject = {
|
||||||
|
starting_after: lastId,
|
||||||
|
ending_before: $.flow.lastInternalId
|
||||||
|
}
|
||||||
|
const queryParams = new URLSearchParams(omitBy(params, isEmpty))
|
||||||
|
const requestPath = `/v1/balance_transactions${
|
||||||
|
queryParams.toString() ? `?${queryParams.toString()}` : ''
|
||||||
|
}`;
|
||||||
|
|
||||||
|
response = (await $.http.get(requestPath)).data
|
||||||
|
for (const entry of response.data) {
|
||||||
|
$.pushTriggerItem({
|
||||||
|
raw: entry,
|
||||||
|
meta: {
|
||||||
|
internalId: entry.id as string
|
||||||
|
}
|
||||||
|
})
|
||||||
|
lastId = entry.id
|
||||||
|
}
|
||||||
|
} while (response.has_more)
|
||||||
|
};
|
||||||
|
|
||||||
|
export default getBalanceTransactions;
|
@@ -1,8 +1,8 @@
|
|||||||
import defineTrigger from "../../../../helpers/define-trigger";
|
import defineTrigger from "../../../../helpers/define-trigger";
|
||||||
import getBalanceTransactions from "../../common/get-balance-transactions";
|
import getBalanceTransactions from "./get-balance-transactions";
|
||||||
|
|
||||||
export default defineTrigger({
|
export default defineTrigger({
|
||||||
name: 'Balance Transaction',
|
name: 'New Balance Transactions',
|
||||||
key: 'balanceTransaction',
|
key: 'balanceTransaction',
|
||||||
description: 'Triggers when a new transaction is processed (refund, payout, adjustment, ...)',
|
description: 'Triggers when a new transaction is processed (refund, payout, adjustment, ...)',
|
||||||
pollInterval: 15,
|
pollInterval: 15,
|
||||||
|
@@ -0,0 +1,32 @@
|
|||||||
|
import {IGlobalVariable, IJSONObject} from "@automatisch/types";
|
||||||
|
import {URLSearchParams} from "url";
|
||||||
|
import {isEmpty, omitBy} from "lodash";
|
||||||
|
|
||||||
|
const getPayouts = async ($: IGlobalVariable) => {
|
||||||
|
let response;
|
||||||
|
let lastId = undefined;
|
||||||
|
|
||||||
|
do {
|
||||||
|
const params: IJSONObject = {
|
||||||
|
starting_after: lastId,
|
||||||
|
ending_before: $.flow.lastInternalId
|
||||||
|
}
|
||||||
|
const queryParams = new URLSearchParams(omitBy(params, isEmpty))
|
||||||
|
const requestPath = `/v1/payouts${
|
||||||
|
queryParams.toString() ? `?${queryParams.toString()}` : ''
|
||||||
|
}`;
|
||||||
|
|
||||||
|
response = (await $.http.get(requestPath)).data
|
||||||
|
for (const entry of response.data) {
|
||||||
|
$.pushTriggerItem({
|
||||||
|
raw: entry,
|
||||||
|
meta: {
|
||||||
|
internalId: entry.id as string
|
||||||
|
}
|
||||||
|
})
|
||||||
|
lastId = entry.id
|
||||||
|
}
|
||||||
|
} while (response.has_more)
|
||||||
|
};
|
||||||
|
|
||||||
|
export default getPayouts;
|
@@ -1,8 +1,8 @@
|
|||||||
import defineTrigger from "../../../../helpers/define-trigger";
|
import defineTrigger from "../../../../helpers/define-trigger";
|
||||||
import getPayouts from "../../common/get-payouts";
|
import getPayouts from "./get-payouts";
|
||||||
|
|
||||||
export default defineTrigger({
|
export default defineTrigger({
|
||||||
name: 'Payout',
|
name: 'New Payouts',
|
||||||
key: 'payout',
|
key: 'payout',
|
||||||
description: 'Triggers when a payout (Stripe <-> Bank account) has been updated',
|
description: 'Triggers when a payout (Stripe <-> Bank account) has been updated',
|
||||||
pollInterval: 15,
|
pollInterval: 15,
|
||||||
|
@@ -9,6 +9,6 @@ You are free to use the **Testing secret key** instead of the productive secret
|
|||||||
:::
|
:::
|
||||||
|
|
||||||
1. Go to the [Stripe Dashboard > Developer > API keys](https://dashboard.stripe.com/apikeys)
|
1. Go to the [Stripe Dashboard > Developer > API keys](https://dashboard.stripe.com/apikeys)
|
||||||
2. Click on **Reveal live key** in the table row **Secret key** and copy the now shown secret key 3
|
2. Click on **Reveal live key** in the table row **Secret key** and copy the now shown secret key
|
||||||
3. Paste the **Secret key** in the named field in Automatisch and assign a display name for the connection.
|
3. Paste the **Secret key** in the named field in Automatisch and assign a display name for the connection.
|
||||||
4. Congrats! You can start using the new Stripe connection!
|
4. Congrats! You can start using the new Stripe connection!
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
---
|
---
|
||||||
favicon: /favicons/stripe.svg
|
favicon: /favicons/stripe.svg
|
||||||
items:
|
items:
|
||||||
- name: Payout
|
- name: New Payouts
|
||||||
desc: Triggers when stripe sent a payout to a third-party bank account or vice versa.
|
desc: Triggers when stripe sent a payout to a third-party bank account or vice versa.
|
||||||
org: Stripe Documentation
|
org: Stripe Documentation
|
||||||
orgLink: https://stripe.com/docs/api/payouts/object
|
orgLink: https://stripe.com/docs/api/payouts/object
|
||||||
- name: Balance Transaction
|
- name: New Balance Transactions
|
||||||
desc: Triggers when a fund has been moved through your stripe account.
|
desc: Triggers when a fund has been moved through your stripe account.
|
||||||
org: Stripe Documentation
|
org: Stripe Documentation
|
||||||
orgLink: https://stripe.com/docs/api/balance_transactions/object
|
orgLink: https://stripe.com/docs/api/balance_transactions/object
|
||||||
|
Reference in New Issue
Block a user