Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Updates #1263

Merged
merged 2 commits into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion lib/PaymentIntent.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @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>).
* @property string $capture_method Controls when the funds will be captured from the customer's account.
* @property \Stripe\Collection<\Stripe\Charge> $charges Charges that were created by this PaymentIntent, if any.
* @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, 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 to <a href="https://stripe.com/docs/payments/accept-a-payment?integration=elements">accept a payment</a> and learn about how <code>client_secret</code> should be handled.</p>
* @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>
* @property string $confirmation_method
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @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>.
Expand Down Expand Up @@ -143,6 +143,23 @@ public function confirm($params = null, $opts = null)
return $this;
}

/**
* @param null|array $params
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\PaymentIntent the incremented payment intent
*/
public function incrementAuthorization($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/increment_authorization';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);

return $this;
}

/**
* @param null|array $params
* @param null|array|string $opts
Expand Down
8 changes: 4 additions & 4 deletions lib/PaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
namespace Stripe;

/**
* PaymentMethod objects represent your customer's payment instruments. They can be
* used with <a
* PaymentMethod objects represent your customer's payment instruments. You can use
* them with <a
* href="https://stripe.com/docs/payments/payment-intents">PaymentIntents</a> to
* collect payments or saved to Customer objects to store instrument details for
* future payments.
* collect payments or save them to Customer objects to store instrument details
* for future payments.
*
* Related guides: <a
* href="https://stripe.com/docs/payments/payment-methods">Payment Methods</a> and
Expand Down
41 changes: 41 additions & 0 deletions lib/Service/PaymentIntentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,47 @@ public function create($params = null, $opts = null)
return $this->request('post', '/v1/payment_intents', $params, $opts);
}

/**
* Perform an incremental authorization on an eligible <a
* href="/docs/api/payment_intents/object">PaymentIntent</a>. To be eligible, the
* PaymentIntent’s status must be <code>requires_capture</code> and <a
* href="/docs/api/charges/object#charge_object-payment_method_details-card_present-incremental_authorization_supported">incremental_authorization_supported</a>
* must be <code>true</code>.
*
* Incremental authorizations attempt to increase the authorized amount on your
* customer’s card to the new, higher <code>amount</code> provided. As with the
* initial authorization, incremental authorizations may be declined. A single
* PaymentIntent can call this endpoint multiple times to further increase the
* authorized amount.
*
* If the incremental authorization succeeds, the PaymentIntent object is returned
* with the updated <a
* href="/docs/api/payment_intents/object#payment_intent_object-amount">amount</a>.
* If the incremental authorization fails, a <a
* href="/docs/error-codes#card-declined">card_declined</a> error is returned, and
* no fields on the PaymentIntent or Charge are updated. The PaymentIntent object
* remains capturable for the previously authorized amount.
*
* Each PaymentIntent can have a maximum of 10 incremental authorization attempts,
* including declines. Once captured, a PaymentIntent can no longer be incremented.
*
* Learn more about <a
* href="/docs/terminal/features/incremental-authorizations">incremental
* authorizations</a>.
*
* @param string $id
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\PaymentIntent
*/
public function incrementAuthorization($id, $params = null, $opts = null)
{
return $this->request('post', $this->buildPath('/v1/payment_intents/%s/increment_authorization', $id), $params, $opts);
}

/**
* Retrieves the details of a PaymentIntent that has previously been created.
*
Expand Down
2 changes: 1 addition & 1 deletion lib/SetupIntent.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
* @property string $object String representing the object's type. Objects of the same type share the same value.
* @property null|string|\Stripe\StripeObject $application ID of the Connect application that created the SetupIntent.
* @property null|string $cancellation_reason Reason for cancellation of this SetupIntent, one of <code>abandoned</code>, <code>requested_by_customer</code>, or <code>duplicate</code>.
* @property null|string $client_secret <p>The client secret of this SetupIntent. Used for client-side retrieval using a publishable key.</p><p>The client secret can be used to complete payment setup 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>
* @property null|string $client_secret <p>The client secret of this SetupIntent. Used for client-side retrieval using a publishable key.</p><p>The client secret can be used to complete payment setup 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>
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property null|string|\Stripe\Customer $customer <p>ID of the Customer this SetupIntent belongs to, if one exists.</p><p>If present, the SetupIntent's payment method will be attached to the Customer on successful setup. Payment methods attached to other Customers cannot be used with this SetupIntent.</p>
* @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users.
Expand Down