• 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

47.2
/src/main/java/com/stripe/model/Refund.java
1
// File generated from our OpenAPI spec
2
package com.stripe.model;
3

4
import com.google.gson.annotations.SerializedName;
5
import com.stripe.exception.StripeException;
6
import com.stripe.net.ApiRequest;
7
import com.stripe.net.ApiRequestParams;
8
import com.stripe.net.ApiResource;
9
import com.stripe.net.BaseAddress;
10
import com.stripe.net.RequestOptions;
11
import com.stripe.net.StripeResponseGetter;
12
import com.stripe.param.RefundCancelParams;
13
import com.stripe.param.RefundCreateParams;
14
import com.stripe.param.RefundExpireParams;
15
import com.stripe.param.RefundListParams;
16
import com.stripe.param.RefundRetrieveParams;
17
import com.stripe.param.RefundUpdateParams;
18
import java.util.Map;
19
import lombok.EqualsAndHashCode;
20
import lombok.Getter;
21
import lombok.Setter;
22

23
/**
24
 * Refund objects allow you to refund a previously created charge that isn't refunded yet. Funds are
25
 * refunded to the credit or debit card that's initially charged.
26
 *
27
 * <p>Related guide: <a href="https://stripe.com/docs/refunds">Refunds</a>
28
 */
