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 for beta branch #1325

Merged
merged 8 commits into from
Jul 19, 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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 8.11.0 - 2022-07-18
* [#1324](https://github.com/stripe/stripe-php/pull/1324) API Updates
* Add support for new value `blik` on enum `PaymentLink.payment_method_types[]`
* Add support for `blik` on `PaymentMethod`
* Add support for new value `blik` on enum `PaymentMethod.type`
* Add `Invoice.upcomingLines` method.
* Add `SourceService.allSourceTransactions` method.
* [#1322](https://github.com/stripe/stripe-php/pull/1322) API Updates
* Change type of `source_type` on `Transfer` from nullable string to string (comment-only change)

## 8.10.0 - 2022-07-07
* [#1319](https://github.com/stripe/stripe-php/pull/1319) API Updates
* Add support for `currency_options` on `Coupon` and `Price`
Expand Down
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v163
v166
2 changes: 2 additions & 0 deletions init.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
require __DIR__ . '/lib/Product.php';
require __DIR__ . '/lib/PromotionCode.php';
require __DIR__ . '/lib/Quote.php';
require __DIR__ . '/lib/QuotePhaseConfiguration.php';
require __DIR__ . '/lib/Radar/EarlyFraudWarning.php';
require __DIR__ . '/lib/Radar/ValueList.php';
require __DIR__ . '/lib/Radar/ValueListItem.php';
Expand Down Expand Up @@ -233,6 +234,7 @@
require __DIR__ . '/lib/Service/ProductService.php';
require __DIR__ . '/lib/Service/PromotionCodeService.php';
require __DIR__ . '/lib/Service/QuoteService.php';
require __DIR__ . '/lib/Service/QuotePhaseConfigurationService.php';
require __DIR__ . '/lib/Service/Radar/EarlyFraudWarningService.php';
require __DIR__ . '/lib/Service/Radar/ValueListService.php';
require __DIR__ . '/lib/Service/Radar/ValueListItemService.php';
Expand Down
44 changes: 19 additions & 25 deletions lib/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,25 @@ public function instanceUrl()
return parent::instanceUrl();
}

/**
* @param null|array|string $id the ID of the account to retrieve, or an
* options array containing an `id` key
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Account
*/
public static function retrieve($id = null, $opts = null)
{
if (!$opts && \is_string($id) && 'sk_' === \substr($id, 0, 3)) {
$opts = $id;
$id = null;
}

return self::_retrieve($id, $opts);
}

public function serializeParameters($force = false)
{
$update = parent::serializeParameters($force);
Expand Down Expand Up @@ -141,25 +160,6 @@ private function serializeAdditionalOwners($legalEntity, $additionalOwners)
return $updateArr;
}

/**
* @param null|array|string $id the ID of the account to retrieve, or an
* options array containing an `id` key
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Account
*/
public static function retrieve($id = null, $opts = null)
{
if (!$opts && \is_string($id) && 'sk_' === \substr($id, 0, 3)) {
$opts = $id;
$id = null;
}

return self::_retrieve($id, $opts);
}

/**
* @param null|array $clientId
* @param null|array|string $opts
Expand Down Expand Up @@ -213,12 +213,6 @@ public function reject($params = null, $opts = null)
return $this;
}

/*
* Capabilities methods
* We can not add the capabilities() method today as the Account object already has a
* capabilities property which is a hash and not the sub-list of capabilities.
*/

const PATH_CAPABILITIES = '/capabilities';

/**
Expand Down
5 changes: 0 additions & 5 deletions lib/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ class File extends ApiResource
create as protected _create;
}

public static function classUrl()
{
return '/v1/files';
}

/**
* @param null|array $params
* @param null|array|string $opts
Expand Down
55 changes: 37 additions & 18 deletions lib/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
* @property null|\Stripe\StripeObject[] $total_discount_amounts The aggregate amounts calculated per discount across all line items.
* @property null|int $total_excluding_tax The integer amount in %s representing the total amount of the invoice including all discounts but excluding all tax.
* @property \Stripe\StripeObject[] $total_tax_amounts The aggregate amounts calculated per tax rate for all line items.
* @property null|\Stripe\StripeObject $transfer_data The account (if any) the payment will be attributed to for tax reporting, and where funds from the payment will be transferred to for the invoice.
* @property null|int $webhooks_delivered_at Invoices are automatically paid or sent 1 hour after webhooks are delivered, or until all webhook delivery attempts have <a href="https://stripe.com/docs/billing/webhooks#understand">been exhausted</a>. This field tracks the time when webhooks for this invoice were successfully delivered. If the invoice had no webhooks to deliver, this will be set while the invoice is being created.
*/
class Invoice extends ApiResource
Expand All @@ -122,13 +123,15 @@ class Invoice extends ApiResource
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Delete;
use ApiOperations\NestedResource;
use ApiOperations\Retrieve;
use ApiOperations\Search;
use ApiOperations\Update;

const BILLING_CHARGE_AUTOMATICALLY = 'charge_automatically';
const BILLING_SEND_INVOICE = 'send_invoice';

const BILLING_REASON_AUTOMATIC_PENDING_INVOICE_ITEM_INVOICE = 'automatic_pending_invoice_item_invoice';
const BILLING_REASON_MANUAL = 'manual';
const BILLING_REASON_QUOTE_ACCEPT = 'quote_accept';
const BILLING_REASON_SUBSCRIPTION = 'subscription';
Expand All @@ -148,24 +151,6 @@ class Invoice extends ApiResource
const STATUS_UNCOLLECTIBLE = 'uncollectible';
const STATUS_VOID = 'void';

use ApiOperations\NestedResource;

const PATH_LINES = '/lines';

/**
* @param string $id the ID of the invoice on which to retrieve the lines
* @param null|array $params
* @param null|array|string $opts
*
* @throws StripeExceptionApiErrorException if the request fails
*
* @return \Stripe\Collection<\Stripe\InvoiceLineItem> the list of lines (InvoiceLineItem)
*/
public static function allLines($id, $params = null, $opts = null)
{
return self::_allNestedResources($id, static::PATH_LINES, $params, $opts);
}

/**
* @param null|array $params
* @param null|array|string $opts
Expand Down Expand Up @@ -252,6 +237,24 @@ public static function upcoming($params = null, $opts = null)
return $obj;
}

/**
* @param null|array $params
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Collection<\Stripe\InvoiceLineItem> list of InvoiceLineItems
*/
public static function upcomingLines($params = null, $opts = null)
{
$url = static::classUrl() . '/upcoming/lines';
list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);

return $obj;
}

/**
* @param null|array $params
* @param null|array|string $opts
Expand Down Expand Up @@ -283,4 +286,20 @@ public static function search($params = null, $opts = null)

return self::_searchResource($url, $params, $opts);
}

const PATH_LINES = '/lines';

/**
* @param string $id the ID of the invoice on which to retrieve the line items
* @param null|array $params
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Collection<\Stripe\LineItem> the list of line items
*/
public static function allLines($id, $params = null, $opts = null)
{
return self::_allNestedResources($id, static::PATH_LINES, $params, $opts);
}
}
2 changes: 1 addition & 1 deletion lib/Issuing/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @property null|string $cancellation_reason The reason why the card was canceled.
* @property \Stripe\Issuing\Cardholder $cardholder <p>An Issuing <code>Cardholder</code> object represents an individual or business entity who is <a href="https://stripe.com/docs/issuing">issued</a> cards.</p><p>Related guide: <a href="https://stripe.com/docs/issuing/cards#create-cardholder">How to create a Cardholder</a></p>
* @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 string $currency Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>, in lowercase. Supported currencies are <code>usd</code> in the US, <code>eur</code> in the EU, and <code>gbp</code> in the UK.
* @property string $cvc The card's CVC. For security reasons, this is only available for virtual cards, and will be omitted unless you explicitly request it with <a href="https://stripe.com/docs/api/expanding_objects">the <code>expand</code> parameter</a>. Additionally, it's only available via the <a href="https://stripe.com/docs/api/issuing/cards/retrieve">&quot;Retrieve a card&quot; endpoint</a>, not via &quot;List all cards&quot; or any other endpoint.
* @property int $exp_month The expiration month of the card.
* @property int $exp_year The expiration year of the card.
Expand Down
1 change: 1 addition & 0 deletions lib/PaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* @property \Stripe\StripeObject $bacs_debit
* @property \Stripe\StripeObject $bancontact
* @property \Stripe\StripeObject $billing_details
* @property \Stripe\StripeObject $blik
* @property \Stripe\StripeObject $boleto
* @property \Stripe\StripeObject $card
* @property \Stripe\StripeObject $card_present
Expand Down
2 changes: 2 additions & 0 deletions lib/Payout.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ class Payout extends ApiResource
const FAILURE_COULD_NOT_PROCESS = 'could_not_process';
const FAILURE_DEBIT_NOT_AUTHORIZED = 'debit_not_authorized';
const FAILURE_DECLINED = 'declined';
const FAILURE_INCORRECT_ACCOUNT_HOLDER_ADDRESS = 'incorrect_account_holder_address';
const FAILURE_INCORRECT_ACCOUNT_HOLDER_NAME = 'incorrect_account_holder_name';
const FAILURE_INCORRECT_ACCOUNT_HOLDER_TAX_ID = 'incorrect_account_holder_tax_id';
const FAILURE_INSUFFICIENT_FUNDS = 'insufficient_funds';
const FAILURE_INVALID_ACCOUNT_NUMBER = 'invalid_account_number';
const FAILURE_INVALID_CURRENCY = 'invalid_currency';
Expand Down
1 change: 1 addition & 0 deletions lib/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* @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. 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|\Stripe\StripeObject $migrate_to Subscriptions using this price will be migrated to use the new referenced price.
* @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.
* @property null|\Stripe\StripeObject $recurring The recurring components of a price such as <code>interval</code> and <code>usage_type</code>.
Expand Down
62 changes: 62 additions & 0 deletions lib/QuotePhaseConfiguration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

