chore: address review comments
This commit is contained in:
@@ -2,30 +2,30 @@ import verifyCredentials from "./verify-credentials";
|
||||
import isStillVerified from "./is-still-verified";
|
||||
|
||||
export default {
|
||||
fields: [
|
||||
{
|
||||
key: 'secretKey',
|
||||
label: 'Secret Key',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description: null,
|
||||
clickToCopy: false,
|
||||
},
|
||||
{
|
||||
key: 'displayName',
|
||||
label: 'Account Name',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description: 'The display name that identifies this stripe connection - most likely the associated account name',
|
||||
clickToCopy: false,
|
||||
},
|
||||
],
|
||||
verifyCredentials,
|
||||
isStillVerified
|
||||
fields: [
|
||||
{
|
||||
key: 'secretKey',
|
||||
label: 'Secret Key',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description: null,
|
||||
clickToCopy: false,
|
||||
},
|
||||
{
|
||||
key: 'displayName',
|
||||
label: 'Account Name',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description: 'The display name that identifies this stripe connection - most likely the associated account name',
|
||||
clickToCopy: false,
|
||||
},
|
||||
],
|
||||
verifyCredentials,
|
||||
isStillVerified
|
||||
};
|
@@ -1,13 +1,9 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
const verifyCredentials = async ($: IGlobalVariable) => {
|
||||
try {
|
||||
await $.http.get(
|
||||
`/v1/events`,
|
||||
);
|
||||
} catch (e) {
|
||||
throw new Error('Invalid secret key')
|
||||
}
|
||||
await $.http.get(
|
||||
`/v1/events`,
|
||||
);
|
||||
await $.auth.set({
|
||||
screenName: $.auth.data?.displayName,
|
||||
});
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import {TBeforeRequest} from "@automatisch/types";
|
||||
|
||||
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
|
||||
requestConfig.headers['Authorization'] = `Bearer ${$.auth.data?.secretKey}`
|
||||
return requestConfig
|
||||
requestConfig.headers['Authorization'] = `Bearer ${$.auth.data?.secretKey}`
|
||||
return requestConfig
|
||||
}
|
||||
|
||||
export default addAuthHeader;
|
@@ -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;
|
@@ -4,16 +4,16 @@ import auth from "./auth"
|
||||
import triggers from "./triggers"
|
||||
|
||||
export default defineApp({
|
||||
name: 'Stripe',
|
||||
key: 'stripe',
|
||||
iconUrl: '{BASE_URL}/apps/stripe/assets/favicon.svg',
|
||||
authDocUrl: 'https://automatisch.io/docs/apps/stripe/connection',
|
||||
supportsConnections: true,
|
||||
baseUrl: 'https://stripe.com',
|
||||
apiBaseUrl: 'https://api.stripe.com',
|
||||
primaryColor: '635bff',
|
||||
beforeRequest: [addAuthHeader],
|
||||
auth,
|
||||
triggers,
|
||||
actions: [],
|
||||
name: 'Stripe',
|
||||
key: 'stripe',
|
||||
iconUrl: '{BASE_URL}/apps/stripe/assets/favicon.svg',
|
||||
authDocUrl: 'https://automatisch.io/docs/apps/stripe/connection',
|
||||
supportsConnections: true,
|
||||
baseUrl: 'https://stripe.com',
|
||||
apiBaseUrl: 'https://api.stripe.com',
|
||||
primaryColor: '635bff',
|
||||
beforeRequest: [addAuthHeader],
|
||||
auth,
|
||||
triggers,
|
||||
actions: [],
|
||||
})
|
@@ -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,12 +1,12 @@
|
||||
import defineTrigger from "../../../../helpers/define-trigger";
|
||||
import getBalanceTransactions from "../../common/get-balance-transactions";
|
||||
import getBalanceTransactions from "./get-balance-transactions";
|
||||
|
||||
export default defineTrigger({
|
||||
name: 'Balance Transaction',
|
||||
key: 'balanceTransaction',
|
||||
description: 'Triggers when a new transaction is processed (refund, payout, adjustment, ...)',
|
||||
pollInterval: 15,
|
||||
async run($) {
|
||||
await getBalanceTransactions($)
|
||||
}
|
||||
name: 'New Balance Transactions',
|
||||
key: 'balanceTransaction',
|
||||
description: 'Triggers when a new transaction is processed (refund, payout, adjustment, ...)',
|
||||
pollInterval: 15,
|
||||
async run($) {
|
||||
await getBalanceTransactions($)
|
||||
}
|
||||
})
|
@@ -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,12 +1,12 @@
|
||||
import defineTrigger from "../../../../helpers/define-trigger";
|
||||
import getPayouts from "../../common/get-payouts";
|
||||
import getPayouts from "./get-payouts";
|
||||
|
||||
export default defineTrigger({
|
||||
name: 'Payout',
|
||||
key: 'payout',
|
||||
description: 'Triggers when a payout (Stripe <-> Bank account) has been updated',
|
||||
pollInterval: 15,
|
||||
async run($) {
|
||||
await getPayouts($)
|
||||
}
|
||||
name: 'New Payouts',
|
||||
key: 'payout',
|
||||
description: 'Triggers when a payout (Stripe <-> Bank account) has been updated',
|
||||
pollInterval: 15,
|
||||
async run($) {
|
||||
await getPayouts($)
|
||||
}
|
||||
})
|
@@ -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)
|
||||
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.
|
||||
4. Congrats! You can start using the new Stripe connection!
|
||||
|
@@ -1,11 +1,11 @@
|
||||
---
|
||||
favicon: /favicons/stripe.svg
|
||||
items:
|
||||
- name: Payout
|
||||
- name: New Payouts
|
||||
desc: Triggers when stripe sent a payout to a third-party bank account or vice versa.
|
||||
org: Stripe Documentation
|
||||
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.
|
||||
org: Stripe Documentation
|
||||
orgLink: https://stripe.com/docs/api/balance_transactions/object
|
||||
|
Reference in New Issue
Block a user