29
@Getter
30
@Setter
31
@EqualsAndHashCode(callSuper = false)
32
public class Refund extends ApiResource implements MetadataStore<Refund>, BalanceTransactionSource {
1✔
33
  /** Amount, in cents (or local equivalent). */
34
  @SerializedName("amount")
35
  Long amount;
36

37
  /** Balance transaction that describes the impact on your account balance. */
38
  @SerializedName("balance_transaction")
39
  @Getter(lombok.AccessLevel.NONE)
40
  @Setter(lombok.AccessLevel.NONE)
41
  ExpandableField<BalanceTransaction> balanceTransaction;
42

43
  /** ID of the charge that's refunded. */
44
  @SerializedName("charge")
45
  @Getter(lombok.AccessLevel.NONE)
46
  @Setter(lombok.AccessLevel.NONE)
47
  ExpandableField<Charge> charge;
48

49
  /** Time at which the object was created. Measured in seconds since the Unix epoch. */
50
  @SerializedName("created")
51
  Long created;
52

53
  /**
54
   * Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>,
55
   * in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported currency</a>.
56
   */
57
  @SerializedName("currency")
58
  String currency;
59

60
  /**
61
   * An arbitrary string attached to the object. You can use this for displaying to users (available
62
   * on non-card refunds only).
63
   */
64
  @SerializedName("description")
65
  String description;
66

67
  @SerializedName("destination_details")
68
  DestinationDetails destinationDetails;
69

70
  /**
71
   * After the refund fails, this balance transaction describes the adjustment made on your account
72
   * balance that reverses the initial balance transaction.
73
   */
74
  @SerializedName("failure_balance_transaction")
75
  @Getter(lombok.AccessLevel.NONE)
76
  @Setter(lombok.AccessLevel.NONE)
77
  ExpandableField<BalanceTransaction> failureBalanceTransaction;
78

79
  /**
80
   * Provides the reason for the refund failure. Possible values are: {@code lost_or_stolen_card},
81
   * {@code expired_or_canceled_card}, {@code charge_for_pending_refund_disputed}, {@code
82
   * insufficient_funds}, {@code declined}, {@code merchant_request}, or {@code unknown}.
83
   */
84
  @SerializedName("failure_reason")
85
  String failureReason;
86

87
  /** Unique identifier for the object. */
88
  @Getter(onMethod_ = {@Override})
89
  @SerializedName("id")
90
  String id;
91

92
  /**
93
   * For payment methods without native refund support (for example, Konbini, PromptPay), provide an
94
   * email address for the customer to receive refund instructions.
95
   */
96
  @SerializedName("instructions_email")
97
  String instructionsEmail;
98

99
  /**
100
   * Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach
101
   * to an object. This can be useful for storing additional information about the object in a
102
   * structured format.
103
   */
104
  @Getter(onMethod_ = {@Override})
105
  @SerializedName("metadata")
106
  Map<String, String> metadata;
107

108
  @SerializedName("next_action")
109
  NextAction nextAction;
110

111
  /**
112
   * String representing the object's type. Objects of the same type share the same value.
113
   *
114
   * <p>Equal to {@code refund}.
115
   */
116
  @SerializedName("object")
117
  String object;
118

119
  /** ID of the PaymentIntent that's refunded. */
120
  @SerializedName("payment_intent")
121
  @Getter(lombok.AccessLevel.NONE)
122
  @Setter(lombok.AccessLevel.NONE)
123
  ExpandableField<PaymentIntent> paymentIntent;
124

125
  /**
126
   * Reason for the refund, which is either user-provided ({@code duplicate}, {@code fraudulent}, or
127
   * {@code requested_by_customer}) or generated by Stripe internally ({@code
128
   * expired_uncaptured_charge}).
129
   *
130
   * <p>One of {@code duplicate}, {@code expired_uncaptured_charge}, {@code fraudulent}, or {@code
131
   * requested_by_customer}.
132
   */
133
  @SerializedName("reason")
134
  String reason;
135

136
  /** This is the transaction number that appears on email receipts sent for this refund. */
137
  @SerializedName("receipt_number")
138
  String receiptNumber;
139

140
  /**
141
   * The transfer reversal that's associated with the refund. Only present if the charge came from
142
   * another Stripe account.
143
   */
144
  @SerializedName("source_transfer_reversal")
145
  @Getter(lombok.AccessLevel.NONE)
146
  @Setter(lombok.AccessLevel.NONE)
147
  ExpandableField<TransferReversal> sourceTransferReversal;
148

149
  /**
150
   * Status of the refund. This can be {@code pending}, {@code requires_action}, {@code succeeded},
151
   * {@code failed}, or {@code canceled}. Learn more about <a
152
   * href="https://stripe.com/docs/refunds#failed-refunds">failed refunds</a>.
153
   */
154
  @SerializedName("status")
155
  String status;
156

157
  /**
158
   * This refers to the transfer reversal object if the accompanying transfer reverses. This is only
159
   * applicable if the charge was created using the destination parameter.
160
   */
161
  @SerializedName("transfer_reversal")
162
  @Getter(lombok.AccessLevel.NONE)
163
  @Setter(lombok.AccessLevel.NONE)
164
  ExpandableField<TransferReversal> transferReversal;
165

166
  /** Get ID of expandable {@code balanceTransaction} object. */
167
  public String getBalanceTransaction() {
168
    return (this.balanceTransaction != null) ? this.balanceTransaction.getId() : null;
1✔
169
  }
170

171
  public void setBalanceTransaction(String id) {
172
    this.balanceTransaction = ApiResource.setExpandableFieldId(id, this.balanceTransaction);
×
173
  }
×
174

175
  /** Get expanded {@code balanceTransaction}. */
176
  public BalanceTransaction getBalanceTransactionObject() {
177
    return (this.balanceTransaction != null) ? this.balanceTransaction.getExpanded() : null;
1✔
178
  }
179

180
  public void setBalanceTransactionObject(BalanceTransaction expandableObject) {
181
    this.balanceTransaction =
×
182
        new ExpandableField<BalanceTransaction>(expandableObject.getId(), expandableObject);
×
183
  }
×
184

185
  /** Get ID of expandable {@code charge} object. */
186
  public String getCharge() {
187
    return (this.charge != null) ? this.charge.getId() : null;
1✔
188
  }
189

190
  public void setCharge(String id) {
191
    this.charge = ApiResource.setExpandableFieldId(id, this.charge);
×
192
  }
×
193

194
  /** Get expanded {@code charge}. */
195
  public Charge getChargeObject() {
196
    return (this.charge != null) ? this.charge.getExpanded() : null;
1✔
197
  }
198

199
  public void setChargeObject(Charge expandableObject) {
200
    this.charge = new ExpandableField<Charge>(expandableObject.getId(), expandableObject);
×
201
  }
×
202

203
  /** Get ID of expandable {@code failureBalanceTransaction} object. */
204
  public String getFailureBalanceTransaction() {
205
    return (this.failureBalanceTransaction != null) ? this.failureBalanceTransaction.getId() : null;
1✔
206
  }
207

208
  public void setFailureBalanceTransaction(String id) {
209
    this.failureBalanceTransaction =
×
210
        ApiResource.setExpandableFieldId(id, this.failureBalanceTransaction);
×
211
  }
×
212

213
  /** Get expanded {@code failureBalanceTransaction}. */
214
  public BalanceTransaction getFailureBalanceTransactionObject() {
215
    return (this.failureBalanceTransaction != null)
1✔
216
        ? this.failureBalanceTransaction.getExpanded()
1✔
217
        : null;
×
218
  }
219

220
  public void setFailureBalanceTransactionObject(BalanceTransaction expandableObject) {
221
    this.failureBalanceTransaction =
×
222
        new ExpandableField<BalanceTransaction>(expandableObject.getId(), expandableObject);
×
223
  }
×
224

225
  /** Get ID of expandable {@code paymentIntent} object. */
226
  public String getPaymentIntent() {
227
    return (this.paymentIntent != null) ? this.paymentIntent.getId() : null;
×
228
  }
229

230
  public void setPaymentIntent(String id) {
231
    this.paymentIntent = ApiResource.setExpandableFieldId(id, this.paymentIntent);
×
232
  }
×
233

234
  /** Get expanded {@code paymentIntent}. */
235
  public PaymentIntent getPaymentIntentObject() {
236
    return (this.paymentIntent != null) ? this.paymentIntent.getExpanded() : null;
×
237
  }
238

239
  public void setPaymentIntentObject(PaymentIntent expandableObject) {
240
    this.paymentIntent =
×
241
        new ExpandableField<PaymentIntent>(expandableObject.getId(), expandableObject);
×
242
  }
×
243

244
  /** Get ID of expandable {@code sourceTransferReversal} object. */
245
  public String getSourceTransferReversal() {
246
    return (this.sourceTransferReversal != null) ? this.sourceTransferReversal.getId() : null;
1✔
247
  }
248

249
  public void setSourceTransferReversal(String id) {
250
    this.sourceTransferReversal = ApiResource.setExpandableFieldId(id, this.sourceTransferReversal);
×
251
  }
×
252

253
  /** Get expanded {@code sourceTransferReversal}. */
254
  public TransferReversal getSourceTransferReversalObject() {
255
    return (this.sourceTransferReversal != null) ? this.sourceTransferReversal.getExpanded() : null;
1✔
256
  }
257

258
  public void setSourceTransferReversalObject(TransferReversal expandableObject) {
259
    this.sourceTransferReversal =
×
260
        new ExpandableField<TransferReversal>(expandableObject.getId(), expandableObject);
×
261
  }
×
262

263
  /** Get ID of expandable {@code transferReversal} object. */
264
  public String getTransferReversal() {
265
    return (this.transferReversal != null) ? this.transferReversal.getId() : null;
1✔
266
  }
267

268
  public void setTransferReversal(String id) {
269
    this.transferReversal = ApiResource.setExpandableFieldId(id, this.transferReversal);
×
270
  }
×
271

272
  /** Get expanded {@code transferReversal}. */
273
  public TransferReversal getTransferReversalObject() {
274
    return (this.transferReversal != null) ? this.transferReversal.getExpanded() : null;
1✔
275
  }
276

277
  public void setTransferReversalObject(TransferReversal expandableObject) {
278
    this.transferReversal =
×
279
        new ExpandableField<TransferReversal>(expandableObject.getId(), expandableObject);
×
280
  }
×
281

282
  /**
283
   * Cancels a refund with a status of {@code requires_action}.
284
   *
285
   * <p>You can’t cancel refunds in other states. Only refunds for payment methods that require
286
   * customer action can enter the {@code requires_action} state.
287
   */
288
  public Refund cancel() throws StripeException {
289
    return cancel((Map<String, Object>) null, (RequestOptions) null);
×
290
  }
291

292
  /**
293
   * Cancels a refund with a status of {@code requires_action}.
294
   *
295
   * <p>You can’t cancel refunds in other states. Only refunds for payment methods that require
296
   * customer action can enter the {@code requires_action} state.
297
   */
298
  public Refund cancel(RequestOptions options) throws StripeException {
299
    return cancel((Map<String, Object>) null, options);
×
300
  }
301

302
  /**
303
   * Cancels a refund with a status of {@code requires_action}.
304
   *
305
   * <p>You can’t cancel refunds in other states. Only refunds for payment methods that require
306
   * customer action can enter the {@code requires_action} state.
307
   */
308
  public Refund cancel(Map<String, Object> params) throws StripeException {
309
    return cancel(params, (RequestOptions) null);
×
310
  }
311

312
  /**
313
   * Cancels a refund with a status of {@code requires_action}.
314
   *
315
   * <p>You can’t cancel refunds in other states. Only refunds for payment methods that require
316
   * customer action can enter the {@code requires_action} state.
317
   */
318
  public Refund cancel(Map<String, Object> params, RequestOptions options) throws StripeException {
319
    String path = String.format("/v1/refunds/%s/cancel", ApiResource.urlEncodeId(this.getId()));
×
320
    ApiRequest request =
×
321
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
UNCOV
322
    return getResponseGetter().request(request, Refund.class);
×
323
  }
324

325
  /**
326
   * Cancels a refund with a status of {@code requires_action}.
327
   *
328
   * <p>You can’t cancel refunds in other states. Only refunds for payment methods that require
329
   * customer action can enter the {@code requires_action} state.
330
   */
331
  public Refund cancel(RefundCancelParams params) throws StripeException {
332
    return cancel(params, (RequestOptions) null);
1✔
333
  }
334

335
  /**
336
   * Cancels a refund with a status of {@code requires_action}.
337
   *
338
   * <p>You can’t cancel refunds in other states. Only refunds for payment methods that require
339
   * customer action can enter the {@code requires_action} state.
340
   */
341
  public Refund cancel(RefundCancelParams params, RequestOptions options) throws StripeException {
342
    String path = String.format("/v1/refunds/%s/cancel", ApiResource.urlEncodeId(this.getId()));
1✔
343
    ApiResource.checkNullTypedParams(path, params);
1✔
344
    ApiRequest request =
1✔
345
        new ApiRequest(
346
            BaseAddress.API,
347
            ApiResource.RequestMethod.POST,
348
            path,
349
            ApiRequestParams.paramsToMap(params),
1✔
350
            options);
351
    return getResponseGetter().request(request, Refund.class);
1✔
352
  }
353

354
  /**
355
   * When you create a new refund, you must specify a Charge or a PaymentIntent object on which to
356
   * create it.
357
   *
358
   * <p>Creating a new refund will refund a charge that has previously been created but not yet
359
   * refunded. Funds will be refunded to the credit or debit card that was originally charged.
360
   *
361
   * <p>You can optionally refund only part of a charge. You can do so multiple times, until the
362
   * entire charge has been refunded.
363
   *
364
   * <p>Once entirely refunded, a charge can’t be refunded again. This method will raise an error
365
   * when called on an already-refunded charge, or when trying to refund more money than is left on
366
   * a charge.
367
   */
368
  public static Refund create(Map<String, Object> params) throws StripeException {
369
    return create(params, (RequestOptions) null);
1✔
370
  }
371

372
  /**
373
   * When you create a new refund, you must specify a Charge or a PaymentIntent object on which to
374
   * create it.
375
   *
376
   * <p>Creating a new refund will refund a charge that has previously been created but not yet
377
   * refunded. Funds will be refunded to the credit or debit card that was originally charged.
378
   *
379
   * <p>You can optionally refund only part of a charge. You can do so multiple times, until the
380
   * entire charge has been refunded.
381
   *
382
   * <p>Once entirely refunded, a charge can’t be refunded again. This method will raise an error
383
   * when called on an already-refunded charge, or when trying to refund more money than is left on
384
   * a charge.
385
   */
386
  public static Refund create(Map<String, Object> params, RequestOptions options)
387
      throws StripeException {
388
    String path = "/v1/refunds";
1✔
389
    ApiRequest request =
1✔
390
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
391
    return getGlobalResponseGetter().request(request, Refund.class);
1✔
392
  }
393

394
  /**
395
   * When you create a new refund, you must specify a Charge or a PaymentIntent object on which to
396
   * create it.
397
   *
398
   * <p>Creating a new refund will refund a charge that has previously been created but not yet
399
   * refunded. Funds will be refunded to the credit or debit card that was originally charged.
400
   *
401
   * <p>You can optionally refund only part of a charge. You can do so multiple times, until the
402
   * entire charge has been refunded.
403
   *
404
   * <p>Once entirely refunded, a charge can’t be refunded again. This method will raise an error
405
   * when called on an already-refunded charge, or when trying to refund more money than is left on
406
   * a charge.
407
   */
408
  public static Refund create(RefundCreateParams params) throws StripeException {
409
    return create(params, (RequestOptions) null);
1✔
410
  }
411

412
  /**
413
   * When you create a new refund, you must specify a Charge or a PaymentIntent object on which to
414
   * create it.
415
   *
416
   * <p>Creating a new refund will refund a charge that has previously been created but not yet
417
   * refunded. Funds will be refunded to the credit or debit card that was originally charged.
418
   *
419
   * <p>You can optionally refund only part of a charge. You can do so multiple times, until the
420
   * entire charge has been refunded.
421
   *
422
   * <p>Once entirely refunded, a charge can’t be refunded again. This method will raise an error
423
   * when called on an already-refunded charge, or when trying to refund more money than is left on
424
   * a charge.
425
   */
426
  public static Refund create(RefundCreateParams params, RequestOptions options)
427
      throws StripeException {
428
    String path = "/v1/refunds";
1✔
429
    ApiResource.checkNullTypedParams(path, params);
1✔
430
    ApiRequest request =
1✔
431
        new ApiRequest(
432
            BaseAddress.API,
433
            ApiResource.RequestMethod.POST,
434
            path,
435
            ApiRequestParams.paramsToMap(params),
1✔
436
            options);
437
    return getGlobalResponseGetter().request(request, Refund.class);
1✔
438
  }
439

440
  /**
441
   * Returns a list of all refunds you created. We return the refunds in sorted order, with the most
442
   * recent refunds appearing first. The 10 most recent refunds are always available by default on
443
   * the Charge object.
444
   */
445
  public static RefundCollection list(Map<String, Object> params) throws StripeException {
446
    return list(params, (RequestOptions) null);
1✔
447
  }
448

449
  /**
450
   * Returns a list of all refunds you created. We return the refunds in sorted order, with the most
451
   * recent refunds appearing first. The 10 most recent refunds are always available by default on
452
   * the Charge object.
453
   */
454
  public static RefundCollection list(Map<String, Object> params, RequestOptions options)
455
      throws StripeException {
456
    String path = "/v1/refunds";
1✔
457
    ApiRequest request =
1✔
458
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.GET, path, params, options);
459
    return getGlobalResponseGetter().request(request, RefundCollection.class);
1✔
460
  }
