Sha256: 1281b8c546de9719a5d2ee62909c67d515ef50d2137de6af30f28069060828aa

Contents?: true

Size: 638 Bytes

Versions: 3

Compression:

Stored size: 638 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, 'POST')
	  request.parameters = {
		:amount => amount,
	  }
	  response = request.run
	  update(response)
	end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pagarme-1.7 lib/pagarme/subscription.rb
pagarme-1.5 lib/pagarme/subscription.rb
pagarme-1.4 lib/pagarme/subscription.rb