Class: FlexCommerce::PaypalExpress::Process::PaypalParams

Inherits:
Object
  • Object
show all
Includes:
Api
Defined in:
lib/paypal_express/process/paypal_params.rb

Constant Summary collapse

DEFAULT_DESCRIPTION =
"Shift Commerce Order".freeze

Constants included from Api

Api::USER_ERRORS

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cart:, success_url:, cancel_url:, ip_address:, allow_shipping_change: true, callback_url:, shipping_method_model: FlexCommerce::ShippingMethod, use_mobile_payments: false, description:) ⇒ PaypalParams

Returns a new instance of PaypalParams.

Parameters:

  • payment_provider_setup (FlexCommerce::PaymentProviderSetup)
  • cart (FlexCommerce::Cart)
  • [gateway_class (Paypal Gateway)

    ::ActiveMerchant::Billing::PaypalExpressGateway]

  • success_url (URL)
    • Generally Paypal confirmation page

  • cancel_url (URL)
    • Generally new transaction page

  • ip_address (IP)
    • User ip address

  • [allow_shipping_change (boolean)

    true] - true: display shipping options, false: dont display shipping options

  • callback_url (URL)
    • Generally cart show page

  • shipping_method_model (FlexCommerce::ShippingMethod) (defaults to: FlexCommerce::ShippingMethod)

    FlexCommerce::ShippingMethod

  • [use_mobile_payments (boolean)

    false]

  • [description] (String)


27
28
29
30
31
32
33
34
35
36
37
# File 'lib/paypal_express/process/paypal_params.rb', line 27

def initialize(cart:,success_url:, cancel_url:, ip_address:, allow_shipping_change: true, callback_url:, shipping_method_model: FlexCommerce::ShippingMethod, use_mobile_payments: false, description:)
  self.cart = cart
  self.allow_shipping_change = allow_shipping_change
  self.success_url = success_url
  self.cancel_url = cancel_url
  self.ip_address = ip_address
  self.callback_url = callback_url
  self.shipping_method_model = shipping_method_model
  self.use_mobile_payments = use_mobile_payments
  self.description = description
end

Instance Attribute Details

#allow_shipping_changeObject

Returns the value of attribute allow_shipping_change.



47
48
49
# File 'lib/paypal_express/process/paypal_params.rb', line 47

def allow_shipping_change
  @allow_shipping_change
end

#callback_urlObject

Returns the value of attribute callback_url.



47
48
49
# File 'lib/paypal_express/process/paypal_params.rb', line 47

def callback_url
  @callback_url
end

#cancel_urlObject

Returns the value of attribute cancel_url.



47
48
49
# File 'lib/paypal_express/process/paypal_params.rb', line 47

def cancel_url
  @cancel_url
end

#cartObject

Returns the value of attribute cart.



47
48
49
# File 'lib/paypal_express/process/paypal_params.rb', line 47

def cart
  @cart
end

#descriptionObject

Returns the value of attribute description.



47
48
49
# File 'lib/paypal_express/process/paypal_params.rb', line 47

def description
  @description
end

#ip_addressObject

Returns the value of attribute ip_address.



47
48
49
# File 'lib/paypal_express/process/paypal_params.rb', line 47

def ip_address
  @ip_address
end

#shipping_method_modelObject

Returns the value of attribute shipping_method_model.



47
48
49
# File 'lib/paypal_express/process/paypal_params.rb', line 47

def shipping_method_model
  @shipping_method_model
end

#success_urlObject

Returns the value of attribute success_url.



47
48
49
# File 'lib/paypal_express/process/paypal_params.rb', line 47

def success_url
  @success_url
end

#use_mobile_paymentsObject

Returns the value of attribute use_mobile_payments.



47
48
49
# File 'lib/paypal_express/process/paypal_params.rb', line 47

def use_mobile_payments
  @use_mobile_payments
end

Instance Method Details

#callObject



39
40
41
42
43
44
45
# File 'lib/paypal_express/process/paypal_params.rb', line 39

def call
  base_paypal_params
    .merge(paypal_shipping_address_params)
    .merge(paypal_items)
    .merge(ui_callback_params)
    .merge(shipping_options_params)
end