461

462
  /**
463
   * Returns a list of all refunds you created. We return the refunds in sorted order, with the most
464
   * recent refunds appearing first. The 10 most recent refunds are always available by default on
465
   * the Charge object.
466
   */
467
  public static RefundCollection list(RefundListParams params) throws StripeException {
468
    return list(params, (RequestOptions) null);
1✔
469
  }
470

471
  /**
472
   * Returns a list of all refunds you created. We return the refunds in sorted order, with the most
473
   * recent refunds appearing first. The 10 most recent refunds are always available by default on
474
   * the Charge object.
475
   */
476
  public static RefundCollection list(RefundListParams params, RequestOptions options)
477
      throws StripeException {
478
    String path = "/v1/refunds";
1✔
479
    ApiResource.checkNullTypedParams(path, params);
1✔
480
    ApiRequest request =
1✔
481
        new ApiRequest(
482
            BaseAddress.API,
483
            ApiResource.RequestMethod.GET,
484
            path,
485
            ApiRequestParams.paramsToMap(params),
1✔
486
            options);
487
    return getGlobalResponseGetter().request(request, RefundCollection.class);
1✔
488
  }
489

490
  /** Retrieves the details of an existing refund. */
491
  public static Refund retrieve(String refund) throws StripeException {
492
    return retrieve(refund, (Map<String, Object>) null, (RequestOptions) null);
1✔
493
  }
