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

stripe / stripe-php / 6471862601

10 Oct 2023 04:02PM UTC coverage: 69.665% (-0.5%) from 70.141%
6471862601

push

github

web-flow
Merge pull request #1570 from localheinz/feature/coveralls

Enhancement: Use `coverallsapp/github-action` to report code coverage

2393 of 3435 relevant lines covered (69.67%)

3.5 hits per line

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

45.45
/lib/PaymentIntent.php
1
<?php
2

3
// File generated from our OpenAPI spec
4

5
namespace Stripe;
6

7
/**
8
 * A PaymentIntent guides you through the process of collecting a payment from your customer.
9
 * We recommend that you create exactly one PaymentIntent for each order or
10
 * customer session in your system. You can reference the PaymentIntent later to
11
 * see the history of payment attempts for a particular session.
12
 *
13
 * A PaymentIntent transitions through
14
 * <a href="https://stripe.com/docs/payments/intents#intent-statuses">multiple statuses</a>
15
 * throughout its lifetime as it interfaces with Stripe.js to perform
16
 * authentication flows and ultimately creates at most one successful charge.
17
 *
18
 * Related guide: <a href="https://stripe.com/docs/payments/payment-intents">Payment Intents API</a>
19
 *
20
 * @property string $id Unique identifier for the object.
21
 * @property string $object String representing the object's type. Objects of the same type share the same value.
22
 * @property int $amount Amount intended to be collected by this PaymentIntent. A positive integer representing how much to charge 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). The minimum amount is $0.50 US or <a href="https://stripe.com/docs/currencies#minimum-and-maximum-charge-amounts">equivalent in charge currency</a>. The amount value supports up to eight digits (e.g., a value of 99999999 for a USD charge of $999,999.99).
23
 * @property int $amount_capturable Amount that can be captured from this PaymentIntent.
24
 * @property null|\Stripe\StripeObject $amount_details
25
 * @property int $amount_received Amount that this PaymentIntent collects.
26
 * @property null|string|\Stripe\StripeObject $application ID of the Connect application that created the PaymentIntent.
27
 * @property null|int $application_fee_amount The amount of the application fee (if any) that will be requested to be applied to the payment and transferred to the application owner's Stripe account. The amount of the application fee collected will be capped at the total payment amount. For more information, see the PaymentIntents <a href="https://stripe.com/docs/payments/connected-accounts">use case for connected accounts</a>.
28
 * @property null|\Stripe\StripeObject $automatic_payment_methods Settings to configure compatible payment methods from the <a href="https://dashboard.stripe.com/settings/payment_methods">Stripe Dashboard</a>
29
 * @property null|int $canceled_at Populated when <code>status</code> is <code>canceled</code>, this is the time at which the PaymentIntent was canceled. Measured in seconds since the Unix epoch.
30
 * @property null|string $cancellation_reason Reason for cancellation of this PaymentIntent, either user-provided (<code>duplicate</code>, <code>fraudulent</code>, <code>requested_by_customer</code>, or <code>abandoned</code>) or generated by Stripe internally (<code>failed_invoice</code>, <code>void_invoice</code>, or <code>automatic</code>).
31
 * @property string $capture_method Controls when the funds will be captured from the customer's account.
32
 * @property null|string $client_secret <p>The client secret of this PaymentIntent. Used for client-side retrieval using a publishable key.</p><p>The client secret can be used to complete a payment from your frontend. It should not be stored, logged, 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 to <a href="https://stripe.com/docs/payments/accept-a-payment?ui=elements">accept a payment</a> and learn about how <code>client_secret</code> should be handled.</p>
33
 * @property string $confirmation_method
34
 * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
35
 * @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>.
36
 * @property null|string|\Stripe\Customer $customer <p>ID of the Customer this PaymentIntent belongs to, if one exists.</p><p>Payment methods attached to other Customers cannot be used with this PaymentIntent.</p><p>If present in combination with <a href="https://stripe.com/docs/api#payment_intent_object-setup_future_usage">setup_future_usage</a>, this PaymentIntent's payment method will be attached to the Customer after the PaymentIntent has been confirmed and any required actions from the user are complete.</p>
37
 * @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users.
38
 * @property null|string|\Stripe\Invoice $invoice ID of the invoice that created this PaymentIntent, if it exists.
39
 * @property null|\Stripe\StripeObject $last_payment_error The payment error encountered in the previous PaymentIntent confirmation. It will be cleared if the PaymentIntent is later updated for any reason.
40
 * @property null|string|\Stripe\Charge $latest_charge The latest charge created by this PaymentIntent.
41
 * @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.
42
 * @property \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. Learn more about <a href="https://stripe.com/docs/payments/payment-intents/creating-payment-intents#storing-information-in-metadata">storing information in metadata</a>.
43
 * @property null|\Stripe\StripeObject $next_action If present, this property tells you what actions you need to take in order for your customer to fulfill a payment using the provided source.
44
 * @property null|string|\Stripe\Account $on_behalf_of The account (if any) for which the funds of the PaymentIntent are intended. See the PaymentIntents <a href="https://stripe.com/docs/payments/connected-accounts">use case for connected accounts</a> for details.
45
 * @property null|string|\Stripe\PaymentMethod $payment_method ID of the payment method used in this PaymentIntent.
46
 * @property null|\Stripe\StripeObject $payment_method_configuration_details Information about the payment method configuration used for this PaymentIntent.
47
 * @property null|\Stripe\StripeObject $payment_method_options Payment-method-specific configuration for this PaymentIntent.
48
 * @property string[] $payment_method_types The list of payment method types (e.g. card) that this PaymentIntent is allowed to use.
49
 * @property null|\Stripe\StripeObject $processing If present, this property tells you about the processing state of the payment.
50
 * @property null|string $receipt_email Email address that the receipt for the resulting payment will be sent to. If <code>receipt_email</code> is specified for a payment in live mode, a receipt will be sent regardless of your <a href="https://dashboard.stripe.com/account/emails">email settings</a>.
51
 * @property null|string|\Stripe\Review $review ID of the review associated with this PaymentIntent, if any.
52
 * @property null|string $setup_future_usage <p>Indicates that you intend to make future payments with this PaymentIntent's payment method.</p><p>Providing this parameter will <a href="https://stripe.com/docs/payments/save-during-payment">attach the payment method</a> to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be <a href="https://stripe.com/docs/api/payment_methods/attach">attached</a> to a Customer after the transaction completes.</p><p>When processing card payments, Stripe also uses <code>setup_future_usage</code> to dynamically optimize your payment flow and comply with regional legislation and network rules, such as <a href="https://stripe.com/docs/strong-customer-authentication">SCA</a>.</p>
53
 * @property null|\Stripe\StripeObject $shipping Shipping information for this PaymentIntent.
54
 * @property null|string|\Stripe\Account|\Stripe\BankAccount|\Stripe\Card|\Stripe\Source $source This is a legacy field that will be removed in the future. It is the ID of the Source object that is associated with this PaymentIntent, if one was supplied.
55
 * @property null|string $statement_descriptor For non-card charges, you can use this value as the complete description that appears on your customers’ statements. Must contain at least one letter, maximum 22 characters.
56
 * @property null|string $statement_descriptor_suffix Provides information about a card payment that customers see on their statements. Concatenated with the prefix (shortened descriptor) or statement descriptor that’s set on the account to form the complete statement descriptor. Maximum 22 characters for the concatenated descriptor.
57
 * @property string $status Status of this PaymentIntent, one of <code>requires_payment_method</code>, <code>requires_confirmation</code>, <code>requires_action</code>, <code>processing</code>, <code>requires_capture</code>, <code>canceled</code>, or <code>succeeded</code>. Read more about each PaymentIntent <a href="https://stripe.com/docs/payments/intents#intent-statuses">status</a>.
58
 * @property null|\Stripe\StripeObject $transfer_data The data that automatically creates a Transfer after the payment finalizes. Learn more about the <a href="https://stripe.com/docs/payments/connected-accounts">use case for connected accounts</a>.
59
 * @property null|string $transfer_group A string that identifies the resulting payment as part of a group. Learn more about the <a href="https://stripe.com/docs/connect/separate-charges-and-transfers">use case for connected accounts</a>.
60
 */
