Class: Spree::WalletonePaymentProcessing

Inherits:
Object
  • Object
show all
Defined in:
app/models/spree/walletone_payment_processing.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ WalletonePaymentProcessing

Returns a new instance of WalletonePaymentProcessing


5
6
7
8
9
10
11
# File 'app/models/spree/walletone_payment_processing.rb', line 5

def initialize(options)
  @payment_id = options[:payment_id]
  @order_id = options[:order_id]
  @payer_id = options[:payer_id]
  @payment_method_id = options[:payment_method_id]
  @amount = options[:amount]
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount


3
4
5
# File 'app/models/spree/walletone_payment_processing.rb', line 3

def amount
  @amount
end

#order_idObject (readonly)

Returns the value of attribute order_id


3
4
5
# File 'app/models/spree/walletone_payment_processing.rb', line 3

def order_id
  @order_id
end

#payer_idObject (readonly)

Returns the value of attribute payer_id


3
4
5
# File 'app/models/spree/walletone_payment_processing.rb', line 3

def payer_id
  @payer_id
end

#payment_idObject (readonly)

Returns the value of attribute payment_id


3
4
5
# File 'app/models/spree/walletone_payment_processing.rb', line 3

def payment_id
  @payment_id
end

#payment_method_idObject (readonly)

Returns the value of attribute payment_method_id


3
4
5
# File 'app/models/spree/walletone_payment_processing.rb', line 3

def payment_method_id
  @payment_method_id
end

Instance Method Details

#orderObject


25
26
27
# File 'app/models/spree/walletone_payment_processing.rb', line 25

def order
  @order ||= Spree::Order.find_by_number(order_id)
end

#payment_methodObject


29
30
31
# File 'app/models/spree/walletone_payment_processing.rb', line 29

def payment_method
  Spree::PaymentMethod.find(payment_method_id)
end

#processObject


13
14
15
16
17
18
19
20
21
22
23
# File 'app/models/spree/walletone_payment_processing.rb', line 13

def process
  order.payments.create!({
    source: Spree::WalletoneCheckout.create({
      token: payment_id,
      payer_id: payer_id
    }),
    amount: amount,
    payment_method: payment_method
  })
  order.next
end