-
Notifications
You must be signed in to change notification settings - Fork 1
/
invoices.go
2134 lines (1897 loc) · 67.1 KB
/
invoices.go
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
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// This file was auto-generated by Fern from our API Definition.
package square
import (
json "encoding/json"
fmt "fmt"
internal "github.com/square/square-go-sdk/internal"
io "io"
)
type CreateInvoiceAttachmentRequest struct {
// The ID of the [invoice](entity:Invoice) to attach the file to.
InvoiceID string `json:"-" url:"-"`
ImageFile io.Reader `json:"-" url:"-"`
Request interface{} `json:"request,omitempty" url:"-"`
}
type DeleteInvoiceAttachmentRequest struct {
// The ID of the [invoice](entity:Invoice) to delete the attachment from.
InvoiceID string `json:"-" url:"-"`
// The ID of the [attachment](entity:InvoiceAttachment) to delete.
AttachmentID string `json:"-" url:"-"`
}
type CancelInvoiceRequest struct {
// The ID of the [invoice](entity:Invoice) to cancel.
InvoiceID string `json:"-" url:"-"`
// The version of the [invoice](entity:Invoice) to cancel.
// If you do not know the version, you can call
// [GetInvoice](api-endpoint:Invoices-GetInvoice) or [ListInvoices](api-endpoint:Invoices-ListInvoices).
Version int `json:"version" url:"-"`
}
type CreateInvoiceRequest struct {
// The invoice to create.
Invoice *Invoice `json:"invoice,omitempty" url:"-"`
// A unique string that identifies the `CreateInvoice` request. If you do not
// provide `idempotency_key` (or provide an empty string as the value), the endpoint
// treats each request as independent.
//
// For more information, see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency).
IdempotencyKey *string `json:"idempotency_key,omitempty" url:"-"`
}
type InvoicesDeleteRequest struct {
// The ID of the invoice to delete.
InvoiceID string `json:"-" url:"-"`
// The version of the [invoice](entity:Invoice) to delete.
// If you do not know the version, you can call [GetInvoice](api-endpoint:Invoices-GetInvoice) or
// [ListInvoices](api-endpoint:Invoices-ListInvoices).
Version *int `json:"-" url:"version,omitempty"`
}
type InvoicesGetRequest struct {
// The ID of the invoice to retrieve.
InvoiceID string `json:"-" url:"-"`
}
type InvoicesListRequest struct {
// The ID of the location for which to list invoices.
LocationID string `json:"-" url:"location_id"`
// A pagination cursor returned by a previous call to this endpoint.
// Provide this cursor to retrieve the next set of results for your original query.
//
// For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination).
Cursor *string `json:"-" url:"cursor,omitempty"`
// The maximum number of invoices to return (200 is the maximum `limit`).
// If not provided, the server uses a default limit of 100 invoices.
Limit *int `json:"-" url:"limit,omitempty"`
}
type PublishInvoiceRequest struct {
// The ID of the invoice to publish.
InvoiceID string `json:"-" url:"-"`
// The version of the [invoice](entity:Invoice) to publish.
// This must match the current version of the invoice; otherwise, the request is rejected.
Version int `json:"version" url:"-"`
// A unique string that identifies the `PublishInvoice` request. If you do not
// provide `idempotency_key` (or provide an empty string as the value), the endpoint
// treats each request as independent.
//
// For more information, see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency).
IdempotencyKey *string `json:"idempotency_key,omitempty" url:"-"`
}
type SearchInvoicesRequest struct {
// Describes the query criteria for searching invoices.
Query *InvoiceQuery `json:"query,omitempty" url:"-"`
// The maximum number of invoices to return (200 is the maximum `limit`).
// If not provided, the server uses a default limit of 100 invoices.
Limit *int `json:"limit,omitempty" url:"-"`
// A pagination cursor returned by a previous call to this endpoint.
// Provide this cursor to retrieve the next set of results for your original query.
//
// For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination).
Cursor *string `json:"cursor,omitempty" url:"-"`
}
// The response returned by the `CancelInvoice` request.
type CancelInvoiceResponse struct {
// The canceled invoice.
Invoice *Invoice `json:"invoice,omitempty" url:"invoice,omitempty"`
// Information about errors encountered during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (c *CancelInvoiceResponse) GetInvoice() *Invoice {
if c == nil {
return nil
}
return c.Invoice
}
func (c *CancelInvoiceResponse) GetErrors() []*Error {
if c == nil {
return nil
}
return c.Errors
}
func (c *CancelInvoiceResponse) GetExtraProperties() map[string]interface{} {
return c.extraProperties
}
func (c *CancelInvoiceResponse) UnmarshalJSON(data []byte) error {
type unmarshaler CancelInvoiceResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*c = CancelInvoiceResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *c)
if err != nil {
return err
}
c.extraProperties = extraProperties
c.rawJSON = json.RawMessage(data)
return nil
}
func (c *CancelInvoiceResponse) String() string {
if len(c.rawJSON) > 0 {
if value, err := internal.StringifyJSON(c.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(c); err == nil {
return value
}
return fmt.Sprintf("%#v", c)
}
// Represents a [CreateInvoiceAttachment](api-endpoint:Invoices-CreateInvoiceAttachment) response.
type CreateInvoiceAttachmentResponse struct {
// Metadata about the attachment that was added to the invoice.
Attachment *InvoiceAttachment `json:"attachment,omitempty" url:"attachment,omitempty"`
// Information about errors encountered during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (c *CreateInvoiceAttachmentResponse) GetAttachment() *InvoiceAttachment {
if c == nil {
return nil
}
return c.Attachment
}
func (c *CreateInvoiceAttachmentResponse) GetErrors() []*Error {
if c == nil {
return nil
}
return c.Errors
}
func (c *CreateInvoiceAttachmentResponse) GetExtraProperties() map[string]interface{} {
return c.extraProperties
}
func (c *CreateInvoiceAttachmentResponse) UnmarshalJSON(data []byte) error {
type unmarshaler CreateInvoiceAttachmentResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*c = CreateInvoiceAttachmentResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *c)
if err != nil {
return err
}
c.extraProperties = extraProperties
c.rawJSON = json.RawMessage(data)
return nil
}
func (c *CreateInvoiceAttachmentResponse) String() string {
if len(c.rawJSON) > 0 {
if value, err := internal.StringifyJSON(c.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(c); err == nil {
return value
}
return fmt.Sprintf("%#v", c)
}
// The response returned by the `CreateInvoice` request.
type CreateInvoiceResponse struct {
// The newly created invoice.
Invoice *Invoice `json:"invoice,omitempty" url:"invoice,omitempty"`
// Information about errors encountered during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (c *CreateInvoiceResponse) GetInvoice() *Invoice {
if c == nil {
return nil
}
return c.Invoice
}
func (c *CreateInvoiceResponse) GetErrors() []*Error {
if c == nil {
return nil
}
return c.Errors
}
func (c *CreateInvoiceResponse) GetExtraProperties() map[string]interface{} {
return c.extraProperties
}
func (c *CreateInvoiceResponse) UnmarshalJSON(data []byte) error {
type unmarshaler CreateInvoiceResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*c = CreateInvoiceResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *c)
if err != nil {
return err
}
c.extraProperties = extraProperties
c.rawJSON = json.RawMessage(data)
return nil
}
func (c *CreateInvoiceResponse) String() string {
if len(c.rawJSON) > 0 {
if value, err := internal.StringifyJSON(c.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(c); err == nil {
return value
}
return fmt.Sprintf("%#v", c)
}
// Represents a [DeleteInvoiceAttachment](api-endpoint:Invoices-DeleteInvoiceAttachment) response.
type DeleteInvoiceAttachmentResponse struct {
// Information about errors encountered during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (d *DeleteInvoiceAttachmentResponse) GetErrors() []*Error {
if d == nil {
return nil
}
return d.Errors
}
func (d *DeleteInvoiceAttachmentResponse) GetExtraProperties() map[string]interface{} {
return d.extraProperties
}
func (d *DeleteInvoiceAttachmentResponse) UnmarshalJSON(data []byte) error {
type unmarshaler DeleteInvoiceAttachmentResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*d = DeleteInvoiceAttachmentResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *d)
if err != nil {
return err
}
d.extraProperties = extraProperties
d.rawJSON = json.RawMessage(data)
return nil
}
func (d *DeleteInvoiceAttachmentResponse) String() string {
if len(d.rawJSON) > 0 {
if value, err := internal.StringifyJSON(d.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(d); err == nil {
return value
}
return fmt.Sprintf("%#v", d)
}
// Describes a `DeleteInvoice` response.
type DeleteInvoiceResponse struct {
// Information about errors encountered during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (d *DeleteInvoiceResponse) GetErrors() []*Error {
if d == nil {
return nil
}
return d.Errors
}
func (d *DeleteInvoiceResponse) GetExtraProperties() map[string]interface{} {
return d.extraProperties
}
func (d *DeleteInvoiceResponse) UnmarshalJSON(data []byte) error {
type unmarshaler DeleteInvoiceResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*d = DeleteInvoiceResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *d)
if err != nil {
return err
}
d.extraProperties = extraProperties
d.rawJSON = json.RawMessage(data)
return nil
}
func (d *DeleteInvoiceResponse) String() string {
if len(d.rawJSON) > 0 {
if value, err := internal.StringifyJSON(d.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(d); err == nil {
return value
}
return fmt.Sprintf("%#v", d)
}
// Describes a `GetInvoice` response.
type GetInvoiceResponse struct {
// The invoice requested.
Invoice *Invoice `json:"invoice,omitempty" url:"invoice,omitempty"`
// Information about errors encountered during the request.
Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (g *GetInvoiceResponse) GetInvoice() *Invoice {
if g == nil {
return nil
}
return g.Invoice
}
func (g *GetInvoiceResponse) GetErrors() []*Error {
if g == nil {
return nil
}
return g.Errors
}
func (g *GetInvoiceResponse) GetExtraProperties() map[string]interface{} {
return g.extraProperties
}
func (g *GetInvoiceResponse) UnmarshalJSON(data []byte) error {
type unmarshaler GetInvoiceResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*g = GetInvoiceResponse(value)
extraProperties, err := internal.ExtractExtraProperties(data, *g)
if err != nil {
return err
}
g.extraProperties = extraProperties
g.rawJSON = json.RawMessage(data)
return nil
}
func (g *GetInvoiceResponse) String() string {
if len(g.rawJSON) > 0 {
if value, err := internal.StringifyJSON(g.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(g); err == nil {
return value
}
return fmt.Sprintf("%#v", g)
}
// Stores information about an invoice. You use the Invoices API to create and manage
// invoices. For more information, see [Invoices API Overview](https://developer.squareup.com/docs/invoices-api/overview).
type Invoice struct {
// The Square-assigned ID of the invoice.
ID *string `json:"id,omitempty" url:"id,omitempty"`
// The Square-assigned version number, which is incremented each time an update is committed to the invoice.
Version *int `json:"version,omitempty" url:"version,omitempty"`
// The ID of the location that this invoice is associated with.
//
// If specified in a `CreateInvoice` request, the value must match the `location_id` of the associated order.
LocationID *string `json:"location_id,omitempty" url:"location_id,omitempty"`
// The ID of the [order](entity:Order) for which the invoice is created.
// This field is required when creating an invoice, and the order must be in the `OPEN` state.
//
// To view the line items and other information for the associated order, call the
// [RetrieveOrder](api-endpoint:Orders-RetrieveOrder) endpoint using the order ID.
OrderID *string `json:"order_id,omitempty" url:"order_id,omitempty"`
// The customer who receives the invoice. This customer data is displayed on the invoice and used by Square to deliver the invoice.
//
// This field is required to publish an invoice, and it must specify the `customer_id`.
PrimaryRecipient *InvoiceRecipient `json:"primary_recipient,omitempty" url:"primary_recipient,omitempty"`
// The payment schedule for the invoice, represented by one or more payment requests that
// define payment settings, such as amount due and due date. An invoice supports the following payment request combinations:
// - One balance
// - One deposit with one balance
// - 2–12 installments
// - One deposit with 2–12 installments
//
// This field is required when creating an invoice. It must contain at least one payment request.
// All payment requests for the invoice must equal the total order amount. For more information, see
// [Configuring payment requests](https://developer.squareup.com/docs/invoices-api/create-publish-invoices#payment-requests).
//
// Adding `INSTALLMENT` payment requests to an invoice requires an
// [Invoices Plus subscription](https://developer.squareup.com/docs/invoices-api/overview#invoices-plus-subscription).
PaymentRequests []*InvoicePaymentRequest `json:"payment_requests,omitempty" url:"payment_requests,omitempty"`
// The delivery method that Square uses to send the invoice, reminders, and receipts to
// the customer. After the invoice is published, Square processes the invoice based on the delivery
// method and payment request settings, either immediately or on the `scheduled_at` date, if specified.
// For example, Square might send the invoice or receipt for an automatic payment. For invoices with
// automatic payments, this field must be set to `EMAIL`.
//
// One of the following is required when creating an invoice:
// - (Recommended) This `delivery_method` field. To configure an automatic payment, the
// `automatic_payment_source` field of the payment request is also required.
// - The deprecated `request_method` field of the payment request. Note that `invoice`
// objects returned in responses do not include `request_method`.
// See [InvoiceDeliveryMethod](#type-invoicedeliverymethod) for possible values
DeliveryMethod *InvoiceDeliveryMethod `json:"delivery_method,omitempty" url:"delivery_method,omitempty"`
// A user-friendly invoice number that is displayed on the invoice. The value is unique within a location.
// If not provided when creating an invoice, Square assigns a value.
// It increments from 1 and is padded with zeros making it 7 characters long
// (for example, 0000001 and 0000002).
InvoiceNumber *string `json:"invoice_number,omitempty" url:"invoice_number,omitempty"`
// The title of the invoice, which is displayed on the invoice.
Title *string `json:"title,omitempty" url:"title,omitempty"`
// The description of the invoice, which is displayed on the invoice.
Description *string `json:"description,omitempty" url:"description,omitempty"`
// The timestamp when the invoice is scheduled for processing, in RFC 3339 format.
// After the invoice is published, Square processes the invoice on the specified date,
// according to the delivery method and payment request settings.
//
// If the field is not set, Square processes the invoice immediately after it is published.
ScheduledAt *string `json:"scheduled_at,omitempty" url:"scheduled_at,omitempty"`
// The URL of the Square-hosted invoice page.
// After you publish the invoice using the `PublishInvoice` endpoint, Square hosts the invoice
// page and returns the page URL in the response.
PublicURL *string `json:"public_url,omitempty" url:"public_url,omitempty"`
// The current amount due for the invoice. In addition to the
// amount due on the next payment request, this includes any overdue payment amounts.
NextPaymentAmountMoney *Money `json:"next_payment_amount_money,omitempty" url:"next_payment_amount_money,omitempty"`
// The status of the invoice.
// See [InvoiceStatus](#type-invoicestatus) for possible values
Status *InvoiceStatus `json:"status,omitempty" url:"status,omitempty"`
// The time zone used to interpret calendar dates on the invoice, such as `due_date`.
// When an invoice is created, this field is set to the `timezone` specified for the seller
// location. The value cannot be changed.
//
// For example, a payment `due_date` of 2021-03-09 with a `timezone` of America/Los\_Angeles
// becomes overdue at midnight on March 9 in America/Los\_Angeles (which equals a UTC timestamp
// of 2021-03-10T08:00:00Z).
Timezone *string `json:"timezone,omitempty" url:"timezone,omitempty"`
// The timestamp when the invoice was created, in RFC 3339 format.
CreatedAt *string `json:"created_at,omitempty" url:"created_at,omitempty"`
// The timestamp when the invoice was last updated, in RFC 3339 format.
UpdatedAt *string `json:"updated_at,omitempty" url:"updated_at,omitempty"`
// The payment methods that customers can use to pay the invoice on the Square-hosted
// invoice page. This setting is independent of any automatic payment requests for the invoice.
//
// This field is required when creating an invoice and must set at least one payment method to `true`.
AcceptedPaymentMethods *InvoiceAcceptedPaymentMethods `json:"accepted_payment_methods,omitempty" url:"accepted_payment_methods,omitempty"`
// Additional seller-defined fields that are displayed on the invoice. For more information, see
// [Custom fields](https://developer.squareup.com/docs/invoices-api/overview#custom-fields).
//
// Adding custom fields to an invoice requires an
// [Invoices Plus subscription](https://developer.squareup.com/docs/invoices-api/overview#invoices-plus-subscription).
//
// Max: 2 custom fields
CustomFields []*InvoiceCustomField `json:"custom_fields,omitempty" url:"custom_fields,omitempty"`
// The ID of the [subscription](entity:Subscription) associated with the invoice.
// This field is present only on subscription billing invoices.
SubscriptionID *string `json:"subscription_id,omitempty" url:"subscription_id,omitempty"`
// The date of the sale or the date that the service is rendered, in `YYYY-MM-DD` format.
// This field can be used to specify a past or future date which is displayed on the invoice.
SaleOrServiceDate *string `json:"sale_or_service_date,omitempty" url:"sale_or_service_date,omitempty"`
// **France only.** The payment terms and conditions that are displayed on the invoice. For more information,
// see [Payment conditions](https://developer.squareup.com/docs/invoices-api/overview#payment-conditions).
//
// For countries other than France, Square returns an `INVALID_REQUEST_ERROR` with a `BAD_REQUEST` code and
// "Payment conditions are not supported for this location's country" detail if this field is included in `CreateInvoice` or `UpdateInvoice` requests.
PaymentConditions *string `json:"payment_conditions,omitempty" url:"payment_conditions,omitempty"`
// Indicates whether to allow a customer to save a credit or debit card as a card on file or a bank transfer as a
// bank account on file. If `true`, Square displays a __Save my card on file__ or __Save my bank on file__ checkbox on the
// invoice payment page. Stored payment information can be used for future automatic payments. The default value is `false`.
StorePaymentMethodEnabled *bool `json:"store_payment_method_enabled,omitempty" url:"store_payment_method_enabled,omitempty"`
// Metadata about the attachments on the invoice. Invoice attachments are managed using the
// [CreateInvoiceAttachment](api-endpoint:Invoices-CreateInvoiceAttachment) and [DeleteInvoiceAttachment](api-endpoint:Invoices-DeleteInvoiceAttachment) endpoints.
Attachments []*InvoiceAttachment `json:"attachments,omitempty" url:"attachments,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (i *Invoice) GetID() *string {
if i == nil {
return nil
}
return i.ID
}
func (i *Invoice) GetVersion() *int {
if i == nil {
return nil
}
return i.Version
}
func (i *Invoice) GetLocationID() *string {
if i == nil {
return nil
}
return i.LocationID
}
func (i *Invoice) GetOrderID() *string {
if i == nil {
return nil
}
return i.OrderID
}
func (i *Invoice) GetPrimaryRecipient() *InvoiceRecipient {
if i == nil {
return nil
}
return i.PrimaryRecipient
}
func (i *Invoice) GetPaymentRequests() []*InvoicePaymentRequest {
if i == nil {
return nil
}
return i.PaymentRequests
}
func (i *Invoice) GetDeliveryMethod() *InvoiceDeliveryMethod {
if i == nil {
return nil
}
return i.DeliveryMethod
}
func (i *Invoice) GetInvoiceNumber() *string {
if i == nil {
return nil
}
return i.InvoiceNumber
}
func (i *Invoice) GetTitle() *string {
if i == nil {
return nil
}
return i.Title
}
func (i *Invoice) GetDescription() *string {
if i == nil {
return nil
}
return i.Description
}
func (i *Invoice) GetScheduledAt() *string {
if i == nil {
return nil
}
return i.ScheduledAt
}
func (i *Invoice) GetPublicURL() *string {
if i == nil {
return nil
}
return i.PublicURL
}
func (i *Invoice) GetNextPaymentAmountMoney() *Money {
if i == nil {
return nil
}
return i.NextPaymentAmountMoney
}
func (i *Invoice) GetStatus() *InvoiceStatus {
if i == nil {
return nil
}
return i.Status
}
func (i *Invoice) GetTimezone() *string {
if i == nil {
return nil
}
return i.Timezone
}
func (i *Invoice) GetCreatedAt() *string {
if i == nil {
return nil
}
return i.CreatedAt
}
func (i *Invoice) GetUpdatedAt() *string {
if i == nil {
return nil
}
return i.UpdatedAt
}
func (i *Invoice) GetAcceptedPaymentMethods() *InvoiceAcceptedPaymentMethods {
if i == nil {
return nil
}
return i.AcceptedPaymentMethods
}
func (i *Invoice) GetCustomFields() []*InvoiceCustomField {
if i == nil {
return nil
}
return i.CustomFields
}
func (i *Invoice) GetSubscriptionID() *string {
if i == nil {
return nil
}
return i.SubscriptionID
}
func (i *Invoice) GetSaleOrServiceDate() *string {
if i == nil {
return nil
}
return i.SaleOrServiceDate
}
func (i *Invoice) GetPaymentConditions() *string {
if i == nil {
return nil
}
return i.PaymentConditions
}
func (i *Invoice) GetStorePaymentMethodEnabled() *bool {
if i == nil {
return nil
}
return i.StorePaymentMethodEnabled
}
func (i *Invoice) GetAttachments() []*InvoiceAttachment {
if i == nil {
return nil
}
return i.Attachments
}
func (i *Invoice) GetExtraProperties() map[string]interface{} {
return i.extraProperties
}
func (i *Invoice) UnmarshalJSON(data []byte) error {
type unmarshaler Invoice
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*i = Invoice(value)
extraProperties, err := internal.ExtractExtraProperties(data, *i)
if err != nil {
return err
}
i.extraProperties = extraProperties
i.rawJSON = json.RawMessage(data)
return nil
}
func (i *Invoice) String() string {
if len(i.rawJSON) > 0 {
if value, err := internal.StringifyJSON(i.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(i); err == nil {
return value
}
return fmt.Sprintf("%#v", i)
}
// The payment methods that customers can use to pay an [invoice](entity:Invoice) on the Square-hosted invoice payment page.
type InvoiceAcceptedPaymentMethods struct {
// Indicates whether credit card or debit card payments are accepted. The default value is `false`.
Card *bool `json:"card,omitempty" url:"card,omitempty"`
// Indicates whether Square gift card payments are accepted. The default value is `false`.
SquareGiftCard *bool `json:"square_gift_card,omitempty" url:"square_gift_card,omitempty"`
// Indicates whether ACH bank transfer payments are accepted. The default value is `false`.
BankAccount *bool `json:"bank_account,omitempty" url:"bank_account,omitempty"`
// Indicates whether Afterpay (also known as Clearpay) payments are accepted. The default value is `false`.
//
// This option is allowed only for invoices that have a single payment request of the `BALANCE` type. This payment method is
// supported if the seller account accepts Afterpay payments and the seller location is in a country where Afterpay
// invoice payments are supported. As a best practice, consider enabling an additional payment method when allowing
// `buy_now_pay_later` payments. For more information, including detailed requirements and processing limits, see
// [Buy Now Pay Later payments with Afterpay](https://developer.squareup.com/docs/invoices-api/overview#buy-now-pay-later).
BuyNowPayLater *bool `json:"buy_now_pay_later,omitempty" url:"buy_now_pay_later,omitempty"`
// Indicates whether Cash App payments are accepted. The default value is `false`.
//
// This payment method is supported only for seller [locations](entity:Location) in the United States.
CashAppPay *bool `json:"cash_app_pay,omitempty" url:"cash_app_pay,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (i *InvoiceAcceptedPaymentMethods) GetCard() *bool {
if i == nil {
return nil
}
return i.Card
}
func (i *InvoiceAcceptedPaymentMethods) GetSquareGiftCard() *bool {
if i == nil {
return nil
}
return i.SquareGiftCard
}
func (i *InvoiceAcceptedPaymentMethods) GetBankAccount() *bool {
if i == nil {
return nil
}
return i.BankAccount
}
func (i *InvoiceAcceptedPaymentMethods) GetBuyNowPayLater() *bool {
if i == nil {
return nil
}
return i.BuyNowPayLater
}
func (i *InvoiceAcceptedPaymentMethods) GetCashAppPay() *bool {
if i == nil {
return nil
}
return i.CashAppPay
}
func (i *InvoiceAcceptedPaymentMethods) GetExtraProperties() map[string]interface{} {
return i.extraProperties
}
func (i *InvoiceAcceptedPaymentMethods) UnmarshalJSON(data []byte) error {
type unmarshaler InvoiceAcceptedPaymentMethods
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*i = InvoiceAcceptedPaymentMethods(value)
extraProperties, err := internal.ExtractExtraProperties(data, *i)
if err != nil {
return err
}
i.extraProperties = extraProperties
i.rawJSON = json.RawMessage(data)
return nil
}
func (i *InvoiceAcceptedPaymentMethods) String() string {
if len(i.rawJSON) > 0 {
if value, err := internal.StringifyJSON(i.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(i); err == nil {
return value
}
return fmt.Sprintf("%#v", i)
}
// Represents a file attached to an [invoice](entity:Invoice).
type InvoiceAttachment struct {
// The Square-assigned ID of the attachment.
ID *string `json:"id,omitempty" url:"id,omitempty"`
// The file name of the attachment, which is displayed on the invoice.
Filename *string `json:"filename,omitempty" url:"filename,omitempty"`
// The description of the attachment, which is displayed on the invoice.
// This field maps to the seller-defined **Message** field.
Description *string `json:"description,omitempty" url:"description,omitempty"`
// The file size of the attachment in bytes.
Filesize *int `json:"filesize,omitempty" url:"filesize,omitempty"`
// The MD5 hash that was generated from the file contents.
Hash *string `json:"hash,omitempty" url:"hash,omitempty"`
// The mime type of the attachment.
// The following mime types are supported:
// image/gif, image/jpeg, image/png, image/tiff, image/bmp, application/pdf.
MimeType *string `json:"mime_type,omitempty" url:"mime_type,omitempty"`
// The timestamp when the attachment was uploaded, in RFC 3339 format.
UploadedAt *string `json:"uploaded_at,omitempty" url:"uploaded_at,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (i *InvoiceAttachment) GetID() *string {
if i == nil {
return nil
}
return i.ID
}
func (i *InvoiceAttachment) GetFilename() *string {
if i == nil {
return nil
}
return i.Filename
}
func (i *InvoiceAttachment) GetDescription() *string {
if i == nil {
return nil
}
return i.Description
}
func (i *InvoiceAttachment) GetFilesize() *int {
if i == nil {
return nil
}
return i.Filesize
}
func (i *InvoiceAttachment) GetHash() *string {
if i == nil {
return nil
}
return i.Hash
}
func (i *InvoiceAttachment) GetMimeType() *string {
if i == nil {
return nil
}
return i.MimeType
}
func (i *InvoiceAttachment) GetUploadedAt() *string {
if i == nil {
return nil
}
return i.UploadedAt
}
func (i *InvoiceAttachment) GetExtraProperties() map[string]interface{} {
return i.extraProperties
}
func (i *InvoiceAttachment) UnmarshalJSON(data []byte) error {
type unmarshaler InvoiceAttachment
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*i = InvoiceAttachment(value)
extraProperties, err := internal.ExtractExtraProperties(data, *i)
if err != nil {
return err
}
i.extraProperties = extraProperties
i.rawJSON = json.RawMessage(data)
return nil
}
func (i *InvoiceAttachment) String() string {
if len(i.rawJSON) > 0 {
if value, err := internal.StringifyJSON(i.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(i); err == nil {
return value
}
return fmt.Sprintf("%#v", i)
}
// Indicates the automatic payment method for an [invoice payment request](entity:InvoicePaymentRequest).
type InvoiceAutomaticPaymentSource string
const (
InvoiceAutomaticPaymentSourceNone InvoiceAutomaticPaymentSource = "NONE"
InvoiceAutomaticPaymentSourceCardOnFile InvoiceAutomaticPaymentSource = "CARD_ON_FILE"
InvoiceAutomaticPaymentSourceBankOnFile InvoiceAutomaticPaymentSource = "BANK_ON_FILE"
)
func NewInvoiceAutomaticPaymentSourceFromString(s string) (InvoiceAutomaticPaymentSource, error) {
switch s {
case "NONE":
return InvoiceAutomaticPaymentSourceNone, nil
case "CARD_ON_FILE":
return InvoiceAutomaticPaymentSourceCardOnFile, nil
case "BANK_ON_FILE":
return InvoiceAutomaticPaymentSourceBankOnFile, nil
}
var t InvoiceAutomaticPaymentSource
return "", fmt.Errorf("%s is not a valid %T", s, t)
}
func (i InvoiceAutomaticPaymentSource) Ptr() *InvoiceAutomaticPaymentSource {
return &i
}
// An additional seller-defined and customer-facing field to include on the invoice. For more information,
// see [Custom fields](https://developer.squareup.com/docs/invoices-api/overview#custom-fields).
//
// Adding custom fields to an invoice requires an
// [Invoices Plus subscription](https://developer.squareup.com/docs/invoices-api/overview#invoices-plus-subscription).
type InvoiceCustomField struct {
// The label or title of the custom field. This field is required for a custom field.
Label *string `json:"label,omitempty" url:"label,omitempty"`
// The text of the custom field. If omitted, only the label is rendered.
Value *string `json:"value,omitempty" url:"value,omitempty"`
// The location of the custom field on the invoice. This field is required for a custom field.
// See [InvoiceCustomFieldPlacement](#type-invoicecustomfieldplacement) for possible values
Placement *InvoiceCustomFieldPlacement `json:"placement,omitempty" url:"placement,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (i *InvoiceCustomField) GetLabel() *string {
if i == nil {
return nil
}
return i.Label
}
func (i *InvoiceCustomField) GetValue() *string {
if i == nil {
return nil
}
return i.Value
}