OAuthTemplates
extends AutoService
in package
Automatically link an OAuth token with a PaymentProcessor.
Usage:
- In the OAuthProvider JSON, specify the
templates['PaymentProcessor']. This is a list ofPaymentProcessorproperties to initialize. Ex: ['user_name' => '{{token.raw.stripe_publishable_key}}', 'password' => '{{token.access_token}}'] - Initiate OAuth process and set the relevant payment-processor. Ex: OAuthClient::authorizationCode()->setTag('PaymentProcessor:123')->...execute()
- Whenever this token is initialized or refreshed, this helper will
update the
user_nameandpasswordforPaymentProcessor:123.
Tags
Table of Contents
Methods
- evaluate() : array<string|int, mixed>
- Evaluate an array and interpolating bits of data.
- getByClientId() : array<string|int, mixed>|null
- Determine which (if any) template is available for a given client.
Methods
evaluate()
Evaluate an array and interpolating bits of data.
public
evaluate(array<string|int, mixed> $template, array<string|int, mixed> $vars) : array<string|int, mixed>
Parameters
- $template : array<string|int, mixed>
-
List of key-value expressions. Ex: ['name' => '{{person.first}} {{person.last}}'] Expressions begin with the dotted-name of a variable. Optionally, the value may be piped through other functions
- $vars : array<string|int, mixed>
-
Array tree of data to interpolate.
Return values
array<string|int, mixed> —The template array, with '{{...}}' expressions evaluated.
getByClientId()
Determine which (if any) template is available for a given client.
public
getByClientId(int $clientId, string $template) : array<string|int, mixed>|null
TODO: Support contact and mail-settings. Migrate 'contactTemplate' and 'mailSettingsTemplate' to generic 'templates'.
Parameters
- $clientId : int
-
Local ID of the OAuthClient
- $template : string
-
Symbolic name of the template.