function uc_credit_default_gateway in Ubercart 7.3
Same name and namespace in other branches
- 5 payment/uc_credit/uc_credit.module \uc_credit_default_gateway()
- 6.2 payment/uc_credit/uc_credit.module \uc_credit_default_gateway()
Retrieves the ID of the default credit card gateway.
Return value
string|false A string containing the ID of the default gateway or FALSE if none exists or none have valid credit callbacks.
3 calls to uc_credit_default_gateway()
- uc_credit_settings_form in payment/
uc_credit/ uc_credit.admin.inc - Credit card settings form.
- uc_credit_terminal_form in payment/
uc_credit/ uc_credit.admin.inc - Displays the credit card terminal form for administrators.
- uc_credit_uc_order in payment/
uc_credit/ uc_credit.module - Implements hook_uc_order().
File
- payment/
uc_credit/ uc_credit.module, line 1013 - Defines the credit card payment method and hooks in payment gateways.
Code
function uc_credit_default_gateway() {
// Get an array of enabled payment gateways available for the payment method.
$gateways = _uc_payment_gateway_list('credit', TRUE);
// Return FALSE if we found no gateways.
if (empty($gateways)) {
return FALSE;
}
// Find the default gateway, or otherwise choose the first available.
$default = variable_get('uc_payment_credit_gateway', 'none');
$gateway = isset($gateways[$default]) ? $gateways[$default] : reset($gateways);
// Return FALSE if the credit callback does not exist.
return function_exists($gateway['credit']) ? $gateway['id'] : FALSE;
}