Class: Workarea::GlobalE::CheckoutCartInfo

Inherits:
Object
  • Object
show all
Defined in:
app/services/workarea/global_e/checkout_cart_info.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(order) ⇒ CheckoutCartInfo

Returns a new instance of CheckoutCartInfo.

Parameters:

  • order (Workarea::Order)


8
9
10
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 8

def initialize(order)
  @order = order
end

Instance Attribute Details

#orderObject (readonly)

Returns the value of attribute order.



4
5
6
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 4

def order
  @order
end

Instance Method Details

#allow_mails_from_merchantBoolean

Indicates if end customer’s consent to receive emails from merchants should be pre-selected in Global- e checkout.

Returns:

  • (Boolean)


282
283
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 282

def allow_mails_from_merchant
end

#billing_detailsObject

Billing details of a registered user (if available on the Merchant’s site). If user_details property mentioned below is specified then billing_details will be ignored.



69
70
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 69

def billing_details
end

#cart_idString

String that represents merchant order id if it’s known already at the point when the user is still in the cart page on the merchant’s store.

Returns:

  • (String)


290
291
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 290

def cart_id
end

#client_ipString

End customer’s IP address optional

Returns:

  • (String)


35
36
37
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 35

def client_ip
  order.ip_address
end

#country_codeString

2-char ISO country code of the shipping country either pre-defined using geo-location or actively selected by the end customer. This may be different from shipping_details.country_code property denoting the registered user’s country defined below.

optional

Returns:

  • (String)


48
49
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 48

def country_code
end

#culture_codeObject

ISO culture code. If specified, the textual properties will be returned in the requested culture’s language if available. Texts in English will be returned by default.



127
128
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 127

def culture_code
end

#current_codeString

3-char ISO currency code denoting the end customer’s currency. If not specified, the Merchant’s default currency will be assumed by default.

Returns:

  • (String)


108
109
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 108

def current_code
end

#discounts_listArray<Workarea::GlobalE::Discount>

List of JSON-serialized Discounts to be applied to the cart. Discounts of any type (“cart”, “shipping”, etc.) may be specified.

Returns:



99
100
101
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 99

def discounts_list
  item_discounts + order_discounts
end

#do_not_charge_vatBoolean

Indicates if the end customer must not be charged VAT. This is usually set to TRUE for registered users who have validated their business entity’s VAT Registration Number with the merchant and are therefore VAT exempted.

Returns:

  • (Boolean)


202
203
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 202

def do_not_charge_vat
end

#free_shipping_coupon_codeString

Merchant’s free shipping coupon code applied by the end customer.

Returns:

  • (String)


217
218
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 217

def free_shipping_coupon_code
end

#hub_idInteger

Identifier of the Global-e’s Local Hub previously returned by ActiveHubDetails method. If not specified, the default Merchant’s Hub will be used instead.

Returns:

  • (Integer)


152
153
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 152

def hub_id
end

#include_vatInteger

IncludeVAT value returned from CountryCoefficients method (optional for the merchants not supporting browsing integration)

Returns:

  • (Integer)


91
92
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 91

def include_vat
end

#is_free_shippingBoolean

Indicates if the Merchant offers free international shipping to the end customer.

Returns:

  • (Boolean)


210
211
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 210

def is_free_shipping
end

#loyalty_codeString

Loyalty code specified by the end customer (or read from the end customer’s account) on the Merchant’s site.

Returns:

  • (String)


184
185
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 184

def loyalty_code
end

#loyalty_pointsWorkarea::GlobalE::LoyaltyPoints

Holds information on the registered user for apply loyalty points in the checkout page.

Returns:

  • (Workarea::GlobalE::LoyaltyPoints)


265
266
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 265

def loyalty_points
end

#loyalty_points_earnedFloat

Number of loyalty points to be earned for this purchase by the end customer on the Merchant’s site.

Returns:

  • (Float)


168
169
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 168

def loyalty_points_earned
end

#loyalty_points_spentFloat

Number of loyalty points to be spent for this purchase by the end customer on the Merchant’s site.

Returns:

  • (Float)


176
177
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 176

def loyalty_points_spent
end

#loyalty_points_totalFloat

