Class: Workarea::GlobalE::CheckoutCartInfo
- Inherits:
-
Object
- Object
- Workarea::GlobalE::CheckoutCartInfo
- Defined in:
- app/services/workarea/global_e/checkout_cart_info.rb
Instance Attribute Summary collapse
-
#order ⇒ Object
readonly
Returns the value of attribute order.
Instance Method Summary collapse
-
#allow_mails_from_merchant ⇒ Boolean
Indicates if end customer’s consent to receive emails from merchants should be pre-selected in Global- e checkout.
-
#billing_details ⇒ Object
Billing details of a registered user (if available on the Merchant’s site).
-
#cart_id ⇒ String
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.
-
#client_ip ⇒ String
End customer’s IP address optional.
-
#country_code ⇒ String
2-char ISO country code of the shipping country either pre-defined using geo-location or actively selected by the end customer.
-
#culture_code ⇒ Object
ISO culture code.
-
#current_code ⇒ String
3-char ISO currency code denoting the end customer’s currency.
-
#discounts_list ⇒ Array<Workarea::GlobalE::Discount>
List of JSON-serialized Discounts to be applied to the cart.
-
#do_not_charge_vat ⇒ Boolean
Indicates if the end customer must not be charged VAT.
-
#free_shipping_coupon_code ⇒ String
Merchant’s free shipping coupon code applied by the end customer.
-
#hub_id ⇒ Integer
Identifier of the Global-e’s Local Hub previously returned by ActiveHubDetails method.
-
#include_vat ⇒ Integer
IncludeVAT value returned from CountryCoefficients method (optional for the merchants not supporting browsing integration).
-
#initialize(order) ⇒ CheckoutCartInfo
constructor
A new instance of CheckoutCartInfo.
-
#is_free_shipping ⇒ Boolean
Indicates if the Merchant offers free international shipping to the end customer.
-
#loyalty_code ⇒ String
Loyalty code specified by the end customer (or read from the end customer’s account) on the Merchant’s site.
-
#loyalty_points ⇒ Workarea::GlobalE::LoyaltyPoints
Holds information on the registered user for apply loyalty points in the checkout page.
-
#loyalty_points_earned ⇒ Float
Number of loyalty points to be earned for this purchase by the end customer on the Merchant’s site.
-
#loyalty_points_spent ⇒ Float
Number of loyalty points to be spent for this purchase by the end customer on the Merchant’s site.
-
#loyalty_points_total ⇒ Float
Total number of loyalty points currently available in the end customer’s user account on the Merchant’s site.
-
#merchant_cart_hash ⇒ String
Hash optionally generated by the merchant, to be returned to the merchant with order API call.
-
#original_currency_code ⇒ String
3-char ISO currency code denoting the original currency on the Merchant’s site (before applying country coefficient and FX conversion).
-
#payment_installments ⇒ String
List of available payment installment amounts.
-
#products_list ⇒ Array<Workarea::GlobalE::Product>
List of Product objects (specified in request body).
-
#shipping_details ⇒ Object
Shipping details of a registered user (if available on the Merchant’s site).
-
#shipping_options_list ⇒ Array<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.
- #to_json ⇒ Object
-
#url_parameters ⇒ Array<Hash>
List of JSON-serialized KeyValuePairs that denote parameter values to be specified in the respective Merchant’s RESTFul API action URLs.
-
#user_details ⇒ Workarea::GlobalE::CartUserDetails
All available details of the user including all relevant addresses.
-
#vat_registration_number ⇒ String
VAT Registration Number of the end customer’s business entity validated with the merchant.
-
#web_store_code ⇒ String
Code used on the merchant’s side to identify the web store where the current cart is originating from.
-
#web_store_instance_code ⇒ String
Code used on the merchant’s side to identify the web store instance where the current cart is originating from.
Constructor Details
#initialize(order) ⇒ CheckoutCartInfo
Returns a new instance of CheckoutCartInfo.
8 9 10 |
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 8 def initialize(order) @order = order end |
Instance Attribute Details
#order ⇒ Object (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_merchant ⇒ Boolean
Indicates if end customer’s consent to receive emails from merchants should be pre-selected in Global- e checkout.
282 283 |
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 282 def allow_mails_from_merchant end |
#billing_details ⇒ Object
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_id ⇒ String
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.
290 291 |
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 290 def cart_id end |
#client_ip ⇒ String
End customer’s IP address optional
35 36 37 |
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 35 def client_ip order.ip_address end |
#country_code ⇒ String
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
48 49 |
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 48 def country_code end |
#culture_code ⇒ Object
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_code ⇒ String
3-char ISO currency code denoting the end customer’s currency. If not specified, the Merchant’s default currency will be assumed by default.
108 109 |
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 108 def current_code end |
#discounts_list ⇒ Array<Workarea::GlobalE::Discount>
List of JSON-serialized Discounts to be applied to the cart. Discounts of any type (“cart”, “shipping”, etc.) may be specified.
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_vat ⇒ Boolean
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.
202 203 |
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 202 def do_not_charge_vat end |
#free_shipping_coupon_code ⇒ String
Merchant’s free shipping coupon code applied by the end customer.
217 218 |
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 217 def free_shipping_coupon_code end |
#hub_id ⇒ Integer
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.
152 153 |
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 152 def hub_id end |
#include_vat ⇒ Integer
IncludeVAT value returned from CountryCoefficients method (optional for the merchants not supporting browsing integration)
91 92 |
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 91 def include_vat end |
#is_free_shipping ⇒ Boolean
Indicates if the Merchant offers free international shipping to the end customer.
210 211 |
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 210 def is_free_shipping end |
#loyalty_code ⇒ String
Loyalty code specified by the end customer (or read from the end customer’s account) on the Merchant’s site.
184 185 |
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 184 def loyalty_code end |
#loyalty_points ⇒ Workarea::GlobalE::LoyaltyPoints
Holds information on the registered user for apply loyalty points in the checkout page.
265 266 |
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 265 def loyalty_points end |
#loyalty_points_earned ⇒ Float
Number of loyalty points to be earned for this purchase by the end customer on the Merchant’s site.
168 169 |
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 168 def loyalty_points_earned end |
#loyalty_points_spent ⇒ Float
Number of loyalty points to be spent for this purchase by the end customer on the Merchant’s site.
176 177 |
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 176 def loyalty_points_spent end |
#loyalty_points_total ⇒ Float
Total number of loyalty points currently available in the end customer’s user account on the Merchant’s site.
160 161 |
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 160 def loyalty_points_total end |
#merchant_cart_hash ⇒ String
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
274 275 |
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 274 def merchant_cart_hash end |
#original_currency_code ⇒ String
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.
118 119 |
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 118 def original_currency_code end |
#payment_installments ⇒ String
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)
226 227 |
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 226 def payment_installments end |
#products_list ⇒ Array<Workarea::GlobalE::Product>
List of Product objects (specified in request body)
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_details ⇒ Object
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_list ⇒ Array<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)
143 144 |
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 143 def end |
#to_json ⇒ Object
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_parameters ⇒ Array<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.
239 240 |
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 239 def url_parameters end |
#user_details ⇒ Workarea::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_number ⇒ String
VAT Registration Number of the end customer’s business entity validated with the merchant.
192 193 |
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 192 def vat_registration_number end |
#web_store_code ⇒ String
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.
248 249 |
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 248 def web_store_code end |
#web_store_instance_code ⇒ String
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.
257 258 |
# File 'app/services/workarea/global_e/checkout_cart_info.rb', line 257 def web_store_instance_code end |