494

495
  /** Retrieves the details of an existing refund. */
496
  public static Refund retrieve(String refund, RequestOptions options) throws StripeException {
497
    return retrieve(refund, (Map<String, Object>) null, options);
×
498
  }
499

500
  /** Retrieves the details of an existing refund. */
501
  public static Refund retrieve(String refund, Map<String, Object> params, RequestOptions options)
502
      throws StripeException {
503
    String path = String.format("/v1/refunds/%s", ApiResource.urlEncodeId(refund));
1✔
504
    ApiRequest request =
1✔
505
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.GET, path, params, options);
506
    return getGlobalResponseGetter().request(request, Refund.class);
1✔
507
  }
508

509
  /** Retrieves the details of an existing refund. */
510
  public static Refund retrieve(String refund, RefundRetrieveParams params, RequestOptions options)
511
      throws StripeException {
512
    String path = String.format("/v1/refunds/%s", ApiResource.urlEncodeId(refund));
×
513
    ApiResource.checkNullTypedParams(path, params);
×
514
    ApiRequest request =
×
515
        new ApiRequest(
516
            BaseAddress.API,
517
            ApiResource.RequestMethod.GET,
518
            path,
519
            ApiRequestParams.paramsToMap(params),
×
520
            options);
UNCOV
521
    return getGlobalResponseGetter().request(request, Refund.class);
×
522
  }
