class Moka::Payment
Attributes
amount[RW]
buyer[RW]
card_holder_full_name[RW]
card_number[RW]
card_token[RW]
client_ip[RW]
credit_card[RW]
currency[RW]
cvc_number[RW]
description[RW]
exp_month[RW]
exp_year[RW]
installment_number[RW]
integrator_id[RW]
is_pool_payment[RW]
is_pre_auth[RW]
other_trx_code[RW]
redirect_type[RW]
redirect_url[RW]
refund_request_id[RW]
response[RW]
result_code[RW]
software[RW]
virtual_pos_order_id[RW]
void_refund_reason[RW]
Public Class Methods
new(opts = {})
click to toggle source
# 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
Public Instance Methods
pay()
click to toggle source
# 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_d()
click to toggle source
# 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
refund()
click to toggle source
# 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?()
click to toggle source
# File lib/moka/model/payment.rb, line 47 def success? response && response['ResultCode'] == 'Success' && response['Data']['IsSuccessful'] == true end
void()
click to toggle source
# 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
Private Instance Methods
payment_hash()
click to toggle source
# File lib/moka/model/payment.rb, line 52 def payment_hash hsh = { "PaymentDealerAuthentication": Moka.configuration.config_hash, "PaymentDealerRequest": { "CardHolderFullName": card_holder_full_name, "CardNumber": card_number, "ExpMonth": exp_month, "ExpYear": exp_year, "CvcNumber": cvc_number, "CardToken": card_token, "Amount": amount, "Currency": currency, "InstallmentNumber": installment_number || 0, "ClientIP": client_ip, "OtherTrxCode": other_trx_code, "IsPreAuth": is_pre_auth || 0, "IsPoolPayment": is_pool_payment || 0, "IntegratorId": integrator_id, "Software": software, "Description": description } } if buyer && buyer.is_a?(Moka::Customer) hsh[:PaymentDealerRequest][:BuyerInformation] = { "BuyerFullName": buyer.full_name, "BuyerEmail": buyer.email, "BuyerGsmNumber": buyer.email, "BuyerAddress": buyer.address } end hsh end
refund_hash()
click to toggle source
# File lib/moka/model/payment.rb, line 104 def refund_hash { "PaymentDealerAuthentication": Moka.configuration.config_hash, "PaymentDealerRequest": { "VirtualPosOrderId": virtual_pos_order_id, "OtherTrxCode": "", "Amount": amount } } end
three_d_payment_hash()
click to toggle source
# File lib/moka/model/payment.rb, line 85 def three_d_payment_hash hsh = payment_hash hsh[:PaymentDealerRequest][:RedirectUrl] = redirect_url hsh[:PaymentDealerRequest][:RedirectType] = redirect_type hsh end
void_hash()
click to toggle source
# File lib/moka/model/payment.rb, line 92 def void_hash { "PaymentDealerAuthentication": Moka.configuration.config_hash, "PaymentDealerRequest": { "VirtualPosOrderId": virtual_pos_order_id, "ClientIP": client_ip, "VoidRefundReason": void_refund_reason || 2 } } end