Lue dans les fichiers PHP du paquet au commit 4105b70ad517 : ses espaces de noms, classes, interfaces et énumérations, leurs constantes, propriétés et méthodes publiques avec leur PHPDoc, et les options que prennent ses fabriques. Rien n’en est exécuté.
AccountsclassStripe's account and subscription objects as Omnitrade's models.
2 methods
ApiclassStripe, through omnipay/stripe: the Checkout gateway (hosted payment page) and the PaymentIntents gateway (what was paid, refunds), both on one secret key. Omnipay talks through the application's HTTP client when one is given (a PSR-18 bridge): the profiler sees the calls, the tests mock them.
9 methods · 2 constants
CheckoutGatewayclassomnipay/stripe's Checkout gateway, its purchase() our request (CheckoutPurchaseRequest).
1 method
CheckoutPurchaseRequestclassomnipay/stripe's Checkout session request, with what it does not send:
15 methods
ProductsclassStripe's Products and their Prices, read as Products: one variant per active price (the default price first), no stock - Stripe counts none.
4 methods
SessionsclassA Checkout session, as Stripe answers it, read as a Transaction.
1 method
StripeGatewayFactoryclassStripe: cards and wallets through Checkout (the hosted page), what was paid, refunds, the webhook's events, and the catalogue kept in Stripe's Products and Prices (no stock: fetchInventory() is not supported).
20 options
AccountLinkActionclassThe onboarding page of a connected account (POST /v1/account_links): single use, valid a few minutes.
3 methods
CancelSubscriptionActionclassStops a subscription: at the end of the paid period (POST, cancel_at_period_end) or at once (DELETE /v1/subscriptions/{id}).
3 methods
CreateAccountActionclassA connected account (POST /v1/accounts): Express by default, in the holder's country, with the capabilities asked for - "transfers" to be sent destination charges, "card_payments" with it where Stripe requires both.
3 methods
FetchAccountActionclassA connected account as it stands (GET /v1/accounts/{id}).
3 methods
FetchProductActionclassOne Stripe product by its id (prod_...), with its active prices. Stripe hosts no product pages: an address answers null, as an unknown id does.
3 methods
FetchProductsActionclassA page of Stripe's Products, each with its active Prices (one call per product): GET /v1/products, the cursor the last product's id (starting_after); with a query, GET /v1/products/search on name~"...", the cursor Stripe's next_page. Stripe's search knows no update date, so updatedSince keeps the products whose "updated" is that late among each page - a page may come back short, or empty with a next one. Pass the same updatedSince and query with the cursor.
4 methods
FetchSubscriptionActionclassA subscription as it stands (GET /v1/subscriptions/{id}).
3 methods
FetchTransactionActionclassThe Checkout session as Stripe has it now: paid, still open, expired, or refunded - its payment intent and that intent's latest charge expanded, the charge's amount_refunded what says so (unexpanded, Stripe gives the intent's id only).
3 methods
GetPaymentMethodsActionclassWhat Checkout offers: the methods insisted on in the options, else the card plus the wallets Stripe shows on its own (Apple Pay, Google Pay, Link) - Stripe decides the rest per account, country and currency on its page.
3 methods
NotifyActionclassA webhook event, its signature checked: the Checkout session events read as what they mean for the transaction - completed and async_payment_succeeded with a paid session is PAID, expired and async_payment_failed is EXPIRED / REFUSED. Any other event is handed back with no status, to ignore or to read from $raw.
3 methods
PurchaseActionclassA Checkout session: Stripe's hosted page, the buyer sent to it (PENDING with the page's URL); notify() or fetch() then says whether they paid. The lines are listed on the page when they and the shipping add up to the amount, the shipping as the session's shipping rate; else (a discount among them, which Checkout takes only as a coupon made beforehand, or lines that do not add up) the amount is one line under the payment's description. Either way the session charges the payment's amount.
5 methods
RefundActionclassMoney back on what a Checkout session was paid with: its payment intent's charge. The reference is the session's id (cs_...), or a payment intent's (pi_...) or a charge's (ch_...) directly. The idempotency key makes the same refund asked twice happen once. Without an amount, the whole charge (what is left of it) is refunded.
3 methods
SubscribeActionclassA Checkout session in subscription mode (POST /v1/checkout/sessions): the buyer is sent to Stripe's page (PENDING with its URL), pays the first period, and Stripe renews. The plan is the request's Stripe price when given, else a price made on the fly from the payment (its amount every interval, named by its description). The payment's metadata is put on the session and on the subscription, so every later event carries it.
3 methods
SubscriptionPortalActionclassThe customer portal (POST /v1/billing_portal/sessions): card, invoices, cancellation.
3 methods
Omnitrade\Stripe
Accounts class
final class Accounts Accounts.php:10
Stripe's account and subscription objects as Omnitrade's models.
Accounts::account()
public static function account(array $account): AccountAccounts::subscription()
public static function subscription(array $subscription): SubscriptionApi class
final class Api Api.php:24
Stripe, through omnipay/stripe: the Checkout gateway (hosted payment page) and the PaymentIntents gateway (what was paid, refunds), both on one secret key. Omnipay talks through the application's HTTP client when one is given (a PSR-18 bridge): the profiler sees the calls, the tests mock them.
The catalogue's plain reads (products, prices) go straight through that client, get(), with the secret key as a bearer token.
const SIGNATURE_HEADER = 'Stripe-Signature'const BASE_URI = 'https://api.stripe.com'
Api::__construct()
public function __construct(readonly string $apiKey, readonly ?string $webhookSecret = null, readonly ?HttpClientInterface $http = null)Api::checkout()
public function checkout(): CheckoutGatewayApi::intents()
public function intents(): PaymentIntentsGatewayApi::get()
public function get(string $path, array $query = []): arrayA GET of Stripe's REST API: "/v1/products", with its query (arrays as Stripe reads them, expand[0]=...).
- Throws
ProviderException with Stripe's error code ("resource_missing")
Api::post()
public function post(string $path, array $parameters = [], ?string $idempotencyKey = null): arrayA POST of Stripe's REST API, form-encoded as Stripe reads it (nested arrays as a[b][c]=...; booleans as "true" / "false"): accounts, account links, portal sessions, subscriptions - what omnipay/stripe has no message for.
- Throws
ProviderException with Stripe's error code
Api::delete()
public function delete(string $path, array $parameters = []): arrayApi::sendOmnipay()
public function sendOmnipay(\Omnipay\Common\Message\RequestInterface $request): \Omnipay\Common\Message\ResponseInterfaceSends one of omnipay's requests (Checkout, payment intents): a network failure, or a request omnipay refuses before sending it (a parameter missing), is a ProviderException, like any other of Stripe's.
- Throws
ProviderException
Api::canVerify()
public function canVerify(): boolApi::verify()
public function verify(string $payload, ?string $header, int $tolerance = 300): voidWhether a webhook payload was signed by Stripe with the endpoint's secret (Stripe-Signature: t=timestamp,v1=hmac), within $tolerance seconds.
- Throws
InvalidNotificationException
CheckoutGateway class
class CheckoutGateway extends OmnipayCheckoutGateway CheckoutGateway.php:8
omnipay/stripe's Checkout gateway, its purchase() our request (CheckoutPurchaseRequest).
CheckoutGateway::purchase()
public function purchase(array $parameters = []): CheckoutPurchaseRequestCheckoutPurchaseRequest class
class CheckoutPurchaseRequest extends PurchaseRequest CheckoutPurchaseRequest.php:24
omnipay/stripe's Checkout session request, with what it does not send:
customer_email the buyer's address, filled in on Stripe's page adaptive_pricing off by default: the session is paid in the given currency, not converted to the buyer's locale the page's language client_reference_id the merchant's reference (the order's) - the parent's parameter, sent here metadata kept by Stripe, given back on every event notice a mention on the page and the receipt (why no VAT...) destination a connected account the payment is passed on to (Connect destination charge) applicationFee what the platform keeps of it, in minor units shippingOptions shipping_options: the shipping rate charged on top of the lines
The methods to insist on (paymentMethodTypes) and the Idempotency-Key header (setIdempotencyKeyHeader) are the parent's.
CheckoutPurchaseRequest::getCustomerEmail()
public function getCustomerEmail(): ?stringCheckoutPurchaseRequest::setCustomerEmail()
public function setCustomerEmail(?string $value): selfCheckoutPurchaseRequest::getAdaptivePricing()
public function getAdaptivePricing(): boolCheckoutPurchaseRequest::setAdaptivePricing()
public function setAdaptivePricing(bool $value): selfCheckoutPurchaseRequest::getLocale()
public function getLocale(): ?stringCheckoutPurchaseRequest::setLocale()
public function setLocale(?string $value): selfCheckoutPurchaseRequest::getDestination()
public function getDestination(): ?stringCheckoutPurchaseRequest::setDestination()
public function setDestination(?string $value): selfCheckoutPurchaseRequest::getApplicationFee()
public function getApplicationFee(): ?intCheckoutPurchaseRequest::setApplicationFee()
public function setApplicationFee(?int $value): selfCheckoutPurchaseRequest::getShippingOptions()
public function getShippingOptions(): ?arrayCheckoutPurchaseRequest::setShippingOptions()
public function setShippingOptions(?array $value): selfCheckoutPurchaseRequest::getNotice()
public function getNotice(): ?stringCheckoutPurchaseRequest::setNotice()
public function setNotice(?string $value): selfCheckoutPurchaseRequest::getData()
public function getData(): arrayProducts class
final class Products Products.php:19
Stripe's Products and their Prices, read as Products: one variant per active price (the default price first), no stock - Stripe counts none.
Metadata are the attributes; by convention its "brand" is the brand, "category"/"categories" and "tags" (comma-separated) the categories and tags, "slug" (or "handle") the handle, a price's "sku" its variant's.
Products::fetch()
public static function fetch(Api $api, array $product): ProductA Stripe product with its active prices, fetched (GET /v1/prices?product=...).
Products::find()
public static function find(Api $api, string $id): ?ProductOne product by its id, with its prices; null when Stripe has none.
- Throws
ProviderException
Products::prices()
public static function prices(Api $api, string $product): array- Returns
the product's active prices, every page
Products::product()
public static function product(array $product, array $prices): Product$producta Stripe product (default_price expanded or not)
$pricesits active prices
Sessions class
final class Sessions Sessions.php:10
A Checkout session, as Stripe answers it, read as a Transaction.
Sessions::transaction()
public static function transaction(array $session): TransactionStripeGatewayFactory class
final class StripeGatewayFactory extends GatewayFactory StripeGatewayFactory.php:44
Stripe: cards and wallets through Checkout (the hosted page), what was paid, refunds, the webhook's events, and the catalogue kept in Stripe's Products and Prices (no stock: fetchInventory() is not supported).
Connect: Express accounts opened for those the platform pays (createAccount(), accountLink(), fetchAccount()), and payments sent to them as destination charges (Payment::$destination, ::$applicationFee). Subscriptions: Checkout in subscription mode (subscribe()), the customer portal, cancellation; account.updated and customer.subscription.* events read by notify().
options: api_key: '%env(STRIPE_API_KEY)%' # sk_live_... / sk_test_... webhook_secret: '%env(STRIPE_WEBHOOK_SECRET)%' # whsec_..., for notify() adaptive_pricing: false # true: Stripe may offer the buyer's own currency payment_methods: [] # ['card', 'sepa_debit']: the methods to insist on active_only: false # true: fetchProducts() lists the active products only
No authorizations: Checkout takes the money when the buyer pays (a session in "setup"/"authorize" mode is not offered here).
Options
| Option | Default | |
|---|---|---|
webhook_secret | null | |
adaptive_pricing | false | |
payment_methods | [] | |
active_only | false | |
omnitrade.api | fn(Config $c) => new Api((string) $c['api_key'], $c['webhook_secret'] ?: null, $this->http) | |
omnitrade.action.purchase | static fn(Config $c) => new PurchaseAction((bool) $c['adaptive_pricing'], (array) $c['payment_methods']) | |
omnitrade.action.fetch | new FetchTransactionAction() | |
omnitrade.action.refund | new RefundAction() | |
omnitrade.action.notify | new NotifyAction() | |
omnitrade.action.products | static fn(Config $c) => new FetchProductsAction((bool) $c['active_only']) | |
omnitrade.action.product | new FetchProductAction() | |
omnitrade.action.account_create | new CreateAccountAction() | |
omnitrade.action.account_link | new AccountLinkAction() | |
omnitrade.action.account | new FetchAccountAction() | |
omnitrade.action.subscribe | new SubscribeAction() | |
omnitrade.action.subscription | new FetchSubscriptionAction() | |
omnitrade.action.subscription_cancel | new CancelSubscriptionAction() | |
omnitrade.action.subscription_portal | new SubscriptionPortalAction() | |
omnitrade.action.methods | static fn(Config $c) => new GetPaymentMethodsAction((array) $c['payment_methods']) | |
api_key | required |
Omnitrade\Stripe\Action
AccountLinkAction class
final class AccountLinkAction implements ActionInterface, ApiAwareInterface AccountLinkAction.php:14
The onboarding page of a connected account (POST /v1/account_links): single use, valid a few minutes.
AccountLinkAction::__construct()
public function __construct()AccountLinkAction::supports()
public function supports(Request $request): boolAccountLinkAction::execute()
public function execute(Request $request): voidCancelSubscriptionAction class
final class CancelSubscriptionAction implements ActionInterface, ApiAwareInterface CancelSubscriptionAction.php:17
Stops a subscription: at the end of the paid period (POST, cancel_at_period_end) or at once (DELETE /v1/subscriptions/{id}).
CancelSubscriptionAction::__construct()
public function __construct()CancelSubscriptionAction::supports()
public function supports(Request $request): boolCancelSubscriptionAction::execute()
public function execute(Request $request): voidCreateAccountAction class
final class CreateAccountAction implements ActionInterface, ApiAwareInterface CreateAccountAction.php:19
A connected account (POST /v1/accounts): Express by default, in the holder's country, with the capabilities asked for - "transfers" to be sent destination charges, "card_payments" with it where Stripe requires both.
CreateAccountAction::__construct()
public function __construct()CreateAccountAction::supports()
public function supports(Request $request): boolCreateAccountAction::execute()
public function execute(Request $request): voidFetchAccountAction class
final class FetchAccountAction implements ActionInterface, ApiAwareInterface FetchAccountAction.php:14
A connected account as it stands (GET /v1/accounts/{id}).
FetchAccountAction::__construct()
public function __construct()FetchAccountAction::supports()
public function supports(Request $request): boolFetchAccountAction::execute()
public function execute(Request $request): voidFetchProductAction class
final class FetchProductAction implements ActionInterface, ApiAwareInterface FetchProductAction.php:17
One Stripe product by its id (prod_...), with its active prices. Stripe hosts no product pages: an address answers null, as an unknown id does.
FetchProductAction::__construct()
public function __construct()FetchProductAction::supports()
public function supports(Request $request): boolFetchProductAction::execute()
public function execute(Request $request): voidFetchProductsAction class
final class FetchProductsAction implements ActionInterface, ApiAwareInterface FetchProductsAction.php:23
A page of Stripe's Products, each with its active Prices (one call per product): GET /v1/products, the cursor the last product's id (starting_after); with a query, GET /v1/products/search on name~"...", the cursor Stripe's next_page. Stripe's search knows no update date, so updatedSince keeps the products whose "updated" is that late among each page - a page may come back short, or empty with a next one. Pass the same updatedSince and query with the cursor.
FetchProductsAction::__construct()
public function __construct(readonly bool $activeOnly = false)FetchProductsAction::supports()
public function supports(Request $request): boolFetchProductsAction::execute()
public function execute(Request $request): voidFetchProductsAction::search()
public static function search(string $text): stringStripe's search: name~"..." (a substring, three characters at least), name:"..." below.
FetchSubscriptionAction class
final class FetchSubscriptionAction implements ActionInterface, ApiAwareInterface FetchSubscriptionAction.php:14
A subscription as it stands (GET /v1/subscriptions/{id}).
FetchSubscriptionAction::__construct()
public function __construct()FetchSubscriptionAction::supports()
public function supports(Request $request): boolFetchSubscriptionAction::execute()
public function execute(Request $request): voidFetchTransactionAction class
final class FetchTransactionAction implements ActionInterface, ApiAwareInterface FetchTransactionAction.php:20
The Checkout session as Stripe has it now: paid, still open, expired, or refunded - its payment intent and that intent's latest charge expanded, the charge's amount_refunded what says so (unexpanded, Stripe gives the intent's id only).
FetchTransactionAction::__construct()
public function __construct()FetchTransactionAction::supports()
public function supports(Request $request): boolFetchTransactionAction::execute()
public function execute(Request $request): voidGetPaymentMethodsAction class
final class GetPaymentMethodsAction implements ActionInterface GetPaymentMethodsAction.php:18
What Checkout offers: the methods insisted on in the options, else the card plus the wallets Stripe shows on its own (Apple Pay, Google Pay, Link) - Stripe decides the rest per account, country and currency on its page.
The amount's currency narrows them: the euro-only methods (SEPA Direct Debit, Bancontact, iDEAL, EPS) are left out of an amount in another currency (Stripe's payment method support table).
GetPaymentMethodsAction::__construct()
public function __construct(readonly array $paymentMethods = [])GetPaymentMethodsAction::supports()
public function supports(Request $request): boolGetPaymentMethodsAction::execute()
public function execute(Request $request): voidNotifyAction class
final class NotifyAction implements ActionInterface, ApiAwareInterface NotifyAction.php:36
A webhook event, its signature checked: the Checkout session events read as what they mean for the transaction - completed and async_payment_succeeded with a paid session is PAID, expired and async_payment_failed is EXPIRED / REFUSED. Any other event is handed back with no status, to ignore or to read from $raw.
account.updated carries the connected account ($account), the customer.subscription.* events the subscription ($subscription); a completed session of a subscription keeps the subscription's id in the transaction's raw data ("subscription"). $reference is the object's id.
The catalogue's events carry the product: product.created and product.updated the event's product with its active prices (one call), price.created, price.updated and price.deleted the price's product, read afresh (two calls); product.deleted the product's id alone. $reference is the product's id.
NotifyAction::__construct()
public function __construct()NotifyAction::supports()
public function supports(Request $request): boolNotifyAction::execute()
public function execute(Request $request): voidPurchaseAction class
final class PurchaseAction implements ActionInterface, ApiAwareInterface PurchaseAction.php:27
A Checkout session: Stripe's hosted page, the buyer sent to it (PENDING with the page's URL); notify() or fetch() then says whether they paid. The lines are listed on the page when they and the shipping add up to the amount, the shipping as the session's shipping rate; else (a discount among them, which Checkout takes only as a coupon made beforehand, or lines that do not add up) the amount is one line under the payment's description. Either way the session charges the payment's amount.
A payment with a destination is a Connect destination charge: taken by the platform, transferred to the connected account, the application fee kept.
PurchaseAction::__construct()
public function __construct(readonly bool $adaptivePricing = false, readonly array $paymentMethods = [])PurchaseAction::supports()
public function supports(Request $request): boolPurchaseAction::execute()
public function execute(Request $request): voidPurchaseAction::lines()
public static function lines(Payment $payment): array- Returns
the session's line items, which with shipping() charge the payment's amount
PurchaseAction::shipping()
public static function shipping(Payment $payment): ?arrayThe shipping as the session's one shipping rate, a fixed amount, when the lines are listed and there is shipping to pay; else null (it is inside the one line).
RefundAction class
final class RefundAction implements ActionInterface, ApiAwareInterface RefundAction.php:23
Money back on what a Checkout session was paid with: its payment intent's charge. The reference is the session's id (cs_...), or a payment intent's (pi_...) or a charge's (ch_...) directly. The idempotency key makes the same refund asked twice happen once. Without an amount, the whole charge (what is left of it) is refunded.
RefundAction::__construct()
public function __construct()RefundAction::supports()
public function supports(Request $request): boolRefundAction::execute()
public function execute(Request $request): voidSubscribeAction class
final class SubscribeAction implements ActionInterface, ApiAwareInterface SubscribeAction.php:26
A Checkout session in subscription mode (POST /v1/checkout/sessions): the buyer is sent to Stripe's page (PENDING with its URL), pays the first period, and Stripe renews. The plan is the request's Stripe price when given, else a price made on the fly from the payment (its amount every interval, named by its description). The payment's metadata is put on the session and on the subscription, so every later event carries it.
Then: checkout.session.completed tells of the first payment (the session's "subscription" is the subscription's id), customer.subscription.updated and .deleted of its life, invoice.paid of each renewal.
SubscribeAction::__construct()
public function __construct()SubscribeAction::supports()
public function supports(Request $request): boolSubscribeAction::execute()
public function execute(Request $request): voidSubscriptionPortalAction class
final class SubscriptionPortalAction implements ActionInterface, ApiAwareInterface SubscriptionPortalAction.php:14
The customer portal (POST /v1/billing_portal/sessions): card, invoices, cancellation.
SubscriptionPortalAction::__construct()
public function __construct()SubscriptionPortalAction::supports()
public function supports(Request $request): boolSubscriptionPortalAction::execute()
public function execute(Request $request): void