lib/processout/invoice.rb in processout-2.31.0 vs lib/processout/invoice.rb in processout-3.0.0

- old
+ new

@@ -19,10 +19,11 @@ attr_reader :subscription_id attr_reader :token attr_reader :token_id attr_reader :details attr_reader :url + attr_reader :url_qrcode attr_reader :name attr_reader :order_id attr_reader :amount attr_reader :currency attr_reader :merchant_initiator_type @@ -37,10 +38,11 @@ attr_reader :cancel_url attr_reader :webhook_url attr_reader :require_backend_capture attr_reader :sandbox attr_reader :created_at + attr_reader :expires_at attr_reader :risk attr_reader :shipping attr_reader :device attr_reader :external_fraud_tools attr_reader :exemption_reason_3ds2 @@ -184,10 +186,14 @@ def url=(val) @url = val end + def url_qrcode=(val) + @url_qrcode = val + end + def name=(val) @name = val end def order_id=(val) @@ -256,10 +262,14 @@ def created_at=(val) @created_at = val end + def expires_at=(val) + @expires_at = val + end + def risk=(val) if val.nil? @risk = val return end @@ -441,10 +451,11 @@ self.subscription_id = data.fetch(:subscription_id, nil) self.token = data.fetch(:token, nil) self.token_id = data.fetch(:token_id, nil) self.details = data.fetch(:details, nil) self.url = data.fetch(:url, nil) + self.url_qrcode = data.fetch(:url_qrcode, nil) self.name = data.fetch(:name, nil) self.order_id = data.fetch(:order_id, nil) self.amount = data.fetch(:amount, nil) self.currency = data.fetch(:currency, nil) self.merchant_initiator_type = data.fetch(:merchant_initiator_type, nil) @@ -459,10 +470,11 @@ self.cancel_url = data.fetch(:cancel_url, nil) self.webhook_url = data.fetch(:webhook_url, nil) self.require_backend_capture = data.fetch(:require_backend_capture, nil) self.sandbox = data.fetch(:sandbox, nil) self.created_at = data.fetch(:created_at, nil) + self.expires_at = data.fetch(:expires_at, nil) self.risk = data.fetch(:risk, nil) self.shipping = data.fetch(:shipping, nil) self.device = data.fetch(:device, nil) self.external_fraud_tools = data.fetch(:external_fraud_tools, nil) self.exemption_reason_3ds2 = data.fetch(:exemption_reason_3ds2, nil) @@ -500,10 +512,11 @@ "subscription_id": self.subscription_id, "token": self.token, "token_id": self.token_id, "details": self.details, "url": self.url, + "url_qrcode": self.url_qrcode, "name": self.name, "order_id": self.order_id, "amount": self.amount, "currency": self.currency, "merchant_initiator_type": self.merchant_initiator_type, @@ -518,10 +531,11 @@ "cancel_url": self.cancel_url, "webhook_url": self.webhook_url, "require_backend_capture": self.require_backend_capture, "sandbox": self.sandbox, "created_at": self.created_at, + "expires_at": self.expires_at, "risk": self.risk, "shipping": self.shipping, "device": self.device, "external_fraud_tools": self.external_fraud_tools, "exemption_reason_3ds2": self.exemption_reason_3ds2, @@ -584,10 +598,13 @@ self.details = data["details"] end if data.include? "url" self.url = data["url"] end + if data.include? "url_qrcode" + self.url_qrcode = data["url_qrcode"] + end if data.include? "name" self.name = data["name"] end if data.include? "order_id" self.order_id = data["order_id"] @@ -638,10 +655,13 @@ self.sandbox = data["sandbox"] end if data.include? "created_at" self.created_at = data["created_at"] end + if data.include? "expires_at" + self.expires_at = data["expires_at"] + end if data.include? "risk" self.risk = data["risk"] end if data.include? "shipping" self.shipping = data["shipping"] @@ -713,10 +733,11 @@ self.subscription_id = data.fetch(:subscription_id, self.subscription_id) self.token = data.fetch(:token, self.token) self.token_id = data.fetch(:token_id, self.token_id) self.details = data.fetch(:details, self.details) self.url = data.fetch(:url, self.url) + self.url_qrcode = data.fetch(:url_qrcode, self.url_qrcode) self.name = data.fetch(:name, self.name) self.order_id = data.fetch(:order_id, self.order_id) self.amount = data.fetch(:amount, self.amount) self.currency = data.fetch(:currency, self.currency) self.merchant_initiator_type = data.fetch(:merchant_initiator_type, self.merchant_initiator_type) @@ -731,10 +752,11 @@ self.cancel_url = data.fetch(:cancel_url, self.cancel_url) self.webhook_url = data.fetch(:webhook_url, self.webhook_url) self.require_backend_capture = data.fetch(:require_backend_capture, self.require_backend_capture) self.sandbox = data.fetch(:sandbox, self.sandbox) self.created_at = data.fetch(:created_at, self.created_at) + self.expires_at = data.fetch(:expires_at, self.expires_at) self.risk = data.fetch(:risk, self.risk) self.shipping = data.fetch(:shipping, self.shipping) self.device = data.fetch(:device, self.device) self.external_fraud_tools = data.fetch(:external_fraud_tools, self.external_fraud_tools) self.exemption_reason_3ds2 = data.fetch(:exemption_reason_3ds2, self.exemption_reason_3ds2) @@ -808,13 +830,17 @@ body = response.body body = body["transaction"] transaction = Transaction.new(@client) return_values.push(transaction.fill_with_data(body)) + body = response.body + body = body["customer_action"] + customer_action = CustomerAction.new(@client) + return_values.push(customer_action.fill_with_data(body)) - return_values[0] + return_values end # Capture the invoice using the given source (customer or token) # Params: # +source+:: Source used to authorization the payment. Can be a card, a token or a gateway request @@ -844,13 +870,17 @@ body = response.body body = body["transaction"] transaction = Transaction.new(@client) return_values.push(transaction.fill_with_data(body)) + body = response.body + body = body["customer_action"] + customer_action = CustomerAction.new(@client) + return_values.push(customer_action.fill_with_data(body)) - return_values[0] + return_values end # Get the customer linked to the invoice. # Params: # +options+:: +Hash+ of options @@ -970,15 +1000,20 @@ response = Response.new(request.post(path, data, options)) return_values = Array.new body = response.body - invoices_process_native_payment_response = InvoicesProcessNativePaymentResponse.new(@client) - return_values.push(invoices_process_native_payment_response.fill_with_data(body)) + body = body["transaction"] + transaction = Transaction.new(@client) + return_values.push(transaction.fill_with_data(body)) + body = response.body + body = body["native_apm"] + native_apm_response = NativeAPMResponse.new(@client) + return_values.push(native_apm_response.fill_with_data(body)) - return_values[0] + return_values end # Initiate a 3-D Secure authentication # Params: # +source+:: Source used to initiate the 3-D Secure authentication. Can be a card, or a token representing a card @@ -1123,11 +1158,12 @@ "tax" => @tax, "payment_type" => @payment_type, "billing" => @billing, "unsupported_feature_bypass" => @unsupported_feature_bypass, "verification" => @verification, - "auto_capture_at" => @auto_capture_at + "auto_capture_at" => @auto_capture_at, + "expires_at" => @expires_at } response = Response.new(request.post(path, data, options)) return_values = Array.new @@ -1163,9 +1199,31 @@ obj = Invoice.new(@client) return_values.push(obj.fill_with_data(body)) + + + return_values[0] + end + + # Delete an invoice by its ID. Only invoices that have not been used yet can be deleted. + # Params: + # +invoice_id+:: ID of the invoice + # +options+:: +Hash+ of options + def delete(invoice_id, options = {}) + self.prefill(options) + + request = Request.new(@client) + path = "/invoices/" + CGI.escape(invoice_id) + "" + data = { + + } + + response = Response.new(request.delete(path, data, options)) + return_values = Array.new + + return_values.push(response.success) return_values[0] end