B2G/gecko/dom/payment/Payment.jsm
/**
   * Helper function to register payment providers stored as preferences.
   */
Helper function to register payment providers stored as preferences.
Helper function to register payment providers stored as preferences .
function registerPaymentProviders() {
    let paymentProviders = prefService
                           .getBranch(PREF_PAYMENTPROVIDERS_BRANCH)
                           .getChildList("");
    let nums = [];
    for (let i in paymentProviders) {
      let match = /^(\d+)\.uri$/.exec(paymentProviders[i]);
      if (!match) {
        continue;
      } else {
        nums.push(match[1]);
      }
    }
    for (let i in nums) {
      let branch = prefService
                   .getBranch(PREF_PAYMENTPROVIDERS_BRANCH + nums[i] + ".");
      let vals = branch.getChildList("");
      if (vals.length == 0) {
        return;
      }
      try {
        let type = branch.getCharPref("type");
        if (type in this.registeredProviders) {
          continue;
        }
        this.registeredProviders[type] = {
          name: branch.getCharPref("name"),
          uri: branch.getCharPref("uri"),
          description: branch.getCharPref("description"),
          requestMethod: branch.getCharPref("requestMethod")
        };
        debug("Registered Payment Providers: " +
              JSON.stringify(this.registeredProviders[type]));
      } catch (ex) {
        debug("An error ocurred registering a payment provider. " + ex);
      }
    }
  }
function registerPaymentProviders ( ) { let paymentProviders = prefService . getBranch ( PREF_PAYMENTPROVIDERS_BRANCH ) . getChildList ( "" ) ; let nums = [ ] ; for ( let i in paymentProviders ) { let match = / ^(\d+)\.uri$ / . exec ( paymentProviders [ i ] ) ; if ( ! match ) { continue ; } else { nums . push ( match [ 1 ] ) ; } } for ( let i in nums ) { let branch = prefService . getBranch ( PREF_PAYMENTPROVIDERS_BRANCH + nums [ i ] + "." ) ; let vals = branch . getChildList ( "" ) ; if ( vals . length == 0 ) { return ; } try { let type = branch . getCharPref ( "type" ) ; if ( type in this . registeredProviders ) { continue ; } this . registeredProviders [ type ] = { name : branch . getCharPref ( "name" ) , uri : branch . getCharPref ( "uri" ) , description : branch . getCharPref ( "description" ) , requestMethod : branch . getCharPref ( "requestMethod" ) } ; debug ( "Registered Payment Providers: " + JSON . stringify ( this . registeredProviders [ type ] ) ) ; } catch ( ex ) { debug ( "An error ocurred registering a payment provider. " + ex ) ; } } }
Helper function to register payment providers stored as preferences.
Helper function to register payment providers stored as preferences .
// First get the numbers of the providers by getting all ###.uri prefs. // Now register the payment providers.