• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stripe / stripe-php / 12472986272

23 Dec 2024 09:08PM UTC coverage: 57.239% (-0.07%) from 57.304%
12472986272

Pull #1796

github

web-flow
Merge 95752e8f3 into 99912a3af
Pull Request #1796: Update generated code for beta

0 of 7 new or added lines in 2 files covered. (0.0%)

2 existing lines in 1 file now uncovered.

3558 of 6216 relevant lines covered (57.24%)

2.25 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.0
/lib/Card.php
1
<?php
2

3
// File generated from our OpenAPI spec
4

5
namespace Stripe;
6

7
/**
8
 * You can store multiple cards on a customer in order to charge the customer
9
 * later. You can also store multiple debit cards on a recipient in order to
10
 * transfer to those cards later.
11
 *
12
 * Related guide: <a href="https://stripe.com/docs/sources/cards">Card payments with Sources</a>
13
 *
14
 * @property string $id Unique identifier for the object.
15
 * @property string $object String representing the object's type. Objects of the same type share the same value.
16
 * @property null|string|\Stripe\Account $account The account this card belongs to. This attribute will not be in the card object if the card belongs to a customer or recipient instead. This property is only available for accounts where <a href="/api/accounts/object#account_object-controller-requirement_collection">controller.requirement_collection</a> is <code>application</code>, which includes Custom accounts.
17
 * @property null|string $address_city City/District/Suburb/Town/Village.
18
 * @property null|string $address_country Billing address country, if provided when creating card.
19
 * @property null|string $address_line1 Address line 1 (Street address/PO Box/Company name).
20
 * @property null|string $address_line1_check If <code>address_line1</code> was provided, results of the check: <code>pass</code>, <code>fail</code>, <code>unavailable</code>, or <code>unchecked</code>.
21
 * @property null|string $address_line2 Address line 2 (Apartment/Suite/Unit/Building).
22
 * @property null|string $address_state State/County/Province/Region.
23
 * @property null|string $address_zip ZIP or postal code.
24
 * @property null|string $address_zip_check If <code>address_zip</code> was provided, results of the check: <code>pass</code>, <code>fail</code>, <code>unavailable</code>, or <code>unchecked</code>.
25
 * @property null|string $allow_redisplay This field indicates whether this payment method can be shown again to its customer in a checkout flow. Stripe products such as Checkout and Elements use this field to determine whether a payment method can be shown as a saved payment method in a checkout flow. The field defaults to “unspecified”.
26
 * @property null|string[] $available_payout_methods A set of available payout methods for this card. Only values from this set should be passed as the <code>method</code> when creating a payout.
27
 * @property string $brand Card brand. Can be <code>American Express</code>, <code>Diners Club</code>, <code>Discover</code>, <code>Eftpos Australia</code>, <code>Girocard</code>, <code>JCB</code>, <code>MasterCard</code>, <code>UnionPay</code>, <code>Visa</code>, or <code>Unknown</code>.
28
 * @property null|string $country Two-letter ISO code representing the country of the card. You could use this attribute to get a sense of the international breakdown of cards you've collected.
29
 * @property null|string $currency Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO code for currency</a> in lowercase. Must be a <a href="https://docs.stripe.com/currencies">supported currency</a>. Only applicable on accounts (not customers or recipients). The card can be used as a transfer destination for funds in this currency. This property is only available for accounts where <a href="/api/accounts/object#account_object-controller-requirement_collection">controller.requirement_collection</a> is <code>application</code>, which includes Custom accounts.
30
 * @property null|string|\Stripe\Customer $customer The customer that this card belongs to. This attribute will not be in the card object if the card belongs to an account or recipient instead.
31
 * @property null|string $cvc_check If a CVC was provided, results of the check: <code>pass</code>, <code>fail</code>, <code>unavailable</code>, or <code>unchecked</code>. A result of unchecked indicates that CVC was provided but hasn't been checked yet. Checks are typically performed when attaching a card to a Customer object, or when creating a charge. For more details, see <a href="https://support.stripe.com/questions/check-if-a-card-is-valid-without-a-charge">Check if a card is valid without a charge</a>.
32
 * @property null|bool $default_for_currency Whether this card is the default external account for its currency. This property is only available for accounts where <a href="/api/accounts/object#account_object-controller-requirement_collection">controller.requirement_collection</a> is <code>application</code>, which includes Custom accounts.
33
 * @property null|string $dynamic_last4 (For tokenized numbers only.) The last four digits of the device account number.
34
 * @property int $exp_month Two-digit number representing the card's expiration month.
35
 * @property int $exp_year Four-digit number representing the card's expiration year.
36
 * @property null|string $fingerprint <p>Uniquely identifies this particular card number. You can use this attribute to check whether two customers who’ve signed up with you are using the same card number, for example. For payment methods that tokenize card information (Apple Pay, Google Pay), the tokenized number might be provided instead of the underlying card number.</p><p><em>As of May 1, 2021, card fingerprint in India for Connect changed to allow two fingerprints for the same card---one for India and one for the rest of the world.</em></p>
37
 * @property string $funding Card funding type. Can be <code>credit</code>, <code>debit</code>, <code>prepaid</code>, or <code>unknown</code>.
38
 * @property string $last4 The last four digits of the card.
39
 * @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.
40
 * @property null|string $name Cardholder name.
41
 * @property (object{preferred: null|string}&\Stripe\StripeObject&\stdClass) $networks
42
 * @property null|string $regulated_status Status of a card based on the card issuer.
43
 * @property null|string $status For external accounts that are cards, possible values are <code>new</code> and <code>errored</code>. If a payout fails, the status is set to <code>errored</code> and <a href="https://stripe.com/docs/payouts#payout-schedule">scheduled payouts</a> are stopped until account details are updated.
44
 * @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.
45
 */
