ApiOperations
2 years ago
BillingPortal
2 years ago
Checkout
2 years ago
Exception
4 years ago
FinancialConnections
2 years ago
HttpClient
2 years ago
Identity
2 years ago
Issuing
2 years ago
Radar
2 years ago
Reporting
4 years ago
Service
2 years ago
Sigma
4 years ago
Terminal
2 years ago
TestHelpers
2 years ago
Util
2 years ago
Account.php
2 years ago
AccountLink.php
4 years ago
AlipayAccount.php
4 years ago
ApiRequestor.php
2 years ago
ApiResource.php
2 years ago
ApiResponse.php
4 years ago
ApplePayDomain.php
4 years ago
ApplicationFee.php
2 years ago
ApplicationFeeRefund.php
4 years ago
Balance.php
4 years ago
BalanceTransaction.php
4 years ago
BankAccount.php
4 years ago
BaseStripeClient.php
2 years ago
BaseStripeClientInterface.php
4 years ago
BitcoinReceiver.php
2 years ago
BitcoinTransaction.php
4 years ago
Capability.php
4 years ago
Card.php
2 years ago
CashBalance.php
2 years ago
Charge.php
2 years ago
Collection.php
2 years ago
CountrySpec.php
4 years ago
Coupon.php
2 years ago
CreditNote.php
2 years ago
CreditNoteLineItem.php
4 years ago
Customer.php
2 years ago
CustomerBalanceTransaction.php
4 years ago
Discount.php
2 years ago
Dispute.php
4 years ago
EphemeralKey.php
4 years ago
ErrorObject.php
4 years ago
Event.php
2 years ago
ExchangeRate.php
4 years ago
File.php
2 years ago
FileLink.php
4 years ago
FundingInstructions.php
2 years ago
Invoice.php
2 years ago
InvoiceItem.php
2 years ago
InvoiceLineItem.php
2 years ago
LineItem.php
4 years ago
LoginLink.php
4 years ago
Mandate.php
4 years ago
OAuth.php
4 years ago
OAuthErrorObject.php
4 years ago
Order.php
2 years ago
OrderItem.php
4 years ago
OrderReturn.php
4 years ago
PaymentIntent.php
2 years ago
PaymentLink.php
2 years ago
PaymentMethod.php
2 years ago
Payout.php
4 years ago
Person.php
2 years ago
Plan.php
2 years ago
Price.php
2 years ago
Product.php
2 years ago
PromotionCode.php
2 years ago
Quote.php
2 years ago
Recipient.php
2 years ago
RecipientTransfer.php
4 years ago
Refund.php
2 years ago
RequestTelemetry.php
4 years ago
Review.php
4 years ago
SKU.php
2 years ago
SearchResult.php
2 years ago
SetupAttempt.php
4 years ago
SetupIntent.php
2 years ago
ShippingRate.php
2 years ago
SingletonApiResource.php
2 years ago
Source.php
4 years ago
SourceTransaction.php
4 years ago
Stripe.php
2 years ago
StripeClient.php
2 years ago
StripeClientInterface.php
4 years ago
StripeObject.php
2 years ago
StripeStreamingClientInterface.php
4 years ago
Subscription.php
2 years ago
SubscriptionItem.php
2 years ago
SubscriptionSchedule.php
2 years ago
TaxCode.php
2 years ago
TaxId.php
2 years ago
TaxRate.php
4 years ago
ThreeDSecure.php
4 years ago
Token.php
4 years ago
Topup.php
4 years ago
Transfer.php
2 years ago
TransferReversal.php
4 years ago
UsageRecord.php
4 years ago
UsageRecordSummary.php
4 years ago
Webhook.php
4 years ago
WebhookEndpoint.php
4 years ago
WebhookSignature.php
4 years ago
BankAccount.php
134 lines
| 1 | <?php |
| 2 | |
| 3 | // File generated from our OpenAPI spec |
| 4 | |
| 5 | namespace Stripe; |
| 6 | |
| 7 | /** |
| 8 | * These bank accounts are payment methods on <code>Customer</code> objects. |
| 9 | * |
| 10 | * On the other hand <a |
| 11 | * href="https://stripe.com/docs/api#external_accounts">External Accounts</a> are |
| 12 | * transfer destinations on <code>Account</code> objects for <a |
| 13 | * href="https://stripe.com/docs/connect/custom-accounts">Custom accounts</a>. They |
| 14 | * can be bank accounts or debit cards as well, and are documented in the links |
| 15 | * above. |
| 16 | * |
| 17 | * Related guide: <a |
| 18 | * href="https://stripe.com/docs/payments/bank-debits-transfers">Bank Debits and |
| 19 | * Transfers</a>. |
| 20 | * |
| 21 | * @property string $id Unique identifier for the object. |
| 22 | * @property string $object String representing the object's type. Objects of the same type share the same value. |
| 23 | * @property null|string|\Stripe\Account $account The ID of the account that the bank account is associated with. |
| 24 | * @property null|string $account_holder_name The name of the person or business that owns the bank account. |
| 25 | * @property null|string $account_holder_type The type of entity that holds the account. This can be either <code>individual</code> or <code>company</code>. |
| 26 | * @property null|string $account_type The bank account type. This can only be <code>checking</code> or <code>savings</code> in most countries. In Japan, this can only be <code>futsu</code> or <code>toza</code>. |
| 27 | * @property null|string[] $available_payout_methods A set of available payout methods for this bank account. Only values from this set should be passed as the <code>method</code> when creating a payout. |
| 28 | * @property null|string $bank_name Name of the bank associated with the routing number (e.g., <code>WELLS FARGO</code>). |
| 29 | * @property string $country Two-letter ISO code representing the country the bank account is located in. |
| 30 | * @property string $currency Three-letter <a href="https://stripe.com/docs/payouts">ISO code for the currency</a> paid out to the bank account. |
| 31 | * @property null|string|\Stripe\Customer $customer The ID of the customer that the bank account is associated with. |
| 32 | * @property null|bool $default_for_currency Whether this bank account is the default external account for its currency. |
| 33 | * @property null|string $fingerprint Uniquely identifies this particular bank account. You can use this attribute to check whether two bank accounts are the same. |
| 34 | * @property string $last4 The last four digits of the bank account number. |
| 35 | * @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. |
| 36 | * @property null|string $routing_number The routing transit number for the bank account. |
| 37 | * @property string $status <p>For bank accounts, possible values are <code>new</code>, <code>validated</code>, <code>verified</code>, <code>verification_failed</code>, or <code>errored</code>. A bank account that hasn't had any activity or validation performed is <code>new</code>. If Stripe can determine that the bank account exists, its status will be <code>validated</code>. Note that there often isn’t enough information to know (e.g., for smaller credit unions), and the validation is not always run. If customer bank account verification has succeeded, the bank account status will be <code>verified</code>. If the verification failed for any reason, such as microdeposit failure, the status will be <code>verification_failed</code>. If a transfer sent to this bank account fails, we'll set the status to <code>errored</code> and will not continue to send transfers until the bank details are updated.</p><p>For external accounts, possible values are <code>new</code> and <code>errored</code>. Validations aren't run against external accounts because they're only used for payouts. This means the other statuses don't apply. If a transfer fails, the status is set to <code>errored</code> and transfers are stopped until account details are updated.</p> |
| 38 | */ |
| 39 | class BankAccount extends ApiResource |
| 40 | { |
| 41 | const OBJECT_NAME = 'bank_account'; |
| 42 | |
| 43 | use ApiOperations\Delete; |
| 44 | use ApiOperations\Update; |
| 45 | |
| 46 | /** |
| 47 | * Possible string representations of the bank verification status. |
| 48 | * |
| 49 | * @see https://stripe.com/docs/api/external_account_bank_accounts/object#account_bank_account_object-status |
| 50 | */ |
| 51 | const STATUS_NEW = 'new'; |
| 52 | const STATUS_VALIDATED = 'validated'; |
| 53 | const STATUS_VERIFIED = 'verified'; |
| 54 | const STATUS_VERIFICATION_FAILED = 'verification_failed'; |
| 55 | const STATUS_ERRORED = 'errored'; |
| 56 | |
| 57 | /** |
| 58 | * @return string The instance URL for this resource. It needs to be special |
| 59 | * cased because it doesn't fit into the standard resource pattern. |
| 60 | */ |
| 61 | public function instanceUrl() |
| 62 | { |
| 63 | if ($this['customer']) { |
| 64 | $base = Customer::classUrl(); |
| 65 | $parent = $this['customer']; |
| 66 | $path = 'sources'; |
| 67 | } elseif ($this['account']) { |
| 68 | $base = Account::classUrl(); |
| 69 | $parent = $this['account']; |
| 70 | $path = 'external_accounts'; |
| 71 | } else { |
| 72 | $msg = 'Bank accounts cannot be accessed without a customer ID or account ID.'; |
| 73 | |
| 74 | throw new Exception\UnexpectedValueException($msg, null); |
| 75 | } |
| 76 | $parentExtn = \urlencode(Util\Util::utf8($parent)); |
| 77 | $extn = \urlencode(Util\Util::utf8($this['id'])); |
| 78 | |
| 79 | return "{$base}/{$parentExtn}/{$path}/{$extn}"; |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * @param array|string $_id |
| 84 | * @param null|array|string $_opts |
| 85 | * |
| 86 | * @throws \Stripe\Exception\BadMethodCallException |
| 87 | */ |
| 88 | public static function retrieve($_id, $_opts = null) |
| 89 | { |
| 90 | $msg = 'Bank accounts cannot be retrieved without a customer ID or ' . |
| 91 | 'an account ID. Retrieve a bank account using ' . |
| 92 | "`Customer::retrieveSource('customer_id', " . |
| 93 | "'bank_account_id')` or `Account::retrieveExternalAccount(" . |
| 94 | "'account_id', 'bank_account_id')`."; |
| 95 | |
| 96 | throw new Exception\BadMethodCallException($msg); |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * @param string $_id |
| 101 | * @param null|array $_params |
| 102 | * @param null|array|string $_options |
| 103 | * |
| 104 | * @throws \Stripe\Exception\BadMethodCallException |
| 105 | */ |
| 106 | public static function update($_id, $_params = null, $_options = null) |
| 107 | { |
| 108 | $msg = 'Bank accounts cannot be updated without a customer ID or an ' . |
| 109 | 'account ID. Update a bank account using ' . |
| 110 | "`Customer::updateSource('customer_id', 'bank_account_id', " . |
| 111 | '$updateParams)` or `Account::updateExternalAccount(' . |
| 112 | "'account_id', 'bank_account_id', \$updateParams)`."; |
| 113 | |
| 114 | throw new Exception\BadMethodCallException($msg); |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * @param null|array $params |
| 119 | * @param null|array|string $opts |
| 120 | * |
| 121 | * @throws \Stripe\Exception\ApiErrorException if the request fails |
| 122 | * |
| 123 | * @return BankAccount the verified bank account |
| 124 | */ |
| 125 | public function verify($params = null, $opts = null) |
| 126 | { |
| 127 | $url = $this->instanceUrl() . '/verify'; |
| 128 | list($response, $opts) = $this->_request('post', $url, $params, $opts); |
| 129 | $this->refreshFrom($response, $opts); |
| 130 | |
| 131 | return $this; |
| 132 | } |
| 133 | } |
| 134 |