Class: Gemgento::API::SOAP::Checkout::Payment

Inherits:
Object
  • Object
show all
Defined in:
lib/gemgento/api/soap/checkout/payment.rb

Class Method Summary collapse

Class Method Details

.compose_additional_information(payment) ⇒ Hash

Compose additional payment attributes hash for Magento API call.

Parameters:

Returns:

  • (Hash)


47
48
49
50
51
52
53
# File 'lib/gemgento/api/soap/checkout/payment.rb', line 47

def self.compose_additional_information(payment)
  additional_information = []
  additional_information << { key: 'save_card', value: payment.save_card } unless payment.save_card.nil?
  additional_information << { key: 'payment_id', value: payment.payment_id } unless payment.payment_id.nil?

  return { item: additional_information }
end

.list(quote) ⇒ Gemgento::MagentoResponse

Get a list of payment methods available for a Quote from Magento.

Parameters:

Returns:



11
12
13
14
15
16
17
# File 'lib/gemgento/api/soap/checkout/payment.rb', line 11

def self.list(quote)
  message = {
      quote_id: quote.magento_id,
      store_id: quote.store.magento_id
  }
  MagentoApi.create_call(:shopping_cart_payment_list, message)
end

.method(quote, payment) ⇒ Gemgento::MagentoResponse

Set the payment method for a Quote in Magento.

Parameters:

Returns:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/gemgento/api/soap/checkout/payment.rb', line 24

def self.method(quote, payment)
  message = {
      quote_id: quote.magento_id,
      method: {
          'po_number' => payment.po_number,
          method: payment.method,
          'cc_cid' => payment.cc_cid,
          'cc_owner' => payment.cc_owner,
          'cc_number' => payment.cc_number,
          'cc_type' => payment.cc_type,
          'cc_exp_year' => payment.cc_exp_year,
          'cc_exp_month' => payment.cc_exp_month,
          'additional_information' => compose_additional_information(payment)
      },
      store_id: quote.store.magento_id
  }
  MagentoApi.create_call(:shopping_cart_payment_method, message)
end