Skip to content

Commit

Permalink
MDL-7537 add all PayPal supported currencies
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Dec 23, 2012
1 parent 0dc5a53 commit 0456edb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
8 changes: 1 addition & 7 deletions enrol/paypal/edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,7 @@ function definition() {
$mform->addElement('text', 'cost', get_string('cost', 'enrol_paypal'), array('size'=>4));
$mform->setDefault('cost', $plugin->get_config('cost'));

$paypalcurrencies = array('USD' => 'US Dollars',
'EUR' => 'Euros',
'JPY' => 'Japanese Yen',
'GBP' => 'British Pounds',
'CAD' => 'Canadian Dollars',
'AUD' => 'Australian Dollars'
);
$paypalcurrencies = $plugin->get_currencies();
$mform->addElement('select', 'currency', get_string('currency', 'enrol_paypal'), $paypalcurrencies);
$mform->setDefault('currency', $plugin->get_config('currency'));

Expand Down
14 changes: 14 additions & 0 deletions enrol/paypal/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@
*/
class enrol_paypal_plugin extends enrol_plugin {

public function get_currencies() {
// See https://www.paypal.com/cgi-bin/webscr?cmd=p/sell/mc/mc_intro-outside,
// 3-character ISO-4217: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_currency_codes
$codes = array(
'AUD', 'BRL', 'CAD', 'CHF', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'ILS', 'JPY',
'MXN', 'MYR', 'NOK', 'NZD', 'PHP', 'PLN', 'SEK', 'SGD', 'THB', 'TRY', 'TWD', 'USD');
$currencies = array();
foreach ($codes as $c) {
$currencies[$c] = new lang_string($c, 'core_currencies');
}

return $currencies;
}

/**
* Returns optional enrolment information icons.
*
Expand Down
8 changes: 1 addition & 7 deletions enrol/paypal/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,7 @@

$settings->add(new admin_setting_configtext('enrol_paypal/cost', get_string('cost', 'enrol_paypal'), '', 0, PARAM_FLOAT, 4));

$paypalcurrencies = array('USD' => 'US Dollars',
'EUR' => 'Euros',
'JPY' => 'Japanese Yen',
'GBP' => 'British Pounds',
'CAD' => 'Canadian Dollars',
'AUD' => 'Australian Dollars'
);
$paypalcurrencies = enrol_get_plugin('paypal')->get_currencies();
$settings->add(new admin_setting_configselect('enrol_paypal/currency', get_string('currency', 'enrol_paypal'), '', 'USD', $paypalcurrencies));

if (!during_initial_install()) {
Expand Down

0 comments on commit 0456edb

Please sign in to comment.