lib/active_merchant/billing/gateways/mercado_pago.rb in activemerchant-1.108.0 vs lib/active_merchant/billing/gateways/mercado_pago.rb in activemerchant-1.109.0

- old
+ new

@@ -1,12 +1,12 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: class MercadoPagoGateway < Gateway self.live_url = self.test_url = 'https://api.mercadopago.com/v1' - self.supported_countries = ['AR', 'BR', 'CL', 'CO', 'MX', 'PE', 'UY'] - self.supported_cardtypes = [:visa, :master, :american_express, :elo, :cabal, :naranja] + self.supported_countries = %w[AR BR CL CO MX PE UY] + self.supported_cardtypes = %i[visa master american_express elo cabal naranja] self.homepage_url = 'https://www.mercadopago.com/' self.display_name = 'Mercado Pago' self.money_format = :dollars @@ -31,11 +31,11 @@ end end def capture(money, authorization, options={}) post = {} - authorization, _ = authorization.split('|') + authorization, = authorization.split('|') post[:capture] = true post[:transaction_amount] = amount(money).to_f commit('capture', "payments/#{authorization}", post) end @@ -45,11 +45,11 @@ post[:amount] = amount(money).to_f if original_amount && original_amount.to_f > amount(money).to_f commit('refund', "payments/#{authorization}/refunds", post) end def void(authorization, options={}) - authorization, _ = authorization.split('|') + authorization, = authorization.split('|') post = { status: 'cancelled' } commit('void', "payments/#{authorization}", post) end def verify(credit_card, options={}) @@ -96,10 +96,11 @@ add_customer_data(post, payment, options) add_address(post, options) add_processing_mode(post, options) add_net_amount(post, options) add_taxes(post, options) + add_notification_url(post, options) post[:binary_mode] = (options[:binary_mode].nil? ? true : options[:binary_mode]) post end def authorize_request(money, payment, options = {}) @@ -201,10 +202,14 @@ def add_net_amount(post, options) post[:net_amount] = Float(options[:net_amount]) if options[:net_amount] end + def add_notification_url(post, options) + post[:notification_url] = options[:notification_url] if options[:notification_url] + end + def add_taxes(post, options) return unless (tax_object = options[:taxes]) if tax_object.is_a?(Array) post[:taxes] = process_taxes_array(tax_object) @@ -249,11 +254,11 @@ 'message' => "A non-JSON response was received from Mercado Pago where one was expected. The raw response was:\n\n#{body}" } end def commit(action, path, parameters) - if ['capture', 'void'].include?(action) + if %w[capture void].include?(action) response = parse(ssl_request(:put, url(path), post_data(parameters), headers)) else response = parse(ssl_post(url(path), post_data(parameters), headers(parameters))) end @@ -269,10 +274,10 @@ def success_from(action, response) if action == 'refund' response['status'] != 404 && response['error'].nil? else - ['active', 'approved', 'authorized', 'cancelled', 'in_process'].include?(response['status']) + %w[active approved authorized cancelled in_process].include?(response['status']) end end def message_from(response) (response['status_detail']) || (response['message'])