IdealPayment.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. namespace Braintree;
  3. /**
  4. * Braintree IdealPayment module
  5. *
  6. * @package Braintree
  7. * @category Resources
  8. */
  9. /**
  10. * Manages Braintree IdealPayments
  11. *
  12. * <b>== More information ==</b>
  13. *
  14. *
  15. * @package Braintree
  16. * @category Resources
  17. *
  18. * @property-read string $id
  19. * @property-read string $idealTransactionId
  20. * @property-read string $currency
  21. * @property-read string $amount
  22. * @property-read string $status
  23. * @property-read string $orderId
  24. * @property-read string $issuer
  25. * @property-read string $ibanBankAccount
  26. */
  27. class IdealPayment extends Base
  28. {
  29. /**
  30. * factory method: returns an instance of IdealPayment
  31. * to the requesting method, with populated properties
  32. *
  33. * @ignore
  34. * @return IdealPayment
  35. */
  36. public static function factory($attributes)
  37. {
  38. $instance = new self();
  39. $instance->_initialize($attributes);
  40. return $instance;
  41. }
  42. /* instance methods */
  43. /**
  44. * sets instance properties from an array of values
  45. *
  46. * @access protected
  47. * @param array $idealPaymentAttribs array of idealPayment data
  48. * @return void
  49. */
  50. protected function _initialize($idealPaymentAttribs)
  51. {
  52. // set the attributes
  53. $this->_attributes = $idealPaymentAttribs;
  54. $ibanBankAccount = isset($idealPaymentAttribs['ibanBankAccount']) ?
  55. IbanBankAccount::factory($idealPaymentAttribs['ibanBankAccount']) :
  56. null;
  57. $this->_set('ibanBankAccount', $ibanBankAccount);
  58. }
  59. /**
  60. * create a printable representation of the object as:
  61. * ClassName[property=value, property=value]
  62. * @return string
  63. */
  64. public function __toString()
  65. {
  66. return __CLASS__ . '[' .
  67. Util::attributesToString($this->_attributes) . ']';
  68. }
  69. // static methods redirecting to gateway
  70. public static function find($idealPaymentId)
  71. {
  72. return Configuration::gateway()->idealPayment()->find($idealPaymentId);
  73. }
  74. public static function sale($idealPaymentId, $transactionAttribs)
  75. {
  76. $transactionAttribs['options'] = [
  77. 'submitForSettlement' => true
  78. ];
  79. return Configuration::gateway()->idealPayment()->sale($idealPaymentId, $transactionAttribs);
  80. }
  81. }
  82. class_alias('Braintree\IdealPayment', 'Braintree_IdealPayment');