• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stripe / stripe-php / 9308609267

30 May 2024 08:13PM UTC coverage: 60.343% (-1.0%) from 61.377%
9308609267

push

github

web-flow
Merge pull request #1699 from stripe/latest-codegen-beta

Update generated code for beta

1080 of 1830 new or added lines in 117 files covered. (59.02%)

15 existing lines in 3 files now uncovered.

3486 of 5777 relevant lines covered (60.34%)

2.19 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/lib/Order.php
1
<?php
2

3
// File generated from our OpenAPI spec
4

5
namespace Stripe;
6

7
/**
8
 * An Order describes a purchase being made by a customer, including the
9
 * products &amp; quantities being purchased, the order status, the payment information,
10
 * and the billing/shipping details.
11
 *
12
 * Related guide: <a href="https://stripe.com/docs/orders">Orders overview</a>
13
 *
14
 * @property string $id Unique identifier for the object.
15
 * @property string $object String representing the object's type. Objects of the same type share the same value.
16
 * @property null|int $amount_remaining
17
 * @property int $amount_subtotal Order cost before any discounts or taxes are applied. A positive integer representing the subtotal of the order in the <a href="https://stripe.com/docs/currencies#zero-decimal">smallest currency unit</a> (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency).
18
 * @property int $amount_total Total order cost after discounts and taxes are applied. A positive integer representing the cost of the order in the <a href="https://stripe.com/docs/currencies#zero-decimal">smallest currency unit</a> (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). To submit an order, the total must be either 0 or at least $0.50 USD or <a href="https://stripe.com/docs/currencies#minimum-and-maximum-charge-amounts">equivalent in charge currency</a>.
19
 * @property null|string|\Stripe\Application $application ID of the Connect application that created the Order, if any.
20
 * @property null|\Stripe\StripeObject $automatic_tax
21
 * @property null|\Stripe\StripeObject $billing_details Customer billing details associated with the order.
22
 * @property null|string $client_secret <p>The client secret of this Order. Used for client-side retrieval using a publishable key.</p><p>The client secret can be used to complete a payment for an Order from your frontend. It should not be stored, logged, embedded in URLs, or exposed to anyone other than the customer. Make sure that you have TLS enabled on any page that includes the client secret.</p><p>Refer to our docs for <a href="https://stripe.com/docs/orders-beta/create-and-process">creating and processing an order</a> to learn about how client_secret should be handled.</p>
23
 * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
24
 * @property null|\Stripe\StripeObject[] $credits The credits applied to the Order. At most 10 credits can be applied to an Order.
25
 * @property string $currency Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>, in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported currency</a>.
26
 * @property null|string|\Stripe\Customer $customer The customer which this orders belongs to.
27
 * @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users.
28
 * @property null|(string|\Stripe\Discount)[] $discounts The discounts applied to the order. Use <code>expand[]=discounts</code> to expand each discount.
29
 * @property null|string $ip_address A recent IP address of the purchaser used for tax reporting and tax location inference.
30
 * @property null|\Stripe\Collection<\Stripe\LineItem> $line_items A list of line items the customer is ordering. Each line item includes information about the product, the quantity, and the resulting cost. There is a maximum of 100 line items.
31
 * @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
32
 * @property null|\Stripe\StripeObject $metadata Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
33
 * @property \Stripe\StripeObject $payment
34
 * @property null|\Stripe\StripeObject $shipping_cost The details of the customer cost of shipping, including the customer chosen ShippingRate.
35
 * @property null|\Stripe\StripeObject $shipping_details Customer shipping information associated with the order.
36
 * @property string $status The overall status of the order.
37
 * @property null|\Stripe\StripeObject $tax_details
38
 * @property \Stripe\StripeObject $total_details
39
 */
