fix php 5.6 in docker dev env (#1740)
[openemr.git] / vendor / stripe / stripe-php / lib / ExternalAccount.php
blob23ddf9b2e8285b934a300ee8be17324d1398ef47
1 <?php
3 namespace Stripe;
5 /**
6 * Class ExternalAccount
8 * @package Stripe
9 */
10 abstract class ExternalAccount extends ApiResource
12 /**
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()
18 $id = $this['id'];
19 if (!$id) {
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();
29 $path = 'sources';
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();
37 $path = 'cards';
38 } else {
39 return null;
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";
50 /**
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);
61 /**
62 * @param array|string|null $opts
64 * @return ExternalAccount The saved external account.
66 public function save($opts = null)
68 return $this->_save($opts);
71 /**
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);
83 return $this;
84 } else {
85 $message = 'Only customer external accounts can be verified in this manner.';
86 throw new Error\Api($message);