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

Merged
merged 1 commit into from
May 3, 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
1 change: 1 addition & 0 deletions init.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
require __DIR__ . '/lib/BitcoinTransaction.php';
require __DIR__ . '/lib/Capability.php';
require __DIR__ . '/lib/Card.php';
require __DIR__ . '/lib/CashBalance.php';
require __DIR__ . '/lib/Charge.php';
require __DIR__ . '/lib/Checkout/Session.php';
require __DIR__ . '/lib/Collection.php';
Expand Down
66 changes: 66 additions & 0 deletions lib/CashBalance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

// File generated from our OpenAPI spec

namespace Stripe;

/**
* A customer's <code>Cash balance</code> represents real funds. Customers can add
* funds to their cash balance by sending a bank transfer. These funds can be used
* for payment and can eventually be paid out to your bank account.
*
* @property string $object String representing the object's type. Objects of the same type share the same value.
* @property null|\Stripe\StripeObject $available A hash of all cash balances available to this customer. You cannot delete a customer with any cash balances, even if the balance is 0.
* @property string $customer The ID of the customer whose cash balance this object represents.
* @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 $settings
*/
class CashBalance extends ApiResource
{
const OBJECT_NAME = 'cash_balance';

/**
* @return string the API URL for this balance transaction
*/
public function instanceUrl()
{
$customer = $this['customer'];
$customer = Util\Util::utf8($customer);

$base = Customer::classUrl();
$customerExtn = \urlencode($customer);

return "{$base}/{$customerExtn}/cash_balance";
}

/**
* @param array|string $_id
* @param null|array|string $_opts
*
* @throws \Stripe\Exception\BadMethodCallException
*/
public static function retrieve($_id, $_opts = null)
{
$msg = 'Customer Cash Balance cannot be retrieved without a ' .
'customer ID. Retrieve a Customer Cash Balance using ' .
"`Customer::retrieveCashBalance('customer_id')`.";

throw new Exception\BadMethodCallException($msg);
}

/**
* @param string $_id
* @param null|array $_params
* @param null|array|string $_options
*
* @throws \Stripe\Exception\BadMethodCallException
*/
public static function update($_id, $_params = null, $_options = null)
{
$msg = 'Customer Cash Balance cannot be updated without a ' .
'customer ID. Retrieve a Customer Cash Balance using ' .
"`Customer::updateCashBalance('customer_id')`.";

throw new Exception\BadMethodCallException($msg);
}
}
32 changes: 32 additions & 0 deletions lib/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* @property string $object String representing the object's type. Objects of the same type share the same value.
* @property null|\Stripe\StripeObject $address The customer's address.
* @property int $balance Current balance, if any, being stored on the customer. If negative, the customer has credit to apply to their next invoice. If positive, the customer has an amount owed that will be added to their next invoice. The balance does not refer to any unpaid invoices; it solely takes into account amounts that have yet to be successfully applied to any invoice. This balance is only taken into account as invoices are finalized.
* @property null|\Stripe\CashBalance $cash_balance The current funds being held by Stripe on behalf of the customer. These funds can be applied towards payment intents with source &quot;cash_balance&quot;.The settings[reconciliation_mode] field describes whether these funds are applied to such payment intents manually or automatically.
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property null|string $currency Three-letter <a href="https://stripe.com/docs/currencies">ISO code for the currency</a> the customer can be charged in for recurring billing purposes.
* @property null|string|\Stripe\Account|\Stripe\AlipayAccount|\Stripe\BankAccount|\Stripe\BitcoinReceiver|\Stripe\Card|\Stripe\Source $default_source <p>ID of the default payment source for the customer.</p><p>If you are using payment methods created via the PaymentMethods API, see the <a href="https://stripe.com/docs/api/customers/object#customer_object-invoice_settings-default_payment_method">invoice_settings.default_payment_method</a> field instead.</p>
Expand Down Expand Up @@ -116,6 +117,37 @@ public static function search($params = null, $opts = null)
return self::_searchResource($url, $params, $opts);
}

const PATH_CASH_BALANCE = '/cash_balance';

/**
* @param string $id the ID of the customer to which the cash balance belongs
* @param null|array $params
* @param null|array|string $opts
* @param mixed $cashBalanceId
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\cash_balance
*/
public static function retrieveCashBalance($id, $cashBalanceId, $params = null, $opts = null)
{
return self::_retrieveNestedResource($id, static::PATH_CASH_BALANCE, $params, $opts);
}

