Skip to content

Commit

Permalink
stripe integration
Browse files Browse the repository at this point in the history
  • Loading branch information
abeljimo committed Feb 15, 2024
1 parent f7bc1a6 commit 8a414a4
Show file tree
Hide file tree
Showing 25 changed files with 8,004 additions and 0 deletions.
22 changes: 22 additions & 0 deletions apps/stripe/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"extends": "../../.eslintrc.json",
"ignorePatterns": ["bundle/componentpacks/*/*.js*"],
"rules": {},
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"parserOptions": {
"project": ["apps/stripe/tsconfig.*?.json"]
},
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
9 changes: 9 additions & 0 deletions apps/stripe/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.uesio
node_modules/
bundle/componentpacks/*/dist/
# Don't include the following types within the app bundle
bundle/collections/**
bundle/fields/**
bundle/routes/**
bundle/selectlists/**
bundle/views/**
6 changes: 6 additions & 0 deletions apps/stripe/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

/bundle/componentpacks/*/dist
package-lock.json
package.json
generated
node_modules
8 changes: 8 additions & 0 deletions apps/stripe/.prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
tabWidth: 4
semi: false
useTabs: true
overrides:
- files: "*.yaml"
options:
tabWidth: 2
printWidth: 1000
18 changes: 18 additions & 0 deletions apps/stripe/bundle/bots/listener/checkout/bot.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { ListenerBotApi } from "@uesio/bots"

export default function checkout(bot: ListenerBotApi) {
const url = `https://api.stripe.com/v1/products`

bot.log.info("URL", url)

const response = bot.http.request({
method: "GET",
url,
headers: {
Authorization:
"Bearer sk_test_51MwQbcF1X3pAO31UFqkNAdVubAAspfKpzZnLLzKiebZGkDVzDQCQ6hTozBBSG7z1zB5NOws9MAsdSZ9Xu39dmoyd00ZVpjccKy",
},
})

bot.log.info("Response", response)
}
3 changes: 3 additions & 0 deletions apps/stripe/bundle/bots/listener/checkout/bot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: checkout
type: LISTENER
dialect: TYPESCRIPT
56 changes: 56 additions & 0 deletions apps/stripe/bundle/bots/runaction/checkout/bot.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { RunActionBotApi } from "@uesio/bots"
import { Params } from "@uesio/app/bots/runaction/uesio/stripe/checkout"

// type OrderDetails = {
// orderNumber: string
// }

export default function checkout(bot: RunActionBotApi) {
const params = bot.params.getAll() as Params
const { successURL, items, mode } = params
const actionName = bot.getActionName()

if (actionName !== "checkout") {
bot.addError("unsupported action name: " + actionName)
return
}

const { apikey } = bot.getCredentials()

if (apikey === "") {
bot.addError("missing api key")
return
}

const baseURL = bot.getIntegration().getBaseURL()

bot.log.info("ITEMS", items)
bot.log.info("apikey", apikey)
bot.log.info("baseURL", baseURL)
bot.log.info("mode", mode)
bot.log.info("successURL", successURL)

const result = bot.http.request({
method: "POST",
headers: {
Authorization: `Bearer ${apikey}`,
},
url: baseURL + "/v1/checkout/sessions",
body: {
mode,
success_url: successURL,
},
})
// if (result.code !== 200) {
// bot.addError("could not complete checkout: " + result.status)
// return
// }

bot.log.info("Result", result)
bot.log.info("Body", result.body)

// const orderDetails = result.body as OrderDetails
// const { orderNumber } = orderDetails

// bot.addResult("orderNumber", orderNumber)
}
17 changes: 17 additions & 0 deletions apps/stripe/bundle/bots/runaction/checkout/bot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: checkout
public: true
type: RUNACTION
dialect: TYPESCRIPT
params:
- name: successURL
label: Success URL
type: TEXT
required: true
- name: items
label: Items
type: LIST
required: true
- name: mode
type: TEXT
required: true
selectList: mode
8 changes: 8 additions & 0 deletions apps/stripe/bundle/bundle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: uesio/stripe
dependencies:
uesio/builder:
version: v0.0.1
uesio/core:
version: v0.0.1
uesio/io:
version: v0.0.1
7 changes: 7 additions & 0 deletions apps/stripe/bundle/credentials/stripe_api_key.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: stripe_api_key
type: API_KEY
apiKey:
key: stripe_key
location: header
locationName: Authorization
locationValue: ${apikey}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: checkout
label: Get Checkout URL
public: true
bot: checkout
6 changes: 6 additions & 0 deletions apps/stripe/bundle/integrations/stripe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: stripe
public: true
type: stripe
authentication: API_KEY
credentials: stripe_api_key
baseUrl: https://api.stripe.com
3 changes: 3 additions & 0 deletions apps/stripe/bundle/integrationtypes/stripe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: stripe
label: Stripe
public: true
4 changes: 4 additions & 0 deletions apps/stripe/bundle/secrets/stripe_key.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: stripe_key
public: true
store: platform
managedBy: site
16 changes: 16 additions & 0 deletions apps/stripe/generated/@types/@uesio/app.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

declare module "@uesio/app/selectlists/uesio/stripe" {
export type Mode = "payment" | "setup" | "subscription"
}
declare module "@uesio/app/bots/runaction/uesio/stripe/checkout" {

type Params = {
successURL: string
items: string[]
mode: string
}

export type {
Params
}
}
Loading

0 comments on commit 8a414a4

Please sign in to comment.