Skip to content

Commit

Permalink
add checkout_retrieve
Browse files Browse the repository at this point in the history
  • Loading branch information
abeljimo committed Feb 22, 2024
1 parent 9f20c7d commit e47e919
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
27 changes: 27 additions & 0 deletions apps/stripe/bundle/bots/runaction/checkout_retrieve/bot.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { RunActionBotApi } from "@uesio/bots"
import { Params } from "@uesio/app/bots/runaction/uesio/stripe/checkout_retrieve"
import { Stripe } from "stripe"

export default function checkout_retrieve(bot: RunActionBotApi) {
const params = bot.params.getAll() as Params
const { id } = params
const actionName = bot.getActionName()

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

const baseURL = bot.getIntegration().getBaseURL()
const result = bot.http.request<null, Stripe.Checkout.Session>({
method: "GET",
url: baseURL + `/v1/checkout/sessions/${id}`,
})

if (result.code !== 200) {
bot.addError("could not complete checkout retrieve: " + result.code)
return
}

bot.addResult("session", result.body)
}
9 changes: 9 additions & 0 deletions apps/stripe/bundle/bots/runaction/checkout_retrieve/bot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: checkout_retrieve
public: true
type: RUNACTION
dialect: TYPESCRIPT
params:
- name: id
label: Checkout Session Id
type: TEXT
required: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: checkout_retrieve
label: Get Checkout Session
public: true
bot: checkout_retrieve

0 comments on commit e47e919

Please sign in to comment.