// File generated from our OpenAPI spec

namespace Stripe;

/**
* A quote phase describes the line items, coupons, and trialing status of a
* subscription for a predefined time period.
*
* @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 int $amount_subtotal Total before any discounts or taxes are applied.
* @property int $amount_total Total after discounts and taxes are applied.
* @property null|string $billing_cycle_anchor If set to <code>new</code>, the billing_cycle_anchor of the subscription is set to the start of the phase when entering the phase. If unset, then the billing cycle anchor is automatically modified as needed when entering the phase. For more information, see the billing cycle <a href="https://stripe.com/docs/billing/subscriptions/billing-cycle">documentation</a>.
* @property null|string $collection_method Either <code>charge_automatically</code>, or <code>send_invoice</code>. When charging automatically, Stripe will attempt to pay the underlying subscription at the end of each billing cycle using the default source attached to the customer. When sending an invoice, Stripe will email your customer an invoice with payment instructions.
* @property (string|\Stripe\TaxRate)[] $default_tax_rates The default tax rates to apply to the subscription during this phase of the quote.
* @property (string|\Stripe\Discount)[] $discounts The stackable discounts that will be applied to the subscription on this phase. Subscription item discounts are applied before subscription discounts.
* @property null|int $end_date The end of this phase of the quote
* @property null|\Stripe\StripeObject $invoice_settings The invoice settings applicable during this phase.
* @property null|int $iterations Integer representing the multiplier applied to the price interval. For example, <code>iterations=2</code> applied to a price with <code>interval=month</code> and <code>interval_count=3</code> results in a phase of duration <code>2 * 3 months = 6 months</code>.
* @property \Stripe\Collection<\Stripe\LineItem> $line_items A list of items the customer is being quoted for.
* @property string $proration_behavior If the quote will prorate when transitioning to this phase. Possible values are <code>create_prorations</code> and <code>none</code>.
* @property \Stripe\StripeObject $total_details
* @property null|bool $trial If set to true the entire phase is counted as a trial and the customer will not be charged for any recurring fees.
* @property null|int $trial_end When the trial ends within the phase.
*/
class QuotePhaseConfiguration extends ApiResource
{
const OBJECT_NAME = 'quote_phase';

use ApiOperations\All;
use ApiOperations\Retrieve;

const BILLING_CYCLE_ANCHOR_RESET = 'reset';

const COLLECTION_METHOD_CHARGE_AUTOMATICALLY = 'charge_automatically';
const COLLECTION_METHOD_SEND_INVOICE = 'send_invoice';

const PRORATION_BEHAVIOR_ALWAYS_INVOICE = 'always_invoice';
const PRORATION_BEHAVIOR_CREATE_PRORATIONS = 'create_prorations';
const PRORATION_BEHAVIOR_NONE = 'none';

/**
* @param string $id
* @param null|array $params
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Collection<\Stripe\LineItem> list of LineItems
*/
public static function allLineItems($id, $params = null, $opts = null)
{
$url = static::resourceUrl($id) . '/line_items';
list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);

return $obj;
}
}
1 change: 1 addition & 0 deletions lib/Refund.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class Refund extends ApiResource
const STATUS_CANCELED = 'canceled';
const STATUS_FAILED = 'failed';
const STATUS_PENDING = 'pending';
const STATUS_REQUIRES_ACTION = 'requires_action';
const STATUS_SUCCEEDED = 'succeeded';

