Stripe
in package
Stripe Checkout and payment fulfillment helpers.
Supporter display config lives on ConfigInfo; stripe secrets in $CFG->getExtension('stripe').
Table of Contents
Methods
- bootstrapDb() : void
- client() : StripeClient
- config() : array<string, mixed>
- Load and validate the stripe extension config block.
- constructEvent() : Event
- fail() : void
- Plain-text error for developer-facing stripe endpoints.
- fulfillCheckoutSession() : array{ok: bool, error?: string, skipped?: bool, profile_id?: int, premium_until?: string}
- grantSupporter() : array{ok: bool, error?: string, skipped?: bool, profile_id?: int, premium_until?: string}
- Grant (or extend) supporter premium for a Tsugi user.
- metadataArray() : array<string, mixed>
- requireSdk() : void
- retrieveCheckoutSession() : object
- val() : mixed
- Read a field from an array or Stripe SDK object (U::get() is array-only).
- webhookSignatureHeader() : string
- collectWebhookSecrets() : array<int, string>
- computePremiumUntil() : string
- sessionHasPrice() : bool
Methods
bootstrapDb()
public
static bootstrapDb() : void
client()
public
static client(string $secret_key) : StripeClient
Parameters
- $secret_key : string
Return values
StripeClientconfig()
Load and validate the stripe extension config block.
public
static config([bool $require_webhook_secret = false ]) : array<string, mixed>
Parameters
- $require_webhook_secret : bool = false
Return values
array<string, mixed>constructEvent()
public
static constructEvent(string $payload, string $sig_header, array<int, string> $webhook_secrets) : Event
Parameters
- $payload : string
- $sig_header : string
- $webhook_secrets : array<int, string>
Return values
Eventfail()
Plain-text error for developer-facing stripe endpoints.
public
static fail(string $message[, int $http_status = 500 ]) : void
Parameters
- $message : string
- $http_status : int = 500
fulfillCheckoutSession()
public
static fulfillCheckoutSession(object $session, string $expected_price_id) : array{ok: bool, error?: string, skipped?: bool, profile_id?: int, premium_until?: string}
Parameters
- $session : object
-
Stripe Checkout Session object from webhook or API
- $expected_price_id : string
Return values
array{ok: bool, error?: string, skipped?: bool, profile_id?: int, premium_until?: string}grantSupporter()
Grant (or extend) supporter premium for a Tsugi user.
public
static grantSupporter(int $user_id, array<string, mixed> $payment) : array{ok: bool, error?: string, skipped?: bool, profile_id?: int, premium_until?: string}
Parameters
- $user_id : int
- $payment : array<string, mixed>
Return values
array{ok: bool, error?: string, skipped?: bool, profile_id?: int, premium_until?: string}metadataArray()
public
static metadataArray(mixed $metadata) : array<string, mixed>
Parameters
- $metadata : mixed
Return values
array<string, mixed>requireSdk()
public
static requireSdk() : void
retrieveCheckoutSession()
public
static retrieveCheckoutSession(StripeClient $stripe, string $session_id) : object
Parameters
- $stripe : StripeClient
- $session_id : string
Return values
objectval()
Read a field from an array or Stripe SDK object (U::get() is array-only).
public
static val(array<string, mixed>|object $source, string $key[, mixed $default = null ]) : mixed
Parameters
- $source : array<string, mixed>|object
- $key : string
- $default : mixed = null
webhookSignatureHeader()
public
static webhookSignatureHeader() : string
Return values
stringcollectWebhookSecrets()
protected
static collectWebhookSecrets(array<string, mixed> $stripe_cfg) : array<int, string>
Parameters
- $stripe_cfg : array<string, mixed>
Return values
array<int, string>computePremiumUntil()
protected
static computePremiumUntil(array<string, mixed> $stripe_block, int $months) : string
Parameters
- $stripe_block : array<string, mixed>
- $months : int
Return values
stringsessionHasPrice()
protected
static sessionHasPrice(object $session, string $price_id) : bool
Parameters
- $session : object
- $price_id : string