Sha256: f91de20d53fafaa320829be36b768bf93439a1737a54783de02132c53de07cac

Contents?: true

Size: 833 Bytes

Versions: 4

Compression:

Stored size: 833 Bytes

Contents

require 'razorpay/request'
require 'razorpay/refund'
require 'razorpay/entity'

module Razorpay
  # Payment class is the most commonly used class
  # and is used to interact with Payments, the most
  # common type of transactions
  class Payment < Entity
    def self.request
      Razorpay::Request.new('payments')
    end

    def self.fetch(id)
      request.fetch id
    end

    def self.all(options = {})
      request.all options
    end

    def refund(options = {})
      self.class.request.post "#{id}/refund", options
    end

    def refunds
      # This needs to be a string, not a symbol
      Refund.new('payment_id' => id)
    end

    def capture(options)
      fail ArgumentError, 'Please provide capture amount' unless options.key?(:amount)
      self.class.request.post "#{id}/capture", options
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
razorpay-1.0.3 lib/razorpay/payment.rb
razorpay-1.0.2 lib/razorpay/payment.rb
razorpay-1.0.1 lib/razorpay/payment.rb
razorpay-1.0.0 lib/razorpay/payment.rb