|
1
|
|
|
<?php namespace Arcanedev\Stripe\Resources; |
|
2
|
|
|
|
|
3
|
|
|
use Arcanedev\Stripe\Contracts\Resources\OrderInterface; |
|
4
|
|
|
use Arcanedev\Stripe\StripeResource; |
|
5
|
|
|
use Arcanedev\Stripe\Utilities\Util; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Class Order |
|
9
|
|
|
* |
|
10
|
|
|
* @package Arcanedev\Stripe\Resources |
|
11
|
|
|
* @author ARCANEDEV <[email protected]> |
|
12
|
|
|
* @link https://stripe.com/docs/api/php#order_object |
|
13
|
|
|
* |
|
14
|
|
|
* @property string id |
|
15
|
|
|
* @property string object // 'order' |
|
16
|
|
|
* @property int amount |
|
17
|
|
|
* @property string application |
|
18
|
|
|
* @property int application_fee |
|
19
|
|
|
* @property string charge |
|
20
|
|
|
* @property int created // timestamp |
|
21
|
|
|
* @property string currency |
|
22
|
|
|
* @property string customer |
|
23
|
|
|
* @property string email |
|
24
|
|
|
* @property string external_coupon_code |
|
25
|
|
|
* @property \Arcanedev\Stripe\Resources\OrderItem[] items |
|
26
|
|
|
* @property bool livemode |
|
27
|
|
|
* @property \Arcanedev\Stripe\AttachedObject metadata |
|
28
|
|
|
* @property string selected_shipping_method |
|
29
|
|
|
* @property array shipping |
|
30
|
|
|
* @property \Arcanedev\Stripe\Collection shipping_methods |
|
31
|
|
|
* @property string status // 'paid', 'fulfilled', or 'refunded'. |
|
32
|
|
|
* @property mixed status_transitions |
|
33
|
|
|
* @property int updated // timestamp |
|
34
|
|
|
*/ |
|
35
|
|
|
class Order extends StripeResource implements OrderInterface |
|
36
|
|
|
{ |
|
37
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
38
|
|
|
| Main Functions |
|
39
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
40
|
|
|
*/ |
|
41
|
|
|
/** |
|
42
|
|
|
* Retrieves the details of an existing Order. |
|
43
|
|
|
* @link https://stripe.com/docs/api/php#retrieve_order |
|
44
|
|
|
* |
|
45
|
|
|
* @param string $id |
|
46
|
|
|
* @param array|string|null $options |
|
47
|
|
|
* |
|
48
|
|
|
* @return self |
|
49
|
|
|
*/ |
|
50
|
5 |
|
public static function retrieve($id, $options = null) |
|
51
|
|
|
{ |
|
52
|
5 |
|
return self::scopedRetrieve($id, $options); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Create a new Order. |
|
57
|
|
|
* @link https://stripe.com/docs/api/php#create_order |
|
58
|
|
|
* |
|
59
|
|
|
* @param array|null $params |
|
60
|
|
|
* @param array|string|null $options |
|
61
|
|
|
* |
|
62
|
|
|
* @return self |
|
63
|
|
|
*/ |
|
64
|
20 |
|
public static function create($params = [], $options = null) |
|
65
|
|
|
{ |
|
66
|
20 |
|
return self::scopedCreate($params, $options); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* List all Orders. |
|
71
|
|
|
* @link https://stripe.com/docs/api/php#list_orders |
|
72
|
|
|
* |
|
73
|
|
|
* @param array|null $params |
|
74
|
|
|
* @param array|string|null $options |
|
75
|
|
|
* |
|
76
|
|
|
* @return \Arcanedev\Stripe\Collection|array |
|
77
|
|
|
*/ |
|
78
|
|
|
public static function all($params = [], $options = null) |
|
79
|
|
|
{ |
|
80
|
|
|
return self::scopedAll($params, $options); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Update an Order. |
|
85
|
|
|
* @link https://stripe.com/docs/api/php#update_order |
|
86
|
|
|
* |
|
87
|
|
|
* @param string $id |
|
88
|
|
|
* @param array|null $params |
|
89
|
|
|
* @param array|string|null $options |
|
90
|
|
|
* |
|
91
|
|
|
* @return self |
|
92
|
|
|
*/ |
|
93
|
|
|
public static function update($id, $params = [], $options = null) |
|
94
|
|
|
{ |
|
95
|
|
|
return self::scopedUpdate($id, $params, $options); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* Update/Save an Order. |
|
100
|
|
|
* @link https://stripe.com/docs/api/php#update_order |
|
101
|
|
|
* |
|
102
|
|
|
* @param array|string|null $options |
|
103
|
|
|
* |
|
104
|
|
|
* @return self |
|
105
|
|
|
*/ |
|
106
|
5 |
|
public function save($options = null) |
|
107
|
|
|
{ |
|
108
|
5 |
|
return $this->scopedSave($options); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* Pay an Order. |
|
113
|
|
|
* @link https://stripe.com/docs/api/php#pay_order |
|
114
|
|
|
* |
|
115
|
|
|
* @param array|null $params |
|
116
|
|
|
* @param array|string|null $options |
|
117
|
|
|
* |
|
118
|
|
|
* @return self |
|
119
|
|
|
*/ |
|
120
|
5 |
|
public function pay($params = [], $options = null) |
|
121
|
|
|
{ |
|
122
|
5 |
|
list($response, $options) = $this->request( |
|
123
|
5 |
|
'post', $this->instanceUrl() . '/pay', $params, $options |
|
124
|
4 |
|
); |
|
125
|
5 |
|
$this->refreshFrom($response, $options); |
|
126
|
|
|
|
|
127
|
5 |
|
return $this; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* Return an order. |
|
132
|
|
|
* @link https://stripe.com/docs/api/php#return_order |
|
133
|
|
|
* |
|
134
|
|
|
* @param array|null $params |
|
135
|
|
|
* @param array|string|null $options |
|
136
|
|
|
* |
|
137
|
|
|
* @return \Arcanedev\Stripe\Resources\OrderReturn|array |
|
138
|
|
|
*/ |
|
139
|
5 |
|
public function returnOrder($params = [], $options = null) |
|
140
|
|
|
{ |
|
141
|
5 |
|
list($response, $options) = $this->request( |
|
142
|
5 |
|
'post', $this->instanceUrl() . '/returns', $params, $options |
|
143
|
4 |
|
); |
|
144
|
|
|
|
|
145
|
5 |
|
return Util::convertToStripeObject($response, $options); |
|
146
|
|
|
} |
|
147
|
|
|
} |
|
148
|
|
|
|