Making WordPress.org

Changeset 4913


Ignore:
Timestamp:
02/16/2017 09:32:03 PM (8 years ago)
Author:
iandunn
Message:

CampTix Tweaks: Open-source the registration of pre-defined PayPal credentials

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/camptix-tweaks.php

    r4912 r4913  
    88// Tickets
    99add_action( 'camptix_admin_notices',                         __NAMESPACE__ . '\show_sandbox_mode_warning'           );
     10add_filter( 'camptix_dashboard_paypal_credentials',          __NAMESPACE__ . '\paypal_credentials'                  );
     11add_filter( 'camptix_paypal_predefined_accounts',            __NAMESPACE__ . '\paypal_credentials'                  );
    1012add_action( 'init',                                          __NAMESPACE__ . '\hide_empty_tickets'                  );
    1113add_action( 'wp_print_styles',                               __NAMESPACE__ . '\print_login_message_styles'          );
     
    7577        }
    7678    }
     79}
     80
     81/**
     82 * Setup our pre-defined payment credentials
     83 *
     84 * @param array $credentials
     85 *
     86 * @return array
     87 */
     88function paypal_credentials( $credentials ) {
     89    // Sandbox account
     90    $credentials = array(
     91        "wordcamp-sandbox" => array(
     92            'label'         => "WordCamp Sandbox",
     93            'sandbox'       => true,
     94            'api_username'  => defined( 'WC_SANDBOX_PAYPAL_NVP_USERNAME'  ) ? WC_SANDBOX_PAYPAL_NVP_USERNAME  : '',
     95            'api_password'  => defined( 'WC_SANDBOX_PAYPAL_NVP_PASSWORD'  ) ? WC_SANDBOX_PAYPAL_NVP_PASSWORD  : '',
     96            'api_signature' => defined( 'WC_SANDBOX_PAYPAL_NVP_SIGNATURE' ) ? WC_SANDBOX_PAYPAL_NVP_SIGNATURE : '',
     97        ),
     98    );
     99
     100    /*
     101     * Live API credentials for WordPress Community Support, PBC
     102     *
     103     * This still uses the old 'foundation' array index in order to maintain backwards-compatibility. When an
     104     * organizer saves the form on the Tickets > Setup > Payment screen, an option is saved with the key of the
     105     * selected pre-defined credentials, which correspond to the indexes in the $credentials array. If those keys
     106     * are ever changed, that would break the mapping for sites that that were previously saved using the old key.
     107     */
     108    if ( defined( 'WPCS_PAYPAL_NVP_USERNAME' ) ) {
     109        $credentials['foundation'] = array(
     110            'label'         => 'WordPress Community Support, PBC',
     111            'sandbox'       => false,
     112            'api_username'  => WPCS_PAYPAL_NVP_USERNAME,
     113            'api_password'  => WPCS_PAYPAL_NVP_PASSWORD,
     114            'api_signature' => WPCS_PAYPAL_NVP_SIGNATURE,
     115        );
     116    }
     117
     118    return $credentials;
    77119}
    78120
Note: See TracChangeset for help on using the changeset viewer.