Total number of loyalty points currently available in the end customer’s user account on the Merchant’s site.

Returns:

  • (Float)


160
161
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 160

def loyalty_points_total
end

#merchant_cart_hashString

Hash optionally generated by the merchant, to be returned to the merchant with order API call. This hash may be used for additional cart and order validation purposes on the Merchant’s side

Returns:

  • (String)


274
275
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 274

def merchant_cart_hash
end

#original_currency_codeString

3-char ISO currency code denoting the original currency on the Merchant’s site (before applying country coefficient and FX conversion). If not specified, the Merchant’s default currency will be assumed by default.

Returns:

  • (String)


118
119
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 118

def original_currency_code
end

#payment_installmentsString

List of available payment installment amounts. Example: 2,4,6,8 – This indicates that we should allow installments in 2, 4, 6 or 8 installment options (to be selected by the customer)

Returns:

  • (String)


226
227
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 226

def payment_installments
end

#products_listArray<Workarea::GlobalE::Product>

List of Product objects (specified in request body)

Returns:



26
27
28
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 26

def products_list
  @product_list ||= order.items.map { |i| GlobalE::Product.from_order_item i }
end

#shipping_detailsObject

Shipping details of a registered user (if available on the Merchant’s site). If user_details property mentioned below is specified then shipping_details will be ignored.

If country_code argument defined above is not specified, the shipping country must be specified in ‘shipping_details.country_code property. If not specified neither in country_code argument nor in shipping_details.country_code property, client_iP argument defined above becomes mandatory and will be used to determine the end user’s shipping country by Global-e system.



62
63
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 62

def shipping_details
end

#shipping_options_listArray<Workarea::GlobalE::ShippingOption>

List of JSON-serialized Shipping Options available for local shipping of the order from the Merchant to Global-e’s Local Hub previously returned by ActiveHubDetails method. If “globaleintegration_standard” shipping method has been created and enabled for Global-e on the Merchant’s site, Global-e will prefer this Shipping Option when posting the order back to the Merchant’s site (using SendOrderToMerchant API method). Therefore, all other shipping methods available for the local shipping may be omitted in shippingOptionsList. (optional in GetCheckoutCartInfo)

Returns:

  • (Array<Workarea::GlobalE::ShippingOption>)


143
144
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 143

def shipping_options_list
end

#to_jsonObject



12
13
14
15
16
17
18
19
20
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 12

def to_json
  {
    productsList: products_list,
    clientIp: client_ip,
    userDetails: user_details,
    discountsList: discounts_list,
    cartId: cart_id
  }.compact.to_json
end

#url_parametersArray<Hash>

List of JSON-serialized KeyValuePairs that denote parameter values to be specified in the respective Merchant’s RESTFul API action URLs. For example to instruct Global-e to include “en-AU” locale in SendOrderToMerhant call for this cart, urlParameters should include the following KeyValuePair: [“Value”:“en-AU”]. In this example “locale” parameter should be configured for SendOrderToMerhant URL for this merchant on Global-e side.

Returns:

  • (Array<Hash>)


239
240
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 239

def url_parameters
end

#user_detailsWorkarea::GlobalE::CartUserDetails

All available details of the user including all relevant addresses. If userDetails is not specified then shippingDetails and billingDetails properties will be used instead. userDetails property can be used by merchants who support multiple shipping and / or multiple billing addresses in user’s account.



80
81
82
83
84
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 80

def user_details
  return unless user.present?

  @user_details ||= GlobalE::CartUserDetails.new(user)
end

#vat_registration_numberString

VAT Registration Number of the end customer’s business entity validated with the merchant.

Returns:

  • (String)


192
193
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 192

def vat_registration_number
end

#web_store_codeString

Code used on the merchant’s side to identify the web store where the current cart is originating from. This code should be used in case of multi-store setup on the merchant’s site.

Returns:

  • (String)


248
249
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 248

def web_store_code
end

#web_store_instance_codeString

Code used on the merchant’s side to identify the web store instance where the current cart is originating from. This code should be used in case of multi-store domains setup on the merchant’s site.

Returns:

  • (String)


257
258
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 257

def web_store_instance_code
end