-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi-cocart-plus-checkout-v2.yaml
More file actions
2362 lines (2356 loc) · 82 KB
/
Copy pathopenapi-cocart-plus-checkout-v2.yaml
File metadata and controls
2362 lines (2356 loc) · 82 KB
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
openapi: 3.0.3
info:
title: CoCart Plus - Checkout API v2
version: 2.0.0
description: |
CoCart Plus extends the CoCart REST API v2 with a full headless checkout flow:
retrieving and updating checkout data (addresses, shipping/payment method, coupons,
currency), processing an order and its payment, retrieving checkout form
configuration, address autocomplete, order confirmation data, paying for an
existing order, and listing/selecting payment methods.
Requires CoCart Starter v5.0+ to be installed and active.
When the geolocation feature is enabled, responses include `Country`,
`Country-Code`, `Region` and `Timezone` headers.
When rate limiting is enabled, responses include `RateLimit-Limit`,
`RateLimit-Remaining` and `RateLimit-Reset` headers (plus `RateLimit-Retry-After`
on 429 responses).
termsOfService: https://cocartapi.com/terms-of-conditions-polar/
contact:
email: support@cocartapi.com
license:
name: GNU General Public License v3.0
url: http://www.gnu.org/licenses/gpl-3.0.html
externalDocs:
description: Find out more about CoCart API
url: https://docs.cocartapi.com
servers:
- url: '{protocol}://{host}/wp-json/cocart/v2'
description: API v2
variables:
protocol:
enum:
- http
- https
default: https
host:
default: example-store.com
description: Your store domain
tags:
- name: checkout
description: Operations for retrieving/updating checkout data and processing orders
- name: payment
description: Operations for available payment methods
- name: orders
description: Operations for order confirmation and paying for existing orders
- name: addresses
description: Operations for address autocomplete search and lookup
paths:
/checkout/config:
get:
tags:
- checkout
summary: Get checkout configuration
description: |
Returns the checkout form field configuration, locale settings, country/state
lists, shipping and account settings, store settings and client-side validation
rules used to build a checkout form. This endpoint is public and does not
require a cart session.
responses:
'200':
description: Checkout configuration retrieved successfully.
content:
application/json:
schema:
$ref: '#/components/schemas/CheckoutConfig'
example:
fields:
billing:
billing_first_name:
type: text
label: First name
placeholder: ''
required: true
class: [form-row-first]
autocomplete: given-name
priority: 10
billing_country:
type: country
label: Country / Region
required: true
class: [form-row-wide, address-field]
priority: 40
default: US
shipping:
shipping_first_name:
type: text
label: First name
required: true
class: [form-row-first]
autocomplete: given-name
priority: 10
account:
account_password:
type: password
label: Password
required: false
class: [form-row-wide]
priority: 10
order:
order_comments:
type: textarea
label: Order notes
placeholder: Notes about your order, e.g. special notes for delivery.
required: false
class: [notes]
priority: 10
locale_settings:
US:
state:
label: State
required: true
countries:
allowed_countries:
US: United States (US)
GB: United Kingdom (UK)
shipping_countries:
US: United States (US)
states:
US:
CA: California
NY: New York
default_country: US
eu_countries: [AT, BE, BG, HR, CY, CZ, DK, EE, FI, FR, DE, GR, HU, IE, IT, LV, LT, LU, MT, NL, PL, PT, RO, SK, SI, ES, SE]
shipping:
enabled: true
calc_shipping: true
ship_to_countries: ''
ship_to_billing_address: false
shipping_cost_requires_address: false
account:
allow_registration: true
registration_generate_username: true
registration_generate_password: false
guest_checkout_enabled: true
must_create_account: false
store:
currency: USD
currency_symbol: $
currency_position: left
price_decimal_sep: .
price_thousand_sep: ','
price_decimals: 2
tax_enabled: true
tax_display_cart: excl
prices_include_tax: false
coupons_enabled: true
terms_page_id: 12
privacy_page_id: 8
store_address:
address_1: 123 Main Street
address_2: ''
city: Beverly Hills
postcode: '90210'
country: US
state: CA
terms_text: I have read and agree to the website terms and conditions
validation:
postcode:
patterns:
GB: ^([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9][A-Za-z]?))))\s?[0-9][A-Za-z]{2})$
US: ^\d{5}(-\d{4})?$
CA: ^[A-Za-z]\d[A-Za-z][ ]?\d[A-Za-z]\d$
DE: ^\d{5}$
phone:
enabled: true
email:
enabled: true
/address/search:
get:
tags:
- addresses
summary: Search addresses
description: |
Searches for address suggestions using the configured address autocomplete
provider (WooCommerce's `woocommerce_address_providers` filter merged with
CoCart's own `cocart_address_autocomplete_providers` filter). This endpoint
is public and does not require a cart session.
parameters:
- name: query
in: query
description: The search text. Must be at least 3 characters long.
required: true
schema:
type: string
minLength: 3
- name: country
in: query
description: |
Two-letter country code to scope the search to. Defaults to the
customer's existing address country, the session country, the store
base country, or `US` if none can be determined.
required: false
schema:
type: string
minLength: 2
maxLength: 2
- name: type
in: query
description: Which address type the search is for.
required: false
schema:
type: string
enum:
- billing
- shipping
default: billing
- name: provider
in: query
description: Specific address provider ID to use. Defaults to the first available provider.
required: false
schema:
type: string
responses:
'200':
description: Address suggestions retrieved successfully.
content:
application/json:
schema:
$ref: '#/components/schemas/AddressSearchResult'
example:
suggestions:
- id: addr_12345
label: 123 Main Street, Beverly Hills, CA 90210
matched_substrings:
- offset: 0
length: 3
count: 1
provider:
id: google_places
name: Google Places
search_country: US
query: 123 Main
'400':
description: Bad request - invalid query or unsupported country.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
invalid_query:
summary: Query too short
value:
code: cocart_address_search_invalid_query
message: Query must be at least 3 characters.
data:
status: 400
country_not_supported:
summary: Country not supported by provider
value:
code: cocart_address_search_country_not_supported
message: 'Address search not supported for country: XX'
data:
status: 400
'500':
description: Server error - no provider available or the provider search failed.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
no_provider:
summary: No provider available
value:
code: cocart_address_search_no_provider
message: No address provider available.
data:
status: 500
search_error:
summary: Provider search error
value:
code: cocart_address_search_error
message: An error occurred while searching for addresses.
data:
status: 500
/address/details:
get:
tags:
- addresses
summary: Get address details
description: |
Resolves a suggestion ID returned by `/address/search` into full address
details using the same address autocomplete provider. This endpoint is
public and does not require a cart session.
parameters:
- name: address_id
in: query
description: The suggestion ID returned by `/address/search`.
required: true
schema:
type: string
- name: provider
in: query
description: The address provider ID that returned the suggestion.
required: true
schema:
type: string
responses:
'200':
description: Address details retrieved successfully.
content:
application/json:
schema:
$ref: '#/components/schemas/AddressDetails'
example:
address:
address_1: 123 Main Street
address_2: Suite 100
city: Beverly Hills
state: CA
postcode: '90210'
country: US
provider:
id: google_places
name: Google Places
'400':
description: Bad request - the address ID is missing.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
code: cocart_address_details_missing_id
message: Address ID is required.
data:
status: 400
'404':
description: Not found - no address details found for the given ID.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
code: cocart_address_details_not_found
message: Address not found.
data:
status: 404
'500':
description: Server error - no provider available, the resolved address was invalid, or the provider lookup failed.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
no_provider:
summary: No provider available
value:
code: cocart_address_details_no_provider
message: No address provider available.
data:
status: 500
invalid:
summary: Resolved address missing required fields
value:
code: cocart_address_details_invalid
message: 'Invalid address: missing address_1'
data:
status: 500
error:
summary: Provider lookup error
value:
code: cocart_address_details_error
message: An error occurred while retrieving address details.
data:
status: 500
/checkout:
get:
tags:
- checkout
summary: Get checkout data
description: |
Returns the current checkout data for the cart: customer addresses, cart
items, coupons, fees, shipping methods, chosen payment method and cart
totals. Requires an active cart session (guest with a valid cart key) or a
logged-in customer.
responses:
'200':
description: Checkout data retrieved successfully.
content:
application/json:
schema:
$ref: '#/components/schemas/CheckoutData'
example:
cart_hash: e629fa6598d732768f7c726b4b621285
cart_key: cb7a23af96a3f23af3c28a8b4b8c6d5e
currency:
currency_code: USD
currency_symbol: $
currency_symbol_pos: left
currency_minor_unit: 2
currency_decimal_separator: .
currency_thousand_separator: ','
currency_prefix: $
currency_suffix: ''
customer:
customer_id: 0
billing_address:
first_name: John
last_name: Doe
company: ''
address_1: 123 Main Street
address_2: ''
city: Beverly Hills
state: CA
postcode: '90210'
country: US
email: john.doe@example.com
phone: +1-555-123-4567
shipping_address:
first_name: John
last_name: Doe
company: ''
address_1: 123 Main Street
address_2: ''
city: Beverly Hills
state: CA
postcode: '90210'
country: US
items:
6364d3f0f495b6ab9dcf8d3b5c6e0b01:
item_key: 6364d3f0f495b6ab9dcf8d3b5c6e0b01
id: 123
name: Premium Quality T-Shirt
price: '1800'
quantity:
value: 2
minimum: 1
maximum: -1
multiple_of: 1
editable: true
totals:
subtotal: '3600'
subtotal_tax: '0'
total: '3600'
tax: '0'
slug: premium-quality-t-shirt
meta:
product_type: simple
sku: TSHIRT-001
backorders: ''
cart_item_data: {}
featured_image: https://example-store.com/wp-content/uploads/2024/03/tshirt.jpg
coupons: []
needs_payment: true
needs_shipping: true
shipping_methods:
flat_rate:1:
id: flat_rate:1
label: Flat rate
cost: '1000'
method_id: flat_rate
instance_id: 1
payment_method: stripe
fees: []
cart_totals:
subtotal: '3600'
subtotal_tax: '0'
fee_total: '0'
fee_tax: '0'
discount_total: '0'
discount_tax: '0'
shipping_total: '1000'
shipping_tax: '0'
cart_contents_total: '3600'
cart_contents_tax: '0'
total: '4600'
total_tax: '0'
message: ''
'401':
description: Unauthorized - no cart session and not logged in.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
code: cocart_rest_authentication_required
message: Authentication or valid cart key required.
data:
status: 401
put:
tags:
- checkout
summary: Update checkout data
description: |
Updates checkout data: billing/shipping address, chosen payment method,
chosen shipping method, applied coupon, and/or currency. Address fields are
validated and saved atomically - if any field fails validation, nothing is
persisted. Recalculates cart totals and returns the updated checkout data
with `message` set to `"Checkout data updated."`. `PUT` and `PATCH` behave
identically. Requires an active cart session or a logged-in customer.
requestBody:
$ref: '#/components/requestBodies/CheckoutUpdateRequest'
responses:
'200':
$ref: '#/components/responses/CheckoutUpdateResponse'
'400':
$ref: '#/components/responses/CheckoutUpdateBadRequest'
'401':
description: Unauthorized - no cart session and not logged in.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
code: cocart_rest_authentication_required
message: Authentication or valid cart key required.
data:
status: 401
patch:
tags:
- checkout
summary: Update checkout data (partial)
description: |
Identical behavior to `PUT /checkout`. Updates checkout data: billing/shipping
address, chosen payment method, chosen shipping method, applied coupon,
and/or currency. Address fields are validated and saved atomically. Requires
an active cart session or a logged-in customer.
requestBody:
$ref: '#/components/requestBodies/CheckoutUpdateRequest'
responses:
'200':
$ref: '#/components/responses/CheckoutUpdateResponse'
'400':
$ref: '#/components/responses/CheckoutUpdateBadRequest'
'401':
description: Unauthorized - no cart session and not logged in.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
code: cocart_rest_authentication_required
message: Authentication or valid cart key required.
data:
status: 401
post:
tags:
- checkout
summary: Process checkout
description: |
Validates the cart and customer data, creates a WooCommerce order (reusing
a matching draft order for the same cart hash on retry to avoid duplicate
orders), processes the payment if the order needs payment, and empties the
cart on success. Requires an active cart session or a logged-in customer.
Unlike `POST /order-received/{order_id}/pay`, a payment failure here does
NOT raise an HTTP error - the order is still created and a `200` is returned
with `payment_result.payment_status` set to `"failed"`.
When the gateway requires further customer action before the payment can
complete (e.g. 3D Secure/SCA), `payment_result.payment_status` is
`"requires_action"` and `action_type`/`action_data` describe what the
client must do (gateway-specific - e.g. for Stripe, `action_data.client_secret`
to confirm client-side). In this case the transaction has NOT finished:
the draft order and cart session are deliberately left intact, and
`cocart_checkout_complete` does not fire. Once the client has completed
the action, call `POST /checkout` again with the same cart/session to
land on the same order rather than creating a duplicate.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CheckoutProcessRequest'
example:
billing_address:
first_name: John
last_name: Doe
address_1: 123 Main Street
city: Beverly Hills
state: CA
postcode: '90210'
country: US
email: john.doe@example.com
phone: +1-555-123-4567
use_different_billing: true
shipping_address:
first_name: John
last_name: Doe
address_1: 123 Main Street
city: Beverly Hills
state: CA
postcode: '90210'
country: US
payment_method: stripe
payment_data:
- key: paymentMethodID
value: pm_1H8x2y2eZvKYlo2C
shipping_method: flat_rate:1
customer_note: Please leave at the front door.
create_account: false
responses:
'200':
description: Checkout processed. An order was created; see `payment_result` for the payment outcome.
content:
application/json:
schema:
$ref: '#/components/schemas/CheckoutProcessResponse'
examples:
success:
summary: Payment completed
value:
order_id: 1234
status: pending
order_key: wc_order_abc123
order_number: '1234'
payment_result:
payment_status: success
redirect_url: https://example-store.com/checkout/order-received/1234/?key=wc_order_abc123
message: ''
customer_id: 0
billing_address:
first_name: John
last_name: Doe
company: ''
address_1: 123 Main Street
address_2: ''
city: Beverly Hills
state: CA
postcode: '90210'
country: US
email: john.doe@example.com
phone: +1-555-123-4567
shipping_address:
first_name: John
last_name: Doe
company: ''
address_1: 123 Main Street
address_2: ''
city: Beverly Hills
state: CA
postcode: '90210'
country: US
requires_action:
summary: Gateway requires further customer action (e.g. 3D Secure)
value:
order_id: 1234
status: pending
order_key: wc_order_abc123
order_number: '1234'
payment_result:
payment_status: requires_action
action_type: stripe_confirm_payment
action_data:
client_secret: pi_3H8x2y2eZvKYlo2C_secret_abc123
intent_type: payment_intent
customer_id: 0
billing_address:
first_name: John
last_name: Doe
company: ''
address_1: 123 Main Street
address_2: ''
city: Beverly Hills
state: CA
postcode: '90210'
country: US
email: john.doe@example.com
phone: +1-555-123-4567
shipping_address:
first_name: John
last_name: Doe
company: ''
address_1: 123 Main Street
address_2: ''
city: Beverly Hills
state: CA
postcode: '90210'
country: US
'400':
description: Bad request - cart/customer validation failed, or the order could not be processed.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
empty_cart:
summary: Cart is empty
value:
code: cocart_cant_checkout_empty_cart
message: Cannot checkout with empty cart.
data:
status: 400
invalid_currency:
summary: Invalid currency code
value:
code: cocart_invalid_currency
message: 'Invalid currency code: XX'
data:
status: 400
customer_error:
summary: The customer could not be retrieved
value:
code: cocart_customer_error
message: Unable to retrieve customer.
data:
status: 400
invalid_address_fields:
summary: One or more address fields failed validation while syncing the customer's address
value:
code: cocart_invalid_address_fields
message: Please provide a valid email address. Please provide a valid phone number.
data:
status: 400
missing_field:
summary: Required billing field missing
value:
code: cocart_address_field_required
message: Address 1 is required.
data:
status: 400
invalid_email:
summary: Invalid billing email
value:
code: cocart_invalid_email_address
message: The email address "john.doe@example" is not valid.
data:
status: 400
invalid_phone:
summary: Invalid billing phone
value:
code: cocart_invalid_phone_number
message: The phone number "123" is not valid.
data:
status: 400
invalid_billing_country:
summary: Invalid billing country code
value:
code: cocart_invalid_billing_country_code
message: 'Invalid billing country: XX. Please select a valid country.'
data:
status: 400
invalid_billing_postcode:
summary: Invalid billing postcode
value:
code: cocart_invalid_billing_postcode
message: The postcode <strong>ABC</strong> is not valid for United States (US).
data:
status: 400
invalid_shipping_country:
summary: Invalid shipping country code
value:
code: cocart_invalid_shipping_country_code
message: 'Invalid shipping country: XX. Please select a valid country.'
data:
status: 400
invalid_shipping_postcode:
summary: Invalid shipping postcode
value:
code: cocart_invalid_shipping_postcode
message: The postcode <strong>ABC</strong> is not valid for United States (US).
data:
status: 400
product_not_exists:
summary: A cart item no longer exists
value:
code: cocart_product_not_exists
message: A product in your cart no longer exists and has been removed.
data:
status: 400
product_not_purchasable:
summary: A cart item is not purchasable
value:
code: cocart_product_not_purchasable
message: '"Premium Quality T-Shirt" is not available for purchase.'
data:
status: 400
product_out_of_stock:
summary: A cart item is out of stock
value:
code: cocart_product_out_of_stock
message: '"Premium Quality T-Shirt" is out of stock and cannot be purchased.'
data:
status: 400
insufficient_stock:
summary: A cart item exceeds available stock
value:
code: cocart_insufficient_stock
message: Insufficient stock for "Premium Quality T-Shirt". Only 1 remaining.
data:
status: 400
invalid_coupon:
summary: An applied coupon is no longer valid
value:
code: cocart_invalid_coupon
message: The coupon "summer10" is no longer valid and has been removed.
data:
status: 400
coupon_email_restricted:
summary: Coupon restricted to certain emails
value:
code: cocart_coupon_email_restricted
message: The coupon "summer10" is not valid for your email address and has been removed.
data:
status: 400
coupon_usage_limit:
summary: Coupon usage limit reached
value:
code: cocart_coupon_usage_limit
message: You have reached the usage limit for coupon "summer10".
data:
status: 400
no_shipping_method:
summary: No shipping method chosen
value:
code: cocart_no_shipping_method
message: Please select a shipping method.
data:
status: 400
no_shipping_method_for_package:
summary: No shipping method chosen for one of several shipping packages
value:
code: cocart_no_shipping_method
message: Please select a shipping method for all packages.
data:
status: 400
invalid_shipping_method:
summary: Chosen shipping method is not available
value:
code: cocart_invalid_shipping_method
message: 'The shipping method "flat_rate:1" is not available.'
data:
status: 400
invalid_payment_method:
summary: Payment method does not exist
value:
code: cocart_invalid_payment_method
message: Invalid payment method.
data:
status: 400
payment_method_disabled:
summary: Payment method is disabled
value:
code: cocart_payment_method_disabled
message: This payment method is currently disabled.
data:
status: 400
payment_method_no_subscription_support:
summary: Payment method does not support subscriptions in cart
value:
code: cocart_payment_method_no_subscription_support
message: The payment method "Stripe" does not support subscriptions. Please choose a different payment method.
data:
status: 400
payment_method_not_available:
summary: Payment method not available for this order
value:
code: cocart_payment_method_not_available
message: This payment method is not available for your order.
data:
status: 400
account_creation_failed:
summary: Guest account creation failed
value:
code: cocart_account_creation_failed
message: An account with this email address already exists.
data:
status: 400
'401':
description: Unauthorized - no cart session and not logged in.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
code: cocart_rest_authentication_required
message: Authentication or valid cart key required.
data:
status: 401
/checkout/payment-methods:
get:
tags:
- payment
summary: Get available payment methods
description: |
Returns the available payment gateways for the current cart, keyed by
gateway ID, including gateway configuration and any saved payment tokens
for the logged-in customer. Requires an active cart session or a logged-in
customer.
responses:
'200':
description: Available payment methods retrieved successfully.
content:
application/json:
schema:
type: object
additionalProperties:
$ref: '#/components/schemas/PaymentMethod'
example:
stripe:
id: stripe
title: Credit Card (Stripe)
description: Pay securely with your credit card via Stripe.
supports: [products, refunds, tokenization]
has_fields: true
order_button_text: Place order
method_title: Stripe
method_description: Take payments via Stripe.
config:
test_mode: false
is_connected: true
supports_tokenization: true
supports_refunds: true
supports_subscriptions: false
requires_billing_address: true
restricted_to_shipping_methods: null
saved_tokens:
- id: '42'
token: Visa ending in 4242
type: CC
gateway_id: stripe
is_default: true
expires: '08/2028'
supports_save_payment: true
cod:
id: cod
title: Cash on delivery
description: Pay with cash upon delivery.
supports: [products]
has_fields: false
order_button_text: Place order
method_title: Cash on Delivery
method_description: Allows you to accept cash on delivery.
config:
test_mode: false
is_connected: true
supports_tokenization: false
supports_refunds: false
supports_subscriptions: false
requires_billing_address: false
restricted_to_shipping_methods: null
saved_tokens: []
supports_save_payment: false
'401':
description: Unauthorized - no cart session and not logged in.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
code: cocart_rest_authentication_required
message: Authentication or valid cart key required.
data:
status: 401
/order-received/{order_id}:
get:
tags:
- orders
summary: Get order received data
description: |
Returns order confirmation data for the "order received" / thank-you page.
Access requires the `order_key` query parameter to match the order's key
(`hash_equals`); if the requester is logged in, the order must also belong
to that customer.
parameters:
- name: order_id
in: path
description: Unique identifier for the order. Must be numeric.
required: true
schema:
type: integer
- name: order_key
in: query
description: The order's key. Passed as a query parameter, not part of the path.
required: true
schema:
type: string
responses:
'200':
description: Order received data retrieved successfully.
content:
application/json:
schema:
$ref: '#/components/schemas/OrderReceived'
example:
order_id: 1234
order_number: '1234'
order_key: wc_order_abc123
status: processing
status_name: Processing
date_created: '2026-03-12T14:45:00Z'
date_paid: '2026-03-12T14:45:05Z'
currency: USD
total: '4600'
subtotal: '3600'
tax_total: '0'
shipping_total: '1000'
discount_total: '0'
payment_method: stripe
payment_method_title: Credit Card (Stripe)
customer_id: 0
customer_note: Please leave at the front door.
billing_address:
first_name: John
last_name: Doe
company: ''
address_1: 123 Main Street
address_2: ''
city: Beverly Hills
state: CA