payments

object

%Stripe

/phlo/resources/payments/Stripe.phlo
version 1.0
creator q-ai.nl
summary Thin Stripe wrappers: Checkout, Billing Portal, prices, customers, subscriptions and webhook verification. Call Stripe::boot($secret) first. Requires the Stripe PHP SDK (composer: stripe/stripe-php).
package payments
frontend false
backend true
tags stripe payments checkout subscription billing webhook
static

Stripe :: boot ($secret, $version = '2025-09-30.clover')

line 9
Initializes the Stripe API with the provided secret key and optionally sets the API version.
$secret = trim((string)$secret)
if (!$secret) error('Stripe secret key not configured', 500)
\Stripe\Stripe::setApiKey($secret)
$version && \Stripe\Stripe::setApiVersion($version)
static

Stripe :: price ($lookupKey)

line 16
Retrieves the price object from Stripe based on the provided lookup key, returning the first active price found or null if none exists.
$prices = \Stripe\Price::all(['lookup_keys' => [$lookupKey], 'limit' => 1, 'active' => true])
return $prices->data[0] ?? null
static

Stripe :: customer ($id)

line 21
Retrieves a Stripe customer by their ID, returning null if the customer is deleted or if an error occurs during the API call.
try {
	$c = \Stripe\Customer::retrieve((string)$id)
	return ($c->deleted ?? false) ? null : $c
}
catch (\Stripe\Exception\ApiErrorException $e){
	return null
}
static

Stripe :: createCustomer (array $data)

line 31
Creates a new customer in Stripe using the provided data.
\Stripe\Customer::create($data)
static

Stripe :: checkout (array $params)

line 33
Creates a new checkout session in Stripe, allowing for the processing of payments and managing customer interactions during the checkout process.
\Stripe\Checkout\Session::create($params)
static

Stripe :: portal ($customerId, $returnUrl)

line 35
Creates a new session for the Stripe Billing Portal, allowing a customer to manage their billing details and subscriptions.
\Stripe\BillingPortal\Session::create(['customer' => (string)$customerId, 'return_url' => (string)$returnUrl])
static

Stripe :: verifyWebhook ($payload, $sigHeader, $secret)

line 37
Verifies a Stripe webhook by constructing an event using the provided payload, signature header, and secret. It throws an error if the secret is not configured.
$secret = trim((string)$secret)
if (!$secret) error('Stripe webhook secret not configured', 500)
return \Stripe\Webhook::constructEvent((string)$payload, (string)$sigHeader, $secret)
static

Stripe :: subscriptions ($customerId, $status = 'all', $limit = 10)

line 43
Retrieves a list of subscriptions for a specified customer from Stripe, filtered by status and limited to a specified number of results.
\Stripe\Subscription::all(['customer' => (string)$customerId, 'status' => $status, 'limit' => $limit])
static

Stripe :: subscription ($id)

line 45
Retrieves a subscription object from Stripe using the specified subscription ID.
\Stripe\Subscription::retrieve((string)$id)
static

Stripe :: product ($id)

line 47
Retrieves a Stripe product by its ID.
\Stripe\Product::retrieve((string)$id)

We use essential cookies to make this site work. With your permission we also use analytics to improve the site.