/**
Expand Down
2 changes: 2 additions & 0 deletions lib/Service/CoreServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
* @property PriceService $prices
* @property ProductService $products
* @property PromotionCodeService $promotionCodes
* @property QuotePhaseConfigurationService $quotePhaseConfigurations
* @property QuoteService $quotes
* @property Radar\RadarServiceFactory $radar
* @property RefundService $refunds
Expand Down Expand Up @@ -109,6 +110,7 @@ class CoreServiceFactory extends \Stripe\Service\AbstractServiceFactory
'prices' => PriceService::class,
'products' => ProductService::class,
'promotionCodes' => PromotionCodeService::class,
'quotePhaseConfigurations' => QuotePhaseConfigurationService::class,
'quotes' => QuoteService::class,
'radar' => Radar\RadarServiceFactory::class,
'refunds' => RefundService::class,
Expand Down
58 changes: 58 additions & 0 deletions lib/Service/QuotePhaseConfigurationService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

// File generated from our OpenAPI spec

namespace Stripe\Service;

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

/**
* When retrieving a quote phase, there is an includable
* <strong>line_items</strong> property containing the first handful of those
* items. There is also a URL where you can retrieve the full (paginated) list of
* line items.
*
* @param string $id
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Collection<\Stripe\LineItem>
*/
public function allLineItems($id, $params = null, $opts = null)
{
return $this->requestCollection('get', $this->buildPath('/v1/quote_phases/%s/line_items', $id), $params, $opts);
}

/**
* Retrieves the quote phase 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\QuotePhaseConfiguration
*/
public function retrieve($id, $params = null, $opts = null)
{
return $this->request('get', $this->buildPath('/v1/quote_phases/%s', $id), $params, $opts);
}
}
Loading