Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: chargify/active_merchant
...
head fork: chargify/active_merchant
  • 4 commits
  • 13 files changed
  • 0 commit comments
  • 1 contributor
View
1  CHANGELOG
@@ -1,5 +1,6 @@
= ActiveMerchant CHANGELOG
+* Add NumericCurrencyCodes module for looking up ISO4217 numeric currency codes when needed. [cody]
* Use basic SkipJack host for all non-authorization transactions. Fix status method [cody]
* Strip non alpha numeric chars out of MerchantWare order number [cody]
* Parse complete response of Authorize.net CIM gateway [Patrick Joyce]
View
2  lib/active_merchant.rb
@@ -49,6 +49,7 @@
require 'active_merchant/lib/post_data'
require 'active_merchant/lib/requires_parameters'
require 'active_merchant/lib/country'
+require 'active_merchant/lib/numeric_currency_code'
require 'active_merchant/billing/avs_result'
require 'active_merchant/billing/cvv_result'
@@ -58,3 +59,4 @@
require 'active_merchant/billing/base'
require 'active_merchant/billing/gateways'
require 'active_merchant/billing/integrations'
+require 'active_merchant/billing/buyer_auth_gateways'
View
52 lib/active_merchant/billing/buyer_auth_gateway.rb
@@ -0,0 +1,52 @@
+require 'net/http'
+require 'net/https'
+require 'active_merchant/billing/response'
+
+module ActiveMerchant #:nodoc:
+ module Billing #:nodoc:
+ class BuyerAuthGateway
+ include PostsData
+ include RequiresParameters
+ include Utils
+
+ # The format of the amounts used by the gateway
+ # :dollars => '12.50'
+ # :cents => '1250'
+ class_inheritable_accessor :money_format
+ self.money_format = :dollars
+
+ # The default currency for the transactions if no currency is provided
+ class_inheritable_accessor :default_currency
+
+ def initialize(options = {})
+ end
+
+ # Are we running in test mode?
+ def test?
+ Base.gateway_mode == :test
+ end
+
+ private
+
+ def amount(money)
+ return nil if money.nil?
+ cents = money.respond_to?(:cents) ? money.cents : money
+
+ if money.is_a?(String) or cents.to_i < 0
+ raise ArgumentError, 'money amount must be either a Money object or a positive integer in cents.'
+ end
+
+ if self.money_format == :cents
+ cents.to_s
+ else
+ sprintf("%.2f", cents.to_f / 100)
+ end
+ end
+
+ def currency(money)
+ money.respond_to?(:currency) ? money.currency : self.default_currency
+ end
+
+ end
+ end
+end
View
3  lib/active_merchant/billing/buyer_auth_gateways.rb
@@ -0,0 +1,3 @@
+require 'active_merchant/billing/buyer_auth_gateway'
+
+Dir[File.dirname(__FILE__) + '/buyer_auth_gateways/*.rb'].each{ |g| require g }
View
115 lib/active_merchant/billing/buyer_auth_gateways/centinel.rb
@@ -0,0 +1,115 @@
+require 'builder'
+require 'rexml/document'
+require 'cgi'
+
+module ActiveMerchant #:nodoc:
+ module Billing #:nodoc:
+ class CentinelBuyerAuthGateway < BuyerAuthGateway
+ MESSAGE_VERSION = "1.7"
+ TRANSACTION_TYPE = "C"
+
+ LIVE_URL = ""
+ TEST_URL = "https://centineltest.cardinalcommerce.com/maps/txns.asp"
+
+ SUCCESS = "0"
+ SUCCESS_MSG = "The request was successful"
+
+ self.money_format = :cents
+
+ CURRENCIES = {
+ "USD" => "840",
+ "EUR" => "978",
+ "JPY" => "392",
+ "CAD" => "124",
+ "GBP" => "826"
+ }
+
+ def initialize(options = {})
+ requires!(options, :login, :password, :processor)
+ @options = options
+ super
+ end
+
+ def verify_enrollment(amount, credit_card, options = {})
+ requires!(options, :currency, :order_id)
+ commit verify_enrollment_request(amount, credit_card, options)
+ end
+
+ def validate_authentication(pa_res, options = {})
+ requires!(options, :transaction_id)
+ commit validate_authentication_request(pa_res, options[:transaction_id])
+ end
+
+ private
+
+ def commit(xml)
+ response = parse(ssl_post(test? ? TEST_URL : LIVE_URL, "cmpi_msg=#{CGI.escape(xml)}"))
+
+ Response.new(successful?(response), message_from(response), response,
+ :test => test?,
+ :authorization => response["TransactionId"]
+ )
+ end
+
+ def message_from(response)
+ successful?(response) ? SUCCESS_MSG : response["ErrorDesc"]
+ end
+
+ def successful?(response)
+ response["ErrorNo"] == SUCCESS
+ end
+
+ def verify_enrollment_request(money, credit_card, options)
+ xml_request("cmpi_lookup") do |xml|
+ xml.tag! "Amount", amount(money)
+ xml.tag! "CurrencyCode", ActiveMerchant::NumericCurrencyCode.lookup(options[:currency])
+ xml.tag! "OrderNumber", options[:order_id].to_s.slice(0, 50)
+ xml.tag! "CardNumber", credit_card.number
+ xml.tag! "CardExpMonth", format_expiry_month(credit_card.month)
+ xml.tag! "CardExpYear", format_expiry_month(credit_card.year)
+ end
+ end
+
+ def validate_authentication_request(pa_res, reference)
+ xml_request("cmpi_authenticate") do |xml|
+ xml.tag! "TransactionId", reference
+ xml.tag! "PAResPayload", pa_res
+ end
+ end
+
+ def xml_request(action)
+ xml = Builder::XmlMarkup.new
+ xml.tag! "CardinalMPI" do
+ xml.tag! "Version", MESSAGE_VERSION
+ xml.tag! "MsgType", action
+ xml.tag! "ProcessorId", @options[:processor]
+ xml.tag! "MerchantId", @options[:login]
+ xml.tag! "TransactionPwd", @options[:password]
+ xml.tag! "TransactionType", TRANSACTION_TYPE
+
+ yield xml
+ end
+ end
+
+ def parse(data)
+ response = {}
+
+ xml = REXML::Document.new(data)
+
+ xml.root.elements.to_a.each do |element|
+ response[element.name] = element.text
+ end
+
+ response
+ end
+
+ def format_expiry_month(month)
+ sprintf("%.2i", month)
+ end
+
+ def format_expiry_year(year)
+ sprintf("%.4i", year)
+ end
+ end
+ end
+end
View
51 lib/active_merchant/billing/gateways/payflow.rb
@@ -12,16 +12,24 @@ class PayflowGateway < Gateway
self.supported_cardtypes = [:visa, :master, :american_express, :jcb, :discover, :diners_club]
self.homepage_url = 'https://www.paypal.com/cgi-bin/webscr?cmd=_payflow-pro-overview-outside'
self.display_name = 'PayPal Payflow Pro'
+
+ def validate_authentication(pares)
+ request = build_validate_authentication_request(:validate_authentication, pares)
+ commit(request)
+ end
+ def verify_enrollment(money, credit_card, options = {})
+ request = build_credit_card_request(:verify_enrollment, money, credit_card, options)
+ commit(request)
+ end
+
def authorize(money, credit_card_or_reference, options = {})
request = build_sale_or_authorization_request(:authorization, money, credit_card_or_reference, options)
-
commit(request)
end
def purchase(money, credit_card_or_reference, options = {})
request = build_sale_or_authorization_request(:purchase, money, credit_card_or_reference, options)
-
commit(request)
end
@@ -72,6 +80,7 @@ def express
end
private
+
def build_sale_or_authorization_request(action, money, credit_card_or_reference, options)
if credit_card_or_reference.is_a?(String)
build_reference_sale_or_authorization_request(action, money, credit_card_or_reference, options)
@@ -105,7 +114,7 @@ def build_credit_card_request(action, money, credit_card, options)
xml.tag! 'CustIP', options[:ip] unless options[:ip].blank?
xml.tag! 'InvNum', options[:order_id].to_s.gsub(/[^\w.]/, '') unless options[:order_id].blank?
xml.tag! 'Description', options[:description] unless options[:description].blank?
-
+
billing_address = options[:billing_address] || options[:address]
add_address(xml, 'BillTo', billing_address, options) if billing_address
add_address(xml, 'ShipTo', options[:shipping_address], options) if options[:shipping_address]
@@ -114,14 +123,22 @@ def build_credit_card_request(action, money, credit_card, options)
end
xml.tag! 'Tender' do
- add_credit_card(xml, credit_card)
+ add_credit_card(xml, credit_card, options)
end
- end
+ end
+ end
+ xml.target!
+ end
+
+ def build_validate_authentication_request(action, pa_res)
+ xml = Builder::XmlMarkup.new
+ xml.tag! TRANSACTIONS[action] do
+ xml.tag! "PARes", pa_res
end
xml.target!
end
- def add_credit_card(xml, credit_card)
+ def add_credit_card(xml, credit_card, options = {})
xml.tag! 'Card' do
xml.tag! 'CardType', credit_card_type(credit_card)
xml.tag! 'CardNum', credit_card.number
@@ -134,6 +151,18 @@ def add_credit_card(xml, credit_card)
xml.tag!('ExtData', 'Name' => 'CardIssue', 'Value' => format(credit_card.issue_number, :two_digits)) unless credit_card.issue_number.blank?
end
xml.tag! 'ExtData', 'Name' => 'LASTNAME', 'Value' => credit_card.last_name
+
+ if results = options[:buyer_auth_result]
+ xml.tag! "BuyerAuthResult" do
+ xml.tag! "Status", results[:status]
+ xml.tag! "AuthenticationId", results[:authentication_id]
+ xml.tag! "ECI", results[:eci]
+
+ # Only returned when the status is Y
+ xml.tag! "CAVV", results[:cavv] if results[:cavv]
+ xml.tag! "XID", results[:xid] if results[:xid]
+ end
+ end
end
end
@@ -146,14 +175,14 @@ def credit_card_type(credit_card)
def expdate(creditcard)
year = sprintf("%.4i", creditcard.year)
month = sprintf("%.2i", creditcard.month)
-
+
"#{year}#{month}"
end
def startdate(creditcard)
year = format(creditcard.start_year, :two_digits)
month = format(creditcard.start_month, :two_digits)
-
+
"#{month}#{year}"
end
@@ -161,7 +190,7 @@ def build_recurring_request(action, money, options)
unless RECURRING_ACTIONS.include?(action)
raise StandardError, "Invalid Recurring Profile Action: #{action}"
end
-
+
xml = Builder::XmlMarkup.new
xml.tag! 'RecurringProfiles' do
xml.tag! 'RecurringProfile' do
@@ -204,7 +233,7 @@ def build_recurring_request(action, money, options)
end
end
end
-
+
def get_pay_period(options)
requires!(options, [:periodicity, :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily, :semimonthly, :quadweekly, :quarterly, :semiyearly])
case options[:periodicity]
@@ -218,7 +247,7 @@ def get_pay_period(options)
when :yearly then 'Yearly'
end
end
-
+
def format_rp_date(time)
case time
when Time, Date then time.strftime("%m%d%Y")
View
4 lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb
@@ -43,7 +43,9 @@ def self.included(base)
:authorization => "Authorization",
:capture => "Capture",
:void => "Void",
- :credit => "Credit"
+ :credit => "Credit" ,
+ :verify_enrollment => "VerifyEnrollment",
+ :validate_authentication => "ValidateAuthentication"
}
CVV_CODE = {
View
190 lib/active_merchant/lib/numeric_currency_code.rb
@@ -0,0 +1,190 @@
+module ActiveMerchant
+ module NumericCurrencyCode
+ def self.lookup(code)
+ CODES[code.to_s.upcase]
+ end
+
+ CODES = {
+ "XPT"=>"962",
+ "SAR"=>"682",
+ "RUB"=>"643",
+ "NIO"=>"558",
+ "LAK"=>"418",
+ "NOK"=>"578",
+ "USD"=>"840",
+ "XCD"=>"951",
+ "OMR"=>"512",
+ "AMD"=>"051",
+ "CDF"=>"976",
+ "KPW"=>"408",
+ "CNY"=>"156",
+ "KES"=>"404",
+ "PLN"=>"985",
+ "KHR"=>"116",
+ "MVR"=>"462",
+ "GTQ"=>"320",
+ "CLP"=>"152",
+ "INR"=>"356",
+ "BZD"=>"084",
+ "MYR"=>"458",
+ "GWP"=>"624",
+ "HKD"=>"344",
+ "SEK"=>"752",
+ "COP"=>"170",
+ "DKK"=>"208",
+ "BYR"=>"974",
+ "LYD"=>"434",
+ "UYI"=>"940",
+ "RON"=>"946",
+ "DZD"=>"012",
+ "BIF"=>"108",
+ "ARS"=>"032",
+ "GIP"=>"292",
+ "BOB"=>"068",
+ "USN"=>"997",
+ "AED"=>"784",
+ "STD"=>"678",
+ "PGK"=>"598",
+ "NGN"=>"566",
+ "XOF"=>"952",
+ "ERN"=>"232",
+ "MWK"=>"454",
+ "CUP"=>"192",
+ "GMD"=>"270",
+ "ZWL"=>"932",
+ "TZS"=>"834",
+ "CVE"=>"132",
+ "COU"=>"970",
+ "BTN"=>"064",
+ "UGX"=>"800",
+ "SYP"=>"760",
+ "MNT"=>"496",
+ "MAD"=>"504",
+ "LSL"=>"426",
+ "XAF"=>"950",
+ "XTS"=>"963",
+ "XAG"=>"961",
+ "TOP"=>"776",
+ "RSD"=>"941",
+ "SHP"=>"654",
+ "HTG"=>"332",
+ "MGA"=>"969",
+ "USS"=>"998",
+ "MZN"=>"943",
+ "LVL"=>"428",
+ "FKP"=>"238",
+ "CHE"=>"947",
+ "BWP"=>"072",
+ "HNL"=>"340",
+ "EUR"=>"978",
+ "PYG"=>"600",
+ "EGP"=>"818",
+ "CHF"=>"756",
+ "ILS"=>"376",
+ "LBP"=>"422",
+ "ANG"=>"532",
+ "KZT"=>"398",
+ "WST"=>"882",
+ "GYD"=>"328",
+ "THB"=>"764",
+ "NPR"=>"524",
+ "KMF"=>"174",
+ "IRR"=>"364",
+ "XPD"=>"964",
+ "XBA"=>"955",
+ "UYU"=>"858",
+ "SRD"=>"968",
+ "JPY"=>"392",
+ "BRL"=>"986",
+ "XBB"=>"956",
+ "SZL"=>"748",
+ "MOP"=>"446",
+ "BMD"=>"060",
+ "XBC"=>"957",
+ "ETB"=>"230",
+ "JOD"=>"400",
+ "IDR"=>"360",
+ "EEK"=>"233",
+ "MDL"=>"498",
+ "XPF"=>"953",
+ "MRO"=>"478",
+ "XBD"=>"958",
+ "YER"=>"886",
+ "PEN"=>"604",
+ "BAM"=>"977",
+ "AWG"=>"533",
+ "NZD"=>"554",
+ "VEF"=>"937",
+ "TRY"=>"949",
+ "SLL"=>"694",
+ "KYD"=>"136",
+ "AOA"=>"973",
+ "TND"=>"788",
+ "TJS"=>"972",
+ "LKR"=>"144",
+ "SGD"=>"702",
+ "SCR"=>"690",
+ "MXN"=>"484",
+ "LTL"=>"440",
+ "HUF"=>"348",
+ "DJF"=>"262",
+ "BSD"=>"044",
+ "GNF"=>"324",
+ "ISK"=>"352",
+ "VUV"=>"548",
+ "SDG"=>"938",
+ "GEL"=>"981",
+ "FJD"=>"242",
+ "DOP"=>"214",
+ "XDR"=>"960",
+ "PHP"=>"608",
+ "MUR"=>"480",
+ "MMK"=>"104",
+ "KRW"=>"410",
+ "LRD"=>"430",
+ "BBD"=>"052",
+ "XAU"=>"959",
+ "ZMK"=>"894",
+ "VND"=>"704",
+ "UAH"=>"980",
+ "TMT"=>"934",
+ "IQD"=>"368",
+ "BGN"=>"975",
+ "GBP"=>"826",
+ "KGS"=>"417",
+ "ZAR"=>"710",
+ "TTD"=>"780",
+ "HRK"=>"191",
+ "BOV"=>"984",
+ "RWF"=>"646",
+ "CLF"=>"990",
+ "BHD"=>"048",
+ "UZS"=>"860",
+ "TWD"=>"901",
+ "PKR"=>"586",
+ "CRC"=>"188",
+ "AUD"=>"036",
+ "MKD"=>"807",
+ "AFN"=>"971",
+ "NAD"=>"516",
+ "BDT"=>"050",
+ "AZN"=>"944",
+ "CZK"=>"203",
+ "XXX"=>"999",
+ "CHW"=>"948",
+ "SOS"=>"706",
+ "QAR"=>"634",
+ "PAB"=>"590",
+ "CUC"=>"931",
+ "MXV"=>"979",
+ "SBD"=>"090",
+ "SVC"=>"222",
+ "ALL"=>"008",
+ "BND"=>"096",
+ "JMD"=>"388",
+ "CAD"=>"124",
+ "KWD"=>"414",
+ "GHS"=>"936"
+ }
+ end
+end
View
73 test/remote/buyer_auth_gateways/remote_centinel_test.rb
@@ -0,0 +1,73 @@
+require 'test_helper'
+
+class CentinelBuyerAuthTest < Test::Unit::TestCase
+
+ CentinelBuyerAuthGateway.logger = Logger.new(STDOUT)
+
+ def setup
+ @gateway = CentinelBuyerAuthGateway.new(fixtures(:centinel))
+ @amount = rand(10000)
+ @enrolled = credit_card('4000000000000002')
+ @options = { :order_id => generate_unique_id, :currency => "USD" }
+ end
+
+ def test_successful_verify_enrollment
+ response = @gateway.verify_enrollment(@amount, @enrolled, @options)
+
+ assert_success response
+ assert response.test?
+
+ p response
+
+ assert_equal CentinelBuyerAuthGateway::SUCCESS_MSG, response.message
+ assert_equal response.params["TransactionId"], response.authorization
+ end
+
+ # def test_error_verify_enrollment
+ # @gateway.expects(:ssl_post).returns(error_verify_enrollment_response)
+ #
+ # response = @gateway.verify_enrollment(@amount, @credit_card, @options)
+ #
+ # assert_failure response
+ # assert response.test?
+ #
+ # assert_equal "U", response.params["Enrolled"]
+ # assert_equal "2Zqy5Svlx0SSivIC0vaL", response.params["TransactionId"]
+ # assert_equal "Payment Initiative Not Supported", response.params["ErrorDesc"]
+ # assert_equal "1360", response.params["ErrorNo"]
+ #
+ # assert_equal response.params["ErrorDesc"], response.message
+ # assert_equal response.params["TransactionId"], response.authorization
+ # end
+ #
+ # def test_successful_validate_authentication
+ # @gateway.expects(:ssl_post).returns(successful_validate_authentication_response)
+ #
+ # response = @gateway.validate_authentication("pares", :order_id => "md")
+ # assert_success response
+ #
+ # assert_equal "05", response.params["EciFlag"]
+ # assert_equal "Y", response.params["PAResStatus"]
+ # assert_equal "Y", response.params["SignatureVerification"]
+ # assert_equal "R2Y4QXdCc1hiZWw5Y3lrZ29iZ1E=", response.params["Xid"]
+ # assert_equal nil, response.params["ErrorDesc"]
+ # assert_equal "0", response.params["ErrorNo"]
+ # assert_equal "AAABAlIFMAAAAAAAdgUwENiWiV+=", response.params["Cavv"]
+ # end
+ #
+ # def test_error_validate_authentication
+ # @gateway.expects(:ssl_post).returns(error_validate_authentication_response)
+ #
+ # response = @gateway.validate_authentication("pares", :order_id => "md")
+ #
+ # assert_failure response
+ # assert response.test?
+ #
+ # assert_equal "Error Processing Authenticate Request Message, Error Validating Message, Transaction Id is Empty", response.params["ErrorDesc"]
+ # assert_equal "1003, 4268", response.params["ErrorNo"]
+ #
+ # assert_equal response.params["ErrorDesc"], response.message
+ # assert_equal nil, response.authorization
+ # end
+ #
+end
View
17 test/remote/gateways/remote_payflow_test.rb
@@ -1,6 +1,7 @@
require 'test_helper'
class RemotePayflowTest < Test::Unit::TestCase
+
def setup
ActiveMerchant::Billing::Base.gateway_mode = :test
@@ -234,4 +235,20 @@ def test_purchase_and_non_referenced_credit
assert credit = @gateway.credit(100, @credit_card, @options)
assert_success credit
end
+
+ def test_verify_enrollment_transaction
+ @credit_card = credit_card('5100000000000008',
+ :type => 'master'
+ )
+ @gateway = PayflowGateway.new(fixtures(:payflow))
+ response = @gateway.verify_enrollment(100, @credit_card, @options)
+
+ assert_success response
+ assert_equal "1", response.params["eci"]
+ assert_equal "https://pilot-buyerauth-post.verisign.com:443/DDDSecure/Acs3DSecureSim/start", response.params["acs_url"]
+ assert_not_nil response.params["authentication_id"]
+ assert_not_nil response.params["pa_req"]
+ assert_equal "E", response.params["status"]
+ end
+
end
View
154 test/unit/buyer_auth_gateways/centinel_test.rb
@@ -0,0 +1,154 @@
+require 'test_helper'
+
+class CentinelBuyerAuthTest < Test::Unit::TestCase
+
+ def setup
+ @gateway = CentinelBuyerAuthGateway.new(
+ :login => "merchant id",
+ :password => "tx password",
+ :processor => "1000"
+ )
+
+ @amount = 100
+ @credit_card = credit_card('4242424242424242')
+ @options = { :order_id => "1", :currency => "USD" }
+ end
+
+ def test_successful_verify_enrollment
+ @gateway.expects(:ssl_post).returns(successful_verify_enrollment_response)
+
+ response = @gateway.verify_enrollment(@amount, @credit_card, @options)
+
+ assert_success response
+ assert response.test?
+
+ assert_equal "07", response.params["EciFlag"]
+ assert_equal "eNpVUstygjAU3ecrnE7XJAHqFOeaGRUcdVpq0TKtO4QoWAUMUB9f3wR8tFndcx8n95wE5rHg3J7xsBKcwSsvimDNW0nUfXjyZ+nCGA6SF2pv++52pDvzBwbTnsf3DH64KJIsZVQjmg74CpGkEGEcpCWDINz3xy4z25SYBuALRLDjYmwz0hzADUSQBjvOZnGWJ6sT4BohCLMqLcWJPettwFeAoBJbFpdl3sH4cDhoRTOlhdkOsKohwPc9ppWKCinvmETM9Rfz5TY7e99uPreHztKZvC2d9cnz37uAVQeCKCg50wmxiEXNFrU6htUhFuA6jyDYqUXYo65rlhLWQAS5uqjXIF1Xpb8ZKaYSgqehVGNK3TeEgB/zLOVqCvAtlhrumw9Gys+wlE55E9ejUelTazNc9Y0PevjanN3hZ9xTHtctNWMinaKE0JoyqW3DigZfXhBfHltG/z7BL5gorGw=", response.params["Payload"]
+ assert_equal "Y", response.params["Enrolled"]
+ assert_equal "5VSnZ3FCiL1DlBNlH2ET", response.params["TransactionId"]
+ assert_equal "3854668635669588", response.params["OrderId"]
+ assert_equal nil, response.params["ErrorDesc"]
+ assert_equal "0", response.params["ErrorNo"]
+ assert_equal "https://testcustomer34.cardinalcommerce.com/V3DSStart?osb=visa-3&VAA=B", response.params["ACSUrl"]
+
+ assert_equal CentinelBuyerAuthGateway::SUCCESS_MSG, response.message
+ assert_equal response.params["TransactionId"], response.authorization
+ end
+
+ def test_error_verify_enrollment
+ @gateway.expects(:ssl_post).returns(error_verify_enrollment_response)
+
+ response = @gateway.verify_enrollment(@amount, @credit_card, @options)
+
+ assert_failure response
+ assert response.test?
+
+ assert_equal "U", response.params["Enrolled"]
+ assert_equal "2Zqy5Svlx0SSivIC0vaL", response.params["TransactionId"]
+ assert_equal "Payment Initiative Not Supported", response.params["ErrorDesc"]
+ assert_equal "1360", response.params["ErrorNo"]
+
+ assert_equal response.params["ErrorDesc"], response.message
+ assert_equal response.params["TransactionId"], response.authorization
+ end
+
+ def test_successful_validate_authentication
+ @gateway.expects(:ssl_post).returns(successful_validate_authentication_response)
+
+ response = @gateway.validate_authentication("pares", :order_id => "md")
+ assert_success response
+
+ assert_equal "05", response.params["EciFlag"]
+ assert_equal "Y", response.params["PAResStatus"]
+ assert_equal "Y", response.params["SignatureVerification"]
+ assert_equal "R2Y4QXdCc1hiZWw5Y3lrZ29iZ1E=", response.params["Xid"]
+ assert_equal nil, response.params["ErrorDesc"]
+ assert_equal "0", response.params["ErrorNo"]
+ assert_equal "AAABAlIFMAAAAAAAdgUwENiWiV+=", response.params["Cavv"]
+ end
+
+ def test_error_validate_authentication
+ @gateway.expects(:ssl_post).returns(error_validate_authentication_response)
+
+ response = @gateway.validate_authentication("pares", :order_id => "md")
+
+ assert_failure response
+ assert response.test?
+
+ assert_equal "Error Processing Authenticate Request Message, Error Validating Message, Transaction Id is Empty", response.params["ErrorDesc"]
+ assert_equal "1003, 4268", response.params["ErrorNo"]
+
+ assert_equal response.params["ErrorDesc"], response.message
+ assert_equal nil, response.authorization
+ end
+
+ private
+ def successful_verify_enrollment_response
+ <<-XML
+<?xml version="1.0"?>
+<CardinalMPI>
+ <EciFlag>07</EciFlag>
+ <Payload>eNpVUstygjAU3ecrnE7XJAHqFOeaGRUcdVpq0TKtO4QoWAUMUB9f3wR8tFndcx8n95wE5rHg3J7xsBKcwSsvimDNW0nUfXjyZ+nCGA6SF2pv++52pDvzBwbTnsf3DH64KJIsZVQjmg74CpGkEGEcpCWDINz3xy4z25SYBuALRLDjYmwz0hzADUSQBjvOZnGWJ6sT4BohCLMqLcWJPettwFeAoBJbFpdl3sH4cDhoRTOlhdkOsKohwPc9ppWKCinvmETM9Rfz5TY7e99uPreHztKZvC2d9cnz37uAVQeCKCg50wmxiEXNFrU6htUhFuA6jyDYqUXYo65rlhLWQAS5uqjXIF1Xpb8ZKaYSgqehVGNK3TeEgB/zLOVqCvAtlhrumw9Gys+wlE55E9ejUelTazNc9Y0PevjanN3hZ9xTHtctNWMinaKE0JoyqW3DigZfXhBfHltG/z7BL5gorGw=</Payload>
+ <Enrolled>Y</Enrolled>
+ <TransactionId>5VSnZ3FCiL1DlBNlH2ET</TransactionId>
+ <OrderId>3854668635669588</OrderId>
+ <ErrorDesc/>
+ <ErrorNo>0</ErrorNo>
+ <ACSUrl>https://testcustomer34.cardinalcommerce.com/V3DSStart?osb=visa-3&amp;VAA=B</ACSUrl>
+</CardinalMPI>
+ XML
+ end
+
+ def error_verify_enrollment_credit_card_response
+ <<-XML
+<?xml version="1.0"?>
+<CardinalMPI>
+ <ErrorDesc>Error Processing Lookup Request Message, Error Validating Credit Card Expiration Information Passed (YYMM) [0901] </ErrorDesc>
+ <ErrorNo>1002, 4090</ErrorNo>
+ <TransactionId>Q4IGfMSJmX1737vDn5TT</TransactionId>
+ <Enrolled>U</Enrolled>
+ <EciFlag/>
+</CardinalMPI>
+ XML
+ end
+
+ def error_verify_enrollment_response
+ <<-XML
+<?xml version="1.0"?>
+<CardinalMPI>
+ <ErrorDesc>Payment Initiative Not Supported</ErrorDesc>
+ <ErrorNo>1360</ErrorNo>
+ <TransactionId>2Zqy5Svlx0SSivIC0vaL</TransactionId>
+ <Payload/>
+ <Enrolled>U</Enrolled>
+ <EciFlag/>
+ <ACSUrl/>
+</CardinalMPI>
+ XML
+ end
+
+ def successful_validate_authentication_response
+ <<-XML
+<?xml version="1.0"?>
+<CardinalMPI>
+ <EciFlag>05</EciFlag>
+ <PAResStatus>Y</PAResStatus>
+ <SignatureVerification>Y</SignatureVerification>
+ <Xid>R2Y4QXdCc1hiZWw5Y3lrZ29iZ1E=</Xid>
+ <ErrorDesc/>
+ <ErrorNo>0</ErrorNo>
+ <Cavv>AAABAlIFMAAAAAAAdgUwENiWiV+=</Cavv>
+</CardinalMPI>
+ XML
+ end
+
+ def error_validate_authentication_response
+ <<-XML
+<?xml version="1.0"?>
+<CardinalMPI>
+ <ErrorDesc>Error Processing Authenticate Request Message, Error Validating Message, Transaction Id is Empty</ErrorDesc>
+ <ErrorNo>1003, 4268</ErrorNo>
+</CardinalMPI>
+ XML
+ end
+end
View
206 test/unit/gateways/payflow_test.rb
@@ -195,6 +195,31 @@ def test_duplicate_response_flag
def test_ensure_gateway_uses_safe_retry
assert @gateway.retry_safe
end
+
+ def test_successful_verify_enrollment
+ @gateway.expects(:ssl_post).returns(successful_verify_enrollment_response)
+
+ response = @gateway.verify_enrollment(@amount, @credit_card, @options)
+ assert_success response
+ assert_equal "E", response.params['status']
+ assert_equal "1e542f17290374177e45", response.params['authentication_id']
+ assert_equal "eJxVUttuwjAM/RWE9tykpVCKTCQu08ZDERqbpu0tSz0oomlJ27Xs6+eUMjZLkX1s58Q5CTzvDeJyi6oyKCDCopA77CXxtO/i0Pc+3cAL+SDw3SBAf9gXsJk94UnAF5oiybRwHe54wK6QGIzaS10KkOo0X62FZw1YhyBFs1oKtzNgFwxapijmWJS9hTweE70jb+LeIktzqc/A2jqorNKlOYuxz4FdAVTmKPZlmU8Yq+va+SAWdSFRxOGoLAVme4DdhttUNiqIs0lisT6oul0PUfP2Tf414u+HWRN591NgtgNiWaLwOA/5yB31eDhx+WQQAGvzIFM7jLgjNWiyDkFuD5ldgGsLfxNAihvU6ixetku6zRUBNnmmkTpItd8Y2G3ixaMVV5Wk25Bo/9jY6twWLEtC4lA9bGksAGa3su4FWffYFP37BD9aga5V", response.params['pa_req']
+ assert_equal "https://pilot-buyerauth-post.verisign.com:443/DDDSecure/Acs3DSecureSim/start", response.params['acs_url']
+ assert_equal "1", response.params["eci"]
+ end
+
+ def test_successful_validate_authorization
+ @gateway.expects(:ssl_post).returns(successful_validate_authentication_response)
+
+ response = @gateway.validate_authentication("pa_res")
+
+ assert_success response
+ assert_equal "Y", response.params["status"]
+ assert_equal "472d2b0c082b34321d1b", response.params["authentication_id"]
+ assert_equal "5", response.params["eci"]
+ assert_equal "Mjg2ZDBlMzZkNWJhOGMxMDU1NzE=", response.params["cavv"]
+ assert_equal "MDAzZjNhMTE2YTM1N2UxNzIxNzY=", response.params["xid"]
+ end
private
def successful_recurring_response
@@ -302,4 +327,185 @@ def successful_duplicate_response
</XMLPayResponse>
XML
end
+
+ def successful_verify_enrollment_response
+ <<-XML
+<?xml version="1.0"?>
+<XMLPayResponse xmlns="http://www.paypal.com/XMLPay">
+ <ResponseData>
+ <Vendor>jadedpixel</Vendor>
+ <Partner>paypal</Partner>
+ <TransactionResults>
+ <TransactionResult>
+ <Result>0</Result>
+ <BuyerAuthResult>
+ <Status>E</Status>
+ <AuthenticationId>1e542f17290374177e45</AuthenticationId>
+ <PAReq>eJxVUttuwjAM/RWE9tykpVCKTCQu08ZDERqbpu0tSz0oomlJ27Xs6+eUMjZLkX1s58Q5CTzvDeJyi6oyKCDCopA77CXxtO/i0Pc+3cAL+SDw3SBAf9gXsJk94UnAF5oiybRwHe54wK6QGIzaS10KkOo0X62FZw1YhyBFs1oKtzNgFwxapijmWJS9hTweE70jb+LeIktzqc/A2jqorNKlOYuxz4FdAVTmKPZlmU8Yq+va+SAWdSFRxOGoLAVme4DdhttUNiqIs0lisT6oul0PUfP2Tf414u+HWRN591NgtgNiWaLwOA/5yB31eDhx+WQQAGvzIFM7jLgjNWiyDkFuD5ldgGsLfxNAihvU6ixetku6zRUBNnmmkTpItd8Y2G3ixaMVV5Wk25Bo/9jY6twWLEtC4lA9bGksAGa3su4FWffYFP37BD9aga5V</PAReq>
+ <ACSUrl>https://pilot-buyerauth-post.verisign.com:443/DDDSecure/Acs3DSecureSim/start</ACSUrl>
+ <ECI>1</ECI>
+ </BuyerAuthResult>
+ <Message>OK</Message>
+ </TransactionResult>
+ </TransactionResults>
+ </ResponseData>
+</XMLPayResponse>
+ XML
+ end
+
+ def verify_enrollment_user_authentication_failed
+ <<-XML
+<?xml version="1.0"?>
+<XMLPayResponse xmlns="http://www.paypal.com/XMLPay">
+ <ResponseData>
+ <Vendor>vendor</Vendor>
+ <Partner>verisign</Partner>
+ <TransactionResults>
+ <TransactionResult>
+ <Result>1</Result>
+ <BuyerAuthResult>
+ <Status>I</Status>
+ <ECI>1</ECI>
+ </BuyerAuthResult>
+ <Message>User authentication failed: 3DCC</Message>
+ </TransactionResult>
+ </TransactionResults>
+ </ResponseData>
+</XMLPayResponse>
+ XML
+ end
+
+ def successful_validate_authentication_response
+ <<-XML
+<?xml version="1.0"?>
+<XMLPayResponse xmlns="http://www.paypal.com/XMLPay">
+ <ResponseData>
+ <Vendor>jadedpixel</Vendor>
+ <Partner>paypal</Partner>
+ <TransactionResults>
+ <TransactionResult>
+ <Result>0</Result>
+ <BuyerAuthResult>
+ <Status>Y</Status>
+ <AuthenticationId>472d2b0c082b34321d1b</AuthenticationId>
+ <ECI>5</ECI>
+ <CAVV>Mjg2ZDBlMzZkNWJhOGMxMDU1NzE=</CAVV>
+ <XID>MDAzZjNhMTE2YTM1N2UxNzIxNzY=</XID>
+ </BuyerAuthResult>
+ <Message>OK</Message>
+ </TransactionResult>
+ </TransactionResults>
+ </ResponseData>
+</XMLPayResponse>
+ XML
+ end
+
+ def failed_authentication_validate_authentication_response
+ <<-XML
+<?xml version="1.0"?>
+<XMLPayResponse xmlns="http://www.paypal.com/XMLPay">
+ <ResponseData>
+ <Vendor>jadedpixel</Vendor>
+ <Partner>paypal</Partner>
+ <TransactionResults>
+ <TransactionResult>
+ <Result>0</Result>
+ <BuyerAuthResult>
+ <Status>N</Status>
+ <AuthenticationId>496350475b25653e1562</AuthenticationId>
+ <ECI>1</ECI>
+ </BuyerAuthResult>
+ <Message>OK</Message>
+ </TransactionResult>
+ </TransactionResults>
+ </ResponseData>
+</XMLPayResponse>
+ XML
+ end
+
+ def invalid_pares_format_response
+ <<-XML
+<?xml version="1.0"?>
+<XMLPayResponse xmlns="http://www.paypal.com/XMLPay">
+ <ResponseData>
+ <Vendor>jadedpixel</Vendor>
+ <Partner>paypal</Partner>
+ <TransactionResults>
+ <TransactionResult>
+ <Result>1042</Result>
+ <BuyerAuthResult>
+ <Status>F</Status>
+ </BuyerAuthResult>
+ <Message>invalid PARES format</Message>
+ </TransactionResult>
+ </TransactionResults>
+ </ResponseData>
+</XMLPayResponse>
+ XML
+ end
+
+ def successful_verified_by_visa_auth_response
+ <<-XML
+<?xml version="1.0"?>
+<XMLPayResponse xmlns="http://www.paypal.com/XMLPay">
+ <ResponseData>
+ <Vendor>jadedpixel</Vendor>
+ <Partner>paypal</Partner>
+ <TransactionResults>
+ <TransactionResult>
+ <Result>0</Result>
+ <ProcessorResult>
+ <CVResult>M</CVResult>
+ <CardSecure>2</CardSecure>
+ <HostCode>A</HostCode>
+ </ProcessorResult>
+ <FraudPreprocessResult>
+ <Message>No Rules Triggered</Message>
+ </FraudPreprocessResult>
+ <FraudPostprocessResult>
+ <Message>No Rules Triggered</Message>
+ </FraudPostprocessResult>
+ <CardSecure>Y</CardSecure>
+ <CVResult>Match</CVResult>
+ <Message>Approved</Message>
+ <PNRef>V18A2A47B809</PNRef>
+ <AuthCode>787PNI</AuthCode>
+ <ExtData Name="VISACARDLEVEL" Value="12"/>
+ </TransactionResult>
+ </TransactionResults>
+ </ResponseData>
+</XMLPayResponse>
+ XML
+ end
+
+ def successful_secure_code_auth_response
+ <<-XML
+<?xml version="1.0"?>
+<XMLPayResponse xmlns="http://www.paypal.com/XMLPay">
+ <ResponseData>
+ <Vendor>jadedpixel</Vendor>
+ <Partner>paypal</Partner>
+ <TransactionResults>
+ <TransactionResult>
+ <Result>0</Result>
+ <ProcessorResult>
+ <CVResult>M</CVResult>
+ <HostCode>A</HostCode>
+ </ProcessorResult>
+ <FraudPreprocessResult>
+ <Message>No Rules Triggered</Message>
+ </FraudPreprocessResult>
+ <FraudPostprocessResult>
+ <Message>No Rules Triggered</Message>
+ </FraudPostprocessResult>
+ <CVResult>Match</CVResult>
+ <Message>Approved</Message>
+ <PNRef>V79A1F00B119</PNRef>
+ <AuthCode>313PNI</AuthCode>
+ </TransactionResult>
+ </TransactionResults>
+ </ResponseData>
+</XMLPayResponse>
+ XML
+ end
end
View
25 test/unit/numeric_currency_code_test.rb
@@ -0,0 +1,25 @@
+require 'test_helper'
+
+class NumericCurrencyCodeTest < Test::Unit::TestCase
+
+ def test_lookup_code
+ assert_equal "840", ActiveMerchant::NumericCurrencyCode.lookup("USD")
+ end
+
+ def test_lookup_code_from_lower_case_currency
+ assert_equal "840", ActiveMerchant::NumericCurrencyCode.lookup("usd")
+ end
+
+ def test_lookup_non_existant_code
+ assert_nil ActiveMerchant::NumericCurrencyCode.lookup("ZZZ")
+ end
+
+ def test_lookup_with_nil
+ assert_nil ActiveMerchant::NumericCurrencyCode.lookup(nil)
+ end
+
+ def test_lookup_with_empty_string
+ assert_nil ActiveMerchant::NumericCurrencyCode.lookup("")
+ end
+
+end

No commit comments for this range

Something went wrong with that request. Please try again.