6 * Class ExternalAccount
10 abstract class ExternalAccount
extends ApiResource
13 * @return string The instance URL for this resource. It needs to be special
14 * cased because it doesn't fit into the standard resource pattern.
16 public function instanceUrl()
20 $class = get_class($this);
21 $msg = "Could not determine which URL to request: $class instance "
22 . "has invalid ID: $id";
23 throw new Error\
InvalidRequest($msg, null);
26 if ($this['customer']) {
27 $parent = $this['customer'];
28 $base = Customer
::classUrl();
30 } elseif ($this['account']) {
31 $parent = $this['account'];
32 $base = Account
::classUrl();
33 $path = 'external_accounts';
34 } elseif ($this['recipient']) {
35 $parent = $this['recipient'];
36 $base = Recipient
::classUrl();
42 $parent = Util\Util
::utf8($parent);
43 $id = Util\Util
::utf8($id);
45 $parentExtn = urlencode($parent);
46 $extn = urlencode($id);
47 return "$base/$parentExtn/$path/$extn";
51 * @param array|null $params
52 * @param array|string|null $opts
54 * @return ExternalAccount The deleted external account.
56 public function delete($params = null, $opts = null)
58 return $this->_delete($params, $opts);
62 * @param array|string|null $opts
64 * @return ExternalAccount The saved external account.
66 public function save($opts = null)
68 return $this->_save($opts);
72 * @param array|null $params
73 * @param array|string|null $opts
75 * @return ExternalAccount The verified (or not) external account.
77 public function verify($params = null, $opts = null)
79 if ($this['customer']) {
80 $url = $this->instanceUrl() . '/verify';
81 list($response, $options) = $this->_request('post', $url, $params, $opts);
82 $this->refreshFrom($response, $options);
85 $message = 'Only customer external accounts can be verified in this manner.';
86 throw new Error\
Api($message);