/**
* @param string $id the ID of the customer to which the cash balance belongs
* @param null|array $params
* @param null|array|string $opts
* @param mixed $cashBalanceId
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\cash_balance
*/
public static function updateCashBalance($id, $cashBalanceId, $params = null, $opts = null)
{
return self::_updateNestedResource($id, static::PATH_CASH_BALANCE, $params, $opts);
}
const PATH_BALANCE_TRANSACTIONS = '/balance_transactions';

/**
Expand Down
1 change: 1 addition & 0 deletions lib/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
* @property int $amount_due Final amount due at this time for this invoice. If the invoice's total is smaller than the minimum charge amount, for example, or if there is account credit that can be applied to the invoice, the <code>amount_due</code> may be 0. If there is a positive <code>starting_balance</code> for the invoice (the customer owes money), the <code>amount_due</code> will also take that into account. The charge that gets generated for the invoice will be for the amount specified in <code>amount_due</code>.
* @property int $amount_paid The amount, in %s, that was paid.
* @property int $amount_remaining The amount remaining, in %s, that is due.
* @property null|string|\Stripe\StripeObject $application ID of the Connect Application that created the invoice.
* @property null|int $application_fee_amount The fee in %s that will be applied to the invoice and transferred to the application owner's Stripe account when the invoice is paid.
* @property int $attempt_count Number of payment attempts made for this invoice, from the perspective of the payment retry schedule. Any payment attempt counts as the first attempt, and subsequently only automatic retries increment the attempt count. In other words, manual payment attempts after the first attempt do not affect the retry schedule.
* @property bool $attempted Whether an attempt has been made to pay the invoice. An invoice is not attempted until 1 hour after the <code>invoice.created</code> webhook, for example, so you might not want to display that invoice as unpaid to your users.
Expand Down
1 change: 1 addition & 0 deletions lib/Quote.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @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|\Stripe\StripeObject $application ID of the Connect Application that created the quote.
* @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. Only applicable if there are no line items with recurring prices on the quote.
* @property null|float $application_fee_percent A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice subtotal that will be transferred to the application owner's Stripe account. Only applicable if there are line items with recurring prices on the quote.
* @property \Stripe\StripeObject $automatic_tax
Expand Down
32 changes: 32 additions & 0 deletions lib/Service/CustomerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,22 @@ public function retrieveBalanceTransaction($parentId, $id, $params = null, $opts
return $this->request('get', $this->buildPath('/v1/customers/%s/balance_transactions/%s', $parentId, $id), $params, $opts);
}

/**
* Retrieves a customer’s cash balance.
*
* @param string $parentId
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\cash_balance
*/
public function retrieveCashBalance($parentId, $params = null, $opts = null)
{
return $this->request('get', $this->buildPath('/v1/customers/%s/cash_balance', $parentId), $params, $opts);
}

/**
* Retrieve a specified source for a given customer.
*
Expand Down Expand Up @@ -376,6 +392,22 @@ public function updateBalanceTransaction($parentId, $id, $params = null, $opts =
return $this->request('post', $this->buildPath('/v1/customers/%s/balance_transactions/%s', $parentId, $id), $params, $opts);
}

/**
* Updates a customer’s cash balance.
*
* @param string $parentId
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\cash_balance
*/
public function updateCashBalance($parentId, $params = null, $opts = null)
{
return $this->request('post', $this->buildPath('/v1/customers/%s/cash_balance', $parentId), $params, $opts);
}

