class KsAPIRefund::KsRefund
Attributes
amount[RW]
currency_code[RW]
note[RW]
params[RW]
refund_type[RW]
transaction_id[RW]
Public Class Methods
new(params)
click to toggle source
Class default constructor
# File lib/koduc_refund/koduc_refund.rb, line 17 def initialize(params) @transaction_id = params[:transaction_id] @amount = params[:amount] @currency_code = params[:payment_currency] @note = params[:note] @refund_type = '' end
Public Instance Methods
ks_refund()
click to toggle source
Method to invoke the refund functionality If the refund type is 'full' dont merge the amount, currency code and note Check the validity of the parameters first If response is true call the Refund API Else return the response obtained from the valid? method
# File lib/koduc_refund/koduc_refund.rb, line 70 def ks_refund env = KsCheckEnvironment::ks_sandbox(false) response = valid? if response[:success] refund_type = refund_type? case refund_type when 'Full' ks_response = KsExpressPaypal::KsRequest.ks_request :RefundTransaction,KsExpressPaypal.ks_merchants_details.merge(transaction).merge(:REFUNDTYPE=>refund_type) else ks_response = KsExpressPaypal::KsRequest.ks_request :RefundTransaction,KsExpressPaypal.ks_merchants_details.merge(transaction).merge(:REFUNDTYPE=>refund_type).merge(partial_params) end else return response end end
partial_params()
click to toggle source
Returns the parameters for the partial payment
# File lib/koduc_refund/koduc_refund.rb, line 48 def partial_params partial_params = { :AMT => amount, :CURRENCYCODE => currency_code, :NOTE => note } return partial_params end
refund_type?()
click to toggle source
Check for the refund type If amount, currency code and note are blank, it will be 'Full' Else it will be partial Returns the refund type
# File lib/koduc_refund/koduc_refund.rb, line 38 def refund_type? if amount.blank? && currency_code.blank? && note.blank? refund_type = 'Full' else refund_type = 'Partial' end return refund_type end
transaction()
click to toggle source
Returns the transaction id in the hash format
# File lib/koduc_refund/koduc_refund.rb, line 58 def transaction transaction = { :TRANSACTIONID=>transaction_id } return transaction end
valid?()
click to toggle source
Method will check the validity of the parameters initialised with the help of the constructor Form a new object of the RefundValidation
class Returns the response fetched from the check_validity method
# File lib/koduc_refund/koduc_refund.rb, line 28 def valid? obj= RefundValidation.new(transaction_id,amount,currency_code,note) response = obj.check_validity return response end