lib/active_merchant/billing/gateways/openpay.rb in activemerchant-1.83.0 vs lib/active_merchant/billing/gateways/openpay.rb in activemerchant-1.84.0
- old
+ new
@@ -3,11 +3,11 @@
class OpenpayGateway < Gateway
self.live_url = 'https://api.openpay.mx/v1/'
self.test_url = 'https://sandbox-api.openpay.mx/v1/'
self.supported_countries = ['MX']
- self.supported_cardtypes = [:visa, :master, :american_express]
+ self.supported_cardtypes = [:visa, :master, :american_express, :carnet]
self.homepage_url = 'http://www.openpay.mx/'
self.display_name = 'Openpay'
self.default_currency = 'MXN'
# Instantiate a instance of OpenpayGateway by passing through your
@@ -102,10 +102,11 @@
gsub(%r((cvv2\\?":\\?")\d+[^"\\]*)i, '\1[FILTERED]').
gsub(%r((cvv2\\?":)null), '\1[BLANK]').
gsub(%r((cvv2\\?":\\?")\\?"), '\1[BLANK]"').
gsub(%r((cvv2\\?":\\?")\s+), '\1[BLANK]')
end
+
private
def create_post_for_auth_or_purchase(money, creditcard, options)
post = {}
post[:amount] = amount(money)
@@ -124,12 +125,12 @@
if creditcard.kind_of?(String)
post[:source_id] = creditcard
elsif creditcard.respond_to?(:number)
card = {
card_number: creditcard.number,
- expiration_month: "#{sprintf("%02d", creditcard.month)}",
- expiration_year: "#{"#{creditcard.year}"[-2, 2]}",
+ expiration_month: sprintf('%02d', creditcard.month),
+ expiration_year: creditcard.year.to_s[-2, 2],
cvv2: creditcard.verification_value,
holder_name: creditcard.name
}
add_address(card, options)
add_customer_data(post, creditcard, options)
@@ -206,14 +207,12 @@
def error?(response)
response.key?('error_code')
end
def response_error(raw_response)
- begin
- parse(raw_response)
- rescue JSON::ParserError
- json_error(raw_response)
- end
+ parse(raw_response)
+ rescue JSON::ParserError
+ json_error(raw_response)
end
def json_error(raw_response)
msg = 'Invalid response received from the Openpay API. Please contact soporte@openpay.mx if you continue to receive this message.'
msg += " (The raw response returned by the API was #{raw_response.inspect})"