ultracart_api 4.1.163 → 4.1.166

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +201 -201
  3. data/README.md +611 -602
  4. data/docs/AffiliateApi.md +455 -455
  5. data/docs/AutoOrderApi.md +1694 -1694
  6. data/docs/BulkApi.md +335 -335
  7. data/docs/ChannelPartnerApi.md +1678 -1678
  8. data/docs/CheckoutApi.md +1622 -1622
  9. data/docs/ConversationApi.md +7867 -7867
  10. data/docs/ConversationEmbedApi.md +226 -226
  11. data/docs/CouponApi.md +1522 -1522
  12. data/docs/CustomerApi.md +2849 -2849
  13. data/docs/DatawarehouseApi.md +1637 -1637
  14. data/docs/EmailCommseqEmailReviewStatus.md +32 -0
  15. data/docs/EmailCommseqEmailReviewStatusResponse.md +26 -0
  16. data/docs/EmailCommseqEmailReviewStatusesRequest.md +18 -0
  17. data/docs/EmailCommseqEmailReviewStatusesResponse.md +26 -0
  18. data/docs/FraudApi.md +332 -332
  19. data/docs/FulfillmentApi.md +567 -567
  20. data/docs/GiftCertificateApi.md +617 -617
  21. data/docs/IntegrationLogApi.md +290 -290
  22. data/docs/ItemApi.md +2502 -2502
  23. data/docs/OauthApi.md +311 -311
  24. data/docs/OrderApi.md +3396 -3396
  25. data/docs/SfvbApi.md +3883 -3883
  26. data/docs/SsoApi.md +223 -223
  27. data/docs/StorefrontApi.md +10143 -10035
  28. data/docs/TaxApi.md +1699 -1699
  29. data/docs/UserApi.md +606 -606
  30. data/docs/WebhookApi.md +840 -840
  31. data/docs/WorkflowApi.md +666 -666
  32. data/lib/ultracart_api/api/storefront_api.rb +143 -0
  33. data/lib/ultracart_api/models/email_commseq_email_review_status.rb +324 -0
  34. data/lib/ultracart_api/models/email_commseq_email_review_status_response.rb +256 -0
  35. data/lib/ultracart_api/models/email_commseq_email_review_statuses_request.rb +222 -0
  36. data/lib/ultracart_api/models/email_commseq_email_review_statuses_response.rb +258 -0
  37. data/lib/ultracart_api/version.rb +1 -1
  38. data/lib/ultracart_api.rb +4 -0
  39. metadata +11 -3
