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

stripe / stripe-php / #7055

pending completion
#7055

push

php-coveralls

anniel-stripe
Bump version to 10.14.0-beta.1

1802 of 2678 relevant lines covered (67.29%)

3.74 hits per line

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

46.15
/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
9
 * customer. We recommend that you create exactly one PaymentIntent for each order
10
 * or 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 <a
14
 * href="https://stripe.com/docs/payments/intents#intent-statuses">multiple
15
 * statuses</a> 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
19
 * href="https://stripe.com/docs/payments/payment-intents">Payment Intents API</a>.
20
 *
21
 * @property string $id Unique identifier for the object.
22
 * @property string $object String representing the object's type. Objects of the same type share the same value.
23
 * @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).
24
 * @property int $amount_capturable Amount that can be captured from this PaymentIntent.
25
 * @property null|\Stripe\StripeObject $amount_details
26
 * @property int $amount_received Amount that was collected by this PaymentIntent.
27
 * @property null|string|\Stripe\StripeObject $application ID of the Connect application that created the PaymentIntent.
28
 * @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>.
29
 * @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>
30
 * @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.
31
 * @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>).
32
 * @property string $capture_method Controls when the funds will be captured from the customer's account.
33
 * @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>
34
 * @property string $confirmation_method
35
 * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
36
 * @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>.
37
 * @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>
38
 * @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users.
39
 * @property null|string|\Stripe\Invoice $invoice ID of the invoice that created this PaymentIntent, if it exists.
40
 * @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.
41
 * @property null|string|\Stripe\Charge $latest_charge The latest charge created by this payment intent.
42
 * @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.
43
 * @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. For more information, see the <a href="https://stripe.com/docs/payments/payment-intents/creating-payment-intents#storing-information-in-metadata">documentation</a>.
44
 * @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.
45
 * @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.
46
 * @property null|string|\Stripe\PaymentMethod $payment_method ID of the payment method used in 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 $secret_key_confirmation Indicates whether confirmation for this PaymentIntent using a secret key is <code>required</code> or <code>optional</code>.
53
 * @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>
54
 * @property null|\Stripe\StripeObject $shipping Shipping information for this PaymentIntent.
55
 * @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.
56
 * @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.
57
 * @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.
58
 * @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>.
59
 * @property null|\Stripe\StripeObject $transfer_data The data with which to automatically create a Transfer when the payment is finalized. See the PaymentIntents <a href="https://stripe.com/docs/payments/connected-accounts">use case for connected accounts</a> for details.
60
 * @property null|string $transfer_group A string that identifies the resulting payment as part of a group. See the PaymentIntents <a href="https://stripe.com/docs/payments/connected-accounts">use case for connected accounts</a> for details.
61
 */
62
class PaymentIntent extends ApiResource
63
{
64
    const OBJECT_NAME = 'payment_intent';
65

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

72
    const SECRET_KEY_CONFIRMATION_OPTIONAL = 'optional';
73
    const SECRET_KEY_CONFIRMATION_REQUIRED = 'required';
74

75
    const STATUS_CANCELED = 'canceled';
76
    const STATUS_PROCESSING = 'processing';
77
    const STATUS_REQUIRES_ACTION = 'requires_action';
78
    const STATUS_REQUIRES_CAPTURE = 'requires_capture';
79
    const STATUS_REQUIRES_CONFIRMATION = 'requires_confirmation';
80
    const STATUS_REQUIRES_PAYMENT_METHOD = 'requires_payment_method';
81
    const STATUS_SUCCEEDED = 'succeeded';
82

83
    /**
84
     * @param null|array $params
85
     * @param null|array|string $opts
86
     *
87
     * @throws \Stripe\Exception\ApiErrorException if the request fails
88
     *
89
     * @return \Stripe\PaymentIntent the applied payment intent
90
     */
91
    public function applyCustomerBalance($params = null, $opts = null)
92
    {
93
        $url = $this->instanceUrl() . '/apply_customer_balance';
×
94
        list($response, $opts) = $this->_request('post', $url, $params, $opts);
×
95
        $this->refreshFrom($response, $opts);
×
96

97
        return $this;
×
98
    }
99

100
    /**
101
     * @param null|array $params
102
     * @param null|array|string $opts
103
     *
104
     * @throws \Stripe\Exception\ApiErrorException if the request fails
105
     *
106
     * @return \Stripe\PaymentIntent the canceled payment intent
107
     */
108
    public function cancel($params = null, $opts = null)
109
    {
110
        $url = $this->instanceUrl() . '/cancel';
1✔
111
        list($response, $opts) = $this->_request('post', $url, $params, $opts);
1✔
112
        $this->refreshFrom($response, $opts);
1✔
113

114
        return $this;
1✔
115
    }
116

117
    /**
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\PaymentIntent the captured payment intent
124
     */
125
    public function capture($params = null, $opts = null)
126
    {
127
        $url = $this->instanceUrl() . '/capture';
1✔
128
        list($response, $opts) = $this->_request('post', $url, $params, $opts);
1✔
129
        $this->refreshFrom($response, $opts);
1✔
130

131
        return $this;
1✔
132
    }
133

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

148
        return $this;
1✔
149
    }
150

151
    /**
152
     * @param null|array $params
153
     * @param null|array|string $opts
154
     *
155
     * @throws \Stripe\Exception\ApiErrorException if the request fails
156
     *
157
     * @return \Stripe\PaymentIntent the incremented payment intent
158
     */
159
    public function incrementAuthorization($params = null, $opts = null)
160
    {
161
        $url = $this->instanceUrl() . '/increment_authorization';
×
162
        list($response, $opts) = $this->_request('post', $url, $params, $opts);
×
163
        $this->refreshFrom($response, $opts);
×
164

165
        return $this;
×
166
    }
167

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

182
        return $this;
×
183
    }
184

185
    /**
186
     * @param null|array $params
187
     * @param null|array|string $opts
188
     *
189
     * @throws \Stripe\Exception\ApiErrorException if the request fails
190
     *
191
     * @return \Stripe\SearchResult<PaymentIntent> the payment intent search results
192
     */
193
    public static function search($params = null, $opts = null)
194
    {
195
        $url = '/v1/payment_intents/search';
×
196

197
        return self::_searchResource($url, $params, $opts);
×
198
    }
199
}
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