Handler
extends SecuredServerPlugin
in package
Implement Stripe handler
This class provides interfaces for Stripe interactions
Tags
Table of Contents
- $config : stdClass|null
- Buffer for configuration
- $defaultPermissions : array<string|int, mixed>
- The default permission set
- $dir : string
- The implementation directory
- $name : string
- Name of the plugin
- $handler : Stripe|null
- The Stripe handler
- $verbose : bool
- __construct() : mixed
- Handler constructor.
- BasketChangeStatus() : void
- Called on basket status change, reaction is needed on cancel
- GetAccessList() : array<string|int, mixed>
- Handler() : Stripe|null
- Get handler instance
- Name() : string
- OnAddOrUpdateContent() : void
- Called on save an object
- OnAfterBasketRegisterUser() : void
- OnAfterMarkSubscriptionForSwitch() : void
- OnAfterUserAdminSave() : void
- Special operation when user was changed by admin and the subscription start date needs to change
- OnAfterUserLoginByPassword() : void
- Called after registration of session, make sure to delete cached methods
- OnArticleGetRawPrice() : void
- OnBeforeMarkSubscriptionForSwitch() : void
- OnCheckBasketTransitions() : void
- Process potentially automatic changes on baskets
- OnCommandLineInterfaceCall() : void
- Cli to fix and check relation id duplications
- OnDeleteContent() : void
- React on basket delete
- OnGetEntityAttributes() : void
- Add input field to core object
- OnMapArrayIncludes() : void
- Add some scripts to the backend to interact with system frontend hooks
- OnMarkSubscriptionForTermination() : void
- Register a plan to terminate the subscription at the nex possible end
- OnRegisterWidgetIncludes() : void
- Add custom scripts to certain widgets when present
- OnSubscriptionChangePaymentMethod() : void
- OnSubscriptionSwitch() : void
- Handle a subscription model change operation
- RegisterHooks() : array<string|int, mixed>
- register system hooks Register a set of handler functions to be called in certain positions.
- RegisterPublicAssetBasePath() : void
- Provide deep link access to js template files
- RequestOnUrlParsed() : mixed
- ServeRequest() : mixed
- Serve request
- settings() : Result|object
- Get/Set the settings
- SetupTemplate() : mixed
- UpdateAccessProduct() : Result
- Send an update access price request based on a certain date If no date is given use the next regular phase
- handleConfig() : void
- Handle the context requests
- hasAccess() : bool
- Check if endpoint is accessible for this user group
- isInContext() : bool
- Is in certain context?
- setupAttributes() : void
- Set up the permission attribute table
- basePath() : string
- Resolve the stripe dashboard base path
- correctAnchorPoint() : Result
- createFromOriginal() : Result
- handleAttachUserPaymentMethod() : void
- Attach method to customer
- handleConfigPreset() : mixed
- Handle the context requests
- handleEndTrail() : void
- handleListCustomer() : void
- Get customer data by customer id
- handleListUserInvoices() : void
- Fetch invoices of a user
- handleListUserPaymentMethods() : void
- Get users payment methods
- handlePriceFetch() : void
- Get resolved price
- handlePriceList() : void
- Get list of prices
- handleRegisterAsConnected() : void
- handleRegisterCustomer() : mixed
- Register customer or get relevant customer object when linked
- handleReplacePSP() : void
- Replace the payment service provider with stripe
- handleSettings() : mixed
- handleSetupIntent() : mixed
- handleSetupIntentComplete() : void
- Complete a setup intent
- handleUsersCompanies() : void
- handleViewBasketPayment() : void
- View single payment by payment intent id
- handleViewBasketRefunds() : void
- Get list of known refunds
- handleWebhook() : Result
- Handle the web hook event
- mapInvoice() : array<string|int, mixed>
- Convert invoice to our object scheme
- mapPaymentMethods() : void
- Map the found payment methods to our structures signature
Properties
$config
Buffer for configuration
protected
stdClass|null
$config
= null
$defaultPermissions
The default permission set
protected
array<string|int, mixed>
$defaultPermissions
= [['endpoint' => 'config', 'root' => true, 'admin' => true]]
$dir
The implementation directory
protected
string
$dir
= ''
$name
Name of the plugin
protected
string
$name
= ''
$handler
The Stripe handler
private
Stripe|null
$handler
= null
?Stripe
$verbose
private
bool
$verbose
= false
Methods
__construct()
Handler constructor.
public
__construct() : mixed
Return values
mixed —BasketChangeStatus()
Called on basket status change, reaction is needed on cancel
public
BasketChangeStatus( $req) : void
Parameters
Return values
void —GetAccessList()
public
GetAccessList(User $user) : array<string|int, mixed>
Parameters
- $user : User
Return values
array<string|int, mixed> —Handler()
Get handler instance
public
Handler() : Stripe|null
Return values
Stripe|null —Name()
public
Name() : string
Return values
string —OnAddOrUpdateContent()
Called on save an object
public
OnAddOrUpdateContent(HookArgument $param) : void
Update the user data in stripe on users modification
Parameters
- $param : HookArgument
-
A hook argument with user and result
Return values
void —OnAfterBasketRegisterUser()
public
OnAfterBasketRegisterUser(HookArgument $param) : void
Parameters
- $param : HookArgument
Return values
void —OnAfterMarkSubscriptionForSwitch()
public
OnAfterMarkSubscriptionForSwitch(HookArgument $param) : void
Parameters
- $param : HookArgument
Return values
void —OnAfterUserAdminSave()
Special operation when user was changed by admin and the subscription start date needs to change
public
OnAfterUserAdminSave(HookArgument $param) : void
Parameters
- $param : HookArgument
Return values
void —OnAfterUserLoginByPassword()
Called after registration of session, make sure to delete cached methods
public
OnAfterUserLoginByPassword(HookArgument $param) : void
Parameters
- $param : HookArgument
Return values
void —OnArticleGetRawPrice()
public
OnArticleGetRawPrice(HookArgument $param) : void
Parameters
- $param : HookArgument
Return values
void —OnBeforeMarkSubscriptionForSwitch()
public
OnBeforeMarkSubscriptionForSwitch(HookArgument $param) : void
Parameters
- $param : HookArgument
Return values
void —OnCheckBasketTransitions()
Process potentially automatic changes on baskets
public
OnCheckBasketTransitions(HookArgument $param) : void
Parameters
- $param : HookArgument
Return values
void —OnCommandLineInterfaceCall()
Cli to fix and check relation id duplications
public
OnCommandLineInterfaceCall( $param) : void
Parameters
Tags
Return values
void —OnDeleteContent()
React on basket delete
public
OnDeleteContent( $param) : void
Parameters
Return values
void —OnGetEntityAttributes()
Add input field to core object
public
OnGetEntityAttributes(HookArgument $reference) : void
Parameters
- $reference : HookArgument
Return values
void —OnMapArrayIncludes()
Add some scripts to the backend to interact with system frontend hooks
public
OnMapArrayIncludes( $param) : void
Parameters
Return values
void —OnMarkSubscriptionForTermination()
Register a plan to terminate the subscription at the nex possible end
public
OnMarkSubscriptionForTermination(HookArgument $param) : void
Parameters
- $param : HookArgument
Return values
void —OnRegisterWidgetIncludes()
Add custom scripts to certain widgets when present
public
OnRegisterWidgetIncludes( $param) : void
Parameters
Return values
void —OnSubscriptionChangePaymentMethod()
public
OnSubscriptionChangePaymentMethod(HookArgument $param) : void
Parameters
- $param : HookArgument
Return values
void —OnSubscriptionSwitch()
Handle a subscription model change operation
public
OnSubscriptionSwitch(HookArgument $param) : void
Parameters
- $param : HookArgument
Tags
Return values
void —RegisterHooks()
register system hooks Register a set of handler functions to be called in certain positions.
public
RegisterHooks() : array<string|int, mixed>
Return values
array<string|int, mixed> —A list of hooks to register
RegisterPublicAssetBasePath()
Provide deep link access to js template files
public
RegisterPublicAssetBasePath(HookArgument $reference) : void
Parameters
- $reference : HookArgument
Return values
void —RequestOnUrlParsed()
public
RequestOnUrlParsed(HookArgument $param) : mixed
Parameters
- $param : HookArgument
Return values
mixed —ServeRequest()
Serve request
public
ServeRequest(Request $request, Response $response) : mixed
Serve the request and return appropriate result.
Parameters
Return values
mixed —settings()
Get/Set the settings
public
settings([null|object $new = null ]) : Result|object
This method is cached per instance
Parameters
- $new : null|object = null
-
New set of settings to store
Return values
Result|object —SetupTemplate()
public
SetupTemplate([mixed $data = null ]) : mixed
Parameters
- $data : mixed = null
Tags
Return values
mixed —UpdateAccessProduct()
Send an update access price request based on a certain date If no date is given use the next regular phase
public
UpdateAccessProduct(Basket $basket[, bool $live = true ][, string|null $date = null ][, string|null $free_until_date = null ]) : Result
Parameters
- $basket : Basket
-
The basket to update
- $live : bool = true
-
Active external transition
- $date : string|null = null
-
Date of transition
- $free_until_date : string|null = null
Return values
Result —A system result
handleConfig()
Handle the context requests
protected
handleConfig(Request &$request, Response &$response) : void
Parameters
Return values
void —hasAccess()
Check if endpoint is accessible for this user group
protected
hasAccess(string|array<string|int, string> $right[, Response|null $response = null ][, User|null $user = null ]) : bool
Parameters
Return values
bool —isInContext()
Is in certain context?
protected
isInContext(HookArgument $param, string $type, string $widget) : bool
Parameters
- $param : HookArgument
-
The hook argument
- $type : string
-
The type can be scss, css and js to search in widgets or _ to search in global includes
- $widget : string
-
The widget to search for
Return values
bool —setupAttributes()
Set up the permission attribute table
protected
setupAttributes( &$attributes, $l) : void
Parameters
Return values
void —basePath()
Resolve the stripe dashboard base path
private
basePath([string|null $mode = null ]) : string
Parameters
- $mode : string|null = null
-
Either test or live, when not set we use the configured default
Return values
string —The base path with domain and protocol
correctAnchorPoint()
private
correctAnchorPoint(Basket $subs[, bool $exec = true ]) : Result
Parameters
- $subs : Basket
- $exec : bool = true
Return values
Result —createFromOriginal()
private
createFromOriginal(Basket $subs) : Result
Parameters
- $subs : Basket
Return values
Result —handleAttachUserPaymentMethod()
Attach method to customer
private
handleAttachUserPaymentMethod(string $id, string $method_id, Response $resp) : void
Parameters
- $id : string
- $method_id : string
- $resp : Response
Return values
void —handleConfigPreset()
Handle the context requests
private
handleConfigPreset(Request $request, Response $response) : mixed
Parameters
Return values
mixed —handleEndTrail()
private
handleEndTrail(User|null $user, Response $response) : void
Parameters
Return values
void —handleListCustomer()
Get customer data by customer id
private
handleListCustomer(string $id, Response $resp) : void
Parameters
- $id : string
- $resp : Response
Return values
void —handleListUserInvoices()
Fetch invoices of a user
private
handleListUserInvoices(User $user, Response $resp, Request $request) : void
Parameters
Return values
void —handleListUserPaymentMethods()
Get users payment methods
private
handleListUserPaymentMethods(string $id, Response $resp, Request $request[, bool $self = false ]) : void
Will add temporarily prepared methods as well
Parameters
Return values
void —handlePriceFetch()
Get resolved price
private
handlePriceFetch(Request $request, Response $response) : void
Parameters
Return values
void —handlePriceList()
Get list of prices
private
handlePriceList(Request $request, Response $response) : void
Parameters
Return values
void —handleRegisterAsConnected()
private
handleRegisterAsConnected(string $action, string $id, Response $response, Request $request) : void
Parameters
Return values
void —handleRegisterCustomer()
Register customer or get relevant customer object when linked
private
handleRegisterCustomer(Request $request, string $id, Response $resp) : mixed
Parameters
Return values
mixed —handleReplacePSP()
Replace the payment service provider with stripe
private
handleReplacePSP(string $id, array<string|int, mixed> $body, Response $resp) : void
Only as customer and only for subscriptions
Parameters
- $id : string
-
The Original basket id
- $body : array<string|int, mixed>
-
The payload from form like register
- $resp : Response
-
Response object
Return values
void —handleSettings()
private
handleSettings(Request $request, string $mode, Response $resp) : mixed
Parameters
Return values
mixed —handleSetupIntent()
private
handleSetupIntent(string|null $id, Response $resp) : mixed
Parameters
- $id : string|null
- $resp : Response
Return values
mixed —handleSetupIntentComplete()
Complete a setup intent
private
handleSetupIntentComplete(Request $request, string|null $id, Response $resp) : void
Either link a payment method to a customer or, make sure it is logged in session for further use
Parameters
- $request : Request
-
The request object
- $id : string|null
-
The user id or null
- $resp : Response
-
The response
Return values
void —handleUsersCompanies()
private
handleUsersCompanies(Response $response, Request $request) : void
Parameters
Return values
void —handleViewBasketPayment()
View single payment by payment intent id
private
handleViewBasketPayment(string|null $id, Response $resp) : void
Parameters
- $id : string|null
- $resp : Response
Return values
void —handleViewBasketRefunds()
Get list of known refunds
private
handleViewBasketRefunds(string $id, Response $resp) : void
Parameters
- $id : string
- $resp : Response
Return values
void —handleWebhook()
Handle the web hook event
private
handleWebhook(Event $event) : Result
Parameters
- $event : Event
Return values
Result —mapInvoice()
Convert invoice to our object scheme
private
mapInvoice(Invoice $given) : array<string|int, mixed>
Parameters
- $given : Invoice
Return values
array<string|int, mixed> —mapPaymentMethods()
Map the found payment methods to our structures signature
private
mapPaymentMethods(Result $res, Response $resp) : void