40
class Order extends ApiResource
41
{
42
    const OBJECT_NAME = 'order';
43

44
    use ApiOperations\Update;
45

46
    const STATUS_CANCELED = 'canceled';
47
    const STATUS_COMPLETE = 'complete';
48
    const STATUS_OPEN = 'open';
49
    const STATUS_PROCESSING = 'processing';
50
    const STATUS_SUBMITTED = 'submitted';
51

52
    /**
53
     * Creates a new <code>open</code> order object.
54
     *
55
     * @param null|array $params
56
     * @param null|array|string $options
57
     *
58
     * @throws \Stripe\Exception\ApiErrorException if the request fails
59
     *
60
     * @return \Stripe\Order the created resource
61
     */
NEW
62
    public static function create($params = null, $options = null)
×
63
    {
NEW
64
        self::_validateParams($params);
×
NEW
65
        $url = static::classUrl();
×
66

NEW
67
        list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
×
NEW
68
        $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
×
NEW
69
        $obj->setLastResponse($response);
×
70

NEW
71
        return $obj;
×
72
    }
73

74
    /**
75
     * Returns a list of your orders. The orders are returned sorted by creation date,
76
     * with the most recently created orders appearing first.
77
     *
78
     * @param null|array $params
79
     * @param null|array|string $opts
80
     *
81
     * @throws \Stripe\Exception\ApiErrorException if the request fails
82
     *
83
     * @return \Stripe\Collection<\Stripe\Order> of ApiResources
84
     */
NEW
85
    public static function all($params = null, $opts = null)
×
86
    {
NEW
87
        $url = static::classUrl();
×
88

NEW
89
        return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
×
90
    }
91

92
    /**
93
     * Retrieves the details of an existing order. Supply the unique order ID from
94
     * either an order creation request or the order list, and Stripe will return the
95
     * corresponding order information.
96
     *
97
     * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
98
     * @param null|array|string $opts
99
     *
100
     * @throws \Stripe\Exception\ApiErrorException if the request fails
101
     *
102
     * @return \Stripe\Order
103
     */
NEW
104
    public static function retrieve($id, $opts = null)
×
105
    {
NEW
106
        $opts = \Stripe\Util\RequestOptions::parse($opts);
×
NEW
107
        $instance = new static($id, $opts);
×
NEW
108
        $instance->refresh();
×
109

NEW
110
        return $instance;
×
111
    }
112

113
    /**
114
     * Updates the specific order by setting the values of the parameters passed. Any
115
     * parameters not provided will be left unchanged.
116
     *
117
     * @param string $id the ID of the resource to update
118
     * @param null|array $params
119
     * @param null|array|string $opts
120
     *
121
     * @throws \Stripe\Exception\ApiErrorException if the request fails
122
     *
123
     * @return \Stripe\Order the updated resource
124
     */
NEW
125
    public static function update($id, $params = null, $opts = null)
×
126
    {
NEW
127
        self::_validateParams($params);
×
NEW
128
        $url = static::resourceUrl($id);
×
129

NEW
130
        list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
×
NEW
131
        $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
×
NEW
132
        $obj->setLastResponse($response);
×
133

NEW
134
        return $obj;
×
135
    }
136

137
    /**
138
     * @param null|array $params
139
     * @param null|array|string $opts
140
     *
141
     * @throws \Stripe\Exception\ApiErrorException if the request fails
142
     *
143
     * @return \Stripe\Order the canceled order
144
     */
145
    public function cancel($params = null, $opts = null)
×
146
    {
147
        $url = $this->instanceUrl() . '/cancel';
×
148
        list($response, $opts) = $this->_request('post', $url, $params, $opts);
×
149
        $this->refreshFrom($response, $opts);
×
150

151
        return $this;
×
152
    }
153

154
    /**
155
     * @param string $id
156
     * @param null|array $params
157
     * @param null|array|string $opts
158
     *
159
     * @throws \Stripe\Exception\ApiErrorException if the request fails
160
     *
161
     * @return \Stripe\Collection<\Stripe\LineItem> list of line items
162
     */
163
    public static function allLineItems($id, $params = null, $opts = null)
×
164
    {
165
        $url = static::resourceUrl($id) . '/line_items';
×
166
        list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
×
167
        $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
×
168
        $obj->setLastResponse($response);
×
169

170
        return $obj;
×
171
    }
172

173
    /**
174
     * @param null|array $params
175
     * @param null|array|string $opts
176
     *
177
     * @throws \Stripe\Exception\ApiErrorException if the request fails
178
     *
179
     * @return \Stripe\Order the reopened order
180
     */
181
    public function reopen($params = null, $opts = null)
×
182
    {
183
        $url = $this->instanceUrl() . '/reopen';
×
184
        list($response, $opts) = $this->_request('post', $url, $params, $opts);
×
185
        $this->refreshFrom($response, $opts);
×
186

187
        return $this;
×
188
    }
189

190
    /**
191
     * @param null|array $params
192
     * @param null|array|string $opts
193
     *
194
     * @throws \Stripe\Exception\ApiErrorException if the request fails
195
     *
196
     * @return \Stripe\Order the submited order
197
     */
198
    public function submit($params = null, $opts = null)
×
199
    {
200
        $url = $this->instanceUrl() . '/submit';
×
201
        list($response, $opts) = $this->_request('post', $url, $params, $opts);
×
202
        $this->refreshFrom($response, $opts);
×
203

204
        return $this;
×
205
    }
206
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc