Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
core_payment\helper Class Reference

Helper class for the payment subsystem. More...

Static Public Member Functions

static add_common_gateway_settings (\admin_settingpage $settings, string $gateway)
 This functions adds the settings that are common for all payment gateways.
 
static delete_payment_account (account $account)
 Delete a payment account (used in management interface)
 
static deliver_order (string $component, string $paymentarea, int $itemid, int $paymentid, int $userid)
 Delivers what the user paid for.
 
static gateways_modal_link_params (string $component, string $paymentarea, int $itemid, string $description)
 Returns the attributes to place on a pay button.
 
static get_available_gateways (string $component, string $paymentarea, int $itemid)
 Returns the list of gateways that can process payments in the given currency.
 
static get_cost_as_string (float $amount, string $currency, float $surcharge=0)
 Returns human-readable amount with correct number of fractional digits and currency indicator, can also apply surcharge.
 
static get_gateway_configuration (string $component, string $paymentarea, int $itemid, string $gatewayname)
 Returns the gateway configuration for given component and gateway.
 
static get_gateway_surcharge (string $gateway)
 Returns the percentage of surcharge that is applied when using a gateway.
 
static get_payable (string $component, string $paymentarea, int $itemid)
 Asks the payable from the related component.
 
static get_payment_accounts_menu (\context $context)
 Get list of accounts available in the given context.
 
static get_payment_accounts_to_manage (\context $context, bool $showarchived=false)
 Returns the list of payment accounts in the given context (used in management interface)
 
static get_rounded_cost (float $amount, string $currency, float $surcharge=0)
 Rounds the cost based on the currency fractional digits, can also apply surcharge.
 
static get_success_url (string $component, string $paymentarea, int $itemid)
 Fetches the URL of the page the user should be redirected to from the related component.
 
static get_supported_currencies ()
 Returns an accumulated list of supported currencies by all payment gateways.
 
static restore_payment_account (account $account)
 Restore archived payment account (used in management interface)
 
static save_payment (int $accountid, string $component, string $paymentarea, int $itemid, int $userid, float $amount, string $currency, string $gateway)
 Stores essential information about the payment and returns the "id" field of the payment record in DB.
 
static save_payment_account (\stdClass $data)
 Save a new or edited payment account (used in management interface)
 
static save_payment_gateway (\stdClass $data)
 Save a payment gateway linked to an existing account (used in management interface)
 

Detailed Description

Helper class for the payment subsystem.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ add_common_gateway_settings()

static core_payment\helper::add_common_gateway_settings ( \admin_settingpage $settings,
string $gateway )
static

This functions adds the settings that are common for all payment gateways.

Parameters
admin_settingpage$settingsThe settings object
string$gatewayThe gateway name prefixed with paygw_

◆ delete_payment_account()

static core_payment\helper::delete_payment_account ( account $account)
static

Delete a payment account (used in management interface)

Parameters
account$account

◆ deliver_order()

static core_payment\helper::deliver_order ( string $component,
string $paymentarea,
int $itemid,
int $paymentid,
int $userid )
static

Delivers what the user paid for.

@uses core_payment\local\callback\service_provider\deliver_order()

Parameters
string$componentName of the component that the paymentarea and itemid belong to
string$paymentareaPayment area
int$itemidAn internal identifier that is used by the component
int$paymentidpayment id as inserted into the 'payments' table, if needed for reference
int$useridThe userid the order is going to deliver to
Return values
boolWhether successful or not

◆ gateways_modal_link_params()

static core_payment\helper::gateways_modal_link_params ( string $component,
string $paymentarea,
int $itemid,
string $description )
static

Returns the attributes to place on a pay button.

Parameters
string$componentName of the component that the paymentarea and itemid belong to
string$paymentareaPayment area
int$itemidAn internal identifier that is used by the component
string$descriptionDescription of the payment
Return values
array

◆ get_available_gateways()

static core_payment\helper::get_available_gateways ( string $component,
string $paymentarea,
int $itemid )
static

Returns the list of gateways that can process payments in the given currency.

