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 #1203

Merged
merged 2 commits into from
Nov 16, 2021
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
2 changes: 2 additions & 0 deletions init.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
require __DIR__ . '/lib/Review.php';
require __DIR__ . '/lib/SetupAttempt.php';
require __DIR__ . '/lib/SetupIntent.php';
require __DIR__ . '/lib/ShippingRate.php';
require __DIR__ . '/lib/Sigma/ScheduledQueryRun.php';
require __DIR__ . '/lib/SKU.php';
require __DIR__ . '/lib/Source.php';
Expand Down Expand Up @@ -215,6 +216,7 @@
require __DIR__ . '/lib/Service/ReviewService.php';
require __DIR__ . '/lib/Service/SetupAttemptService.php';
require __DIR__ . '/lib/Service/SetupIntentService.php';
require __DIR__ . '/lib/Service/ShippingRateService.php';
require __DIR__ . '/lib/Service/Sigma/ScheduledQueryRunService.php';
require __DIR__ . '/lib/Service/SkuService.php';
require __DIR__ . '/lib/Service/SourceService.php';
Expand Down
29 changes: 27 additions & 2 deletions lib/Checkout/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
/**
* A Checkout Session represents your customer's session as they pay for one-time
* purchases or subscriptions through <a
* href="https://stripe.com/docs/payments/checkout">Checkout</a>. We recommend
* creating a new Session each time your customer attempts to pay.
* href="https://stripe.com/docs/payments/checkout">Checkout</a> or <a
* href="https://stripe.com/docs/payments/payment-links">Payment Links</a>. We
* recommend creating a new Session each time your customer attempts to pay.
*
* Once payment is successful, the Checkout Session will contain a reference to the
* <a href="https://stripe.com/docs/api/customers">Customer</a>, and either the
Expand Down Expand Up @@ -53,6 +54,9 @@
* @property null|string|\Stripe\SetupIntent $setup_intent The ID of the SetupIntent for Checkout Sessions in <code>setup</code> mode.
* @property null|\Stripe\StripeObject $shipping Shipping information for this Checkout Session.
* @property null|\Stripe\StripeObject $shipping_address_collection When set, provides configuration for Checkout to collect a shipping address from a customer.
* @property \Stripe\StripeObject[] $shipping_options The shipping rate options applied to this Session.
* @property null|string|\Stripe\ShippingRate $shipping_rate The ID of the ShippingRate for Checkout Sessions in <code>payment</code> mode.
* @property null|string $status The status of the Checkout Session, one of <code>open</code>, <code>complete</code>, or <code>expired</code>.
* @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, but not Checkout Sessions in <code>subscription</code> or <code>setup</code> mode.
* @property null|string|\Stripe\Subscription $subscription The ID of the subscription for Checkout Sessions in <code>subscription</code> mode.
* @property string $success_url The URL the customer will be directed to after the payment or subscription creation is successful.
Expand Down Expand Up @@ -80,11 +84,32 @@ class Session extends \Stripe\ApiResource
const PAYMENT_STATUS_PAID = 'paid';
const PAYMENT_STATUS_UNPAID = 'unpaid';

const STATUS_COMPLETE = 'complete';
const STATUS_EXPIRED = 'expired';
const STATUS_OPEN = 'open';

const SUBMIT_TYPE_AUTO = 'auto';
const SUBMIT_TYPE_BOOK = 'book';
const SUBMIT_TYPE_DONATE = 'donate';
const SUBMIT_TYPE_PAY = 'pay';

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

return $this;
}

const PATH_LINE_ITEMS = '/line_items';

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @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>.
* @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.
* @property null|string $lookup_key A lookup key used to retrieve prices dynamically from a static string.
* @property null|string $lookup_key A lookup key used to retrieve prices dynamically from a static string. This may be up to 200 characters.
* @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.
* @property null|string $nickname A brief description of the price, hidden from customers.
* @property string|\Stripe\Product $product The ID of the product this price is associated with.
Expand Down
7 changes: 4 additions & 3 deletions lib/Service/ChargeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ public function all($params = null, $opts = null)
* of the two-step payment flow, where first you <a href="#create_charge">created a
* charge</a> with the capture option set to false.
*
* Uncaptured payments expire exactly seven days after they are created. If they
* are not captured by that point in time, they will be marked as refunded and will
* no longer be capturable.
* Uncaptured payments expire a set number of days after they are created (<a
* href="/docs/charges/placing-a-hold">7 by default</a>). If they are not captured
* by that point in time, they will be marked as refunded and will no longer be
* capturable.
*
* @param string $id
* @param null|array $params
Expand Down
19 changes: 19 additions & 0 deletions lib/Service/Checkout/SessionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,25 @@ public function create($params = null, $opts = null)
return $this->request('post', '/v1/checkout/sessions', $params, $opts);
}

/**
* A Session can be expired when it is in one of these statuses: <code>open</code>.
*
* After it expires, a customer can’t complete a Session and customers loading the
* Session see a message saying the Session is expired.
*
* @param string $id
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Checkout\Session
*/
public function expire($id, $params = null, $opts = null)
{
return $this->request('post', $this->buildPath('/v1/checkout/sessions/%s/expire', $id), $params, $opts);
}