data/docs/CheckoutApi.md CHANGED
@@ -1,1622 +1,1622 @@
1
- # UltracartClient::CheckoutApi
2
-
3
- All URIs are relative to *https://secure.ultracart.com/rest/v2*
4
-
5
- | Method | HTTP request | Description |
6
- | ------ | ------------ | ----------- |
7
- | [**city_state**](CheckoutApi.md#city_state) | **POST** /checkout/city_state | City/State for Zip |
8
- | [**finalize_order**](CheckoutApi.md#finalize_order) | **POST** /checkout/cart/finalizeOrder | Finalize Order |
9
- | [**get_affirm_checkout**](CheckoutApi.md#get_affirm_checkout) | **GET** /checkout/cart/{cart_id}/affirmCheckout | Get affirm checkout (by cart id) |
10
- | [**get_allowed_countries**](CheckoutApi.md#get_allowed_countries) | **POST** /checkout/allowedCountries | Allowed countries |
11
- | [**get_cart**](CheckoutApi.md#get_cart) | **GET** /checkout/cart | Get cart |
12
- | [**get_cart_by_cart_id**](CheckoutApi.md#get_cart_by_cart_id) | **GET** /checkout/cart/{cart_id} | Get cart (by cart id) |
13
- | [**get_cart_by_return_code**](CheckoutApi.md#get_cart_by_return_code) | **GET** /checkout/return/{return_code} | Get cart (by return code) |
14
- | [**get_cart_by_return_token**](CheckoutApi.md#get_cart_by_return_token) | **GET** /checkout/return_token | Get cart (by return token) |
15
- | [**get_state_provinces_for_country**](CheckoutApi.md#get_state_provinces_for_country) | **POST** /checkout/stateProvincesForCountry/{country_code} | Get state/province list for a country code |
16
- | [**handoff_cart**](CheckoutApi.md#handoff_cart) | **POST** /checkout/cart/handoff | Handoff cart |
17
- | [**login**](CheckoutApi.md#login) | **POST** /checkout/cart/profile/login | Profile login |
18
- | [**logout**](CheckoutApi.md#logout) | **POST** /checkout/cart/profile/logout | Profile logout |
19
- | [**register**](CheckoutApi.md#register) | **POST** /checkout/cart/profile/register | Profile registration |
20
- | [**register_affiliate_click**](CheckoutApi.md#register_affiliate_click) | **POST** /checkout/affiliateClick/register | Register affiliate click |
21
- | [**related_items_for_cart**](CheckoutApi.md#related_items_for_cart) | **POST** /checkout/related_items | Related items |
22
- | [**related_items_for_item**](CheckoutApi.md#related_items_for_item) | **POST** /checkout/relatedItems/{item_id} | Related items (specific item) |
23
- | [**setup_browser_key**](CheckoutApi.md#setup_browser_key) | **PUT** /checkout/browser_key | Setup Browser Application |
24
- | [**update_cart**](CheckoutApi.md#update_cart) | **PUT** /checkout/cart | Update cart |
25
- | [**validate_cart**](CheckoutApi.md#validate_cart) | **POST** /checkout/cart/validate | Validate |
26
-
27
-
28
- ## city_state
29
-
30
- > <CityStateZip> city_state(cart)
31
-
32
- City/State for Zip
33
-
34
- Look up the city and state for the shipping zip code. Useful for building an auto complete for parts of the shipping address
35
-
36
-
37
- ### Examples
38
-
39
- ```ruby
40
- # Reference Implementation: https://github.com/UltraCart/responsive_checkout
41
- # Takes a postal code and returns back a city and state (US Only)
42
-
43
- require 'ultracart_api'
44
- require_relative '../constants'
45
-
46
- checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
47
-
48
- cart_id = '123456789123456789123456789123456789' # you should have the cart id from session or cookie
49
- cart = UltracartClient::Cart.new
50
- cart.cart_id = cart_id # required
51
- cart.shipping = UltracartClient::CartShipping.new
52
- cart.shipping.postal_code = '44233'
53
-
54
- api_response = checkout_api.city_state(cart)
55
- puts "City: #{api_response.city}"
56
- puts "State: #{api_response.state}"
57
- ```
58
-
59
-
60
- #### Using the city_state_with_http_info variant
61
-
62
- This returns an Array which contains the response data, status code and headers.
63
-
64
- > <Array(<CityStateZip>, Integer, Hash)> city_state_with_http_info(cart)
65
-
66
- ```ruby
67
- begin
68
- # City/State for Zip
69
- data, status_code, headers = api_instance.city_state_with_http_info(cart)
70
- p status_code # => 2xx
71
- p headers # => { ... }
72
- p data # => <CityStateZip>
73
- rescue UltracartClient::ApiError => e
74
- puts "Error when calling CheckoutApi->city_state_with_http_info: #{e}"
75
- end
76
- ```
77
-
78
- ### Parameters
79
-
80
- | Name | Type | Description | Notes |
81
- | ---- | ---- | ----------- | ----- |
82
- | **cart** | [**Cart**](Cart.md) | Cart | |
83
-
84
- ### Return type
85
-
86
- [**CityStateZip**](CityStateZip.md)
87
-
88
- ### Authorization
89
-
90
- [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
91
-
92
- ### HTTP request headers
93
-
94
- - **Content-Type**: application/json
95
- - **Accept**: application/json
96
-
97
-
98
- ## finalize_order
99
-
100
- > <CartFinalizeOrderResponse> finalize_order(finalize_request)
101
-
102
- Finalize Order
103
-
104
- Finalize the cart into an order. This method can not be called with browser key authentication. It is ONLY meant for server side code to call.
105
-
106
-
107
- ### Examples
108
-
109
- ```ruby
110
- require 'ultracart_api'
111
- require_relative '../constants'
112
- # Reference Implementation: https://github.com/UltraCart/responsive_checkout
113
-
114
- # Note: You probably should NOT be using this method. Use handoff_cart() instead.
115
- # This method is a server-side only (no browser key allowed) method for turning a cart into an order.
116
- # It exists for merchants who wish to provide their own upsells, but again, a warning, using this method
117
- # will exclude the customer checkout from a vast and powerful suite of functionality provided free by UltraCart.
118
- # Still, some merchants need this functionality, so here it is. If you're unsure, you don't need it. Use handoff.
119
-
120
- checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
121
-
122
- expansion = "customer_profile,items,billing,shipping,coupons,checkout,payment,summary,taxes"
123
- # Possible Expansion Variables: (see https://www.ultracart.com/api/#resource_checkout.html
124
- # affiliate checkout customer_profile
125
- # billing coupons gift
126
- # gift_certificate items.attributes items.multimedia
127
- # items items.multimedia.thumbnails items.physical
128
- # marketing payment settings.gift
129
- # settings.billing.provinces settings.shipping.deliver_on_date settings.shipping.estimates
130
- # settings.shipping.provinces settings.shipping.ship_on_date settings.taxes
131
- # settings.terms shipping taxes
132
- # summary upsell_after
133
-
134
- cart_id = nil
135
- cart_id = cookies[Constants::CART_ID_COOKIE_NAME] if cookies[Constants::CART_ID_COOKIE_NAME]
136
-
137
- cart = nil
138
- if cart_id.nil?
139
- api_response = checkout_api.get_cart(_expand: expansion)
140
- else
141
- api_response = checkout_api.get_cart_by_cart_id(cart_id, _expand: expansion)
142
- end
143
- cart = api_response.cart
144
-
145
- # TODO - add some items, collect billing and shipping, use hosted fields to collect payment, etc.
146
-
147
- finalize_request = UltracartClient::CartFinalizeOrderRequest.new
148
- finalize_request.cart = cart
149
- finalize_options = UltracartClient::CartFinalizeOrderRequestOptions.new # Lots of options here. Contact support if you're unsure what you need.
150
- finalize_request.options = finalize_options
151
-
152
- api_response = checkout_api.finalize_order(finalize_request)
153
- # api_response.successful
154
- # api_response.errors
155
- # api_response.order_id
156
- # api_response.order
157
-
158
- puts api_response.inspect
159
- ```
160
-
161
-
162
- #### Using the finalize_order_with_http_info variant
163
-
164
- This returns an Array which contains the response data, status code and headers.
165
-
166
- > <Array(<CartFinalizeOrderResponse>, Integer, Hash)> finalize_order_with_http_info(finalize_request)
167
-
168
- ```ruby
169
- begin
170
- # Finalize Order
171
- data, status_code, headers = api_instance.finalize_order_with_http_info(finalize_request)
172
- p status_code # => 2xx
173
- p headers # => { ... }
174
- p data # => <CartFinalizeOrderResponse>
175
- rescue UltracartClient::ApiError => e
176
- puts "Error when calling CheckoutApi->finalize_order_with_http_info: #{e}"
177
- end
178
- ```
179
-
180
- ### Parameters
181
-
182
- | Name | Type | Description | Notes |
183
- | ---- | ---- | ----------- | ----- |
184
- | **finalize_request** | [**CartFinalizeOrderRequest**](CartFinalizeOrderRequest.md) | Finalize request | |
185
-
186
- ### Return type
187
-
188
- [**CartFinalizeOrderResponse**](CartFinalizeOrderResponse.md)
189
-
190
- ### Authorization
191
-
192
- [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
193
-
194
- ### HTTP request headers
195
-
196
- - **Content-Type**: application/json
197
- - **Accept**: application/json
198
-
199
-
200
- ## get_affirm_checkout
201
-
202
- > <CartAffirmCheckoutResponse> get_affirm_checkout(cart_id)
203
-
204
- Get affirm checkout (by cart id)
205
-
206
- Get a Affirm checkout object for the specified cart_id parameter.
207
-
208
-
209
- ### Examples
210
-
211
- ```ruby
212
- # Reference Implementation: https://github.com/UltraCart/responsive_checkout
213
- # For a given cart id (the cart should be fully updated in UltraCart), returns back the json object
214
- # needed to proceed with an Affirm checkout. See https://www.affirm.com/ for details about Affirm.
215
- # This sample does not show the construction of the affirm checkout widgets. See the affirm api for those examples.
216
-
217
- require 'ultracart_api'
218
- require_relative '../constants'
219
-
220
- checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
221
- cart_id = '123456789123456789123456789123456789' # this should be retrieved from a session or cookie
222
- api_response = checkout_api.get_affirm_checkout(cart_id)
223
- if !api_response.errors.nil? && api_response.errors.length > 0
224
- # TODO: display errors to customer about the failure
225
- api_response.errors.each do |error|
226
- puts error.inspect
227
- end
228
- else
229
- puts api_response.checkout_json.inspect # this is the object to send to Affirm.
230
- end
231
- ```
232
-
233
-
234
- #### Using the get_affirm_checkout_with_http_info variant
235
-
236
- This returns an Array which contains the response data, status code and headers.
237
-
238
- > <Array(<CartAffirmCheckoutResponse>, Integer, Hash)> get_affirm_checkout_with_http_info(cart_id)
239
-
240
- ```ruby
241
- begin
242
- # Get affirm checkout (by cart id)
243
- data, status_code, headers = api_instance.get_affirm_checkout_with_http_info(cart_id)
244
- p status_code # => 2xx
245
- p headers # => { ... }
246
- p data # => <CartAffirmCheckoutResponse>
247
- rescue UltracartClient::ApiError => e
248
- puts "Error when calling CheckoutApi->get_affirm_checkout_with_http_info: #{e}"
249
- end
250
- ```
251
-
252
- ### Parameters
253
-
254
- | Name | Type | Description | Notes |
255
- | ---- | ---- | ----------- | ----- |
256
- | **cart_id** | **String** | Cart ID to retrieve | |
257
-
258
- ### Return type
259
-
260
- [**CartAffirmCheckoutResponse**](CartAffirmCheckoutResponse.md)
261
-
262
- ### Authorization
263
-
264
- [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
265
-
266
- ### HTTP request headers
267
-
268
- - **Content-Type**: Not defined
269
- - **Accept**: application/json
270
-
271
-
272
- ## get_allowed_countries
273
-
274
- > <CheckoutAllowedCountriesResponse> get_allowed_countries
275
-
276
- Allowed countries
277
-
278
- Lookup the allowed countries for this merchant id
279
-
280
-
281
- ### Examples
282
-
283
- ```ruby
284
- # Reference Implementation: https://github.com/UltraCart/responsive_checkout
285
- # A simple method for populating the country list boxes with all the countries this merchant has configured to accept.
286
-
287
- require 'ultracart_api'
288
- require_relative '../constants'
289
-
290
- checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
291
-
292
- api_response = checkout_api.get_allowed_countries
293
- allowed_countries = api_response.countries
294
-
295
- allowed_countries.each do |country|
296
- puts country.inspect # contains both iso2code and name
297
- end
298
- ```
299
-
300
-
301
- #### Using the get_allowed_countries_with_http_info variant
302
-
303
- This returns an Array which contains the response data, status code and headers.
304
-
305
- > <Array(<CheckoutAllowedCountriesResponse>, Integer, Hash)> get_allowed_countries_with_http_info
306
-
307
- ```ruby
308
- begin
309
- # Allowed countries
310
- data, status_code, headers = api_instance.get_allowed_countries_with_http_info
311
- p status_code # => 2xx
312
- p headers # => { ... }
313
- p data # => <CheckoutAllowedCountriesResponse>
314
- rescue UltracartClient::ApiError => e
315
- puts "Error when calling CheckoutApi->get_allowed_countries_with_http_info: #{e}"
316
- end
317
- ```
318
-
319
- ### Parameters
320
-
321
- This endpoint does not need any parameter.
322
-
323
- ### Return type
324
-
325
- [**CheckoutAllowedCountriesResponse**](CheckoutAllowedCountriesResponse.md)
326
-
327
- ### Authorization
328
-
329
- [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
330
-
331
- ### HTTP request headers
332
-
333
- - **Content-Type**: Not defined
334
- - **Accept**: application/json
335
-
336
-
337
- ## get_cart
338
-
339
- > <CartResponse> get_cart(opts)
340
-
341
- Get cart
342
-
343
- If the cookie is set on the browser making the request then it will return their active cart. Otherwise it will create a new cart.
344
-
345
-
346
- ### Examples
347
-
348
- ```ruby
349
- # frozen_string_literal: true
350
-
351
- require 'json'
352
- require 'yaml'
353
- require 'ultracart_api'
354
- require_relative '../constants'
355
-
356
- api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY, Constants::VERIFY_SSL, Constants::DEBUG_MODE)
357
-
358
- # this example is the same for both get_cart.rb and get_cart_by_id.rb. They work as a pair and are called
359
- # depending on the presence of an existing cart id or not. For new carts, getCart() is used. For existing
360
- # carts, getCartByCartId(cart_id) is used.
361
-
362
- expansion = 'items' # for this example, we're just getting a cart to insert some items into it.
363
-
364
- # do you have the cart id from a cookie or some other server side state engine?
365
- cart_id = nil
366
- # run this example once to get a cart id, then you can add it here to test.
367
- # the cart id below will not work for you.
368
- # cart_id = 'C6A8693A3C78C6017FDA7A50EE380100'
369
-
370
- api_response = if cart_id.nil?
371
- api.get_cart({ '_expand': expansion })
372
- else
373
- api.get_cart_by_cart_id(cart_id, { '_expand': expansion })
374
- end
375
-
376
- cart = api_response.cart
377
-
378
- puts cart.to_yaml
379
- ```
380
-
381
-
382
- #### Using the get_cart_with_http_info variant
383
-
384
- This returns an Array which contains the response data, status code and headers.
385
-
386
- > <Array(<CartResponse>, Integer, Hash)> get_cart_with_http_info(opts)
387
-
388
- ```ruby
389
- begin
390
- # Get cart
391
- data, status_code, headers = api_instance.get_cart_with_http_info(opts)
392
- p status_code # => 2xx
393
- p headers # => { ... }
394
- p data # => <CartResponse>
395
- rescue UltracartClient::ApiError => e
396
- puts "Error when calling CheckoutApi->get_cart_with_http_info: #{e}"
397
- end
398
- ```
399
-
400
- ### Parameters
401
-
402
- | Name | Type | Description | Notes |
403
- | ---- | ---- | ----------- | ----- |
404
- | **_expand** | **String** | The object expansion to perform on the result. See documentation for examples | [optional] |
405
-
406
- ### Return type
407
-
408
- [**CartResponse**](CartResponse.md)
409
-
410
- ### Authorization
411
-
412
- [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
413
-
414
- ### HTTP request headers
415
-
416
- - **Content-Type**: Not defined
417
- - **Accept**: application/json
418
-
419
-
420
- ## get_cart_by_cart_id
421
-
422
- > <CartResponse> get_cart_by_cart_id(cart_id, opts)
423
-
424
- Get cart (by cart id)
425
-
426
- Get a cart specified by the cart_id parameter.
427
-
428
-
429
- ### Examples
430
-
431
- ```ruby
432
- # frozen_string_literal: true
433
-
434
- require 'json'
435
- require 'yaml'
436
- require 'ultracart_api'
437
- require_relative '../constants'
438
-
439
- api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY, Constants::VERIFY_SSL, Constants::DEBUG_MODE)
440
-
441
- # this example is the same for both get_cart.rb and get_cart_by_id.rb. They work as a pair and are called
442
- # depending on the presence of an existing cart id or not. For new carts, getCart() is used. For existing
443
- # carts, getCartByCartId(cart_id) is used.
444
-
445
- expansion = 'items' # for this example, we're just getting a cart to insert some items into it.
446
-
447
- # do you have the cart id from a cookie or some other server side state engine?
448
- cart_id = nil
449
- # run this example once to get a cart id, then you can add it here to test.
450
- # the cart id below will not work for you.
451
- # cart_id = 'C6A8693A3C78C6017FDA7A50EE380100'
452
-
453
- api_response = if cart_id.nil?
454
- api.get_cart({ '_expand': expansion })
455
- else
456
- api.get_cart_by_cart_id(cart_id, { '_expand': expansion })
457
- end
458
-
459
- cart = api_response.cart
460
-
461
- puts cart.to_yaml
462
- ```
463
-
464
-
465
- #### Using the get_cart_by_cart_id_with_http_info variant
466
-
467
- This returns an Array which contains the response data, status code and headers.
468
-
469
- > <Array(<CartResponse>, Integer, Hash)> get_cart_by_cart_id_with_http_info(cart_id, opts)
470
-
471
- ```ruby
472
- begin
473
- # Get cart (by cart id)
474
- data, status_code, headers = api_instance.get_cart_by_cart_id_with_http_info(cart_id, opts)
475
- p status_code # => 2xx
476
- p headers # => { ... }
477
- p data # => <CartResponse>
478
- rescue UltracartClient::ApiError => e
479
- puts "Error when calling CheckoutApi->get_cart_by_cart_id_with_http_info: #{e}"
480
- end
481
- ```
482
-
483
- ### Parameters
484
-
485
- | Name | Type | Description | Notes |
486
- | ---- | ---- | ----------- | ----- |
487
- | **cart_id** | **String** | Cart ID to retrieve | |
488
- | **_expand** | **String** | The object expansion to perform on the result. See documentation for examples | [optional] |
489
-
490
- ### Return type
491
-
492
- [**CartResponse**](CartResponse.md)
493
-
494
- ### Authorization
495
-
496
- [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
497
-
498
- ### HTTP request headers
499
-
500
- - **Content-Type**: Not defined
501
- - **Accept**: application/json
502
-
503
-
504
- ## get_cart_by_return_code
505
-
506
- > <CartResponse> get_cart_by_return_code(return_code, opts)
507
-
508
- Get cart (by return code)
509
-
510
- Get a cart specified by the return code parameter.
511
-
512
-
513
- ### Examples
514
-
515
- ```ruby
516
- # Reference Implementation: https://github.com/UltraCart/responsive_checkout
517
-
518
- # this example returns a shopping cart given a return_code. The return_code is generated by UltraCart
519
- # and usually emailed to a customer. The email will provide a link to this script where you may use the
520
- # return_code to retrieve the customer's cart.
521
-
522
- require 'ultracart_api'
523
- require_relative '../constants'
524
-
525
- checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
526
-
527
- expansion = "items,billing,shipping,coupons,checkout,payment,summary,taxes"
528
- # Possible Expansion Variables: (see https://www.ultracart.com/api/#resource_checkout.html
529
- # affiliate checkout customer_profile
530
- # billing coupons gift
531
- # gift_certificate items.attributes items.multimedia
532
- # items items.multimedia.thumbnails items.physical
533
- # marketing payment settings.gift
534
- # settings.billing.provinces settings.shipping.deliver_on_date settings.shipping.estimates
535
- # settings.shipping.provinces settings.shipping.ship_on_date settings.taxes
536
- # settings.terms shipping taxes
537
- # summary upsell_after
538
-
539
- return_code = '1234567890' # usually retrieved from a query parameter
540
- api_response = checkout_api.get_cart_by_return_code(return_code, _expand: expansion)
541
- cart = api_response.cart
542
-
543
- # TODO: set or re-set the cart cookie if this is part of a multi-page process. two weeks is a generous cart id time.
544
- cookies[Constants::CART_ID_COOKIE_NAME] = { value: cart.cart_id, expires: Time.now + 1209600, path: "/" }
545
-
546
- puts cart.inspect
547
- ```
548
-
549
-
550
- #### Using the get_cart_by_return_code_with_http_info variant
551
-
552
- This returns an Array which contains the response data, status code and headers.
553
-
554
- > <Array(<CartResponse>, Integer, Hash)> get_cart_by_return_code_with_http_info(return_code, opts)
555
-
556
- ```ruby
557
- begin
558
- # Get cart (by return code)
559
- data, status_code, headers = api_instance.get_cart_by_return_code_with_http_info(return_code, opts)
560
- p status_code # => 2xx
561
- p headers # => { ... }
562
- p data # => <CartResponse>
563
- rescue UltracartClient::ApiError => e
564
- puts "Error when calling CheckoutApi->get_cart_by_return_code_with_http_info: #{e}"
565
- end
566
- ```
567
-
568
- ### Parameters
569
-
570
- | Name | Type | Description | Notes |
571
- | ---- | ---- | ----------- | ----- |
572
- | **return_code** | **String** | Return code to lookup cart ID by | |
573
- | **_expand** | **String** | The object expansion to perform on the result. See documentation for examples | [optional] |
574
-
575
- ### Return type
576
-
577
- [**CartResponse**](CartResponse.md)
578
-
579
- ### Authorization
580
-
581
- [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
582
-
583
- ### HTTP request headers
584
-
585
- - **Content-Type**: Not defined
586
- - **Accept**: application/json
587
-
588
-
589
- ## get_cart_by_return_token
590
-
591
- > <CartResponse> get_cart_by_return_token(opts)
592
-
593
- Get cart (by return token)
594
-
595
- Get a cart specified by the encrypted return token parameter.
596
-
597
-
598
- ### Examples
599
-
600
- ```ruby
601
- # Reference Implementation: https://github.com/UltraCart/responsive_checkout
602
-
603
- # this example returns a shopping cart given a return_token. The return token is generated by StoreFront Communications
604
- # and usually emailed to a customer. The link within the email will (when you configure your storefront communications)
605
- # provide a link to this script where you may use the token to retrieve the customer's cart.
606
-
607
- require 'ultracart_api'
608
- require_relative '../constants'
609
-
610
- checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
611
-
612
- expansion = "items,billing,shipping,coupons,checkout,payment,summary,taxes"
613
- # Possible Expansion Variables: (see https://www.ultracart.com/api/#resource_checkout.html
614
- # affiliate checkout customer_profile
615
- # billing coupons gift
616
- # gift_certificate items.attributes items.multimedia
617
- # items items.multimedia.thumbnails items.physical
618
- # marketing payment settings.gift
619
- # settings.billing.provinces settings.shipping.deliver_on_date settings.shipping.estimates
620
- # settings.shipping.provinces settings.shipping.ship_on_date settings.taxes
621
- # settings.terms shipping taxes
622
- # summary upsell_after
623
-
624
- cart_token = '1234567890' # usually retrieved from a query parameter
625
- api_response = checkout_api.get_cart_by_return_token(cart_token, _expand: expansion)
626
- cart = api_response.cart
627
-
628
- # TODO: set or re-set the cart cookie if this is part of a multi-page process. two weeks is a generous cart id time.
629
- cookies[Constants::CART_ID_COOKIE_NAME] = { value: cart.cart_id, expires: Time.now + 1209600, path: "/" }
630
-
631
- puts cart.inspect
632
- ```
633
-
634
-
635
- #### Using the get_cart_by_return_token_with_http_info variant
636
-
637
- This returns an Array which contains the response data, status code and headers.
638
-
639
- > <Array(<CartResponse>, Integer, Hash)> get_cart_by_return_token_with_http_info(opts)
640
-
641
- ```ruby
642
- begin
643
- # Get cart (by return token)
644
- data, status_code, headers = api_instance.get_cart_by_return_token_with_http_info(opts)
645
- p status_code # => 2xx
646
- p headers # => { ... }
647
- p data # => <CartResponse>
648
- rescue UltracartClient::ApiError => e
649
- puts "Error when calling CheckoutApi->get_cart_by_return_token_with_http_info: #{e}"
650
- end
651
- ```
652
-
653
- ### Parameters
654
-
655
- | Name | Type | Description | Notes |
656
- | ---- | ---- | ----------- | ----- |
657
- | **return_token** | **String** | Return token provided by StoreFront Communications | [optional] |
658
- | **_expand** | **String** | The object expansion to perform on the result. See documentation for examples | [optional] |
659
-
660
- ### Return type
661
-
662
- [**CartResponse**](CartResponse.md)
663
-
664
- ### Authorization
665
-
666
- [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
667
-
668
- ### HTTP request headers
669
-
670
- - **Content-Type**: Not defined
671
- - **Accept**: application/json
672
-
673
-
674
- ## get_state_provinces_for_country
675
-
676
- > <CheckoutStateProvinceResponse> get_state_provinces_for_country(country_code)
677
-
678
- Get state/province list for a country code
679
-
680
- Lookup a state/province list for a given country code
681
-
682
-
683
- ### Examples
684
-
685
- ```ruby
686
- # Reference Implementation: https://github.com/UltraCart/responsive_checkout
687
- # A simple method for populating the state_region list boxes with all the states/regions allowed for a country code.
688
-
689
- require 'ultracart_api'
690
- require_relative '../constants'
691
-
692
- checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
693
-
694
- country_code = 'US'
695
-
696
- api_response = checkout_api.get_state_provinces_for_country(country_code)
697
- provinces = api_response.state_provinces
698
-
699
- provinces.each do |province|
700
- puts province.inspect # contains both name and abbreviation
701
- end
702
- ```
703
-
704
-
705
- #### Using the get_state_provinces_for_country_with_http_info variant
706
-
707
- This returns an Array which contains the response data, status code and headers.
708
-
709
- > <Array(<CheckoutStateProvinceResponse>, Integer, Hash)> get_state_provinces_for_country_with_http_info(country_code)
710
-
711
- ```ruby
712
- begin
713
- # Get state/province list for a country code
714
- data, status_code, headers = api_instance.get_state_provinces_for_country_with_http_info(country_code)
715
- p status_code # => 2xx
716
- p headers # => { ... }
717
- p data # => <CheckoutStateProvinceResponse>
718
- rescue UltracartClient::ApiError => e
719
- puts "Error when calling CheckoutApi->get_state_provinces_for_country_with_http_info: #{e}"
720
- end
721
- ```
722
-
723
- ### Parameters
724
-
725
- | Name | Type | Description | Notes |
726
- | ---- | ---- | ----------- | ----- |
727
- | **country_code** | **String** | Two letter ISO country code | |
728
-
729
- ### Return type
730
-
731
- [**CheckoutStateProvinceResponse**](CheckoutStateProvinceResponse.md)
732
-
733
- ### Authorization
734
-
735
- [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
736
-
737
- ### HTTP request headers
738
-
739
- - **Content-Type**: Not defined
740
- - **Accept**: application/json
741
-
742
-
743
- ## handoff_cart
744
-
745
- > <CheckoutHandoffResponse> handoff_cart(handoff_request, opts)
746
-
747
- Handoff cart
748
-
749
- Handoff the browser to UltraCart for view cart on StoreFront, transfer to PayPal, transfer to Affirm, transfer to Sezzle or finalization of the order (including upsell processing).
750
-
751
-
752
- ### Examples
753
-
754
- ```ruby
755
- require 'ultracart_api'
756
- require_relative '../constants'
757
-
758
- # Reference Implementation: https://github.com/UltraCart/responsive_checkout
759
-
760
- # This example uses the get_cart.rb code as a starting point because we must get a cart to hand off a cart.
761
- # Here, we are handing off the cart to the UltraCart engine with an operation of 'view', meaning that we
762
- # simply added some items to the cart and wish for UltraCart to gather the remaining customer information
763
- # as part of a normal checkout operation.
764
- # Valid operations are: "view", "checkout", "paypal", "paypalcredit", "affirm", "sezzle"
765
- # Besides "view", the other operations are finalizers.
766
- # "checkout": Finalize the transaction using a customer's personal credit card (traditional checkout)
767
- # "paypal": Finalize the transaction by sending the customer to PayPal
768
-
769
- # get_cart.rb code start ----------------------------------------------------------------------------
770
-
771
- # This example is the same for both get_cart.rb and get_cart_by_cart_id.rb. They work as a pair and are called
772
- # depending on the presence of an existing cart ID or not. For new carts, get_cart() is used. For existing
773
- # carts, get_cart_by_cart_id(cart_id) is used.
774
-
775
- checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
776
-
777
- expansion = "items" # For this example, we're just getting a cart to insert some items into it.
778
-
779
- cart_id = nil
780
- cart_id = ENV['HTTP_COOKIE'].scan(/UltraCartShoppingCartID=([^;]+)/).flatten.first if ENV['HTTP_COOKIE']
781
-
782
- cart = nil
783
- if cart_id.nil?
784
- api_response = checkout_api.get_cart(expansion: expansion)
785
- else
786
- api_response = checkout_api.get_cart_by_cart_id(cart_id, expansion: expansion)
787
- end
788
- cart = api_response.cart
789
-
790
- # get_cart.rb code end ----------------------------------------------------------------------------
791
-
792
- # Although the above code checks for a cookie and retrieves or creates a cart based on the cookie presence, typically
793
- # a Ruby script calling the handoff() method will have an existing cart, so you may wish to check for a cookie and
794
- # redirect if there isn't one. However, it is possible that you wish to create a cart, update it, and hand it off
795
- # to UltraCart all within one script, so we've left the conditional cart creation calls intact.
796
-
797
- handoff_request = UltracartClient::CheckoutHandoffRequest.new
798
- handoff_request.cart = cart
799
- handoff_request.operation = "view"
800
- handoff_request.error_return_url = "/some/page/on/this/ruby/server/that/can/handle/errors/if/ultracart/encounters/an/issue/with/this/cart.rb"
801
- handoff_request.error_parameter_name = "uc_error" # Name this whatever the script supplied in ->setErrorReturnUrl() will check for in the params.
802
- handoff_request.secure_host_name = "mystorefront.com" # Set to desired storefront. Some merchants have multiple storefronts.
803
-
804
- api_response = checkout_api.handoff_cart(handoff_request, { '_expand' => expansion })
805
-
806
- if !api_response.errors.nil? && !api_response.errors.empty?
807
- # TODO: Handle errors that might happen before handoff and manage those
808
- else
809
- redirect_url = api_response.redirect_to_url
810
- puts "Location: #{redirect_url}\n\n"
811
- end
812
- ```
813
-
814
-
815
- #### Using the handoff_cart_with_http_info variant
816
-
817
- This returns an Array which contains the response data, status code and headers.
818
-
819
- > <Array(<CheckoutHandoffResponse>, Integer, Hash)> handoff_cart_with_http_info(handoff_request, opts)
820
-
821
- ```ruby
822
- begin
823
- # Handoff cart
824
- data, status_code, headers = api_instance.handoff_cart_with_http_info(handoff_request, opts)
825
- p status_code # => 2xx
826
- p headers # => { ... }
827
- p data # => <CheckoutHandoffResponse>
828
- rescue UltracartClient::ApiError => e
829
- puts "Error when calling CheckoutApi->handoff_cart_with_http_info: #{e}"
830
- end
831
- ```
832
-
833
- ### Parameters
834
-
835
- | Name | Type | Description | Notes |
836
- | ---- | ---- | ----------- | ----- |
837
- | **handoff_request** | [**CheckoutHandoffRequest**](CheckoutHandoffRequest.md) | Handoff request | |
838
- | **_expand** | **String** | The object expansion to perform on the result. See documentation for examples | [optional] |
839
-
840
- ### Return type
841
-
842
- [**CheckoutHandoffResponse**](CheckoutHandoffResponse.md)
843
-
844
- ### Authorization
845
-
846
- [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
847
-
848
- ### HTTP request headers
849
-
850
- - **Content-Type**: application/json
851
- - **Accept**: application/json
852
-
853
-
854
- ## login
855
-
856
- > <CartProfileLoginResponse> login(login_request, opts)
857
-
858
- Profile login
859
-
860
- Login in to the customer profile specified by cart.billing.email and password
861
-
862
-
863
- ### Examples
864
-
865
- ```ruby
866
- require 'ultracart_api'
867
- require_relative '../constants'
868
-
869
- # Reference Implementation: https://github.com/UltraCart/responsive_checkout
870
-
871
- # This example logs a user into the UltraCart system.
872
- # This example assumes you already have a shopping cart object created.
873
- # For new carts, get_cart() is used. For existing carts, get_cart_by_cart_id(cart_id) is used.
874
-
875
- checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
876
-
877
- # Note: customer_profile is a required expansion for login to work properly
878
- expansion = "customer_profile,items,billing,shipping,coupons,checkout,payment,summary,taxes"
879
- # Possible Expansion Variables: (see https://www.ultracart.com/api/#resource_checkout.html)
880
-
881
- # Create a new cart (change this to an existing if you have one)
882
- cart = checkout_api.get_cart(expansion: expansion).cart
883
-
884
- email = 'test@test.com' # Collect this from user.
885
- password = 'ABC123' # Collect this from user.
886
-
887
- cart.billing = UltracartClient::CartBilling.new
888
- cart.billing.email = email
889
-
890
- login_request = UltracartClient::CartProfileLoginRequest.new
891
- login_request.cart = cart # Will look for billing.email
892
- login_request.password = password
893
-
894
- api_response = checkout_api.login(login_request)
895
- cart = api_response.cart
896
-
897
- if api_response.success
898
- # Proceed with successful login.
899
- else
900
- # Notify customer login failed.
901
- end
902
- ```
903
-
904
-
905
- #### Using the login_with_http_info variant
906
-
907
- This returns an Array which contains the response data, status code and headers.
908
-
909
- > <Array(<CartProfileLoginResponse>, Integer, Hash)> login_with_http_info(login_request, opts)
910
-
911
- ```ruby
912
- begin
913
- # Profile login
914
- data, status_code, headers = api_instance.login_with_http_info(login_request, opts)
915
- p status_code # => 2xx
916
- p headers # => { ... }
917
- p data # => <CartProfileLoginResponse>
918
- rescue UltracartClient::ApiError => e
919
- puts "Error when calling CheckoutApi->login_with_http_info: #{e}"
920
- end
921
- ```
922
-
923
- ### Parameters
924
-
925
- | Name | Type | Description | Notes |
926
- | ---- | ---- | ----------- | ----- |
927
- | **login_request** | [**CartProfileLoginRequest**](CartProfileLoginRequest.md) | Login request | |
928
- | **_expand** | **String** | The object expansion to perform on the result. See documentation for examples | [optional] |
929
-
930
- ### Return type
931
-
932
- [**CartProfileLoginResponse**](CartProfileLoginResponse.md)
933
-
934
- ### Authorization
935
-
936
- [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
937
-
938
- ### HTTP request headers
939
-
940
- - **Content-Type**: application/json
941
- - **Accept**: application/json
942
-
943
-
944
- ## logout
945
-
946
- > <CartResponse> logout(cart, opts)
947
-
948
- Profile logout
949
-
950
- Log the cart out of the current profile. No error will occur if they are not logged in.
951
-
952
-
953
- ### Examples
954
-
955
- ```ruby
956
- require 'ultracart_api'
957
- require_relative '../constants'
958
-
959
- # Reference Implementation: https://github.com/UltraCart/responsive_checkout
960
-
961
- # This example logs a user OUT of the UltraCart system.
962
- # It assumes the shopping cart has already had a successful login.
963
- # See login sdk_sample for logging in help.
964
- # For new carts, get_cart() is used. For existing carts, get_cart_by_cart_id(cart_id) is used.
965
-
966
- checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
967
-
968
- # Note: customer_profile is a required expansion for login to work properly
969
- expansion = "customer_profile,items,billing,shipping,coupons,checkout,payment,summary,taxes"
970
- # Possible Expansion Variables: (see https://www.ultracart.com/api/#resource_checkout.html)
971
-
972
- # Create a new cart (change this to an existing if you have one)
973
- cart = checkout_api.get_cart(expansion: expansion).cart
974
-
975
- email = 'test@test.com' # Collect this from user.
976
- password = 'ABC123' # Collect this from user.
977
-
978
- cart.billing = UltracartClient::CartBilling.new
979
- cart.billing.email = email
980
-
981
- login_request = UltracartClient::CartProfileLoginRequest.new
982
- login_request.cart = cart # Will look for billing.email
983
- login_request.password = password
984
-
985
- api_response = checkout_api.login(login_request)
986
- cart = api_response.cart
987
-
988
- if api_response.success
989
- checkout_api.logout(cart, { '_expand' => expansion }) # <-- Here is the logout call.
990
- else
991
- # Notify customer login failed. Until they log in, you can't log them out.
992
- end
993
- ```
994
-
995
-
996
- #### Using the logout_with_http_info variant
997
-
998
- This returns an Array which contains the response data, status code and headers.
999
-
1000
- > <Array(<CartResponse>, Integer, Hash)> logout_with_http_info(cart, opts)
1001
-
1002
- ```ruby
1003
- begin
1004
- # Profile logout
1005
- data, status_code, headers = api_instance.logout_with_http_info(cart, opts)
1006
- p status_code # => 2xx
1007
- p headers # => { ... }
1008
- p data # => <CartResponse>
1009
- rescue UltracartClient::ApiError => e
1010
- puts "Error when calling CheckoutApi->logout_with_http_info: #{e}"
1011
- end
1012
- ```
1013
-
1014
- ### Parameters
1015
-
1016
- | Name | Type | Description | Notes |
1017
- | ---- | ---- | ----------- | ----- |
1018
- | **cart** | [**Cart**](Cart.md) | Cart | |
1019
- | **_expand** | **String** | The object expansion to perform on the result. See documentation for examples | [optional] |
1020
-
1021
- ### Return type
1022
-
1023
- [**CartResponse**](CartResponse.md)
1024
-
1025
- ### Authorization
1026
-
1027
- [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
1028
-
1029
- ### HTTP request headers
1030
-
1031
- - **Content-Type**: application/json
1032
- - **Accept**: application/json
1033
-
1034
-
1035
- ## register
1036
-
1037
- > <CartProfileRegisterResponse> register(register_request, opts)
1038
-
1039
- Profile registration
1040
-
1041
- Register a new customer profile. Requires the cart.billing object to be populated along with the password.
1042
-
1043
-
1044
- ### Examples
1045
-
1046
- ```ruby
1047
- require 'ultracart_api'
1048
- require_relative '../constants'
1049
-
1050
- # Reference Implementation: https://github.com/UltraCart/responsive_checkout
1051
-
1052
- # Registers a user in your merchant system. This will create a customer profile.
1053
- # For new carts, get_cart() is used. For existing carts, get_cart_by_cart_id(cart_id) is used.
1054
-
1055
- checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
1056
-
1057
- # Note: customer_profile is a required expansion for login to work properly
1058
- expansion = "customer_profile,items,billing,shipping,coupons,checkout,payment,summary,taxes"
1059
- # Possible Expansion Variables: (see https://www.ultracart.com/api/#resource_checkout.html)
1060
-
1061
- # Create a new cart (change this to an existing if you have one)
1062
- cart = checkout_api.get_cart(expansion: expansion).cart
1063
-
1064
- email = 'test@test.com' # Collect this from user.
1065
- password = 'ABC123' # Collect this from user.
1066
-
1067
- cart.billing = UltracartClient::CartBilling.new
1068
- cart.billing.email = email # This is the username.
1069
-
1070
- register_request = UltracartClient::CartProfileRegisterRequest.new
1071
- register_request.cart = cart # Will look for billing.email
1072
- register_request.password = password
1073
-
1074
- api_response = checkout_api.register(register_request)
1075
- cart = api_response.cart # Important! Get the cart from the response.
1076
-
1077
- if api_response.success
1078
- puts 'Successfully registered new customer profile!'
1079
- else
1080
- api_response.errors.each { |error| puts error.inspect }
1081
- end
1082
- ```
1083
-
1084
-
1085
- #### Using the register_with_http_info variant
1086
-
1087
- This returns an Array which contains the response data, status code and headers.
1088
-
1089
- > <Array(<CartProfileRegisterResponse>, Integer, Hash)> register_with_http_info(register_request, opts)
1090
-
1091
- ```ruby
1092
- begin
1093
- # Profile registration
1094
- data, status_code, headers = api_instance.register_with_http_info(register_request, opts)
1095
- p status_code # => 2xx
1096
- p headers # => { ... }
1097
- p data # => <CartProfileRegisterResponse>
1098
- rescue UltracartClient::ApiError => e
1099
- puts "Error when calling CheckoutApi->register_with_http_info: #{e}"
1100
- end
1101
- ```
1102
-
1103
- ### Parameters
1104
-
1105
- | Name | Type | Description | Notes |
1106
- | ---- | ---- | ----------- | ----- |
1107
- | **register_request** | [**CartProfileRegisterRequest**](CartProfileRegisterRequest.md) | Register request | |
1108
- | **_expand** | **String** | The object expansion to perform on the result. See documentation for examples | [optional] |
1109
-
1110
- ### Return type
1111
-
1112
- [**CartProfileRegisterResponse**](CartProfileRegisterResponse.md)
1113
-
1114
- ### Authorization
1115
-
1116
- [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
1117
-
1118
- ### HTTP request headers
1119
-
1120
- - **Content-Type**: application/json
1121
- - **Accept**: application/json
1122
-
1123
-
1124
- ## register_affiliate_click
1125
-
1126
- > <RegisterAffiliateClickResponse> register_affiliate_click(register_affiliate_click_request, opts)
1127
-
1128
- Register affiliate click
1129
-
1130
- Register an affiliate click. Used by custom checkouts that are completely API based and do not perform checkout handoff.
1131
-
1132
-
1133
- ### Examples
1134
-
1135
- ```ruby
1136
- require 'ultracart_api'
1137
- require_relative '../constants'
1138
-
1139
- # Reference Implementation: https://github.com/UltraCart/responsive_checkout
1140
- # Records an affiliate click.
1141
-
1142
- checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
1143
-
1144
- click_request = UltracartClient::RegisterAffiliateClickRequest.new
1145
- click_request.ip_address = ENV['HTTP_X_FORWARDED_FOR'] || ENV['REMOTE_ADDR']
1146
- click_request.user_agent = ENV['HTTP_USER_AGENT'] || ''
1147
- click_request.referrer_url = ENV['HTTP_REFERER'] || ''
1148
- click_request.affid = 123_456_789 # You should know this from your UltraCart affiliate system.
1149
- click_request.subid = 'TODO:SupplyThisValue'
1150
- # click_request.landing_page_url = nil # If you have a landing page URL.
1151
-
1152
- api_response = checkout_api.register_affiliate_click(click_request)
1153
-
1154
- puts api_response.inspect
1155
- ```
1156
-
1157
-
1158
- #### Using the register_affiliate_click_with_http_info variant
1159
-
1160
- This returns an Array which contains the response data, status code and headers.
1161
-
1162
- > <Array(<RegisterAffiliateClickResponse>, Integer, Hash)> register_affiliate_click_with_http_info(register_affiliate_click_request, opts)
1163
-
1164
- ```ruby
1165
- begin
1166
- # Register affiliate click
1167
- data, status_code, headers = api_instance.register_affiliate_click_with_http_info(register_affiliate_click_request, opts)
1168
- p status_code # => 2xx
1169
- p headers # => { ... }
1170
- p data # => <RegisterAffiliateClickResponse>
1171
- rescue UltracartClient::ApiError => e
1172
- puts "Error when calling CheckoutApi->register_affiliate_click_with_http_info: #{e}"
1173
- end
1174
- ```
1175
-
1176
- ### Parameters
1177
-
1178
- | Name | Type | Description | Notes |
1179
- | ---- | ---- | ----------- | ----- |
1180
- | **register_affiliate_click_request** | [**RegisterAffiliateClickRequest**](RegisterAffiliateClickRequest.md) | Register affiliate click request | |
1181
- | **_expand** | **String** | The object expansion to perform on the result. See documentation for examples | [optional] |
1182
-
1183
- ### Return type
1184
-
1185
- [**RegisterAffiliateClickResponse**](RegisterAffiliateClickResponse.md)
1186
-
1187
- ### Authorization
1188
-
1189
- [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
1190
-
1191
- ### HTTP request headers
1192
-
1193
- - **Content-Type**: application/json
1194
- - **Accept**: application/json
1195
-
1196
-
1197
- ## related_items_for_cart
1198
-
1199
- > <ItemsResponse> related_items_for_cart(cart, opts)
1200
-
1201
- Related items
1202
-
1203
- Retrieve all the related items for the cart contents. Expansion is limited to content, content.assignments, content.attributes, content.multimedia, content.multimedia.thumbnails, options, pricing, and pricing.tiers.
1204
-
1205
-
1206
- ### Examples
1207
-
1208
- ```ruby
1209
- require 'ultracart_api'
1210
- require_relative '../constants'
1211
-
1212
- # Reference Implementation: https://github.com/UltraCart/responsive_checkout
1213
- # Retrieves items related to the items within the cart. Item relations are configured in the UltraCart backend.
1214
- # See: https://ultracart.atlassian.net/wiki/spaces/ucdoc/pages/1377171/Related+Items
1215
-
1216
- checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
1217
-
1218
- expansion = 'customer_profile,items,billing,shipping,coupons,checkout,payment,summary,taxes'
1219
-
1220
- cart_id = ENV['HTTP_ULTRACARTSHOPPINGCARTID']
1221
-
1222
- cart = if cart_id.nil?
1223
- checkout_api.get_cart({_expand: expansion}).cart
1224
- else
1225
- checkout_api.get_cart_by_cart_id(cart_id, {_expand: expansion}).cart
1226
- end
1227
-
1228
- # TODO - add some items to the cart and update.
1229
-
1230
- items = []
1231
- cart_item = UltracartClient::CartItem.new
1232
- cart_item.item_id = 'ITEM_ABC'
1233
- cart_item.quantity = 1
1234
- items << cart_item
1235
- cart.items = items
1236
-
1237
- # Update the cart
1238
- cart = checkout_api.update_cart(cart, { '_expand' => expansion }).cart
1239
-
1240
- api_response = checkout_api.related_items_for_cart(cart)
1241
- related_items = api_response.items
1242
-
1243
- puts related_items.inspect
1244
- ```
1245
-
1246
-
1247
- #### Using the related_items_for_cart_with_http_info variant
1248
-
1249
- This returns an Array which contains the response data, status code and headers.
1250
-
1251
- > <Array(<ItemsResponse>, Integer, Hash)> related_items_for_cart_with_http_info(cart, opts)
1252
-
1253
- ```ruby
1254
- begin
1255
- # Related items
1256
- data, status_code, headers = api_instance.related_items_for_cart_with_http_info(cart, opts)
1257
- p status_code # => 2xx
1258
- p headers # => { ... }
1259
- p data # => <ItemsResponse>
1260
- rescue UltracartClient::ApiError => e
1261
- puts "Error when calling CheckoutApi->related_items_for_cart_with_http_info: #{e}"
1262
- end
1263
- ```
1264
-
1265
- ### Parameters
1266
-
1267
- | Name | Type | Description | Notes |
1268
- | ---- | ---- | ----------- | ----- |
1269
- | **cart** | [**Cart**](Cart.md) | Cart | |
1270
- | **_expand** | **String** | The object expansion to perform on the result. See item resource documentation for examples | [optional] |
1271
-
1272
- ### Return type
1273
-
1274
- [**ItemsResponse**](ItemsResponse.md)
1275
-
1276
- ### Authorization
1277
-
1278
- [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
1279
-
1280
- ### HTTP request headers
1281
-
1282
- - **Content-Type**: application/json
1283
- - **Accept**: application/json
1284
-
1285
-
1286
- ## related_items_for_item
1287
-
1288
- > <ItemsResponse> related_items_for_item(item_id, cart, opts)
1289
-
1290
- Related items (specific item)
1291
-
1292
- Retrieve all the related items for the cart contents. Expansion is limited to content, content.assignments, content.attributes, content.multimedia, content.multimedia.thumbnails, options, pricing, and pricing.tiers.
1293
-
1294
-
1295
- ### Examples
1296
-
1297
- ```ruby
1298
- require 'ultracart_api'
1299
- require_relative '../constants'
1300
-
1301
- # Reference Implementation: https://github.com/UltraCart/responsive_checkout
1302
- # Retrieves items related to the items within the cart, in addition to another item ID you supply.
1303
- # Item relations are configured in the UltraCart backend.
1304
- # See: https://ultracart.atlassian.net/wiki/spaces/ucdoc/pages/1377171/Related+Items
1305
-
1306
- checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
1307
-
1308
- expansion = 'customer_profile,items,billing,shipping,coupons,checkout,payment,summary,taxes'
1309
-
1310
- cart_id = ENV['HTTP_ULTRACARTSHOPPINGCARTID']
1311
-
1312
- cart = if cart_id.nil?
1313
- checkout_api.get_cart({_expand: expansion}).cart
1314
- else
1315
- checkout_api.get_cart_by_cart_id(cart_id, {_expand: expansion}).cart
1316
- end
1317
-
1318
- # TODO - add some items to the cart and update.
1319
-
1320
- items = []
1321
- cart_item = UltracartClient::CartItem.new
1322
- cart_item.item_id = 'ITEM_ABC'
1323
- cart_item.quantity = 1
1324
- items << cart_item
1325
- cart.items = items
1326
-
1327
- # Update the cart
1328
- cart = checkout_api.update_cart(cart, { '_expand' => expansion }).cart
1329
-
1330
- another_item_id = 'ITEM_ZZZ'
1331
-
1332
- api_response = checkout_api.related_items_for_item(another_item_id, cart, { '_expand' => expansion })
1333
- related_items = api_response.items
1334
-
1335
- puts related_items.inspect
1336
- ```
1337
-
1338
-
1339
- #### Using the related_items_for_item_with_http_info variant
1340
-
1341
- This returns an Array which contains the response data, status code and headers.
1342
-
1343
- > <Array(<ItemsResponse>, Integer, Hash)> related_items_for_item_with_http_info(item_id, cart, opts)
1344
-
1345
- ```ruby
1346
- begin
1347
- # Related items (specific item)
1348
- data, status_code, headers = api_instance.related_items_for_item_with_http_info(item_id, cart, opts)
1349
- p status_code # => 2xx
1350
- p headers # => { ... }
1351
- p data # => <ItemsResponse>
1352
- rescue UltracartClient::ApiError => e
1353
- puts "Error when calling CheckoutApi->related_items_for_item_with_http_info: #{e}"
1354
- end
1355
- ```
1356
-
1357
- ### Parameters
1358
-
1359
- | Name | Type | Description | Notes |
1360
- | ---- | ---- | ----------- | ----- |
1361
- | **item_id** | **String** | Item ID to retrieve related items for | |
1362
- | **cart** | [**Cart**](Cart.md) | Cart | |
1363
- | **_expand** | **String** | The object expansion to perform on the result. See item resource documentation for examples | [optional] |
1364
-
1365
- ### Return type
1366
-
1367
- [**ItemsResponse**](ItemsResponse.md)
1368
-
1369
- ### Authorization
1370
-
1371
- [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
1372
-
1373
- ### HTTP request headers
1374
-
1375
- - **Content-Type**: application/json
1376
- - **Accept**: application/json
1377
-
1378
-
1379
- ## setup_browser_key
1380
-
1381
- > <CheckoutSetupBrowserKeyResponse> setup_browser_key(browser_key_request)
1382
-
1383
- Setup Browser Application
1384
-
1385
- Setup a browser key authenticated application with checkout permissions. This REST call must be made with an authentication scheme that is not browser key. The new application will be linked to the application that makes this call. If this application is disabled / deleted, then so will the application setup by this call. The purpose of this call is to allow an OAuth application, such as the Wordpress plugin, to setup the proper browser based authentication for the REST checkout API to use.
1386
-
1387
-
1388
- ### Examples
1389
-
1390
- ```ruby
1391
- require 'ultracart_api'
1392
- require_relative '../constants'
1393
-
1394
- # This is a checkout API method. It creates a browser key for use in a client-side checkout.
1395
- # This call must be made server-side with a Simple API Key or an OAuth access token.
1396
-
1397
- checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
1398
-
1399
- key_request = UltracartClient::CheckoutSetupBrowserKeyRequest.new
1400
- key_request.allowed_referrers = ["https://www.mywebsite.com"]
1401
-
1402
- browser_key = checkout_api.setup_browser_key(key_request).browser_key
1403
-
1404
- puts browser_key.inspect
1405
- ```
1406
-
1407
-
1408
- #### Using the setup_browser_key_with_http_info variant
1409
-
1410
- This returns an Array which contains the response data, status code and headers.
1411
-
1412
- > <Array(<CheckoutSetupBrowserKeyResponse>, Integer, Hash)> setup_browser_key_with_http_info(browser_key_request)
1413
-
1414
- ```ruby
1415
- begin
1416
- # Setup Browser Application
1417
- data, status_code, headers = api_instance.setup_browser_key_with_http_info(browser_key_request)
1418
- p status_code # => 2xx
1419
- p headers # => { ... }
1420
- p data # => <CheckoutSetupBrowserKeyResponse>
1421
- rescue UltracartClient::ApiError => e
1422
- puts "Error when calling CheckoutApi->setup_browser_key_with_http_info: #{e}"
1423
- end
1424
- ```
1425
-
1426
- ### Parameters
1427
-
1428
- | Name | Type | Description | Notes |
1429
- | ---- | ---- | ----------- | ----- |
1430
- | **browser_key_request** | [**CheckoutSetupBrowserKeyRequest**](CheckoutSetupBrowserKeyRequest.md) | Setup browser key request | |
1431
-
1432
- ### Return type
1433
-
1434
- [**CheckoutSetupBrowserKeyResponse**](CheckoutSetupBrowserKeyResponse.md)
1435
-
1436
- ### Authorization
1437
-
1438
- [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
1439
-
1440
- ### HTTP request headers
1441
-
1442
- - **Content-Type**: application/json
1443
- - **Accept**: application/json
1444
-
1445
-
1446
- ## update_cart
1447
-
1448
- > <CartResponse> update_cart(cart, opts)
1449
-
1450
- Update cart
1451
-
1452
- Update the cart.
1453
-
1454
-
1455
- ### Examples
1456
-
1457
- ```ruby
1458
- require 'ultracart_api'
1459
- require_relative '../constants'
1460
-
1461
- # Reference Implementation: https://github.com/UltraCart/responsive_checkout
1462
-
1463
- checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
1464
-
1465
- expansion = 'items' # For this example, we're just getting a cart to insert some items into it.
1466
-
1467
- cart_id = nil
1468
- cart_id = ENV['HTTP_COOKIE'].to_s[/#{Constants::CART_ID_COOKIE_NAME}=([^;]+)/, 1] if ENV['HTTP_COOKIE']
1469
-
1470
- cart = if cart_id.nil?
1471
- checkout_api.get_cart({_expand: expansion}).cart
1472
- else
1473
- checkout_api.get_cart_by_cart_id(cart_id, {_expand: expansion}).cart
1474
- end
1475
-
1476
- # Get the items array on the cart, creating it if it doesn't exist.
1477
- items = cart.items || []
1478
-
1479
- # Create a new item
1480
- item = UltracartClient::CartItem.new
1481
- item.item_id = 'BASEBALL' # TODO: Adjust the item id
1482
- item.quantity = 1 # TODO: Adjust the quantity
1483
-
1484
- # TODO: If your item has options, then you need to create a new UltracartClient::CartItemOption object and push it into the array.
1485
- options = []
1486
- item.options = options
1487
-
1488
- # Add the item to the items array
1489
- items << item
1490
-
1491
- # Update the cart with the new items
1492
- cart.items = items
1493
-
1494
- # Push the cart up to save the item
1495
- cart_response = checkout_api.update_cart(cart, {_expand: expansion})
1496
-
1497
- # Extract the updated cart from the response
1498
- cart = cart_response.cart
1499
-
1500
- # TODO: Set or reset the cart cookie if this is part of a multi-page process. Two weeks is a generous cart ID time.
1501
- puts "Set-Cookie: #{Constants::CART_ID_COOKIE_NAME}=#{cart.cart_id}; Path=/; Max-Age=1209600"
1502
-
1503
- puts cart.inspect
1504
- ```
1505
-
1506
-
1507
- #### Using the update_cart_with_http_info variant
1508
-
1509
- This returns an Array which contains the response data, status code and headers.
1510
-
1511
- > <Array(<CartResponse>, Integer, Hash)> update_cart_with_http_info(cart, opts)
1512
-
1513
- ```ruby
1514
- begin
1515
- # Update cart
1516
- data, status_code, headers = api_instance.update_cart_with_http_info(cart, opts)
1517
- p status_code # => 2xx
1518
- p headers # => { ... }
1519
- p data # => <CartResponse>
1520
- rescue UltracartClient::ApiError => e
1521
- puts "Error when calling CheckoutApi->update_cart_with_http_info: #{e}"
1522
- end
1523
- ```
1524
-
1525
- ### Parameters
1526
-
1527
- | Name | Type | Description | Notes |
1528
- | ---- | ---- | ----------- | ----- |
1529
- | **cart** | [**Cart**](Cart.md) | Cart | |
1530
- | **_expand** | **String** | The object expansion to perform on the result. See documentation for examples | [optional] |
1531
-
1532
- ### Return type
1533
-
1534
- [**CartResponse**](CartResponse.md)
1535
-
1536
- ### Authorization
1537
-
1538
- [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
1539
-
1540
- ### HTTP request headers
1541
-
1542
- - **Content-Type**: application/json
1543
- - **Accept**: application/json
1544
-
1545
-
1546
- ## validate_cart
1547
-
1548
- > <CartValidationResponse> validate_cart(validation_request, opts)
1549
-
1550
- Validate
1551
-
1552
- Validate the cart for errors. Specific checks can be passed and multiple validations can occur throughout your checkout flow.
1553
-
1554
-
1555
- ### Examples
1556
-
1557
- ```ruby
1558
- require 'ultracart_api'
1559
- require_relative '../constants'
1560
-
1561
- # Reference Implementation: https://github.com/UltraCart/responsive_checkout
1562
-
1563
- checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
1564
-
1565
- cart_id = '123456789123456789123456789123456789' # Usually this would be retrieved from a session variable or cookie.
1566
-
1567
- expansion = 'items,billing,shipping,coupons,checkout,payment,summary,taxes'
1568
-
1569
- cart = checkout_api.get_cart_by_cart_id(cart_id, {_expand: expansion}).cart
1570
-
1571
- validation_request = UltracartClient::CartValidationRequest.new
1572
- validation_request.cart = cart
1573
-
1574
- # Possible Checks (you can set these as needed, or leave as default):
1575
- # validation_request.set_checks(["All", "Item Quantity Valid", "Payment Information Validate"])
1576
-
1577
- api_response = checkout_api.validate_cart(validation_request, {_expand: expansion})
1578
- cart = api_response.cart
1579
-
1580
- puts "Validation Errors:"
1581
- puts api_response.errors.inspect
1582
- ```
1583
-
1584
-
1585
- #### Using the validate_cart_with_http_info variant
1586
-
1587
- This returns an Array which contains the response data, status code and headers.
1588
-
1589
- > <Array(<CartValidationResponse>, Integer, Hash)> validate_cart_with_http_info(validation_request, opts)
1590
-
1591
- ```ruby
1592
- begin
1593
- # Validate
1594
- data, status_code, headers = api_instance.validate_cart_with_http_info(validation_request, opts)
1595
- p status_code # => 2xx
1596
- p headers # => { ... }
1597
- p data # => <CartValidationResponse>
1598
- rescue UltracartClient::ApiError => e
1599
- puts "Error when calling CheckoutApi->validate_cart_with_http_info: #{e}"
1600
- end
1601
- ```
1602
-
1603
- ### Parameters
1604
-
1605
- | Name | Type | Description | Notes |
1606
- | ---- | ---- | ----------- | ----- |
1607
- | **validation_request** | [**CartValidationRequest**](CartValidationRequest.md) | Validation request | |
1608
- | **_expand** | **String** | The object expansion to perform on the result. See documentation for examples | [optional] |
1609
-
1610
- ### Return type
1611
-
1612
- [**CartValidationResponse**](CartValidationResponse.md)
1613
-
1614
- ### Authorization
1615
-
1616
- [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
1617
-
1618
- ### HTTP request headers
1619
-
1620
- - **Content-Type**: application/json
1621
- - **Accept**: application/json
1622
-
1
+ # UltracartClient::CheckoutApi
2
+
3
+ All URIs are relative to *https://secure.ultracart.com/rest/v2*
4
+
5
+ | Method | HTTP request | Description |
6
+ | ------ | ------------ | ----------- |
7
+ | [**city_state**](CheckoutApi.md#city_state) | **POST** /checkout/city_state | City/State for Zip |
8
+ | [**finalize_order**](CheckoutApi.md#finalize_order) | **POST** /checkout/cart/finalizeOrder | Finalize Order |
9
+ | [**get_affirm_checkout**](CheckoutApi.md#get_affirm_checkout) | **GET** /checkout/cart/{cart_id}/affirmCheckout | Get affirm checkout (by cart id) |
10
+ | [**get_allowed_countries**](CheckoutApi.md#get_allowed_countries) | **POST** /checkout/allowedCountries | Allowed countries |
11
+ | [**get_cart**](CheckoutApi.md#get_cart) | **GET** /checkout/cart | Get cart |
12
+ | [**get_cart_by_cart_id**](CheckoutApi.md#get_cart_by_cart_id) | **GET** /checkout/cart/{cart_id} | Get cart (by cart id) |
13
+ | [**get_cart_by_return_code**](CheckoutApi.md#get_cart_by_return_code) | **GET** /checkout/return/{return_code} | Get cart (by return code) |
14
+ | [**get_cart_by_return_token**](CheckoutApi.md#get_cart_by_return_token) | **GET** /checkout/return_token | Get cart (by return token) |
15
+ | [**get_state_provinces_for_country**](CheckoutApi.md#get_state_provinces_for_country) | **POST** /checkout/stateProvincesForCountry/{country_code} | Get state/province list for a country code |
16
+ | [**handoff_cart**](CheckoutApi.md#handoff_cart) | **POST** /checkout/cart/handoff | Handoff cart |
17
+ | [**login**](CheckoutApi.md#login) | **POST** /checkout/cart/profile/login | Profile login |
18
+ | [**logout**](CheckoutApi.md#logout) | **POST** /checkout/cart/profile/logout | Profile logout |
19
+ | [**register**](CheckoutApi.md#register) | **POST** /checkout/cart/profile/register | Profile registration |
20
+ | [**register_affiliate_click**](CheckoutApi.md#register_affiliate_click) | **POST** /checkout/affiliateClick/register | Register affiliate click |
21
+ | [**related_items_for_cart**](CheckoutApi.md#related_items_for_cart) | **POST** /checkout/related_items | Related items |
22
+ | [**related_items_for_item**](CheckoutApi.md#related_items_for_item) | **POST** /checkout/relatedItems/{item_id} | Related items (specific item) |
23
+ | [**setup_browser_key**](CheckoutApi.md#setup_browser_key) | **PUT** /checkout/browser_key | Setup Browser Application |
24
+ | [**update_cart**](CheckoutApi.md#update_cart) | **PUT** /checkout/cart | Update cart |
25
+ | [**validate_cart**](CheckoutApi.md#validate_cart) | **POST** /checkout/cart/validate | Validate |
26
+
27
+
28
+ ## city_state
29
+
30
+ > <CityStateZip> city_state(cart)
31
+
32
+ City/State for Zip
33
+
34
+ Look up the city and state for the shipping zip code. Useful for building an auto complete for parts of the shipping address
35
+
36
+
37
+ ### Examples
38
+
39
+ ```ruby
40
+ # Reference Implementation: https://github.com/UltraCart/responsive_checkout
41
+ # Takes a postal code and returns back a city and state (US Only)
42
+
43
+ require 'ultracart_api'
44
+ require_relative '../constants'
45
+
46
+ checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
47
+
48
+ cart_id = '123456789123456789123456789123456789' # you should have the cart id from session or cookie
49
+ cart = UltracartClient::Cart.new
50
+ cart.cart_id = cart_id # required
51
+ cart.shipping = UltracartClient::CartShipping.new
52
+ cart.shipping.postal_code = '44233'
53
+
54
+ api_response = checkout_api.city_state(cart)
55
+ puts "City: #{api_response.city}"
56
+ puts "State: #{api_response.state}"
57
+ ```
58
+
59
+
60
+ #### Using the city_state_with_http_info variant
61
+
62
+ This returns an Array which contains the response data, status code and headers.
63
+
64
+ > <Array(<CityStateZip>, Integer, Hash)> city_state_with_http_info(cart)
65
+
66
+ ```ruby
67
+ begin
68
+ # City/State for Zip
69
+ data, status_code, headers = api_instance.city_state_with_http_info(cart)
70
+ p status_code # => 2xx
71
+ p headers # => { ... }
72
+ p data # => <CityStateZip>
73
+ rescue UltracartClient::ApiError => e
74
+ puts "Error when calling CheckoutApi->city_state_with_http_info: #{e}"
75
+ end
76
+ ```
77
+
78
+ ### Parameters
79
+
80
+ | Name | Type | Description | Notes |
81
+ | ---- | ---- | ----------- | ----- |
82
+ | **cart** | [**Cart**](Cart.md) | Cart | |
83
+
84
+ ### Return type
85
+
86
+ [**CityStateZip**](CityStateZip.md)
87
+
88
+ ### Authorization
89
+
90
+ [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
91
+
92
+ ### HTTP request headers
93
+
94
+ - **Content-Type**: application/json
95
+ - **Accept**: application/json
96
+
97
+
98
+ ## finalize_order
99
+
100
+ > <CartFinalizeOrderResponse> finalize_order(finalize_request)
101
+
102
+ Finalize Order
103
+
104
+ Finalize the cart into an order. This method can not be called with browser key authentication. It is ONLY meant for server side code to call.
105
+
106
+
107
+ ### Examples
108
+
109
+ ```ruby
110
+ require 'ultracart_api'
111
+ require_relative '../constants'
112
+ # Reference Implementation: https://github.com/UltraCart/responsive_checkout
113
+
114
+ # Note: You probably should NOT be using this method. Use handoff_cart() instead.
115
+ # This method is a server-side only (no browser key allowed) method for turning a cart into an order.
116
+ # It exists for merchants who wish to provide their own upsells, but again, a warning, using this method
117
+ # will exclude the customer checkout from a vast and powerful suite of functionality provided free by UltraCart.
118
+ # Still, some merchants need this functionality, so here it is. If you're unsure, you don't need it. Use handoff.
119
+
120
+ checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
121
+
122
+ expansion = "customer_profile,items,billing,shipping,coupons,checkout,payment,summary,taxes"
123
+ # Possible Expansion Variables: (see https://www.ultracart.com/api/#resource_checkout.html
124
+ # affiliate checkout customer_profile
125
+ # billing coupons gift
126
+ # gift_certificate items.attributes items.multimedia
127
+ # items items.multimedia.thumbnails items.physical
128
+ # marketing payment settings.gift
129
+ # settings.billing.provinces settings.shipping.deliver_on_date settings.shipping.estimates
130
+ # settings.shipping.provinces settings.shipping.ship_on_date settings.taxes
131
+ # settings.terms shipping taxes
132
+ # summary upsell_after
133
+
134
+ cart_id = nil
135
+ cart_id = cookies[Constants::CART_ID_COOKIE_NAME] if cookies[Constants::CART_ID_COOKIE_NAME]
136
+
137
+ cart = nil
138
+ if cart_id.nil?
139
+ api_response = checkout_api.get_cart(_expand: expansion)
140
+ else
141
+ api_response = checkout_api.get_cart_by_cart_id(cart_id, _expand: expansion)
142
+ end
143
+ cart = api_response.cart
144
+
145
+ # TODO - add some items, collect billing and shipping, use hosted fields to collect payment, etc.
146
+
147
+ finalize_request = UltracartClient::CartFinalizeOrderRequest.new
148
+ finalize_request.cart = cart
149
+ finalize_options = UltracartClient::CartFinalizeOrderRequestOptions.new # Lots of options here. Contact support if you're unsure what you need.
150
+ finalize_request.options = finalize_options
151
+
152
+ api_response = checkout_api.finalize_order(finalize_request)
153
+ # api_response.successful
154
+ # api_response.errors
155
+ # api_response.order_id
156
+ # api_response.order
157
+
158
+ puts api_response.inspect
159
+ ```
160
+
161
+
162
+ #### Using the finalize_order_with_http_info variant
163
+
164
+ This returns an Array which contains the response data, status code and headers.
165
+
166
+ > <Array(<CartFinalizeOrderResponse>, Integer, Hash)> finalize_order_with_http_info(finalize_request)
167
+
168
+ ```ruby
169
+ begin
170
+ # Finalize Order
171
+ data, status_code, headers = api_instance.finalize_order_with_http_info(finalize_request)
172
+ p status_code # => 2xx
173
+ p headers # => { ... }
174
+ p data # => <CartFinalizeOrderResponse>
175
+ rescue UltracartClient::ApiError => e
176
+ puts "Error when calling CheckoutApi->finalize_order_with_http_info: #{e}"
177
+ end
178
+ ```
179
+
180
+ ### Parameters
181
+
182
+ | Name | Type | Description | Notes |
183
+ | ---- | ---- | ----------- | ----- |
184
+ | **finalize_request** | [**CartFinalizeOrderRequest**](CartFinalizeOrderRequest.md) | Finalize request | |
185
+
186
+ ### Return type
187
+
188
+ [**CartFinalizeOrderResponse**](CartFinalizeOrderResponse.md)
189
+
190
+ ### Authorization
191
+
192
+ [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
193
+
194
+ ### HTTP request headers
195
+
196
+ - **Content-Type**: application/json
197
+ - **Accept**: application/json
198
+
199
+
200
+ ## get_affirm_checkout
201
+
202
+ > <CartAffirmCheckoutResponse> get_affirm_checkout(cart_id)
203
+
204
+ Get affirm checkout (by cart id)
205
+
206
+ Get a Affirm checkout object for the specified cart_id parameter.
207
+
208
+
209
+ ### Examples
210
+
211
+ ```ruby
212
+ # Reference Implementation: https://github.com/UltraCart/responsive_checkout
213
+ # For a given cart id (the cart should be fully updated in UltraCart), returns back the json object
214
+ # needed to proceed with an Affirm checkout. See https://www.affirm.com/ for details about Affirm.
215
+ # This sample does not show the construction of the affirm checkout widgets. See the affirm api for those examples.
216
+
217
+ require 'ultracart_api'
218
+ require_relative '../constants'
219
+
220
+ checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
221
+ cart_id = '123456789123456789123456789123456789' # this should be retrieved from a session or cookie
222
+ api_response = checkout_api.get_affirm_checkout(cart_id)
223
+ if !api_response.errors.nil? && api_response.errors.length > 0
224
+ # TODO: display errors to customer about the failure
225
+ api_response.errors.each do |error|
226
+ puts error.inspect
227
+ end
228
+ else
229
+ puts api_response.checkout_json.inspect # this is the object to send to Affirm.
230
+ end
231
+ ```
232
+
233
+
234
+ #### Using the get_affirm_checkout_with_http_info variant
235
+
236
+ This returns an Array which contains the response data, status code and headers.
237
+
238
+ > <Array(<CartAffirmCheckoutResponse>, Integer, Hash)> get_affirm_checkout_with_http_info(cart_id)
239
+
240
+ ```ruby
241
+ begin
242
+ # Get affirm checkout (by cart id)
243
+ data, status_code, headers = api_instance.get_affirm_checkout_with_http_info(cart_id)
244
+ p status_code # => 2xx
245
+ p headers # => { ... }
246
+ p data # => <CartAffirmCheckoutResponse>
247
+ rescue UltracartClient::ApiError => e
248
+ puts "Error when calling CheckoutApi->get_affirm_checkout_with_http_info: #{e}"
249
+ end
250
+ ```
251
+
252
+ ### Parameters
253
+
254
+ | Name | Type | Description | Notes |
255
+ | ---- | ---- | ----------- | ----- |
256
+ | **cart_id** | **String** | Cart ID to retrieve | |
257
+
258
+ ### Return type
259
+
260
+ [**CartAffirmCheckoutResponse**](CartAffirmCheckoutResponse.md)
261
+
262
+ ### Authorization
263
+
264
+ [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
265
+
266
+ ### HTTP request headers
267
+
268
+ - **Content-Type**: Not defined
269
+ - **Accept**: application/json
270
+
271
+
272
+ ## get_allowed_countries
273
+
274
+ > <CheckoutAllowedCountriesResponse> get_allowed_countries
275
+
276
+ Allowed countries
277
+
278
+ Lookup the allowed countries for this merchant id
279
+
280
+
281
+ ### Examples
282
+
283
+ ```ruby
284
+ # Reference Implementation: https://github.com/UltraCart/responsive_checkout
285
+ # A simple method for populating the country list boxes with all the countries this merchant has configured to accept.
286
+
287
+ require 'ultracart_api'
288
+ require_relative '../constants'
289
+
290
+ checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
291
+
292
+ api_response = checkout_api.get_allowed_countries
293
+ allowed_countries = api_response.countries
294
+
295
+ allowed_countries.each do |country|
296
+ puts country.inspect # contains both iso2code and name
297
+ end
298
+ ```
299
+
300
+
301
+ #### Using the get_allowed_countries_with_http_info variant
302
+
303
+ This returns an Array which contains the response data, status code and headers.
304
+
305
+ > <Array(<CheckoutAllowedCountriesResponse>, Integer, Hash)> get_allowed_countries_with_http_info
306
+
307
+ ```ruby
308
+ begin
309
+ # Allowed countries
310
+ data, status_code, headers = api_instance.get_allowed_countries_with_http_info
311
+ p status_code # => 2xx
312
+ p headers # => { ... }
313
+ p data # => <CheckoutAllowedCountriesResponse>
314
+ rescue UltracartClient::ApiError => e
315
+ puts "Error when calling CheckoutApi->get_allowed_countries_with_http_info: #{e}"
316
+ end
317
+ ```
318
+
319
+ ### Parameters
320
+
321
+ This endpoint does not need any parameter.
322
+
323
+ ### Return type
324
+
325
+ [**CheckoutAllowedCountriesResponse**](CheckoutAllowedCountriesResponse.md)
326
+
327
+ ### Authorization
328
+
329
+ [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
330
+
331
+ ### HTTP request headers
332
+
333
+ - **Content-Type**: Not defined
334
+ - **Accept**: application/json
335
+
336
+
337
+ ## get_cart
338
+
339
+ > <CartResponse> get_cart(opts)
340
+
341
+ Get cart
342
+
343
+ If the cookie is set on the browser making the request then it will return their active cart. Otherwise it will create a new cart.
344
+
345
+
346
+ ### Examples
347
+
348
+ ```ruby
349
+ # frozen_string_literal: true
350
+
351
+ require 'json'
352
+ require 'yaml'
353
+ require 'ultracart_api'
354
+ require_relative '../constants'
355
+
356
+ api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY, Constants::VERIFY_SSL, Constants::DEBUG_MODE)
357
+
358
+ # this example is the same for both get_cart.rb and get_cart_by_id.rb. They work as a pair and are called
359
+ # depending on the presence of an existing cart id or not. For new carts, getCart() is used. For existing
360
+ # carts, getCartByCartId(cart_id) is used.
361
+
362
+ expansion = 'items' # for this example, we're just getting a cart to insert some items into it.
363
+
364
+ # do you have the cart id from a cookie or some other server side state engine?
365
+ cart_id = nil
366
+ # run this example once to get a cart id, then you can add it here to test.
367
+ # the cart id below will not work for you.
368
+ # cart_id = 'C6A8693A3C78C6017FDA7A50EE380100'
369
+
370
+ api_response = if cart_id.nil?
371
+ api.get_cart({ '_expand': expansion })
372
+ else
373
+ api.get_cart_by_cart_id(cart_id, { '_expand': expansion })
374
+ end
375
+
376
+ cart = api_response.cart
377
+
378
+ puts cart.to_yaml
379
+ ```
380
+
381
+
382
+ #### Using the get_cart_with_http_info variant
383
+
384
+ This returns an Array which contains the response data, status code and headers.
385
+
386
+ > <Array(<CartResponse>, Integer, Hash)> get_cart_with_http_info(opts)
387
+
388
+ ```ruby
389
+ begin
390
+ # Get cart
391
+ data, status_code, headers = api_instance.get_cart_with_http_info(opts)
392
+ p status_code # => 2xx
393
+ p headers # => { ... }
394
+ p data # => <CartResponse>
395
+ rescue UltracartClient::ApiError => e
396
+ puts "Error when calling CheckoutApi->get_cart_with_http_info: #{e}"
397
+ end
398
+ ```
399
+
400
+ ### Parameters
401
+
402
+ | Name | Type | Description | Notes |
403
+ | ---- | ---- | ----------- | ----- |
404
+ | **_expand** | **String** | The object expansion to perform on the result. See documentation for examples | [optional] |
405
+
406
+ ### Return type
407
+
408
+ [**CartResponse**](CartResponse.md)
409
+
410
+ ### Authorization
411
+
412
+ [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
413
+
414
+ ### HTTP request headers
415
+
416
+ - **Content-Type**: Not defined
417
+ - **Accept**: application/json
418
+
419
+
420
+ ## get_cart_by_cart_id
421
+
422
+ > <CartResponse> get_cart_by_cart_id(cart_id, opts)
423
+
424
+ Get cart (by cart id)
425
+
426
+ Get a cart specified by the cart_id parameter.
427
+
428
+
429
+ ### Examples
430
+
431
+ ```ruby
432
+ # frozen_string_literal: true
433
+
434
+ require 'json'
435
+ require 'yaml'
436
+ require 'ultracart_api'
437
+ require_relative '../constants'
438
+
439
+ api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY, Constants::VERIFY_SSL, Constants::DEBUG_MODE)
440
+
441
+ # this example is the same for both get_cart.rb and get_cart_by_id.rb. They work as a pair and are called
442
+ # depending on the presence of an existing cart id or not. For new carts, getCart() is used. For existing
443
+ # carts, getCartByCartId(cart_id) is used.
444
+
445
+ expansion = 'items' # for this example, we're just getting a cart to insert some items into it.
446
+
447
+ # do you have the cart id from a cookie or some other server side state engine?
448
+ cart_id = nil
449
+ # run this example once to get a cart id, then you can add it here to test.
450
+ # the cart id below will not work for you.
451
+ # cart_id = 'C6A8693A3C78C6017FDA7A50EE380100'
452
+
453
+ api_response = if cart_id.nil?
454
+ api.get_cart({ '_expand': expansion })
455
+ else
456
+ api.get_cart_by_cart_id(cart_id, { '_expand': expansion })
457
+ end
458
+
459
+ cart = api_response.cart
460
+
461
+ puts cart.to_yaml
462
+ ```
463
+
464
+
465
+ #### Using the get_cart_by_cart_id_with_http_info variant
466
+
467
+ This returns an Array which contains the response data, status code and headers.
468
+
469
+ > <Array(<CartResponse>, Integer, Hash)> get_cart_by_cart_id_with_http_info(cart_id, opts)
470
+
471
+ ```ruby
472
+ begin
473
+ # Get cart (by cart id)
474
+ data, status_code, headers = api_instance.get_cart_by_cart_id_with_http_info(cart_id, opts)
475
+ p status_code # => 2xx
476
+ p headers # => { ... }
477
+ p data # => <CartResponse>
478
+ rescue UltracartClient::ApiError => e
479
+ puts "Error when calling CheckoutApi->get_cart_by_cart_id_with_http_info: #{e}"
480
+ end
481
+ ```
482
+
483
+ ### Parameters
484
+
485
+ | Name | Type | Description | Notes |
486
+ | ---- | ---- | ----------- | ----- |
487
+ | **cart_id** | **String** | Cart ID to retrieve | |
488
+ | **_expand** | **String** | The object expansion to perform on the result. See documentation for examples | [optional] |
489
+
490
+ ### Return type
491
+
492
+ [**CartResponse**](CartResponse.md)
493
+
494
+ ### Authorization
495
+
496
+ [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
497
+
498
+ ### HTTP request headers
499
+
500
+ - **Content-Type**: Not defined
501
+ - **Accept**: application/json
502
+
503
+
504
+ ## get_cart_by_return_code
505
+
506
+ > <CartResponse> get_cart_by_return_code(return_code, opts)
507
+
508
+ Get cart (by return code)
509
+
510
+ Get a cart specified by the return code parameter.
511
+
512
+
513
+ ### Examples
514
+
515
+ ```ruby
516
+ # Reference Implementation: https://github.com/UltraCart/responsive_checkout
517
+
518
+ # this example returns a shopping cart given a return_code. The return_code is generated by UltraCart
519
+ # and usually emailed to a customer. The email will provide a link to this script where you may use the
520
+ # return_code to retrieve the customer's cart.
521
+
522
+ require 'ultracart_api'
523
+ require_relative '../constants'
524
+
525
+ checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
526
+
527
+ expansion = "items,billing,shipping,coupons,checkout,payment,summary,taxes"
528
+ # Possible Expansion Variables: (see https://www.ultracart.com/api/#resource_checkout.html
529
+ # affiliate checkout customer_profile
530
+ # billing coupons gift
531
+ # gift_certificate items.attributes items.multimedia
532
+ # items items.multimedia.thumbnails items.physical
533
+ # marketing payment settings.gift
534
+ # settings.billing.provinces settings.shipping.deliver_on_date settings.shipping.estimates
535
+ # settings.shipping.provinces settings.shipping.ship_on_date settings.taxes
536
+ # settings.terms shipping taxes
537
+ # summary upsell_after
538
+
539
+ return_code = '1234567890' # usually retrieved from a query parameter
540
+ api_response = checkout_api.get_cart_by_return_code(return_code, _expand: expansion)
541
+ cart = api_response.cart
542
+
543
+ # TODO: set or re-set the cart cookie if this is part of a multi-page process. two weeks is a generous cart id time.
544
+ cookies[Constants::CART_ID_COOKIE_NAME] = { value: cart.cart_id, expires: Time.now + 1209600, path: "/" }
545
+
546
+ puts cart.inspect
547
+ ```
548
+
549
+
550
+ #### Using the get_cart_by_return_code_with_http_info variant
551
+
552
+ This returns an Array which contains the response data, status code and headers.
553
+
554
+ > <Array(<CartResponse>, Integer, Hash)> get_cart_by_return_code_with_http_info(return_code, opts)
555
+
556
+ ```ruby
557
+ begin
558
+ # Get cart (by return code)
559
+ data, status_code, headers = api_instance.get_cart_by_return_code_with_http_info(return_code, opts)
560
+ p status_code # => 2xx
561
+ p headers # => { ... }
562
+ p data # => <CartResponse>
563
+ rescue UltracartClient::ApiError => e
564
+ puts "Error when calling CheckoutApi->get_cart_by_return_code_with_http_info: #{e}"
565
+ end
566
+ ```
567
+
568
+ ### Parameters
569
+
570
+ | Name | Type | Description | Notes |
571
+ | ---- | ---- | ----------- | ----- |
572
+ | **return_code** | **String** | Return code to lookup cart ID by | |
573
+ | **_expand** | **String** | The object expansion to perform on the result. See documentation for examples | [optional] |
574
+
575
+ ### Return type
576
+
577
+ [**CartResponse**](CartResponse.md)
578
+
579
+ ### Authorization
580
+
581
+ [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
582
+
583
+ ### HTTP request headers
584
+
585
+ - **Content-Type**: Not defined
586
+ - **Accept**: application/json
587
+
588
+
589
+ ## get_cart_by_return_token
590
+
591
+ > <CartResponse> get_cart_by_return_token(opts)
592
+
593
+ Get cart (by return token)
594
+
595
+ Get a cart specified by the encrypted return token parameter.
596
+
597
+
598
+ ### Examples
599
+
600
+ ```ruby
601
+ # Reference Implementation: https://github.com/UltraCart/responsive_checkout
602
+
603
+ # this example returns a shopping cart given a return_token. The return token is generated by StoreFront Communications
604
+ # and usually emailed to a customer. The link within the email will (when you configure your storefront communications)
605
+ # provide a link to this script where you may use the token to retrieve the customer's cart.
606
+
607
+ require 'ultracart_api'
608
+ require_relative '../constants'
609
+
610
+ checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
611
+
612
+ expansion = "items,billing,shipping,coupons,checkout,payment,summary,taxes"
613
+ # Possible Expansion Variables: (see https://www.ultracart.com/api/#resource_checkout.html
614
+ # affiliate checkout customer_profile
615
+ # billing coupons gift
616
+ # gift_certificate items.attributes items.multimedia
617
+ # items items.multimedia.thumbnails items.physical
618
+ # marketing payment settings.gift
619
+ # settings.billing.provinces settings.shipping.deliver_on_date settings.shipping.estimates
620
+ # settings.shipping.provinces settings.shipping.ship_on_date settings.taxes
621
+ # settings.terms shipping taxes
622
+ # summary upsell_after
623
+
624
+ cart_token = '1234567890' # usually retrieved from a query parameter
625
+ api_response = checkout_api.get_cart_by_return_token(cart_token, _expand: expansion)
626
+ cart = api_response.cart
627
+
628
+ # TODO: set or re-set the cart cookie if this is part of a multi-page process. two weeks is a generous cart id time.
629
+ cookies[Constants::CART_ID_COOKIE_NAME] = { value: cart.cart_id, expires: Time.now + 1209600, path: "/" }
630
+
631
+ puts cart.inspect
632
+ ```
633
+
634
+
635
+ #### Using the get_cart_by_return_token_with_http_info variant
636
+
637
+ This returns an Array which contains the response data, status code and headers.
638
+
639
+ > <Array(<CartResponse>, Integer, Hash)> get_cart_by_return_token_with_http_info(opts)
640
+
641
+ ```ruby
642
+ begin
643
+ # Get cart (by return token)
644
+ data, status_code, headers = api_instance.get_cart_by_return_token_with_http_info(opts)
645
+ p status_code # => 2xx
646
+ p headers # => { ... }
647
+ p data # => <CartResponse>
648
+ rescue UltracartClient::ApiError => e
649
+ puts "Error when calling CheckoutApi->get_cart_by_return_token_with_http_info: #{e}"
650
+ end
651
+ ```
652
+
653
+ ### Parameters
654
+
655
+ | Name | Type | Description | Notes |
656
+ | ---- | ---- | ----------- | ----- |
657
+ | **return_token** | **String** | Return token provided by StoreFront Communications | [optional] |
658
+ | **_expand** | **String** | The object expansion to perform on the result. See documentation for examples | [optional] |
659
+
660
+ ### Return type
661
+
662
+ [**CartResponse**](CartResponse.md)
663
+
664
+ ### Authorization
665
+
666
+ [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
667
+
668
+ ### HTTP request headers
669
+
670
+ - **Content-Type**: Not defined
671
+ - **Accept**: application/json
672
+
673
+
674
+ ## get_state_provinces_for_country
675
+
676
+ > <CheckoutStateProvinceResponse> get_state_provinces_for_country(country_code)
677
+
678
+ Get state/province list for a country code
679
+
680
+ Lookup a state/province list for a given country code
681
+
682
+
683
+ ### Examples
684
+
685
+ ```ruby
686
+ # Reference Implementation: https://github.com/UltraCart/responsive_checkout
687
+ # A simple method for populating the state_region list boxes with all the states/regions allowed for a country code.
688
+
689
+ require 'ultracart_api'
690
+ require_relative '../constants'
691
+
692
+ checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
693
+
694
+ country_code = 'US'
695
+
696
+ api_response = checkout_api.get_state_provinces_for_country(country_code)
697
+ provinces = api_response.state_provinces
698
+
699
+ provinces.each do |province|
700
+ puts province.inspect # contains both name and abbreviation
701
+ end
702
+ ```
703
+
704
+
705
+ #### Using the get_state_provinces_for_country_with_http_info variant
706
+
707
+ This returns an Array which contains the response data, status code and headers.
708
+
709
+ > <Array(<CheckoutStateProvinceResponse>, Integer, Hash)> get_state_provinces_for_country_with_http_info(country_code)
710
+
711
+ ```ruby
712
+ begin
713
+ # Get state/province list for a country code
714
+ data, status_code, headers = api_instance.get_state_provinces_for_country_with_http_info(country_code)
715
+ p status_code # => 2xx
716
+ p headers # => { ... }
717
+ p data # => <CheckoutStateProvinceResponse>
718
+ rescue UltracartClient::ApiError => e
719
+ puts "Error when calling CheckoutApi->get_state_provinces_for_country_with_http_info: #{e}"
720
+ end
721
+ ```
722
+
723
+ ### Parameters
724
+
725
+ | Name | Type | Description | Notes |
726
+ | ---- | ---- | ----------- | ----- |
727
+ | **country_code** | **String** | Two letter ISO country code | |
728
+
729
+ ### Return type
730
+
731
+ [**CheckoutStateProvinceResponse**](CheckoutStateProvinceResponse.md)
732
+
733
+ ### Authorization
734
+
735
+ [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
736
+
737
+ ### HTTP request headers
738
+
739
+ - **Content-Type**: Not defined
740
+ - **Accept**: application/json
741
+
742
+
743
+ ## handoff_cart
744
+
745
+ > <CheckoutHandoffResponse> handoff_cart(handoff_request, opts)
746
+
747
+ Handoff cart
748
+
749
+ Handoff the browser to UltraCart for view cart on StoreFront, transfer to PayPal, transfer to Affirm, transfer to Sezzle or finalization of the order (including upsell processing).
750
+
751
+
752
+ ### Examples
753
+
754
+ ```ruby
755
+ require 'ultracart_api'
756
+ require_relative '../constants'
757
+
758
+ # Reference Implementation: https://github.com/UltraCart/responsive_checkout
759
+
760
+ # This example uses the get_cart.rb code as a starting point because we must get a cart to hand off a cart.
761
+ # Here, we are handing off the cart to the UltraCart engine with an operation of 'view', meaning that we
762
+ # simply added some items to the cart and wish for UltraCart to gather the remaining customer information
763
+ # as part of a normal checkout operation.
764
+ # Valid operations are: "view", "checkout", "paypal", "paypalcredit", "affirm", "sezzle"
765
+ # Besides "view", the other operations are finalizers.
766
+ # "checkout": Finalize the transaction using a customer's personal credit card (traditional checkout)
767
+ # "paypal": Finalize the transaction by sending the customer to PayPal
768
+
769
+ # get_cart.rb code start ----------------------------------------------------------------------------
770
+
771
+ # This example is the same for both get_cart.rb and get_cart_by_cart_id.rb. They work as a pair and are called
772
+ # depending on the presence of an existing cart ID or not. For new carts, get_cart() is used. For existing
773
+ # carts, get_cart_by_cart_id(cart_id) is used.
774
+
775
+ checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
776
+
777
+ expansion = "items" # For this example, we're just getting a cart to insert some items into it.
778
+
779
+ cart_id = nil
780
+ cart_id = ENV['HTTP_COOKIE'].scan(/UltraCartShoppingCartID=([^;]+)/).flatten.first if ENV['HTTP_COOKIE']
781
+
782
+ cart = nil
783
+ if cart_id.nil?
784
+ api_response = checkout_api.get_cart(expansion: expansion)
785
+ else
786
+ api_response = checkout_api.get_cart_by_cart_id(cart_id, expansion: expansion)
787
+ end
788
+ cart = api_response.cart
789
+
790
+ # get_cart.rb code end ----------------------------------------------------------------------------
791
+
792
+ # Although the above code checks for a cookie and retrieves or creates a cart based on the cookie presence, typically
793
+ # a Ruby script calling the handoff() method will have an existing cart, so you may wish to check for a cookie and
794
+ # redirect if there isn't one. However, it is possible that you wish to create a cart, update it, and hand it off
795
+ # to UltraCart all within one script, so we've left the conditional cart creation calls intact.
796
+
797
+ handoff_request = UltracartClient::CheckoutHandoffRequest.new
798
+ handoff_request.cart = cart
799
+ handoff_request.operation = "view"
800
+ handoff_request.error_return_url = "/some/page/on/this/ruby/server/that/can/handle/errors/if/ultracart/encounters/an/issue/with/this/cart.rb"
801
+ handoff_request.error_parameter_name = "uc_error" # Name this whatever the script supplied in ->setErrorReturnUrl() will check for in the params.
802
+ handoff_request.secure_host_name = "mystorefront.com" # Set to desired storefront. Some merchants have multiple storefronts.
803
+
804
+ api_response = checkout_api.handoff_cart(handoff_request, { '_expand' => expansion })
805
+
806
+ if !api_response.errors.nil? && !api_response.errors.empty?
807
+ # TODO: Handle errors that might happen before handoff and manage those
808
+ else
809
+ redirect_url = api_response.redirect_to_url
810
+ puts "Location: #{redirect_url}\n\n"
811
+ end
812
+ ```
813
+
814
+
815
+ #### Using the handoff_cart_with_http_info variant
816
+
817
+ This returns an Array which contains the response data, status code and headers.
818
+
819
+ > <Array(<CheckoutHandoffResponse>, Integer, Hash)> handoff_cart_with_http_info(handoff_request, opts)
820
+
821
+ ```ruby
822
+ begin
823
+ # Handoff cart
824
+ data, status_code, headers = api_instance.handoff_cart_with_http_info(handoff_request, opts)
825
+ p status_code # => 2xx
826
+ p headers # => { ... }
827
+ p data # => <CheckoutHandoffResponse>
828
+ rescue UltracartClient::ApiError => e
829
+ puts "Error when calling CheckoutApi->handoff_cart_with_http_info: #{e}"
830
+ end
831
+ ```
832
+
833
+ ### Parameters
834
+
835
+ | Name | Type | Description | Notes |
836
+ | ---- | ---- | ----------- | ----- |
837
+ | **handoff_request** | [**CheckoutHandoffRequest**](CheckoutHandoffRequest.md) | Handoff request | |
838
+ | **_expand** | **String** | The object expansion to perform on the result. See documentation for examples | [optional] |
839
+
840
+ ### Return type
841
+
842
+ [**CheckoutHandoffResponse**](CheckoutHandoffResponse.md)
843
+
844
+ ### Authorization
845
+
846
+ [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
847
+
848
+ ### HTTP request headers
849
+
850
+ - **Content-Type**: application/json
851
+ - **Accept**: application/json
852
+
853
+
854
+ ## login
855
+
856
+ > <CartProfileLoginResponse> login(login_request, opts)
857
+
858
+ Profile login
859
+
860
+ Login in to the customer profile specified by cart.billing.email and password
861
+
862
+
863
+ ### Examples
864
+
865
+ ```ruby
866
+ require 'ultracart_api'
867
+ require_relative '../constants'
868
+
869
+ # Reference Implementation: https://github.com/UltraCart/responsive_checkout
870
+
871
+ # This example logs a user into the UltraCart system.
872
+ # This example assumes you already have a shopping cart object created.
873
+ # For new carts, get_cart() is used. For existing carts, get_cart_by_cart_id(cart_id) is used.
874
+
875
+ checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
876
+
877
+ # Note: customer_profile is a required expansion for login to work properly
878
+ expansion = "customer_profile,items,billing,shipping,coupons,checkout,payment,summary,taxes"
879
+ # Possible Expansion Variables: (see https://www.ultracart.com/api/#resource_checkout.html)
880
+
881
+ # Create a new cart (change this to an existing if you have one)
882
+ cart = checkout_api.get_cart(expansion: expansion).cart
883
+
884
+ email = 'test@test.com' # Collect this from user.
885
+ password = 'ABC123' # Collect this from user.
886
+
887
+ cart.billing = UltracartClient::CartBilling.new
888
+ cart.billing.email = email
889
+
890
+ login_request = UltracartClient::CartProfileLoginRequest.new
891
+ login_request.cart = cart # Will look for billing.email
892
+ login_request.password = password
893
+
894
+ api_response = checkout_api.login(login_request)
895
+ cart = api_response.cart
896
+
897
+ if api_response.success
898
+ # Proceed with successful login.
899
+ else
900
+ # Notify customer login failed.
901
+ end
902
+ ```
903
+
904
+
905
+ #### Using the login_with_http_info variant
906
+
907
+ This returns an Array which contains the response data, status code and headers.
908
+
909
+ > <Array(<CartProfileLoginResponse>, Integer, Hash)> login_with_http_info(login_request, opts)
910
+
911
+ ```ruby
912
+ begin
913
+ # Profile login
914
+ data, status_code, headers = api_instance.login_with_http_info(login_request, opts)
915
+ p status_code # => 2xx
916
+ p headers # => { ... }
917
+ p data # => <CartProfileLoginResponse>
918
+ rescue UltracartClient::ApiError => e
919
+ puts "Error when calling CheckoutApi->login_with_http_info: #{e}"
920
+ end
921
+ ```
922
+
923
+ ### Parameters
924
+
925
+ | Name | Type | Description | Notes |
926
+ | ---- | ---- | ----------- | ----- |
927
+ | **login_request** | [**CartProfileLoginRequest**](CartProfileLoginRequest.md) | Login request | |
928
+ | **_expand** | **String** | The object expansion to perform on the result. See documentation for examples | [optional] |
929
+
930
+ ### Return type
931
+
932
+ [**CartProfileLoginResponse**](CartProfileLoginResponse.md)
933
+
934
+ ### Authorization
935
+
936
+ [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
937
+
938
+ ### HTTP request headers
939
+
940
+ - **Content-Type**: application/json
941
+ - **Accept**: application/json
942
+
943
+
944
+ ## logout
945
+
946
+ > <CartResponse> logout(cart, opts)
947
+
948
+ Profile logout
949
+
950
+ Log the cart out of the current profile. No error will occur if they are not logged in.
951
+
952
+
953
+ ### Examples
954
+
955
+ ```ruby
956
+ require 'ultracart_api'
957
+ require_relative '../constants'
958
+
959
+ # Reference Implementation: https://github.com/UltraCart/responsive_checkout
960
+
961
+ # This example logs a user OUT of the UltraCart system.
962
+ # It assumes the shopping cart has already had a successful login.
963
+ # See login sdk_sample for logging in help.
964
+ # For new carts, get_cart() is used. For existing carts, get_cart_by_cart_id(cart_id) is used.
965
+
966
+ checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
967
+
968
+ # Note: customer_profile is a required expansion for login to work properly
969
+ expansion = "customer_profile,items,billing,shipping,coupons,checkout,payment,summary,taxes"
970
+ # Possible Expansion Variables: (see https://www.ultracart.com/api/#resource_checkout.html)
971
+
972
+ # Create a new cart (change this to an existing if you have one)
973
+ cart = checkout_api.get_cart(expansion: expansion).cart
974
+
975
+ email = 'test@test.com' # Collect this from user.
976
+ password = 'ABC123' # Collect this from user.
977
+
978
+ cart.billing = UltracartClient::CartBilling.new
979
+ cart.billing.email = email
980
+
981
+ login_request = UltracartClient::CartProfileLoginRequest.new
982
+ login_request.cart = cart # Will look for billing.email
983
+ login_request.password = password
984
+
985
+ api_response = checkout_api.login(login_request)
986
+ cart = api_response.cart
987
+
988
+ if api_response.success
989
+ checkout_api.logout(cart, { '_expand' => expansion }) # <-- Here is the logout call.
990
+ else
991
+ # Notify customer login failed. Until they log in, you can't log them out.
992
+ end
993
+ ```
994
+
995
+
996
+ #### Using the logout_with_http_info variant
997
+
998
+ This returns an Array which contains the response data, status code and headers.
999
+
1000
+ > <Array(<CartResponse>, Integer, Hash)> logout_with_http_info(cart, opts)
1001
+
1002
+ ```ruby
1003
+ begin
1004
+ # Profile logout
1005
+ data, status_code, headers = api_instance.logout_with_http_info(cart, opts)
1006
+ p status_code # => 2xx
1007
+ p headers # => { ... }
1008
+ p data # => <CartResponse>
1009
+ rescue UltracartClient::ApiError => e
1010
+ puts "Error when calling CheckoutApi->logout_with_http_info: #{e}"
1011
+ end
1012
+ ```
1013
+
1014
+ ### Parameters
1015
+
1016
+ | Name | Type | Description | Notes |
1017
+ | ---- | ---- | ----------- | ----- |
1018
+ | **cart** | [**Cart**](Cart.md) | Cart | |
1019
+ | **_expand** | **String** | The object expansion to perform on the result. See documentation for examples | [optional] |
1020
+
1021
+ ### Return type
1022
+
1023
+ [**CartResponse**](CartResponse.md)
1024
+
1025
+ ### Authorization
1026
+
1027
+ [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
1028
+
1029
+ ### HTTP request headers
1030
+
1031
+ - **Content-Type**: application/json
1032
+ - **Accept**: application/json
1033
+
1034
+
1035
+ ## register
1036
+
1037
+ > <CartProfileRegisterResponse> register(register_request, opts)
1038
+
1039
+ Profile registration
1040
+
1041
+ Register a new customer profile. Requires the cart.billing object to be populated along with the password.
1042
+
1043
+
1044
+ ### Examples
1045
+
1046
+ ```ruby
1047
+ require 'ultracart_api'
1048
+ require_relative '../constants'
1049
+
1050
+ # Reference Implementation: https://github.com/UltraCart/responsive_checkout
1051
+
1052
+ # Registers a user in your merchant system. This will create a customer profile.
1053
+ # For new carts, get_cart() is used. For existing carts, get_cart_by_cart_id(cart_id) is used.
1054
+
1055
+ checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
1056
+
1057
+ # Note: customer_profile is a required expansion for login to work properly
1058
+ expansion = "customer_profile,items,billing,shipping,coupons,checkout,payment,summary,taxes"
1059
+ # Possible Expansion Variables: (see https://www.ultracart.com/api/#resource_checkout.html)
1060
+
1061
+ # Create a new cart (change this to an existing if you have one)
1062
+ cart = checkout_api.get_cart(expansion: expansion).cart
1063
+
1064
+ email = 'test@test.com' # Collect this from user.
1065
+ password = 'ABC123' # Collect this from user.
1066
+
1067
+ cart.billing = UltracartClient::CartBilling.new
1068
+ cart.billing.email = email # This is the username.
1069
+
1070
+ register_request = UltracartClient::CartProfileRegisterRequest.new
1071
+ register_request.cart = cart # Will look for billing.email
1072
+ register_request.password = password
1073
+
1074
+ api_response = checkout_api.register(register_request)
1075
+ cart = api_response.cart # Important! Get the cart from the response.
1076
+
1077
+ if api_response.success
1078
+ puts 'Successfully registered new customer profile!'
1079
+ else
1080
+ api_response.errors.each { |error| puts error.inspect }
1081
+ end
1082
+ ```
1083
+
1084
+
1085
+ #### Using the register_with_http_info variant
1086
+
1087
+ This returns an Array which contains the response data, status code and headers.
1088
+
1089
+ > <Array(<CartProfileRegisterResponse>, Integer, Hash)> register_with_http_info(register_request, opts)
1090
+
1091
+ ```ruby
1092
+ begin
1093
+ # Profile registration
1094
+ data, status_code, headers = api_instance.register_with_http_info(register_request, opts)
1095
+ p status_code # => 2xx
1096
+ p headers # => { ... }
1097
+ p data # => <CartProfileRegisterResponse>
1098
+ rescue UltracartClient::ApiError => e
1099
+ puts "Error when calling CheckoutApi->register_with_http_info: #{e}"
1100
+ end
1101
+ ```
1102
+
1103
+ ### Parameters
1104
+
1105
+ | Name | Type | Description | Notes |
1106
+ | ---- | ---- | ----------- | ----- |
1107
+ | **register_request** | [**CartProfileRegisterRequest**](CartProfileRegisterRequest.md) | Register request | |
1108
+ | **_expand** | **String** | The object expansion to perform on the result. See documentation for examples | [optional] |
1109
+
1110
+ ### Return type
1111
+
1112
+ [**CartProfileRegisterResponse**](CartProfileRegisterResponse.md)
1113
+
1114
+ ### Authorization
1115
+
1116
+ [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
1117
+
1118
+ ### HTTP request headers
1119
+
1120
+ - **Content-Type**: application/json
1121
+ - **Accept**: application/json
1122
+
1123
+
1124
+ ## register_affiliate_click
1125
+
1126
+ > <RegisterAffiliateClickResponse> register_affiliate_click(register_affiliate_click_request, opts)
1127
+
1128
+ Register affiliate click
1129
+
1130
+ Register an affiliate click. Used by custom checkouts that are completely API based and do not perform checkout handoff.
1131
+
1132
+
1133
+ ### Examples
1134
+
1135
+ ```ruby
1136
+ require 'ultracart_api'
1137
+ require_relative '../constants'
1138
+
1139
+ # Reference Implementation: https://github.com/UltraCart/responsive_checkout
1140
+ # Records an affiliate click.
1141
+
1142
+ checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
1143
+
1144
+ click_request = UltracartClient::RegisterAffiliateClickRequest.new
1145
+ click_request.ip_address = ENV['HTTP_X_FORWARDED_FOR'] || ENV['REMOTE_ADDR']
1146
+ click_request.user_agent = ENV['HTTP_USER_AGENT'] || ''
1147
+ click_request.referrer_url = ENV['HTTP_REFERER'] || ''
1148
+ click_request.affid = 123_456_789 # You should know this from your UltraCart affiliate system.
1149
+ click_request.subid = 'TODO:SupplyThisValue'
1150
+ # click_request.landing_page_url = nil # If you have a landing page URL.
1151
+
1152
+ api_response = checkout_api.register_affiliate_click(click_request)
1153
+
1154
+ puts api_response.inspect
1155
+ ```
1156
+
1157
+
1158
+ #### Using the register_affiliate_click_with_http_info variant
1159
+
1160
+ This returns an Array which contains the response data, status code and headers.
1161
+
1162
+ > <Array(<RegisterAffiliateClickResponse>, Integer, Hash)> register_affiliate_click_with_http_info(register_affiliate_click_request, opts)
1163
+
1164
+ ```ruby
1165
+ begin
1166
+ # Register affiliate click
1167
+ data, status_code, headers = api_instance.register_affiliate_click_with_http_info(register_affiliate_click_request, opts)
1168
+ p status_code # => 2xx
1169
+ p headers # => { ... }
1170
+ p data # => <RegisterAffiliateClickResponse>
1171
+ rescue UltracartClient::ApiError => e
1172
+ puts "Error when calling CheckoutApi->register_affiliate_click_with_http_info: #{e}"
1173
+ end
1174
+ ```
1175
+
1176
+ ### Parameters
1177
+
1178
+ | Name | Type | Description | Notes |
1179
+ | ---- | ---- | ----------- | ----- |
1180
+ | **register_affiliate_click_request** | [**RegisterAffiliateClickRequest**](RegisterAffiliateClickRequest.md) | Register affiliate click request | |
1181
+ | **_expand** | **String** | The object expansion to perform on the result. See documentation for examples | [optional] |
1182
+
1183
+ ### Return type
1184
+
1185
+ [**RegisterAffiliateClickResponse**](RegisterAffiliateClickResponse.md)
1186
+
1187
+ ### Authorization
1188
+
1189
+ [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
1190
+
1191
+ ### HTTP request headers
1192
+
1193
+ - **Content-Type**: application/json
1194
+ - **Accept**: application/json
1195
+
1196
+
1197
+ ## related_items_for_cart
1198
+
1199
+ > <ItemsResponse> related_items_for_cart(cart, opts)
1200
+
1201
+ Related items
1202
+
1203
+ Retrieve all the related items for the cart contents. Expansion is limited to content, content.assignments, content.attributes, content.multimedia, content.multimedia.thumbnails, options, pricing, and pricing.tiers.
1204
+
1205
+
1206
+ ### Examples
1207
+
1208
+ ```ruby
1209
+ require 'ultracart_api'
1210
+ require_relative '../constants'
1211
+
1212
+ # Reference Implementation: https://github.com/UltraCart/responsive_checkout
1213
+ # Retrieves items related to the items within the cart. Item relations are configured in the UltraCart backend.
1214
+ # See: https://ultracart.atlassian.net/wiki/spaces/ucdoc/pages/1377171/Related+Items
1215
+
1216
+ checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
1217
+
1218
+ expansion = 'customer_profile,items,billing,shipping,coupons,checkout,payment,summary,taxes'
1219
+
1220
+ cart_id = ENV['HTTP_ULTRACARTSHOPPINGCARTID']
1221
+
1222
+ cart = if cart_id.nil?
1223
+ checkout_api.get_cart({_expand: expansion}).cart
1224
+ else
1225
+ checkout_api.get_cart_by_cart_id(cart_id, {_expand: expansion}).cart
1226
+ end
1227
+
1228
+ # TODO - add some items to the cart and update.
1229
+
1230
+ items = []
1231
+ cart_item = UltracartClient::CartItem.new
1232
+ cart_item.item_id = 'ITEM_ABC'
1233
+ cart_item.quantity = 1
1234
+ items << cart_item
1235
+ cart.items = items
1236
+
1237
+ # Update the cart
1238
+ cart = checkout_api.update_cart(cart, { '_expand' => expansion }).cart
1239
+
1240
+ api_response = checkout_api.related_items_for_cart(cart)
1241
+ related_items = api_response.items
1242
+
1243
+ puts related_items.inspect
1244
+ ```
1245
+
1246
+
1247
+ #### Using the related_items_for_cart_with_http_info variant
1248
+
1249
+ This returns an Array which contains the response data, status code and headers.
1250
+
1251
+ > <Array(<ItemsResponse>, Integer, Hash)> related_items_for_cart_with_http_info(cart, opts)
1252
+
1253
+ ```ruby
1254
+ begin
1255
+ # Related items
1256
+ data, status_code, headers = api_instance.related_items_for_cart_with_http_info(cart, opts)
1257
+ p status_code # => 2xx
1258
+ p headers # => { ... }
1259
+ p data # => <ItemsResponse>
1260
+ rescue UltracartClient::ApiError => e
1261
+ puts "Error when calling CheckoutApi->related_items_for_cart_with_http_info: #{e}"
1262
+ end
1263
+ ```
1264
+
1265
+ ### Parameters
1266
+
1267
+ | Name | Type | Description | Notes |
1268
+ | ---- | ---- | ----------- | ----- |
1269
+ | **cart** | [**Cart**](Cart.md) | Cart | |
1270
+ | **_expand** | **String** | The object expansion to perform on the result. See item resource documentation for examples | [optional] |
1271
+
1272
+ ### Return type
1273
+
1274
+ [**ItemsResponse**](ItemsResponse.md)
1275
+
1276
+ ### Authorization
1277
+
1278
+ [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
1279
+
1280
+ ### HTTP request headers
1281
+
1282
+ - **Content-Type**: application/json
1283
+ - **Accept**: application/json
1284
+
1285
+
1286
+ ## related_items_for_item
1287
+
1288
+ > <ItemsResponse> related_items_for_item(item_id, cart, opts)
1289
+
1290
+ Related items (specific item)
1291
+
1292
+ Retrieve all the related items for the cart contents. Expansion is limited to content, content.assignments, content.attributes, content.multimedia, content.multimedia.thumbnails, options, pricing, and pricing.tiers.
1293
+
1294
+
1295
+ ### Examples
1296
+
1297
+ ```ruby
1298
+ require 'ultracart_api'
1299
+ require_relative '../constants'
1300
+
1301
+ # Reference Implementation: https://github.com/UltraCart/responsive_checkout
1302
+ # Retrieves items related to the items within the cart, in addition to another item ID you supply.
1303
+ # Item relations are configured in the UltraCart backend.
1304
+ # See: https://ultracart.atlassian.net/wiki/spaces/ucdoc/pages/1377171/Related+Items
1305
+
1306
+ checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
1307
+
1308
+ expansion = 'customer_profile,items,billing,shipping,coupons,checkout,payment,summary,taxes'
1309
+
1310
+ cart_id = ENV['HTTP_ULTRACARTSHOPPINGCARTID']
1311
+
1312
+ cart = if cart_id.nil?
1313
+ checkout_api.get_cart({_expand: expansion}).cart
1314
+ else
1315
+ checkout_api.get_cart_by_cart_id(cart_id, {_expand: expansion}).cart
1316
+ end
1317
+
1318
+ # TODO - add some items to the cart and update.
1319
+
1320
+ items = []
1321
+ cart_item = UltracartClient::CartItem.new
1322
+ cart_item.item_id = 'ITEM_ABC'
1323
+ cart_item.quantity = 1
1324
+ items << cart_item
1325
+ cart.items = items
1326
+
1327
+ # Update the cart
1328
+ cart = checkout_api.update_cart(cart, { '_expand' => expansion }).cart
1329
+
1330
+ another_item_id = 'ITEM_ZZZ'
1331
+
1332
+ api_response = checkout_api.related_items_for_item(another_item_id, cart, { '_expand' => expansion })
1333
+ related_items = api_response.items
1334
+
1335
+ puts related_items.inspect
1336
+ ```
1337
+
1338
+
1339
+ #### Using the related_items_for_item_with_http_info variant
1340
+
1341
+ This returns an Array which contains the response data, status code and headers.
1342
+
1343
+ > <Array(<ItemsResponse>, Integer, Hash)> related_items_for_item_with_http_info(item_id, cart, opts)
1344
+
1345
+ ```ruby
1346
+ begin
1347
+ # Related items (specific item)
1348
+ data, status_code, headers = api_instance.related_items_for_item_with_http_info(item_id, cart, opts)
1349
+ p status_code # => 2xx
1350
+ p headers # => { ... }
1351
+ p data # => <ItemsResponse>
1352
+ rescue UltracartClient::ApiError => e
1353
+ puts "Error when calling CheckoutApi->related_items_for_item_with_http_info: #{e}"
1354
+ end
1355
+ ```
1356
+
1357
+ ### Parameters
1358
+
1359
+ | Name | Type | Description | Notes |
1360
+ | ---- | ---- | ----------- | ----- |
1361
+ | **item_id** | **String** | Item ID to retrieve related items for | |
1362
+ | **cart** | [**Cart**](Cart.md) | Cart | |
1363
+ | **_expand** | **String** | The object expansion to perform on the result. See item resource documentation for examples | [optional] |
1364
+
1365
+ ### Return type
1366
+
1367
+ [**ItemsResponse**](ItemsResponse.md)
1368
+
1369
+ ### Authorization
1370
+
1371
+ [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
1372
+
1373
+ ### HTTP request headers
1374
+
1375
+ - **Content-Type**: application/json
1376
+ - **Accept**: application/json
1377
+
1378
+
1379
+ ## setup_browser_key
1380
+
1381
+ > <CheckoutSetupBrowserKeyResponse> setup_browser_key(browser_key_request)
1382
+
1383
+ Setup Browser Application
1384
+
1385
+ Setup a browser key authenticated application with checkout permissions. This REST call must be made with an authentication scheme that is not browser key. The new application will be linked to the application that makes this call. If this application is disabled / deleted, then so will the application setup by this call. The purpose of this call is to allow an OAuth application, such as the Wordpress plugin, to setup the proper browser based authentication for the REST checkout API to use.
1386
+
1387
+
1388
+ ### Examples
1389
+
1390
+ ```ruby
1391
+ require 'ultracart_api'
1392
+ require_relative '../constants'
1393
+
1394
+ # This is a checkout API method. It creates a browser key for use in a client-side checkout.
1395
+ # This call must be made server-side with a Simple API Key or an OAuth access token.
1396
+
1397
+ checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
1398
+
1399
+ key_request = UltracartClient::CheckoutSetupBrowserKeyRequest.new
1400
+ key_request.allowed_referrers = ["https://www.mywebsite.com"]
1401
+
1402
+ browser_key = checkout_api.setup_browser_key(key_request).browser_key
1403
+
1404
+ puts browser_key.inspect
1405
+ ```
1406
+
1407
+
1408
+ #### Using the setup_browser_key_with_http_info variant
1409
+
1410
+ This returns an Array which contains the response data, status code and headers.
1411
+
1412
+ > <Array(<CheckoutSetupBrowserKeyResponse>, Integer, Hash)> setup_browser_key_with_http_info(browser_key_request)
1413
+
1414
+ ```ruby
1415
+ begin
1416
+ # Setup Browser Application
1417
+ data, status_code, headers = api_instance.setup_browser_key_with_http_info(browser_key_request)
1418
+ p status_code # => 2xx
1419
+ p headers # => { ... }
1420
+ p data # => <CheckoutSetupBrowserKeyResponse>
1421
+ rescue UltracartClient::ApiError => e
1422
+ puts "Error when calling CheckoutApi->setup_browser_key_with_http_info: #{e}"
1423
+ end
1424
+ ```
1425
+
1426
+ ### Parameters
1427
+
1428
+ | Name | Type | Description | Notes |
1429
+ | ---- | ---- | ----------- | ----- |
1430
+ | **browser_key_request** | [**CheckoutSetupBrowserKeyRequest**](CheckoutSetupBrowserKeyRequest.md) | Setup browser key request | |
1431
+
1432
+ ### Return type
1433
+
1434
+ [**CheckoutSetupBrowserKeyResponse**](CheckoutSetupBrowserKeyResponse.md)
1435
+
1436
+ ### Authorization
1437
+
1438
+ [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
1439
+
1440
+ ### HTTP request headers
1441
+
1442
+ - **Content-Type**: application/json
1443
+ - **Accept**: application/json
1444
+
1445
+
1446
+ ## update_cart
1447
+
1448
+ > <CartResponse> update_cart(cart, opts)
1449
+
1450
+ Update cart
1451
+
1452
+ Update the cart.
1453
+
1454
+
1455
+ ### Examples
1456
+
1457
+ ```ruby
1458
+ require 'ultracart_api'
1459
+ require_relative '../constants'
1460
+
1461
+ # Reference Implementation: https://github.com/UltraCart/responsive_checkout
1462
+
1463
+ checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
1464
+
1465
+ expansion = 'items' # For this example, we're just getting a cart to insert some items into it.
1466
+
1467
+ cart_id = nil
1468
+ cart_id = ENV['HTTP_COOKIE'].to_s[/#{Constants::CART_ID_COOKIE_NAME}=([^;]+)/, 1] if ENV['HTTP_COOKIE']
1469
+
1470
+ cart = if cart_id.nil?
1471
+ checkout_api.get_cart({_expand: expansion}).cart
1472
+ else
1473
+ checkout_api.get_cart_by_cart_id(cart_id, {_expand: expansion}).cart
1474
+ end
1475
+
1476
+ # Get the items array on the cart, creating it if it doesn't exist.
1477
+ items = cart.items || []
1478
+
1479
+ # Create a new item
1480
+ item = UltracartClient::CartItem.new
1481
+ item.item_id = 'BASEBALL' # TODO: Adjust the item id
1482
+ item.quantity = 1 # TODO: Adjust the quantity
1483
+
1484
+ # TODO: If your item has options, then you need to create a new UltracartClient::CartItemOption object and push it into the array.
1485
+ options = []
1486
+ item.options = options
1487
+
1488
+ # Add the item to the items array
1489
+ items << item
1490
+
1491
+ # Update the cart with the new items
1492
+ cart.items = items
1493
+
1494
+ # Push the cart up to save the item
1495
+ cart_response = checkout_api.update_cart(cart, {_expand: expansion})
1496
+
1497
+ # Extract the updated cart from the response
1498
+ cart = cart_response.cart
1499
+
1500
+ # TODO: Set or reset the cart cookie if this is part of a multi-page process. Two weeks is a generous cart ID time.
1501
+ puts "Set-Cookie: #{Constants::CART_ID_COOKIE_NAME}=#{cart.cart_id}; Path=/; Max-Age=1209600"
1502
+
1503
+ puts cart.inspect
1504
+ ```
1505
+
1506
+
1507
+ #### Using the update_cart_with_http_info variant
1508
+
1509
+ This returns an Array which contains the response data, status code and headers.
1510
+
1511
+ > <Array(<CartResponse>, Integer, Hash)> update_cart_with_http_info(cart, opts)
1512
+
1513
+ ```ruby
1514
+ begin
1515
+ # Update cart
1516
+ data, status_code, headers = api_instance.update_cart_with_http_info(cart, opts)
1517
+ p status_code # => 2xx
1518
+ p headers # => { ... }
1519
+ p data # => <CartResponse>
1520
+ rescue UltracartClient::ApiError => e
1521
+ puts "Error when calling CheckoutApi->update_cart_with_http_info: #{e}"
1522
+ end
1523
+ ```
1524
+
1525
+ ### Parameters
1526
+
1527
+ | Name | Type | Description | Notes |
1528
+ | ---- | ---- | ----------- | ----- |
1529
+ | **cart** | [**Cart**](Cart.md) | Cart | |
1530
+ | **_expand** | **String** | The object expansion to perform on the result. See documentation for examples | [optional] |
1531
+
1532
+ ### Return type
1533
+
1534
+ [**CartResponse**](CartResponse.md)
1535
+
1536
+ ### Authorization
1537
+
1538
+ [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
1539
+
1540
+ ### HTTP request headers
1541
+
1542
+ - **Content-Type**: application/json
1543
+ - **Accept**: application/json
1544
+
1545
+
1546
+ ## validate_cart
1547
+
1548
+ > <CartValidationResponse> validate_cart(validation_request, opts)
1549
+
1550
+ Validate
1551
+
1552
+ Validate the cart for errors. Specific checks can be passed and multiple validations can occur throughout your checkout flow.
1553
+
1554
+
1555
+ ### Examples
1556
+
1557
+ ```ruby
1558
+ require 'ultracart_api'
1559
+ require_relative '../constants'
1560
+
1561
+ # Reference Implementation: https://github.com/UltraCart/responsive_checkout
1562
+
1563
+ checkout_api = UltracartClient::CheckoutApi.new_using_api_key(Constants::API_KEY)
1564
+
1565
+ cart_id = '123456789123456789123456789123456789' # Usually this would be retrieved from a session variable or cookie.
1566
+
1567
+ expansion = 'items,billing,shipping,coupons,checkout,payment,summary,taxes'
1568
+
1569
+ cart = checkout_api.get_cart_by_cart_id(cart_id, {_expand: expansion}).cart
1570
+
1571
+ validation_request = UltracartClient::CartValidationRequest.new
1572
+ validation_request.cart = cart
1573
+
1574
+ # Possible Checks (you can set these as needed, or leave as default):
1575
+ # validation_request.set_checks(["All", "Item Quantity Valid", "Payment Information Validate"])
1576
+
1577
+ api_response = checkout_api.validate_cart(validation_request, {_expand: expansion})
1578
+ cart = api_response.cart
1579
+
1580
+ puts "Validation Errors:"
1581
+ puts api_response.errors.inspect
1582
+ ```
1583
+
1584
+
1585
+ #### Using the validate_cart_with_http_info variant
1586
+
1587
+ This returns an Array which contains the response data, status code and headers.
1588
+
1589
+ > <Array(<CartValidationResponse>, Integer, Hash)> validate_cart_with_http_info(validation_request, opts)
1590
+
1591
+ ```ruby
1592
+ begin
1593
+ # Validate
1594
+ data, status_code, headers = api_instance.validate_cart_with_http_info(validation_request, opts)
1595
+ p status_code # => 2xx
1596
+ p headers # => { ... }
1597
+ p data # => <CartValidationResponse>
1598
+ rescue UltracartClient::ApiError => e
1599
+ puts "Error when calling CheckoutApi->validate_cart_with_http_info: #{e}"
1600
+ end
1601
+ ```
1602
+
1603
+ ### Parameters
1604
+
1605
+ | Name | Type | Description | Notes |
1606
+ | ---- | ---- | ----------- | ----- |
1607
+ | **validation_request** | [**CartValidationRequest**](CartValidationRequest.md) | Validation request | |
1608
+ | **_expand** | **String** | The object expansion to perform on the result. See documentation for examples | [optional] |
1609
+
1610
+ ### Return type
1611
+
1612
+ [**CartValidationResponse**](CartValidationResponse.md)
1613
+
1614
+ ### Authorization
1615
+
1616
+ [ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
1617
+
1618
+ ### HTTP request headers
1619
+
1620
+ - **Content-Type**: application/json
1621
+ - **Accept**: application/json
1622
+