Sha256: 78650a8daee6cd14c24f2c08cd9b32c35a6462975fbc77387aec2541757a482c
Contents?: true
Size: 1.54 KB
Versions: 1
Compression:
Stored size: 1.54 KB
Contents
require "nokogiri" module Moiper class Payment # The unique ID you can set for this payment. This is usefull to keep # trak of which payment we will receive on the Moip's notification process. attr_accessor :id # The description of the purchase. attr_accessor :description # The amount to be billed from the user. attr_accessor :price # The URL where the user will be redirected after he finishes the # payment process. attr_accessor :return_url # The URL where Moip will send notifications about your purchase updates. attr_accessor :notification_url # Create a new Moip Payment request def initialize(options = {}) raise ArgumentError if options[:description].nil? || options[:description].empty? raise ArgumentError if options[:price].nil? || options[:price].to_f <= 0 options.each do |attribute, value| send "#{attribute}=", value end end # Create the payment XML representation def to_xml builder = Nokogiri::XML::Builder.new(:encoding => "UTF-8") do |xml| xml.EnviarInstrucao { xml.InstrucaoUnica { xml.Razao description xml.IdProprio id if id xml.Valores { xml.Valor price, :moeda => "BRL" } xml.URLNotificacao notification_url if notification_url xml.URLRetorno return_url if return_url } } end builder.to_xml end def checkout request = Request.new request.process(to_xml) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
moiper-0.1.1 | lib/moiper/payment.rb |