BraintreeApplePayCard

Braintree ApplePayCard module Creates and manages Braintree Apple Pay cards.

Defined (1)

The class is defined in the following location(s).

/classes/lib/Braintree/Braintree/ApplePayCard.php  
  1. class ApplePayCard extends Base 
  2. // Card Type 
  3. const AMEX = 'Apple Pay - American Express'; 
  4. const MASTER_CARD = 'Apple Pay - MasterCard'; 
  5. const VISA = 'Apple Pay - Visa'; 
  6.  
  7. /** instance methods */ 
  8. /** 
  9. * returns false if default is null or false 
  10. * @return boolean 
  11. */ 
  12. public function isDefault() 
  13. return $this->default; 
  14.  
  15. /** 
  16. * checks whether the card is expired based on the current date 
  17. * @return boolean 
  18. */ 
  19. public function isExpired() 
  20. return $this->expired; 
  21.  
  22. /** 
  23. * factory method: returns an instance of ApplePayCard 
  24. * to the requesting method, with populated properties 
  25. * @ignore 
  26. * @return ApplePayCard 
  27. */ 
  28. public static function factory($attributes) 
  29. $defaultAttributes = [ 
  30. 'expirationMonth' => '',  
  31. 'expirationYear' => '',  
  32. 'last4' => '',  
  33. ]; 
  34.  
  35. $instance = new self(); 
  36. $instance->_initialize(array_merge($defaultAttributes, $attributes)); 
  37. return $instance; 
  38.  
  39. /** 
  40. * sets instance properties from an array of values 
  41. * @access protected 
  42. * @param array $applePayCardAttribs array of Apple Pay card properties 
  43. * @return void 
  44. */ 
  45. protected function _initialize($applePayCardAttribs) 
  46. // set the attributes 
  47. $this->_attributes = $applePayCardAttribs; 
  48.  
  49. $subscriptionArray = []; 
  50. if (isset($applePayCardAttribs['subscriptions'])) { 
  51. foreach ($applePayCardAttribs['subscriptions'] AS $subscription) { 
  52. $subscriptionArray[] = Subscription::factory($subscription); 
  53.  
  54. $this->_set('subscriptions', $subscriptionArray); 
  55. $this->_set('expirationDate', $this->expirationMonth . '/' . $this->expirationYear);