46
class Card extends ApiResource
47
{
48
    const OBJECT_NAME = 'card';
49

50
    const ALLOW_REDISPLAY_ALWAYS = 'always';
51
    const ALLOW_REDISPLAY_LIMITED = 'limited';
52
    const ALLOW_REDISPLAY_UNSPECIFIED = 'unspecified';
53

54
    const REGULATED_STATUS_REGULATED = 'regulated';
55
    const REGULATED_STATUS_UNREGULATED = 'unregulated';
56

57
    /**
58
     * Delete a specified external account for a given account.
59
     *
60
     * @param null|array $params
61
     * @param null|array|string $opts
62
     *
63
     * @throws \Stripe\Exception\ApiErrorException if the request fails
64
     *
65
     * @return \Stripe\Card the deleted resource
66
     */
67
    public function delete($params = null, $opts = null)
1✔
68
    {
69
        self::_validateParams($params);
1✔
70

71
        $url = $this->instanceUrl();
1✔
72
        list($response, $opts) = $this->_request('delete', $url, $params, $opts);
1✔
73
        $this->refreshFrom($response, $opts);
1✔
74

75
        return $this;
1✔
76
    }
77

78
    /**
79
     * Possible string representations of the CVC check status.
80
     *
81
     * @see https://stripe.com/docs/api/cards/object#card_object-cvc_check
82
     */
83
    const CVC_CHECK_FAIL = 'fail';
84
    const CVC_CHECK_PASS = 'pass';
85
    const CVC_CHECK_UNAVAILABLE = 'unavailable';
86
    const CVC_CHECK_UNCHECKED = 'unchecked';
87

88
    /**
89
     * Possible string representations of the funding of the card.
90
     *
91
     * @see https://stripe.com/docs/api/cards/object#card_object-funding
92
     */
93
    const FUNDING_CREDIT = 'credit';
94
    const FUNDING_DEBIT = 'debit';
95
    const FUNDING_PREPAID = 'prepaid';
96
    const FUNDING_UNKNOWN = 'unknown';
97

98
    /**
99
     * Possible string representations of the tokenization method when using Apple Pay or Google Pay.
100
     *
101
     * @see https://stripe.com/docs/api/cards/object#card_object-tokenization_method
102
     */
103
    const TOKENIZATION_METHOD_APPLE_PAY = 'apple_pay';
104
    const TOKENIZATION_METHOD_GOOGLE_PAY = 'google_pay';
105

106
    /**
107
     * @return string The instance URL for this resource. It needs to be special
108
     *    cased because cards are nested resources that may belong to different
109
     *    top-level resources.
110
     */
111
    public function instanceUrl()
4✔
112
    {
113
        if ($this['customer']) {
4✔
114
            $base = Customer::classUrl();
3✔
115
            $parent = $this['customer'];
3✔
116
            $path = 'sources';
3✔
117
        } elseif ($this['account']) {
1✔
118
            $base = Account::classUrl();
1✔
119
            $parent = $this['account'];
1✔
120
            $path = 'external_accounts';
1✔
121
        } else {
UNCOV
122
            $msg = 'Cards cannot be accessed without a customer ID, or account ID.';
×
123

UNCOV
124
            throw new Exception\UnexpectedValueException($msg);
×
125
        }
126
        $parentExtn = \urlencode(Util\Util::utf8($parent));
4✔
127
        $extn = \urlencode(Util\Util::utf8($this['id']));
4✔
128

129
        return "{$base}/{$parentExtn}/{$path}/{$extn}";
4✔
130
    }
131

132
    /**
133
     * @param array|string $_id
134
     * @param null|array|string $_opts
135
     *
136
     * @throws \Stripe\Exception\BadMethodCallException
137
     */
138
    public static function retrieve($_id, $_opts = null)
1✔
139
    {
140
        $msg = 'Cards cannot be retrieved without a customer ID or an ' .
1✔
141
               'account ID. Retrieve a card using ' .
1✔
142
               "`Customer::retrieveSource('customer_id', 'card_id')` or " .
1✔
143
               "`Account::retrieveExternalAccount('account_id', 'card_id')`.";
1✔
144

145
        throw new Exception\BadMethodCallException($msg);
1✔
146
    }
147

148
    /**
149
     * @param string $_id
150
     * @param null|array $_params
151
     * @param null|array|string $_options
152
     *
153
     * @throws \Stripe\Exception\BadMethodCallException
154
     */
155
    public static function update($_id, $_params = null, $_options = null)
1✔
156
    {
157
        $msg = 'Cards cannot be updated without a customer ID or an ' .
1✔
158
               'account ID. Update a card using ' .
1✔
159
               "`Customer::updateSource('customer_id', 'card_id', " .
1✔
160
               '$updateParams)` or `Account::updateExternalAccount(' .
1✔
161
               "'account_id', 'card_id', \$updateParams)`.";
1✔
162

163
        throw new Exception\BadMethodCallException($msg);
1✔
164
    }
165

166
    /**
167
     * @param null|array|string $opts
168
     *
169
     * @throws \Stripe\Exception\ApiErrorException if the request fails
170
     *
171
     * @return static the saved resource
172
     *
173
     * @deprecated The `save` method is deprecated and will be removed in a
174
     *     future major version of the library. Use the static method `update`
175
     *     on the resource instead.
176
     */
177
    public function save($opts = null)
1✔
178
    {
179
        $params = $this->serializeParameters();
1✔
180
        if (\count($params) > 0) {
1✔
181
            $url = $this->instanceUrl();
1✔
182
            list($response, $opts) = $this->_request('post', $url, $params, $opts, ['save']);
1✔
183
            $this->refreshFrom($response, $opts);
1✔
184
        }
185

186
        return $this;
1✔
187
    }
188
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc