AndroidPayCard.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace Braintree;
  3. /**
  4. * Braintree AndroidPayCard module
  5. * Creates and manages Braintree Android Pay cards
  6. *
  7. * <b>== More information ==</b>
  8. *
  9. * See {@link https://developers.braintreepayments.com/javascript+php}<br />
  10. *
  11. * @package Braintree
  12. * @category Resources
  13. *
  14. * @property-read string $bin
  15. * @property-read string $cardType
  16. * @property-read string $createdAt
  17. * @property-read string $customerId
  18. * @property-read string $default
  19. * @property-read string $expirationMonth
  20. * @property-read string $expirationYear
  21. * @property-read string $googleTransactionId
  22. * @property-read string $imageUrl
  23. * @property-read string $last4
  24. * @property-read string $sourceCardLast4
  25. * @property-read string $sourceCardType
  26. * @property-read string $sourceDescription
  27. * @property-read string $token
  28. * @property-read string $updatedAt
  29. * @property-read string $virtualCardLast4
  30. * @property-read string $virtualCardType
  31. */
  32. class AndroidPayCard extends Base
  33. {
  34. /* instance methods */
  35. /**
  36. * returns false if default is null or false
  37. *
  38. * @return boolean
  39. */
  40. public function isDefault()
  41. {
  42. return $this->default;
  43. }
  44. /**
  45. * factory method: returns an instance of AndroidPayCard
  46. * to the requesting method, with populated properties
  47. *
  48. * @ignore
  49. * @return AndroidPayCard
  50. */
  51. public static function factory($attributes)
  52. {
  53. $defaultAttributes = [
  54. 'expirationMonth' => '',
  55. 'expirationYear' => '',
  56. 'last4' => $attributes['virtualCardLast4'],
  57. 'cardType' => $attributes['virtualCardType'],
  58. ];
  59. $instance = new self();
  60. $instance->_initialize(array_merge($defaultAttributes, $attributes));
  61. return $instance;
  62. }
  63. /**
  64. * sets instance properties from an array of values
  65. *
  66. * @access protected
  67. * @param array $androidPayCardAttribs array of Android Pay card properties
  68. * @return void
  69. */
  70. protected function _initialize($androidPayCardAttribs)
  71. {
  72. // set the attributes
  73. $this->_attributes = $androidPayCardAttribs;
  74. $subscriptionArray = [];
  75. if (isset($androidPayCardAttribs['subscriptions'])) {
  76. foreach ($androidPayCardAttribs['subscriptions'] AS $subscription) {
  77. $subscriptionArray[] = Subscription::factory($subscription);
  78. }
  79. }
  80. $this->_set('subscriptions', $subscriptionArray);
  81. }
  82. }
  83. class_alias('Braintree\AndroidPayCard', 'Braintree_AndroidPayCard');