class PS::Payment

Attributes

actual_settled_date[RW]
amount[RW]
can_void_until[RW]
customer_account_id[RW]
customer_id[RW]
description[RW]
estimate_settled_date[RW]
invoice_id[RW]
invoice_number[RW]
is_debit[RW]
order_id[RW]
payment_date[RW]
payment_sub_type[RW]
payment_type[RW]
provider_auth_code[RW]
purchase_order_number[RW]
recurring_schedule_id[RW]
ref_payment_id[RW]
status[RW]
trace_number[RW]

Public Class Methods

cancel_by_id(payment_id) click to toggle source
# File lib/ps/objects/payment.rb, line 23
def cancel_by_id(payment_id)
  request("cancelpayment", { :paymentId =>  payment_id })
  true
end
list(customer_id, criteria=nil) click to toggle source
# File lib/ps/objects/payment.rb, line 14
def list(customer_id, criteria=nil)
  request("listpayments", { :customerId => customer_id, :criteria => criteria }, &instantiate_object)
end
make(customer_id, amount, account_id=nil, cid="", order_details=nil) click to toggle source
# File lib/ps/objects/payment.rb, line 28
def make(customer_id, amount, account_id=nil, cid="", order_details=nil)
  request("makepayment", 
    {
      :customerId => customer_id,
      :customerAccountId => account_id,
      :amount => amount,
      :cid => cid,
      :detail => order_details 
    }, &instantiate_object)
end
reverse_by_id(payment_id) click to toggle source
# File lib/ps/objects/payment.rb, line 18
def reverse_by_id(payment_id)
  request("reversepayment", { :paymentId => payment_id })
  true
end

Public Instance Methods

cancel() click to toggle source
# File lib/ps/objects/payment.rb, line 5
def cancel
  request("cancelpayment", { :paymentId => self.ps_reference_id }, &update_by_find)
end
reverse() click to toggle source
# File lib/ps/objects/payment.rb, line 9
def reverse
  request("reversepayment", { :paymentId => self.ps_reference_id }, &update_by_find)
end

Private Instance Methods

update_by_find() click to toggle source
# File lib/ps/objects/payment.rb, line 41
def update_by_find
  Proc.new do
    i = 0
    loop do
      payments = self.class
      .list(self.customer_id, { :page => i, :items_per_page => 200 })
      case payments
      when []
        break
      when Array
        updated = false
        payments.each do |payment|
          if payment.ps_reference_id == self.ps_reference_id then
            set_attributes(payment.attributes) 
            updated = true
            break
          end
        end
        break if updated
      when PS::Payment
        if payments.ps_reference_id == self.ps_reference_id then
          set_attributes(payments.attributes) 
        end
        # break here because if only one payment is returned, then it's
        # only one that exists or it is the last one...
        break
      end
      i += 1
    end
  end
end