Skip to content

Commit

Permalink
Next major release changes (#1341)
Browse files Browse the repository at this point in the history
* chore!: Update CA certifacte bundle (Apr 26). (#1314)

* Update error codes (#1329)

r? @dcr-stripe 

## Summary
Update error codes based on https://stripe.com/docs/error-codes.

## Changelog
- ⚠️ Remove deprecated error codes:
  - `'account_already_exists'`
  - `'order_creation_failed'`
  - `'order_required_settings'`
  - `'order_status_invalid'`
  - `'order_upstream_timeout'`
  - `'upstream_order_creation_failed'`
- Add error codes:
  - `'account_error_country_change_requires_additional_steps'`
  - `'account_information_mismatch'`
  - `'acss_debit_session_incomplete'`
  - `'authentication_required'`
  - `'bank_account_bad_routing_numbers'`
  - `'bank_account_declined'`
  - `'bank_account_verification_failed'`
  - `'billing_invalid_mandate'`
  - `'card_decline_rate_limit_exceeded'`
  - `'cardholder_phone_number_required'`
  - `'charge_invalid_parameter'`
  - `'clearing_code_unsupported'`
  - `'country_code_invalid'`
  - `'customer_max_payment_methods'`
  - `'debit_not_authorized'`
  - `'instant_payouts_limit_exceeded'`
  - `'insufficient_funds'`
  - `'intent_invalid_state'`
  - `'intent_verification_method_missing'`
  - `'invalid_characters'`
  - `'invoice_no_payment_method_types'`
  - `'invoice_on_behalf_of_not_editable'`
  - `'no_account'`
  - `'payment_intent_action_required'`
  - `'payment_intent_konbini_rejected_confirmation_number'`
  - `'payment_intent_mandate_invalid'`
  - `'payment_intent_payment_attempt_expired'`
  - `'payment_method_bank_account_already_verified'`
  - `'payment_method_bank_account_blocked'`
  - `'payment_method_billing_details_address_missing'`
  - `'payment_method_currency_mismatch'`
  - `'payment_method_invalid_parameter'`
  - `'payment_method_invalid_parameter_testmode'`
  - `'payment_method_microdeposit_failed'`
  - `'payment_method_microdeposit_verification_amounts_invalid'`
  - `'payment_method_microdeposit_verification_amounts_mismatch'`
  - `'payment_method_microdeposit_verification_attempts_exceeded'`
  - `'payment_method_microdeposit_verification_descriptor_code_mismatch'`
  - `'payment_method_microdeposit_verification_timeout'`
  - `'payment_method_provider_decline'`
  - `'payment_method_provider_timeout'`
  - `'payment_method_unsupported_type'`
  - `'platform_account_required'`
  - `'refer_to_customer'`
  - `'refund_disputed_payment'`
  - `'return_intent_already_processed'`
  - `'setup_intent_invalid_parameter'`
  - `'setup_intent_setup_attempt_expired'`
  - `'terminal_location_country_unsupported'`
  - `'transfer_source_balance_parameters_mismatch'`

* Generate stripe-php with breaking changes

* Remove more resources

* Remove tests to removed resources

* Regenerate files

* Remove outdated test

* Remove outdated test

* Fix more tests

* Fix type

* Remove outdated test

* Fix syntax

* Change return type in a test

* Change allSourcesTest to expect a StripeObject for now.

* Fix SourceTest

* Remove unused OrderItem class. (#1342)

Co-authored-by: Dominic Charley-Roy <[email protected]>
Co-authored-by: yejia-stripe <[email protected]>
Co-authored-by: Dominic Charley-Roy <[email protected]>
  • Loading branch information
4 people authored Aug 1, 2022
1 parent dcd1deb commit 0fc5809
Show file tree
Hide file tree
Showing 45 changed files with 893 additions and 1,630 deletions.
1,661 changes: 766 additions & 895 deletions data/ca-certificates.crt

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions init.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
// Stripe API Resources
require __DIR__ . '/lib/Account.php';
require __DIR__ . '/lib/AccountLink.php';
require __DIR__ . '/lib/AlipayAccount.php';
require __DIR__ . '/lib/ApplePayDomain.php';
require __DIR__ . '/lib/ApplicationFee.php';
require __DIR__ . '/lib/ApplicationFeeRefund.php';
Expand All @@ -89,8 +88,6 @@
require __DIR__ . '/lib/BankAccount.php';
require __DIR__ . '/lib/BillingPortal/Configuration.php';
require __DIR__ . '/lib/BillingPortal/Session.php';
require __DIR__ . '/lib/BitcoinReceiver.php';
require __DIR__ . '/lib/BitcoinTransaction.php';
require __DIR__ . '/lib/Capability.php';
require __DIR__ . '/lib/Card.php';
require __DIR__ . '/lib/CashBalance.php';
Expand Down Expand Up @@ -144,8 +141,6 @@
require __DIR__ . '/lib/Radar/EarlyFraudWarning.php';
require __DIR__ . '/lib/Radar/ValueList.php';
require __DIR__ . '/lib/Radar/ValueListItem.php';
require __DIR__ . '/lib/Recipient.php';
require __DIR__ . '/lib/RecipientTransfer.php';
require __DIR__ . '/lib/Refund.php';
require __DIR__ . '/lib/Reporting/ReportRun.php';
require __DIR__ . '/lib/Reporting/ReportType.php';
Expand All @@ -169,7 +164,6 @@
require __DIR__ . '/lib/Terminal/Location.php';
require __DIR__ . '/lib/Terminal/Reader.php';
require __DIR__ . '/lib/TestHelpers/TestClock.php';
require __DIR__ . '/lib/ThreeDSecure.php';
require __DIR__ . '/lib/Token.php';
require __DIR__ . '/lib/Topup.php';
require __DIR__ . '/lib/Transfer.php';
Expand Down
27 changes: 0 additions & 27 deletions lib/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,6 @@ class Account extends ApiResource
const BUSINESS_TYPE_INDIVIDUAL = 'individual';
const BUSINESS_TYPE_NON_PROFIT = 'non_profit';

const CAPABILITY_CARD_PAYMENTS = 'card_payments';
const CAPABILITY_LEGACY_PAYMENTS = 'legacy_payments';
const CAPABILITY_PLATFORM_PAYMENTS = 'platform_payments';
const CAPABILITY_TRANSFERS = 'transfers';

const CAPABILITY_STATUS_ACTIVE = 'active';
const CAPABILITY_STATUS_INACTIVE = 'inactive';
const CAPABILITY_STATUS_PENDING = 'pending';

const TYPE_CUSTOM = 'custom';
const TYPE_EXPRESS = 'express';
const TYPE_STANDARD = 'standard';
Expand Down Expand Up @@ -178,24 +169,6 @@ public function deauthorize($clientId = null, $opts = null)
return OAuth::deauthorize($params, $opts);
}

/**
* @param null|array $params
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Collection<\Stripe\Person> the list of persons
*/
public function persons($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/persons';
list($response, $opts) = $this->_request('get', $url, $params, $opts);
$obj = Util\Util::convertToStripeObject($response, $opts);
$obj->setLastResponse($response);

return $obj;
}

/**
* @param null|array $params
* @param null|array|string $opts
Expand Down
71 changes: 0 additions & 71 deletions lib/BitcoinReceiver.php

This file was deleted.

19 changes: 0 additions & 19 deletions lib/BitcoinTransaction.php

This file was deleted.

7 changes: 1 addition & 6 deletions lib/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
* @property string $last4 The last four digits of the card.
* @property null|\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 $name Cardholder name.
* @property null|string|\Stripe\Recipient $recipient The recipient that this card belongs to. This attribute will not be in the card object if the card belongs to a customer or account instead.
* @property null|string $status For external accounts, possible values are <code>new</code> and <code>errored</code>. If a transfer fails, the status is set to <code>errored</code> and transfers are stopped until account details are updated.
* @property null|string $tokenization_method If the card number is tokenized, this is the method that was used. Can be <code>android_pay</code> (includes Google Pay), <code>apple_pay</code>, <code>masterpass</code>, <code>visa_checkout</code>, or null.
*/
Expand Down Expand Up @@ -92,12 +91,8 @@ public function instanceUrl()
$base = Account::classUrl();
$parent = $this['account'];
$path = 'external_accounts';
} elseif ($this['recipient']) {
$base = Recipient::classUrl();
$parent = $this['recipient'];
$path = 'cards';
} else {
$msg = 'Cards cannot be accessed without a customer ID, account ID or recipient ID.';
$msg = 'Cards cannot be accessed without a customer ID, or account ID.';

throw new Exception\UnexpectedValueException($msg);
}
Expand Down
5 changes: 4 additions & 1 deletion lib/Charge.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
*
* @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 \Stripe\StripeObject $alternate_statement_descriptors
* @property int $amount Amount intended to be collected by this payment. 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).
* @property int $amount_captured Amount in %s captured (can be less than the amount attribute on the charge if a partial capture was made).
* @property int $amount_refunded Amount in %s refunded (can be less than the amount attribute on the charge if a partial refund was issued).
* @property null|string|\Stripe\StripeObject $application ID of the Connect application that created the charge.
* @property null|string|\Stripe\ApplicationFee $application_fee The application fee (if any) for the charge. <a href="https://stripe.com/docs/connect/direct-charges#collecting-fees">See the Connect documentation</a> for details.
* @property null|int $application_fee_amount The amount of the application fee (if any) requested for the charge. <a href="https://stripe.com/docs/connect/direct-charges#collecting-fees">See the Connect documentation</a> for details.
* @property string $authorization_code Authorization code on the charge.
* @property null|string|\Stripe\BalanceTransaction $balance_transaction ID of the balance transaction that describes the impact of this charge on your account balance (not including refunds or disputes).
* @property \Stripe\StripeObject $billing_details
* @property null|string $calculated_statement_descriptor The full statement descriptor that is passed to card networks, and that is displayed on your customers' credit card and bank statements. Allows you to see what the statement descriptor looks like after the static and dynamic portions are combined.
Expand All @@ -37,6 +39,7 @@
* @property null|string $failure_message Message to user further explaining reason for charge failure if available.
* @property null|\Stripe\StripeObject $fraud_details Information on fraud assessments for the charge.
* @property null|string|\Stripe\Invoice $invoice ID of the invoice this charge is for if one exists.
* @property \Stripe\StripeObject $level3
* @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|\Stripe\Account $on_behalf_of The account (if any) the charge was made on behalf of without triggering an automatic transfer. See the <a href="https://stripe.com/docs/connect/charges-transfers">Connect documentation</a> for details.
Expand All @@ -53,7 +56,7 @@
* @property \Stripe\Collection<\Stripe\Refund> $refunds A list of refunds that have been applied to the charge.
* @property null|string|\Stripe\Review $review ID of the review associated with this charge if one exists.
* @property null|\Stripe\StripeObject $shipping Shipping information for the charge.
* @property null|\Stripe\Account|\Stripe\AlipayAccount|\Stripe\BankAccount|\Stripe\BitcoinReceiver|\Stripe\Card|\Stripe\Source $source This is a legacy field that will be removed in the future. It contains the Source, Card, or BankAccount object used for the charge. For details about the payment method used for this charge, refer to <code>payment_method</code> or <code>payment_method_details</code> instead.
* @property null|\Stripe\Account|\Stripe\BankAccount|\Stripe\Card|\Stripe\Source $source This is a legacy field that will be removed in the future. It contains the Source, Card, or BankAccount object used for the charge. For details about the payment method used for this charge, refer to <code>payment_method</code> or <code>payment_method_details</code> instead.
* @property null|string|\Stripe\Transfer $source_transfer The transfer ID which created this charge. Only present if the charge came from another Stripe account. <a href="https://stripe.com/docs/connect/destination-charges">See the Connect documentation</a> for details.
* @property null|string $statement_descriptor For card charges, use <code>statement_descriptor_suffix</code> instead. Otherwise, you can use this value as the complete description of a charge on your customers’ statements. Must contain at least one letter, maximum 22 characters.
* @property null|string $statement_descriptor_suffix Provides information about the charge 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.
Expand Down
14 changes: 8 additions & 6 deletions lib/Checkout/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ class Session extends \Stripe\ApiResource

use \Stripe\ApiOperations\All;
use \Stripe\ApiOperations\Create;
use \Stripe\ApiOperations\NestedResource;
use \Stripe\ApiOperations\Retrieve;

const BILLING_ADDRESS_COLLECTION_AUTO = 'auto';
Expand Down Expand Up @@ -115,19 +114,22 @@ public function expire($params = null, $opts = null)
return $this;
}

const PATH_LINE_ITEMS = '/line_items';

/**
* @param string $id the ID of the session on which to retrieve the items
* @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> the list of items
* @return \Stripe\Collection<\Stripe\LineItem> list of LineItems
*/
public static function allLineItems($id, $params = null, $opts = null)
{
return self::_allNestedResources($id, static::PATH_LINE_ITEMS, $params, $opts);
$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;
}
}
18 changes: 18 additions & 0 deletions lib/CreditNote.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,24 @@ public static function preview($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\CreditNoteLineItem> list of CreditNoteLineItems
*/
public static function previewLines($params = null, $opts = null)
{
$url = static::classUrl() . '/preview/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
Loading

0 comments on commit 0fc5809

Please sign in to comment.