ApiOperations
2 months ago
Apps
2 months ago
Billing
2 months ago
BillingPortal
2 months ago
Checkout
2 months ago
Climate
2 months ago
Entitlements
2 months ago
EventData
2 months ago
Events
2 months ago
Exception
2 months ago
FinancialConnections
2 months ago
Forwarding
2 months ago
HttpClient
2 months ago
Identity
2 months ago
Issuing
2 months ago
Radar
2 months ago
Reporting
2 months ago
Service
2 months ago
Sigma
2 months ago
Tax
2 months ago
Terminal
2 months ago
TestHelpers
2 months ago
Treasury
2 months ago
Util
2 months ago
V2
2 months ago
Account.php
2 months ago
AccountLink.php
2 months ago
AccountSession.php
2 months ago
ApiRequestor.php
2 months ago
ApiResource.php
2 months ago
ApiResponse.php
2 months ago
ApplePayDomain.php
2 months ago
Application.php
2 months ago
ApplicationFee.php
2 months ago
ApplicationFeeRefund.php
2 months ago
Balance.php
2 months ago
BalanceTransaction.php
2 months ago
BankAccount.php
2 months ago
BaseStripeClient.php
2 months ago
BaseStripeClientInterface.php
2 months ago
Capability.php
2 months ago
Card.php
2 months ago
CashBalance.php
2 months ago
Charge.php
2 months ago
Collection.php
2 months ago
ConfirmationToken.php
2 months ago
ConnectCollectionTransfer.php
2 months ago
CountrySpec.php
2 months ago
Coupon.php
2 months ago
CreditNote.php
2 months ago
CreditNoteLineItem.php
2 months ago
Customer.php
2 months ago
CustomerBalanceTransaction.php
2 months ago
CustomerCashBalanceTransaction.php
2 months ago
CustomerSession.php
2 months ago
Discount.php
2 months ago
Dispute.php
2 months ago
EphemeralKey.php
2 months ago
ErrorObject.php
2 months ago
Event.php
2 months ago
ExchangeRate.php
2 months ago
File.php
2 months ago
FileLink.php
2 months ago
FundingInstructions.php
2 months ago
Invoice.php
2 months ago
InvoiceItem.php
2 months ago
InvoiceLineItem.php
2 months ago
InvoiceRenderingTemplate.php
2 months ago
LineItem.php
2 months ago
LoginLink.php
2 months ago
Mandate.php
2 months ago
OAuth.php
2 months ago
OAuthErrorObject.php
2 months ago
PaymentIntent.php
2 months ago
PaymentLink.php
2 months ago
PaymentMethod.php
2 months ago
PaymentMethodConfiguration.php
2 months ago
PaymentMethodDomain.php
2 months ago
Payout.php
2 months ago
Person.php
2 months ago
Plan.php
2 months ago
Price.php
2 months ago
Product.php
2 months ago
ProductFeature.php
2 months ago
PromotionCode.php
2 months ago
Quote.php
2 months ago
Reason.php
2 months ago
RecipientTransfer.php
2 months ago
Refund.php
2 months ago
RelatedObject.php
2 months ago
RequestTelemetry.php
2 months ago
ReserveTransaction.php
2 months ago
Review.php
2 months ago
SearchResult.php
2 months ago
SetupAttempt.php
2 months ago
SetupIntent.php
2 months ago
ShippingRate.php
2 months ago
SingletonApiResource.php
2 months ago
Source.php
2 months ago
SourceMandateNotification.php
2 months ago
SourceTransaction.php
2 months ago
Stripe.php
2 months ago
StripeClient.php
2 months ago
StripeClientInterface.php
2 months ago
StripeObject.php
2 months ago
StripeStreamingClientInterface.php
2 months ago
Subscription.php
2 months ago
SubscriptionItem.php
2 months ago
SubscriptionSchedule.php
2 months ago
TaxCode.php
2 months ago
TaxDeductedAtSource.php
2 months ago
TaxId.php
2 months ago
TaxRate.php
2 months ago
ThinEvent.php
2 months ago
Token.php
2 months ago
Topup.php
2 months ago
Transfer.php
2 months ago
TransferReversal.php
2 months ago
UsageRecord.php
2 months ago
UsageRecordSummary.php
2 months ago
Webhook.php
2 months ago
WebhookEndpoint.php
2 months ago
WebhookSignature.php
2 months ago
CreditNote.php
208 lines
| 1 | <?php |
| 2 | |
| 3 | // File generated from our OpenAPI spec |
| 4 | namespace ProfilePressVendor\Stripe; |
| 5 | |
| 6 | /** |
| 7 | * Issue a credit note to adjust an invoice's amount after the invoice is finalized. |
| 8 | * |
| 9 | * Related guide: <a href="https://stripe.com/docs/billing/invoices/credit-notes">Credit notes</a> |
| 10 | * |
| 11 | * @property string $id Unique identifier for the object. |
| 12 | * @property string $object String representing the object's type. Objects of the same type share the same value. |
| 13 | * @property int $amount The integer amount in cents (or local equivalent) representing the total amount of the credit note, including tax. |
| 14 | * @property int $amount_shipping This is the sum of all the shipping amounts. |
| 15 | * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. |
| 16 | * @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>. |
| 17 | * @property string|\Stripe\Customer $customer ID of the customer. |
| 18 | * @property null|string|\Stripe\CustomerBalanceTransaction $customer_balance_transaction Customer balance transaction related to this credit note. |
| 19 | * @property int $discount_amount The integer amount in cents (or local equivalent) representing the total amount of discount that was credited. |
| 20 | * @property \Stripe\StripeObject[] $discount_amounts The aggregate amounts calculated per discount for all line items. |
| 21 | * @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. |
| 22 | * @property string|\Stripe\Invoice $invoice ID of the invoice. |
| 23 | * @property \Stripe\Collection<\Stripe\CreditNoteLineItem> $lines Line items that make up the credit note |
| 24 | * @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. |
| 25 | * @property null|string $memo Customer-facing text that appears on the credit note PDF. |
| 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 $number A unique number that identifies this particular credit note and appears on the PDF of the credit note and its associated invoice. |
| 28 | * @property null|int $out_of_band_amount Amount that was credited outside of Stripe. |
| 29 | * @property string $pdf The link to download the PDF of the credit note. |
| 30 | * @property \Stripe\StripeObject[] $pretax_credit_amounts The pretax credit amounts (ex: discount, credit grants, etc) for all line items. |
| 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 | use ApiOperations\NestedResource; |
| 47 | use ApiOperations\Update; |
| 48 | const REASON_DUPLICATE = 'duplicate'; |
| 49 | const REASON_FRAUDULENT = 'fraudulent'; |
| 50 | const REASON_ORDER_CHANGE = 'order_change'; |
| 51 | const REASON_PRODUCT_UNSATISFACTORY = 'product_unsatisfactory'; |
| 52 | const STATUS_ISSUED = 'issued'; |
| 53 | const STATUS_VOID = 'void'; |
| 54 | const TYPE_POST_PAYMENT = 'post_payment'; |
| 55 | const TYPE_PRE_PAYMENT = 'pre_payment'; |
| 56 | /** |
| 57 | * Issue a credit note to adjust the amount of a finalized invoice. For a |
| 58 | * <code>status=open</code> invoice, a credit note reduces its |
| 59 | * <code>amount_due</code>. For a <code>status=paid</code> invoice, a credit note |
| 60 | * does not affect its <code>amount_due</code>. Instead, it can result in any |
| 61 | * combination of the following:. |
| 62 | * |
| 63 | * <ul> <li>Refund: create a new refund (using <code>refund_amount</code>) or link |
| 64 | * an existing refund (using <code>refund</code>).</li> <li>Customer balance |
| 65 | * credit: credit the customer’s balance (using <code>credit_amount</code>) which |
| 66 | * will be automatically applied to their next invoice when it’s finalized.</li> |
| 67 | * <li>Outside of Stripe credit: record the amount that is or will be credited |
| 68 | * outside of Stripe (using <code>out_of_band_amount</code>).</li> </ul> |
| 69 | * |
| 70 | * For post-payment credit notes the sum of the refund, credit and outside of |
| 71 | * Stripe amounts must equal the credit note total. |
| 72 | * |
| 73 | * You may issue multiple credit notes for an invoice. Each credit note will |
| 74 | * increment the invoice’s <code>pre_payment_credit_notes_amount</code> or |
| 75 | * <code>post_payment_credit_notes_amount</code> depending on its |
| 76 | * <code>status</code> at the time of credit note creation. |
| 77 | * |
| 78 | * @param null|array $params |
| 79 | * @param null|array|string $options |
| 80 | * |
| 81 | * @throws \Stripe\Exception\ApiErrorException if the request fails |
| 82 | * |
| 83 | * @return \Stripe\CreditNote the created resource |
| 84 | */ |
| 85 | public static function create($params = null, $options = null) |
| 86 | { |
| 87 | self::_validateParams($params); |
| 88 | $url = static::classUrl(); |
| 89 | list($response, $opts) = static::_staticRequest('post', $url, $params, $options); |
| 90 | $obj = \ProfilePressVendor\Stripe\Util\Util::convertToStripeObject($response->json, $opts); |
| 91 | $obj->setLastResponse($response); |
| 92 | return $obj; |
| 93 | } |
| 94 | /** |
| 95 | * Returns a list of credit notes. |
| 96 | * |
| 97 | * @param null|array $params |
| 98 | * @param null|array|string $opts |
| 99 | * |
| 100 | * @throws \Stripe\Exception\ApiErrorException if the request fails |
| 101 | * |
| 102 | * @return \Stripe\Collection<\Stripe\CreditNote> of ApiResources |
| 103 | */ |
| 104 | public static function all($params = null, $opts = null) |
| 105 | { |
| 106 | $url = static::classUrl(); |
| 107 | return static::_requestPage($url, \ProfilePressVendor\Stripe\Collection::class, $params, $opts); |
| 108 | } |
| 109 | /** |
| 110 | * Retrieves the credit note object with the given identifier. |
| 111 | * |
| 112 | * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key |
| 113 | * @param null|array|string $opts |
| 114 | * |
| 115 | * @throws \Stripe\Exception\ApiErrorException if the request fails |
| 116 | * |
| 117 | * @return \Stripe\CreditNote |
| 118 | */ |
| 119 | public static function retrieve($id, $opts = null) |
| 120 | { |
| 121 | $opts = \ProfilePressVendor\Stripe\Util\RequestOptions::parse($opts); |
| 122 | $instance = new static($id, $opts); |
| 123 | $instance->refresh(); |
| 124 | return $instance; |
| 125 | } |
| 126 | /** |
| 127 | * Updates an existing credit note. |
| 128 | * |
| 129 | * @param string $id the ID of the resource to update |
| 130 | * @param null|array $params |
| 131 | * @param null|array|string $opts |
| 132 | * |
| 133 | * @throws \Stripe\Exception\ApiErrorException if the request fails |
| 134 | * |
| 135 | * @return \Stripe\CreditNote the updated resource |
| 136 | */ |
| 137 | public static function update($id, $params = null, $opts = null) |
| 138 | { |
| 139 | self::_validateParams($params); |
| 140 | $url = static::resourceUrl($id); |
| 141 | list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); |
| 142 | $obj = \ProfilePressVendor\Stripe\Util\Util::convertToStripeObject($response->json, $opts); |
| 143 | $obj->setLastResponse($response); |
| 144 | return $obj; |
| 145 | } |
| 146 | /** |
| 147 | * @param null|array $params |
| 148 | * @param null|array|string $opts |
| 149 | * |
| 150 | * @throws \Stripe\Exception\ApiErrorException if the request fails |
| 151 | * |
| 152 | * @return \Stripe\CreditNote the previewed credit note |
| 153 | */ |
| 154 | public static function preview($params = null, $opts = null) |
| 155 | { |
| 156 | $url = static::classUrl() . '/preview'; |
| 157 | list($response, $opts) = static::_staticRequest('get', $url, $params, $opts); |
| 158 | $obj = \ProfilePressVendor\Stripe\Util\Util::convertToStripeObject($response->json, $opts); |
| 159 | $obj->setLastResponse($response); |
| 160 | return $obj; |
| 161 | } |
| 162 | /** |
| 163 | * @param null|array $params |
| 164 | * @param null|array|string $opts |
| 165 | * |
| 166 | * @throws \Stripe\Exception\ApiErrorException if the request fails |
| 167 | * |
| 168 | * @return \Stripe\Collection<\Stripe\CreditNoteLineItem> list of credit note line items |
| 169 | */ |
| 170 | public static function previewLines($params = null, $opts = null) |
| 171 | { |
| 172 | $url = static::classUrl() . '/preview/lines'; |
| 173 | list($response, $opts) = static::_staticRequest('get', $url, $params, $opts); |
| 174 | $obj = \ProfilePressVendor\Stripe\Util\Util::convertToStripeObject($response->json, $opts); |
| 175 | $obj->setLastResponse($response); |
| 176 | return $obj; |
| 177 | } |
| 178 | /** |
| 179 | * @param null|array $params |
| 180 | * @param null|array|string $opts |
| 181 | * |
| 182 | * @throws \Stripe\Exception\ApiErrorException if the request fails |
| 183 | * |
| 184 | * @return \Stripe\CreditNote the voided credit note |
| 185 | */ |
| 186 | public function voidCreditNote($params = null, $opts = null) |
| 187 | { |
| 188 | $url = $this->instanceUrl() . '/void'; |
| 189 | list($response, $opts) = $this->_request('post', $url, $params, $opts); |
| 190 | $this->refreshFrom($response, $opts); |
| 191 | return $this; |
| 192 | } |
| 193 | const PATH_LINES = '/lines'; |
| 194 | /** |
| 195 | * @param string $id the ID of the credit note on which to retrieve the credit note line items |
| 196 | * @param null|array $params |
| 197 | * @param null|array|string $opts |
| 198 | * |
| 199 | * @throws \Stripe\Exception\ApiErrorException if the request fails |
| 200 | * |
| 201 | * @return \Stripe\Collection<\Stripe\CreditNoteLineItem> the list of credit note line items |
| 202 | */ |
| 203 | public static function allLines($id, $params = null, $opts = null) |
| 204 | { |
| 205 | return self::_allNestedResources($id, static::PATH_LINES, $params, $opts); |
| 206 | } |
| 207 | } |
| 208 |