|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Stripe; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Class PaymentMethod |
|
7
|
|
|
* |
|
8
|
|
|
* @property string $id |
|
9
|
|
|
* @property string $object |
|
10
|
|
|
* @property mixed $billing_details |
|
11
|
|
|
* @property mixed $card |
|
12
|
|
|
* @property mixed $card_present |
|
13
|
|
|
* @property int $created |
|
14
|
|
|
* @property string $customer |
|
15
|
|
|
* @property mixed $ideal |
|
16
|
|
|
* @property bool $livemode |
|
17
|
|
|
* @property StripeObject $metadata |
|
18
|
|
|
* @property mixed $sepa_debit |
|
19
|
|
|
* @property string $type |
|
20
|
|
|
* |
|
21
|
|
|
* @package Stripe |
|
22
|
|
|
*/ |
|
23
|
|
View Code Duplication |
class PaymentMethod extends ApiResource |
|
|
|
|
|
|
24
|
|
|
{ |
|
25
|
|
|
|
|
26
|
|
|
const OBJECT_NAME = "payment_method"; |
|
27
|
|
|
|
|
28
|
|
|
use ApiOperations\All; |
|
29
|
|
|
use ApiOperations\Create; |
|
30
|
|
|
use ApiOperations\Retrieve; |
|
31
|
|
|
use ApiOperations\Update; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @param array|null $params |
|
35
|
|
|
* @param array|string|null $opts |
|
36
|
|
|
* |
|
37
|
|
|
* @return PaymentMethod The attached payment method. |
|
38
|
|
|
*/ |
|
39
|
|
|
public function attach($params = null, $opts = null) |
|
40
|
|
|
{ |
|
41
|
|
|
$url = $this->instanceUrl() . '/attach'; |
|
42
|
|
|
list($response, $opts) = $this->_request('post', $url, $params, $opts); |
|
|
|
|
|
|
43
|
|
|
$this->refreshFrom($response, $opts); |
|
44
|
|
|
return $this; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @param array|null $params |
|
49
|
|
|
* @param array|string|null $opts |
|
50
|
|
|
* |
|
51
|
|
|
* @return PaymentMethod The detached payment method. |
|
52
|
|
|
*/ |
|
53
|
|
|
public function detach($params = null, $opts = null) |
|
54
|
|
|
{ |
|
55
|
|
|
$url = $this->instanceUrl() . '/detach'; |
|
56
|
|
|
list($response, $opts) = $this->_request('post', $url, $params, $opts); |
|
|
|
|
|
|
57
|
|
|
$this->refreshFrom($response, $opts); |
|
58
|
|
|
return $this; |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.