Overview
  • Namespace
  • Class

Namespaces

  • PayPal
    • Api
    • Auth
    • Cache
    • Common
    • Converter
    • Core
    • Exception
    • Handler
    • Log
    • Rest
    • Security
    • Transport
    • Validation

Classes

  • PayPal\Api\Address
  • PayPal\Api\Agreement
  • PayPal\Api\AgreementDetails
  • PayPal\Api\AgreementStateDescriptor
  • PayPal\Api\AgreementTransaction
  • PayPal\Api\AgreementTransactions
  • PayPal\Api\AlternatePayment
  • PayPal\Api\Amount
  • PayPal\Api\Authorization
  • PayPal\Api\BankAccount
  • PayPal\Api\BankAccountsList
  • PayPal\Api\BankToken
  • PayPal\Api\BaseAddress
  • PayPal\Api\Billing
  • PayPal\Api\BillingAgreementToken
  • PayPal\Api\BillingInfo
  • PayPal\Api\CancelNotification
  • PayPal\Api\Capture
  • PayPal\Api\CarrierAccount
  • PayPal\Api\CarrierAccountToken
  • PayPal\Api\CartBase
  • PayPal\Api\ChargeModel
  • PayPal\Api\Cost
  • PayPal\Api\CountryCode
  • PayPal\Api\CreateProfileResponse
  • PayPal\Api\Credit
  • PayPal\Api\CreditCard
  • PayPal\Api\CreditCardHistory
  • PayPal\Api\CreditCardList
  • PayPal\Api\CreditCardToken
  • PayPal\Api\CreditFinancingOffered
  • PayPal\Api\Currency
  • PayPal\Api\CurrencyConversion
  • PayPal\Api\CustomAmount
  • PayPal\Api\DetailedRefund
  • PayPal\Api\Details
  • PayPal\Api\Error
  • PayPal\Api\ErrorDetails
  • PayPal\Api\ExtendedBankAccount
  • PayPal\Api\ExternalFunding
  • PayPal\Api\FileAttachment
  • PayPal\Api\FlowConfig
  • PayPal\Api\FmfDetails
  • PayPal\Api\FundingDetail
  • PayPal\Api\FundingInstrument
  • PayPal\Api\FundingOption
  • PayPal\Api\FundingSource
  • PayPal\Api\FuturePayment
  • PayPal\Api\HyperSchema
  • PayPal\Api\Image
  • PayPal\Api\Incentive
  • PayPal\Api\InputFields
  • PayPal\Api\InstallmentInfo
  • PayPal\Api\InstallmentOption
  • PayPal\Api\Invoice
  • PayPal\Api\InvoiceAddress
  • PayPal\Api\InvoiceItem
  • PayPal\Api\InvoiceNumber
  • PayPal\Api\InvoiceSearchResponse
  • PayPal\Api\Item
  • PayPal\Api\ItemList
  • PayPal\Api\Links
  • PayPal\Api\Measurement
  • PayPal\Api\MerchantInfo
  • PayPal\Api\MerchantPreferences
  • PayPal\Api\Metadata
  • PayPal\Api\NameValuePair
  • PayPal\Api\Notification
  • PayPal\Api\OpenIdAddress
  • PayPal\Api\OpenIdError
  • PayPal\Api\OpenIdSession
  • PayPal\Api\OpenIdTokeninfo
  • PayPal\Api\OpenIdUserinfo
  • PayPal\Api\Order
  • PayPal\Api\OverrideChargeModel
  • PayPal\Api\Participant
  • PayPal\Api\Patch
  • PayPal\Api\PatchRequest
  • PayPal\Api\Payee
  • PayPal\Api\Payer
  • PayPal\Api\PayerInfo
  • PayPal\Api\Payment
  • PayPal\Api\PaymentCard
  • PayPal\Api\PaymentCardToken
  • PayPal\Api\PaymentDefinition
  • PayPal\Api\PaymentDetail
  • PayPal\Api\PaymentExecution
  • PayPal\Api\PaymentHistory
  • PayPal\Api\PaymentInstruction
  • PayPal\Api\PaymentOptions
  • PayPal\Api\PaymentSummary
  • PayPal\Api\PaymentTerm
  • PayPal\Api\Payout
  • PayPal\Api\PayoutBatch
  • PayPal\Api\PayoutBatchHeader
  • PayPal\Api\PayoutItem
  • PayPal\Api\PayoutItemDetails
  • PayPal\Api\PayoutSenderBatchHeader
  • PayPal\Api\Phone
  • PayPal\Api\Plan
  • PayPal\Api\PlanList
  • PayPal\Api\PotentialPayerInfo
  • PayPal\Api\Presentation
  • PayPal\Api\PrivateLabelCard
  • PayPal\Api\ProcessorResponse
  • PayPal\Api\RecipientBankingInstruction
  • PayPal\Api\RedirectUrls
  • PayPal\Api\Refund
  • PayPal\Api\RefundDetail
  • PayPal\Api\RefundRequest
  • PayPal\Api\RelatedResources
  • PayPal\Api\Sale
  • PayPal\Api\Search
  • PayPal\Api\ShippingAddress
  • PayPal\Api\ShippingCost
  • PayPal\Api\ShippingInfo
  • PayPal\Api\Tax
  • PayPal\Api\Template
  • PayPal\Api\TemplateData
  • PayPal\Api\Templates
  • PayPal\Api\TemplateSettings
  • PayPal\Api\TemplateSettingsMetadata
  • PayPal\Api\Terms
  • PayPal\Api\Transaction
  • PayPal\Api\TransactionBase
  • PayPal\Api\Transactions
  • PayPal\Api\VerifyWebhookSignature
  • PayPal\Api\VerifyWebhookSignatureResponse
  • PayPal\Api\Webhook
  • PayPal\Api\WebhookEvent
  • PayPal\Api\WebhookEventList
  • PayPal\Api\WebhookEventType
  • PayPal\Api\WebhookEventTypeList
  • PayPal\Api\WebhookList
  • PayPal\Api\WebProfile
  • PayPal\Auth\OAuthTokenCredential
  • PayPal\Cache\AuthorizationCache
  • PayPal\Common\ArrayUtil
  • PayPal\Common\PayPalModel
  • PayPal\Common\PayPalResourceModel
  • PayPal\Common\PayPalUserAgent
  • PayPal\Common\ReflectionUtil
  • PayPal\Converter\FormatConverter
  • PayPal\Core\PayPalConfigManager
  • PayPal\Core\PayPalConstants
  • PayPal\Core\PayPalCredentialManager
  • PayPal\Core\PayPalHttpConfig
  • PayPal\Core\PayPalHttpConnection
  • PayPal\Core\PayPalLoggingManager
  • PayPal\Handler\OauthHandler
  • PayPal\Handler\RestHandler
  • PayPal\Log\PayPalDefaultLogFactory
  • PayPal\Log\PayPalLogger
  • PayPal\Rest\ApiContext
  • PayPal\Security\Cipher
  • PayPal\Transport\PayPalRestCall
  • PayPal\Validation\ArgumentValidator
  • PayPal\Validation\JsonValidator
  • PayPal\Validation\NumericValidator
  • PayPal\Validation\UrlValidator

