Permalink
Browse files

Update version to 52.0 for PayPal and add support for Fraud Filter re…

…sponse
  • Loading branch information...
1 parent e7b9769 commit e4bc642821294d621f5559ce90700f6b76fe106f Cody Fauser committed Jul 4, 2008
Showing with 63 additions and 7 deletions.
  1. +1 −0 CHANGELOG
  2. +14 −7 lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb
  3. +48 −0 test/unit/gateways/paypal_test.rb
View
1 CHANGELOG
@@ -1,5 +1,6 @@
= ActiveMerchant CHANGELOG
+* Add support for PayPal Fraud Review Response [cody]
* Add testing support for German Wirecard Gateway [Soleone]
* Specify required version of ActiveSupport [cody]
* Make ssl_strict a superclass_delegating_accessor so the entire application's validation of SSL certs can be disabled in the event of certificate problem. [cody]
View
21 lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb
@@ -8,7 +8,7 @@ def self.included(base)
base.cattr_accessor :signature
end
- API_VERSION = '2.0'
+ API_VERSION = '52.0'
URLS = {
:test => { :certificate => 'https://api.sandbox.paypal.com/2.0/',
@@ -42,6 +42,8 @@ def self.included(base)
SUCCESS_CODES = [ 'Success', 'SuccessWithWarning' ]
+ FRAUD_REVIEW_CODE = "11610"
+
# The gateway must be configured with either your PayPal PEM file
# or your PayPal API Signature. Only one is required.
#
@@ -109,7 +111,7 @@ def credit(money, identification, options = {})
private
def build_reauthorize_request(money, authorization, options)
- xml = Builder::XmlMarkup.new :indent => 2
+ xml = Builder::XmlMarkup.new
xml.tag! 'DoReauthorizationReq', 'xmlns' => PAYPAL_NAMESPACE do
xml.tag! 'DoReauthorizationRequest', 'xmlns:n2' => EBAY_NAMESPACE do
@@ -123,7 +125,7 @@ def build_reauthorize_request(money, authorization, options)
end
def build_capture_request(money, authorization, options)
- xml = Builder::XmlMarkup.new :indent => 2
+ xml = Builder::XmlMarkup.new
xml.tag! 'DoCaptureReq', 'xmlns' => PAYPAL_NAMESPACE do
xml.tag! 'DoCaptureRequest', 'xmlns:n2' => EBAY_NAMESPACE do
@@ -139,7 +141,7 @@ def build_capture_request(money, authorization, options)
end
def build_credit_request(money, identification, options)
- xml = Builder::XmlMarkup.new :indent => 2
+ xml = Builder::XmlMarkup.new
xml.tag! 'RefundTransactionReq', 'xmlns' => PAYPAL_NAMESPACE do
xml.tag! 'RefundTransactionRequest', 'xmlns:n2' => EBAY_NAMESPACE do
@@ -155,7 +157,7 @@ def build_credit_request(money, identification, options)
end
def build_void_request(authorization, options)
- xml = Builder::XmlMarkup.new :indent => 2
+ xml = Builder::XmlMarkup.new
xml.tag! 'DoVoidReq', 'xmlns' => PAYPAL_NAMESPACE do
xml.tag! 'DoVoidRequest', 'xmlns:n2' => EBAY_NAMESPACE do
@@ -172,7 +174,7 @@ def build_mass_pay_request(*args)
default_options = args.last.is_a?(Hash) ? args.pop : {}
recipients = args.first.is_a?(Array) ? args : [args]
- xml = Builder::XmlMarkup.new :indent => 2
+ xml = Builder::XmlMarkup.new
xml.tag! 'MassPayReq', 'xmlns' => PAYPAL_NAMESPACE do
xml.tag! 'MassPayRequest', 'xmlns:n2' => EBAY_NAMESPACE do
@@ -243,7 +245,7 @@ def response_type_for(action)
end
def build_request(body)
- xml = Builder::XmlMarkup.new :indent => 2
+ xml = Builder::XmlMarkup.new
xml.instruct!
xml.tag! 'env:Envelope', ENVELOPE_NAMESPACES do
@@ -293,11 +295,16 @@ def commit(action, request)
build_response(successful?(response), message_from(response), response,
:test => test?,
:authorization => authorization_from(response),
+ :fraud_review => fraud_review?(response),
:avs_result => { :code => response[:avs_code] },
:cvv_result => response[:cvv2_code]
)
end
+ def fraud_review?(response)
+ response[:error_codes] == FRAUD_REVIEW_CODE
+ end
+
def authorization_from(response)
response[:transaction_id] || response[:authorization_id] # latter one is from reauthorization
end
View
48 test/unit/gateways/paypal_test.rb
@@ -193,6 +193,16 @@ def test_cvv_result
assert_equal 'M', response.cvv_result['code']
end
+ def test_fraud_review
+ @gateway.expects(:ssl_post).returns(fraud_review_response)
+
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_success response
+ assert_equal "SuccessWithWarning", response.params["ack"]
+ assert_equal "Payment Pending your review in Fraud Management Filters", response.message
+ assert response.fraud_review?
+ end
+
private
def successful_purchase_response
<<-RESPONSE
@@ -377,4 +387,42 @@ def successful_with_warning_reauthorization_response
</SOAP-ENV:Envelope>
RESPONSE
end
+
+ def fraud_review_response
+ <<-RESPONSE
+ <?xml version="1.0" encoding="UTF-8"?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cc="urn:ebay:apis:CoreComponentTypes" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" xmlns:ns="urn:ebay:api:PayPalAPI">
+ <SOAP-ENV:Header>
+ <Security xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext" xsi:type="wsse:SecurityType"/>
+ <RequesterCredentials xmlns="urn:ebay:api:PayPalAPI" xsi:type="ebl:CustomSecurityHeaderType">
+ <Credentials xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:UserIdPasswordType">
+ <Username xsi:type="xs:string"/>
+ <Password xsi:type="xs:string"/>
+ <Signature xsi:type="xs:string">An5ns1Kso7MWUdW4ErQKJJJ4qi4-Azffuo82oMt-Cv9I8QTOs-lG5sAv</Signature>
+ <Subject xsi:type="xs:string"/>
+ </Credentials>
+ </RequesterCredentials>
+ </SOAP-ENV:Header>
+ <SOAP-ENV:Body id="_0">
+ <DoDirectPaymentResponse xmlns="urn:ebay:api:PayPalAPI">
+ <Timestamp xmlns="urn:ebay:apis:eBLBaseComponents">2008-07-04T19:27:39Z</Timestamp>
+ <Ack xmlns="urn:ebay:apis:eBLBaseComponents">SuccessWithWarning</Ack>
+ <CorrelationID xmlns="urn:ebay:apis:eBLBaseComponents">205d8397e7ed</CorrelationID>
+ <Errors xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:ErrorType">
+ <ShortMessage xsi:type="xs:string">Payment Pending your review in Fraud Management Filters</ShortMessage>
+ <LongMessage xsi:type="xs:string">Payment Pending your review in Fraud Management Filters</LongMessage>
+ <ErrorCode xsi:type="xs:token">11610</ErrorCode>
+ <SeverityCode xmlns="urn:ebay:apis:eBLBaseComponents">Warning</SeverityCode>
+ </Errors>
+ <Version xmlns="urn:ebay:apis:eBLBaseComponents">50.0</Version>
+ <Build xmlns="urn:ebay:apis:eBLBaseComponents">623197</Build>
+ <Amount xsi:type="cc:BasicAmountType" currencyID="USD">1500.00</Amount>
+ <AVSCode xsi:type="xs:string">X</AVSCode>
+ <CVV2Code xsi:type="xs:string">M</CVV2Code>
+ <TransactionID>5V117995ER6796022</TransactionID>
+ </DoDirectPaymentResponse>
+ </SOAP-ENV:Body>
+</SOAP-ENV:Envelope>
+ RESPONSE
+ end
end

0 comments on commit e4bc642

Please sign in to comment.