/**
* @param string $parentId
* @param string $id
Expand Down
1 change: 1 addition & 0 deletions lib/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*
* @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 null|string|\Stripe\StripeObject $application ID of the Connect Application that created the subscription.
* @property null|float $application_fee_percent A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice subtotal that will be transferred to the application owner's Stripe account.
* @property \Stripe\StripeObject $automatic_tax
* @property int $billing_cycle_anchor Determines the date of the first full invoice, and, for plans with <code>month</code> or <code>year</code> intervals, the day of the month for subsequent invoices.
Expand Down
1 change: 1 addition & 0 deletions lib/SubscriptionSchedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*
* @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 null|string|\Stripe\StripeObject $application ID of the Connect Application that created the schedule.
* @property null|int $canceled_at Time at which the subscription schedule was canceled. Measured in seconds since the Unix epoch.
* @property null|int $completed_at Time at which the subscription schedule was completed. Measured in seconds since the Unix epoch.
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
Expand Down
3 changes: 2 additions & 1 deletion lib/TaxId.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property null|string|\Stripe\Customer $customer ID of the customer.
* @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 string $type Type of the tax ID, one of <code>ae_trn</code>, <code>au_abn</code>, <code>au_arn</code>, <code>bg_uic</code>, <code>br_cnpj</code>, <code>br_cpf</code>, <code>ca_bn</code>, <code>ca_gst_hst</code>, <code>ca_pst_bc</code>, <code>ca_pst_mb</code>, <code>ca_pst_sk</code>, <code>ca_qst</code>, <code>ch_vat</code>, <code>cl_tin</code>, <code>es_cif</code>, <code>eu_vat</code>, <code>gb_vat</code>, <code>ge_vat</code>, <code>hk_br</code>, <code>hu_tin</code>, <code>id_npwp</code>, <code>il_vat</code>, <code>in_gst</code>, <code>is_vat</code>, <code>jp_cn</code>, <code>jp_rn</code>, <code>kr_brn</code>, <code>li_uid</code>, <code>mx_rfc</code>, <code>my_frp</code>, <code>my_itn</code>, <code>my_sst</code>, <code>no_vat</code>, <code>nz_gst</code>, <code>ru_inn</code>, <code>ru_kpp</code>, <code>sa_vat</code>, <code>sg_gst</code>, <code>sg_uen</code>, <code>si_tin</code>, <code>th_vat</code>, <code>tw_vat</code>, <code>ua_vat</code>, <code>us_ein</code>, or <code>za_vat</code>. Note that some legacy tax IDs have type <code>unknown</code>
* @property string $type Type of the tax ID, one of <code>ae_trn</code>, <code>au_abn</code>, <code>au_arn</code>, <code>bg_uic</code>, <code>br_cnpj</code>, <code>br_cpf</code>, <code>ca_bn</code>, <code>ca_gst_hst</code>, <code>ca_pst_bc</code>, <code>ca_pst_mb</code>, <code>ca_pst_sk</code>, <code>ca_qst</code>, <code>ch_vat</code>, <code>cl_tin</code>, <code>es_cif</code>, <code>eu_oss_vat</code>, <code>eu_vat</code>, <code>gb_vat</code>, <code>ge_vat</code>, <code>hk_br</code>, <code>hu_tin</code>, <code>id_npwp</code>, <code>il_vat</code>, <code>in_gst</code>, <code>is_vat</code>, <code>jp_cn</code>, <code>jp_rn</code>, <code>kr_brn</code>, <code>li_uid</code>, <code>mx_rfc</code>, <code>my_frp</code>, <code>my_itn</code>, <code>my_sst</code>, <code>no_vat</code>, <code>nz_gst</code>, <code>ru_inn</code>, <code>ru_kpp</code>, <code>sa_vat</code>, <code>sg_gst</code>, <code>sg_uen</code>, <code>si_tin</code>, <code>th_vat</code>, <code>tw_vat</code>, <code>ua_vat</code>, <code>us_ein</code>, or <code>za_vat</code>. Note that some legacy tax IDs have type <code>unknown</code>
* @property string $value Value of the tax ID.
* @property null|\Stripe\StripeObject $verification Tax ID verification information.
*/
Expand All @@ -43,6 +43,7 @@ class TaxId extends ApiResource
const TYPE_CH_VAT = 'ch_vat';
const TYPE_CL_TIN = 'cl_tin';
const TYPE_ES_CIF = 'es_cif';
const TYPE_EU_OSS_VAT = 'eu_oss_vat';
const TYPE_EU_VAT = 'eu_vat';
const TYPE_GB_VAT = 'gb_vat';
const TYPE_GE_VAT = 'ge_vat';
Expand Down
1 change: 1 addition & 0 deletions lib/Util/ObjectTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class ObjectTypes
\Stripe\BitcoinTransaction::OBJECT_NAME => \Stripe\BitcoinTransaction::class,
\Stripe\Capability::OBJECT_NAME => \Stripe\Capability::class,
\Stripe\Card::OBJECT_NAME => \Stripe\Card::class,
\Stripe\CashBalance::OBJECT_NAME => \Stripe\CashBalance::class,
\Stripe\Charge::OBJECT_NAME => \Stripe\Charge::class,
\Stripe\Checkout\Session::OBJECT_NAME => \Stripe\Checkout\Session::class,
\Stripe\Collection::OBJECT_NAME => \Stripe\Collection::class,
Expand Down