Payment
Reference for the Payment module: format amounts held in millipennies as a currency string, configure a small set of products and subscriptions, and read and write the database records for purchases, subscriptions and merchants along with their status history.
This page is a pure reference. For how the framework fits together, see the Guide.
Payment- currency formatting and routing entry point.PaymentConfig- register products, subscriptions, settings and providers.PaymentMerchantData- immutable data for a payment merchant record.PaymentMerchantDatabase- database operations for payment merchants.PaymentMerchantStatusData- immutable data for a merchant status history record.PaymentProviderPaymentStatusEnum- the outcome reported by a payment provider.PaymentPurchaseData- immutable data for a purchase record.PaymentPurchaseDatabase- database operations for payment purchases.PaymentPurchaseStatusData- immutable data for a purchase status history record.PaymentRegularityEnum- the billing regularity of a subscription.PaymentSubscriptionData- immutable data for a subscription record.PaymentSubscriptionDatabase- database operations for payment subscriptions.PaymentSubscriptionStatusData- immutable data for a subscription status history record.
Payment
The module's entry point: a routing hook and a helper that formats an amount in millipennies as a currency string using integer maths, avoiding floating point rounding.
FormatMillipennies
Payment::FormatMillipennies(int $millipennies, string $currency = 'GBP'): string
Formats millipennies (1000 units = 1 penny) as a currency string. Uses text processing on an integer to avoid float rounding issues.
| Name | Type | Description |
|---|---|---|
$millipennies | int | The amount in millipennies (1000 = 1 penny, 100000 = 1 pound or dollar). |
$currency | string | The currency code, for example GBP or USD. |
Returns string The formatted currency string.
Route
Payment::Route(): void
Routing entry point for the module. Webhooks are handled by provider modules, so this performs no routing.
Returns void
PaymentConfig
Where a site configures its products and subscriptions. Designed for a small set of rarely changing products and subscriptions; a full product database is not supported. Registered subscriptions, settings and providers are collected in public static arrays.
Constants
| Constant | Value | Description |
|---|---|---|
PaymentConfig::PAYMENT_SANDBOX | true | Whether the sandbox keys are used. |
PaymentConfig::PAYMENT_PUBLIC_KEY | string | The provider public key, chosen by the sandbox flag. |
PaymentConfig::PAYMENT_PRIVATE_KEY | string | The provider private key, chosen by the sandbox flag. |
PaymentConfig::ENDPOINT_SECRET | string | The webhook endpoint signing secret. |
Properties
| Property | Type | Description |
|---|---|---|
PaymentConfig::$subscriptions | array | Registered subscriptions, keyed by subscription name. |
PaymentConfig::$settings | array | Registered settings, keyed by name. |
PaymentConfig::$providers | array | Registered providers, keyed by provider name. |
AddProvider
PaymentConfig::AddProvider(string $providerName, string $displayName): void
Registers a payment provider.
| Name | Type | Description |
|---|---|---|
$providerName | string | The name of the provider, for example stripe or paypal. |
$displayName | string | The display name, for example Stripe or PayPal. |
Returns void
AddSetting
PaymentConfig::AddSetting(string $name, string $defaultValue): void
Registers a named setting with a default value.
| Name | Type | Description |
|---|---|---|
$name | string | The setting name. |
$defaultValue | string | The default value for the setting. |
Returns void
Subscription
PaymentConfig::Subscription(string $subscriptionName, string $subscriptionTitle, string $subscriptionReference, array $price, callable|string $onCreate, callable|string $onSuccess, callable|string $onRecurrence): void
Registers a subscription option with its price and lifecycle callbacks.
| Name | Type | Description |
|---|---|---|
$subscriptionName | string | The unique key for the subscription. |
$subscriptionTitle | string | The subscription title. |
$subscriptionReference | string | The subscription reference. |
$price | array | The subscription price. |
$onCreate | callable|string | Callback invoked when the subscription is created. |
$onSuccess | callable|string | Callback invoked on a successful payment. |
$onRecurrence | callable|string | Callback invoked on a recurring payment. |
Returns void
PaymentMerchantData
Immutable data for a payment merchant record, with helpers to encode to and decode from JSON.
Properties
| Property | Type | Description |
|---|---|---|
$data->id | int | The merchant record id (readonly). |
$data->providerIdentifier | string | The provider identifier (readonly). |
$data->memberId | ?int | The owning member id, or null (readonly). |
$data->providerAccountRef | ?string | The provider account reference, or null (readonly). |
$data->providerDataJson | ?string | Provider-specific data JSON, or null (readonly). |
$data->createdAt | CalendarDateTimeData | When the record was created (readonly). |
__construct
new PaymentMerchantData(int $id = 0, string $providerIdentifier = '', ?int $memberId = null, ?string $providerAccountRef = null, ?string $providerDataJson = null, CalendarDateTimeData $createdAt = new CalendarDateTimeData())
Create merchant data from its fields.
| Name | Type | Description |
|---|---|---|
$id | int | The merchant record id. |
$providerIdentifier | string | The provider identifier. |
$memberId | ?int | The owning member id, or null. |
$providerAccountRef | ?string | The provider account reference, or null. |
$providerDataJson | ?string | Provider-specific data JSON, or null. |
$createdAt | CalendarDateTimeData | When the record was created. |
Returns PaymentMerchantData
FromJson
PaymentMerchantData::FromJson(string $json): self
Build merchant data from its JSON representation.
| Name | Type | Description |
|---|---|---|
$json | string | The JSON string. |
Returns self The merchant data.
ToJson
$data->ToJson(): string
The merchant data encoded as a JSON string.
Returns string The JSON string.
PaymentMerchantDatabase
Database operations for payment merchants: read merchants, append status history and update provider account flags.
Constants
| Constant | Value | Description |
|---|---|---|
PaymentMerchantDatabase::MERCHANT_STATUS_PENDING | 0 | Merchant is pending. |
PaymentMerchantDatabase::MERCHANT_STATUS_ACTIVE | 1 | Merchant is active. |
PaymentMerchantDatabase::MERCHANT_STATUS_RESTRICTED | 2 | Merchant is restricted. |
PaymentMerchantDatabase::MERCHANT_STATUS_REJECTED | 3 | Merchant is rejected. |
PaymentMerchantDatabase::MERCHANT_STATUS_SUSPENDED | 4 | Merchant is suspended. |
AddStatus
PaymentMerchantDatabase::AddStatus(int $merchantId, int $statusType, ?string $displayDetails = null, ?string $statusDataJson = null): void
Add a status history record for a merchant.
| Name | Type | Description |
|---|---|---|
$merchantId | int | Merchant id. |
$statusType | int | Status type constant. |
$displayDetails | ?string | Human-readable status details, or null. |
$statusDataJson | ?string | Additional status data JSON, or null. |
Returns void
fromRow
PaymentMerchantDatabase::fromRow(object $row): PaymentMerchantData
Convert a database row to a merchant data object.
| Name | Type | Description |
|---|---|---|
$row | object | Database row. |
Returns PaymentMerchantData The merchant data.
GetByProviderAccountRef
PaymentMerchantDatabase::GetByProviderAccountRef(string $accountRef): PaymentMerchantData
Get a merchant by provider account reference.
| Name | Type | Description |
|---|---|---|
$accountRef | string | Provider account reference, for example a Stripe account id. |
Returns PaymentMerchantData The merchant data.
UpdateStripeAccountFlags
PaymentMerchantDatabase::UpdateStripeAccountFlags(int $merchantId, bool $chargesEnabled, bool $payoutsEnabled, bool $detailsSubmitted, bool $tosAccepted, bool $externalAccountAdded): void
Update the Stripe account flags stored in a merchant's provider data.
| Name | Type | Description |
|---|---|---|
$merchantId | int | Merchant id. |
$chargesEnabled | bool | Whether charges are enabled. |
$payoutsEnabled | bool | Whether payouts are enabled. |
$detailsSubmitted | bool | Whether details have been submitted. |
$tosAccepted | bool | Whether terms of service have been accepted. |
$externalAccountAdded | bool | Whether an external account has been added. |
Returns void
UpdateStripeExternalAccountStatus
PaymentMerchantDatabase::UpdateStripeExternalAccountStatus(int $merchantId, bool $externalAccountAdded): void
Update the Stripe external account status stored in a merchant's provider data.
| Name | Type | Description |
|---|---|---|
$merchantId | int | Merchant id. |
$externalAccountAdded | bool | Whether an external account has been added. |
Returns void
PaymentMerchantStatusData
Immutable data for a merchant status history record, with helpers to encode to and decode from JSON.
Properties
| Property | Type | Description |
|---|---|---|
$data->id | int | The status record id (readonly). |
$data->merchantId | int | The merchant id this status belongs to (readonly). |
$data->statusType | int | The status type constant (readonly). |
$data->displayDetails | ?string | Human-readable status details, or null (readonly). |
$data->providerRef | ?string | Provider reference, or null (readonly). |
$data->providerDataJson | ?string | Provider-specific data JSON, or null (readonly). |
$data->createdAt | CalendarDateTimeData | When the record was created (readonly). |
__construct
new PaymentMerchantStatusData(int $id = 0, int $merchantId = 0, int $statusType = 0, ?string $displayDetails = null, ?string $providerRef = null, ?string $providerDataJson = null, CalendarDateTimeData $createdAt = new CalendarDateTimeData())
Create merchant status data from its fields.
| Name | Type | Description |
|---|---|---|
$id | int | The status record id. |
$merchantId | int | The merchant id this status belongs to. |
$statusType | int | The status type constant. |
$displayDetails | ?string | Human-readable status details, or null. |
$providerRef | ?string | Provider reference, or null. |
$providerDataJson | ?string | Provider-specific data JSON, or null. |
$createdAt | CalendarDateTimeData | When the record was created. |
Returns PaymentMerchantStatusData
FromJson
PaymentMerchantStatusData::FromJson(string $json): self
Build merchant status data from its JSON representation.
| Name | Type | Description |
|---|---|---|
$json | string | The JSON string. |
Returns self The merchant status data.
ToJson
$data->ToJson(): string
The merchant status data encoded as a JSON string.
Returns string The JSON string.
PaymentProviderPaymentStatusEnum
The outcome of a payment as reported by a payment provider. A backed enum with integer values.
Cases
| Case | Value | Description |
|---|---|---|
PaymentProviderPaymentStatusEnum::SUCCESS | 1 | The payment succeeded. |
PaymentProviderPaymentStatusEnum::PENDING | 2 | The payment is pending. |
PaymentProviderPaymentStatusEnum::ERROR | 3 | The payment failed. |
PaymentProviderPaymentStatusEnum::UNKNOWN | 4 | The payment outcome is unknown. |
PaymentPurchaseData
Immutable data for a purchase record, with helpers to encode to and decode from JSON.
Properties
| Property | Type | Description |
|---|---|---|
$data->id | int | The purchase record id (readonly). |
$data->providerIdentifier | string | The provider identifier (readonly). |
$data->memberId | ?int | The owning member id, or null (readonly). |
$data->moduleName | string | The module that created the purchase (readonly). |
$data->typeIdentifier | string | The purchase type identifier (readonly). |
$data->currency | string | The currency code (readonly). |
$data->amountMillipennies | int | The amount in millipennies (readonly). |
$data->title | string | The purchase title (readonly). |
$data->displayDetails | string | Display details (readonly). |
$data->dataJson | string | Module-specific data JSON (readonly). |
$data->successUrl | string | The success URL (readonly). |
$data->productDataJson | ?string | Product data JSON, or null (readonly). |
$data->providerDataJson | ?string | Provider-specific data JSON, or null (readonly). |
$data->createdAt | CalendarDateTimeData | When the record was created (readonly). |
__construct
new PaymentPurchaseData(int $id = 0, string $providerIdentifier = '', ?int $memberId = null, string $moduleName = '', string $typeIdentifier = '', string $currency = '', int $amountMillipennies = 0, string $title = '', string $displayDetails = '', string $dataJson = '', string $successUrl = '', ?string $productDataJson = null, ?string $providerDataJson = null, CalendarDateTimeData $createdAt = new CalendarDateTimeData())
Create purchase data from its fields.
| Name | Type | Description |
|---|---|---|
$id | int | The purchase record id. |
$providerIdentifier | string | The provider identifier. |
$memberId | ?int | The owning member id, or null. |
$moduleName | string | The module that created the purchase. |
$typeIdentifier | string | The purchase type identifier. |
$currency | string | The currency code. |
$amountMillipennies | int | The amount in millipennies. |
$title | string | The purchase title. |
$displayDetails | string | Display details. |
$dataJson | string | Module-specific data JSON. |
$successUrl | string | The success URL. |
$productDataJson | ?string | Product data JSON, or null. |
$providerDataJson | ?string | Provider-specific data JSON, or null. |
$createdAt | CalendarDateTimeData | When the record was created. |
Returns PaymentPurchaseData
FromJson
PaymentPurchaseData::FromJson(string $json): self
Build purchase data from its JSON representation.
| Name | Type | Description |
|---|---|---|
$json | string | The JSON string. |
Returns self The purchase data.
ToJson
$data->ToJson(): string
The purchase data encoded as a JSON string.
Returns string The JSON string.
PaymentPurchaseDatabase
Database operations for payment purchases: create and read purchases, look them up by provider references, and append status history.
Constants
| Constant | Value | Description |
|---|---|---|
PaymentPurchaseDatabase::PURCHASE_STATUS_CREATED | 0 | Purchase has been created. |
PaymentPurchaseDatabase::PURCHASE_STATUS_RESERVED | 1 | Purchase has been reserved. |
PaymentPurchaseDatabase::PURCHASE_STATUS_PENDING | 2 | Purchase is pending. |
PaymentPurchaseDatabase::PURCHASE_STATUS_SUCCESS | 3 | Purchase succeeded. |
PaymentPurchaseDatabase::PURCHASE_STATUS_ERROR | 4 | Purchase failed. |
PaymentPurchaseDatabase::PURCHASE_STATUS_CANCELLED | 5 | Purchase was cancelled. |
AddStatus
PaymentPurchaseDatabase::AddStatus(int $purchaseId, int $statusType, ?string $displayDetails = null, ?string $statusDataJson = null): void
Add a status history record for a purchase.
| Name | Type | Description |
|---|---|---|
$purchaseId | int | Purchase id. |
$statusType | int | Status type constant. |
$displayDetails | ?string | Human-readable status details, or null. |
$statusDataJson | ?string | Additional status data JSON, or null. |
Returns void
Create
PaymentPurchaseDatabase::Create(string $providerIdentifier, ?int $optionalMemberId, string $moduleName, string $typeIdentifier, string $currency, int $amountMillipennies, string $title, string $displayDetails, string $dataJson, string $successUrl, ?string $optionalProductDataJson = null, ?string $optionalProviderDataJson = null): int
Create a new payment purchase record.
| Name | Type | Description |
|---|---|---|
$providerIdentifier | string | Provider identifier, for example stripe. |
$optionalMemberId | ?int | Optional member id. |
$moduleName | string | Module name. |
$typeIdentifier | string | Type identifier. |
$currency | string | Currency code. |
$amountMillipennies | int | Amount in millipennies. |
$title | string | Purchase title. |
$displayDetails | string | Display details. |
$dataJson | string | Module-specific data JSON. |
$successUrl | string | Success URL. |
$optionalProductDataJson | ?string | Optional product data JSON. |
$optionalProviderDataJson | ?string | Optional provider data JSON. |
Returns int The purchase id.
fromRow
PaymentPurchaseDatabase::fromRow(object $row): PaymentPurchaseData
Convert a database row to a purchase data object.
| Name | Type | Description |
|---|---|---|
$row | object | Database row. |
Returns PaymentPurchaseData The purchase data.
GetByClientSecret
PaymentPurchaseDatabase::GetByClientSecret(string $clientSecret): PaymentPurchaseData
Get a purchase by client secret, matching the payment intent id extracted from it against the provider data JSON.
| Name | Type | Description |
|---|---|---|
$clientSecret | string | Client secret. |
Returns PaymentPurchaseData The purchase data.
GetByProviderPaymentRef
PaymentPurchaseDatabase::GetByProviderPaymentRef(string $paymentRef): PaymentPurchaseData
Get a purchase by provider payment reference.
| Name | Type | Description |
|---|---|---|
$paymentRef | string | Provider payment reference, for example a PaymentIntent id or Charge id. |
Returns PaymentPurchaseData The purchase data.
GetByProviderToRef
PaymentPurchaseDatabase::GetByProviderToRef(string $toRef): array
Get purchases whose provider data JSON holds the given transfer reference.
| Name | Type | Description |
|---|---|---|
$toRef | string | Provider "to" reference, for example a Transfer id. |
Returns array A list of PaymentPurchaseData.
GetOptionalByRideId
PaymentPurchaseDatabase::GetOptionalByRideId(int $rideId): ?PaymentPurchaseData
Get the most recent ride payment purchase for a ride id, or null when there is none.
| Name | Type | Description |
|---|---|---|
$rideId | int | The ride id. |
Returns ?PaymentPurchaseData The purchase data, or null.
UpdateAmountAndProviderData
PaymentPurchaseDatabase::UpdateAmountAndProviderData(int $purchaseId, int $amountMillipennies, ?string $optionalProviderDataJson = null): void
Update a purchase's amount and, when given, its provider data JSON.
| Name | Type | Description |
|---|---|---|
$purchaseId | int | Purchase id. |
$amountMillipennies | int | New amount in millipennies. |
$optionalProviderDataJson | ?string | Optional provider data JSON. |
Returns void
UpdateProviderPaymentRef
PaymentPurchaseDatabase::UpdateProviderPaymentRef(int $purchaseId, string $paymentRef): void
Update the provider payment reference for a purchase.
| Name | Type | Description |
|---|---|---|
$purchaseId | int | Purchase id. |
$paymentRef | string | Provider payment reference. |
Returns void
PaymentPurchaseStatusData
Immutable data for a purchase status history record, with helpers to encode to and decode from JSON.
Properties
| Property | Type | Description |
|---|---|---|
$data->id | int | The status record id (readonly). |
$data->purchaseId | int | The purchase id this status belongs to (readonly). |
$data->statusType | int | The status type constant (readonly). |
$data->displayDetails | ?string | Human-readable status details, or null (readonly). |
$data->providerRef | ?string | Provider reference, or null (readonly). |
$data->providerDataJson | ?string | Provider-specific data JSON, or null (readonly). |
$data->createdAt | CalendarDateTimeData | When the record was created (readonly). |
__construct
new PaymentPurchaseStatusData(int $id = 0, int $purchaseId = 0, int $statusType = 0, ?string $displayDetails = null, ?string $providerRef = null, ?string $providerDataJson = null, CalendarDateTimeData $createdAt = new CalendarDateTimeData())
Create purchase status data from its fields.
| Name | Type | Description |
|---|---|---|
$id | int | The status record id. |
$purchaseId | int | The purchase id this status belongs to. |
$statusType | int | The status type constant. |
$displayDetails | ?string | Human-readable status details, or null. |
$providerRef | ?string | Provider reference, or null. |
$providerDataJson | ?string | Provider-specific data JSON, or null. |
$createdAt | CalendarDateTimeData | When the record was created. |
Returns PaymentPurchaseStatusData
FromJson
PaymentPurchaseStatusData::FromJson(string $json): self
Build purchase status data from its JSON representation.
| Name | Type | Description |
|---|---|---|
$json | string | The JSON string. |
Returns self The purchase status data.
ToJson
$data->ToJson(): string
The purchase status data encoded as a JSON string.
Returns string The JSON string.
PaymentRegularityEnum
The billing regularity of a subscription. A backed enum with integer values, plus a helper to build a case from its value.
Cases
| Case | Value | Description |
|---|---|---|
PaymentRegularityEnum::DAILY | 1 | Billed daily. |
PaymentRegularityEnum::WEEKLY | 2 | Billed weekly. |
PaymentRegularityEnum::MONTHLY | 3 | Billed monthly. |
PaymentRegularityEnum::QUARTERLY | 4 | Billed quarterly. |
PaymentRegularityEnum::YEARLY | 5 | Billed yearly. |
fromValue
PaymentRegularityEnum::fromValue(int $value): self
Return the case with the given integer value, throwing when no case matches.
| Name | Type | Description |
|---|---|---|
$value | int | The integer value of the case. |
Returns self The matching case.
PaymentSubscriptionData
Immutable data for a subscription record, with helpers to encode to and decode from JSON.
Properties
| Property | Type | Description |
|---|---|---|
$data->id | int | The subscription record id (readonly). |
$data->providerIdentifier | string | The provider identifier (readonly). |
$data->memberId | ?int | The owning member id, or null (readonly). |
$data->currency | string | The currency code (readonly). |
$data->amountMillipennies | int | The amount in millipennies per period (readonly). |
$data->module | string | The module that created the subscription (readonly). |
$data->identifier | string | The subscription identifier within the module (readonly). |
$data->title | string | The subscription title (readonly). |
$data->humanReadableDetail | string | Human-readable detail text (readonly). |
$data->priceDescription | string | Description of the subscription price (readonly). |
$data->regularity | int | Regularity enum value (readonly). |
$data->providerRef | string | Provider reference (readonly). |
$data->providerDataJson | ?string | Provider-specific data JSON, or null (readonly). |
$data->createdAt | CalendarDateTimeData | When the record was created (readonly). |
__construct
new PaymentSubscriptionData(int $id = 0, string $providerIdentifier = '', ?int $memberId = null, string $currency = '', int $amountMillipennies = 0, string $module = '', string $identifier = '', string $title = '', string $humanReadableDetail = '', string $priceDescription = '', int $regularity = 0, string $providerRef = '', ?string $providerDataJson = null, CalendarDateTimeData $createdAt = new CalendarDateTimeData())
Create subscription data from its fields.
| Name | Type | Description |
|---|---|---|
$id | int | The subscription record id. |
$providerIdentifier | string | The provider identifier. |
$memberId | ?int | The owning member id, or null. |
$currency | string | The currency code. |
$amountMillipennies | int | The amount in millipennies per period. |
$module | string | The module that created the subscription. |
$identifier | string | The subscription identifier within the module. |
$title | string | The subscription title. |
$humanReadableDetail | string | Human-readable detail text. |
$priceDescription | string | Description of the subscription price. |
$regularity | int | Regularity enum value. |
$providerRef | string | Provider reference. |
$providerDataJson | ?string | Provider-specific data JSON, or null. |
$createdAt | CalendarDateTimeData | When the record was created. |
Returns PaymentSubscriptionData
FromJson
PaymentSubscriptionData::FromJson(string $json): self
Build subscription data from its JSON representation.
| Name | Type | Description |
|---|---|---|
$json | string | The JSON string. |
Returns self The subscription data.
ToJson
$data->ToJson(): string
The subscription data encoded as a JSON string.
Returns string The JSON string.
PaymentSubscriptionDatabase
Database operations for payment subscriptions: create and read subscriptions, look them up by provider reference, append status history and update provider data.
Constants
| Constant | Value | Description |
|---|---|---|
PaymentSubscriptionDatabase::SUBSCRIPTION_STATUS_PENDING | 0 | Subscription is pending. |
PaymentSubscriptionDatabase::SUBSCRIPTION_STATUS_ACTIVE | 1 | Subscription is active. |
PaymentSubscriptionDatabase::SUBSCRIPTION_STATUS_TRIALING | 2 | Subscription is in a trial. |
PaymentSubscriptionDatabase::SUBSCRIPTION_STATUS_PAST_DUE | 3 | Subscription is past due. |
PaymentSubscriptionDatabase::SUBSCRIPTION_STATUS_UNPAID | 4 | Subscription is unpaid. |
PaymentSubscriptionDatabase::SUBSCRIPTION_STATUS_CANCELLED | 5 | Subscription was cancelled. |
AddStatus
PaymentSubscriptionDatabase::AddStatus(int $subscriptionId, int $statusType, ?string $displayDetails = null, ?string $statusDataJson = null): void
Add a status history record for a subscription.
| Name | Type | Description |
|---|---|---|
$subscriptionId | int | Subscription id. |
$statusType | int | Status type constant. |
$displayDetails | ?string | Human-readable status details, or null. |
$statusDataJson | ?string | Additional status data JSON, or null. |
Returns void
Create
PaymentSubscriptionDatabase::Create(string $providerIdentifier, ?int $memberId, string $module, string $identifier, string $title, string $humanReadableDetail, string $currency, int $amountMillipennies, string $priceDescription, int $regularity, string $providerRef, object $providerData): int
Create a new subscription and record its initial pending status.
| Name | Type | Description |
|---|---|---|
$providerIdentifier | string | Provider identifier, for example stripe. |
$memberId | ?int | Optional member id. |
$module | string | Module name that created the subscription. |
$identifier | string | Subscription identifier within the module. |
$title | string | Subscription title. |
$humanReadableDetail | string | Human-readable detail text. |
$currency | string | Currency code. |
$amountMillipennies | int | Amount in millipennies per billing period. |
$priceDescription | string | Description of the subscription price. |
$regularity | int | Regularity enum value. |
$providerRef | string | Provider reference. |
$providerData | object | Provider-specific data object with a ToJson method. |
Returns int The subscription id.
fromRow
PaymentSubscriptionDatabase::fromRow(object $row): PaymentSubscriptionData
Convert a database row to a subscription data object.
| Name | Type | Description |
|---|---|---|
$row | object | Database row. |
Returns PaymentSubscriptionData The subscription data.
GetByProviderRef
PaymentSubscriptionDatabase::GetByProviderRef(string $providerRef): PaymentSubscriptionData
Get a subscription by provider reference.
| Name | Type | Description |
|---|---|---|
$providerRef | string | Provider reference, for example a Stripe subscription id. |
Returns PaymentSubscriptionData The subscription data.
UpdateStripeProviderData
PaymentSubscriptionDatabase::UpdateStripeProviderData(int $subscriptionId, string $providerRef, object $stripeProviderData): void
Update both the provider reference and the provider data JSON for a subscription.
| Name | Type | Description |
|---|---|---|
$subscriptionId | int | Subscription id. |
$providerRef | string | Provider reference, for example a Stripe subscription id. |
$stripeProviderData | object | Provider data object with a ToJson method. |
Returns void
PaymentSubscriptionStatusData
Immutable data for a subscription status history record, with helpers to encode to and decode from JSON.
Properties
| Property | Type | Description |
|---|---|---|
$data->id | int | The status record id (readonly). |
$data->subscriptionId | int | The subscription id this status belongs to (readonly). |
$data->statusType | int | The status type constant (readonly). |
$data->displayDetails | ?string | Human-readable status details, or null (readonly). |
$data->providerRef | ?string | Provider reference, or null (readonly). |
$data->providerDataJson | ?string | Provider-specific data JSON, or null (readonly). |
$data->createdAt | CalendarDateTimeData | When the record was created (readonly). |
__construct
new PaymentSubscriptionStatusData(int $id = 0, int $subscriptionId = 0, int $statusType = 0, ?string $displayDetails = null, ?string $providerRef = null, ?string $providerDataJson = null, CalendarDateTimeData $createdAt = new CalendarDateTimeData())
Create subscription status data from its fields.
| Name | Type | Description |
|---|---|---|
$id | int | The status record id. |
$subscriptionId | int | The subscription id this status belongs to. |
$statusType | int | The status type constant. |
$displayDetails | ?string | Human-readable status details, or null. |
$providerRef | ?string | Provider reference, or null. |
$providerDataJson | ?string | Provider-specific data JSON, or null. |
$createdAt | CalendarDateTimeData | When the record was created. |
Returns PaymentSubscriptionStatusData
FromJson
PaymentSubscriptionStatusData::FromJson(string $json): self
Build subscription status data from its JSON representation.
| Name | Type | Description |
|---|---|---|
$json | string | The JSON string. |
Returns self The subscription status data.
ToJson
$data->ToJson(): string
The subscription status data encoded as a JSON string.
Returns string The JSON string.