Interfaces

  • PayPal\Handler\IPayPalHandler
  • PayPal\Log\PayPalLogFactory
  • PayPal\Rest\IResource

Exceptions

  • PayPal\Exception\PayPalConfigurationException
  • PayPal\Exception\PayPalConnectionException
  • PayPal\Exception\PayPalInvalidCredentialException
  • PayPal\Exception\PayPalMissingCredentialException
  1 <?php
  2 
  3 namespace PayPal\Core;
  4 
  5 /**
  6  * Class PayPalConfigManager
  7  *
  8  * PayPalConfigManager loads the SDK configuration file and
  9  * hands out appropriate config params to other classes
 10  *
 11  * @package PayPal\Core
 12  */
 13 class PayPalConfigManager
 14 {
 15 
 16     /**
 17      * Configuration Options
 18      *
 19      * @var array
 20      */
 21     private $configs = array(
 22     );
 23 
 24     /**
 25      * Singleton Object
 26      *
 27      * @var $this
 28      */
 29     private static $instance;
 30 
 31     /**
 32      * Private Constructor
 33      */
 34     private function __construct()
 35     {
 36         if (defined('PP_CONFIG_PATH')) {
 37             $configFile = constant('PP_CONFIG_PATH') . '/sdk_config.ini';
 38         } else {
 39             $configFile = implode(DIRECTORY_SEPARATOR,
 40                 array(dirname(__FILE__), "..", "config", "sdk_config.ini"));
 41         }
 42         if (file_exists($configFile)) {
 43             $this->addConfigFromIni($configFile);
 44         }
 45     }
 46 
 47     /**
 48      * Returns the singleton object
 49      *
 50      * @return $this
 51      */
 52     public static function getInstance()
 53     {
 54         if (!isset(self::$instance)) {
 55             self::$instance = new self();
 56         }
 57         return self::$instance;
 58     }
 59 
 60     /**
 61      * Add Configuration from configuration.ini files
 62      *
 63      * @param string $fileName
 64      * @return $this
 65      */
 66     public function addConfigFromIni($fileName)
 67     {
 68         if ($configs = parse_ini_file($fileName)) {
 69             $this->addConfigs($configs);
 70         }
 71         return $this;
 72     }
 73 
 74     /**
 75      * If a configuration exists in both arrays,
 76      * then the element from the first array will be used and
 77      * the matching key's element from the second array will be ignored.
 78      *
 79      * @param array $configs
 80      * @return $this
 81      */
 82     public function addConfigs($configs = array())
 83     {
 84         $this->configs = $configs + $this->configs;
 85         return $this;
 86     }
 87 
 88     /**
 89      * Simple getter for configuration params
 90      * If an exact match for key is not found,
 91      * does a "contains" search on the key
 92      *
 93      * @param string $searchKey
 94      * @return array
 95      */
 96     public function get($searchKey)
 97     {
 98         if (array_key_exists($searchKey, $this->configs)) {
 99             return $this->configs[$searchKey];
100         } else {
101             $arr = array();
102             if ($searchKey !== '') {
103                 foreach ($this->configs as $k => $v) {
104                     if (strstr($k, $searchKey)) {
105                         $arr[$k] = $v;
106                     }
107                 }
108             }
109 
110             return $arr;
111         }
112     }
113 
114     /**
115      * Utility method for handling account configuration
116      * return config key corresponding to the API userId passed in
117      *
118      * If $userId is null, returns config keys corresponding to
119      * all configured accounts
120      *
121      * @param string|null $userId
122      * @return array|string
123      */
124     public function getIniPrefix($userId = null)
125     {
126         if ($userId == null) {
127             $arr = array();
128             foreach ($this->configs as $key => $value) {
129                 $pos = strpos($key, '.');
130                 if (strstr($key, "acct")) {
131                     $arr[] = substr($key, 0, $pos);
132                 }
133             }
134             return array_unique($arr);
135         } else {
136             $iniPrefix = array_search($userId, $this->configs);
137             $pos = strpos($iniPrefix, '.');
138             $acct = substr($iniPrefix, 0, $pos);
139 
140             return $acct;
141         }
142     }
143 
144     /**
145      * returns the config file hashmap
146      */
147     public function getConfigHashmap()
148     {
149         return $this->configs;
150     }
151 
152     /**
153      * Disabling __clone call
154      */
155     public function __clone()
156     {
157         trigger_error('Clone is not allowed.', E_USER_ERROR);
158     }
159 }
160 
API documentation generated by ApiGen