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

stripe / stripe-php / 9960871025

16 Jul 2024 04:46PM UTC coverage: 60.176% (-0.02%) from 60.197%
9960871025

Pull #1723

github

web-flow
Merge bfc436aa1 into ff51fb89b
Pull Request #1723: Update generated code for beta

0 of 2 new or added lines in 1 file covered. (0.0%)

64 existing lines in 6 files now uncovered.

3486 of 5793 relevant lines covered (60.18%)

2.19 hits per line

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

69.23
/lib/Checkout/Session.php
1
<?php
2

3
// File generated from our OpenAPI spec
4

5
namespace Stripe\Checkout;
6

7
/**
8
 * A Checkout Session represents your customer's session as they pay for
9
 * one-time purchases or subscriptions through <a href="https://stripe.com/docs/payments/checkout">Checkout</a>
10
 * or <a href="https://stripe.com/docs/payments/payment-links">Payment Links</a>. We recommend creating a
11
 * new Session each time your customer attempts to pay.
12
 *
13
 * Once payment is successful, the Checkout Session will contain a reference
14
 * to the <a href="https://stripe.com/docs/api/customers">Customer</a>, and either the successful
15
 * <a href="https://stripe.com/docs/api/payment_intents">PaymentIntent</a> or an active
16
 * <a href="https://stripe.com/docs/api/subscriptions">Subscription</a>.
17
 *
18
 * You can create a Checkout Session on your server and redirect to its URL
19
 * to begin Checkout.
20
 *
21
 * Related guide: <a href="https://stripe.com/docs/checkout/quickstart">Checkout quickstart</a>
22
 *
23
 * @property string $id Unique identifier for the object.
24
 * @property string $object String representing the object's type. Objects of the same type share the same value.
25
 * @property null|\Stripe\StripeObject $after_expiration When set, provides configuration for actions to take if this Checkout Session expires.
26
 * @property null|bool $allow_promotion_codes Enables user redeemable promotion codes.
27
 * @property null|int $amount_subtotal Total of all items before discounts or taxes are applied.
28
 * @property null|int $amount_total Total of all items after discounts and taxes are applied.
29
 * @property \Stripe\StripeObject $automatic_tax
30
 * @property null|string $billing_address_collection Describes whether Checkout should collect the customer's billing address. Defaults to <code>auto</code>.
31
 * @property null|string $cancel_url If set, Checkout displays a back button and customers will be directed to this URL if they decide to cancel payment and return to your website.
32
 * @property null|string $client_reference_id A unique string to reference the Checkout Session. This can be a customer ID, a cart ID, or similar, and can be used to reconcile the Session with your internal systems.
33
 * @property null|string $client_secret Client secret to be used when initializing Stripe.js embedded checkout.
34
 * @property null|\Stripe\StripeObject $consent Results of <code>consent_collection</code> for this session.
35
 * @property null|\Stripe\StripeObject $consent_collection When set, provides configuration for the Checkout Session to gather active consent from customers.
36
 * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
37
 * @property null|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>.
38
 * @property null|\Stripe\StripeObject $currency_conversion Currency conversion details for automatic currency conversion sessions
39
 * @property \Stripe\StripeObject[] $custom_fields Collect additional information from your customer using custom fields. Up to 3 fields are supported.
40
 * @property \Stripe\StripeObject $custom_text
41
 * @property null|string|\Stripe\Customer $customer The ID of the customer for this Session. For Checkout Sessions in <code>subscription</code> mode or Checkout Sessions with <code>customer_creation</code> set as <code>always</code> in <code>payment</code> mode, Checkout will create a new customer object based on information provided during the payment flow unless an existing customer was provided when the Session was created.
42
 * @property null|string $customer_creation Configure whether a Checkout Session creates a Customer when the Checkout Session completes.
43
 * @property null|\Stripe\StripeObject $customer_details The customer details including the customer's tax exempt status and the customer's tax IDs. Customer's address details are not present on Sessions in <code>setup</code> mode.
44
 * @property null|string $customer_email If provided, this value will be used when the Customer object is created. If not provided, customers will be asked to enter their email address. Use this parameter to prefill customer data if you already have an email on file. To access information about the customer once the payment flow is complete, use the <code>customer</code> attribute.
45
 * @property int $expires_at The timestamp at which the Checkout Session will expire.
46
 * @property null|string|\Stripe\Invoice $invoice ID of the invoice created by the Checkout Session, if it exists.
47
 * @property null|\Stripe\StripeObject $invoice_creation Details on the state of invoice creation for the Checkout Session.
48
 * @property null|\Stripe\Collection<\Stripe\LineItem> $line_items The line items purchased by the customer.
49
 * @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.
50
 * @property null|string $locale The IETF language tag of the locale Checkout is displayed in. If blank or <code>auto</code>, the browser's locale is used.
51
 * @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.
52
 * @property string $mode The mode of the Checkout Session.
53
 * @property null|string|\Stripe\PaymentIntent $payment_intent The ID of the PaymentIntent for Checkout Sessions in <code>payment</code> mode. You can't confirm or cancel the PaymentIntent for a Checkout Session. To cancel, <a href="https://stripe.com/docs/api/checkout/sessions/expire">expire the Checkout Session</a> instead.
54
 * @property null|string|\Stripe\PaymentLink $payment_link The ID of the Payment Link that created this Session.
55
 * @property null|string $payment_method_collection Configure whether a Checkout Session should collect a payment method. Defaults to <code>always</code>.
56
 * @property null|\Stripe\StripeObject $payment_method_configuration_details Information about the payment method configuration used for this Checkout session if using dynamic payment methods.
57
 * @property null|\Stripe\StripeObject $payment_method_options Payment-method-specific configuration for the PaymentIntent or SetupIntent of this CheckoutSession.
58
 * @property string[] $payment_method_types A list of the types of payment methods (e.g. card) this Checkout Session is allowed to accept.
59
 * @property string $payment_status The payment status of the Checkout Session, one of <code>paid</code>, <code>unpaid</code>, or <code>no_payment_required</code>. You can use this value to decide when to fulfill your customer's order.
60
 * @property null|\Stripe\StripeObject $phone_number_collection
61
 * @property null|string $recovered_from The ID of the original expired Checkout Session that triggered the recovery flow.
62
 * @property null|string $redirect_on_completion This parameter applies to <code>ui_mode: embedded</code>. Learn more about the <a href="https://stripe.com/docs/payments/checkout/custom-redirect-behavior">redirect behavior</a> of embedded sessions. Defaults to <code>always</code>.
63
 * @property null|string $return_url Applies to Checkout Sessions with <code>ui_mode: embedded</code>. The URL to redirect your customer back to after they authenticate or cancel their payment on the payment method's app or site.
64
 * @property null|\Stripe\StripeObject $saved_payment_method_options Controls saved payment method settings for the session. Only available in <code>payment</code> and <code>subscription</code> mode.
65
 * @property null|string|\Stripe\SetupIntent $setup_intent The ID of the SetupIntent for Checkout Sessions in <code>setup</code> mode. You can't confirm or cancel the SetupIntent for a Checkout Session. To cancel, <a href="https://stripe.com/docs/api/checkout/sessions/expire">expire the Checkout Session</a> instead.
66
 * @property null|\Stripe\StripeObject $shipping_address_collection When set, provides configuration for Checkout to collect a shipping address from a customer.
67
 * @property null|\Stripe\StripeObject $shipping_cost The details of the customer cost of shipping, including the customer chosen ShippingRate.
68
 * @property null|\Stripe\StripeObject $shipping_details Shipping information for this Checkout Session.
69
 * @property \Stripe\StripeObject[] $shipping_options The shipping rate options applied to this Session.
70
 * @property null|string $status The status of the Checkout Session, one of <code>open</code>, <code>complete</code>, or <code>expired</code>.
71
 * @property null|string $submit_type Describes the type of transaction being performed by Checkout in order to customize relevant text on the page, such as the submit button. <code>submit_type</code> can only be specified on Checkout Sessions in <code>payment</code> mode. If blank or <code>auto</code>, <code>pay</code> is used.
72
 * @property null|string|\Stripe\Subscription $subscription The ID of the subscription for Checkout Sessions in <code>subscription</code> mode.
73
 * @property null|string $success_url The URL the customer will be directed to after the payment or subscription creation is successful.
74
 * @property null|\Stripe\StripeObject $tax_id_collection
75
 * @property null|\Stripe\StripeObject $total_details Tax and discount details for the computed total amount.
76
 * @property null|string $ui_mode The UI mode of the Session. Defaults to <code>hosted</code>.
77
 * @property null|string $url The URL to the Checkout Session. Redirect customers to this URL to take them to Checkout. If you’re using <a href="https://stripe.com/docs/payments/checkout/custom-domains">Custom Domains</a>, the URL will use your subdomain. Otherwise, it’ll use <code>checkout.stripe.com.</code> This value is only present when the session is active.
78
 */