61
class PaymentIntent extends ApiResource
62
{
63
    const OBJECT_NAME = 'payment_intent';
64

65
    use ApiOperations\All;
66
    use ApiOperations\Create;
67
    use ApiOperations\Retrieve;
68
    use ApiOperations\Search;
69
    use ApiOperations\Update;
70

71
    const CANCELLATION_REASON_ABANDONED = 'abandoned';
72
    const CANCELLATION_REASON_AUTOMATIC = 'automatic';
73
    const CANCELLATION_REASON_DUPLICATE = 'duplicate';
74
    const CANCELLATION_REASON_FAILED_INVOICE = 'failed_invoice';
75
    const CANCELLATION_REASON_FRAUDULENT = 'fraudulent';
76
    const CANCELLATION_REASON_REQUESTED_BY_CUSTOMER = 'requested_by_customer';
77
    const CANCELLATION_REASON_VOID_INVOICE = 'void_invoice';
78

79
    const CAPTURE_METHOD_AUTOMATIC = 'automatic';
80
    const CAPTURE_METHOD_AUTOMATIC_ASYNC = 'automatic_async';
81
    const CAPTURE_METHOD_MANUAL = 'manual';
82

83
    const CONFIRMATION_METHOD_AUTOMATIC = 'automatic';
84
    const CONFIRMATION_METHOD_MANUAL = 'manual';
85

86
    const SETUP_FUTURE_USAGE_OFF_SESSION = 'off_session';
87
    const SETUP_FUTURE_USAGE_ON_SESSION = 'on_session';
88

89
    const STATUS_CANCELED = 'canceled';
90
    const STATUS_PROCESSING = 'processing';
91
    const STATUS_REQUIRES_ACTION = 'requires_action';
92
    const STATUS_REQUIRES_CAPTURE = 'requires_capture';
93
    const STATUS_REQUIRES_CONFIRMATION = 'requires_confirmation';
94
    const STATUS_REQUIRES_PAYMENT_METHOD = 'requires_payment_method';
95
    const STATUS_SUCCEEDED = 'succeeded';
96

97
    /**
98
     * @param null|array $params
99
     * @param null|array|string $opts
100
     *
101
     * @throws \Stripe\Exception\ApiErrorException if the request fails
102
     *
103
     * @return \Stripe\PaymentIntent the applied payment intent
104
     */
105
    public function applyCustomerBalance($params = null, $opts = null)
×
106
    {
107
        $url = $this->instanceUrl() . '/apply_customer_balance';
×
108
        list($response, $opts) = $this->_request('post', $url, $params, $opts);
×
109
        $this->refreshFrom($response, $opts);
×
110

111
        return $this;
×
112
    }
113

114
    /**
115
     * @param null|array $params
116
     * @param null|array|string $opts
117
     *
118
     * @throws \Stripe\Exception\ApiErrorException if the request fails
119
     *
120
     * @return \Stripe\PaymentIntent the canceled payment intent
121
     */
122
    public function cancel($params = null, $opts = null)
1✔
123
    {
124
        $url = $this->instanceUrl() . '/cancel';
1✔
125
        list($response, $opts) = $this->_request('post', $url, $params, $opts);
1✔
126
        $this->refreshFrom($response, $opts);
1✔
127

128
        return $this;
1✔
129
    }
130

131
    /**
132
     * @param null|array $params
133
     * @param null|array|string $opts
134
     *
135
     * @throws \Stripe\Exception\ApiErrorException if the request fails
136
     *
137
     * @return \Stripe\PaymentIntent the captured payment intent
138
     */
139
    public function capture($params = null, $opts = null)
1✔
140
    {
141
        $url = $this->instanceUrl() . '/capture';
1✔
142
        list($response, $opts) = $this->_request('post', $url, $params, $opts);
1✔
143
        $this->refreshFrom($response, $opts);
1✔
144

145
        return $this;
1✔
146
    }
147

148
    /**
149
     * @param null|array $params
150
     * @param null|array|string $opts
151
     *
152
     * @throws \Stripe\Exception\ApiErrorException if the request fails
153
     *
154
     * @return \Stripe\PaymentIntent the confirmed payment intent
155
     */
156
    public function confirm($params = null, $opts = null)
1✔
157
    {
158
        $url = $this->instanceUrl() . '/confirm';
1✔
159
        list($response, $opts) = $this->_request('post', $url, $params, $opts);
1✔
160
        $this->refreshFrom($response, $opts);
1✔
161

162
        return $this;
1✔
163
    }
164

165
    /**
166
     * @param null|array $params
167
     * @param null|array|string $opts
168
     *
169
     * @throws \Stripe\Exception\ApiErrorException if the request fails
170
     *
171
     * @return \Stripe\PaymentIntent the incremented payment intent
172
     */
173
    public function incrementAuthorization($params = null, $opts = null)
×
174
    {
175
        $url = $this->instanceUrl() . '/increment_authorization';
×
176
        list($response, $opts) = $this->_request('post', $url, $params, $opts);
×
177
        $this->refreshFrom($response, $opts);
×
178

179
        return $this;
×
180
    }
181

182
    /**
183
     * @param null|array $params
184
     * @param null|array|string $opts
185
     *
186
     * @throws \Stripe\Exception\ApiErrorException if the request fails
187
     *
188
     * @return \Stripe\PaymentIntent the verified payment intent
189
     */
190
    public function verifyMicrodeposits($params = null, $opts = null)
×
191
    {
192
        $url = $this->instanceUrl() . '/verify_microdeposits';
×
193
        list($response, $opts) = $this->_request('post', $url, $params, $opts);
×
194
        $this->refreshFrom($response, $opts);
×
195

196
        return $this;
×
197
    }
198

199
    /**
200
     * @param null|array $params
201
     * @param null|array|string $opts
202
     *
203
     * @throws \Stripe\Exception\ApiErrorException if the request fails
204
     *
205
     * @return \Stripe\SearchResult<\Stripe\PaymentIntent> the payment intent search results
206
     */
207
    public static function search($params = null, $opts = null)
×
208
    {
209
        $url = '/v1/payment_intents/search';
×
210

211
        return self::_searchResource($url, $params, $opts);
×
212
    }
213
}
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