Class: Moka::Payment

Inherits:
Object
  • Object
show all
Defined in:
lib/moka/model/payment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Payment

Returns a new instance of Payment.



13
14
15
16
17
# File 'lib/moka/model/payment.rb', line 13

def initialize(opts = {})
  opts.each do |o|
    send("#{o.first.to_s}=".to_sym, o.last)
  end
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



3
4
5
# File 'lib/moka/model/payment.rb', line 3

def amount
  @amount
end

#buyerObject

Returns the value of attribute buyer.



3
4
5
# File 'lib/moka/model/payment.rb', line 3

def buyer
  @buyer
end

#card_holder_full_nameObject

Returns the value of attribute card_holder_full_name.



3
4
5
# File 'lib/moka/model/payment.rb', line 3

def card_holder_full_name
  @card_holder_full_name
end

#card_numberObject

Returns the value of attribute card_number.



3
4
5
# File 'lib/moka/model/payment.rb', line 3

def card_number
  @card_number
end

#card_tokenObject

Returns the value of attribute card_token.



3
4
5
# File 'lib/moka/model/payment.rb', line 3

def card_token
  @card_token
end

#client_ipObject

Returns the value of attribute client_ip.



3
4
5
# File 'lib/moka/model/payment.rb', line 3

def client_ip
  @client_ip
end

#credit_cardObject

Returns the value of attribute credit_card.



3
4
5
# File 'lib/moka/model/payment.rb', line 3

def credit_card
  @credit_card
end

#currencyObject

Returns the value of attribute currency.



3
4
5
# File 'lib/moka/model/payment.rb', line 3

def currency
  @currency
end

#cvc_numberObject

Returns the value of attribute cvc_number.



3
4
5
# File 'lib/moka/model/payment.rb', line 3

def cvc_number
  @cvc_number
end

#descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/moka/model/payment.rb', line 3

def description
  @description
end

#exp_monthObject

Returns the value of attribute exp_month.



3
4
5
# File 'lib/moka/model/payment.rb', line 3

def exp_month
  @exp_month
end

#exp_yearObject

Returns the value of attribute exp_year.



3
4
5
# File 'lib/moka/model/payment.rb', line 3

def exp_year
  @exp_year
end

#installment_numberObject

Returns the value of attribute installment_number.



3
4
5
# File 'lib/moka/model/payment.rb', line 3

def installment_number
  @installment_number
end

#integrator_idObject

Returns the value of attribute integrator_id.



3
4
5
# File 'lib/moka/model/payment.rb', line 3

def integrator_id
  @integrator_id
end

#is_pool_paymentObject

Returns the value of attribute is_pool_payment.



3
4
5
# File 'lib/moka/model/payment.rb', line 3

def is_pool_payment
  @is_pool_payment
end

#is_pre_authObject

Returns the value of attribute is_pre_auth.



3
4
5
# File 'lib/moka/model/payment.rb', line 3

def is_pre_auth
  @is_pre_auth
end

#other_trx_codeObject

Returns the value of attribute other_trx_code.



3
4
5
# File 'lib/moka/model/payment.rb', line 3

def other_trx_code
  @other_trx_code
end

#redirect_typeObject

Returns the value of attribute redirect_type.



3
4
5
# File 'lib/moka/model/payment.rb', line 3

def redirect_type
  @redirect_type
end

#redirect_urlObject

Returns the value of attribute redirect_url.



3
4
5
# File 'lib/moka/model/payment.rb', line 3

def redirect_url
  @redirect_url
end

#refund_request_idObject

Returns the value of attribute refund_request_id.



3
4
5
# File 'lib/moka/model/payment.rb', line 3

def refund_request_id
  @refund_request_id
end

#responseObject

Returns the value of attribute response.



3
4
5
# File 'lib/moka/model/payment.rb', line 3

def response
  @response
end

#result_codeObject

Returns the value of attribute result_code.



3
4
5
# File 'lib/moka/model/payment.rb', line 3

def result_code
  @result_code
end

#softwareObject

Returns the value of attribute software.



3
4
5
# File 'lib/moka/model/payment.rb', line 3

def software
  @software
end

#virtual_pos_order_idObject

Returns the value of attribute virtual_pos_order_id.



3
4
5
# File 'lib/moka/model/payment.rb', line 3

def virtual_pos_order_id
  @virtual_pos_order_id
end

#void_refund_reasonObject

Returns the value of attribute void_refund_reason.



3
4
5
# File 'lib/moka/model/payment.rb', line 3

def void_refund_reason
  @void_refund_reason
end

Instance Method Details

#payObject



19
20
21
22
23
24
# File 'lib/moka/model/payment.rb', line 19

def pay
  response          = RestClient.post Moka.endpoints.direct_payment, payment_hash
  self.response     = JSON.parse(response.body)
  self.result_code  = self.response['ResultCode']
  self.response
end

#pay_three_dObject



26
27
28
29
30
31
# File 'lib/moka/model/payment.rb', line 26

def pay_three_d
  response          = RestClient.post Moka.endpoints.direct_payment_three_d, three_d_payment_hash
  self.response     = JSON.parse(response.body)
  self.result_code  = self.response['ResultCode']
  self.response
end

#refundObject



40
41
42
43
44
45
# File 'lib/moka/model/payment.rb', line 40

def refund
  response          = RestClient.post Moka.endpoints.refund, refund_hash
  self.response     = JSON.parse(response.body)
  self.result_code  = self.response['ResultCode']
  self.response
end

#success?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/moka/model/payment.rb', line 47

def success?
  response && response['ResultCode'] == 'Success' && response['Data']['IsSuccessful'] == true
end

#voidObject



33
34
35
36
37
38
# File 'lib/moka/model/payment.rb', line 33

def void
  response          = RestClient.post Moka.endpoints.void, void_hash
  self.response     = JSON.parse(response.body)
  self.result_code  = self.response['ResultCode']
  self.response
end