523

524
  /**
525
   * Updates the refund that you specify by setting the values of the passed parameters. Any
526
   * parameters that you don’t provide remain unchanged.
527
   *
528
   * <p>This request only accepts {@code metadata} as an argument.
529
   */
530
  @Override
531
  public Refund update(Map<String, Object> params) throws StripeException {
532
    return update(params, (RequestOptions) null);
1✔
533
  }
534

535
  /**
536
   * Updates the refund that you specify by setting the values of the passed parameters. Any
537
   * parameters that you don’t provide remain unchanged.
538
   *
539
   * <p>This request only accepts {@code metadata} as an argument.
540
   */
541
  @Override
542
  public Refund update(Map<String, Object> params, RequestOptions options) throws StripeException {
543
    String path = String.format("/v1/refunds/%s", ApiResource.urlEncodeId(this.getId()));
1✔
544
    ApiRequest request =
1✔
545
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
546
    return getResponseGetter().request(request, Refund.class);
1✔
547
  }
548

549
  /**
550
   * Updates the refund that you specify by setting the values of the passed parameters. Any
551
   * parameters that you don’t provide remain unchanged.
552
   *
553
   * <p>This request only accepts {@code metadata} as an argument.
554
   */
555
  public Refund update(RefundUpdateParams params) throws StripeException {
556
    return update(params, (RequestOptions) null);
1✔
557
  }
558

559
  /**
560
   * Updates the refund that you specify by setting the values of the passed parameters. Any
561
   * parameters that you don’t provide remain unchanged.
562
   *
563
   * <p>This request only accepts {@code metadata} as an argument.
564
   */
565
  public Refund update(RefundUpdateParams params, RequestOptions options) throws StripeException {
566
    String path = String.format("/v1/refunds/%s", ApiResource.urlEncodeId(this.getId()));
1✔
567
    ApiResource.checkNullTypedParams(path, params);
1✔
568
    ApiRequest request =
1✔
569
        new ApiRequest(
570
            BaseAddress.API,
571
            ApiResource.RequestMethod.POST,
572
            path,
573
            ApiRequestParams.paramsToMap(params),
1✔
574
            options);
575
    return getResponseGetter().request(request, Refund.class);
1✔
576
  }
577

578
  @Getter
579
  @Setter
580
  @EqualsAndHashCode(callSuper = false)
