/** * Constructs a new Stripe instance * @param string $environment 'sandbox' or 'production' * @param mixed $merchant_attr Account ID, ElggEntity or entity guid of the merchant on whose behalf the requests are to be made * @return StripeClient */ function __construct($environment = null, $merchant_attr = null) { StripeClientFactory::stageEnvironment($environment); $merchant = new StripeMerchant($merchant_attr); $access_token = $merchant->getAccessToken(); $this->setAccessToken($access_token); }
/** * Get an access token for signing API requests */ public function getAccessToken() { if (!elgg_instanceof($this->entity)) { return false; } switch ($this->entity->getType()) { case 'site': return StripeClientFactory::getSecretKey(); break; default: return $this->entity->getPrivateSetting('stripe_access_token'); break; } }
/** * Stage an environment * @param string $environment */ public static function stageEnvironment($environment = null) { self::$environment = self::filterEnvironment($environment); self::init(); }
elgg.config.stripePublishableKey = '<?php echo StripeClientFactory::getPublishableKey(); ?> ';