Sha256: 686bd2bd85642da66375e3c7fd4db76cf4151bcfd65faf3113d0d6225a4ef8d5

Contents?: true

Size: 844 Bytes

Versions: 2

Compression:

Stored size: 844 Bytes

Contents

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

module Razorpay
  # Order API is currently in beta and allows you to
  # associate Payments with an order entity
  class Order < Entity
    def self.request
      Razorpay::Request.new('orders')
    end

    def self.create(options)
      raise ArgumentError, 'Please provide order amount' unless options.key?(:amount)
      raise ArgumentError, 'Please provide order currency' unless options.key?(:currency)
      raise ArgumentError, 'Please provide order receipt' unless options.key?(:receipt)
      request.create options
    end

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

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

    def payments(options = {})
      r = self.class.request
      r.request :get, "/orders/#{id}/payments", options
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
razorpay-1.2.0 lib/razorpay/order.rb
razorpay-1.1.0 lib/razorpay/order.rb