-
Notifications
You must be signed in to change notification settings - Fork 340
/
issuing__dispute.ex
356 lines (329 loc) · 13.5 KB
/
issuing__dispute.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
defmodule Stripe.Issuing.Dispute do
use Stripe.Entity
@moduledoc "As a [card issuer](https://stripe.com/docs/issuing), you can dispute transactions that the cardholder does not recognize, suspects to be fraudulent, or has other issues with.\n\nRelated guide: [Issuing disputes](https://stripe.com/docs/issuing/purchases/disputes)"
(
defstruct [
:amount,
:balance_transactions,
:created,
:currency,
:evidence,
:id,
:livemode,
:metadata,
:object,
:status,
:transaction,
:treasury
]
@typedoc "The `issuing.dispute` type.\n\n * `amount` Disputed amount in the card's currency and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). Usually the amount of the `transaction`, but can differ (usually because of currency fluctuation).\n * `balance_transactions` List of balance transactions associated with the dispute.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` The currency the `transaction` was made in.\n * `evidence` \n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` 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.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `status` Current status of the dispute.\n * `transaction` The transaction being disputed.\n * `treasury` [Treasury](https://stripe.com/docs/api/treasury) details related to this dispute if it was created on a [FinancialAccount](/docs/api/treasury/financial_accounts\n"
@type t :: %__MODULE__{
amount: integer,
balance_transactions: term | nil,
created: integer,
currency: binary,
evidence: term,
id: binary,
livemode: boolean,
metadata: term,
object: binary,
status: binary,
transaction: binary | Stripe.Issuing.Transaction.t(),
treasury: term | nil
}
)
(
@typedoc nil
@type canceled :: %{
optional(:additional_documentation) => binary | binary,
optional(:canceled_at) => integer | binary,
optional(:cancellation_policy_provided) => boolean | binary,
optional(:cancellation_reason) => binary | binary,
optional(:expected_at) => integer | binary,
optional(:explanation) => binary | binary,
optional(:product_description) => binary | binary,
optional(:product_type) => :merchandise | :service,
optional(:return_status) => :merchant_rejected | :successful,
optional(:returned_at) => integer | binary
}
)
(
@typedoc nil
@type created :: %{
optional(:gt) => integer,
optional(:gte) => integer,
optional(:lt) => integer,
optional(:lte) => integer
}
)
(
@typedoc nil
@type duplicate :: %{
optional(:additional_documentation) => binary | binary,
optional(:card_statement) => binary | binary,
optional(:cash_receipt) => binary | binary,
optional(:check_image) => binary | binary,
optional(:explanation) => binary | binary,
optional(:original_transaction) => binary
}
)
(
@typedoc "Evidence provided for the dispute."
@type evidence :: %{
optional(:canceled) => canceled | binary,
optional(:duplicate) => duplicate | binary,
optional(:fraudulent) => fraudulent | binary,
optional(:merchandise_not_as_described) => merchandise_not_as_described | binary,
optional(:not_received) => not_received | binary,
optional(:other) => other | binary,
optional(:reason) =>
:canceled
| :duplicate
| :fraudulent
| :merchandise_not_as_described
| :not_received
| :other
| :service_not_as_described,
optional(:service_not_as_described) => service_not_as_described | binary
}
)
(
@typedoc nil
@type fraudulent :: %{
optional(:additional_documentation) => binary | binary,
optional(:explanation) => binary | binary
}
)
(
@typedoc nil
@type merchandise_not_as_described :: %{
optional(:additional_documentation) => binary | binary,
optional(:explanation) => binary | binary,
optional(:received_at) => integer | binary,
optional(:return_description) => binary | binary,
optional(:return_status) => :merchant_rejected | :successful,
optional(:returned_at) => integer | binary
}
)
(
@typedoc nil
@type not_received :: %{
optional(:additional_documentation) => binary | binary,
optional(:expected_at) => integer | binary,
optional(:explanation) => binary | binary,
optional(:product_description) => binary | binary,
optional(:product_type) => :merchandise | :service
}
)
(
@typedoc nil
@type other :: %{
optional(:additional_documentation) => binary | binary,
optional(:explanation) => binary | binary,
optional(:product_description) => binary | binary,
optional(:product_type) => :merchandise | :service
}
)
(
@typedoc nil
@type service_not_as_described :: %{
optional(:additional_documentation) => binary | binary,
optional(:canceled_at) => integer | binary,
optional(:cancellation_reason) => binary | binary,
optional(:explanation) => binary | binary,
optional(:received_at) => integer | binary
}
)
(
@typedoc "Params for disputes related to Treasury FinancialAccounts"
@type treasury :: %{optional(:received_debit) => binary}
)
(
nil
@doc "<p>Returns a list of Issuing <code>Dispute</code> objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first.</p>\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/issuing/disputes`\n"
(
@spec list(
params :: %{
optional(:created) => created | integer,
optional(:ending_before) => binary,
optional(:expand) => list(binary),
optional(:limit) => integer,
optional(:starting_after) => binary,
optional(:status) => :expired | :lost | :submitted | :unsubmitted | :won,
optional(:transaction) => binary
},
opts :: Keyword.t()
) ::
{:ok, Stripe.List.t(Stripe.Issuing.Dispute.t())}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def list(params \\ %{}, opts \\ []) do
path = Stripe.OpenApi.Path.replace_path_params("/v1/issuing/disputes", [], [])
Stripe.Request.new_request(opts)
|> Stripe.Request.put_endpoint(path)
|> Stripe.Request.put_params(params)
|> Stripe.Request.put_method(:get)
|> Stripe.Request.make_request()
end
)
)
(
nil
@doc "<p>Creates an Issuing <code>Dispute</code> object. Individual pieces of evidence within the <code>evidence</code> object are optional at this point. Stripe only validates that required evidence is present during submission. Refer to <a href=\"/docs/issuing/purchases/disputes#dispute-reasons-and-evidence\">Dispute reasons and evidence</a> for more details about evidence requirements.</p>\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/issuing/disputes`\n"
(
@spec create(
params :: %{
optional(:amount) => integer,
optional(:evidence) => evidence,
optional(:expand) => list(binary),
optional(:metadata) => %{optional(binary) => binary},
optional(:transaction) => binary,
optional(:treasury) => treasury
},
opts :: Keyword.t()
) ::
{:ok, Stripe.Issuing.Dispute.t()}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def create(params \\ %{}, opts \\ []) do
path = Stripe.OpenApi.Path.replace_path_params("/v1/issuing/disputes", [], [])
Stripe.Request.new_request(opts)
|> Stripe.Request.put_endpoint(path)
|> Stripe.Request.put_params(params)
|> Stripe.Request.put_method(:post)
|> Stripe.Request.make_request()
end
)
)
(
nil
@doc "<p>Updates the specified Issuing <code>Dispute</code> object by setting the values of the parameters passed. Any parameters not provided will be left unchanged. Properties on the <code>evidence</code> object can be unset by passing in an empty string.</p>\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/issuing/disputes/{dispute}`\n"
(
@spec update(
dispute :: binary(),
params :: %{
optional(:amount) => integer,
optional(:evidence) => evidence,
optional(:expand) => list(binary),
optional(:metadata) => %{optional(binary) => binary} | binary
},
opts :: Keyword.t()
) ::
{:ok, Stripe.Issuing.Dispute.t()}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def update(dispute, params \\ %{}, opts \\ []) do
path =
Stripe.OpenApi.Path.replace_path_params(
"/v1/issuing/disputes/{dispute}",
[
%OpenApiGen.Blueprint.Parameter{
in: "path",
name: "dispute",
required: true,
schema: %OpenApiGen.Blueprint.Parameter.Schema{
name: "dispute",
title: nil,
type: "string",
items: [],
properties: [],
any_of: []
}
}
],
[dispute]
)
Stripe.Request.new_request(opts)
|> Stripe.Request.put_endpoint(path)
|> Stripe.Request.put_params(params)
|> Stripe.Request.put_method(:post)
|> Stripe.Request.make_request()
end
)
)
(
nil
@doc "<p>Retrieves an Issuing <code>Dispute</code> object.</p>\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/issuing/disputes/{dispute}`\n"
(
@spec retrieve(
dispute :: binary(),
params :: %{optional(:expand) => list(binary)},
opts :: Keyword.t()
) ::
{:ok, Stripe.Issuing.Dispute.t()}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def retrieve(dispute, params \\ %{}, opts \\ []) do
path =
Stripe.OpenApi.Path.replace_path_params(
"/v1/issuing/disputes/{dispute}",
[
%OpenApiGen.Blueprint.Parameter{
in: "path",
name: "dispute",
required: true,
schema: %OpenApiGen.Blueprint.Parameter.Schema{
name: "dispute",
title: nil,
type: "string",
items: [],
properties: [],
any_of: []
}
}
],
[dispute]
)
Stripe.Request.new_request(opts)
|> Stripe.Request.put_endpoint(path)
|> Stripe.Request.put_params(params)
|> Stripe.Request.put_method(:get)
|> Stripe.Request.make_request()
end
)
)
(
nil
@doc "<p>Submits an Issuing <code>Dispute</code> to the card network. Stripe validates that all evidence fields required for the dispute’s reason are present. For more details, see <a href=\"/docs/issuing/purchases/disputes#dispute-reasons-and-evidence\">Dispute reasons and evidence</a>.</p>\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/issuing/disputes/{dispute}/submit`\n"
(
@spec submit(
dispute :: binary(),
params :: %{
optional(:expand) => list(binary),
optional(:metadata) => %{optional(binary) => binary} | binary
},
opts :: Keyword.t()
) ::
{:ok, Stripe.Issuing.Dispute.t()}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def submit(dispute, params \\ %{}, opts \\ []) do
path =
Stripe.OpenApi.Path.replace_path_params(
"/v1/issuing/disputes/{dispute}/submit",
[
%OpenApiGen.Blueprint.Parameter{
in: "path",
name: "dispute",
required: true,
schema: %OpenApiGen.Blueprint.Parameter.Schema{
name: "dispute",
title: nil,
type: "string",
items: [],
properties: [],
any_of: []
}
}
],
[dispute]
)
Stripe.Request.new_request(opts)
|> Stripe.Request.put_endpoint(path)
|> Stripe.Request.put_params(params)
|> Stripe.Request.put_method(:post)
|> Stripe.Request.make_request()
end
)
)
end