/**
* Retrieves a Session object.
*
Expand Down
2 changes: 2 additions & 0 deletions lib/Service/CoreServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
* @property ReviewService $reviews
* @property SetupAttemptService $setupAttempts
* @property SetupIntentService $setupIntents
* @property ShippingRateService $shippingRates
* @property Sigma\SigmaServiceFactory $sigma
* @property SkuService $skus
* @property SourceService $sources
Expand Down Expand Up @@ -109,6 +110,7 @@ class CoreServiceFactory extends \Stripe\Service\AbstractServiceFactory
'reviews' => ReviewService::class,
'setupAttempts' => SetupAttemptService::class,
'setupIntents' => SetupIntentService::class,
'shippingRates' => ShippingRateService::class,
'sigma' => Sigma\SigmaServiceFactory::class,
'skus' => SkuService::class,
'sources' => SourceService::class,
Expand Down
4 changes: 2 additions & 2 deletions lib/Service/PaymentIntentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public function cancel($id, $params = null, $opts = null)
* Capture the funds of an existing uncaptured PaymentIntent when its status is
* <code>requires_capture</code>.
*
* Uncaptured PaymentIntents will be canceled exactly seven days after they are
* created.
* Uncaptured PaymentIntents will be canceled a set number of days after they are
* created (7 by default).
*
* Learn more about <a href="/docs/payments/capture-later">separate authorization
* and capture</a>.
Expand Down
4 changes: 3 additions & 1 deletion lib/Service/PaymentMethodService.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
class PaymentMethodService extends \Stripe\Service\AbstractService
{
/**
* Returns a list of PaymentMethods for a given Customer.
* Returns a list of PaymentMethods. For listing a customer’s payment methods, you
* should use <a href="/docs/api/payment_methods/customer_list">List a Customer’s
* PaymentMethods</a>.
*
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
Expand Down
70 changes: 70 additions & 0 deletions lib/Service/ShippingRateService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

// File generated from our OpenAPI spec

namespace Stripe\Service;

class ShippingRateService extends \Stripe\Service\AbstractService
{
/**
* Returns a list of your shipping rates.
*
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Collection
*/
public function all($params = null, $opts = null)
{
return $this->requestCollection('get', '/v1/shipping_rates', $params, $opts);
}

/**
* Creates a new shipping rate object.
*
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\ShippingRate
*/
public function create($params = null, $opts = null)
{
return $this->request('post', '/v1/shipping_rates', $params, $opts);
}

/**
* Returns the shipping rate object with the given ID.
*
* @param string $id
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\ShippingRate
*/
public function retrieve($id, $params = null, $opts = null)
{
return $this->request('get', $this->buildPath('/v1/shipping_rates/%s', $id), $params, $opts);
}

/**
* Updates an existing shipping rate object.
*
* @param string $id
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\ShippingRate
*/
public function update($id, $params = null, $opts = null)
{
return $this->request('post', $this->buildPath('/v1/shipping_rates/%s', $id), $params, $opts);
}
}
40 changes: 40 additions & 0 deletions lib/ShippingRate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

// File generated from our OpenAPI spec

namespace Stripe;

