github.com/stripe/stripe-go/v76@v76.25.0/dispute.go (about)

     1  //
     2  //
     3  // File generated from our OpenAPI spec
     4  //
     5  //
     6  
     7  package stripe
     8  
     9  import "encoding/json"
    10  
    11  // Payment method type.
    12  type DisputePaymentMethodDetailsType string
    13  
    14  // List of values that DisputePaymentMethodDetailsType can take
    15  const (
    16  	DisputePaymentMethodDetailsTypeCard DisputePaymentMethodDetailsType = "card"
    17  )
    18  
    19  // Reason given by cardholder for dispute. Possible values are `bank_cannot_process`, `check_returned`, `credit_not_processed`, `customer_initiated`, `debit_not_authorized`, `duplicate`, `fraudulent`, `general`, `incorrect_account_details`, `insufficient_funds`, `product_not_received`, `product_unacceptable`, `subscription_canceled`, or `unrecognized`. Learn more about [dispute reasons](https://stripe.com/docs/disputes/categories).
    20  type DisputeReason string
    21  
    22  // List of values that DisputeReason can take
    23  const (
    24  	DisputeReasonBankCannotProcess       DisputeReason = "bank_cannot_process"
    25  	DisputeReasonCheckReturned           DisputeReason = "check_returned"
    26  	DisputeReasonCreditNotProcessed      DisputeReason = "credit_not_processed"
    27  	DisputeReasonCustomerInitiated       DisputeReason = "customer_initiated"
    28  	DisputeReasonDebitNotAuthorized      DisputeReason = "debit_not_authorized"
    29  	DisputeReasonDuplicate               DisputeReason = "duplicate"
    30  	DisputeReasonFraudulent              DisputeReason = "fraudulent"
    31  	DisputeReasonGeneral                 DisputeReason = "general"
    32  	DisputeReasonIncorrectAccountDetails DisputeReason = "incorrect_account_details"
    33  	DisputeReasonInsufficientFunds       DisputeReason = "insufficient_funds"
    34  	DisputeReasonProductNotReceived      DisputeReason = "product_not_received"
    35  	DisputeReasonProductUnacceptable     DisputeReason = "product_unacceptable"
    36  	DisputeReasonSubscriptionCanceled    DisputeReason = "subscription_canceled"
    37  	DisputeReasonUnrecognized            DisputeReason = "unrecognized"
    38  )
    39  
    40  // Current status of dispute. Possible values are `warning_needs_response`, `warning_under_review`, `warning_closed`, `needs_response`, `under_review`, `won`, or `lost`.
    41  type DisputeStatus string
    42  
    43  // List of values that DisputeStatus can take
    44  const (
    45  	DisputeStatusLost                 DisputeStatus = "lost"
    46  	DisputeStatusNeedsResponse        DisputeStatus = "needs_response"
    47  	DisputeStatusUnderReview          DisputeStatus = "under_review"
    48  	DisputeStatusWarningClosed        DisputeStatus = "warning_closed"
    49  	DisputeStatusWarningNeedsResponse DisputeStatus = "warning_needs_response"
    50  	DisputeStatusWarningUnderReview   DisputeStatus = "warning_under_review"
    51  	DisputeStatusWon                  DisputeStatus = "won"
    52  )
    53  
    54  // Returns a list of your disputes.
    55  type DisputeListParams struct {
    56  	ListParams `form:"*"`
    57  	// Only return disputes associated to the charge specified by this charge ID.
    58  	Charge       *string           `form:"charge"`
    59  	Created      *int64            `form:"created"`
    60  	CreatedRange *RangeQueryParams `form:"created"`
    61  	// Specifies which fields in the response should be expanded.
    62  	Expand []*string `form:"expand"`
    63  	// Only return disputes associated to the PaymentIntent specified by this PaymentIntent ID.
    64  	PaymentIntent *string `form:"payment_intent"`
    65  }
    66  
    67  // AddExpand appends a new field to expand.
    68  func (p *DisputeListParams) AddExpand(f string) {
    69  	p.Expand = append(p.Expand, &f)
    70  }
    71  
    72  // Retrieves the dispute with the given ID.
    73  type DisputeParams struct {
    74  	Params `form:"*"`
    75  	// Evidence to upload, to respond to a dispute. Updating any field in the hash will submit all fields in the hash for review. The combined character count of all fields is limited to 150,000.
    76  	Evidence *DisputeEvidenceParams `form:"evidence"`
    77  	// Specifies which fields in the response should be expanded.
    78  	Expand []*string `form:"expand"`
    79  	// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
    80  	Metadata map[string]string `form:"metadata"`
    81  	// Whether to immediately submit evidence to the bank. If `false`, evidence is staged on the dispute. Staged evidence is visible in the API and Dashboard, and can be submitted to the bank by making another request with this attribute set to `true` (the default).
    82  	Submit *bool `form:"submit"`
    83  }
    84  
    85  // AddExpand appends a new field to expand.
    86  func (p *DisputeParams) AddExpand(f string) {
    87  	p.Expand = append(p.Expand, &f)
    88  }
    89  
    90  // AddMetadata adds a new key-value pair to the Metadata.
    91  func (p *DisputeParams) AddMetadata(key string, value string) {
    92  	if p.Metadata == nil {
    93  		p.Metadata = make(map[string]string)
    94  	}
    95  
    96  	p.Metadata[key] = value
    97  }
    98  
    99  // Evidence to upload, to respond to a dispute. Updating any field in the hash will submit all fields in the hash for review. The combined character count of all fields is limited to 150,000.
   100  type DisputeEvidenceParams struct {
   101  	// Any server or activity logs showing proof that the customer accessed or downloaded the purchased digital product. This information should include IP addresses, corresponding timestamps, and any detailed recorded activity. Has a maximum character count of 20,000.
   102  	AccessActivityLog *string `form:"access_activity_log"`
   103  	// The billing address provided by the customer.
   104  	BillingAddress *string `form:"billing_address"`
   105  	// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Your subscription cancellation policy, as shown to the customer.
   106  	CancellationPolicy *string `form:"cancellation_policy"`
   107  	// An explanation of how and when the customer was shown your refund policy prior to purchase. Has a maximum character count of 20,000.
   108  	CancellationPolicyDisclosure *string `form:"cancellation_policy_disclosure"`
   109  	// A justification for why the customer's subscription was not canceled. Has a maximum character count of 20,000.
   110  	CancellationRebuttal *string `form:"cancellation_rebuttal"`
   111  	// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Any communication with the customer that you feel is relevant to your case. Examples include emails proving that the customer received the product or service, or demonstrating their use of or satisfaction with the product or service.
   112  	CustomerCommunication *string `form:"customer_communication"`
   113  	// The email address of the customer.
   114  	CustomerEmailAddress *string `form:"customer_email_address"`
   115  	// The name of the customer.
   116  	CustomerName *string `form:"customer_name"`
   117  	// The IP address that the customer used when making the purchase.
   118  	CustomerPurchaseIP *string `form:"customer_purchase_ip"`
   119  	// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) A relevant document or contract showing the customer's signature.
   120  	CustomerSignature *string `form:"customer_signature"`
   121  	// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Documentation for the prior charge that can uniquely identify the charge, such as a receipt, shipping label, work order, etc. This document should be paired with a similar document from the disputed payment that proves the two payments are separate.
   122  	DuplicateChargeDocumentation *string `form:"duplicate_charge_documentation"`
   123  	// An explanation of the difference between the disputed charge versus the prior charge that appears to be a duplicate. Has a maximum character count of 20,000.
   124  	DuplicateChargeExplanation *string `form:"duplicate_charge_explanation"`
   125  	// The Stripe ID for the prior charge which appears to be a duplicate of the disputed charge.
   126  	DuplicateChargeID *string `form:"duplicate_charge_id"`
   127  	// A description of the product or service that was sold. Has a maximum character count of 20,000.
   128  	ProductDescription *string `form:"product_description"`
   129  	// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Any receipt or message sent to the customer notifying them of the charge.
   130  	Receipt *string `form:"receipt"`
   131  	// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Your refund policy, as shown to the customer.
   132  	RefundPolicy *string `form:"refund_policy"`
   133  	// Documentation demonstrating that the customer was shown your refund policy prior to purchase. Has a maximum character count of 20,000.
   134  	RefundPolicyDisclosure *string `form:"refund_policy_disclosure"`
   135  	// A justification for why the customer is not entitled to a refund. Has a maximum character count of 20,000.
   136  	RefundRefusalExplanation *string `form:"refund_refusal_explanation"`
   137  	// The date on which the customer received or began receiving the purchased service, in a clear human-readable format.
   138  	ServiceDate *string `form:"service_date"`
   139  	// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Documentation showing proof that a service was provided to the customer. This could include a copy of a signed contract, work order, or other form of written agreement.
   140  	ServiceDocumentation *string `form:"service_documentation"`
   141  	// The address to which a physical product was shipped. You should try to include as complete address information as possible.
   142  	ShippingAddress *string `form:"shipping_address"`
   143  	// The delivery service that shipped a physical product, such as Fedex, UPS, USPS, etc. If multiple carriers were used for this purchase, please separate them with commas.
   144  	ShippingCarrier *string `form:"shipping_carrier"`
   145  	// The date on which a physical product began its route to the shipping address, in a clear human-readable format.
   146  	ShippingDate *string `form:"shipping_date"`
   147  	// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Documentation showing proof that a product was shipped to the customer at the same address the customer provided to you. This could include a copy of the shipment receipt, shipping label, etc. It should show the customer's full shipping address, if possible.
   148  	ShippingDocumentation *string `form:"shipping_documentation"`
   149  	// The tracking number for a physical product, obtained from the delivery service. If multiple tracking numbers were generated for this purchase, please separate them with commas.
   150  	ShippingTrackingNumber *string `form:"shipping_tracking_number"`
   151  	// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Any additional evidence or statements.
   152  	UncategorizedFile *string `form:"uncategorized_file"`
   153  	// Any additional evidence or statements. Has a maximum character count of 20,000.
   154  	UncategorizedText *string `form:"uncategorized_text"`
   155  }
   156  type DisputeEvidence struct {
   157  	// Any server or activity logs showing proof that the customer accessed or downloaded the purchased digital product. This information should include IP addresses, corresponding timestamps, and any detailed recorded activity.
   158  	AccessActivityLog string `json:"access_activity_log"`
   159  	// The billing address provided by the customer.
   160  	BillingAddress string `json:"billing_address"`
   161  	// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Your subscription cancellation policy, as shown to the customer.
   162  	CancellationPolicy *File `json:"cancellation_policy"`
   163  	// An explanation of how and when the customer was shown your refund policy prior to purchase.
   164  	CancellationPolicyDisclosure string `json:"cancellation_policy_disclosure"`
   165  	// A justification for why the customer's subscription was not canceled.
   166  	CancellationRebuttal string `json:"cancellation_rebuttal"`
   167  	// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Any communication with the customer that you feel is relevant to your case. Examples include emails proving that the customer received the product or service, or demonstrating their use of or satisfaction with the product or service.
   168  	CustomerCommunication *File `json:"customer_communication"`
   169  	// The email address of the customer.
   170  	CustomerEmailAddress string `json:"customer_email_address"`
   171  	// The name of the customer.
   172  	CustomerName string `json:"customer_name"`
   173  	// The IP address that the customer used when making the purchase.
   174  	CustomerPurchaseIP string `json:"customer_purchase_ip"`
   175  	// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) A relevant document or contract showing the customer's signature.
   176  	CustomerSignature *File `json:"customer_signature"`
   177  	// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Documentation for the prior charge that can uniquely identify the charge, such as a receipt, shipping label, work order, etc. This document should be paired with a similar document from the disputed payment that proves the two payments are separate.
   178  	DuplicateChargeDocumentation *File `json:"duplicate_charge_documentation"`
   179  	// An explanation of the difference between the disputed charge versus the prior charge that appears to be a duplicate.
   180  	DuplicateChargeExplanation string `json:"duplicate_charge_explanation"`
   181  	// The Stripe ID for the prior charge which appears to be a duplicate of the disputed charge.
   182  	DuplicateChargeID string `json:"duplicate_charge_id"`
   183  	// A description of the product or service that was sold.
   184  	ProductDescription string `json:"product_description"`
   185  	// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Any receipt or message sent to the customer notifying them of the charge.
   186  	Receipt *File `json:"receipt"`
   187  	// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Your refund policy, as shown to the customer.
   188  	RefundPolicy *File `json:"refund_policy"`
   189  	// Documentation demonstrating that the customer was shown your refund policy prior to purchase.
   190  	RefundPolicyDisclosure string `json:"refund_policy_disclosure"`
   191  	// A justification for why the customer is not entitled to a refund.
   192  	RefundRefusalExplanation string `json:"refund_refusal_explanation"`
   193  	// The date on which the customer received or began receiving the purchased service, in a clear human-readable format.
   194  	ServiceDate string `json:"service_date"`
   195  	// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Documentation showing proof that a service was provided to the customer. This could include a copy of a signed contract, work order, or other form of written agreement.
   196  	ServiceDocumentation *File `json:"service_documentation"`
   197  	// The address to which a physical product was shipped. You should try to include as complete address information as possible.
   198  	ShippingAddress string `json:"shipping_address"`
   199  	// The delivery service that shipped a physical product, such as Fedex, UPS, USPS, etc. If multiple carriers were used for this purchase, please separate them with commas.
   200  	ShippingCarrier string `json:"shipping_carrier"`
   201  	// The date on which a physical product began its route to the shipping address, in a clear human-readable format.
   202  	ShippingDate string `json:"shipping_date"`
   203  	// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Documentation showing proof that a product was shipped to the customer at the same address the customer provided to you. This could include a copy of the shipment receipt, shipping label, etc. It should show the customer's full shipping address, if possible.
   204  	ShippingDocumentation *File `json:"shipping_documentation"`
   205  	// The tracking number for a physical product, obtained from the delivery service. If multiple tracking numbers were generated for this purchase, please separate them with commas.
   206  	ShippingTrackingNumber string `json:"shipping_tracking_number"`
   207  	// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Any additional evidence or statements.
   208  	UncategorizedFile *File `json:"uncategorized_file"`
   209  	// Any additional evidence or statements.
   210  	UncategorizedText string `json:"uncategorized_text"`
   211  }
   212  type DisputeEvidenceDetails struct {
   213  	// Date by which evidence must be submitted in order to successfully challenge dispute. Will be 0 if the customer's bank or credit card company doesn't allow a response for this particular dispute.
   214  	DueBy int64 `json:"due_by"`
   215  	// Whether evidence has been staged for this dispute.
   216  	HasEvidence bool `json:"has_evidence"`
   217  	// Whether the last evidence submission was submitted past the due date. Defaults to `false` if no evidence submissions have occurred. If `true`, then delivery of the latest evidence is *not* guaranteed.
   218  	PastDue bool `json:"past_due"`
   219  	// The number of times evidence has been submitted. Typically, you may only submit evidence once.
   220  	SubmissionCount int64 `json:"submission_count"`
   221  }
   222  
   223  // Card specific dispute details.
   224  type DisputePaymentMethodDetailsCard struct {
   225  	// Card brand. Can be `amex`, `diners`, `discover`, `eftpos_au`, `jcb`, `mastercard`, `unionpay`, `visa`, or `unknown`.
   226  	Brand string `json:"brand"`
   227  	// The card network's specific dispute reason code, which maps to one of Stripe's primary dispute categories to simplify response guidance. The [Network code map](https://stripe.com/docs/disputes/categories#network-code-map) lists all available dispute reason codes by network.
   228  	NetworkReasonCode string `json:"network_reason_code"`
   229  }
   230  type DisputePaymentMethodDetails struct {
   231  	// Card specific dispute details.
   232  	Card *DisputePaymentMethodDetailsCard `json:"card"`
   233  	// Payment method type.
   234  	Type DisputePaymentMethodDetailsType `json:"type"`
   235  }
   236  
   237  // A dispute occurs when a customer questions your charge with their card issuer.
   238  // When this happens, you have the opportunity to respond to the dispute with
   239  // evidence that shows that the charge is legitimate.
   240  //
   241  // Related guide: [Disputes and fraud](https://stripe.com/docs/disputes)
   242  type Dispute struct {
   243  	APIResource
   244  	// Disputed amount. Usually the amount of the charge, but it can differ (usually because of currency fluctuation or because only part of the order is disputed).
   245  	Amount int64 `json:"amount"`
   246  	// List of zero, one, or two balance transactions that show funds withdrawn and reinstated to your Stripe account as a result of this dispute.
   247  	BalanceTransactions []*BalanceTransaction `json:"balance_transactions"`
   248  	// ID of the charge that's disputed.
   249  	Charge *Charge `json:"charge"`
   250  	// Time at which the object was created. Measured in seconds since the Unix epoch.
   251  	Created int64 `json:"created"`
   252  	// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
   253  	Currency        Currency                `json:"currency"`
   254  	Evidence        *DisputeEvidence        `json:"evidence"`
   255  	EvidenceDetails *DisputeEvidenceDetails `json:"evidence_details"`
   256  	// Unique identifier for the object.
   257  	ID string `json:"id"`
   258  	// If true, it's still possible to refund the disputed payment. After the payment has been fully refunded, no further funds are withdrawn from your Stripe account as a result of this dispute.
   259  	IsChargeRefundable bool `json:"is_charge_refundable"`
   260  	// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
   261  	Livemode bool `json:"livemode"`
   262  	// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
   263  	Metadata map[string]string `json:"metadata"`
   264  	// Network-dependent reason code for the dispute.
   265  	NetworkReasonCode string `json:"network_reason_code"`
   266  	// String representing the object's type. Objects of the same type share the same value.
   267  	Object string `json:"object"`
   268  	// ID of the PaymentIntent that's disputed.
   269  	PaymentIntent        *PaymentIntent               `json:"payment_intent"`
   270  	PaymentMethodDetails *DisputePaymentMethodDetails `json:"payment_method_details"`
   271  	// Reason given by cardholder for dispute. Possible values are `bank_cannot_process`, `check_returned`, `credit_not_processed`, `customer_initiated`, `debit_not_authorized`, `duplicate`, `fraudulent`, `general`, `incorrect_account_details`, `insufficient_funds`, `product_not_received`, `product_unacceptable`, `subscription_canceled`, or `unrecognized`. Learn more about [dispute reasons](https://stripe.com/docs/disputes/categories).
   272  	Reason DisputeReason `json:"reason"`
   273  	// Current status of dispute. Possible values are `warning_needs_response`, `warning_under_review`, `warning_closed`, `needs_response`, `under_review`, `won`, or `lost`.
   274  	Status DisputeStatus `json:"status"`
   275  }
   276  
   277  // DisputeList is a list of Disputes as retrieved from a list endpoint.
   278  type DisputeList struct {
   279  	APIResource
   280  	ListMeta
   281  	Data []*Dispute `json:"data"`
   282  }
   283  
   284  // UnmarshalJSON handles deserialization of a Dispute.
   285  // This custom unmarshaling is needed because the resulting
   286  // property may be an id or the full struct if it was expanded.
   287  func (d *Dispute) UnmarshalJSON(data []byte) error {
   288  	if id, ok := ParseID(data); ok {
   289  		d.ID = id
   290  		return nil
   291  	}
   292  
   293  	type dispute Dispute
   294  	var v dispute
   295  	if err := json.Unmarshal(data, &v); err != nil {
   296  		return err
   297  	}
   298  
   299  	*d = Dispute(v)
   300  	return nil
   301  }