示例#1
0
 public static function initStatics()
 {
     /* WARNING: resource paths for Bf_StripeTokens do not follow the usual pattern;
      * instead of posting to 'root' of a URL root reserved for Bf_StripeTokens, 
      * this routing is a bit less standard; for example we can't GET from the same
      * place we POST to.
      */
     self::$_resourcePath = new Bf_ResourcePath('vaulted-gateways/stripe', 'stripe_token');
 }
示例#2
0
 /**
  * Creates using the API a new StripeToken.
  * Adds to this Bf_Account's paymentMethods a model of
  * a Bf_PaymentMethod for that token.
  * @param Stripe_Card The 'card' object retrieved from Stripe
  * @return Bf_Account ($this)
  */
 public function addNewStripePaymentMethod($card)
 {
     // create model of relationship to tokenized card
     $stripeToken = new Bf_StripeToken(array('accountID' => $this->id, 'cardDetailsID' => $card->id, 'stripeCustomerID' => $card->customer));
     // send model to API to be created
     $createdStripeToken = Bf_StripeToken::create($stripeToken);
     // create model of payment method
     $stripePaymentMethod = new Bf_PaymentMethod(array('linkID' => $createdStripeToken->id, 'name' => $card->last4, 'description' => "Stripe (" . ($card->type ? $card->type : ($card->brand ? $card->brand : "Unknown")) . "): " . $card->last4, 'crmID' => $card->id, 'expiryDate' => $card->exp_year . '/' . str_pad($card->exp_month, 2, "0", STR_PAD_LEFT), 'gateway' => "stripe"));
     if (!$this->paymentMethods) {
         // initialize as empty array
         $this->paymentMethods = array();
     }
     // add our modelled payment method
     array_push($this->paymentMethods, $stripePaymentMethod);
     return $this;
 }