581
  public static class DestinationDetails extends StripeObject {
1✔
582
    @SerializedName("affirm")
583
    Affirm affirm;
584

585
    @SerializedName("afterpay_clearpay")
586
    AfterpayClearpay afterpayClearpay;
587

588
    @SerializedName("alipay")
589
    Alipay alipay;
590

591
    @SerializedName("amazon_pay")
592
    AmazonPay amazonPay;
593

594
    @SerializedName("au_bank_transfer")
595
    AuBankTransfer auBankTransfer;
596

597
    @SerializedName("blik")
598
    Blik blik;
599

600
    @SerializedName("br_bank_transfer")
601
    BrBankTransfer brBankTransfer;
602

603
    @SerializedName("card")
604
    Card card;
605

606
    @SerializedName("cashapp")
607
    Cashapp cashapp;
608

609
    @SerializedName("customer_cash_balance")
610
    CustomerCashBalance customerCashBalance;
611

612
    @SerializedName("eps")
613
    Eps eps;
614

615
    @SerializedName("eu_bank_transfer")
616
    EuBankTransfer euBankTransfer;
617

618
    @SerializedName("gb_bank_transfer")
619
    GbBankTransfer gbBankTransfer;
620

621
    @SerializedName("giropay")
622
    Giropay giropay;
623

624
    @SerializedName("grabpay")
625
    Grabpay grabpay;
626

627
    @SerializedName("jp_bank_transfer")
628
    JpBankTransfer jpBankTransfer;
629

630
    @SerializedName("klarna")
631
    Klarna klarna;
632

633
    @SerializedName("multibanco")
634
    Multibanco multibanco;
635

636
    @SerializedName("mx_bank_transfer")
637
    MxBankTransfer mxBankTransfer;
638

639
    @SerializedName("p24")
640
    P24 p24;
641

642
    @SerializedName("paynow")
643
    Paynow paynow;
644

645
    @SerializedName("paypal")
646
    Paypal paypal;
647

648
    @SerializedName("pix")
649
    Pix pix;
650

651
    @SerializedName("revolut")
652
    Revolut revolut;
653

654
    @SerializedName("sofort")
655
    Sofort sofort;
656

657
    @SerializedName("swish")
658
    Swish swish;
659

660
    @SerializedName("th_bank_transfer")
661
    ThBankTransfer thBankTransfer;
662

663
    /**
664
     * The type of transaction-specific details of the payment method used in the refund (e.g.,
665
     * {@code card}). An additional hash is included on {@code destination_details} with a name
666
     * matching this value. It contains information specific to the refund transaction.
667
     */
668
    @SerializedName("type")
669
    String type;
670

671
    @SerializedName("us_bank_transfer")
672
    UsBankTransfer usBankTransfer;
673

674
    @SerializedName("wechat_pay")
675
    WechatPay wechatPay;
676

677
    @SerializedName("zip")
678
    Zip zip;
679

680
    @Getter
681
    @Setter
682
    @EqualsAndHashCode(callSuper = false)
683
    public static class Affirm extends StripeObject {}
×
684

685
    @Getter
686
    @Setter
687
    @EqualsAndHashCode(callSuper = false)
688
    public static class AfterpayClearpay extends StripeObject {}
×
689

690
    @Getter
691
    @Setter
692
    @EqualsAndHashCode(callSuper = false)
693
    public static class Alipay extends StripeObject {}
×
694

695
    @Getter
696
    @Setter
697
    @EqualsAndHashCode(callSuper = false)
698
    public static class AmazonPay extends StripeObject {}
×
699

700
    @Getter
701
    @Setter
702
    @EqualsAndHashCode(callSuper = false)
703
    public static class AuBankTransfer extends StripeObject {}
×
704

705
    @Getter
706
    @Setter
707
    @EqualsAndHashCode(callSuper = false)
708
    public static class Blik extends StripeObject {
×
709
      /** The reference assigned to the refund. */
710
      @SerializedName("reference")
711
      String reference;
712

713
      /**
714
       * Status of the reference on the refund. This can be {@code pending}, {@code available} or
715
       * {@code unavailable}.
716
       */
717
      @SerializedName("reference_status")
718
      String referenceStatus;
719
    }
720

721
    @Getter
722
    @Setter
723
    @EqualsAndHashCode(callSuper = false)
724
    public static class BrBankTransfer extends StripeObject {
×
725
      /** The reference assigned to the refund. */
726
      @SerializedName("reference")
727
      String reference;
728

729
      /**
730
       * Status of the reference on the refund. This can be {@code pending}, {@code available} or
731
       * {@code unavailable}.
732
       */
733
      @SerializedName("reference_status")
734
      String referenceStatus;
735
    }
736

737
    @Getter
738
    @Setter
739
    @EqualsAndHashCode(callSuper = false)
740
    public static class Card extends StripeObject {
1✔
741
      /** Value of the reference number assigned to the refund. */
742
      @SerializedName("reference")
743
      String reference;
744

745
      /**
746
       * Status of the reference number on the refund. This can be {@code pending}, {@code
747
       * available} or {@code unavailable}.
748
       */
749
      @SerializedName("reference_status")
750
      String referenceStatus;
751

752
      /** Type of the reference number assigned to the refund. */
753
      @SerializedName("reference_type")
754
      String referenceType;
755

756
      /**
757
       * The type of refund. This can be {@code refund}, {@code reversal}, or {@code pending}.
758
       *
759
       * <p>One of {@code pending}, {@code refund}, or {@code reversal}.
760
       */
761
      @SerializedName("type")
762
      String type;
763
    }
764

765
    @Getter
766
    @Setter
767
    @EqualsAndHashCode(callSuper = false)
768
    public static class Cashapp extends StripeObject {}
×
769

770
    @Getter
771
    @Setter
772
    @EqualsAndHashCode(callSuper = false)
773
    public static class CustomerCashBalance extends StripeObject {}
×
774

775
    @Getter
776
    @Setter
777
    @EqualsAndHashCode(callSuper = false)
778
    public static class Eps extends StripeObject {}
×
779

780
    @Getter
781
    @Setter
782
    @EqualsAndHashCode(callSuper = false)
783
    public static class EuBankTransfer extends StripeObject {
×
784
      /** The reference assigned to the refund. */
785
      @SerializedName("reference")
786
      String reference;
787

788
      /**
789
       * Status of the reference on the refund. This can be {@code pending}, {@code available} or
790
       * {@code unavailable}.
791
       */
792
      @SerializedName("reference_status")
793
      String referenceStatus;
794
    }
795

796
    @Getter
797
    @Setter
798
    @EqualsAndHashCode(callSuper = false)
799
    public static class GbBankTransfer extends StripeObject {
×
800
      /** The reference assigned to the refund. */
801
      @SerializedName("reference")
802
      String reference;
803

804
      /**
805
       * Status of the reference on the refund. This can be {@code pending}, {@code available} or
806
       * {@code unavailable}.
807
       */
808
      @SerializedName("reference_status")
809
      String referenceStatus;
810
    }
811

812
    @Getter
813
    @Setter
814
    @EqualsAndHashCode(callSuper = false)
815
    public static class Giropay extends StripeObject {}
×
816

817
    @Getter
818
    @Setter
819
    @EqualsAndHashCode(callSuper = false)
820
    public static class Grabpay extends StripeObject {}
×
821

822
    @Getter
823
    @Setter
824
    @EqualsAndHashCode(callSuper = false)
825
    public static class JpBankTransfer extends StripeObject {
×
826
      /** The reference assigned to the refund. */
827
      @SerializedName("reference")
828
      String reference;
829

830
      /**
831
       * Status of the reference on the refund. This can be {@code pending}, {@code available} or
832
       * {@code unavailable}.
833
       */
834
      @SerializedName("reference_status")
835
      String referenceStatus;
836
    }
837

838
    @Getter
839
    @Setter
840
    @EqualsAndHashCode(callSuper = false)
841
    public static class Klarna extends StripeObject {}
×
842

843
    @Getter
844
    @Setter
845
    @EqualsAndHashCode(callSuper = false)
846
    public static class Multibanco extends StripeObject {
×
847
      /** The reference assigned to the refund. */
848
      @SerializedName("reference")
849
      String reference;
850

851
      /**
852
       * Status of the reference on the refund. This can be {@code pending}, {@code available} or
853
       * {@code unavailable}.
854
       */
855
      @SerializedName("reference_status")
856
      String referenceStatus;
857
    }
858

859
    @Getter
860
    @Setter
861
    @EqualsAndHashCode(callSuper = false)
862
    public static class MxBankTransfer extends StripeObject {
×
863
      /** The reference assigned to the refund. */
864
      @SerializedName("reference")
865
      String reference;
866

867
      /**
868
       * Status of the reference on the refund. This can be {@code pending}, {@code available} or
869
       * {@code unavailable}.
870
       */
871
      @SerializedName("reference_status")
872
      String referenceStatus;
873
    }
874

875
    @Getter
876
    @Setter
877
    @EqualsAndHashCode(callSuper = false)
878
    public static class P24 extends StripeObject {
×
879
      /** The reference assigned to the refund. */
880
      @SerializedName("reference")
881
      String reference;
882

883
      /**
884
       * Status of the reference on the refund. This can be {@code pending}, {@code available} or
885
       * {@code unavailable}.
886
       */
887
      @SerializedName("reference_status")
888
      String referenceStatus;
889
    }
890

891
    @Getter
892
    @Setter
893
    @EqualsAndHashCode(callSuper = false)
894
    public static class Paynow extends StripeObject {}
×
895

896
    @Getter
897
    @Setter
898
    @EqualsAndHashCode(callSuper = false)
899
    public static class Paypal extends StripeObject {}
×
900

901
    @Getter
902
    @Setter
903
    @EqualsAndHashCode(callSuper = false)
904
    public static class Pix extends StripeObject {}
×
905

906
    @Getter
907
    @Setter
908
    @EqualsAndHashCode(callSuper = false)
909
    public static class Revolut extends StripeObject {}
×
910

911
    @Getter
912
    @Setter
913
    @EqualsAndHashCode(callSuper = false)
914
    public static class Sofort extends StripeObject {}
×
915

916
    @Getter
917
    @Setter
918
    @EqualsAndHashCode(callSuper = false)
919
    public static class Swish extends StripeObject {
×
920
      /** The reference assigned to the refund. */
921
      @SerializedName("reference")
922
      String reference;
923

924
      /**
925
       * Status of the reference on the refund. This can be {@code pending}, {@code available} or
926
       * {@code unavailable}.
927
       */
928
      @SerializedName("reference_status")
929
      String referenceStatus;
930
    }
931

932
    @Getter
933
    @Setter
934
    @EqualsAndHashCode(callSuper = false)
935
    public static class ThBankTransfer extends StripeObject {
×
936
      /** The reference assigned to the refund. */
937
      @SerializedName("reference")
938
      String reference;
939

940
      /**
941
       * Status of the reference on the refund. This can be {@code pending}, {@code available} or
942
       * {@code unavailable}.
943
       */
944
      @SerializedName("reference_status")
945
      String referenceStatus;
946
    }
947

948
    @Getter
949
    @Setter
950
    @EqualsAndHashCode(callSuper = false)
951
    public static class UsBankTransfer extends StripeObject {
×
952
      /** The reference assigned to the refund. */
953
      @SerializedName("reference")
954
      String reference;
955

956
      /**
957
       * Status of the reference on the refund. This can be {@code pending}, {@code available} or
958
       * {@code unavailable}.
959
       */
960
      @SerializedName("reference_status")
961
      String referenceStatus;
962
    }
963

964
    @Getter
965
    @Setter
966
    @EqualsAndHashCode(callSuper = false)
967
    public static class WechatPay extends StripeObject {}
×
968

969
    @Getter
970
    @Setter
971
    @EqualsAndHashCode(callSuper = false)
972
    public static class Zip extends StripeObject {}
×
973
  }
