Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]
Contains helper class for the payment subsystem.
Copyright: | 2019 Shamim Rezaie <shamim@moodle.com> |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 399 lines (15 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
helper:: (18 methods):
get_supported_currencies()
get_available_gateways()
get_rounded_cost()
get_cost_as_string()
get_gateway_surcharge()
gateways_modal_link_params()
get_service_provider_classname()
get_payable()
get_gateway_configuration()
deliver_order()
save_payment()
add_common_gateway_settings()
save_payment_account()
delete_payment_account()
restore_payment_account()
save_payment_gateway()
get_payment_accounts_to_manage()
get_payment_accounts_menu()
get_supported_currencies() X-Ref |
Returns an accumulated list of supported currencies by all payment gateways. return: string[] An array of the currency codes in the three-character ISO-4217 format |
get_available_gateways(string $component, string $paymentarea, int $itemid) X-Ref |
Returns the list of gateways that can process payments in the given currency. param: string $component param: string $paymentarea param: int $itemid return: string[] |
get_rounded_cost(float $amount, string $currency, float $surcharge = 0) X-Ref |
Rounds the cost based on the currency fractional digits, can also apply surcharge param: float $amount amount in the currency units param: string $currency currency, used for calculating the number of fractional digits param: float $surcharge surcharge in percents return: float |
get_cost_as_string(float $amount, string $currency, float $surcharge = 0) X-Ref |
Returns human-readable amount with correct number of fractional digits and currency indicator, can also apply surcharge param: float $amount amount in the currency units param: string $currency The currency param: float $surcharge surcharge in percents return: string |
get_gateway_surcharge(string $gateway) X-Ref |
Returns the percentage of surcharge that is applied when using a gateway param: string $gateway Name of the gateway return: float |
gateways_modal_link_params(string $component, string $paymentarea, int $itemid,string $description) X-Ref |
Returns the attributes to place on a pay button. param: string $component Name of the component that the itemid belongs to param: string $paymentarea param: int $itemid An internal identifier that is used by the component param: string $description Description of the payment return: array |
get_service_provider_classname(string $component) X-Ref |
param: string $component return: string |
get_payable(string $component, string $paymentarea, int $itemid) X-Ref |
Asks the payable from the related component. param: string $component Name of the component that the itemid belongs to param: string $paymentarea param: int $itemid An internal identifier that is used by the component return: local\entities\payable |
get_gateway_configuration(string $component, string $paymentarea, int $itemid,string $gatewayname) X-Ref |
Returns the gateway configuration for given component and gateway param: string $component param: string $paymentarea param: int $itemid param: string $gatewayname return: array |
deliver_order(string $component, string $paymentarea, int $itemid, int $paymentid, int $userid) X-Ref |
Delivers what the user paid for. param: string $component Name of the component that the itemid belongs to param: string $paymentarea param: int $itemid An internal identifier that is used by the component param: int $paymentid payment id as inserted into the 'payments' table, if needed for reference param: int $userid The userid the order is going to deliver to return: bool Whether successful or not |
save_payment(int $accountid, string $component, string $paymentarea, int $itemid, int $userid,float $amount, string $currency, string $gateway) X-Ref |
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. param: int $accountid Account id param: string $component Name of the component that the itemid belongs to param: string $paymentarea param: int $itemid An internal identifier that is used by the component param: int $userid Id of the user who is paying param: float $amount Amount of payment param: string $currency Currency of payment param: string $gateway The gateway that is used for the payment return: int |
add_common_gateway_settings(\admin_settingpage $settings, string $gateway) X-Ref |
This functions adds the settings that are common for all payment gateways. param: \admin_settingpage $settings The settings object param: string $gateway The gateway name prefixed with paygw_ |
save_payment_account(\stdClass $data) X-Ref |
Save a new or edited payment account (used in management interface) param: \stdClass $data return: account |
delete_payment_account(account $account) X-Ref |
Delete a payment account (used in management interface) param: account $account |
restore_payment_account(account $account) X-Ref |
Restore archived payment account (used in management interface) param: account $account |
save_payment_gateway(\stdClass $data) X-Ref |
Save a payment gateway linked to an existing account (used in management interface) param: \stdClass $data return: account_gateway |
get_payment_accounts_to_manage(\context $context, bool $showarchived = false) X-Ref |
Returns the list of payment accounts in the given context (used in management interface) param: \context $context return: account[] |
get_payment_accounts_menu(\context $context) X-Ref |
Get list of accounts available in the given context param: \context $context return: array |