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

stripe / stripe-java / #16380

30 Aug 2024 07:54PM UTC coverage: 12.882% (-0.004%) from 12.886%
#16380

push

github

web-flow
Merge from master after the changes to not pass api_mode from individual methods (#1857)

* Generate SDK for OpenAPI spec version 1230 (#1856)

* Bump version to 26.9.0

* No need for APIMode to be passed around from individual API methods (#1855)

* Generated code

* Update the code around raw request

* Update the v2 tests to use v2 path

16 of 23 new or added lines in 7 files covered. (69.57%)

706 existing lines in 213 files now uncovered.

18468 of 143365 relevant lines covered (12.88%)

0.13 hits per line

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

57.14
/src/main/java/com/stripe/service/CreditNoteService.java
1
// File generated from our OpenAPI spec
2
package com.stripe.service;
3

4
import com.google.gson.reflect.TypeToken;
5
import com.stripe.exception.StripeException;
6
import com.stripe.model.CreditNote;
7
import com.stripe.model.StripeCollection;
8
import com.stripe.net.ApiRequest;
9
import com.stripe.net.ApiRequestParams;
10
import com.stripe.net.ApiResource;
11
import com.stripe.net.ApiService;
12
import com.stripe.net.BaseAddress;
13
import com.stripe.net.RequestOptions;
14
import com.stripe.net.StripeResponseGetter;
15
import com.stripe.param.CreditNoteCreateParams;
16
import com.stripe.param.CreditNoteListParams;
17
import com.stripe.param.CreditNotePreviewParams;
18
import com.stripe.param.CreditNoteRetrieveParams;
19
import com.stripe.param.CreditNoteUpdateParams;
20
import com.stripe.param.CreditNoteVoidCreditNoteParams;
21

22
public final class CreditNoteService extends ApiService {
23
  public CreditNoteService(StripeResponseGetter responseGetter) {
24
    super(responseGetter);
1✔
25
  }
1✔
26

27
  /** Returns a list of credit notes. */
28
  public StripeCollection<CreditNote> list(CreditNoteListParams params) throws StripeException {
29
    return list(params, (RequestOptions) null);
1✔
30
  }
31
  /** Returns a list of credit notes. */
32
  public StripeCollection<CreditNote> list(RequestOptions options) throws StripeException {
33
    return list((CreditNoteListParams) null, options);
×
34
  }
35
  /** Returns a list of credit notes. */
36
  public StripeCollection<CreditNote> list() throws StripeException {
37
    return list((CreditNoteListParams) null, (RequestOptions) null);
×
38
  }
39
  /** Returns a list of credit notes. */
40
  public StripeCollection<CreditNote> list(CreditNoteListParams params, RequestOptions options)
41
      throws StripeException {
42
    String path = "/v1/credit_notes";
1✔
43
    ApiRequest request =
1✔
44
        new ApiRequest(
45
            BaseAddress.API,
46
            ApiResource.RequestMethod.GET,
47
            path,
48
            ApiRequestParams.paramsToMap(params),
1✔
49
            options);
50
    return this.request(request, new TypeToken<StripeCollection<CreditNote>>() {}.getType());
1✔
51
  }
52
  /**
53
   * Issue a credit note to adjust the amount of a finalized invoice. For a {@code status=open}
54
   * invoice, a credit note reduces its {@code amount_due}. For a {@code status=paid} invoice, a
55
   * credit note does not affect its {@code amount_due}. Instead, it can result in any combination
56
   * of the following:
57
   *
58
   * <p>
59
   *
60
   * <ul>
61
   *   <li>Refund: create a new refund (using {@code refund_amount}) or link an existing refund
62
   *       (using {@code refund}).
63
   *   <li>Customer balance credit: credit the customer’s balance (using {@code credit_amount})
64
   *       which will be automatically applied to their next invoice when it’s finalized.
65
   *   <li>Outside of Stripe credit: record the amount that is or will be credited outside of Stripe
66
   *       (using {@code out_of_band_amount}).
67
   * </ul>
68
   *
69
   * <p>For post-payment credit notes the sum of the refund, credit and outside of Stripe amounts
70
   * must equal the credit note total.
71
   *
72
   * <p>You may issue multiple credit notes for an invoice. Each credit note will increment the
73
   * invoice’s {@code pre_payment_credit_notes_amount} or {@code post_payment_credit_notes_amount}
74
   * depending on its {@code status} at the time of credit note creation.
75
   */
76
  public CreditNote create(CreditNoteCreateParams params) throws StripeException {
77
    return create(params, (RequestOptions) null);
1✔
78
  }
79
  /**
80
   * Issue a credit note to adjust the amount of a finalized invoice. For a {@code status=open}
81
   * invoice, a credit note reduces its {@code amount_due}. For a {@code status=paid} invoice, a
82
   * credit note does not affect its {@code amount_due}. Instead, it can result in any combination
83
   * of the following:
84
   *
85
   * <p>
86
   *
87
   * <ul>
88
   *   <li>Refund: create a new refund (using {@code refund_amount}) or link an existing refund
89
   *       (using {@code refund}).
90
   *   <li>Customer balance credit: credit the customer’s balance (using {@code credit_amount})
91
   *       which will be automatically applied to their next invoice when it’s finalized.
92
   *   <li>Outside of Stripe credit: record the amount that is or will be credited outside of Stripe
93
   *       (using {@code out_of_band_amount}).
94
   * </ul>
95
   *
96
   * <p>For post-payment credit notes the sum of the refund, credit and outside of Stripe amounts
97
   * must equal the credit note total.
98
   *
99
   * <p>You may issue multiple credit notes for an invoice. Each credit note will increment the
100
   * invoice’s {@code pre_payment_credit_notes_amount} or {@code post_payment_credit_notes_amount}
101
   * depending on its {@code status} at the time of credit note creation.
102
   */
103
  public CreditNote create(CreditNoteCreateParams params, RequestOptions options)
104
      throws StripeException {
105
    String path = "/v1/credit_notes";
1✔
106
    ApiRequest request =
1✔
107
        new ApiRequest(
108
            BaseAddress.API,
109
            ApiResource.RequestMethod.POST,
110
            path,
111
            ApiRequestParams.paramsToMap(params),
1✔
112
            options);
113
    return this.request(request, CreditNote.class);
1✔
114
  }
115
  /** Retrieves the credit note object with the given identifier. */
116
  public CreditNote retrieve(String id, CreditNoteRetrieveParams params) throws StripeException {
117
    return retrieve(id, params, (RequestOptions) null);
×
118
  }
119
  /** Retrieves the credit note object with the given identifier. */
120
  public CreditNote retrieve(String id, RequestOptions options) throws StripeException {
121
    return retrieve(id, (CreditNoteRetrieveParams) null, options);
×
122
  }
123
  /** Retrieves the credit note object with the given identifier. */
124
  public CreditNote retrieve(String id) throws StripeException {
125
    return retrieve(id, (CreditNoteRetrieveParams) null, (RequestOptions) null);
×
126
  }
127
  /** Retrieves the credit note object with the given identifier. */
128
  public CreditNote retrieve(String id, CreditNoteRetrieveParams params, RequestOptions options)
129
      throws StripeException {
130
    String path = String.format("/v1/credit_notes/%s", ApiResource.urlEncodeId(id));
×
131
    ApiRequest request =
×
132
        new ApiRequest(
133
            BaseAddress.API,
134
            ApiResource.RequestMethod.GET,
135
            path,
136
            ApiRequestParams.paramsToMap(params),
×
137
            options);
UNCOV
138
    return this.request(request, CreditNote.class);
×
139
  }
140
  /** Updates an existing credit note. */
141
  public CreditNote update(String id, CreditNoteUpdateParams params) throws StripeException {
142
    return update(id, params, (RequestOptions) null);
×
143
  }
144
  /** Updates an existing credit note. */
145
  public CreditNote update(String id, RequestOptions options) throws StripeException {
146
    return update(id, (CreditNoteUpdateParams) null, options);
×
147
  }
148
  /** Updates an existing credit note. */
149
  public CreditNote update(String id) throws StripeException {
150
    return update(id, (CreditNoteUpdateParams) null, (RequestOptions) null);
×
151
  }
152
  /** Updates an existing credit note. */
153
  public CreditNote update(String id, CreditNoteUpdateParams params, RequestOptions options)
154
      throws StripeException {
155
    String path = String.format("/v1/credit_notes/%s", ApiResource.urlEncodeId(id));
×
156
    ApiRequest request =
×
157
        new ApiRequest(
158
            BaseAddress.API,
159
            ApiResource.RequestMethod.POST,
160
            path,
161
            ApiRequestParams.paramsToMap(params),
×
162
            options);
UNCOV
163
    return this.request(request, CreditNote.class);
×
164
  }
165
  /** Get a preview of a credit note without creating it. */
166
  public CreditNote preview(CreditNotePreviewParams params) throws StripeException {
167
    return preview(params, (RequestOptions) null);
1✔
168
  }
169
  /** Get a preview of a credit note without creating it. */
170
  public CreditNote preview(CreditNotePreviewParams params, RequestOptions options)
171
      throws StripeException {
172
    String path = "/v1/credit_notes/preview";
1✔
173
    ApiRequest request =
1✔
174
        new ApiRequest(
175
            BaseAddress.API,
176
            ApiResource.RequestMethod.GET,
177
            path,
178
            ApiRequestParams.paramsToMap(params),
1✔
179
            options);
180
    return this.request(request, CreditNote.class);
1✔
181
  }
182
  /**
183
   * Marks a credit note as void. Learn more about <a
184
   * href="https://stripe.com/docs/billing/invoices/credit-notes#voiding">voiding credit notes</a>.
185
   */
186
  public CreditNote voidCreditNote(String id, CreditNoteVoidCreditNoteParams params)
187
      throws StripeException {
188
    return voidCreditNote(id, params, (RequestOptions) null);
1✔
189
  }
190
  /**
191
   * Marks a credit note as void. Learn more about <a
192
   * href="https://stripe.com/docs/billing/invoices/credit-notes#voiding">voiding credit notes</a>.
193
   */
194
  public CreditNote voidCreditNote(String id, RequestOptions options) throws StripeException {
195
    return voidCreditNote(id, (CreditNoteVoidCreditNoteParams) null, options);
×
196
  }
197
  /**
198
   * Marks a credit note as void. Learn more about <a
199
   * href="https://stripe.com/docs/billing/invoices/credit-notes#voiding">voiding credit notes</a>.
200
   */
201
  public CreditNote voidCreditNote(String id) throws StripeException {
202
    return voidCreditNote(id, (CreditNoteVoidCreditNoteParams) null, (RequestOptions) null);
×
203
  }
204
  /**
205
   * Marks a credit note as void. Learn more about <a
206
   * href="https://stripe.com/docs/billing/invoices/credit-notes#voiding">voiding credit notes</a>.
207
   */
208
  public CreditNote voidCreditNote(
209
      String id, CreditNoteVoidCreditNoteParams params, RequestOptions options)
210
      throws StripeException {
211
    String path = String.format("/v1/credit_notes/%s/void", ApiResource.urlEncodeId(id));
1✔
212
    ApiRequest request =
1✔
213
        new ApiRequest(
214
            BaseAddress.API,
215
            ApiResource.RequestMethod.POST,
216
            path,
217
            ApiRequestParams.paramsToMap(params),
1✔
218
            options);
219
    return this.request(request, CreditNote.class);
1✔
220
  }
221

222
  public com.stripe.service.CreditNoteLineItemService lineItems() {
223
    return new com.stripe.service.CreditNoteLineItemService(this.getResponseGetter());
1✔
224
  }
225

226
  public com.stripe.service.CreditNotePreviewLinesService previewLines() {
227
    return new com.stripe.service.CreditNotePreviewLinesService(this.getResponseGetter());
1✔
228
  }
229
}
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