974

975
  @Getter
976
  @Setter
977
  @EqualsAndHashCode(callSuper = false)
978
  public static class NextAction extends StripeObject {
×
979
    /** Contains the refund details. */
980
    @SerializedName("display_details")
981
    DisplayDetails displayDetails;
982

983
    /** Type of the next action to perform. */
984
    @SerializedName("type")
985
    String type;
986

987
    @Getter
988
    @Setter
989
    @EqualsAndHashCode(callSuper = false)
990
    public static class DisplayDetails extends StripeObject {
×
991
      @SerializedName("email_sent")
992
      EmailSent emailSent;
993

994
      /** The expiry timestamp. */
995
      @SerializedName("expires_at")
996
      Long expiresAt;
997

998
      @Getter
999
      @Setter
1000
      @EqualsAndHashCode(callSuper = false)
1001
      public static class EmailSent extends StripeObject {
×
1002
        /** The timestamp when the email was sent. */
1003
        @SerializedName("email_sent_at")
1004
        Long emailSentAt;
1005

1006
        /** The recipient's email address. */
1007
        @SerializedName("email_sent_to")
1008
        String emailSentTo;
1009
      }
1010
    }
1011
  }
1012

1013
  public TestHelpers getTestHelpers() {
1014
    return new TestHelpers(this);
1✔
1015
  }
