Stripe API client for OCaml
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocaml-stripe: bind README example as functions and switch to Fmt

The block referenced [session] / [secret] / [payload] / [signature]
free, mixed top-level [Printf.printf] with a top-level [match]
expression. Wrap as [create_subscription ~session] and
[handle_webhook ~secret ~payload ~signature], use [Fmt.pr] / [Fmt.epr],
and add [fmt] to the mdx libraries.

+12 -11
+11 -10
README.md
··· 26 26 ## Usage 27 27 28 28 ```ocaml 29 - let cfg = Stripe.config ~secret_key:"sk_test_..." session 30 - (* Create a customer and subscription *) 31 - let customer = Stripe.Customer.create cfg ~email:"user@example.com" () 32 - let sub = Stripe.Subscription.create cfg 33 - ~customer:customer.id ~price:"price_..." () in 34 - Printf.printf "Subscription %s: %s\n" sub.id sub.status; 29 + let create_subscription ~session = 30 + let cfg = Stripe.config ~secret_key:"sk_test_..." session in 31 + let customer = Stripe.Customer.create cfg ~email:"user@example.com" () in 32 + let sub = 33 + Stripe.Subscription.create cfg ~customer:customer.id ~price:"price_..." () 34 + in 35 + Fmt.pr "Subscription %s: %s@." sub.id sub.status 35 36 36 - (* Verify a webhook *) 37 - match Stripe.Webhook.verify_signature ~secret ~payload ~signature with 38 - | Ok event -> Printf.printf "Event: %s\n" event.event_type 39 - | Error msg -> Printf.printf "Invalid: %s\n" msg 37 + let handle_webhook ~secret ~payload ~signature = 38 + match Stripe.Webhook.verify_signature ~secret ~payload ~signature with 39 + | Ok event -> Fmt.pr "Event: %s@." event.event_type 40 + | Error msg -> Fmt.epr "Invalid: %s@." msg 40 41 ``` 41 42 42 43 ## API Overview
+1 -1
dune
··· 4 4 5 5 (mdx 6 6 (files README.md) 7 - (libraries stripe)) 7 + (libraries stripe fmt))