composer package updates
[openemr.git] / vendor / stripe / stripe-php / lib / Source.php
blob5a9669d7a424af193223d745e5f173a01526affd
1 <?php
3 namespace Stripe;
5 /**
6 * Class Source
8 * @property string $id
9 * @property string $object
10 * @property int $amount
11 * @property string $client_secret
12 * @property mixed $code_verification
13 * @property int $created
14 * @property string $currency
15 * @property string $flow
16 * @property bool $livemode
17 * @property StripeObject $metadata
18 * @property mixed $owner
19 * @property mixed $receiver
20 * @property mixed $redirect
21 * @property string $statement_descriptor
22 * @property string $status
23 * @property string $type
24 * @property string $usage
26 * @package Stripe
28 class Source extends ApiResource
31 const OBJECT_NAME = "source";
33 use ApiOperations\Create;
34 use ApiOperations\Retrieve;
35 use ApiOperations\Update;
37 /**
38 * @param array|null $params
39 * @param array|string|null $options
41 * @return Source The detached source.
43 public function detach($params = null, $options = null)
45 self::_validateParams($params);
47 $id = $this['id'];
48 if (!$id) {
49 $class = get_class($this);
50 $msg = "Could not determine which URL to request: $class instance "
51 . "has invalid ID: $id";
52 throw new Error\InvalidRequest($msg, null);
55 if ($this['customer']) {
56 $base = Customer::classUrl();
57 $parentExtn = urlencode(Util\Util::utf8($this['customer']));
58 $extn = urlencode(Util\Util::utf8($id));
59 $url = "$base/$parentExtn/sources/$extn";
61 list($response, $opts) = $this->_request('delete', $url, $params, $options);
62 $this->refreshFrom($response, $opts);
63 return $this;
64 } else {
65 $message = "This source object does not appear to be currently attached "
66 . "to a customer object.";
67 throw new Error\Api($message);
71 /**
72 * @param array|null $params
73 * @param array|string|null $options
75 * @return Source The detached source.
77 * @deprecated Use the `detach` method instead.
79 public function delete($params = null, $options = null)
81 $this->detach($params, $options);
84 /**
85 * @param array|null $params
86 * @param array|string|null $options
88 * @return Collection The list of source transactions.
90 public function sourceTransactions($params = null, $options = null)
92 $url = $this->instanceUrl() . '/source_transactions';
93 list($response, $opts) = $this->_request('get', $url, $params, $options);
94 $obj = Util\Util::convertToStripeObject($response, $opts);
95 $obj->setLastResponse($response);
96 return $obj;
99 /**
100 * @param array|null $params
101 * @param array|string|null $options
103 * @return Source The verified source.
105 public function verify($params = null, $options = null)
107 $url = $this->instanceUrl() . '/verify';
108 list($response, $opts) = $this->_request('post', $url, $params, $options);
109 $this->refreshFrom($response, $opts);
110 return $this;