Shortcut multiple @get and @send


I’m trying to create the following binding:

  const session = await stripe.checkout.sessions.create({

I have the stripe type can achieve this via:

type checkout

external checkout: stripe => checkout = "checkout"

type sessions

external sessions : checkout => sessions = "sessions"

external create : (sessions, {..}) => Promise.t<string> = "create"


let session = s->Stripe.checkout->Stripe.sessions->Stripe.create({ "key": "value"})

This works, but I’m not sure if this is idiomatic or not.
Can I not add the additional path to my @send somehow? type checkout and type sessions don’t really mean much in this case.

Perhaps you could use something like this?

external create : ({..}) => Promise.t<string> = "create"

Sorry, there is a bit more to it, it should be called on the stripe object:

type stripe

@module("stripe") @new
external make: string => stripe = "default"

external createCheckoutSession: (stripe, {..}) => Promise.t<string> = "create"
let s = Stripe.make(Common.stripe_private_key)
// Does not work yet
let session = s->Stripe.createCheckoutSession({ "key": "value"})

I see the issue. Maybe this will work?

@scope(("checkout", "sessions"))
external createCheckoutSession: (stripe, {..}) => Promise.t<string> = "create"

Yes, that works!