Stripe\Stripe::setApiKey PHP Method

setApiKey() public static method

Sets the API key to be used for requests.
public static setApiKey ( string $apiKey )
$apiKey string
    public static function setApiKey($apiKey)
    {
        self::$apiKey = $apiKey;
    }

Usage Example

Esempio n. 1
12
 public function charge($Token, $Amount, $Description, $Meta = array(), $Currency = 'gbp')
 {
     // Set your secret key: remember to change this to your live secret key in production
     // See your keys here https://dashboard.stripe.com/account/apikeys
     \Stripe\Stripe::setApiKey($this->config['secret_key']);
     // Create the charge on Stripe's servers - this will charge the user's card
     try {
         $charge = \Stripe\Charge::create(array("amount" => floatval($Amount) * 100, "currency" => $Currency, "source" => $Token, "description" => $Description, "metadata" => $Meta));
         return true;
     } catch (\Stripe\Error\ApiConnection $e) {
         // Network problem, perhaps try again.
         return $e;
     } catch (\Stripe\Error\InvalidRequest $e) {
         // You screwed up in your programming. Shouldn't happen!
         return $e;
     } catch (\Stripe\Error\Api $e) {
         // Stripe's servers are down!
         return $e;
     } catch (\Stripe\Error\Card $e) {
         // Card was declined.
         return $e;
     } catch (\Stripe\Error\Base $e) {
         // ?????
         return $e;
     } catch (\Stripe\Error\RateLimit $e) {
         // ?????
         return $e;
     }
     return false;
 }
All Usage Examples Of Stripe\Stripe::setApiKey