|
1
|
|
|
<?php namespace Arcanedev\Stripe\Resources; |
|
2
|
|
|
|
|
3
|
|
|
use Arcanedev\Stripe\Contracts\Resources\ApplicationFeeRefundInterface; |
|
4
|
|
|
use Arcanedev\Stripe\Exceptions\InvalidRequestException; |
|
5
|
|
|
use Arcanedev\Stripe\StripeResource; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Class ApplicationFeeRefund |
|
9
|
|
|
* |
|
10
|
|
|
* @package Arcanedev\Stripe\Resources |
|
11
|
|
|
* @author ARCANEDEV <[email protected]> |
|
12
|
|
|
* @link https://stripe.com/docs/api/php#fee_refunds |
|
13
|
|
|
* |
|
14
|
|
|
* @property string id |
|
15
|
|
|
* @property string object // "fee_refund" |
|
16
|
|
|
* @property int amount |
|
17
|
|
|
* @property string balance_transaction |
|
18
|
|
|
* @property int created |
|
19
|
|
|
* @property string currency |
|
20
|
|
|
* @property string fee |
|
21
|
|
|
* @property \Arcanedev\Stripe\AttachedObject metadata |
|
22
|
|
|
*/ |
|
23
|
|
|
class ApplicationFeeRefund extends StripeResource implements ApplicationFeeRefundInterface |
|
24
|
|
|
{ |
|
25
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
26
|
|
|
| Constants |
|
27
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
28
|
|
|
*/ |
|
29
|
|
|
const BASE_CLASS = 'Arcanedev\\Stripe\\Resources\\ApplicationFee'; |
|
30
|
|
|
|
|
31
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
32
|
|
|
| Main Functions |
|
33
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
34
|
|
|
*/ |
|
35
|
|
|
/** |
|
36
|
|
|
* Get instance URL - The API URL for this Stripe refund. |
|
37
|
|
|
* |
|
38
|
|
|
* @return string |
|
39
|
|
|
*/ |
|
40
|
10 |
|
public function instanceUrl() |
|
41
|
|
|
{ |
|
42
|
10 |
|
$this->checkId($this['id']); |
|
43
|
|
|
|
|
44
|
5 |
|
$base = self::classUrl(self::BASE_CLASS); |
|
45
|
5 |
|
$feeExtn = urlencode(str_utf8($this['fee'])); |
|
46
|
5 |
|
$extn = urlencode(str_utf8($this['id'])); |
|
47
|
|
|
|
|
48
|
5 |
|
return "$base/$feeExtn/refunds/$extn"; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
52
|
|
|
| CRUD Functions |
|
53
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
54
|
|
|
*/ |
|
55
|
|
|
/** |
|
56
|
|
|
* Update/Save an Application Fee Refund. |
|
57
|
|
|
* |
|
58
|
|
|
* @link https://stripe.com/docs/api/php#update_fee_refund |
|
59
|
|
|
* |
|
60
|
|
|
* @param array|string|null $options |
|
61
|
|
|
* |
|
62
|
|
|
* @return self |
|
63
|
|
|
*/ |
|
64
|
|
|
public function save($options = null) |
|
65
|
|
|
{ |
|
66
|
|
|
return self::scopedSave($options); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
70
|
|
|
| Check Functions |
|
71
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
72
|
|
|
*/ |
|
73
|
|
|
/** |
|
74
|
|
|
* Check if id is not empty. |
|
75
|
|
|
* |
|
76
|
|
|
* @param string $id |
|
77
|
|
|
* |
|
78
|
|
|
* @throws \Arcanedev\Stripe\Exceptions\InvalidRequestException |
|
79
|
|
|
*/ |
|
80
|
10 |
|
protected function checkId($id) |
|
81
|
|
|
{ |
|
82
|
10 |
|
if ( ! $id) { |
|
83
|
5 |
|
throw new InvalidRequestException( |
|
84
|
5 |
|
"Could not determine which URL to request: class instance has invalid ID: $id", |
|
85
|
1 |
|
400 |
|
86
|
4 |
|
); |
|
87
|
|
|
} |
|
88
|
5 |
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|