PPPStripeExternalAccount

Class ExternalAccount.

Defined (1)

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

/includes/api/stripe-php/lib/ExternalAccount.php  
  1. abstract class ExternalAccount extends ApiResource 
  2. /** 
  3. * @return string The instance URL for this resource. It needs to be special 
  4. * cased because it doesn't fit into the standard resource pattern. 
  5. */ 
  6. public function instanceUrl() 
  7. $id = $this['id']; 
  8. if (!$id) { 
  9. $class = get_class($this); 
  10. $msg = "Could not determine which URL to request: $class instance " 
  11. . "has invalid ID: $id"; 
  12. throw new Error\InvalidRequest($msg, null); 
  13.  
  14. if ($this['customer']) { 
  15. $parent = $this['customer']; 
  16. $base = Customer::classUrl(); //TODO need namespace here? 
  17. $path = 'sources'; 
  18. } elseif ($this['account']) { 
  19. $parent = $this['account']; 
  20. $base = Account::classUrl(); 
  21. $path = 'external_accounts'; 
  22. } elseif ($this['recipient']) { 
  23. $parent = $this['recipient']; 
  24. $base = Recipient::classUrl(); 
  25. $path = 'cards'; 
  26. } else { 
  27. return null; 
  28.  
  29. $parent = Util\Util::utf8($parent); 
  30. $id = Util\Util::utf8($id); 
  31.  
  32. $parentExtn = urlencode($parent); 
  33. $extn = urlencode($id); 
  34. return "$base/$parentExtn/$path/$extn"; 
  35.  
  36. /** 
  37. * @param array|null $params 
  38. * @param array|string|null $opts 
  39. * @return ExternalAccount The deleted external account. 
  40. */ 
  41. public function delete($params = null, $opts = null) 
  42. return $this->_delete($params, $opts); 
  43.  
  44. /** 
  45. * @param array|string|null $opts 
  46. * @return ExternalAccount The saved external account. 
  47. */ 
  48. public function save($opts = null) 
  49. return $this->_save($opts); 
  50.  
  51. /** 
  52. * @param array|null $params 
  53. * @param array|string|null $opts 
  54. * @return ExternalAccount The verified (or not) external account. 
  55. */ 
  56. public function verify($params = null, $opts = null) 
  57. if ($this['customer']) { 
  58. $url = $this->instanceUrl() . '/verify'; 
  59. list($response, $options) = $this->_request('post', $url, $params, $opts); 
  60. $this->refreshFrom($response, $options); 
  61. return $this; 
  62. } else { 
  63. $message = 'Only customer external accounts can be verified in this manner.'; 
  64. throw new Error\Api($message);