/
customer.ex
808 lines (758 loc) · 31.2 KB
/
customer.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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
defmodule Stripe.Customer do
use Stripe.Entity
@moduledoc "This object represents a customer of your business. Use it to create recurring charges and track payments that belong to the same customer.\n\nRelated guide: [Save a card during payment](https://stripe.com/docs/payments/save-during-payment)"
(
defstruct [
:address,
:balance,
:cash_balance,
:created,
:currency,
:default_source,
:delinquent,
:description,
:discount,
:email,
:id,
:invoice_credit_balance,
:invoice_prefix,
:invoice_settings,
:livemode,
:metadata,
:name,
:next_invoice_sequence,
:object,
:phone,
:preferred_locales,
:shipping,
:sources,
:subscriptions,
:tax,
:tax_exempt,
:tax_ids,
:test_clock
]
@typedoc "The `customer` type.\n\n * `address` The customer's address.\n * `balance` The current balance, if any, that's stored on the customer. If negative, the customer has credit to apply to their next invoice. If positive, the customer has an amount owed that's added to their next invoice. The balance only considers amounts that Stripe hasn't successfully applied to any invoice. It doesn't reflect unpaid invoices. This balance is only taken into account after invoices finalize.\n * `cash_balance` The current funds being held by Stripe on behalf of the customer. You can apply these funds towards payment intents when the source is \"cash_balance\". The `settings[reconciliation_mode]` field describes if these funds apply to these payment intents manually or automatically.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO code for the currency](https://stripe.com/docs/currencies) the customer can be charged in for recurring billing purposes.\n * `default_source` ID of the default payment source for the customer.\n\nIf you use payment methods created through the PaymentMethods API, see the [invoice_settings.default_payment_method](https://stripe.com/docs/api/customers/object#customer_object-invoice_settings-default_payment_method) field instead.\n * `delinquent` Tracks the most recent state change on any invoice belonging to the customer. Paying an invoice or marking it uncollectible via the API will set this field to false. An automatic payment failure or passing the `invoice.due_date` will set this field to `true`.\n\nIf an invoice becomes uncollectible by [dunning](https://stripe.com/docs/billing/automatic-collection), `delinquent` doesn't reset to `false`.\n\nIf you care whether the customer has paid their most recent subscription invoice, use `subscription.status` instead. Paying or marking uncollectible any customer invoice regardless of whether it is the latest invoice for a subscription will always set this field to `false`.\n * `description` An arbitrary string attached to the object. Often useful for displaying to users.\n * `discount` Describes the current discount active on the customer, if there is one.\n * `email` The customer's email address.\n * `id` Unique identifier for the object.\n * `invoice_credit_balance` The current multi-currency balances, if any, that's stored on the customer. If positive in a currency, the customer has a credit to apply to their next invoice denominated in that currency. If negative, the customer has an amount owed that's added to their next invoice denominated in that currency. These balances don't apply to unpaid invoices. They solely track amounts that Stripe hasn't successfully applied to any invoice. Stripe only applies a balance in a specific currency to an invoice after that invoice (which is in the same currency) finalizes.\n * `invoice_prefix` The prefix for the customer used to generate unique invoice numbers.\n * `invoice_settings` \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 * `name` The customer's full name or business name.\n * `next_invoice_sequence` The suffix of the customer's next invoice number (for example, 0001).\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `phone` The customer's phone number.\n * `preferred_locales` The customer's preferred locales (languages), ordered by preference.\n * `shipping` Mailing and shipping address for the customer. Appears on invoices emailed to this customer.\n * `sources` The customer's payment sources, if any.\n * `subscriptions` The customer's current subscriptions, if any.\n * `tax` \n * `tax_exempt` Describes the customer's tax exemption status, which is `none`, `exempt`, or `reverse`. When set to `reverse`, invoice and receipt PDFs include the following text: **\"Reverse charge\"**.\n * `tax_ids` The customer's tax IDs.\n * `test_clock` ID of the test clock that this customer belongs to.\n"
@type t :: %__MODULE__{
address: term | nil,
balance: integer,
cash_balance: Stripe.CashBalance.t() | nil,
created: integer,
currency: binary | nil,
default_source: (binary | Stripe.PaymentSource.t()) | nil,
delinquent: boolean | nil,
description: binary | nil,
discount: term | nil,
email: binary | nil,
id: binary,
invoice_credit_balance: term,
invoice_prefix: binary | nil,
invoice_settings: term,
livemode: boolean,
metadata: term,
name: binary | nil,
next_invoice_sequence: integer,
object: binary,
phone: binary | nil,
preferred_locales: term | nil,
shipping: term | nil,
sources: term,
subscriptions: term,
tax: term,
tax_exempt: binary | nil,
tax_ids: term,
test_clock: (binary | Stripe.TestHelpers.TestClock.t()) | nil
}
)
(
@typedoc nil
@type address :: %{
optional(:city) => binary,
optional(:country) => binary,
optional(:line1) => binary,
optional(:line2) => binary,
optional(:postal_code) => binary,
optional(:state) => binary
}
)
(
@typedoc "Additional parameters for `bank_transfer` funding types"
@type bank_transfer :: %{
optional(:eu_bank_transfer) => eu_bank_transfer,
optional(:requested_address_types) => list(:iban | :sort_code | :spei | :zengin),
optional(:type) =>
:eu_bank_transfer
| :gb_bank_transfer
| :jp_bank_transfer
| :mx_bank_transfer
| :us_bank_transfer
}
)
(
@typedoc "Balance information and default balance settings for this customer."
@type cash_balance :: %{optional(:settings) => settings}
)
(
@typedoc nil
@type created :: %{
optional(:gt) => integer,
optional(:gte) => integer,
optional(:lt) => integer,
optional(:lte) => integer
}
)
(
@typedoc nil
@type custom_fields :: %{optional(:name) => binary, optional(:value) => binary}
)
(
@typedoc "Configuration for eu_bank_transfer funding type."
@type eu_bank_transfer :: %{optional(:country) => binary}
)
(
@typedoc "Default invoice settings for this customer."
@type invoice_settings :: %{
optional(:custom_fields) => list(custom_fields) | binary,
optional(:default_payment_method) => binary,
optional(:footer) => binary,
optional(:rendering_options) => rendering_options | binary
}
)
(
@typedoc nil
@type rendering_options :: %{
optional(:amount_tax_display) => :exclude_tax | :include_inclusive_tax
}
)
(
@typedoc "Settings controlling the behavior of the customer's cash balance,\nsuch as reconciliation of funds received."
@type settings :: %{
optional(:reconciliation_mode) => :automatic | :manual | :merchant_default
}
)
(
@typedoc nil
@type shipping :: %{
optional(:address) => address,
optional(:name) => binary,
optional(:phone) => binary
}
)
(
@typedoc "Tax details about the customer."
@type tax :: %{optional(:ip_address) => binary | binary}
)
(
@typedoc nil
@type tax_id_data :: %{
optional(:type) =>
:ad_nrt
| :ae_trn
| :ar_cuit
| :au_abn
| :au_arn
| :bg_uic
| :bo_tin
| :br_cnpj
| :br_cpf
| :ca_bn
| :ca_gst_hst
| :ca_pst_bc
| :ca_pst_mb
| :ca_pst_sk
| :ca_qst
| :ch_vat
| :cl_tin
| :cn_tin
| :co_nit
| :cr_tin
| :do_rcn
| :ec_ruc
| :eg_tin
| :es_cif
| :eu_oss_vat
| :eu_vat
| :gb_vat
| :ge_vat
| :hk_br
| :hu_tin
| :id_npwp
| :il_vat
| :in_gst
| :is_vat
| :jp_cn
| :jp_rn
| :jp_trn
| :ke_pin
| :kr_brn
| :li_uid
| :mx_rfc
| :my_frp
| :my_itn
| :my_sst
| :no_vat
| :nz_gst
| :pe_ruc
| :ph_tin
| :ro_tin
| :rs_pib
| :ru_inn
| :ru_kpp
| :sa_vat
| :sg_gst
| :sg_uen
| :si_tin
| :sv_nit
| :th_vat
| :tr_tin
| :tw_vat
| :ua_vat
| :us_ein
| :uy_ruc
| :ve_rif
| :vn_tin
| :za_vat,
optional(:value) => binary
}
)
(
nil
@doc "<p>Search for customers you’ve previously created using Stripe’s <a href=\"/docs/search#search-query-language\">Search Query Language</a>.\nDon’t use search in read-after-write flows where strict consistency is necessary. Under normal operating\nconditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up\nto an hour behind during outages. Search functionality is not available to merchants in India.</p>\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/customers/search`\n"
(
@spec search(
params :: %{
optional(:expand) => list(binary),
optional(:limit) => integer,
optional(:page) => binary,
optional(:query) => binary
},
opts :: Keyword.t()
) ::
{:ok, Stripe.SearchResult.t(Stripe.Customer.t())}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def search(params \\ %{}, opts \\ []) do
path = Stripe.OpenApi.Path.replace_path_params("/v1/customers/search", [], [])
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>Returns a list of your customers. The customers are returned sorted by creation date, with the most recent customers appearing first.</p>\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/customers`\n"
(
@spec list(
params :: %{
optional(:created) => created | integer,
optional(:email) => binary,
optional(:ending_before) => binary,
optional(:expand) => list(binary),
optional(:limit) => integer,
optional(:starting_after) => binary,
optional(:test_clock) => binary
},
opts :: Keyword.t()
) ::
{:ok, Stripe.List.t(Stripe.Customer.t())}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def list(params \\ %{}, opts \\ []) do
path = Stripe.OpenApi.Path.replace_path_params("/v1/customers", [], [])
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 a new customer object.</p>\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/customers`\n"
(
@spec create(
params :: %{
optional(:address) => address | binary,
optional(:balance) => integer,
optional(:cash_balance) => cash_balance,
optional(:coupon) => binary,
optional(:description) => binary,
optional(:email) => binary,
optional(:expand) => list(binary),
optional(:invoice_prefix) => binary,
optional(:invoice_settings) => invoice_settings,
optional(:metadata) => %{optional(binary) => binary} | binary,
optional(:name) => binary,
optional(:next_invoice_sequence) => integer,
optional(:payment_method) => binary,
optional(:phone) => binary,
optional(:preferred_locales) => list(binary),
optional(:promotion_code) => binary,
optional(:shipping) => shipping | binary,
optional(:source) => binary,
optional(:tax) => tax,
optional(:tax_exempt) => :exempt | :none | :reverse,
optional(:tax_id_data) => list(tax_id_data),
optional(:test_clock) => binary,
optional(:validate) => boolean
},
opts :: Keyword.t()
) :: {:ok, Stripe.Customer.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
def create(params \\ %{}, opts \\ []) do
path = Stripe.OpenApi.Path.replace_path_params("/v1/customers", [], [])
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 a Customer object.</p>\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/customers/{customer}`\n"
(
@spec retrieve(
customer :: binary(),
params :: %{optional(:expand) => list(binary)},
opts :: Keyword.t()
) ::
{:ok, Stripe.Customer.t() | Stripe.DeletedCustomer.t()}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def retrieve(customer, params \\ %{}, opts \\ []) do
path =
Stripe.OpenApi.Path.replace_path_params(
"/v1/customers/{customer}",
[
%OpenApiGen.Blueprint.Parameter{
in: "path",
name: "customer",
required: true,
schema: %OpenApiGen.Blueprint.Parameter.Schema{
name: "customer",
title: nil,
type: "string",
items: [],
properties: [],
any_of: []
}
}
],
[customer]
)
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>Updates the specified customer by setting the values of the parameters passed. Any parameters not provided will be left unchanged. For example, if you pass the <strong>source</strong> parameter, that becomes the customer’s active source (e.g., a card) to be used for all charges in the future. When you update a customer to a new valid card source by passing the <strong>source</strong> parameter: for each of the customer’s current subscriptions, if the subscription bills automatically and is in the <code>past_due</code> state, then the latest open invoice for the subscription with automatic collection enabled will be retried. This retry will not count as an automatic retry, and will not affect the next regularly scheduled payment for the invoice. Changing the <strong>default_source</strong> for a customer will not trigger this behavior.</p>\n\n<p>This request accepts mostly the same arguments as the customer creation call.</p>\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/customers/{customer}`\n"
(
@spec update(
customer :: binary(),
params :: %{
optional(:address) => address | binary,
optional(:balance) => integer,
optional(:cash_balance) => cash_balance,
optional(:coupon) => binary,
optional(:default_source) => binary,
optional(:description) => binary,
optional(:email) => binary,
optional(:expand) => list(binary),
optional(:invoice_prefix) => binary,
optional(:invoice_settings) => invoice_settings,
optional(:metadata) => %{optional(binary) => binary} | binary,
optional(:name) => binary,
optional(:next_invoice_sequence) => integer,
optional(:phone) => binary,
optional(:preferred_locales) => list(binary),
optional(:promotion_code) => binary,
optional(:shipping) => shipping | binary,
optional(:source) => binary,
optional(:tax) => tax,
optional(:tax_exempt) => :exempt | :none | :reverse,
optional(:validate) => boolean
},
opts :: Keyword.t()
) :: {:ok, Stripe.Customer.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
def update(customer, params \\ %{}, opts \\ []) do
path =
Stripe.OpenApi.Path.replace_path_params(
"/v1/customers/{customer}",
[
%OpenApiGen.Blueprint.Parameter{
in: "path",
name: "customer",
required: true,
schema: %OpenApiGen.Blueprint.Parameter.Schema{
name: "customer",
title: nil,
type: "string",
items: [],
properties: [],
any_of: []
}
}
],
[customer]
)
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>Permanently deletes a customer. It cannot be undone. Also immediately cancels any active subscriptions on the customer.</p>\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/customers/{customer}`\n"
(
@spec delete(customer :: binary(), opts :: Keyword.t()) ::
{:ok, Stripe.DeletedCustomer.t()}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def delete(customer, opts \\ []) do
path =
Stripe.OpenApi.Path.replace_path_params(
"/v1/customers/{customer}",
[
%OpenApiGen.Blueprint.Parameter{
in: "path",
name: "customer",
required: true,
schema: %OpenApiGen.Blueprint.Parameter.Schema{
name: "customer",
title: nil,
type: "string",
items: [],
properties: [],
any_of: []
}
}
],
[customer]
)
Stripe.Request.new_request(opts)
|> Stripe.Request.put_endpoint(path)
|> Stripe.Request.put_method(:delete)
|> Stripe.Request.make_request()
end
)
)
(
nil
@doc "<p>Returns a list of PaymentMethods for a given Customer</p>\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/customers/{customer}/payment_methods`\n"
(
@spec list_payment_methods(
customer :: binary(),
params :: %{
optional(:ending_before) => binary,
optional(:expand) => list(binary),
optional(:limit) => integer,
optional(:starting_after) => binary,
optional(:type) =>
:acss_debit
| :affirm
| :afterpay_clearpay
| :alipay
| :au_becs_debit
| :bacs_debit
| :bancontact
| :blik
| :boleto
| :card
| :cashapp
| :customer_balance
| :eps
| :fpx
| :giropay
| :grabpay
| :ideal
| :klarna
| :konbini
| :link
| :oxxo
| :p24
| :paynow
| :paypal
| :pix
| :promptpay
| :revolut_pay
| :sepa_debit
| :sofort
| :us_bank_account
| :wechat_pay
| :zip
},
opts :: Keyword.t()
) ::
{:ok, Stripe.List.t(Stripe.PaymentMethod.t())}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def list_payment_methods(customer, params \\ %{}, opts \\ []) do
path =
Stripe.OpenApi.Path.replace_path_params(
"/v1/customers/{customer}/payment_methods",
[
%OpenApiGen.Blueprint.Parameter{
in: "path",
name: "customer",
required: true,
schema: %OpenApiGen.Blueprint.Parameter.Schema{
name: "customer",
title: nil,
type: "string",
items: [],
properties: [],
any_of: []
}
}
],
[customer]
)
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>Retrieves a PaymentMethod object for a given Customer.</p>\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/customers/{customer}/payment_methods/{payment_method}`\n"
(
@spec retrieve_payment_method(
customer :: binary(),
payment_method :: binary(),
params :: %{optional(:expand) => list(binary)},
opts :: Keyword.t()
) ::
{:ok, Stripe.PaymentMethod.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
def retrieve_payment_method(customer, payment_method, params \\ %{}, opts \\ []) do
path =
Stripe.OpenApi.Path.replace_path_params(
"/v1/customers/{customer}/payment_methods/{payment_method}",
[
%OpenApiGen.Blueprint.Parameter{
in: "path",
name: "customer",
required: true,
schema: %OpenApiGen.Blueprint.Parameter.Schema{
name: "customer",
title: nil,
type: "string",
items: [],
properties: [],
any_of: []
}
},
%OpenApiGen.Blueprint.Parameter{
in: "path",
name: "payment_method",
required: true,
schema: %OpenApiGen.Blueprint.Parameter.Schema{
name: "payment_method",
title: nil,
type: "string",
items: [],
properties: [],
any_of: []
}
}
],
[customer, payment_method]
)
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>Returns a list of transactions that updated the customer’s <a href=\"/docs/billing/customer/balance\">balances</a>.</p>\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/customers/{customer}/balance_transactions`\n"
(
@spec balance_transactions(
customer :: binary(),
params :: %{
optional(:ending_before) => binary,
optional(:expand) => list(binary),
optional(:limit) => integer,
optional(:starting_after) => binary
},
opts :: Keyword.t()
) ::
{:ok, Stripe.List.t(Stripe.CustomerBalanceTransaction.t())}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def balance_transactions(customer, params \\ %{}, opts \\ []) do
path =
Stripe.OpenApi.Path.replace_path_params(
"/v1/customers/{customer}/balance_transactions",
[
%OpenApiGen.Blueprint.Parameter{
in: "path",
name: "customer",
required: true,
schema: %OpenApiGen.Blueprint.Parameter.Schema{
name: "customer",
title: nil,
type: "string",
items: [],
properties: [],
any_of: []
}
}
],
[customer]
)
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>Create an incoming testmode bank transfer</p>\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/test_helpers/customers/{customer}/fund_cash_balance`\n"
(
@spec fund_cash_balance(
customer :: binary(),
params :: %{
optional(:amount) => integer,
optional(:currency) => binary,
optional(:expand) => list(binary),
optional(:reference) => binary
},
opts :: Keyword.t()
) ::
{:ok, Stripe.CustomerCashBalanceTransaction.t()}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def fund_cash_balance(customer, params \\ %{}, opts \\ []) do
path =
Stripe.OpenApi.Path.replace_path_params(
"/v1/test_helpers/customers/{customer}/fund_cash_balance",
[
%OpenApiGen.Blueprint.Parameter{
in: "path",
name: "customer",
required: true,
schema: %OpenApiGen.Blueprint.Parameter.Schema{
name: "customer",
title: nil,
type: "string",
items: [],
properties: [],
any_of: []
}
}
],
[customer]
)
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>Retrieve funding instructions for a customer cash balance. If funding instructions do not yet exist for the customer, new\nfunding instructions will be created. If funding instructions have already been created for a given customer, the same\nfunding instructions will be retrieved. In other words, we will return the same funding instructions each time.</p>\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/customers/{customer}/funding_instructions`\n"
(
@spec create_funding_instructions(
customer :: binary(),
params :: %{
optional(:bank_transfer) => bank_transfer,
optional(:currency) => binary,
optional(:expand) => list(binary),
optional(:funding_type) => :bank_transfer
},
opts :: Keyword.t()
) ::
{:ok, Stripe.FundingInstructions.t()}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def create_funding_instructions(customer, params \\ %{}, opts \\ []) do
path =
Stripe.OpenApi.Path.replace_path_params(
"/v1/customers/{customer}/funding_instructions",
[
%OpenApiGen.Blueprint.Parameter{
in: "path",
name: "customer",
required: true,
schema: %OpenApiGen.Blueprint.Parameter.Schema{
name: "customer",
title: nil,
type: "string",
items: [],
properties: [],
any_of: []
}
}
],
[customer]
)
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>Removes the currently applied discount on a customer.</p>\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/customers/{customer}/discount`\n"
(
@spec delete_discount(customer :: binary(), opts :: Keyword.t()) ::
{:ok, Stripe.DeletedDiscount.t()}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def delete_discount(customer, opts \\ []) do
path =
Stripe.OpenApi.Path.replace_path_params(
"/v1/customers/{customer}/discount",
[
%OpenApiGen.Blueprint.Parameter{
in: "path",
name: "customer",
required: true,
schema: %OpenApiGen.Blueprint.Parameter.Schema{
name: "customer",
title: nil,
type: "string",
items: [],
properties: [],
any_of: []
}
}
],
[customer]
)
Stripe.Request.new_request(opts)
|> Stripe.Request.put_endpoint(path)
|> Stripe.Request.put_method(:delete)
|> Stripe.Request.make_request()
end
)
)
end