/**
* Shipping rates describe the price of shipping presented to your customers and
* can be applied to <a
* href="https://stripe.com/docs/payments/checkout/shipping">Checkout Sessions</a>
* to collect shipping costs.
*
* @property string $id Unique identifier for the object.
* @property string $object String representing the object's type. Objects of the same type share the same value.
* @property bool $active Whether the shipping rate can be used for new purchases. Defaults to <code>true</code>.
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property null|\Stripe\StripeObject $delivery_estimate The estimated range for how long shipping will take, meant to be displayable to the customer. This will appear on CheckoutSessions.
* @property null|string $display_name The name of the shipping rate, meant to be displayable to the customer. This will appear on CheckoutSessions.
* @property \Stripe\StripeObject $fixed_amount
* @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.
* @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.
* @property null|string $tax_behavior Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. One of <code>inclusive</code>, <code>exclusive</code>, or <code>unspecified</code>.
* @property null|string|\Stripe\TaxCode $tax_code A <a href="https://stripe.com/docs/tax/tax-codes">tax code</a> ID. The Shipping tax code is <code>txcd_92010001</code>.
* @property string $type The type of calculation to use on the shipping rate. Can only be <code>fixed_amount</code> for now.
*/
class ShippingRate extends ApiResource
{
const OBJECT_NAME = 'shipping_rate';

use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Retrieve;
use ApiOperations\Update;

const TAX_BEHAVIOR_EXCLUSIVE = 'exclusive';
const TAX_BEHAVIOR_INCLUSIVE = 'inclusive';
const TAX_BEHAVIOR_UNSPECIFIED = 'unspecified';

const TYPE_FIXED_AMOUNT = 'fixed_amount';
}
1 change: 1 addition & 0 deletions lib/StripeClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
* @property \Stripe\Service\ReviewService $reviews
* @property \Stripe\Service\SetupAttemptService $setupAttempts
* @property \Stripe\Service\SetupIntentService $setupIntents
* @property \Stripe\Service\ShippingRateService $shippingRates
* @property \Stripe\Service\Sigma\SigmaServiceFactory $sigma
* @property \Stripe\Service\SkuService $skus
* @property \Stripe\Service\SourceService $sources
Expand Down
6 changes: 3 additions & 3 deletions lib/Terminal/ConnectionToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
/**
* A Connection Token is used by the Stripe Terminal SDK to connect to a reader.
*
* Related guide: <a
* href="https://stripe.com/docs/terminal/creating-locations">Fleet Management</a>.
* Related guide: <a href="https://stripe.com/docs/terminal/fleet/locations">Fleet
* Management</a>.
*
* @property string $object String representing the object's type. Objects of the same type share the same value.
* @property string $location The id of the location that this connection token is scoped to. Note that location scoping only applies to internet-connected readers. For more details, see <a href="https://stripe.com/docs/terminal/readers/fleet-management#connection-tokens">the docs on scoping connection tokens</a>.
* @property string $location The id of the location that this connection token is scoped to. Note that location scoping only applies to internet-connected readers. For more details, see <a href="https://stripe.com/docs/terminal/fleet/locations#connection-tokens">the docs on scoping connection tokens</a>.
* @property string $secret Your application should pass this token to the Stripe Terminal SDK.
*/
class ConnectionToken extends \Stripe\ApiResource
Expand Down
4 changes: 2 additions & 2 deletions lib/Terminal/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
/**
* A Location represents a grouping of readers.
*
* Related guide: <a
* href="https://stripe.com/docs/terminal/creating-locations">Fleet Management</a>.
* Related guide: <a href="https://stripe.com/docs/terminal/fleet/locations">Fleet
* Management</a>.
*
* @property string $id Unique identifier for the object.
* @property string $object String representing the object's type. Objects of the same type share the same value.
Expand Down
2 changes: 1 addition & 1 deletion lib/Terminal/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* A Reader represents a physical device for accepting payment details.
*
* Related guide: <a
* href="https://stripe.com/docs/terminal/readers/connecting">Connecting to a
* href="https://stripe.com/docs/terminal/payments/connect-reader">Connecting to a
* Reader</a>.
*
* @property string $id Unique identifier for the object.
Expand Down
1 change: 1 addition & 0 deletions lib/Util/ObjectTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class ObjectTypes
\Stripe\Review::OBJECT_NAME => \Stripe\Review::class,
\Stripe\SetupAttempt::OBJECT_NAME => \Stripe\SetupAttempt::class,
\Stripe\SetupIntent::OBJECT_NAME => \Stripe\SetupIntent::class,
\Stripe\ShippingRate::OBJECT_NAME => \Stripe\ShippingRate::class,
\Stripe\Sigma\ScheduledQueryRun::OBJECT_NAME => \Stripe\Sigma\ScheduledQueryRun::class,
\Stripe\SKU::OBJECT_NAME => \Stripe\SKU::class,
\Stripe\Source::OBJECT_NAME => \Stripe\Source::class,
Expand Down
Loading