79
class Session extends \Stripe\ApiResource
80
{
81
    const OBJECT_NAME = 'checkout.session';
82

83
    const BILLING_ADDRESS_COLLECTION_AUTO = 'auto';
84
    const BILLING_ADDRESS_COLLECTION_REQUIRED = 'required';
85

86
    const CUSTOMER_CREATION_ALWAYS = 'always';
87
    const CUSTOMER_CREATION_IF_REQUIRED = 'if_required';
88

89
    const MODE_PAYMENT = 'payment';
90
    const MODE_SETUP = 'setup';
91
    const MODE_SUBSCRIPTION = 'subscription';
92

93
    const PAYMENT_METHOD_COLLECTION_ALWAYS = 'always';
94
    const PAYMENT_METHOD_COLLECTION_IF_REQUIRED = 'if_required';
95

96
    const PAYMENT_STATUS_NO_PAYMENT_REQUIRED = 'no_payment_required';
97
    const PAYMENT_STATUS_PAID = 'paid';
98
    const PAYMENT_STATUS_UNPAID = 'unpaid';
99

100
    const REDIRECT_ON_COMPLETION_ALWAYS = 'always';
101
    const REDIRECT_ON_COMPLETION_IF_REQUIRED = 'if_required';
102
    const REDIRECT_ON_COMPLETION_NEVER = 'never';
103

104
    const STATUS_COMPLETE = 'complete';
105
    const STATUS_EXPIRED = 'expired';
106
    const STATUS_OPEN = 'open';
107

108
    const SUBMIT_TYPE_AUTO = 'auto';
109
    const SUBMIT_TYPE_BOOK = 'book';
110
    const SUBMIT_TYPE_DONATE = 'donate';
111
    const SUBMIT_TYPE_PAY = 'pay';
112

113
    const UI_MODE_EMBEDDED = 'embedded';
114
    const UI_MODE_HOSTED = 'hosted';
115

116
    /**
117
     * Creates a Session object.
118
     *
119
     * @param null|array $params
120
     * @param null|array|string $options
121
     *
122
     * @throws \Stripe\Exception\ApiErrorException if the request fails
123
     *
124
     * @return \Stripe\Checkout\Session the created resource
125
     */
126
    public static function create($params = null, $options = null)
1✔
127
    {
128
        self::_validateParams($params);
1✔
129
        $url = static::classUrl();
1✔
130

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

135
        return $obj;
1✔
136
    }
137

138
    /**
139
     * Returns a list of Checkout Sessions.
140
     *
141
     * @param null|array $params
142
     * @param null|array|string $opts
143
     *
144
     * @throws \Stripe\Exception\ApiErrorException if the request fails
145
     *
146
     * @return \Stripe\Collection<\Stripe\Checkout\Session> of ApiResources
147
     */
UNCOV
148
    public static function all($params = null, $opts = null)
×
149
    {
150
        $url = static::classUrl();
×
151

152
        return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
×
153
    }
154

155
    /**
156
     * Retrieves a Session object.
157
     *
158
     * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
159
     * @param null|array|string $opts
160
     *
161
     * @throws \Stripe\Exception\ApiErrorException if the request fails
162
     *
163
     * @return \Stripe\Checkout\Session
164
     */
165
    public static function retrieve($id, $opts = null)
1✔
166
    {
167
        $opts = \Stripe\Util\RequestOptions::parse($opts);
1✔
168
        $instance = new static($id, $opts);
1✔
169
        $instance->refresh();
1✔
170

171
        return $instance;
1✔
172
    }
173

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

188
        return $this;
×
189
    }
190

191
    /**
192
     * @param string $id
193
     * @param null|array $params
194
     * @param null|array|string $opts
195
     *
196
     * @throws \Stripe\Exception\ApiErrorException if the request fails
197
     *
198
     * @return \Stripe\Collection<\Stripe\LineItem> list of line items
199
     */
200
    public static function allLineItems($id, $params = null, $opts = null)
1✔
201
    {
202
        $url = static::resourceUrl($id) . '/line_items';
1✔
203
        list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
1✔
204
        $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
1✔
205
        $obj->setLastResponse($response);
1✔
206

207
        return $obj;
1✔
208
    }
209
}
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

© 2024 Coveralls, Inc