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

stripe / stripe-php / 6471862601

10 Oct 2023 04:02PM UTC coverage: 69.665% (-0.5%) from 70.141%
6471862601

push

github

web-flow
Merge pull request #1570 from localheinz/feature/coveralls

Enhancement: Use `coverallsapp/github-action` to report code coverage

2393 of 3435 relevant lines covered (69.67%)

3.5 hits per line

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

38.46
/lib/CustomerBalanceTransaction.php
1
<?php
2

3
// File generated from our OpenAPI spec
4

5
namespace Stripe;
6

7
/**
8
 * Each customer has a <a href="https://stripe.com/docs/api/customers/object#customer_object-balance">Balance</a> value,
9
 * which denotes a debit or credit that's automatically applied to their next invoice upon finalization.
10
 * You may modify the value directly by using the <a href="https://stripe.com/docs/api/customers/update">update customer API</a>,
11
 * or by creating a Customer Balance Transaction, which increments or decrements the customer's <code>balance</code> by the specified <code>amount</code>.
12
 *
13
 * Related guide: <a href="https://stripe.com/docs/billing/customer/balance">Customer balance</a>
14
 *
15
 * @property string $id Unique identifier for the object.
16
 * @property string $object String representing the object's type. Objects of the same type share the same value.
17
 * @property int $amount The amount of the transaction. A negative value is a credit for the customer's balance, and a positive value is a debit to the customer's <code>balance</code>.
18
 * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
19
 * @property null|string|\Stripe\CreditNote $credit_note The ID of the credit note (if any) related to the transaction.
20
 * @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>.
21
 * @property string|\Stripe\Customer $customer The ID of the customer the transaction belongs to.
22
 * @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users.
23
 * @property int $ending_balance The customer's <code>balance</code> after the transaction was applied. A negative value decreases the amount due on the customer's next invoice. A positive value increases the amount due on the customer's next invoice.
24
 * @property null|string|\Stripe\Invoice $invoice The ID of the invoice (if any) related to the transaction.
25
 * @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.
26
 * @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.
27
 * @property string $type Transaction type: <code>adjustment</code>, <code>applied_to_invoice</code>, <code>credit_note</code>, <code>initial</code>, <code>invoice_overpaid</code>, <code>invoice_too_large</code>, <code>invoice_too_small</code>, <code>unspent_receiver_credit</code>, or <code>unapplied_from_invoice</code>. See the <a href="https://stripe.com/docs/billing/customer/balance#types">Customer Balance page</a> to learn more about transaction types.
28
 */
29
class CustomerBalanceTransaction extends ApiResource
30
{
31
    const OBJECT_NAME = 'customer_balance_transaction';
32

33
    const TYPE_ADJUSTMENT = 'adjustment';
34
    const TYPE_APPLIED_TO_INVOICE = 'applied_to_invoice';
35
    const TYPE_CREDIT_NOTE = 'credit_note';
36
    const TYPE_INITIAL = 'initial';
37
    const TYPE_INVOICE_OVERPAID = 'invoice_overpaid';
38
    const TYPE_INVOICE_TOO_LARGE = 'invoice_too_large';
39
    const TYPE_INVOICE_TOO_SMALL = 'invoice_too_small';
40
    const TYPE_UNSPENT_RECEIVER_CREDIT = 'unspent_receiver_credit';
41

42
    const TYPE_ADJUSTEMENT = 'adjustment';
43

44
    /**
45
     * @return string the API URL for this balance transaction
46
     */
47
    public function instanceUrl()
1✔
48
    {
49
        $id = $this['id'];
1✔
50
        $customer = $this['customer'];
1✔
51
        if (!$id) {
1✔
52
            throw new Exception\UnexpectedValueException(
×
53
                "Could not determine which URL to request: class instance has invalid ID: {$id}",
×
54
                null
×
55
            );
×
56
        }
57
        $id = Util\Util::utf8($id);
1✔
58
        $customer = Util\Util::utf8($customer);
1✔
59

60
        $base = Customer::classUrl();
1✔
61
        $customerExtn = \urlencode($customer);
1✔
62
        $extn = \urlencode($id);
1✔
63

64
        return "{$base}/{$customerExtn}/balance_transactions/{$extn}";
1✔
65
    }
66

67
    /**
68
     * @param array|string $_id
69
     * @param null|array|string $_opts
70
     *
71
     * @throws \Stripe\Exception\BadMethodCallException
72
     */
73
    public static function retrieve($_id, $_opts = null)
×
74
    {
75
        $msg = 'Customer Balance Transactions cannot be retrieved without a ' .
×
76
               'customer ID. Retrieve a Customer Balance Transaction using ' .
×
77
               "`Customer::retrieveBalanceTransaction('customer_id', " .
×
78
               "'balance_transaction_id')`.";
×
79

80
        throw new Exception\BadMethodCallException($msg);
×
81
    }
82

83
    /**
84
     * @param string $_id
85
     * @param null|array $_params
86
     * @param null|array|string $_options
87
     *
88
     * @throws \Stripe\Exception\BadMethodCallException
89
     */
90
    public static function update($_id, $_params = null, $_options = null)
×
91
    {
92
        $msg = 'Customer Balance Transactions cannot be updated without a ' .
×
93
               'customer ID. Update a Customer Balance Transaction using ' .
×
94
               "`Customer::updateBalanceTransaction('customer_id', " .
×
95
               "'balance_transaction_id', \$updateParams)`.";
×
96

97
        throw new Exception\BadMethodCallException($msg);
×
98
    }
99
}
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