Stripe API client for OCaml
0
fork

Configure Feed

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

Add READMEs for 16 packages, fix merlint issues, add KVN tests

READMEs for all new packages. Fix missing docs (ocm, stix, globe),
naming (project_visible→visible, label_info→info, shader_kind→kind),
add .ocamlformat to csvt, add 11 KVN tests.

+44
+44
README.md
··· 1 + # stripe 2 + 3 + Stripe API client for OCaml. 4 + 5 + Minimal Stripe API client for SaaS billing: customers, products, prices, subscriptions, checkout sessions, billing portal, and webhook verification. Uses `requests` for HTTP and `jsont` for JSON codecs. 6 + 7 + ## Installation 8 + 9 + ``` 10 + opam install stripe 11 + ``` 12 + 13 + ## Usage 14 + 15 + ```ocaml 16 + let cfg = Stripe.config ~secret_key:"sk_test_..." session in 17 + 18 + (* Create a customer and subscription *) 19 + let customer = Stripe.Customer.create cfg ~email:"user@example.com" () in 20 + let sub = Stripe.Subscription.create cfg 21 + ~customer:customer.id ~price:"price_..." () in 22 + Printf.printf "Subscription %s: %s\n" sub.id sub.status; 23 + 24 + (* Verify a webhook *) 25 + match Stripe.Webhook.verify_signature ~secret ~payload ~signature with 26 + | Ok event -> Printf.printf "Event: %s\n" event.event_type 27 + | Error msg -> Printf.printf "Invalid: %s\n" msg 28 + ``` 29 + 30 + ## API Overview 31 + 32 + - **`config`** -- Create API configuration with secret key + HTTP session 33 + - **`Customer`** -- `create`, `retrieve`, `list` 34 + - **`Product`** -- `create`, `retrieve` 35 + - **`Price`** -- `create` (one-time or recurring) 36 + - **`Subscription`** -- `create`, `retrieve`, `cancel` 37 + - **`Checkout`** -- `create` checkout sessions 38 + - **`Portal`** -- `create` billing portal sessions 39 + - **`Webhook`** -- `verify_signature` (HMAC-SHA256 with timestamp tolerance) 40 + - **`exception Stripe_error`** -- Raised on 4xx/5xx API errors 41 + 42 + ## License 43 + 44 + MIT