Parameters
string$componentName of the component that the paymentarea and itemid belong to
string$paymentareaPayment area
int$itemidAn identifier that is known to the component
Return values
string[]

◆ get_cost_as_string()

static core_payment\helper::get_cost_as_string ( float $amount,
string $currency,
float $surcharge = 0 )
static

Returns human-readable amount with correct number of fractional digits and currency indicator, can also apply surcharge.

Parameters
float$amountamount in the currency units
string$currencyThe currency
float$surchargesurcharge in percents
Return values
string

◆ get_gateway_configuration()

static core_payment\helper::get_gateway_configuration ( string $component,
string $paymentarea,
int $itemid,
string $gatewayname )
static

Returns the gateway configuration for given component and gateway.

Parameters
string$componentName of the component that the paymentarea and itemid belong to
string$paymentareaPayment area
int$itemidAn identifier that is known to the component
string$gatewaynameThe gateway name
Return values
array
Exceptions
moodle_exception

◆ get_gateway_surcharge()

static core_payment\helper::get_gateway_surcharge ( string $gateway)
static

Returns the percentage of surcharge that is applied when using a gateway.

Parameters
string$gatewayName of the gateway
Return values
float

◆ get_payable()

static core_payment\helper::get_payable ( string $component,
string $paymentarea,
int $itemid )
static

Asks the payable from the related component.

Parameters
string$componentName of the component that the paymentarea and itemid belong to
string$paymentareaPayment area
int$itemidAn internal identifier that is used by the component
Return values
local\entities\payable

◆ get_payment_accounts_menu()

static core_payment\helper::get_payment_accounts_menu ( \context $context)
static

Get list of accounts available in the given context.

Parameters
context$context
Return values
array

◆ get_payment_accounts_to_manage()

static core_payment\helper::get_payment_accounts_to_manage ( \context $context,
bool $showarchived = false )
static

Returns the list of payment accounts in the given context (used in management interface)

Parameters
context$context
Return values
account[]

◆ get_rounded_cost()

static core_payment\helper::get_rounded_cost ( float $amount,
string $currency,
float $surcharge = 0 )
static

Rounds the cost based on the currency fractional digits, can also apply surcharge.

Parameters
float$amountamount in the currency units
string$currencycurrency, used for calculating the number of fractional digits
float$surchargesurcharge in percents
Return values
float

◆ get_success_url()

static core_payment\helper::get_success_url ( string $component,
string $paymentarea,
int $itemid )
static

Fetches the URL of the page the user should be redirected to from the related component.

Parameters
string$componentName of the component that the paymentarea and itemid belong to
string$paymentareaPayment area
int$itemidAn identifier that is known to the component
Return values
moodle_url

◆ get_supported_currencies()

static core_payment\helper::get_supported_currencies ( )
static

Returns an accumulated list of supported currencies by all payment gateways.

Return values
string[]An array of the currency codes in the three-character ISO-4217 format

◆ restore_payment_account()

static core_payment\helper::restore_payment_account ( account $account)
static

Restore archived payment account (used in management interface)

Parameters
account$account

◆ save_payment()

static core_payment\helper::save_payment ( int $accountid,
string $component,
string $paymentarea,
int $itemid,
int $userid,
float $amount,
string $currency,
string $gateway )
static

Stores essential information about the payment and returns the "id" field of the payment record in DB.

Each payment gateway may then store the additional information their way.

Parameters
int$accountidAccount id
string$componentName of the component that the paymentarea and itemid belong to
string$paymentareaPayment area
int$itemidAn internal identifier that is used by the component
int$useridId of the user who is paying
float$amountAmount of payment
string$currencyCurrency of payment
string$gatewayThe gateway that is used for the payment
Return values
int

◆ save_payment_account()

static core_payment\helper::save_payment_account ( \stdClass $data)
static

Save a new or edited payment account (used in management interface)

Parameters
stdClass$data
Return values
account

◆ save_payment_gateway()

static core_payment\helper::save_payment_gateway ( \stdClass $data)
static

Save a payment gateway linked to an existing account (used in management interface)

Parameters
stdClass$data
Return values
account_gateway

The documentation for this class was generated from the following file: