Sha256: eb757da46cf6c691d00fc0bcd4942d3bae9a36f410bd750029b1d17e2dc5b291

Contents?: true

Size: 711 Bytes

Versions: 4

Compression:

Stored size: 711 Bytes

Contents

# encoding: utf-8
require File.join(File.dirname(__FILE__), '..', 'pagarme')

module PagarMe
  class Subscription < TransactionCommon


	def create
	  if self.plan
		self.plan_id = plan.id
	  end

	  self.plan = nil
	  super
	end

	def save
	  if self.plan
		self.plan_id = plan.id
	  end

	  self.plan = nil
	  super
	end

	def cancel
	  request = PagarMe::Request.new(self.url + '/cancel', 'POST')
	  response = request.run
	  update(response)
	end

	def charge(amount)
	  request = PagarMe::Request.new(self.url + '/transactions', 'POST')
	  request.parameters = {
		:amount => amount,
	  }
	  response = request.run

	  request = PagarMe::Request.new(self.url, 'GET')
	  update(request.run)
	end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pagarme-1.9.2 lib/pagarme/subscription.rb
pagarme-1.9.1 lib/pagarme/subscription.rb
pagarme-1.9 lib/pagarme/subscription.rb
pagarme-1.8 lib/pagarme/subscription.rb