lib/active_merchant/billing/gateways/mercado_pago.rb in activemerchant-1.86.0 vs lib/active_merchant/billing/gateways/mercado_pago.rb in activemerchant-1.87.0
- old
+ new
@@ -8,35 +8,28 @@
self.homepage_url = 'https://www.mercadopago.com/'
self.display_name = 'Mercado Pago'
self.money_format = :dollars
- CARD_BRAND = {
- 'american_express' => 'amex',
- 'diners_club' => 'diners'
- }
-
def initialize(options={})
requires!(options, :access_token)
super
end
def purchase(money, payment, options={})
MultiResponse.run do |r|
r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) }
- options.merge!(card_brand: (CARD_BRAND[payment.brand] || payment.brand))
- options.merge!(card_token: r.authorization.split('|').first)
- r.process { commit('purchase', 'payments', purchase_request(money, payment, options) ) }
+ options[:card_token] = r.authorization.split('|').first
+ r.process { commit('purchase', 'payments', purchase_request(money, payment, options)) }
end
end
def authorize(money, payment, options={})
MultiResponse.run do |r|
r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) }
- options.merge!(card_brand: (CARD_BRAND[payment.brand] || payment.brand))
- options.merge!(card_token: r.authorization.split('|').first)
- r.process { commit('authorize', 'payments', authorize_request(money, payment, options) ) }
+ options[:card_token] = r.authorization.split('|').first
+ r.process { commit('authorize', 'payments', authorize_request(money, payment, options)) }
end
end
def capture(money, authorization, options={})
post = {}
@@ -106,11 +99,11 @@
post
end
def authorize_request(money, payment, options = {})
post = purchase_request(money, payment, options)
- post.merge!(capture: false)
+ post[:capture] = false
post
end
def add_additional_data(post, options)
post[:sponsor_id] = options[:sponsor_id]
@@ -179,10 +172,11 @@
post[:external_reference] = options[:order_id] || SecureRandom.hex(16)
end
def add_payment(post, options)
post[:token] = options[:card_token]
- post[:payment_method_id] = options[:card_brand]
+ post[:issuer_id] = options[:issuer_id] if options[:issuer_id]
+ post[:payment_method_id] = options[:payment_method_id] if options[:payment_method_id]
end
def parse(body)
JSON.parse(body)
rescue JSON::ParserError