# stripe/stripe-php architecture

> Architecture diagram of the GitHub repository stripe/stripe-php, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/stripe/stripe-php
- Repository: https://github.com/stripe/stripe-php

## Overview

Stripe PHP is an SDK for making Stripe API calls from PHP applications and working with the returned resources. The principal workflow is application → client/service → request construction and transport → Stripe API → response deserialization into resource objects. The library also supports webhook/event notifications and a broad set of API domains, including Checkout, billing, identity, issuing, and financial connections. The graph uses documented behavior and sampled/index evidence; unsampled domain implementations are represented at their existing directories, with uncertain links omitted.

Main entry points: [`lib/BaseStripeClient.php`](https://github.com/stripe/stripe-php/blob/master/lib/BaseStripeClient.php) (Base Client), [`lib/Service/Checkout/SessionService.php`](https://github.com/stripe/stripe-php/blob/master/lib/Service/Checkout/SessionService.php) (Checkout Service), [`lib/StripeClient.php`](https://github.com/stripe/stripe-php/blob/master/lib/StripeClient.php) (Stripe Client), [`lib/ApiRequestor.php`](https://github.com/stripe/stripe-php/blob/master/lib/ApiRequestor.php) (API Requestor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client and Services"]
  node_stripeclient["Stripe Client<br/>[StripeClient.php]"]
  node_baseclient["Base Client"]
  node_checkoutservice["Checkout Service<br/>[SessionService.php]"]
  node_servicebase["Service Base"]
end

subgraph group_transport["Request Runtime"]
  node_requestor["API Requestor<br/>[ApiRequestor.php]"]
  node_curl["cURL Transport<br/>[CurlClient.php]"]
  node_conversion["Response Conversion<br/>[Util.php]"]
end

subgraph group_domains["Stripe API Domains"]
  node_checkout["Checkout Sessions<br/>[Session.php]"]
  node_resources["API Resources<br/>[ApiResource.php]"]
  node_billing["Billing Resources"]
  node_identity["Identity Resources"]
  node_issuing["Issuing Resources"]
  node_financial["Financial Connections"]
end

subgraph group_events["Events and Webhooks"]
  node_handler["Notification Handler"]
  node_notification["V2 Event Notification"]
  node_webhook["Webhook Payload<br/>[Webhook.php]"]
  node_unknown["Unknown Notification"]
end

node_app(("PHP Application"))
node_stripeapi["Stripe API"]

node_app -->|"creates client"| node_stripeclient
node_stripeclient -->|"extends"| node_baseclient
node_stripeclient -.->|"exposes service"| node_checkoutservice
node_checkoutservice -->|"inherits"| node_servicebase
node_servicebase -->|"sends requests"| node_baseclient
node_app -->|"creates session"| node_checkoutservice
node_checkoutservice -->|"operates on"| node_checkout
node_baseclient -->|"issues request"| node_requestor
node_requestor -->|"sends API request"| node_stripeapi
node_requestor -.->|"uses transport"| node_curl
node_stripeapi -.->|"returns response"| node_conversion
node_baseclient -->|"deserializes response"| node_conversion
node_conversion -->|"constructs objects"| node_resources
node_baseclient -->|"creates handler"| node_handler
node_handler -.->|"dispatches callbacks"| node_app
node_notification -->|"parses payload"| node_webhook
node_notification -->|"defaults to"| node_unknown

click node_stripeclient "https://github.com/stripe/stripe-php/blob/master/lib/StripeClient.php"
click node_baseclient "https://github.com/stripe/stripe-php/blob/master/lib/BaseStripeClient.php"
click node_checkoutservice "https://github.com/stripe/stripe-php/blob/master/lib/Service/Checkout/SessionService.php"
click node_servicebase "https://github.com/stripe/stripe-php/blob/master/lib/Service/AbstractService.php"
click node_checkout "https://github.com/stripe/stripe-php/blob/master/lib/Checkout/Session.php"
click node_resources "https://github.com/stripe/stripe-php/blob/master/lib/ApiResource.php"
click node_billing "https://github.com/stripe/stripe-php/tree/master/lib/Billing"
click node_identity "https://github.com/stripe/stripe-php/tree/master/lib/Identity"
click node_issuing "https://github.com/stripe/stripe-php/tree/master/lib/Issuing"
click node_financial "https://github.com/stripe/stripe-php/tree/master/lib/FinancialConnections"
click node_requestor "https://github.com/stripe/stripe-php/blob/master/lib/ApiRequestor.php"
click node_curl "https://github.com/stripe/stripe-php/blob/master/lib/HttpClient/CurlClient.php"
click node_conversion "https://github.com/stripe/stripe-php/blob/master/lib/Util/Util.php"
click node_handler "https://github.com/stripe/stripe-php/blob/master/lib/AbstractEventNotificationHandler.php"
click node_notification "https://github.com/stripe/stripe-php/blob/master/lib/V2/Core/EventNotification.php"
click node_webhook "https://github.com/stripe/stripe-php/blob/master/lib/Webhook.php"
click node_unknown "https://github.com/stripe/stripe-php/blob/master/lib/Events/UnknownEventNotification.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_stripeclient,node_baseclient,node_checkoutservice,node_servicebase toneBlue
class node_requestor,node_curl,node_conversion toneAmber
class node_checkout,node_resources,node_billing,node_identity,node_issuing,node_financial,node_stripeapi toneMint
class node_handler,node_notification,node_webhook,node_unknown toneRose
class node_app toneIndigo
```

## Components

### Client and Services

- [Stripe Client](https://github.com/stripe/stripe-php/blob/master/lib/StripeClient.php): `lib/StripeClient.php`
- [Base Client](https://github.com/stripe/stripe-php/blob/master/lib/BaseStripeClient.php): `lib/BaseStripeClient.php`
- [Checkout Service](https://github.com/stripe/stripe-php/blob/master/lib/Service/Checkout/SessionService.php): `lib/Service/Checkout/SessionService.php`
- [Service Base](https://github.com/stripe/stripe-php/blob/master/lib/Service/AbstractService.php): `lib/Service/AbstractService.php`

### Request Runtime

- [API Requestor](https://github.com/stripe/stripe-php/blob/master/lib/ApiRequestor.php): `lib/ApiRequestor.php`
- [cURL Transport](https://github.com/stripe/stripe-php/blob/master/lib/HttpClient/CurlClient.php): `lib/HttpClient/CurlClient.php`
- [Response Conversion](https://github.com/stripe/stripe-php/blob/master/lib/Util/Util.php): `lib/Util/Util.php`

### Stripe API Domains

- [Checkout Sessions](https://github.com/stripe/stripe-php/blob/master/lib/Checkout/Session.php): `lib/Checkout/Session.php`
- [API Resources](https://github.com/stripe/stripe-php/blob/master/lib/ApiResource.php): `lib/ApiResource.php`
- [Billing Resources](https://github.com/stripe/stripe-php/tree/master/lib/Billing): `lib/Billing`
- [Identity Resources](https://github.com/stripe/stripe-php/tree/master/lib/Identity): `lib/Identity`
- [Issuing Resources](https://github.com/stripe/stripe-php/tree/master/lib/Issuing): `lib/Issuing`
- [Financial Connections](https://github.com/stripe/stripe-php/tree/master/lib/FinancialConnections): `lib/FinancialConnections`

### Events and Webhooks

- [Notification Handler](https://github.com/stripe/stripe-php/blob/master/lib/AbstractEventNotificationHandler.php): `lib/AbstractEventNotificationHandler.php`
- [V2 Event Notification](https://github.com/stripe/stripe-php/blob/master/lib/V2/Core/EventNotification.php): `lib/V2/Core/EventNotification.php`
- [Webhook Payload](https://github.com/stripe/stripe-php/blob/master/lib/Webhook.php): `lib/Webhook.php`
- [Unknown Notification](https://github.com/stripe/stripe-php/blob/master/lib/Events/UnknownEventNotification.php): `lib/Events/UnknownEventNotification.php`

### Other components

- **PHP Application**
- **Stripe API**

## Connections

- PHP Application → Stripe Client: creates client (evidence: `README.md`)
- Stripe Client → Base Client: extends (evidence: `lib/StripeClient.php`)
- Stripe Client → Checkout Service: exposes service
- Checkout Service → Service Base: inherits (evidence: `lib/Service/Checkout/SessionService.php`)
- Service Base → Base Client: sends requests (evidence: `lib/Service/AbstractService.php`)
- PHP Application → Checkout Service: creates session (evidence: `README.md`)
- Checkout Service → Checkout Sessions: operates on (evidence: `lib/Service/Checkout/SessionService.php`)
- Base Client → API Requestor: issues request (evidence: `lib/BaseStripeClient.php`)
- API Requestor → Stripe API: sends API request (evidence: `README.md`)
- API Requestor → cURL Transport: uses transport (evidence: `lib/ApiRequestor.php`)
- Stripe API → Response Conversion: returns response
- Base Client → Response Conversion: deserializes response (evidence: `lib/BaseStripeClient.php`)
- Response Conversion → API Resources: constructs objects (evidence: `lib/Util/Util.php`)
- Base Client → Notification Handler: creates handler (evidence: `lib/BaseStripeClient.php`)
- Notification Handler → PHP Application: dispatches callbacks
- V2 Event Notification → Webhook Payload: parses payload (evidence: `lib/V2/Core/EventNotification.php`)
- V2 Event Notification → Unknown Notification: defaults to (evidence: `lib/V2/Core/EventNotification.php`)
