• 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

68.42
/lib/CreditNote.php
1
<?php
2

3
// File generated from our OpenAPI spec
4

5
namespace Stripe;
6

7
/**
8
 * Issue a credit note to adjust an invoice's amount after the invoice is finalized.
9
 *
10
 * Related guide: <a href="https://stripe.com/docs/billing/invoices/credit-notes">Credit notes</a>
11
 *
12
 * @property string $id Unique identifier for the object.
13
 * @property string $object String representing the object's type. Objects of the same type share the same value.
14
 * @property int $amount The integer amount in cents (or local equivalent) representing the total amount of the credit note, including tax.
15
 * @property int $amount_shipping This is the sum of all the shipping amounts.
16
 * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
17
 * @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>.
18
 * @property string|\Stripe\Customer $customer ID of the customer.
19
 * @property null|string|\Stripe\CustomerBalanceTransaction $customer_balance_transaction Customer balance transaction related to this credit note.
20
 * @property int $discount_amount The integer amount in cents (or local equivalent) representing the total amount of discount that was credited.
21
 * @property \Stripe\StripeObject[] $discount_amounts The aggregate amounts calculated per discount for all line items.
22
 * @property null|int $effective_at The date when this credit note is in effect. Same as <code>created</code> unless overwritten. When defined, this value replaces the system-generated 'Date of issue' printed on the credit note PDF.
23
 * @property string|\Stripe\Invoice $invoice ID of the invoice.
24
 * @property \Stripe\Collection<\Stripe\CreditNoteLineItem> $lines Line items that make up the credit note
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|string $memo Customer-facing text that appears on the credit note PDF.
27
 * @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.
28
 * @property string $number A unique number that identifies this particular credit note and appears on the PDF of the credit note and its associated invoice.
29
 * @property null|int $out_of_band_amount Amount that was credited outside of Stripe.
30
 * @property string $pdf The link to download the PDF of the credit note.
31
 * @property null|string $reason Reason for issuing this credit note, one of <code>duplicate</code>, <code>fraudulent</code>, <code>order_change</code>, or <code>product_unsatisfactory</code>
32
 * @property null|string|\Stripe\Refund $refund Refund related to this credit note.
33
 * @property null|\Stripe\StripeObject $shipping_cost The details of the cost of shipping, including the ShippingRate applied to the invoice.
34
 * @property string $status Status of this credit note, one of <code>issued</code> or <code>void</code>. Learn more about <a href="https://stripe.com/docs/billing/invoices/credit-notes#voiding">voiding credit notes</a>.
35
 * @property int $subtotal The integer amount in cents (or local equivalent) representing the amount of the credit note, excluding exclusive tax and invoice level discounts.
36
 * @property null|int $subtotal_excluding_tax The integer amount in cents (or local equivalent) representing the amount of the credit note, excluding all tax and invoice level discounts.
37
 * @property \Stripe\StripeObject[] $tax_amounts The aggregate amounts calculated per tax rate for all line items.
38
 * @property int $total The integer amount in cents (or local equivalent) representing the total amount of the credit note, including tax and all discount.
39
 * @property null|int $total_excluding_tax The integer amount in cents (or local equivalent) representing the total amount of the credit note, excluding tax, but including discounts.
40
 * @property string $type Type of this credit note, one of <code>pre_payment</code> or <code>post_payment</code>. A <code>pre_payment</code> credit note means it was issued when the invoice was open. A <code>post_payment</code> credit note means it was issued when the invoice was paid.
41
 * @property null|int $voided_at The time that the credit note was voided.
42
 */
43
class CreditNote extends ApiResource
44
{
45
    const OBJECT_NAME = 'credit_note';
46

47
    use ApiOperations\All;
48
    use ApiOperations\Create;
49
    use ApiOperations\NestedResource;
50
    use ApiOperations\Retrieve;
51
    use ApiOperations\Update;
52

53
    const REASON_DUPLICATE = 'duplicate';
54
    const REASON_FRAUDULENT = 'fraudulent';
55
    const REASON_ORDER_CHANGE = 'order_change';
56
    const REASON_PRODUCT_UNSATISFACTORY = 'product_unsatisfactory';
57

58
    const STATUS_ISSUED = 'issued';
59
    const STATUS_VOID = 'void';
60

61
    const TYPE_POST_PAYMENT = 'post_payment';
62
    const TYPE_PRE_PAYMENT = 'pre_payment';
63

64
    /**
65
     * @param null|array $params
66
     * @param null|array|string $opts
67
     *
68
     * @throws \Stripe\Exception\ApiErrorException if the request fails
69
     *
70
     * @return \Stripe\CreditNote the previewed credit note
71
     */
72
    public static function preview($params = null, $opts = null)
1✔
73
    {
74
        $url = static::classUrl() . '/preview';
1✔
75
        list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
1✔
76
        $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
1✔
77
        $obj->setLastResponse($response);
1✔
78

79
        return $obj;
1✔
80
    }
81

82
    /**
83
     * @param null|array $params
84
     * @param null|array|string $opts
85
     *
86
     * @throws \Stripe\Exception\ApiErrorException if the request fails
87
     *
88
     * @return \Stripe\Collection<\Stripe\CreditNoteLineItem> list of credit note line items
89
     */
90
    public static function previewLines($params = null, $opts = null)
×
91
    {
92
        $url = static::classUrl() . '/preview/lines';
×
93
        list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
×
94
        $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
×
95
        $obj->setLastResponse($response);
×
96

97
        return $obj;
×
98
    }
99

100
    /**
101
     * @param null|array $params
102
     * @param null|array|string $opts
103
     *
104
     * @throws \Stripe\Exception\ApiErrorException if the request fails
105
     *
106
     * @return \Stripe\CreditNote the voided credit note
107
     */
108
    public function voidCreditNote($params = null, $opts = null)
1✔
109
    {
110
        $url = $this->instanceUrl() . '/void';
1✔
111
        list($response, $opts) = $this->_request('post', $url, $params, $opts);
1✔
112
        $this->refreshFrom($response, $opts);
1✔
113

114
        return $this;
1✔
115
    }
116

117
    const PATH_LINES = '/lines';
118

119
    /**
120
     * @param string $id the ID of the credit note on which to retrieve the credit note line items
121
     * @param null|array $params
122
     * @param null|array|string $opts
123
     *
124
     * @throws \Stripe\Exception\ApiErrorException if the request fails
125
     *
126
     * @return \Stripe\Collection<\Stripe\CreditNoteLineItem> the list of credit note line items
127
     */
128
    public static function allLines($id, $params = null, $opts = null)
1✔
129
    {
130
        return self::_allNestedResources($id, static::PATH_LINES, $params, $opts);
1✔
131
    }
132
}
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