1016

1017
  public static class TestHelpers {
1018
    private final Refund resource;
1019

1020
    private TestHelpers(Refund resource) {
1✔
1021
      this.resource = resource;
1✔
1022
    }
1✔
1023

1024
    /** Expire a refund with a status of {@code requires_action}. */
1025
    public Refund expire() throws StripeException {
1026
      return expire((Map<String, Object>) null, (RequestOptions) null);
×
1027
    }
1028

1029
    /** Expire a refund with a status of {@code requires_action}. */
1030
    public Refund expire(RequestOptions options) throws StripeException {
1031
      return expire((Map<String, Object>) null, options);
×
1032
    }
1033

1034
    /** Expire a refund with a status of {@code requires_action}. */
1035
    public Refund expire(Map<String, Object> params) throws StripeException {
1036
      return expire(params, (RequestOptions) null);
×
1037
    }
1038

1039
    /** Expire a refund with a status of {@code requires_action}. */
1040
    public Refund expire(Map<String, Object> params, RequestOptions options)
1041
        throws StripeException {
1042
      String path =
×
1043
          String.format(
×
1044
              "/v1/test_helpers/refunds/%s/expire", ApiResource.urlEncodeId(this.resource.getId()));
×
1045
      ApiRequest request =
×
1046
          new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
UNCOV
1047
      return resource.getResponseGetter().request(request, Refund.class);
×
1048
    }
1049

1050
    /** Expire a refund with a status of {@code requires_action}. */
1051
    public Refund expire(RefundExpireParams params) throws StripeException {
1052
      return expire(params, (RequestOptions) null);
1✔
1053
    }
1054

1055
    /** Expire a refund with a status of {@code requires_action}. */
1056
    public Refund expire(RefundExpireParams params, RequestOptions options) throws StripeException {
1057
      String path =
1✔
1058
          String.format(
1✔
1059
              "/v1/test_helpers/refunds/%s/expire", ApiResource.urlEncodeId(this.resource.getId()));
1✔
1060
      ApiResource.checkNullTypedParams(path, params);
1✔
1061
      ApiRequest request =
1✔
1062
          new ApiRequest(
1063
              BaseAddress.API,
1064
              ApiResource.RequestMethod.POST,
1065
              path,
1066
              ApiRequestParams.paramsToMap(params),
1✔
1067
              options);
1068
      return resource.getResponseGetter().request(request, Refund.class);
1✔
1069
    }
1070
  }
1071

1072
  @Override
1073
  public void setResponseGetter(StripeResponseGetter responseGetter) {
1074
    super.setResponseGetter(responseGetter);
1✔
1075
    trySetResponseGetter(balanceTransaction, responseGetter);
1✔
1076
    trySetResponseGetter(charge, responseGetter);
1✔
1077
    trySetResponseGetter(destinationDetails, responseGetter);
1✔
1078
    trySetResponseGetter(failureBalanceTransaction, responseGetter);
1✔
1079
    trySetResponseGetter(nextAction, responseGetter);
1✔
1080
    trySetResponseGetter(paymentIntent, responseGetter);
1✔
1081
    trySetResponseGetter(sourceTransferReversal, responseGetter);
1✔
1082
    trySetResponseGetter(transferReversal, responseGetter);
1✔
1083
  }
1✔
1084
}
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