diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3e03ded..e065e1f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: go-semantic-release/action@v1 + - uses: go-semantic-release/action@v1.24.1 id: semrel with: github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/lib/processout.rb b/lib/processout.rb index 75446dc..dc52369 100644 --- a/lib/processout.rb +++ b/lib/processout.rb @@ -1,7 +1,5 @@ require "processout/version" require "processout/gateway_request" -require "processout/activity" -require "processout/addon" require "processout/api_version" require "processout/apple_pay_alternative_merchant_certificates" require "processout/alternative_merchant_certificate" @@ -11,11 +9,9 @@ require "processout/card" require "processout/card_information" require "processout/phone" -require "processout/coupon" require "processout/customer" require "processout/customer_phone" require "processout/token" -require "processout/discount" require "processout/event" require "processout/export_layout" require "processout/export_layout_configuration" @@ -38,6 +34,8 @@ require "processout/invoice_shipping_phone" require "processout/invoice_billing" require "processout/unsupported_feature_bypass" +require "processout/payment_processing_configuration" +require "processout/apm_payment_processing_configuration" require "processout/invoice_detail" require "processout/invoice_submerchant" require "processout/submerchant_phone_number" @@ -47,13 +45,13 @@ require "processout/payout" require "processout/payout_item" require "processout/payout_item_amount_breakdowns" -require "processout/plan" require "processout/product" require "processout/project" require "processout/project_sftp_settings" require "processout/project_sftp_settings_public" require "processout/refund" -require "processout/subscription" +require "processout/submerchant" +require "processout/submerchant_mapping" require "processout/transaction" require "processout/native_apm_response" require "processout/native_apm_parameter_definition" @@ -65,11 +63,12 @@ require "processout/transaction_operation" require "processout/webhook" require "processout/webhook_endpoint" +require "processout/card_update_request" +require "processout/card_create_request" +require "processout/card_scheme_details" require "processout/device" require "processout/card_contact" require "processout/card_shipping" -require "processout/card_update_request" -require "processout/card_create_request" require "processout/error_codes" require "processout/category_error_codes" require "processout/external_three_ds" @@ -88,16 +87,6 @@ def initialize(project_id, project_secret) @project_secret = project_secret end - # Create a new Activity instance - def activity(data = {}) - obj = Activity.new(self, data) - end - - # Create a new Addon instance - def addon(data = {}) - obj = Addon.new(self, data) - end - # Create a new APIVersion instance def api_version(data = {}) obj = APIVersion.new(self, data) @@ -143,11 +132,6 @@ def phone(data = {}) obj = Phone.new(self, data) end - # Create a new Coupon instance - def coupon(data = {}) - obj = Coupon.new(self, data) - end - # Create a new Customer instance def customer(data = {}) obj = Customer.new(self, data) @@ -163,11 +147,6 @@ def token(data = {}) obj = Token.new(self, data) end - # Create a new Discount instance - def discount(data = {}) - obj = Discount.new(self, data) - end - # Create a new Event instance def event(data = {}) obj = Event.new(self, data) @@ -278,6 +257,16 @@ def unsupported_feature_bypass(data = {}) obj = UnsupportedFeatureBypass.new(self, data) end + # Create a new PaymentProcessingConfiguration instance + def payment_processing_configuration(data = {}) + obj = PaymentProcessingConfiguration.new(self, data) + end + + # Create a new APMPaymentProcessingConfiguration instance + def apm_payment_processing_configuration(data = {}) + obj = APMPaymentProcessingConfiguration.new(self, data) + end + # Create a new InvoiceDetail instance def invoice_detail(data = {}) obj = InvoiceDetail.new(self, data) @@ -323,11 +312,6 @@ def payout_item_amount_breakdowns(data = {}) obj = PayoutItemAmountBreakdowns.new(self, data) end - # Create a new Plan instance - def plan(data = {}) - obj = Plan.new(self, data) - end - # Create a new Product instance def product(data = {}) obj = Product.new(self, data) @@ -353,9 +337,14 @@ def refund(data = {}) obj = Refund.new(self, data) end - # Create a new Subscription instance - def subscription(data = {}) - obj = Subscription.new(self, data) + # Create a new Submerchant instance + def submerchant(data = {}) + obj = Submerchant.new(self, data) + end + + # Create a new SubmerchantMapping instance + def submerchant_mapping(data = {}) + obj = SubmerchantMapping.new(self, data) end # Create a new Transaction instance @@ -413,6 +402,21 @@ def webhook_endpoint(data = {}) obj = WebhookEndpoint.new(self, data) end + # Create a new CardUpdateRequest instance + def card_update_request(data = {}) + obj = CardUpdateRequest.new(self, data) + end + + # Create a new CardCreateRequest instance + def card_create_request(data = {}) + obj = CardCreateRequest.new(self, data) + end + + # Create a new CardSchemeDetails instance + def card_scheme_details(data = {}) + obj = CardSchemeDetails.new(self, data) + end + # Create a new Device instance def device(data = {}) obj = Device.new(self, data) @@ -428,16 +432,6 @@ def card_shipping(data = {}) obj = CardShipping.new(self, data) end - # Create a new CardUpdateRequest instance - def card_update_request(data = {}) - obj = CardUpdateRequest.new(self, data) - end - - # Create a new CardCreateRequest instance - def card_create_request(data = {}) - obj = CardCreateRequest.new(self, data) - end - # Create a new ErrorCodes instance def error_codes(data = {}) obj = ErrorCodes.new(self, data) diff --git a/lib/processout/activity.rb b/lib/processout/activity.rb deleted file mode 100755 index 59d9bd9..0000000 --- a/lib/processout/activity.rb +++ /dev/null @@ -1,206 +0,0 @@ -# The content of this file was automatically generated - -require "cgi" -require "json" -require "processout/networking/request" -require "processout/networking/response" - -module ProcessOut - class Activity - - attr_reader :id - attr_reader :project - attr_reader :project_id - attr_reader :title - attr_reader :content - attr_reader :level - attr_reader :created_at - - - def id=(val) - @id = val - end - - def project=(val) - if val.nil? - @project = val - return - end - - if val.instance_of? Project - @project = val - else - obj = Project.new(@client) - obj.fill_with_data(val) - @project = obj - end - - end - - def project_id=(val) - @project_id = val - end - - def title=(val) - @title = val - end - - def content=(val) - @content = val - end - - def level=(val) - @level = val - end - - def created_at=(val) - @created_at = val - end - - - # Initializes the Activity object - # Params: - # +client+:: +ProcessOut+ client instance - # +data+:: data that can be used to fill the object - def initialize(client, data = {}) - @client = client - - self.id = data.fetch(:id, nil) - self.project = data.fetch(:project, nil) - self.project_id = data.fetch(:project_id, nil) - self.title = data.fetch(:title, nil) - self.content = data.fetch(:content, nil) - self.level = data.fetch(:level, nil) - self.created_at = data.fetch(:created_at, nil) - - end - - # Create a new Activity using the current client - def new(data = {}) - Activity.new(@client, data) - end - - # Overrides the JSON marshaller to only send the fields we want - def to_json(options) - { - "id": self.id, - "project": self.project, - "project_id": self.project_id, - "title": self.title, - "content": self.content, - "level": self.level, - "created_at": self.created_at, - }.to_json - end - - # Fills the object with data coming from the API - # Params: - # +data+:: +Hash+ of data coming from the API - def fill_with_data(data) - if data.nil? - return self - end - if data.include? "id" - self.id = data["id"] - end - if data.include? "project" - self.project = data["project"] - end - if data.include? "project_id" - self.project_id = data["project_id"] - end - if data.include? "title" - self.title = data["title"] - end - if data.include? "content" - self.content = data["content"] - end - if data.include? "level" - self.level = data["level"] - end - if data.include? "created_at" - self.created_at = data["created_at"] - end - - self - end - - # Prefills the object with the data passed as parameters - # Params: - # +data+:: +Hash+ of data - def prefill(data) - if data.nil? - return self - end - self.id = data.fetch(:id, self.id) - self.project = data.fetch(:project, self.project) - self.project_id = data.fetch(:project_id, self.project_id) - self.title = data.fetch(:title, self.title) - self.content = data.fetch(:content, self.content) - self.level = data.fetch(:level, self.level) - self.created_at = data.fetch(:created_at, self.created_at) - - self - end - - # Get all the project activities. - # Params: - # +options+:: +Hash+ of options - def all(options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/activities" - data = { - - } - - response = Response.new(request.get(path, data, options)) - return_values = Array.new - - a = Array.new - body = response.body - for v in body['activities'] - tmp = Activity.new(@client) - tmp.fill_with_data(v) - a.push(tmp) - end - - return_values.push(a) - - - - return_values[0] - end - - # Find a specific activity and fetch its data. - # Params: - # +activity_id+:: ID of the activity - # +options+:: +Hash+ of options - def find(activity_id, options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/activities/" + CGI.escape(activity_id) + "" - data = { - - } - - response = Response.new(request.get(path, data, options)) - return_values = Array.new - - body = response.body - body = body.key?("activity") ? body["activity"] : nil - - - obj = Activity.new(@client) - return_values.push(obj.fill_with_data(body)) - - - - return_values[0] - end - - - end -end diff --git a/lib/processout/addon.rb b/lib/processout/addon.rb deleted file mode 100755 index 3edc6cd..0000000 --- a/lib/processout/addon.rb +++ /dev/null @@ -1,401 +0,0 @@ -# The content of this file was automatically generated - -require "cgi" -require "json" -require "processout/networking/request" -require "processout/networking/response" - -module ProcessOut - class Addon - - attr_reader :id - attr_reader :project - attr_reader :project_id - attr_reader :subscription - attr_reader :subscription_id - attr_reader :plan - attr_reader :plan_id - attr_reader :type - attr_reader :name - attr_reader :amount - attr_reader :quantity - attr_reader :metadata - attr_reader :sandbox - attr_reader :created_at - - - def id=(val) - @id = val - end - - def project=(val) - if val.nil? - @project = val - return - end - - if val.instance_of? Project - @project = val - else - obj = Project.new(@client) - obj.fill_with_data(val) - @project = obj - end - - end - - def project_id=(val) - @project_id = val - end - - def subscription=(val) - if val.nil? - @subscription = val - return - end - - if val.instance_of? Subscription - @subscription = val - else - obj = Subscription.new(@client) - obj.fill_with_data(val) - @subscription = obj - end - - end - - def subscription_id=(val) - @subscription_id = val - end - - def plan=(val) - if val.nil? - @plan = val - return - end - - if val.instance_of? Plan - @plan = val - else - obj = Plan.new(@client) - obj.fill_with_data(val) - @plan = obj - end - - end - - def plan_id=(val) - @plan_id = val - end - - def type=(val) - @type = val - end - - def name=(val) - @name = val - end - - def amount=(val) - @amount = val - end - - def quantity=(val) - @quantity = val - end - - def metadata=(val) - @metadata = val - end - - def sandbox=(val) - @sandbox = val - end - - def created_at=(val) - @created_at = val - end - - - # Initializes the Addon object - # Params: - # +client+:: +ProcessOut+ client instance - # +data+:: data that can be used to fill the object - def initialize(client, data = {}) - @client = client - - self.id = data.fetch(:id, nil) - self.project = data.fetch(:project, nil) - self.project_id = data.fetch(:project_id, nil) - self.subscription = data.fetch(:subscription, nil) - self.subscription_id = data.fetch(:subscription_id, nil) - self.plan = data.fetch(:plan, nil) - self.plan_id = data.fetch(:plan_id, nil) - self.type = data.fetch(:type, nil) - self.name = data.fetch(:name, nil) - self.amount = data.fetch(:amount, nil) - self.quantity = data.fetch(:quantity, nil) - self.metadata = data.fetch(:metadata, nil) - self.sandbox = data.fetch(:sandbox, nil) - self.created_at = data.fetch(:created_at, nil) - - end - - # Create a new Addon using the current client - def new(data = {}) - Addon.new(@client, data) - end - - # Overrides the JSON marshaller to only send the fields we want - def to_json(options) - { - "id": self.id, - "project": self.project, - "project_id": self.project_id, - "subscription": self.subscription, - "subscription_id": self.subscription_id, - "plan": self.plan, - "plan_id": self.plan_id, - "type": self.type, - "name": self.name, - "amount": self.amount, - "quantity": self.quantity, - "metadata": self.metadata, - "sandbox": self.sandbox, - "created_at": self.created_at, - }.to_json - end - - # Fills the object with data coming from the API - # Params: - # +data+:: +Hash+ of data coming from the API - def fill_with_data(data) - if data.nil? - return self - end - if data.include? "id" - self.id = data["id"] - end - if data.include? "project" - self.project = data["project"] - end - if data.include? "project_id" - self.project_id = data["project_id"] - end - if data.include? "subscription" - self.subscription = data["subscription"] - end - if data.include? "subscription_id" - self.subscription_id = data["subscription_id"] - end - if data.include? "plan" - self.plan = data["plan"] - end - if data.include? "plan_id" - self.plan_id = data["plan_id"] - end - if data.include? "type" - self.type = data["type"] - end - if data.include? "name" - self.name = data["name"] - end - if data.include? "amount" - self.amount = data["amount"] - end - if data.include? "quantity" - self.quantity = data["quantity"] - end - if data.include? "metadata" - self.metadata = data["metadata"] - end - if data.include? "sandbox" - self.sandbox = data["sandbox"] - end - if data.include? "created_at" - self.created_at = data["created_at"] - end - - self - end - - # Prefills the object with the data passed as parameters - # Params: - # +data+:: +Hash+ of data - def prefill(data) - if data.nil? - return self - end - self.id = data.fetch(:id, self.id) - self.project = data.fetch(:project, self.project) - self.project_id = data.fetch(:project_id, self.project_id) - self.subscription = data.fetch(:subscription, self.subscription) - self.subscription_id = data.fetch(:subscription_id, self.subscription_id) - self.plan = data.fetch(:plan, self.plan) - self.plan_id = data.fetch(:plan_id, self.plan_id) - self.type = data.fetch(:type, self.type) - self.name = data.fetch(:name, self.name) - self.amount = data.fetch(:amount, self.amount) - self.quantity = data.fetch(:quantity, self.quantity) - self.metadata = data.fetch(:metadata, self.metadata) - self.sandbox = data.fetch(:sandbox, self.sandbox) - self.created_at = data.fetch(:created_at, self.created_at) - - self - end - - # Get the addons applied to the subscription. - # Params: - # +subscription_id+:: ID of the subscription - # +options+:: +Hash+ of options - def fetch_subscription_addons(subscription_id, options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/subscriptions/" + CGI.escape(subscription_id) + "/addons" - data = { - - } - - response = Response.new(request.get(path, data, options)) - return_values = Array.new - - a = Array.new - body = response.body - for v in body['addons'] - tmp = Addon.new(@client) - tmp.fill_with_data(v) - a.push(tmp) - end - - return_values.push(a) - - - - return_values[0] - end - - # Create a new addon to the given subscription ID. - # Params: - # +options+:: +Hash+ of options - def create(options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/subscriptions/" + CGI.escape(@subscription_id) + "/addons" - data = { - "plan_id" => @plan_id, - "type" => @type, - "name" => @name, - "amount" => @amount, - "quantity" => @quantity, - "metadata" => @metadata, - "prorate" => options.fetch(:prorate, nil), - "proration_date" => options.fetch(:proration_date, nil), - "preview" => options.fetch(:preview, nil) - } - - response = Response.new(request.post(path, data, options)) - return_values = Array.new - - body = response.body - body = body.key?("addon") ? body["addon"] : nil - - - return_values.push(self.fill_with_data(body)) - - - - return_values[0] - end - - # Find a subscription's addon by its ID. - # Params: - # +subscription_id+:: ID of the subscription on which the addon was applied - # +addon_id+:: ID of the addon - # +options+:: +Hash+ of options - def find(subscription_id, addon_id, options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/subscriptions/" + CGI.escape(subscription_id) + "/addons/" + CGI.escape(addon_id) + "" - data = { - - } - - response = Response.new(request.get(path, data, options)) - return_values = Array.new - - body = response.body - body = body.key?("addon") ? body["addon"] : nil - - - obj = Addon.new(@client) - return_values.push(obj.fill_with_data(body)) - - - - return_values[0] - end - - # Save the updated addon attributes. - # Params: - # +options+:: +Hash+ of options - def save(options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/subscriptions/" + CGI.escape(@subscription_id) + "/addons/" + CGI.escape(@id) + "" - data = { - "plan_id" => @plan_id, - "type" => @type, - "name" => @name, - "amount" => @amount, - "quantity" => @quantity, - "metadata" => @metadata, - "prorate" => options.fetch(:prorate, nil), - "proration_date" => options.fetch(:proration_date, nil), - "preview" => options.fetch(:preview, nil), - "increment_quantity_by" => options.fetch(:increment_quantity_by, nil) - } - - response = Response.new(request.put(path, data, options)) - return_values = Array.new - - body = response.body - body = body.key?("addon") ? body["addon"] : nil - - - return_values.push(self.fill_with_data(body)) - - - - return_values[0] - end - - # Delete an addon applied to a subscription. - # Params: - # +options+:: +Hash+ of options - def delete(options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/subscriptions/" + CGI.escape(@subscription_id) + "/addons/" + CGI.escape(@id) + "" - data = { - "prorate" => options.fetch(:prorate, nil), - "proration_date" => options.fetch(:proration_date, nil), - "preview" => options.fetch(:preview, nil) - } - - response = Response.new(request.delete(path, data, options)) - return_values = Array.new - - return_values.push(response.success) - - - return_values[0] - end - - - end -end diff --git a/lib/processout/apm_payment_processing_configuration.rb b/lib/processout/apm_payment_processing_configuration.rb new file mode 100755 index 0000000..0c0f5b3 --- /dev/null +++ b/lib/processout/apm_payment_processing_configuration.rb @@ -0,0 +1,81 @@ +# The content of this file was automatically generated + +require "cgi" +require "json" +require "processout/networking/request" +require "processout/networking/response" + +module ProcessOut + class APMPaymentProcessingConfiguration + + attr_reader :return_redirect_type + attr_reader :preferred_finalization_mode + + + def return_redirect_type=(val) + @return_redirect_type = val + end + + def preferred_finalization_mode=(val) + @preferred_finalization_mode = val + end + + + # Initializes the APMPaymentProcessingConfiguration object + # Params: + # +client+:: +ProcessOut+ client instance + # +data+:: data that can be used to fill the object + def initialize(client, data = {}) + @client = client + + self.return_redirect_type = data.fetch(:return_redirect_type, nil) + self.preferred_finalization_mode = data.fetch(:preferred_finalization_mode, nil) + + end + + # Create a new APMPaymentProcessingConfiguration using the current client + def new(data = {}) + APMPaymentProcessingConfiguration.new(@client, data) + end + + # Overrides the JSON marshaller to only send the fields we want + def to_json(options) + { + "return_redirect_type": self.return_redirect_type, + "preferred_finalization_mode": self.preferred_finalization_mode, + }.to_json + end + + # Fills the object with data coming from the API + # Params: + # +data+:: +Hash+ of data coming from the API + def fill_with_data(data) + if data.nil? + return self + end + if data.include? "return_redirect_type" + self.return_redirect_type = data["return_redirect_type"] + end + if data.include? "preferred_finalization_mode" + self.preferred_finalization_mode = data["preferred_finalization_mode"] + end + + self + end + + # Prefills the object with the data passed as parameters + # Params: + # +data+:: +Hash+ of data + def prefill(data) + if data.nil? + return self + end + self.return_redirect_type = data.fetch(:return_redirect_type, self.return_redirect_type) + self.preferred_finalization_mode = data.fetch(:preferred_finalization_mode, self.preferred_finalization_mode) + + self + end + + + end +end diff --git a/lib/processout/card.rb b/lib/processout/card.rb index 2fba062..ce1c191 100755 --- a/lib/processout/card.rb +++ b/lib/processout/card.rb @@ -32,6 +32,7 @@ class Card attr_reader :state attr_reader :zip attr_reader :country_code + attr_reader :billing_country_code attr_reader :ip_address attr_reader :fingerprint attr_reader :token_type @@ -41,6 +42,9 @@ class Card attr_reader :expires_soon attr_reader :sandbox attr_reader :created_at + attr_reader :preferred_card_type + attr_reader :initial_scheme_transaction_id + attr_reader :payment_account_reference def id=(val) @@ -163,6 +167,10 @@ def country_code=(val) @country_code = val end + def billing_country_code=(val) + @billing_country_code = val + end + def ip_address=(val) @ip_address = val end @@ -199,6 +207,18 @@ def created_at=(val) @created_at = val end + def preferred_card_type=(val) + @preferred_card_type = val + end + + def initial_scheme_transaction_id=(val) + @initial_scheme_transaction_id = val + end + + def payment_account_reference=(val) + @payment_account_reference = val + end + # Initializes the Card object # Params: @@ -231,6 +251,7 @@ def initialize(client, data = {}) self.state = data.fetch(:state, nil) self.zip = data.fetch(:zip, nil) self.country_code = data.fetch(:country_code, nil) + self.billing_country_code = data.fetch(:billing_country_code, nil) self.ip_address = data.fetch(:ip_address, nil) self.fingerprint = data.fetch(:fingerprint, nil) self.token_type = data.fetch(:token_type, nil) @@ -240,6 +261,9 @@ def initialize(client, data = {}) self.expires_soon = data.fetch(:expires_soon, nil) self.sandbox = data.fetch(:sandbox, nil) self.created_at = data.fetch(:created_at, nil) + self.preferred_card_type = data.fetch(:preferred_card_type, nil) + self.initial_scheme_transaction_id = data.fetch(:initial_scheme_transaction_id, nil) + self.payment_account_reference = data.fetch(:payment_account_reference, nil) end @@ -275,6 +299,7 @@ def to_json(options) "state": self.state, "zip": self.zip, "country_code": self.country_code, + "billing_country_code": self.billing_country_code, "ip_address": self.ip_address, "fingerprint": self.fingerprint, "token_type": self.token_type, @@ -284,6 +309,9 @@ def to_json(options) "expires_soon": self.expires_soon, "sandbox": self.sandbox, "created_at": self.created_at, + "preferred_card_type": self.preferred_card_type, + "initial_scheme_transaction_id": self.initial_scheme_transaction_id, + "payment_account_reference": self.payment_account_reference, }.to_json end @@ -366,6 +394,9 @@ def fill_with_data(data) if data.include? "country_code" self.country_code = data["country_code"] end + if data.include? "billing_country_code" + self.billing_country_code = data["billing_country_code"] + end if data.include? "ip_address" self.ip_address = data["ip_address"] end @@ -393,6 +424,15 @@ def fill_with_data(data) if data.include? "created_at" self.created_at = data["created_at"] end + if data.include? "preferred_card_type" + self.preferred_card_type = data["preferred_card_type"] + end + if data.include? "initial_scheme_transaction_id" + self.initial_scheme_transaction_id = data["initial_scheme_transaction_id"] + end + if data.include? "payment_account_reference" + self.payment_account_reference = data["payment_account_reference"] + end self end @@ -428,6 +468,7 @@ def prefill(data) self.state = data.fetch(:state, self.state) self.zip = data.fetch(:zip, self.zip) self.country_code = data.fetch(:country_code, self.country_code) + self.billing_country_code = data.fetch(:billing_country_code, self.billing_country_code) self.ip_address = data.fetch(:ip_address, self.ip_address) self.fingerprint = data.fetch(:fingerprint, self.fingerprint) self.token_type = data.fetch(:token_type, self.token_type) @@ -437,6 +478,9 @@ def prefill(data) self.expires_soon = data.fetch(:expires_soon, self.expires_soon) self.sandbox = data.fetch(:sandbox, self.sandbox) self.created_at = data.fetch(:created_at, self.created_at) + self.preferred_card_type = data.fetch(:preferred_card_type, self.preferred_card_type) + self.initial_scheme_transaction_id = data.fetch(:initial_scheme_transaction_id, self.initial_scheme_transaction_id) + self.payment_account_reference = data.fetch(:payment_account_reference, self.payment_account_reference) self end diff --git a/lib/processout/card_contact.rb b/lib/processout/card_contact.rb index 9a53f53..27e5a8a 100755 --- a/lib/processout/card_contact.rb +++ b/lib/processout/card_contact.rb @@ -13,6 +13,7 @@ class CardContact attr_reader :city attr_reader :state attr_reader :country_code + attr_reader :billing_country_code attr_reader :zip @@ -36,6 +37,10 @@ def country_code=(val) @country_code = val end + def billing_country_code=(val) + @billing_country_code = val + end + def zip=(val) @zip = val end @@ -53,6 +58,7 @@ def initialize(client, data = {}) self.city = data.fetch(:city, nil) self.state = data.fetch(:state, nil) self.country_code = data.fetch(:country_code, nil) + self.billing_country_code = data.fetch(:billing_country_code, nil) self.zip = data.fetch(:zip, nil) end @@ -70,6 +76,7 @@ def to_json(options) "city": self.city, "state": self.state, "country_code": self.country_code, + "billing_country_code": self.billing_country_code, "zip": self.zip, }.to_json end @@ -96,6 +103,9 @@ def fill_with_data(data) if data.include? "country_code" self.country_code = data["country_code"] end + if data.include? "billing_country_code" + self.billing_country_code = data["billing_country_code"] + end if data.include? "zip" self.zip = data["zip"] end @@ -115,6 +125,7 @@ def prefill(data) self.city = data.fetch(:city, self.city) self.state = data.fetch(:state, self.state) self.country_code = data.fetch(:country_code, self.country_code) + self.billing_country_code = data.fetch(:billing_country_code, self.billing_country_code) self.zip = data.fetch(:zip, self.zip) self diff --git a/lib/processout/card_create_request.rb b/lib/processout/card_create_request.rb index 02da243..4697e0a 100755 --- a/lib/processout/card_create_request.rb +++ b/lib/processout/card_create_request.rb @@ -16,6 +16,7 @@ class CardCreateRequest attr_reader :exp_year attr_reader :cvc2 attr_reader :preferred_scheme + attr_reader :preferred_card_type attr_reader :metadata attr_reader :token_type attr_reader :eci @@ -25,6 +26,7 @@ class CardCreateRequest attr_reader :payment_token attr_reader :contact attr_reader :shipping + attr_reader :scheme_details def device=(val) @@ -71,6 +73,10 @@ def preferred_scheme=(val) @preferred_scheme = val end + def preferred_card_type=(val) + @preferred_card_type = val + end + def metadata=(val) @metadata = val end @@ -131,6 +137,22 @@ def shipping=(val) end + def scheme_details=(val) + if val.nil? + @scheme_details = val + return + end + + if val.instance_of? CardSchemeDetails + @scheme_details = val + else + obj = CardSchemeDetails.new(@client) + obj.fill_with_data(val) + @scheme_details = obj + end + + end + # Initializes the CardCreateRequest object # Params: @@ -147,6 +169,7 @@ def initialize(client, data = {}) self.exp_year = data.fetch(:exp_year, nil) self.cvc2 = data.fetch(:cvc2, nil) self.preferred_scheme = data.fetch(:preferred_scheme, nil) + self.preferred_card_type = data.fetch(:preferred_card_type, nil) self.metadata = data.fetch(:metadata, nil) self.token_type = data.fetch(:token_type, nil) self.eci = data.fetch(:eci, nil) @@ -156,6 +179,7 @@ def initialize(client, data = {}) self.payment_token = data.fetch(:payment_token, nil) self.contact = data.fetch(:contact, nil) self.shipping = data.fetch(:shipping, nil) + self.scheme_details = data.fetch(:scheme_details, nil) end @@ -175,6 +199,7 @@ def to_json(options) "exp_year": self.exp_year, "cvc2": self.cvc2, "preferred_scheme": self.preferred_scheme, + "preferred_card_type": self.preferred_card_type, "metadata": self.metadata, "token_type": self.token_type, "eci": self.eci, @@ -184,6 +209,7 @@ def to_json(options) "payment_token": self.payment_token, "contact": self.contact, "shipping": self.shipping, + "scheme_details": self.scheme_details, }.to_json end @@ -218,6 +244,9 @@ def fill_with_data(data) if data.include? "preferred_scheme" self.preferred_scheme = data["preferred_scheme"] end + if data.include? "preferred_card_type" + self.preferred_card_type = data["preferred_card_type"] + end if data.include? "metadata" self.metadata = data["metadata"] end @@ -245,6 +274,9 @@ def fill_with_data(data) if data.include? "shipping" self.shipping = data["shipping"] end + if data.include? "scheme_details" + self.scheme_details = data["scheme_details"] + end self end @@ -264,6 +296,7 @@ def prefill(data) self.exp_year = data.fetch(:exp_year, self.exp_year) self.cvc2 = data.fetch(:cvc2, self.cvc2) self.preferred_scheme = data.fetch(:preferred_scheme, self.preferred_scheme) + self.preferred_card_type = data.fetch(:preferred_card_type, self.preferred_card_type) self.metadata = data.fetch(:metadata, self.metadata) self.token_type = data.fetch(:token_type, self.token_type) self.eci = data.fetch(:eci, self.eci) @@ -273,6 +306,7 @@ def prefill(data) self.payment_token = data.fetch(:payment_token, self.payment_token) self.contact = data.fetch(:contact, self.contact) self.shipping = data.fetch(:shipping, self.shipping) + self.scheme_details = data.fetch(:scheme_details, self.scheme_details) self end @@ -294,6 +328,7 @@ def create(options = {}) "exp_year" => @exp_year, "cvc2" => @cvc2, "preferred_scheme" => @preferred_scheme, + "preferred_card_type" => @preferred_card_type, "metadata" => @metadata, "token_type" => @token_type, "eci" => @eci, @@ -302,7 +337,8 @@ def create(options = {}) "applepay_mid" => @applepay_mid, "payment_token" => @payment_token, "contact" => @contact, - "shipping" => @shipping + "shipping" => @shipping, + "scheme_details" => @scheme_details } response = Response.new(request.post(path, data, options)) diff --git a/lib/processout/card_scheme_details.rb b/lib/processout/card_scheme_details.rb new file mode 100755 index 0000000..c0b540c --- /dev/null +++ b/lib/processout/card_scheme_details.rb @@ -0,0 +1,81 @@ +# The content of this file was automatically generated + +require "cgi" +require "json" +require "processout/networking/request" +require "processout/networking/response" + +module ProcessOut + class CardSchemeDetails + + attr_reader :transaction_id + attr_reader :transaction_link_id + + + def transaction_id=(val) + @transaction_id = val + end + + def transaction_link_id=(val) + @transaction_link_id = val + end + + + # Initializes the CardSchemeDetails object + # Params: + # +client+:: +ProcessOut+ client instance + # +data+:: data that can be used to fill the object + def initialize(client, data = {}) + @client = client + + self.transaction_id = data.fetch(:transaction_id, nil) + self.transaction_link_id = data.fetch(:transaction_link_id, nil) + + end + + # Create a new CardSchemeDetails using the current client + def new(data = {}) + CardSchemeDetails.new(@client, data) + end + + # Overrides the JSON marshaller to only send the fields we want + def to_json(options) + { + "transaction_id": self.transaction_id, + "transaction_link_id": self.transaction_link_id, + }.to_json + end + + # Fills the object with data coming from the API + # Params: + # +data+:: +Hash+ of data coming from the API + def fill_with_data(data) + if data.nil? + return self + end + if data.include? "transaction_id" + self.transaction_id = data["transaction_id"] + end + if data.include? "transaction_link_id" + self.transaction_link_id = data["transaction_link_id"] + end + + self + end + + # Prefills the object with the data passed as parameters + # Params: + # +data+:: +Hash+ of data + def prefill(data) + if data.nil? + return self + end + self.transaction_id = data.fetch(:transaction_id, self.transaction_id) + self.transaction_link_id = data.fetch(:transaction_link_id, self.transaction_link_id) + + self + end + + + end +end diff --git a/lib/processout/card_update_request.rb b/lib/processout/card_update_request.rb index 3e4f19f..3c083da 100755 --- a/lib/processout/card_update_request.rb +++ b/lib/processout/card_update_request.rb @@ -9,12 +9,34 @@ module ProcessOut class CardUpdateRequest attr_reader :preferred_scheme + attr_reader :preferred_card_type + attr_reader :scheme_details def preferred_scheme=(val) @preferred_scheme = val end + def preferred_card_type=(val) + @preferred_card_type = val + end + + def scheme_details=(val) + if val.nil? + @scheme_details = val + return + end + + if val.instance_of? CardSchemeDetails + @scheme_details = val + else + obj = CardSchemeDetails.new(@client) + obj.fill_with_data(val) + @scheme_details = obj + end + + end + # Initializes the CardUpdateRequest object # Params: @@ -24,6 +46,8 @@ def initialize(client, data = {}) @client = client self.preferred_scheme = data.fetch(:preferred_scheme, nil) + self.preferred_card_type = data.fetch(:preferred_card_type, nil) + self.scheme_details = data.fetch(:scheme_details, nil) end @@ -36,6 +60,8 @@ def new(data = {}) def to_json(options) { "preferred_scheme": self.preferred_scheme, + "preferred_card_type": self.preferred_card_type, + "scheme_details": self.scheme_details, }.to_json end @@ -49,6 +75,12 @@ def fill_with_data(data) if data.include? "preferred_scheme" self.preferred_scheme = data["preferred_scheme"] end + if data.include? "preferred_card_type" + self.preferred_card_type = data["preferred_card_type"] + end + if data.include? "scheme_details" + self.scheme_details = data["scheme_details"] + end self end @@ -61,6 +93,8 @@ def prefill(data) return self end self.preferred_scheme = data.fetch(:preferred_scheme, self.preferred_scheme) + self.preferred_card_type = data.fetch(:preferred_card_type, self.preferred_card_type) + self.scheme_details = data.fetch(:scheme_details, self.scheme_details) self end @@ -75,7 +109,8 @@ def update(card_id, options = {}) request = Request.new(@client) path = "/cards/" + CGI.escape(card_id) + "" data = { - "preferred_scheme" => @preferred_scheme + "preferred_scheme" => @preferred_scheme, + "scheme_details" => @scheme_details } response = Response.new(request.put(path, data, options)) diff --git a/lib/processout/coupon.rb b/lib/processout/coupon.rb deleted file mode 100755 index ebc5213..0000000 --- a/lib/processout/coupon.rb +++ /dev/null @@ -1,352 +0,0 @@ -# The content of this file was automatically generated - -require "cgi" -require "json" -require "processout/networking/request" -require "processout/networking/response" - -module ProcessOut - class Coupon - - attr_reader :id - attr_reader :project - attr_reader :project_id - attr_reader :amount_off - attr_reader :percent_off - attr_reader :currency - attr_reader :iteration_count - attr_reader :max_redemptions - attr_reader :expires_at - attr_reader :metadata - attr_reader :redeemed_number - attr_reader :sandbox - attr_reader :created_at - - - def id=(val) - @id = val - end - - def project=(val) - if val.nil? - @project = val - return - end - - if val.instance_of? Project - @project = val - else - obj = Project.new(@client) - obj.fill_with_data(val) - @project = obj - end - - end - - def project_id=(val) - @project_id = val - end - - def amount_off=(val) - @amount_off = val - end - - def percent_off=(val) - @percent_off = val - end - - def currency=(val) - @currency = val - end - - def iteration_count=(val) - @iteration_count = val - end - - def max_redemptions=(val) - @max_redemptions = val - end - - def expires_at=(val) - @expires_at = val - end - - def metadata=(val) - @metadata = val - end - - def redeemed_number=(val) - @redeemed_number = val - end - - def sandbox=(val) - @sandbox = val - end - - def created_at=(val) - @created_at = val - end - - - # Initializes the Coupon object - # Params: - # +client+:: +ProcessOut+ client instance - # +data+:: data that can be used to fill the object - def initialize(client, data = {}) - @client = client - - self.id = data.fetch(:id, nil) - self.project = data.fetch(:project, nil) - self.project_id = data.fetch(:project_id, nil) - self.amount_off = data.fetch(:amount_off, nil) - self.percent_off = data.fetch(:percent_off, nil) - self.currency = data.fetch(:currency, nil) - self.iteration_count = data.fetch(:iteration_count, nil) - self.max_redemptions = data.fetch(:max_redemptions, nil) - self.expires_at = data.fetch(:expires_at, nil) - self.metadata = data.fetch(:metadata, nil) - self.redeemed_number = data.fetch(:redeemed_number, nil) - self.sandbox = data.fetch(:sandbox, nil) - self.created_at = data.fetch(:created_at, nil) - - end - - # Create a new Coupon using the current client - def new(data = {}) - Coupon.new(@client, data) - end - - # Overrides the JSON marshaller to only send the fields we want - def to_json(options) - { - "id": self.id, - "project": self.project, - "project_id": self.project_id, - "amount_off": self.amount_off, - "percent_off": self.percent_off, - "currency": self.currency, - "iteration_count": self.iteration_count, - "max_redemptions": self.max_redemptions, - "expires_at": self.expires_at, - "metadata": self.metadata, - "redeemed_number": self.redeemed_number, - "sandbox": self.sandbox, - "created_at": self.created_at, - }.to_json - end - - # Fills the object with data coming from the API - # Params: - # +data+:: +Hash+ of data coming from the API - def fill_with_data(data) - if data.nil? - return self - end - if data.include? "id" - self.id = data["id"] - end - if data.include? "project" - self.project = data["project"] - end - if data.include? "project_id" - self.project_id = data["project_id"] - end - if data.include? "amount_off" - self.amount_off = data["amount_off"] - end - if data.include? "percent_off" - self.percent_off = data["percent_off"] - end - if data.include? "currency" - self.currency = data["currency"] - end - if data.include? "iteration_count" - self.iteration_count = data["iteration_count"] - end - if data.include? "max_redemptions" - self.max_redemptions = data["max_redemptions"] - end - if data.include? "expires_at" - self.expires_at = data["expires_at"] - end - if data.include? "metadata" - self.metadata = data["metadata"] - end - if data.include? "redeemed_number" - self.redeemed_number = data["redeemed_number"] - end - if data.include? "sandbox" - self.sandbox = data["sandbox"] - end - if data.include? "created_at" - self.created_at = data["created_at"] - end - - self - end - - # Prefills the object with the data passed as parameters - # Params: - # +data+:: +Hash+ of data - def prefill(data) - if data.nil? - return self - end - self.id = data.fetch(:id, self.id) - self.project = data.fetch(:project, self.project) - self.project_id = data.fetch(:project_id, self.project_id) - self.amount_off = data.fetch(:amount_off, self.amount_off) - self.percent_off = data.fetch(:percent_off, self.percent_off) - self.currency = data.fetch(:currency, self.currency) - self.iteration_count = data.fetch(:iteration_count, self.iteration_count) - self.max_redemptions = data.fetch(:max_redemptions, self.max_redemptions) - self.expires_at = data.fetch(:expires_at, self.expires_at) - self.metadata = data.fetch(:metadata, self.metadata) - self.redeemed_number = data.fetch(:redeemed_number, self.redeemed_number) - self.sandbox = data.fetch(:sandbox, self.sandbox) - self.created_at = data.fetch(:created_at, self.created_at) - - self - end - - # Get all the coupons. - # Params: - # +options+:: +Hash+ of options - def all(options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/coupons" - data = { - - } - - response = Response.new(request.get(path, data, options)) - return_values = Array.new - - a = Array.new - body = response.body - for v in body['coupons'] - tmp = Coupon.new(@client) - tmp.fill_with_data(v) - a.push(tmp) - end - - return_values.push(a) - - - - return_values[0] - end - - # Create a new coupon. - # Params: - # +options+:: +Hash+ of options - def create(options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/coupons" - data = { - "id" => @id, - "amount_off" => @amount_off, - "percent_off" => @percent_off, - "currency" => @currency, - "iteration_count" => @iteration_count, - "max_redemptions" => @max_redemptions, - "expires_at" => @expires_at, - "metadata" => @metadata - } - - response = Response.new(request.post(path, data, options)) - return_values = Array.new - - body = response.body - body = body.key?("coupon") ? body["coupon"] : nil - - - return_values.push(self.fill_with_data(body)) - - - - return_values[0] - end - - # Find a coupon by its ID. - # Params: - # +coupon_id+:: ID of the coupon - # +options+:: +Hash+ of options - def find(coupon_id, options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/coupons/" + CGI.escape(coupon_id) + "" - data = { - - } - - response = Response.new(request.get(path, data, options)) - return_values = Array.new - - body = response.body - body = body.key?("coupon") ? body["coupon"] : nil - - - obj = Coupon.new(@client) - return_values.push(obj.fill_with_data(body)) - - - - return_values[0] - end - - # Save the updated coupon attributes. - # Params: - # +options+:: +Hash+ of options - def save(options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/coupons/" + CGI.escape(@id) + "" - data = { - "metadata" => @metadata - } - - response = Response.new(request.put(path, data, options)) - return_values = Array.new - - body = response.body - body = body.key?("coupon") ? body["coupon"] : nil - - - return_values.push(self.fill_with_data(body)) - - - - return_values[0] - end - - # Delete the coupon. - # Params: - # +options+:: +Hash+ of options - def delete(options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/coupons/" + CGI.escape(@id) + "" - data = { - - } - - response = Response.new(request.delete(path, data, options)) - return_values = Array.new - - return_values.push(response.success) - - - return_values[0] - end - - - end -end diff --git a/lib/processout/customer.rb b/lib/processout/customer.rb index 329fd9f..f591be4 100755 --- a/lib/processout/customer.rb +++ b/lib/processout/customer.rb @@ -14,7 +14,6 @@ class Customer attr_reader :default_token attr_reader :default_token_id attr_reader :tokens - attr_reader :subscriptions attr_reader :transactions attr_reader :balance attr_reader :currency @@ -106,26 +105,6 @@ def tokens=(val) end - def subscriptions=(val) - if val.nil? - @subscriptions = [] - return - end - - if val.length > 0 and val[0].instance_of? Subscription - @subscriptions = val - else - l = Array.new - for v in val - obj = Subscription.new(@client) - obj.fill_with_data(v) - l.push(obj) - end - @subscriptions = l - end - - end - def transactions=(val) if val.nil? @transactions = [] @@ -268,7 +247,6 @@ def initialize(client, data = {}) self.default_token = data.fetch(:default_token, nil) self.default_token_id = data.fetch(:default_token_id, nil) self.tokens = data.fetch(:tokens, nil) - self.subscriptions = data.fetch(:subscriptions, nil) self.transactions = data.fetch(:transactions, nil) self.balance = data.fetch(:balance, nil) self.currency = data.fetch(:currency, nil) @@ -311,7 +289,6 @@ def to_json(options) "default_token": self.default_token, "default_token_id": self.default_token_id, "tokens": self.tokens, - "subscriptions": self.subscriptions, "transactions": self.transactions, "balance": self.balance, "currency": self.currency, @@ -365,9 +342,6 @@ def fill_with_data(data) if data.include? "tokens" self.tokens = data["tokens"] end - if data.include? "subscriptions" - self.subscriptions = data["subscriptions"] - end if data.include? "transactions" self.transactions = data["transactions"] end @@ -460,7 +434,6 @@ def prefill(data) self.default_token = data.fetch(:default_token, self.default_token) self.default_token_id = data.fetch(:default_token_id, self.default_token_id) self.tokens = data.fetch(:tokens, self.tokens) - self.subscriptions = data.fetch(:subscriptions, self.subscriptions) self.transactions = data.fetch(:transactions, self.transactions) self.balance = data.fetch(:balance, self.balance) self.currency = data.fetch(:currency, self.currency) @@ -490,36 +463,6 @@ def prefill(data) self end - # Get the subscriptions belonging to the customer. - # Params: - # +options+:: +Hash+ of options - def fetch_subscriptions(options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/customers/" + CGI.escape(@id) + "/subscriptions" - data = { - - } - - response = Response.new(request.get(path, data, options)) - return_values = Array.new - - a = Array.new - body = response.body - for v in body['subscriptions'] - tmp = Subscription.new(@client) - tmp.fill_with_data(v) - a.push(tmp) - end - - return_values.push(a) - - - - return_values[0] - end - # Get the customer's tokens. # Params: # +options+:: +Hash+ of options diff --git a/lib/processout/device.rb b/lib/processout/device.rb index 9925cae..ffd6189 100755 --- a/lib/processout/device.rb +++ b/lib/processout/device.rb @@ -11,6 +11,8 @@ class Device attr_reader :request_origin attr_reader :id attr_reader :channel + attr_reader :threeds_sdk + attr_reader :platform attr_reader :ip_address attr_reader :user_agent attr_reader :header_accept @@ -35,6 +37,14 @@ def channel=(val) @channel = val end + def threeds_sdk=(val) + @threeds_sdk = val + end + + def platform=(val) + @platform = val + end + def ip_address=(val) @ip_address = val end @@ -86,6 +96,8 @@ def initialize(client, data = {}) self.request_origin = data.fetch(:request_origin, nil) self.id = data.fetch(:id, nil) self.channel = data.fetch(:channel, nil) + self.threeds_sdk = data.fetch(:threeds_sdk, nil) + self.platform = data.fetch(:platform, nil) self.ip_address = data.fetch(:ip_address, nil) self.user_agent = data.fetch(:user_agent, nil) self.header_accept = data.fetch(:header_accept, nil) @@ -110,6 +122,8 @@ def to_json(options) "request_origin": self.request_origin, "id": self.id, "channel": self.channel, + "threeds_sdk": self.threeds_sdk, + "platform": self.platform, "ip_address": self.ip_address, "user_agent": self.user_agent, "header_accept": self.header_accept, @@ -139,6 +153,12 @@ def fill_with_data(data) if data.include? "channel" self.channel = data["channel"] end + if data.include? "threeds_sdk" + self.threeds_sdk = data["threeds_sdk"] + end + if data.include? "platform" + self.platform = data["platform"] + end if data.include? "ip_address" self.ip_address = data["ip_address"] end @@ -183,6 +203,8 @@ def prefill(data) self.request_origin = data.fetch(:request_origin, self.request_origin) self.id = data.fetch(:id, self.id) self.channel = data.fetch(:channel, self.channel) + self.threeds_sdk = data.fetch(:threeds_sdk, self.threeds_sdk) + self.platform = data.fetch(:platform, self.platform) self.ip_address = data.fetch(:ip_address, self.ip_address) self.user_agent = data.fetch(:user_agent, self.user_agent) self.header_accept = data.fetch(:header_accept, self.header_accept) diff --git a/lib/processout/discount.rb b/lib/processout/discount.rb deleted file mode 100755 index 23421e8..0000000 --- a/lib/processout/discount.rb +++ /dev/null @@ -1,360 +0,0 @@ -# The content of this file was automatically generated - -require "cgi" -require "json" -require "processout/networking/request" -require "processout/networking/response" - -module ProcessOut - class Discount - - attr_reader :id - attr_reader :project - attr_reader :project_id - attr_reader :subscription - attr_reader :subscription_id - attr_reader :coupon - attr_reader :coupon_id - attr_reader :name - attr_reader :amount - attr_reader :percent - attr_reader :expires_at - attr_reader :metadata - attr_reader :sandbox - attr_reader :created_at - - - def id=(val) - @id = val - end - - def project=(val) - if val.nil? - @project = val - return - end - - if val.instance_of? Project - @project = val - else - obj = Project.new(@client) - obj.fill_with_data(val) - @project = obj - end - - end - - def project_id=(val) - @project_id = val - end - - def subscription=(val) - if val.nil? - @subscription = val - return - end - - if val.instance_of? Subscription - @subscription = val - else - obj = Subscription.new(@client) - obj.fill_with_data(val) - @subscription = obj - end - - end - - def subscription_id=(val) - @subscription_id = val - end - - def coupon=(val) - if val.nil? - @coupon = val - return - end - - if val.instance_of? Coupon - @coupon = val - else - obj = Coupon.new(@client) - obj.fill_with_data(val) - @coupon = obj - end - - end - - def coupon_id=(val) - @coupon_id = val - end - - def name=(val) - @name = val - end - - def amount=(val) - @amount = val - end - - def percent=(val) - @percent = val - end - - def expires_at=(val) - @expires_at = val - end - - def metadata=(val) - @metadata = val - end - - def sandbox=(val) - @sandbox = val - end - - def created_at=(val) - @created_at = val - end - - - # Initializes the Discount object - # Params: - # +client+:: +ProcessOut+ client instance - # +data+:: data that can be used to fill the object - def initialize(client, data = {}) - @client = client - - self.id = data.fetch(:id, nil) - self.project = data.fetch(:project, nil) - self.project_id = data.fetch(:project_id, nil) - self.subscription = data.fetch(:subscription, nil) - self.subscription_id = data.fetch(:subscription_id, nil) - self.coupon = data.fetch(:coupon, nil) - self.coupon_id = data.fetch(:coupon_id, nil) - self.name = data.fetch(:name, nil) - self.amount = data.fetch(:amount, nil) - self.percent = data.fetch(:percent, nil) - self.expires_at = data.fetch(:expires_at, nil) - self.metadata = data.fetch(:metadata, nil) - self.sandbox = data.fetch(:sandbox, nil) - self.created_at = data.fetch(:created_at, nil) - - end - - # Create a new Discount using the current client - def new(data = {}) - Discount.new(@client, data) - end - - # Overrides the JSON marshaller to only send the fields we want - def to_json(options) - { - "id": self.id, - "project": self.project, - "project_id": self.project_id, - "subscription": self.subscription, - "subscription_id": self.subscription_id, - "coupon": self.coupon, - "coupon_id": self.coupon_id, - "name": self.name, - "amount": self.amount, - "percent": self.percent, - "expires_at": self.expires_at, - "metadata": self.metadata, - "sandbox": self.sandbox, - "created_at": self.created_at, - }.to_json - end - - # Fills the object with data coming from the API - # Params: - # +data+:: +Hash+ of data coming from the API - def fill_with_data(data) - if data.nil? - return self - end - if data.include? "id" - self.id = data["id"] - end - if data.include? "project" - self.project = data["project"] - end - if data.include? "project_id" - self.project_id = data["project_id"] - end - if data.include? "subscription" - self.subscription = data["subscription"] - end - if data.include? "subscription_id" - self.subscription_id = data["subscription_id"] - end - if data.include? "coupon" - self.coupon = data["coupon"] - end - if data.include? "coupon_id" - self.coupon_id = data["coupon_id"] - end - if data.include? "name" - self.name = data["name"] - end - if data.include? "amount" - self.amount = data["amount"] - end - if data.include? "percent" - self.percent = data["percent"] - end - if data.include? "expires_at" - self.expires_at = data["expires_at"] - end - if data.include? "metadata" - self.metadata = data["metadata"] - end - if data.include? "sandbox" - self.sandbox = data["sandbox"] - end - if data.include? "created_at" - self.created_at = data["created_at"] - end - - self - end - - # Prefills the object with the data passed as parameters - # Params: - # +data+:: +Hash+ of data - def prefill(data) - if data.nil? - return self - end - self.id = data.fetch(:id, self.id) - self.project = data.fetch(:project, self.project) - self.project_id = data.fetch(:project_id, self.project_id) - self.subscription = data.fetch(:subscription, self.subscription) - self.subscription_id = data.fetch(:subscription_id, self.subscription_id) - self.coupon = data.fetch(:coupon, self.coupon) - self.coupon_id = data.fetch(:coupon_id, self.coupon_id) - self.name = data.fetch(:name, self.name) - self.amount = data.fetch(:amount, self.amount) - self.percent = data.fetch(:percent, self.percent) - self.expires_at = data.fetch(:expires_at, self.expires_at) - self.metadata = data.fetch(:metadata, self.metadata) - self.sandbox = data.fetch(:sandbox, self.sandbox) - self.created_at = data.fetch(:created_at, self.created_at) - - self - end - - # Get the discounts applied to the subscription. - # Params: - # +subscription_id+:: ID of the subscription - # +options+:: +Hash+ of options - def fetch_subscription_discounts(subscription_id, options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/subscriptions/" + CGI.escape(subscription_id) + "/discounts" - data = { - - } - - response = Response.new(request.get(path, data, options)) - return_values = Array.new - - a = Array.new - body = response.body - for v in body['discounts'] - tmp = Discount.new(@client) - tmp.fill_with_data(v) - a.push(tmp) - end - - return_values.push(a) - - - - return_values[0] - end - - # Create a new discount for the given subscription ID. - # Params: - # +options+:: +Hash+ of options - def create(options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/subscriptions/" + CGI.escape(@subscription_id) + "/discounts" - data = { - "coupon_id" => @coupon_id, - "name" => @name, - "amount" => @amount, - "expires_at" => @expires_at, - "metadata" => @metadata - } - - response = Response.new(request.post(path, data, options)) - return_values = Array.new - - body = response.body - body = body.key?("discount") ? body["discount"] : nil - - - return_values.push(self.fill_with_data(body)) - - - - return_values[0] - end - - # Find a subscription's discount by its ID. - # Params: - # +subscription_id+:: ID of the subscription on which the discount was applied - # +discount_id+:: ID of the discount - # +options+:: +Hash+ of options - def find(subscription_id, discount_id, options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/subscriptions/" + CGI.escape(subscription_id) + "/discounts/" + CGI.escape(discount_id) + "" - data = { - - } - - response = Response.new(request.get(path, data, options)) - return_values = Array.new - - body = response.body - body = body.key?("discount") ? body["discount"] : nil - - - obj = Discount.new(@client) - return_values.push(obj.fill_with_data(body)) - - - - return_values[0] - end - - # Delete a discount applied to a subscription. - # Params: - # +options+:: +Hash+ of options - def delete(options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/subscriptions/" + CGI.escape(@subscription_id) + "/discounts/" + CGI.escape(@id) + "" - data = { - - } - - response = Response.new(request.delete(path, data, options)) - return_values = Array.new - - return_values.push(response.success) - - - return_values[0] - end - - - end -end diff --git a/lib/processout/invoice.rb b/lib/processout/invoice.rb index 7690256..53ddccc 100755 --- a/lib/processout/invoice.rb +++ b/lib/processout/invoice.rb @@ -15,12 +15,11 @@ class Invoice attr_reader :transaction_id attr_reader :customer attr_reader :customer_id - attr_reader :subscription - attr_reader :subscription_id attr_reader :token attr_reader :token_id attr_reader :details attr_reader :submerchant + attr_reader :submerchant_id attr_reader :url attr_reader :url_qrcode attr_reader :name @@ -60,6 +59,7 @@ class Invoice attr_reader :verification attr_reader :auto_capture_at attr_reader :reference_id + attr_reader :payment_processing_config def id=(val) @@ -126,26 +126,6 @@ def customer_id=(val) @customer_id = val end - def subscription=(val) - if val.nil? - @subscription = val - return - end - - if val.instance_of? Subscription - @subscription = val - else - obj = Subscription.new(@client) - obj.fill_with_data(val) - @subscription = obj - end - - end - - def subscription_id=(val) - @subscription_id = val - end - def token=(val) if val.nil? @token = val @@ -202,6 +182,10 @@ def submerchant=(val) end + def submerchant_id=(val) + @submerchant_id = val + end + def url=(val) @url = val end @@ -454,6 +438,22 @@ def reference_id=(val) @reference_id = val end + def payment_processing_config=(val) + if val.nil? + @payment_processing_config = val + return + end + + if val.instance_of? PaymentProcessingConfiguration + @payment_processing_config = val + else + obj = PaymentProcessingConfiguration.new(@client) + obj.fill_with_data(val) + @payment_processing_config = obj + end + + end + # Initializes the Invoice object # Params: @@ -469,12 +469,11 @@ def initialize(client, data = {}) self.transaction_id = data.fetch(:transaction_id, nil) self.customer = data.fetch(:customer, nil) self.customer_id = data.fetch(:customer_id, nil) - self.subscription = data.fetch(:subscription, nil) - 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.submerchant = data.fetch(:submerchant, nil) + self.submerchant_id = data.fetch(:submerchant_id, nil) self.url = data.fetch(:url, nil) self.url_qrcode = data.fetch(:url_qrcode, nil) self.name = data.fetch(:name, nil) @@ -514,6 +513,7 @@ def initialize(client, data = {}) self.verification = data.fetch(:verification, nil) self.auto_capture_at = data.fetch(:auto_capture_at, nil) self.reference_id = data.fetch(:reference_id, nil) + self.payment_processing_config = data.fetch(:payment_processing_config, nil) end @@ -532,12 +532,11 @@ def to_json(options) "transaction_id": self.transaction_id, "customer": self.customer, "customer_id": self.customer_id, - "subscription": self.subscription, - "subscription_id": self.subscription_id, "token": self.token, "token_id": self.token_id, "details": self.details, "submerchant": self.submerchant, + "submerchant_id": self.submerchant_id, "url": self.url, "url_qrcode": self.url_qrcode, "name": self.name, @@ -577,6 +576,7 @@ def to_json(options) "verification": self.verification, "auto_capture_at": self.auto_capture_at, "reference_id": self.reference_id, + "payment_processing_config": self.payment_processing_config, }.to_json end @@ -608,12 +608,6 @@ def fill_with_data(data) if data.include? "customer_id" self.customer_id = data["customer_id"] end - if data.include? "subscription" - self.subscription = data["subscription"] - end - if data.include? "subscription_id" - self.subscription_id = data["subscription_id"] - end if data.include? "token" self.token = data["token"] end @@ -626,6 +620,9 @@ def fill_with_data(data) if data.include? "submerchant" self.submerchant = data["submerchant"] end + if data.include? "submerchant_id" + self.submerchant_id = data["submerchant_id"] + end if data.include? "url" self.url = data["url"] end @@ -743,6 +740,9 @@ def fill_with_data(data) if data.include? "reference_id" self.reference_id = data["reference_id"] end + if data.include? "payment_processing_config" + self.payment_processing_config = data["payment_processing_config"] + end self end @@ -761,12 +761,11 @@ def prefill(data) self.transaction_id = data.fetch(:transaction_id, self.transaction_id) self.customer = data.fetch(:customer, self.customer) self.customer_id = data.fetch(:customer_id, self.customer_id) - self.subscription = data.fetch(:subscription, self.subscription) - 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.submerchant = data.fetch(:submerchant, self.submerchant) + self.submerchant_id = data.fetch(:submerchant_id, self.submerchant_id) self.url = data.fetch(:url, self.url) self.url_qrcode = data.fetch(:url_qrcode, self.url_qrcode) self.name = data.fetch(:name, self.name) @@ -806,10 +805,59 @@ def prefill(data) self.verification = data.fetch(:verification, self.verification) self.auto_capture_at = data.fetch(:auto_capture_at, self.auto_capture_at) self.reference_id = data.fetch(:reference_id, self.reference_id) + self.payment_processing_config = data.fetch(:payment_processing_config, self.payment_processing_config) self end + # Autheticate the invoice using the given source (customer or token) + # Params: + # +source+:: Source used to authenticate the payment. Can be a card, token or a gateway request. + # +options+:: +Hash+ of options + def authenticate(source, options = {}) + self.prefill(options) + + request = Request.new(@client) + path = "/invoices/:invoice_id/authenticate" + data = { + "device" => @device, + "incremental" => @incremental, + "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), + "allow_fallback_to_sale" => options.fetch(:allow_fallback_to_sale, nil), + "auto_capture_at" => options.fetch(:auto_capture_at, nil), + "metadata" => options.fetch(:metadata, nil), + "override_mac_blocking" => options.fetch(:override_mac_blocking, nil), + "external_three_d_s" => options.fetch(:external_three_d_s, nil), + "save_source" => options.fetch(:save_source, nil), + "provision_network_token" => options.fetch(:provision_network_token, nil), + "invoice_line_items" => options.fetch(:invoice_line_items, nil), + "transaction_link_id" => options.fetch(:transaction_link_id, nil), + "source" => source + } + + response = Response.new(request.post(path, data, options)) + return_values = Array.new + + body = response.body + body = body.key?("transaction") ? body["transaction"] : nil + if !body.nil? + transaction = Transaction.new(@client) + return_values.push(transaction.fill_with_data(body)) + end + body = response.body + body = body.key?("customer_action") ? body["customer_action"] : nil + if !body.nil? + customer_action = CustomerAction.new(@client) + return_values.push(customer_action.fill_with_data(body)) + end + + + return_values + end + # Create an incremental authorization # Params: # +amount+:: Amount to increment authorization by @@ -860,6 +908,9 @@ def authorize(source, options = {}) "override_mac_blocking" => options.fetch(:override_mac_blocking, nil), "external_three_d_s" => options.fetch(:external_three_d_s, nil), "save_source" => options.fetch(:save_source, nil), + "provision_network_token" => options.fetch(:provision_network_token, nil), + "invoice_line_items" => options.fetch(:invoice_line_items, nil), + "transaction_link_id" => options.fetch(:transaction_link_id, nil), "source" => source } @@ -906,6 +957,8 @@ def capture(source, options = {}) "override_mac_blocking" => options.fetch(:override_mac_blocking, nil), "external_three_d_s" => options.fetch(:external_three_d_s, nil), "save_source" => options.fetch(:save_source, nil), + "provision_network_token" => options.fetch(:provision_network_token, nil), + "transaction_link_id" => options.fetch(:transaction_link_id, nil), "source" => source } @@ -994,6 +1047,7 @@ def payout(gateway_configuration_id, source, options = {}) path = "/invoices/" + CGI.escape(@id) + "/payout" data = { "force_gateway_configuration_id" => options.fetch(:force_gateway_configuration_id, nil), + "metadata" => options.fetch(:metadata, nil), "gateway_configuration_id" => gateway_configuration_id, "source" => source } @@ -1202,6 +1256,7 @@ def create(options = {}) "metadata" => @metadata, "details" => @details, "submerchant" => @submerchant, + "submerchant_id" => @submerchant_id, "reference_id" => @reference_id, "exemption_reason_3ds2" => @exemption_reason_3ds2, "sca_exemption_reason" => @sca_exemption_reason, diff --git a/lib/processout/invoice_device.rb b/lib/processout/invoice_device.rb index 97a6261..65a07ef 100755 --- a/lib/processout/invoice_device.rb +++ b/lib/processout/invoice_device.rb @@ -9,6 +9,7 @@ module ProcessOut class InvoiceDevice attr_reader :channel + attr_reader :platform attr_reader :ip_address attr_reader :id @@ -17,6 +18,10 @@ def channel=(val) @channel = val end + def platform=(val) + @platform = val + end + def ip_address=(val) @ip_address = val end @@ -34,6 +39,7 @@ def initialize(client, data = {}) @client = client self.channel = data.fetch(:channel, nil) + self.platform = data.fetch(:platform, nil) self.ip_address = data.fetch(:ip_address, nil) self.id = data.fetch(:id, nil) @@ -48,6 +54,7 @@ def new(data = {}) def to_json(options) { "channel": self.channel, + "platform": self.platform, "ip_address": self.ip_address, "id": self.id, }.to_json @@ -63,6 +70,9 @@ def fill_with_data(data) if data.include? "channel" self.channel = data["channel"] end + if data.include? "platform" + self.platform = data["platform"] + end if data.include? "ip_address" self.ip_address = data["ip_address"] end @@ -81,6 +91,7 @@ def prefill(data) return self end self.channel = data.fetch(:channel, self.channel) + self.platform = data.fetch(:platform, self.platform) self.ip_address = data.fetch(:ip_address, self.ip_address) self.id = data.fetch(:id, self.id) diff --git a/lib/processout/invoice_external_fraud_tools.rb b/lib/processout/invoice_external_fraud_tools.rb index e2ead1d..61065e6 100755 --- a/lib/processout/invoice_external_fraud_tools.rb +++ b/lib/processout/invoice_external_fraud_tools.rb @@ -11,6 +11,7 @@ class InvoiceExternalFraudTools attr_reader :forter attr_reader :ravelin attr_reader :signifyd + attr_reader :riskified def forter=(val) @@ -28,6 +29,11 @@ def signifyd=(val) end + def riskified=(val) + @riskified = val + + end + # Initializes the InvoiceExternalFraudTools object # Params: @@ -39,6 +45,7 @@ def initialize(client, data = {}) self.forter = data.fetch(:forter, nil) self.ravelin = data.fetch(:ravelin, nil) self.signifyd = data.fetch(:signifyd, nil) + self.riskified = data.fetch(:riskified, nil) end @@ -53,6 +60,7 @@ def to_json(options) "forter": self.forter, "ravelin": self.ravelin, "signifyd": self.signifyd, + "riskified": self.riskified, }.to_json end @@ -72,6 +80,9 @@ def fill_with_data(data) if data.include? "signifyd" self.signifyd = data["signifyd"] end + if data.include? "riskified" + self.riskified = data["riskified"] + end self end @@ -86,6 +97,7 @@ def prefill(data) self.forter = data.fetch(:forter, self.forter) self.ravelin = data.fetch(:ravelin, self.ravelin) self.signifyd = data.fetch(:signifyd, self.signifyd) + self.riskified = data.fetch(:riskified, self.riskified) self end diff --git a/lib/processout/networking/request.rb b/lib/processout/networking/request.rb index 3db2d68..c89d715 100644 --- a/lib/processout/networking/request.rb +++ b/lib/processout/networking/request.rb @@ -13,7 +13,7 @@ def apply_headers(req, options) req.basic_auth @client.project_id, @client.project_secret req.content_type = "application/json" req["API-Version"] = "1.4.0.0" - req["User-Agent"] = "ProcessOut Ruby-Bindings/4.0.0" + req["User-Agent"] = "ProcessOut Ruby-Bindings/6.0.0" unless options.nil? req["Idempotency-Key"] = options.fetch(:idempotency_key, "") diff --git a/lib/processout/payment_processing_configuration.rb b/lib/processout/payment_processing_configuration.rb new file mode 100755 index 0000000..0adf756 --- /dev/null +++ b/lib/processout/payment_processing_configuration.rb @@ -0,0 +1,93 @@ +# The content of this file was automatically generated + +require "cgi" +require "json" +require "processout/networking/request" +require "processout/networking/response" + +module ProcessOut + class PaymentProcessingConfiguration + + attr_reader :bypass_unsupported_split_payments + attr_reader :apm_payment_config + + + def bypass_unsupported_split_payments=(val) + @bypass_unsupported_split_payments = val + end + + def apm_payment_config=(val) + if val.nil? + @apm_payment_config = val + return + end + + if val.instance_of? APMPaymentProcessingConfiguration + @apm_payment_config = val + else + obj = APMPaymentProcessingConfiguration.new(@client) + obj.fill_with_data(val) + @apm_payment_config = obj + end + + end + + + # Initializes the PaymentProcessingConfiguration object + # Params: + # +client+:: +ProcessOut+ client instance + # +data+:: data that can be used to fill the object + def initialize(client, data = {}) + @client = client + + self.bypass_unsupported_split_payments = data.fetch(:bypass_unsupported_split_payments, nil) + self.apm_payment_config = data.fetch(:apm_payment_config, nil) + + end + + # Create a new PaymentProcessingConfiguration using the current client + def new(data = {}) + PaymentProcessingConfiguration.new(@client, data) + end + + # Overrides the JSON marshaller to only send the fields we want + def to_json(options) + { + "bypass_unsupported_split_payments": self.bypass_unsupported_split_payments, + "apm_payment_config": self.apm_payment_config, + }.to_json + end + + # Fills the object with data coming from the API + # Params: + # +data+:: +Hash+ of data coming from the API + def fill_with_data(data) + if data.nil? + return self + end + if data.include? "bypass_unsupported_split_payments" + self.bypass_unsupported_split_payments = data["bypass_unsupported_split_payments"] + end + if data.include? "apm_payment_config" + self.apm_payment_config = data["apm_payment_config"] + end + + self + end + + # Prefills the object with the data passed as parameters + # Params: + # +data+:: +Hash+ of data + def prefill(data) + if data.nil? + return self + end + self.bypass_unsupported_split_payments = data.fetch(:bypass_unsupported_split_payments, self.bypass_unsupported_split_payments) + self.apm_payment_config = data.fetch(:apm_payment_config, self.apm_payment_config) + + self + end + + + end +end diff --git a/lib/processout/plan.rb b/lib/processout/plan.rb deleted file mode 100755 index 53041a5..0000000 --- a/lib/processout/plan.rb +++ /dev/null @@ -1,368 +0,0 @@ -# The content of this file was automatically generated - -require "cgi" -require "json" -require "processout/networking/request" -require "processout/networking/response" - -module ProcessOut - class Plan - - attr_reader :id - attr_reader :project - attr_reader :project_id - attr_reader :url - attr_reader :name - attr_reader :amount - attr_reader :currency - attr_reader :metadata - attr_reader :interval - attr_reader :trial_period - attr_reader :return_url - attr_reader :cancel_url - attr_reader :sandbox - attr_reader :created_at - - - def id=(val) - @id = val - end - - def project=(val) - if val.nil? - @project = val - return - end - - if val.instance_of? Project - @project = val - else - obj = Project.new(@client) - obj.fill_with_data(val) - @project = obj - end - - end - - def project_id=(val) - @project_id = val - end - - def url=(val) - @url = val - end - - def name=(val) - @name = val - end - - def amount=(val) - @amount = val - end - - def currency=(val) - @currency = val - end - - def metadata=(val) - @metadata = val - end - - def interval=(val) - @interval = val - end - - def trial_period=(val) - @trial_period = val - end - - def return_url=(val) - @return_url = val - end - - def cancel_url=(val) - @cancel_url = val - end - - def sandbox=(val) - @sandbox = val - end - - def created_at=(val) - @created_at = val - end - - - # Initializes the Plan object - # Params: - # +client+:: +ProcessOut+ client instance - # +data+:: data that can be used to fill the object - def initialize(client, data = {}) - @client = client - - self.id = data.fetch(:id, nil) - self.project = data.fetch(:project, nil) - self.project_id = data.fetch(:project_id, nil) - self.url = data.fetch(:url, nil) - self.name = data.fetch(:name, nil) - self.amount = data.fetch(:amount, nil) - self.currency = data.fetch(:currency, nil) - self.metadata = data.fetch(:metadata, nil) - self.interval = data.fetch(:interval, nil) - self.trial_period = data.fetch(:trial_period, nil) - self.return_url = data.fetch(:return_url, nil) - self.cancel_url = data.fetch(:cancel_url, nil) - self.sandbox = data.fetch(:sandbox, nil) - self.created_at = data.fetch(:created_at, nil) - - end - - # Create a new Plan using the current client - def new(data = {}) - Plan.new(@client, data) - end - - # Overrides the JSON marshaller to only send the fields we want - def to_json(options) - { - "id": self.id, - "project": self.project, - "project_id": self.project_id, - "url": self.url, - "name": self.name, - "amount": self.amount, - "currency": self.currency, - "metadata": self.metadata, - "interval": self.interval, - "trial_period": self.trial_period, - "return_url": self.return_url, - "cancel_url": self.cancel_url, - "sandbox": self.sandbox, - "created_at": self.created_at, - }.to_json - end - - # Fills the object with data coming from the API - # Params: - # +data+:: +Hash+ of data coming from the API - def fill_with_data(data) - if data.nil? - return self - end - if data.include? "id" - self.id = data["id"] - end - if data.include? "project" - self.project = data["project"] - end - if data.include? "project_id" - self.project_id = data["project_id"] - end - if data.include? "url" - self.url = data["url"] - end - if data.include? "name" - self.name = data["name"] - end - if data.include? "amount" - self.amount = data["amount"] - end - if data.include? "currency" - self.currency = data["currency"] - end - if data.include? "metadata" - self.metadata = data["metadata"] - end - if data.include? "interval" - self.interval = data["interval"] - end - if data.include? "trial_period" - self.trial_period = data["trial_period"] - end - if data.include? "return_url" - self.return_url = data["return_url"] - end - if data.include? "cancel_url" - self.cancel_url = data["cancel_url"] - end - if data.include? "sandbox" - self.sandbox = data["sandbox"] - end - if data.include? "created_at" - self.created_at = data["created_at"] - end - - self - end - - # Prefills the object with the data passed as parameters - # Params: - # +data+:: +Hash+ of data - def prefill(data) - if data.nil? - return self - end - self.id = data.fetch(:id, self.id) - self.project = data.fetch(:project, self.project) - self.project_id = data.fetch(:project_id, self.project_id) - self.url = data.fetch(:url, self.url) - self.name = data.fetch(:name, self.name) - self.amount = data.fetch(:amount, self.amount) - self.currency = data.fetch(:currency, self.currency) - self.metadata = data.fetch(:metadata, self.metadata) - self.interval = data.fetch(:interval, self.interval) - self.trial_period = data.fetch(:trial_period, self.trial_period) - self.return_url = data.fetch(:return_url, self.return_url) - self.cancel_url = data.fetch(:cancel_url, self.cancel_url) - self.sandbox = data.fetch(:sandbox, self.sandbox) - self.created_at = data.fetch(:created_at, self.created_at) - - self - end - - # Get all the plans. - # Params: - # +options+:: +Hash+ of options - def all(options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/plans" - data = { - - } - - response = Response.new(request.get(path, data, options)) - return_values = Array.new - - a = Array.new - body = response.body - for v in body['plans'] - tmp = Plan.new(@client) - tmp.fill_with_data(v) - a.push(tmp) - end - - return_values.push(a) - - - - return_values[0] - end - - # Create a new plan. - # Params: - # +options+:: +Hash+ of options - def create(options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/plans" - data = { - "id" => @id, - "name" => @name, - "amount" => @amount, - "currency" => @currency, - "interval" => @interval, - "trial_period" => @trial_period, - "metadata" => @metadata, - "return_url" => @return_url, - "cancel_url" => @cancel_url - } - - response = Response.new(request.post(path, data, options)) - return_values = Array.new - - body = response.body - body = body.key?("plan") ? body["plan"] : nil - - - return_values.push(self.fill_with_data(body)) - - - - return_values[0] - end - - # Find a plan by its ID. - # Params: - # +plan_id+:: ID of the plan - # +options+:: +Hash+ of options - def find(plan_id, options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/plans/" + CGI.escape(plan_id) + "" - data = { - - } - - response = Response.new(request.get(path, data, options)) - return_values = Array.new - - body = response.body - body = body.key?("plan") ? body["plan"] : nil - - - obj = Plan.new(@client) - return_values.push(obj.fill_with_data(body)) - - - - return_values[0] - end - - # Save the updated plan attributes. This action won't affect subscriptions already linked to this plan. - # Params: - # +options+:: +Hash+ of options - def save(options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/plans/" + CGI.escape(@id) + "" - data = { - "name" => @name, - "trial_period" => @trial_period, - "metadata" => @metadata, - "return_url" => @return_url, - "cancel_url" => @cancel_url - } - - response = Response.new(request.put(path, data, options)) - return_values = Array.new - - body = response.body - body = body.key?("plan") ? body["plan"] : nil - - - return_values.push(self.fill_with_data(body)) - - - - return_values[0] - end - - # Delete a plan. Subscriptions linked to this plan won't be affected. - # Params: - # +options+:: +Hash+ of options - def end(options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/plans/" + CGI.escape(@id) + "" - data = { - - } - - response = Response.new(request.delete(path, data, options)) - return_values = Array.new - - return_values.push(response.success) - - - return_values[0] - end - - - end -end diff --git a/lib/processout/project.rb b/lib/processout/project.rb index ad8d270..733298e 100755 --- a/lib/processout/project.rb +++ b/lib/processout/project.rb @@ -285,67 +285,6 @@ def delete(options = {}) return_values.push(response.success) - return_values[0] - end - - # Get all the supervised projects. - # Params: - # +options+:: +Hash+ of options - def fetch_supervised(options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/supervised-projects" - data = { - - } - - response = Response.new(request.get(path, data, options)) - return_values = Array.new - - a = Array.new - body = response.body - for v in body['projects'] - tmp = Project.new(@client) - tmp.fill_with_data(v) - a.push(tmp) - end - - return_values.push(a) - - - - return_values[0] - end - - # Create a new supervised project. - # Params: - # +options+:: +Hash+ of options - def create_supervised(options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/supervised-projects" - data = { - "id" => @id, - "name" => @name, - "default_currency" => @default_currency, - "dunning_configuration" => @dunning_configuration, - "applepay_settings" => options.fetch(:applepay_settings, nil), - "public_metadata" => options.fetch(:public_metadata, nil) - } - - response = Response.new(request.post(path, data, options)) - return_values = Array.new - - body = response.body - body = body.key?("project") ? body["project"] : nil - - - return_values.push(self.fill_with_data(body)) - - - return_values[0] end diff --git a/lib/processout/submerchant.rb b/lib/processout/submerchant.rb new file mode 100755 index 0000000..89b7a4b --- /dev/null +++ b/lib/processout/submerchant.rb @@ -0,0 +1,92 @@ +# The content of this file was automatically generated + +require "cgi" +require "json" +require "processout/networking/request" +require "processout/networking/response" + +module ProcessOut + class Submerchant + + attr_reader :id + attr_reader :name + attr_reader :created_at + + + def id=(val) + @id = val + end + + def name=(val) + @name = val + end + + def created_at=(val) + @created_at = val + end + + + # Initializes the Submerchant object + # Params: + # +client+:: +ProcessOut+ client instance + # +data+:: data that can be used to fill the object + def initialize(client, data = {}) + @client = client + + self.id = data.fetch(:id, nil) + self.name = data.fetch(:name, nil) + self.created_at = data.fetch(:created_at, nil) + + end + + # Create a new Submerchant using the current client + def new(data = {}) + Submerchant.new(@client, data) + end + + # Overrides the JSON marshaller to only send the fields we want + def to_json(options) + { + "id": self.id, + "name": self.name, + "created_at": self.created_at, + }.to_json + end + + # Fills the object with data coming from the API + # Params: + # +data+:: +Hash+ of data coming from the API + def fill_with_data(data) + if data.nil? + return self + end + if data.include? "id" + self.id = data["id"] + end + if data.include? "name" + self.name = data["name"] + end + if data.include? "created_at" + self.created_at = data["created_at"] + end + + self + end + + # Prefills the object with the data passed as parameters + # Params: + # +data+:: +Hash+ of data + def prefill(data) + if data.nil? + return self + end + self.id = data.fetch(:id, self.id) + self.name = data.fetch(:name, self.name) + self.created_at = data.fetch(:created_at, self.created_at) + + self + end + + + end +end diff --git a/lib/processout/submerchant_mapping.rb b/lib/processout/submerchant_mapping.rb new file mode 100755 index 0000000..1026890 --- /dev/null +++ b/lib/processout/submerchant_mapping.rb @@ -0,0 +1,103 @@ +# The content of this file was automatically generated + +require "cgi" +require "json" +require "processout/networking/request" +require "processout/networking/response" + +module ProcessOut + class SubmerchantMapping + + attr_reader :submerchant_id + attr_reader :gateway_configuration_id + attr_reader :psp_submerchant_id + attr_reader :created_at + + + def submerchant_id=(val) + @submerchant_id = val + end + + def gateway_configuration_id=(val) + @gateway_configuration_id = val + end + + def psp_submerchant_id=(val) + @psp_submerchant_id = val + end + + def created_at=(val) + @created_at = val + end + + + # Initializes the SubmerchantMapping object + # Params: + # +client+:: +ProcessOut+ client instance + # +data+:: data that can be used to fill the object + def initialize(client, data = {}) + @client = client + + self.submerchant_id = data.fetch(:submerchant_id, nil) + self.gateway_configuration_id = data.fetch(:gateway_configuration_id, nil) + self.psp_submerchant_id = data.fetch(:psp_submerchant_id, nil) + self.created_at = data.fetch(:created_at, nil) + + end + + # Create a new SubmerchantMapping using the current client + def new(data = {}) + SubmerchantMapping.new(@client, data) + end + + # Overrides the JSON marshaller to only send the fields we want + def to_json(options) + { + "submerchant_id": self.submerchant_id, + "gateway_configuration_id": self.gateway_configuration_id, + "psp_submerchant_id": self.psp_submerchant_id, + "created_at": self.created_at, + }.to_json + end + + # Fills the object with data coming from the API + # Params: + # +data+:: +Hash+ of data coming from the API + def fill_with_data(data) + if data.nil? + return self + end + if data.include? "submerchant_id" + self.submerchant_id = data["submerchant_id"] + end + if data.include? "gateway_configuration_id" + self.gateway_configuration_id = data["gateway_configuration_id"] + end + if data.include? "psp_submerchant_id" + self.psp_submerchant_id = data["psp_submerchant_id"] + end + if data.include? "created_at" + self.created_at = data["created_at"] + end + + self + end + + # Prefills the object with the data passed as parameters + # Params: + # +data+:: +Hash+ of data + def prefill(data) + if data.nil? + return self + end + self.submerchant_id = data.fetch(:submerchant_id, self.submerchant_id) + self.gateway_configuration_id = data.fetch(:gateway_configuration_id, self.gateway_configuration_id) + self.psp_submerchant_id = data.fetch(:psp_submerchant_id, self.psp_submerchant_id) + self.created_at = data.fetch(:created_at, self.created_at) + + self + end + + + end +end diff --git a/lib/processout/subscription.rb b/lib/processout/subscription.rb deleted file mode 100755 index 9c5cf3d..0000000 --- a/lib/processout/subscription.rb +++ /dev/null @@ -1,916 +0,0 @@ -# The content of this file was automatically generated - -require "cgi" -require "json" -require "processout/networking/request" -require "processout/networking/response" - -module ProcessOut - class Subscription - - attr_reader :id - attr_reader :project - attr_reader :project_id - attr_reader :plan - attr_reader :plan_id - attr_reader :discounts - attr_reader :addons - attr_reader :transactions - attr_reader :customer - attr_reader :customer_id - attr_reader :token - attr_reader :token_id - attr_reader :url - attr_reader :name - attr_reader :amount - attr_reader :billable_amount - attr_reader :discounted_amount - attr_reader :addons_amount - attr_reader :currency - attr_reader :metadata - attr_reader :interval - attr_reader :trial_end_at - attr_reader :activated - attr_reader :active - attr_reader :cancel_at - attr_reader :canceled - attr_reader :cancellation_reason - attr_reader :pending_cancellation - attr_reader :return_url - attr_reader :cancel_url - attr_reader :unpaid_state - attr_reader :sandbox - attr_reader :created_at - attr_reader :activated_at - attr_reader :iterate_at - - - def id=(val) - @id = val - end - - def project=(val) - if val.nil? - @project = val - return - end - - if val.instance_of? Project - @project = val - else - obj = Project.new(@client) - obj.fill_with_data(val) - @project = obj - end - - end - - def project_id=(val) - @project_id = val - end - - def plan=(val) - if val.nil? - @plan = val - return - end - - if val.instance_of? Plan - @plan = val - else - obj = Plan.new(@client) - obj.fill_with_data(val) - @plan = obj - end - - end - - def plan_id=(val) - @plan_id = val - end - - def discounts=(val) - if val.nil? - @discounts = [] - return - end - - if val.length > 0 and val[0].instance_of? Discount - @discounts = val - else - l = Array.new - for v in val - obj = Discount.new(@client) - obj.fill_with_data(v) - l.push(obj) - end - @discounts = l - end - - end - - def addons=(val) - if val.nil? - @addons = [] - return - end - - if val.length > 0 and val[0].instance_of? Addon - @addons = val - else - l = Array.new - for v in val - obj = Addon.new(@client) - obj.fill_with_data(v) - l.push(obj) - end - @addons = l - end - - end - - def transactions=(val) - if val.nil? - @transactions = [] - return - end - - if val.length > 0 and val[0].instance_of? Transaction - @transactions = val - else - l = Array.new - for v in val - obj = Transaction.new(@client) - obj.fill_with_data(v) - l.push(obj) - end - @transactions = l - end - - end - - def customer=(val) - if val.nil? - @customer = val - return - end - - if val.instance_of? Customer - @customer = val - else - obj = Customer.new(@client) - obj.fill_with_data(val) - @customer = obj - end - - end - - def customer_id=(val) - @customer_id = val - end - - def token=(val) - if val.nil? - @token = val - return - end - - if val.instance_of? Token - @token = val - else - obj = Token.new(@client) - obj.fill_with_data(val) - @token = obj - end - - end - - def token_id=(val) - @token_id = val - end - - def url=(val) - @url = val - end - - def name=(val) - @name = val - end - - def amount=(val) - @amount = val - end - - def billable_amount=(val) - @billable_amount = val - end - - def discounted_amount=(val) - @discounted_amount = val - end - - def addons_amount=(val) - @addons_amount = val - end - - def currency=(val) - @currency = val - end - - def metadata=(val) - @metadata = val - end - - def interval=(val) - @interval = val - end - - def trial_end_at=(val) - @trial_end_at = val - end - - def activated=(val) - @activated = val - end - - def active=(val) - @active = val - end - - def cancel_at=(val) - @cancel_at = val - end - - def canceled=(val) - @canceled = val - end - - def cancellation_reason=(val) - @cancellation_reason = val - end - - def pending_cancellation=(val) - @pending_cancellation = val - end - - def return_url=(val) - @return_url = val - end - - def cancel_url=(val) - @cancel_url = val - end - - def unpaid_state=(val) - @unpaid_state = val - end - - def sandbox=(val) - @sandbox = val - end - - def created_at=(val) - @created_at = val - end - - def activated_at=(val) - @activated_at = val - end - - def iterate_at=(val) - @iterate_at = val - end - - - # Initializes the Subscription object - # Params: - # +client+:: +ProcessOut+ client instance - # +data+:: data that can be used to fill the object - def initialize(client, data = {}) - @client = client - - self.id = data.fetch(:id, nil) - self.project = data.fetch(:project, nil) - self.project_id = data.fetch(:project_id, nil) - self.plan = data.fetch(:plan, nil) - self.plan_id = data.fetch(:plan_id, nil) - self.discounts = data.fetch(:discounts, nil) - self.addons = data.fetch(:addons, nil) - self.transactions = data.fetch(:transactions, nil) - self.customer = data.fetch(:customer, nil) - self.customer_id = data.fetch(:customer_id, nil) - self.token = data.fetch(:token, nil) - self.token_id = data.fetch(:token_id, nil) - self.url = data.fetch(:url, nil) - self.name = data.fetch(:name, nil) - self.amount = data.fetch(:amount, nil) - self.billable_amount = data.fetch(:billable_amount, nil) - self.discounted_amount = data.fetch(:discounted_amount, nil) - self.addons_amount = data.fetch(:addons_amount, nil) - self.currency = data.fetch(:currency, nil) - self.metadata = data.fetch(:metadata, nil) - self.interval = data.fetch(:interval, nil) - self.trial_end_at = data.fetch(:trial_end_at, nil) - self.activated = data.fetch(:activated, nil) - self.active = data.fetch(:active, nil) - self.cancel_at = data.fetch(:cancel_at, nil) - self.canceled = data.fetch(:canceled, nil) - self.cancellation_reason = data.fetch(:cancellation_reason, nil) - self.pending_cancellation = data.fetch(:pending_cancellation, nil) - self.return_url = data.fetch(:return_url, nil) - self.cancel_url = data.fetch(:cancel_url, nil) - self.unpaid_state = data.fetch(:unpaid_state, nil) - self.sandbox = data.fetch(:sandbox, nil) - self.created_at = data.fetch(:created_at, nil) - self.activated_at = data.fetch(:activated_at, nil) - self.iterate_at = data.fetch(:iterate_at, nil) - - end - - # Create a new Subscription using the current client - def new(data = {}) - Subscription.new(@client, data) - end - - # Overrides the JSON marshaller to only send the fields we want - def to_json(options) - { - "id": self.id, - "project": self.project, - "project_id": self.project_id, - "plan": self.plan, - "plan_id": self.plan_id, - "discounts": self.discounts, - "addons": self.addons, - "transactions": self.transactions, - "customer": self.customer, - "customer_id": self.customer_id, - "token": self.token, - "token_id": self.token_id, - "url": self.url, - "name": self.name, - "amount": self.amount, - "billable_amount": self.billable_amount, - "discounted_amount": self.discounted_amount, - "addons_amount": self.addons_amount, - "currency": self.currency, - "metadata": self.metadata, - "interval": self.interval, - "trial_end_at": self.trial_end_at, - "activated": self.activated, - "active": self.active, - "cancel_at": self.cancel_at, - "canceled": self.canceled, - "cancellation_reason": self.cancellation_reason, - "pending_cancellation": self.pending_cancellation, - "return_url": self.return_url, - "cancel_url": self.cancel_url, - "unpaid_state": self.unpaid_state, - "sandbox": self.sandbox, - "created_at": self.created_at, - "activated_at": self.activated_at, - "iterate_at": self.iterate_at, - }.to_json - end - - # Fills the object with data coming from the API - # Params: - # +data+:: +Hash+ of data coming from the API - def fill_with_data(data) - if data.nil? - return self - end - if data.include? "id" - self.id = data["id"] - end - if data.include? "project" - self.project = data["project"] - end - if data.include? "project_id" - self.project_id = data["project_id"] - end - if data.include? "plan" - self.plan = data["plan"] - end - if data.include? "plan_id" - self.plan_id = data["plan_id"] - end - if data.include? "discounts" - self.discounts = data["discounts"] - end - if data.include? "addons" - self.addons = data["addons"] - end - if data.include? "transactions" - self.transactions = data["transactions"] - end - if data.include? "customer" - self.customer = data["customer"] - end - if data.include? "customer_id" - self.customer_id = data["customer_id"] - end - if data.include? "token" - self.token = data["token"] - end - if data.include? "token_id" - self.token_id = data["token_id"] - end - if data.include? "url" - self.url = data["url"] - end - if data.include? "name" - self.name = data["name"] - end - if data.include? "amount" - self.amount = data["amount"] - end - if data.include? "billable_amount" - self.billable_amount = data["billable_amount"] - end - if data.include? "discounted_amount" - self.discounted_amount = data["discounted_amount"] - end - if data.include? "addons_amount" - self.addons_amount = data["addons_amount"] - end - if data.include? "currency" - self.currency = data["currency"] - end - if data.include? "metadata" - self.metadata = data["metadata"] - end - if data.include? "interval" - self.interval = data["interval"] - end - if data.include? "trial_end_at" - self.trial_end_at = data["trial_end_at"] - end - if data.include? "activated" - self.activated = data["activated"] - end - if data.include? "active" - self.active = data["active"] - end - if data.include? "cancel_at" - self.cancel_at = data["cancel_at"] - end - if data.include? "canceled" - self.canceled = data["canceled"] - end - if data.include? "cancellation_reason" - self.cancellation_reason = data["cancellation_reason"] - end - if data.include? "pending_cancellation" - self.pending_cancellation = data["pending_cancellation"] - end - if data.include? "return_url" - self.return_url = data["return_url"] - end - if data.include? "cancel_url" - self.cancel_url = data["cancel_url"] - end - if data.include? "unpaid_state" - self.unpaid_state = data["unpaid_state"] - end - if data.include? "sandbox" - self.sandbox = data["sandbox"] - end - if data.include? "created_at" - self.created_at = data["created_at"] - end - if data.include? "activated_at" - self.activated_at = data["activated_at"] - end - if data.include? "iterate_at" - self.iterate_at = data["iterate_at"] - end - - self - end - - # Prefills the object with the data passed as parameters - # Params: - # +data+:: +Hash+ of data - def prefill(data) - if data.nil? - return self - end - self.id = data.fetch(:id, self.id) - self.project = data.fetch(:project, self.project) - self.project_id = data.fetch(:project_id, self.project_id) - self.plan = data.fetch(:plan, self.plan) - self.plan_id = data.fetch(:plan_id, self.plan_id) - self.discounts = data.fetch(:discounts, self.discounts) - self.addons = data.fetch(:addons, self.addons) - self.transactions = data.fetch(:transactions, self.transactions) - self.customer = data.fetch(:customer, self.customer) - self.customer_id = data.fetch(:customer_id, self.customer_id) - self.token = data.fetch(:token, self.token) - self.token_id = data.fetch(:token_id, self.token_id) - self.url = data.fetch(:url, self.url) - self.name = data.fetch(:name, self.name) - self.amount = data.fetch(:amount, self.amount) - self.billable_amount = data.fetch(:billable_amount, self.billable_amount) - self.discounted_amount = data.fetch(:discounted_amount, self.discounted_amount) - self.addons_amount = data.fetch(:addons_amount, self.addons_amount) - self.currency = data.fetch(:currency, self.currency) - self.metadata = data.fetch(:metadata, self.metadata) - self.interval = data.fetch(:interval, self.interval) - self.trial_end_at = data.fetch(:trial_end_at, self.trial_end_at) - self.activated = data.fetch(:activated, self.activated) - self.active = data.fetch(:active, self.active) - self.cancel_at = data.fetch(:cancel_at, self.cancel_at) - self.canceled = data.fetch(:canceled, self.canceled) - self.cancellation_reason = data.fetch(:cancellation_reason, self.cancellation_reason) - self.pending_cancellation = data.fetch(:pending_cancellation, self.pending_cancellation) - self.return_url = data.fetch(:return_url, self.return_url) - self.cancel_url = data.fetch(:cancel_url, self.cancel_url) - self.unpaid_state = data.fetch(:unpaid_state, self.unpaid_state) - self.sandbox = data.fetch(:sandbox, self.sandbox) - self.created_at = data.fetch(:created_at, self.created_at) - self.activated_at = data.fetch(:activated_at, self.activated_at) - self.iterate_at = data.fetch(:iterate_at, self.iterate_at) - - self - end - - # Get the addons applied to the subscription. - # Params: - # +options+:: +Hash+ of options - def fetch_addons(options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/subscriptions/" + CGI.escape(@id) + "/addons" - data = { - - } - - response = Response.new(request.get(path, data, options)) - return_values = Array.new - - a = Array.new - body = response.body - for v in body['addons'] - tmp = Addon.new(@client) - tmp.fill_with_data(v) - a.push(tmp) - end - - return_values.push(a) - - - - return_values[0] - end - - # Find a subscription's addon by its ID. - # Params: - # +addon_id+:: ID of the addon - # +options+:: +Hash+ of options - def find_addon(addon_id, options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/subscriptions/" + CGI.escape(@id) + "/addons/" + CGI.escape(addon_id) + "" - data = { - - } - - response = Response.new(request.get(path, data, options)) - return_values = Array.new - - body = response.body - body = body.key?("addon") ? body["addon"] : nil - if !body.nil? - addon = Addon.new(@client) - return_values.push(addon.fill_with_data(body)) - end - - - return_values[0] - end - - # Delete an addon applied to a subscription. - # Params: - # +addon_id+:: ID of the addon or plan to be removed from the subscription - # +options+:: +Hash+ of options - def delete_addon(addon_id, options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/subscriptions/" + CGI.escape(@id) + "/addons/" + CGI.escape(addon_id) + "" - data = { - "prorate" => options.fetch(:prorate, nil), - "proration_date" => options.fetch(:proration_date, nil), - "preview" => options.fetch(:preview, nil) - } - - response = Response.new(request.delete(path, data, options)) - return_values = Array.new - - return_values.push(response.success) - - - return_values[0] - end - - # Get the customer owning the subscription. - # Params: - # +options+:: +Hash+ of options - def fetch_customer(options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/subscriptions/" + CGI.escape(@id) + "/customers" - data = { - - } - - response = Response.new(request.get(path, data, options)) - return_values = Array.new - - body = response.body - body = body.key?("customer") ? body["customer"] : nil - if !body.nil? - customer = Customer.new(@client) - return_values.push(customer.fill_with_data(body)) - end - - - return_values[0] - end - - # Get the discounts applied to the subscription. - # Params: - # +options+:: +Hash+ of options - def fetch_discounts(options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/subscriptions/" + CGI.escape(@id) + "/discounts" - data = { - - } - - response = Response.new(request.get(path, data, options)) - return_values = Array.new - - a = Array.new - body = response.body - for v in body['discounts'] - tmp = Discount.new(@client) - tmp.fill_with_data(v) - a.push(tmp) - end - - return_values.push(a) - - - - return_values[0] - end - - # Find a subscription's discount by its ID. - # Params: - # +discount_id+:: ID of the discount - # +options+:: +Hash+ of options - def find_discount(discount_id, options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/subscriptions/" + CGI.escape(@id) + "/discounts/" + CGI.escape(discount_id) + "" - data = { - - } - - response = Response.new(request.get(path, data, options)) - return_values = Array.new - - body = response.body - body = body.key?("discount") ? body["discount"] : nil - if !body.nil? - discount = Discount.new(@client) - return_values.push(discount.fill_with_data(body)) - end - - - return_values[0] - end - - # Delete a discount applied to a subscription. - # Params: - # +discount_id+:: ID of the discount or coupon to be removed from the subscription - # +options+:: +Hash+ of options - def delete_discount(discount_id, options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/subscriptions/" + CGI.escape(@id) + "/discounts/" + CGI.escape(discount_id) + "" - data = { - - } - - response = Response.new(request.delete(path, data, options)) - return_values = Array.new - - return_values.push(response.success) - - - return_values[0] - end - - # Get the subscriptions past transactions. - # Params: - # +options+:: +Hash+ of options - def fetch_transactions(options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/subscriptions/" + CGI.escape(@id) + "/transactions" - data = { - - } - - response = Response.new(request.get(path, data, options)) - return_values = Array.new - - a = Array.new - body = response.body - for v in body['transactions'] - tmp = Transaction.new(@client) - tmp.fill_with_data(v) - a.push(tmp) - end - - return_values.push(a) - - - - return_values[0] - end - - # Get all the subscriptions. - # Params: - # +options+:: +Hash+ of options - def all(options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/subscriptions" - data = { - - } - - response = Response.new(request.get(path, data, options)) - return_values = Array.new - - a = Array.new - body = response.body - for v in body['subscriptions'] - tmp = Subscription.new(@client) - tmp.fill_with_data(v) - a.push(tmp) - end - - return_values.push(a) - - - - return_values[0] - end - - # Create a new subscription for the given customer. - # Params: - # +options+:: +Hash+ of options - def create(options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/subscriptions" - data = { - "plan_id" => @plan_id, - "cancel_at" => @cancel_at, - "name" => @name, - "amount" => @amount, - "currency" => @currency, - "metadata" => @metadata, - "interval" => @interval, - "trial_end_at" => @trial_end_at, - "customer_id" => @customer_id, - "return_url" => @return_url, - "cancel_url" => @cancel_url, - "source" => options.fetch(:source, nil), - "coupon_id" => options.fetch(:coupon_id, nil) - } - - response = Response.new(request.post(path, data, options)) - return_values = Array.new - - body = response.body - body = body.key?("subscription") ? body["subscription"] : nil - - - return_values.push(self.fill_with_data(body)) - - - - return_values[0] - end - - # Find a subscription by its ID. - # Params: - # +subscription_id+:: ID of the subscription - # +options+:: +Hash+ of options - def find(subscription_id, options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/subscriptions/" + CGI.escape(subscription_id) + "" - data = { - - } - - response = Response.new(request.get(path, data, options)) - return_values = Array.new - - body = response.body - body = body.key?("subscription") ? body["subscription"] : nil - - - obj = Subscription.new(@client) - return_values.push(obj.fill_with_data(body)) - - - - return_values[0] - end - - # Save the updated subscription attributes. - # Params: - # +options+:: +Hash+ of options - def save(options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/subscriptions/" + CGI.escape(@id) + "" - data = { - "plan_id" => @plan_id, - "name" => @name, - "amount" => @amount, - "interval" => @interval, - "trial_end_at" => @trial_end_at, - "metadata" => @metadata, - "coupon_id" => options.fetch(:coupon_id, nil), - "source" => options.fetch(:source, nil), - "prorate" => options.fetch(:prorate, nil), - "proration_date" => options.fetch(:proration_date, nil), - "preview" => options.fetch(:preview, nil) - } - - response = Response.new(request.put(path, data, options)) - return_values = Array.new - - body = response.body - body = body.key?("subscription") ? body["subscription"] : nil - - - return_values.push(self.fill_with_data(body)) - - - - return_values[0] - end - - # Cancel a subscription. The reason may be provided as well. - # Params: - # +options+:: +Hash+ of options - def cancel(options = {}) - self.prefill(options) - - request = Request.new(@client) - path = "/subscriptions/" + CGI.escape(@id) + "" - data = { - "cancel_at" => @cancel_at, - "cancellation_reason" => @cancellation_reason, - "cancel_at_end" => options.fetch(:cancel_at_end, nil) - } - - response = Response.new(request.delete(path, data, options)) - return_values = Array.new - - body = response.body - body = body.key?("subscription") ? body["subscription"] : nil - - - return_values.push(self.fill_with_data(body)) - - - - return_values[0] - end - - - end -end diff --git a/lib/processout/token.rb b/lib/processout/token.rb index ae8b7cb..c4b604f 100755 --- a/lib/processout/token.rb +++ b/lib/processout/token.rb @@ -31,6 +31,7 @@ class Token attr_reader :verification_status attr_reader :can_get_balance attr_reader :webhook_url + attr_reader :provision_network_token def id=(val) @@ -173,6 +174,10 @@ def webhook_url=(val) @webhook_url = val end + def provision_network_token=(val) + @provision_network_token = val + end + # Initializes the Token object # Params: @@ -204,6 +209,7 @@ def initialize(client, data = {}) self.verification_status = data.fetch(:verification_status, nil) self.can_get_balance = data.fetch(:can_get_balance, nil) self.webhook_url = data.fetch(:webhook_url, nil) + self.provision_network_token = data.fetch(:provision_network_token, nil) end @@ -238,6 +244,7 @@ def to_json(options) "verification_status": self.verification_status, "can_get_balance": self.can_get_balance, "webhook_url": self.webhook_url, + "provision_network_token": self.provision_network_token, }.to_json end @@ -317,6 +324,9 @@ def fill_with_data(data) if data.include? "webhook_url" self.webhook_url = data["webhook_url"] end + if data.include? "provision_network_token" + self.provision_network_token = data["provision_network_token"] + end self end @@ -351,6 +361,7 @@ def prefill(data) self.verification_status = data.fetch(:verification_status, self.verification_status) self.can_get_balance = data.fetch(:can_get_balance, self.can_get_balance) self.webhook_url = data.fetch(:webhook_url, self.webhook_url) + self.provision_network_token = data.fetch(:provision_network_token, self.provision_network_token) self end @@ -440,7 +451,8 @@ def create(options = {}) "set_default" => options.fetch(:set_default, nil), "verify_statement_descriptor" => options.fetch(:verify_statement_descriptor, nil), "invoice_return_url" => options.fetch(:invoice_return_url, nil), - "summary" => options.fetch(:summary, nil) + "summary" => options.fetch(:summary, nil), + "provision_network_token" => options.fetch(:provision_network_token, nil) } response = Response.new(request.post(path, data, options)) @@ -480,7 +492,8 @@ def save(options = {}) "set_default" => options.fetch(:set_default, nil), "verify_statement_descriptor" => options.fetch(:verify_statement_descriptor, nil), "invoice_return_url" => options.fetch(:invoice_return_url, nil), - "gateway_configuration_id" => options.fetch(:gateway_configuration_id, nil) + "gateway_configuration_id" => options.fetch(:gateway_configuration_id, nil), + "provision_network_token" => options.fetch(:provision_network_token, nil) } response = Response.new(request.put(path, data, options)) diff --git a/lib/processout/transaction.rb b/lib/processout/transaction.rb index 31e11d6..909a565 100755 --- a/lib/processout/transaction.rb +++ b/lib/processout/transaction.rb @@ -15,8 +15,6 @@ class Transaction attr_reader :invoice_id attr_reader :customer attr_reader :customer_id - attr_reader :subscription - attr_reader :subscription_id attr_reader :token attr_reader :token_id attr_reader :card @@ -75,6 +73,7 @@ class Transaction attr_reader :eci attr_reader :native_apm attr_reader :external_details + attr_reader :origin def id=(val) @@ -141,26 +140,6 @@ def customer_id=(val) @customer_id = val end - def subscription=(val) - if val.nil? - @subscription = val - return - end - - if val.instance_of? Subscription - @subscription = val - else - obj = Subscription.new(@client) - obj.fill_with_data(val) - @subscription = obj - end - - end - - def subscription_id=(val) - @subscription_id = val - end - def token=(val) if val.nil? @token = val @@ -498,6 +477,10 @@ def external_details=(val) end + def origin=(val) + @origin = val + end + # Initializes the Transaction object # Params: @@ -513,8 +496,6 @@ def initialize(client, data = {}) self.invoice_id = data.fetch(:invoice_id, nil) self.customer = data.fetch(:customer, nil) self.customer_id = data.fetch(:customer_id, nil) - self.subscription = data.fetch(:subscription, nil) - self.subscription_id = data.fetch(:subscription_id, nil) self.token = data.fetch(:token, nil) self.token_id = data.fetch(:token_id, nil) self.card = data.fetch(:card, nil) @@ -573,6 +554,7 @@ def initialize(client, data = {}) self.eci = data.fetch(:eci, nil) self.native_apm = data.fetch(:native_apm, nil) self.external_details = data.fetch(:external_details, nil) + self.origin = data.fetch(:origin, nil) end @@ -591,8 +573,6 @@ def to_json(options) "invoice_id": self.invoice_id, "customer": self.customer, "customer_id": self.customer_id, - "subscription": self.subscription, - "subscription_id": self.subscription_id, "token": self.token, "token_id": self.token_id, "card": self.card, @@ -651,6 +631,7 @@ def to_json(options) "eci": self.eci, "native_apm": self.native_apm, "external_details": self.external_details, + "origin": self.origin, }.to_json end @@ -682,12 +663,6 @@ def fill_with_data(data) if data.include? "customer_id" self.customer_id = data["customer_id"] end - if data.include? "subscription" - self.subscription = data["subscription"] - end - if data.include? "subscription_id" - self.subscription_id = data["subscription_id"] - end if data.include? "token" self.token = data["token"] end @@ -862,6 +837,9 @@ def fill_with_data(data) if data.include? "external_details" self.external_details = data["external_details"] end + if data.include? "origin" + self.origin = data["origin"] + end self end @@ -880,8 +858,6 @@ def prefill(data) self.invoice_id = data.fetch(:invoice_id, self.invoice_id) self.customer = data.fetch(:customer, self.customer) self.customer_id = data.fetch(:customer_id, self.customer_id) - self.subscription = data.fetch(:subscription, self.subscription) - 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.card = data.fetch(:card, self.card) @@ -940,6 +916,7 @@ def prefill(data) self.eci = data.fetch(:eci, self.eci) self.native_apm = data.fetch(:native_apm, self.native_apm) self.external_details = data.fetch(:external_details, self.external_details) + self.origin = data.fetch(:origin, self.origin) self end diff --git a/lib/processout/transaction_operation.rb b/lib/processout/transaction_operation.rb index 8afb177..6d2fea2 100755 --- a/lib/processout/transaction_operation.rb +++ b/lib/processout/transaction_operation.rb @@ -35,6 +35,7 @@ class TransactionOperation attr_reader :scheme_id attr_reader :processed_with_network_token attr_reader :payment_type + attr_reader :capture_type attr_reader :metadata attr_reader :gateway_fee attr_reader :created_at @@ -232,6 +233,10 @@ def payment_type=(val) @payment_type = val end + def capture_type=(val) + @capture_type = val + end + def metadata=(val) @metadata = val end @@ -279,6 +284,7 @@ def initialize(client, data = {}) self.scheme_id = data.fetch(:scheme_id, nil) self.processed_with_network_token = data.fetch(:processed_with_network_token, nil) self.payment_type = data.fetch(:payment_type, nil) + self.capture_type = data.fetch(:capture_type, nil) self.metadata = data.fetch(:metadata, nil) self.gateway_fee = data.fetch(:gateway_fee, nil) self.created_at = data.fetch(:created_at, nil) @@ -320,6 +326,7 @@ def to_json(options) "scheme_id": self.scheme_id, "processed_with_network_token": self.processed_with_network_token, "payment_type": self.payment_type, + "capture_type": self.capture_type, "metadata": self.metadata, "gateway_fee": self.gateway_fee, "created_at": self.created_at, @@ -414,6 +421,9 @@ def fill_with_data(data) if data.include? "payment_type" self.payment_type = data["payment_type"] end + if data.include? "capture_type" + self.capture_type = data["capture_type"] + end if data.include? "metadata" self.metadata = data["metadata"] end @@ -461,6 +471,7 @@ def prefill(data) self.scheme_id = data.fetch(:scheme_id, self.scheme_id) self.processed_with_network_token = data.fetch(:processed_with_network_token, self.processed_with_network_token) self.payment_type = data.fetch(:payment_type, self.payment_type) + self.capture_type = data.fetch(:capture_type, self.capture_type) self.metadata = data.fetch(:metadata, self.metadata) self.gateway_fee = data.fetch(:gateway_fee, self.gateway_fee) self.created_at = data.fetch(:created_at, self.created_at) diff --git a/lib/processout/unsupported_feature_bypass.rb b/lib/processout/unsupported_feature_bypass.rb index 1ddf8c2..ce28735 100755 --- a/lib/processout/unsupported_feature_bypass.rb +++ b/lib/processout/unsupported_feature_bypass.rb @@ -9,12 +9,17 @@ module ProcessOut class UnsupportedFeatureBypass attr_reader :incremental_authorization + attr_reader :split_payments def incremental_authorization=(val) @incremental_authorization = val end + def split_payments=(val) + @split_payments = val + end + # Initializes the UnsupportedFeatureBypass object # Params: @@ -24,6 +29,7 @@ def initialize(client, data = {}) @client = client self.incremental_authorization = data.fetch(:incremental_authorization, nil) + self.split_payments = data.fetch(:split_payments, nil) end @@ -36,6 +42,7 @@ def new(data = {}) def to_json(options) { "incremental_authorization": self.incremental_authorization, + "split_payments": self.split_payments, }.to_json end @@ -49,6 +56,9 @@ def fill_with_data(data) if data.include? "incremental_authorization" self.incremental_authorization = data["incremental_authorization"] end + if data.include? "split_payments" + self.split_payments = data["split_payments"] + end self end @@ -61,6 +71,7 @@ def prefill(data) return self end self.incremental_authorization = data.fetch(:incremental_authorization, self.incremental_authorization) + self.split_payments = data.fetch(:split_payments, self.split_payments) self end diff --git a/lib/processout/version.rb b/lib/processout/version.rb index c7f2629..67dce35 100644 --- a/lib/processout/version.rb +++ b/lib/processout/version.rb @@ -1,3 +1,3 @@ module ProcessOut - VERSION = "4.0.0" + VERSION = "6.0.0" end diff --git a/spec/processout_spec.rb b/spec/processout_spec.rb index 5af3efd..3d36ce5 100644 --- a/spec/processout_spec.rb +++ b/spec/processout_spec.rb @@ -6,7 +6,7 @@ end it "creates and fetches an invoice" do - client = ProcessOut::Client.new("test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x", + client = ProcessOut::Client.new("test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x", "key_sandbox_mah31RDFqcDxmaS7MvhDbJfDJvjtsFTB") invoice = client.invoice.new( @@ -20,10 +20,10 @@ expect(invoice2.id).to eq(invoice.id) end - it "captures an invoice and expands the gateway configuration" do - client = ProcessOut::Client.new("test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x", + it "captures an invoice and expands the gateway configuration", skip: "Sandbox gateway does not support capturing invoices with gateway requests" do + client = ProcessOut::Client.new("test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x", "key_sandbox_mah31RDFqcDxmaS7MvhDbJfDJvjtsFTB") - + invoice = client.invoice.new( name: "Test invoice", amount: "9.99", @@ -31,7 +31,7 @@ ).create gr = ProcessOut::GatewayRequest.new("gway_conf_44ae90db0a62f819a404ef6a8ff994ca", { - method: "POST", url: "https://processout.com?token=test-valid", body: "", + method: "POST", url: "https://processout.com?token=test-valid", body: "", headers: { "Content-Type" => "application/json" } @@ -46,9 +46,9 @@ end it "creates and deletes a customer" do - client = ProcessOut::Client.new("test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x", + client = ProcessOut::Client.new("test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x", "key_sandbox_mah31RDFqcDxmaS7MvhDbJfDJvjtsFTB") - + customer = client.customer.create expect(customer.id).not_to be_empty @@ -56,35 +56,14 @@ end it "fetches the customers" do - client = ProcessOut::Client.new("test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x", + client = ProcessOut::Client.new("test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x", "key_sandbox_mah31RDFqcDxmaS7MvhDbJfDJvjtsFTB") client.customer.all end - it "creates a subscription for a customer and updates its metadata" do - client = ProcessOut::Client.new("test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x", - "key_sandbox_mah31RDFqcDxmaS7MvhDbJfDJvjtsFTB") - - customer = client.customer.create - expect(customer.id).not_to be_empty - - sub = client.subscription.new( - customer_id: customer.id, - amount: "9.99", - currency: "USD", - interval: "1d", - name: "great subscription" - ).create() - expect(sub.id).not_to be_empty - - sub.save( - metadata: {test: "yeah"} - ) - end - it "expands a customer project" do - client = ProcessOut::Client.new("test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x", + client = ProcessOut::Client.new("test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x", "key_sandbox_mah31RDFqcDxmaS7MvhDbJfDJvjtsFTB") customer = client.customer.create({expand: ["project"]}) @@ -92,7 +71,7 @@ end it "errors when a customer is not found" do - client = ProcessOut::Client.new("test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x", + client = ProcessOut::Client.new("test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x", "key_sandbox_mah31RDFqcDxmaS7MvhDbJfDJvjtsFTB") begin