lib/processout/invoice.rb in processout-2.10.0 vs lib/processout/invoice.rb in processout-2.11.0

- old
+ new

@@ -32,10 +32,13 @@ attr_reader :return_url attr_reader :cancel_url attr_reader :webhook_url attr_reader :sandbox attr_reader :created_at + attr_reader :risk + attr_reader :shipping + attr_reader :device def id=(val) @id = val end @@ -218,11 +221,59 @@ def created_at=(val) @created_at = val end + def risk=(val) + if val.nil? + @risk = val + return + end + if val.instance_of? InvoiceRisk + @risk = val + else + obj = InvoiceRisk.new(@client) + obj.fill_with_data(val) + @risk = obj + end + + end + + def shipping=(val) + if val.nil? + @shipping = val + return + end + + if val.instance_of? InvoiceShipping + @shipping = val + else + obj = InvoiceShipping.new(@client) + obj.fill_with_data(val) + @shipping = obj + end + + end + + def device=(val) + if val.nil? + @device = val + return + end + + if val.instance_of? InvoiceDevice + @device = val + else + obj = InvoiceDevice.new(@client) + obj.fill_with_data(val) + @device = obj + end + + end + + # Initializes the Invoice object # Params: # +client+:: +ProcessOut+ client instance # +data+:: data that can be used to fill the object def initialize(client, data = {}) @@ -253,10 +304,13 @@ self.return_url = data.fetch(:return_url, nil) self.cancel_url = data.fetch(:cancel_url, nil) self.webhook_url = data.fetch(:webhook_url, nil) self.sandbox = data.fetch(:sandbox, nil) self.created_at = data.fetch(:created_at, nil) + self.risk = data.fetch(:risk, nil) + self.shipping = data.fetch(:shipping, nil) + self.device = data.fetch(:device, nil) end # Create a new Invoice using the current client def new(data = {}) @@ -349,10 +403,19 @@ self.sandbox = data["sandbox"] end if data.include? "created_at" self.created_at = data["created_at"] end + if data.include? "risk" + self.risk = data["risk"] + end + if data.include? "shipping" + self.shipping = data["shipping"] + end + if data.include? "device" + self.device = data["device"] + end self end # Prefills the object with the data passed as parameters @@ -387,10 +450,13 @@ self.return_url = data.fetch(:return_url, self.return_url) self.cancel_url = data.fetch(:cancel_url, self.cancel_url) self.webhook_url = data.fetch(:webhook_url, self.webhook_url) self.sandbox = data.fetch(:sandbox, self.sandbox) self.created_at = data.fetch(:created_at, self.created_at) + self.risk = data.fetch(:risk, self.risk) + self.shipping = data.fetch(:shipping, self.shipping) + self.device = data.fetch(:device, self.device) self end # Authorize the invoice using the given source (customer or token) @@ -404,10 +470,12 @@ path = "/invoices/" + CGI.escape(@id) + "/authorize" data = { "synchronous" => options.fetch(:synchronous, nil), "retry_drop_liability_shift" => options.fetch(:retry_drop_liability_shift, nil), "capture_amount" => options.fetch(:capture_amount, nil), + "enable_three_d_s_2" => options.fetch(:enable_three_d_s_2, nil), + "auto_capture_at" => options.fetch(:auto_capture_at, nil), "source" => source } response = Response.new(request.post(path, data, options)) return_values = Array.new @@ -433,10 +501,12 @@ data = { "authorize_only" => options.fetch(:authorize_only, nil), "synchronous" => options.fetch(:synchronous, nil), "retry_drop_liability_shift" => options.fetch(:retry_drop_liability_shift, nil), "capture_amount" => options.fetch(:capture_amount, nil), + "auto_capture_at" => options.fetch(:auto_capture_at, nil), + "enable_three_d_s_2" => options.fetch(:enable_three_d_s_2, nil), "source" => source } response = Response.new(request.post(path, data, options)) return_values = Array.new @@ -507,10 +577,11 @@ self.prefill(options) request = Request.new(@client) path = "/invoices/" + CGI.escape(@id) + "/three-d-s" data = { + "enable_three_d_s_2" => options.fetch(:enable_three_d_s_2, nil), "source" => source } response = Response.new(request.post(path, data, options)) return_values = Array.new @@ -622,10 +693,13 @@ "statement_descriptor_city" => @statement_descriptor_city, "statement_descriptor_company" => @statement_descriptor_company, "statement_descriptor_url" => @statement_descriptor_url, "return_url" => @return_url, "cancel_url" => @cancel_url, - "webhook_url" => @webhook_url + "webhook_url" => @webhook_url, + "risk" => @risk, + "shipping" => @shipping, + "device" => @device } response = Response.new(request.post(path, data, options)) return_values = Array.new