lib/pagseguro_client/order.rb in pagseguro_client-0.3.2 vs lib/pagseguro_client/order.rb in pagseguro_client-0.3.3
- old
+ new
@@ -1,12 +1,13 @@
module PagseguroClient
class Order
- attr_accessor :id, :products
+ attr_accessor :id, :products, :redirect_url
- def initialize(order_id)
+ def initialize(order_id, redirect_url = nil)
self.id = order_id
+ self.redirect_url = redirect_url
self.products = []
end
# The allowed values are:
# - id (Required. Should match the product in your database)
@@ -17,10 +18,11 @@
products.push(options)
end
def data
data = { email: PagseguroClient.email, token: PagseguroClient.token, currency: "BRL", reference: id }
- data["redirectURL"] = PagseguroClient.redirect_url if PagseguroClient.redirect?
+ data["redirectURL"] = redirect_url
+ data["redirectURL"] ||= PagseguroClient.redirect_url if PagseguroClient.redirect?
products.each_with_index do |item, index|
index += 1
data["itemId#{index}"] = item[:id]
data["itemDescription#{index}"] = item[:description].to_s.unpack("U*").pack("C*")