Browse files

tests for paypal recurring gteway

  • Loading branch information...
1 parent aefafb7 commit 007afdb219536228fd491438353c36cb5842ea59 @ginettev committed Dec 4, 2011
View
58 lib/active_merchant/billing/gateways/paypal_recurring.rb
@@ -2,47 +2,45 @@
require File.dirname(__FILE__) + '/paypal/paypal_express_response'
require File.dirname(__FILE__) + '/paypal_express_common'
-module ActiveMerchant #:nodoc:
- module Billing #:nodoc:
+module ActiveMerchant
+ module Billing
class PaypalRecurringGateway < Gateway
include PaypalCommonAPI
include PaypalExpressCommon
-
+
self.test_redirect_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token='
self.live_redirect_url = 'https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token='
- # self.supported_countries = ['US']
- # self.homepage_url = 'https://www.paypal.com/cgi-bin/webscr?cmd=xpt/merchant/ExpressCheckoutIntro-outside'
- # self.display_name = 'PayPal Express Checkout Recurring'
+
API_VERSION = '59.0'
-
+
def setup_authorization(money, options = {})
requires!(options, :description, :return_url, :cancel_return_url)
-
+
commit 'SetExpressCheckout', build_setup_request('Authorization', money, options)
end
-
+
def setup_purchase(money, options = {})
requires!(options, :return_url, :cancel_return_url)
-
+
commit 'SetExpressCheckout', build_setup_request('Sale', money, options)
end
-
+
def details_for(token)
commit 'GetExpressCheckoutDetails', build_get_details_request(token)
end
-
+
def authorize(money, options = {})
requires!(options, :token, :payer_id)
-
+
commit 'DoExpressCheckoutPayment', build_sale_or_authorization_request('Authorization', money, options)
end
-
+
def purchase(money, options = {})
requires!(options, :token, :payer_id)
-
+
commit 'DoExpressCheckoutPayment', build_sale_or_authorization_request('Sale', money, options)
end
-
+
def get_agreement(token)
commit 'GetBillingAgreementCustomerDetails', build_get_agreement_request(token)
end
@@ -84,7 +82,7 @@ def build_setup_request(action, money, options)
xml.tag! 'SetExpressCheckoutReq', 'xmlns' => PAYPAL_NAMESPACE do
xml.tag! 'SetExpressCheckoutRequest', 'xmlns:n2' => EBAY_NAMESPACE do
xml.tag! 'n2:Version', API_VERSION
- xml.tag! 'n2:SetExpressCheckoutRequestDetails' do
+ xml.tag! 'n2:SetExpressCheckoutRequestDetails' do
xml.tag! 'n2:BillingAgreementDetails' do
xml.tag! 'n2:BillingType', 'RecurringPayments'
xml.tag! 'n2:BillingAgreementDescription', options[:description]
@@ -98,19 +96,19 @@ def build_setup_request(action, money, options)
xml.tag! 'n2:IPAddress', options[:ip] unless options[:ip].blank?
# IMPORTANT: If you want to use Invoice ID, it has to be unique!
# xml.tag! 'n2:InvoiceID', 'InvoiceID' + Time.now.to_i.to_s
-
+
xml.tag! 'n2:AllowNote', '0'
xml.tag! 'n2:LocaleCode', options[:locale] unless options[:locale].blank?
end
end
end
-
+
xml.target!
end
-
+
def build_sale_or_authorization_request(action, money, options)
currency_code = options[:currency] || currency(money)
-
+
xml = Builder::XmlMarkup.new :indent => 2
xml.tag! 'DoExpressCheckoutPaymentReq', 'xmlns' => PAYPAL_NAMESPACE do
xml.tag! 'DoExpressCheckoutPaymentRequest', 'xmlns:n2' => EBAY_NAMESPACE do
@@ -121,15 +119,15 @@ def build_sale_or_authorization_request(action, money, options)
xml.tag! 'n2:PayerID', options[:payer_id]
xml.tag! 'n2:PaymentDetails' do
xml.tag! 'n2:OrderTotal', amount(money), 'currencyID' => currency_code
-
+
# All of the values must be included together and add up to the order total
if [:subtotal, :shipping, :handling, :tax].all?{ |o| options.has_key?(o) }
xml.tag! 'n2:ItemTotal', amount(options[:subtotal]), 'currencyID' => currency_code
xml.tag! 'n2:ShippingTotal', amount(options[:shipping]),'currencyID' => currency_code
xml.tag! 'n2:HandlingTotal', amount(options[:handling]),'currencyID' => currency_code
xml.tag! 'n2:TaxTotal', amount(options[:tax]), 'currencyID' => currency_code
end
-
+
xml.tag! 'n2:NotifyURL', options[:notify_url]
xml.tag! 'n2:ButtonSource', application_id.to_s.slice(0,32) unless application_id.blank?
end
@@ -195,13 +193,13 @@ def build_create_profile_request(token, options)
xml.tag! 'n2:BillingFrequency', options[:trialfrequency]
xml.tag! 'n2:TotalBillingCycles', options[:trialcycles] || 1
xml.tag! 'n2:Amount', amount(options[:trialamount]), 'currencyID' => options[:currency] || 'USD'
- end
+ end
end
if !options[:initial_amount].blank?
xml.tag! 'n2:ActivationDetails' do
xml.tag! 'n2:InitialAmount', amount(options[:initial_amount]), 'currencyID' => options[:currency] || 'USD'
xml.tag! 'n2:FailedInitialAmountAction', options[:continue_on_failure] ? 'ContinueOnFailure' : 'CancelOnFailure'
- end
+ end
end
# xml.tag! 'n2:MaxFailedPayments', options[:max_failed_payments] unless options[:max_failed_payments].blank?
xml.tag! 'n2:AutoBillOutstandingAmount', options[:auto_bill_outstanding] ? 'AddToNextBilling' : 'NoAutoBill'
@@ -255,7 +253,7 @@ def build_change_profile_request(profile_id, options)
xml.target!
end
-
+
def build_manage_profile_request(profile_id, action, options)
xml = Builder::XmlMarkup.new :indent => 2
xml.tag! 'ManageRecurringPaymentsProfileStatusReq', 'xmlns' => PAYPAL_NAMESPACE do
@@ -295,19 +293,19 @@ def add_credit_card(xml, credit_card, address, options)
xml.tag! 'n2:ExpMonth', format(credit_card.month, :two_digits)
xml.tag! 'n2:ExpYear', format(credit_card.year, :four_digits)
xml.tag! 'n2:CVV2', credit_card.verification_value
-
+
if [ 'switch', 'solo' ].include?(card_brand(credit_card).to_s)
xml.tag! 'n2:StartMonth', format(credit_card.start_month, :two_digits) unless credit_card.start_month.blank?
xml.tag! 'n2:StartYear', format(credit_card.start_year, :four_digits) unless credit_card.start_year.blank?
xml.tag! 'n2:IssueNumber', format(credit_card.issue_number, :two_digits) unless credit_card.issue_number.blank?
end
-
+
xml.tag! 'n2:CardOwner' do
xml.tag! 'n2:PayerName' do
xml.tag! 'n2:FirstName', credit_card.first_name
xml.tag! 'n2:LastName', credit_card.last_name
end
-
+
xml.tag! 'n2:Payer', options[:email]
add_address(xml, 'n2:Address', address) if address
end
@@ -330,4 +328,4 @@ def build_response(success, message, response, options = {})
end
end
end
-end
+end
View
2 lib/active_merchant/common/validateable.rb
@@ -47,7 +47,7 @@ def empty?
# if more than one error is available we will only return the first. If no error is available
# we return an empty string
def on(field)
- self[field].to_a.first if self[:field].present?
+ self[field].to_a.first if self[field].present?
end
def add(field, error)
View
534 test/unit/gateways/paypal_recurring_test.rb
@@ -0,0 +1,534 @@
+require 'test_helper'
+
+class PaypalRecurringTest < Test::Unit::TestCase
+ TEST_REDIRECT_URL = 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token='
+ LIVE_REDIRECT_URL = 'https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token='
+
+ def setup
+ @gateway = PaypalRecurringGateway.new(
+ :login => 'cody',
+ :password => 'test',
+ :pem => 'PEM'
+ )
+
+ @address = { :address1 => '1234 My Street',
+ :address2 => 'Apt 1',
+ :company => 'Widgets Inc',
+ :city => 'Ottawa',
+ :state => 'ON',
+ :zip => 'K1C2N6',
+ :country => 'Canada',
+ :phone => '(555)555-5555'
+ }
+
+ Base.gateway_mode = :test
+ end
+
+ def teardown
+ Base.gateway_mode = :test
+ end
+
+ def test_live_redirect_url
+ token = "1234567890"
+ Base.gateway_mode = :production
+ assert_equal LIVE_REDIRECT_URL + "?cmd=_express-checkout&token=#{token}", @gateway.redirect_url_for(token)
+ end
+
+ def test_force_sandbox_redirect_url
+ Base.gateway_mode = :production
+
+ gateway = PaypalRecurringGateway.new(
+ :login => 'cody',
+ :password => 'test',
+ :pem => 'PEM',
+ :test => true
+ )
+ token = "1234567890"
+ assert gateway.test?
+ assert_equal TEST_REDIRECT_URL + "?cmd=_express-checkout&token=#{token}", gateway.redirect_url_for(token)
+ end
+
+ def test_test_redirect_url
+ token = "1234567890"
+ assert_equal :test, Base.gateway_mode
+ assert_equal TEST_REDIRECT_URL + "?cmd=_express-checkout&token=#{token}", @gateway.redirect_url_for(token)
+ end
+
+ def test_get_express_details
+ @gateway.expects(:ssl_post).returns(successful_details_response)
+ response = @gateway.details_for('EC-2OPN7UJGFWK9OYFV')
+
+ assert_instance_of PaypalExpressResponse, response
+ assert response.success?
+ assert response.test?
+
+ assert_equal 'EC-2XE90996XX9870316', response.token
+ assert_equal 'FWRVKNRRZ3WUC', response.payer_id
+ assert_equal 'buyer@jadedpallet.com', response.email
+
+ assert address = response.address
+ assert_equal 'Fred Brooks', address['name']
+ assert_nil address['company']
+ assert_equal '1234 Penny Lane', address['address1']
+ assert_nil address['address2']
+ assert_equal 'Jonsetown', address['city']
+ assert_equal 'NC', address['state']
+ assert_equal '23456', address['zip']
+ assert_equal 'US', address['country']
+ assert_equal '416-618-9984', address['phone']
+ end
+
+ def test_authorization
+ @gateway.expects(:ssl_post).returns(successful_authorization_response)
+ response = @gateway.authorize(300, :token => 'EC-6WS104951Y388951L', :payer_id => 'FWRVKNRRZ3WUC')
+ assert response.success?
+ assert_not_nil response.authorization
+ assert response.test?
+ end
+
+ def test_default_payflow_currency
+ assert_equal 'USD', PaypalRecurringGateway.default_currency
+ end
+
+ def test_includes_description
+ xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 0, { :description => 'a description' }))
+
+ assert_equal 'a description', REXML::XPath.first(xml, '//n2:SetExpressCheckoutRequestDetails/n2:BillingAgreementDetails/n2:BillingAgreementDescription').text
+ end
+
+ def test_includes_correct_payment_action
+ xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 0, { }))
+
+ assert_equal 'SetExpressCheckout', REXML::XPath.first(xml, '//n2:SetExpressCheckoutRequestDetails/n2:PaymentAction').text
+ end
+
+ def test_handle_non_zero_amount
+ xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 50, {}))
+
+ assert_equal '0.50', REXML::XPath.first(xml, '//n2:SetExpressCheckoutRequestDetails/n2:OrderTotal').text
+ end
+
+ def test_handles_zero_amount
+ xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 0, {}))
+
+ assert_equal '1.00', REXML::XPath.first(xml, '//n2:SetExpressCheckoutRequestDetails/n2:OrderTotal').text
+ end
+
+ def test_amount_format_for_jpy_currency
+ @gateway.expects(:ssl_post).with(anything, regexp_matches(/n2:OrderTotal currencyID=.JPY.>1.00<\/n2:OrderTotal>/)).returns(successful_authorization_response)
+ response = @gateway.authorize(100, :token => 'EC-6WS104951Y388951L', :payer_id => 'FWRVKNRRZ3WUC', :currency => 'JPY')
+ assert response.success?
+ end
+
+ def test_handle_locale_code
+ xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 0, { :locale => 'GB' }))
+
+ assert_equal 'GB', REXML::XPath.first(xml, '//n2:LocaleCode').text
+ end
+
+ def test_button_source
+ PaypalRecurringGateway.application_id = 'ActiveMerchant_EC'
+
+ xml = REXML::Document.new(@gateway.send(:build_sale_or_authorization_request, 'Test', 100, {}))
+ assert_equal 'ActiveMerchant_EC', REXML::XPath.first(xml, '//n2:ButtonSource').text
+ end
+
+ def test_error_code_for_single_error
+ @gateway.expects(:ssl_post).returns(response_with_error)
+ response = @gateway.setup_authorization(100,
+ :description => "description",
+ :return_url => 'http://example.com',
+ :cancel_return_url => 'http://example.com'
+ )
+ assert_equal "10736", response.params['error_codes']
+ end
+
+ def test_ensure_only_unique_error_codes
+ @gateway.expects(:ssl_post).returns(response_with_duplicate_errors)
+ response = @gateway.setup_authorization(100,
+ :description => "description",
+ :return_url => 'http://example.com',
+ :cancel_return_url => 'http://example.com'
+ )
+
+ assert_equal "10736" , response.params['error_codes']
+ end
+
+ def test_error_codes_for_multiple_errors
+ @gateway.expects(:ssl_post).returns(response_with_errors)
+ response = @gateway.setup_authorization(100,
+ :description => "description",
+ :return_url => 'http://example.com',
+ :cancel_return_url => 'http://example.com'
+ )
+
+ assert_equal ["10736", "10002"] , response.params['error_codes'].split(',')
+ end
+
+ def test_get_phone_number_from_address_if_contact_phone_not_sent
+ response = successful_details_response.sub(%r{<ContactPhone>416-618-9984</ContactPhone>\n}, '')
+ @gateway.expects(:ssl_post).returns(response)
+ response = @gateway.details_for('EC-2OPN7UJGFWK9OYFV')
+ assert address = response.address
+ assert_equal '123-456-7890', address['phone']
+ end
+
+ def test_sucessful_create_profile
+ @gateway.expects(:ssl_post).returns(successful_create_profile_paypal_response)
+ response = @gateway.create_profile('EC-2OPN7UJGFWK9OYFV', :description => "some description", :start_date => Time.now, :frequency => 12, :amount => 50)
+
+ assert_instance_of PaypalExpressResponse, response
+ assert response.success?
+ assert response.test?
+ assert_equal 'I-G7A2FF8V75JY', response.profile_id
+ assert_equal 'ActiveProfile', response.params['ProfileStatus']
+ end
+
+ def test_create_profile_fails_when_description_is_not_passed
+ assert_raises ArgumentError do
+ @gateway.create_profile('EC-2OPN7UJGFWK9OYFV', :start_date => Time.now, :frequency => 12, :amount => 50)
+ end
+ end
+
+ def test_create_profile_fails_when_start_date_is_not_passed
+ assert_raises ArgumentError do
+ @gateway.create_profile('EC-2OPN7UJGFWK9OYFV', :description => "desc", :frequency => 12, :amount => 50)
+ end
+ end
+
+ def test_create_profile_fails_when_frequency_is_not_passed
+ assert_raises ArgumentError do
+ @gateway.create_profile('EC-2OPN7UJGFWK9OYFV', :description => "desc", :start_date => Time.now, :amount => 50)
+ end
+ end
+
+ def test_create_profile_fails_when_amount_is_not_passed
+ assert_raises ArgumentError do
+ @gateway.create_profile('EC-2OPN7UJGFWK9OYFV', :description => "desc", :start_date => Time.now, :frequency => 12)
+ end
+ end
+
+ def test_failed_create_profile
+ @gateway.expects(:ssl_post).returns(failed_create_profile_paypal_response)
+ response = @gateway.create_profile('EC-2OPN7UJGFWK9OYFV', :description => "some description", :start_date => Time.now, :frequency => 12, :amount => 50)
+
+ assert_instance_of PaypalExpressResponse, response
+ assert !response.success?
+ assert response.test?
+ assert_equal 'I-G7A2FF8V75JY', response.profile_id
+ assert_equal 'ActiveProfile', response.params['ProfileStatus']
+ end
+
+ private
+ def successful_create_profile_paypal_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:ed=\"urn:ebay:apis:EnhancedDataTypes\" 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\"></Security>
+ <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\"></Username>
+ <Password xsi:type=\"xs:string\"></Password>
+ <Signature xsi:type=\"xs:string\"></Signature>
+ <Subject xsi:type=\"xs:string\"></Subject></Credentials>
+ </RequesterCredentials></SOAP-ENV:Header><SOAP-ENV:Body id=\"_0\">
+ <CreateRecurringPaymentsProfileResponse xmlns=\"urn:ebay:api:PayPalAPI\">
+ <Timestamp xmlns=\"urn:ebay:apis:eBLBaseComponents\">2011-08-28T18:59:40Z</Timestamp>
+ <Ack xmlns=\"urn:ebay:apis:eBLBaseComponents\">Success</Ack>
+ <CorrelationID xmlns=\"urn:ebay:apis:eBLBaseComponents\">4b8eaecc084b</CorrelationID>
+ <Version xmlns=\"urn:ebay:apis:eBLBaseComponents\">59.0</Version>
+ <Build xmlns=\"urn:ebay:apis:eBLBaseComponents\">2085867</Build>
+ <CreateRecurringPaymentsProfileResponseDetails xmlns=\"urn:ebay:apis:eBLBaseComponents\" xsi:type=\"ebl:CreateRecurringPaymentsProfileResponseDetailsType\">
+ <ProfileID xsi:type=\"xs:string\">I-G7A2FF8V75JY</ProfileID>
+ <ProfileStatus xsi:type=\"ebl:RecurringPaymentsProfileStatusType\">ActiveProfile</ProfileStatus>
+ <TransactionID xsi:type=\"xs:string\"></TransactionID></CreateRecurringPaymentsProfileResponseDetails>
+ </CreateRecurringPaymentsProfileResponse>
+ </SOAP-ENV:Body>
+ </SOAP-ENV:Envelope>
+ RESPONSE
+ end
+
+ def failed_create_profile_paypal_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:ed=\"urn:ebay:apis:EnhancedDataTypes\" 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\"></Security>
+ <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\"></Username>
+ <Password xsi:type=\"xs:string\"></Password>
+ <Signature xsi:type=\"xs:string\"></Signature>
+ <Subject xsi:type=\"xs:string\"></Subject>
+ </Credentials>
+ </RequesterCredentials>
+ </SOAP-ENV:Header>
+ <SOAP-ENV:Body id=\"_0\">
+ <CreateRecurringPaymentsProfileResponse xmlns=\"urn:ebay:api:PayPalAPI\">
+ <Timestamp xmlns=\"urn:ebay:apis:eBLBaseComponents\">2011-08-28T18:59:40Z</Timestamp>
+ <Ack xmlns=\"urn:ebay:apis:eBLBaseComponents\">This is a test failure</Ack>
+ <CorrelationID xmlns=\"urn:ebay:apis:eBLBaseComponents\">4b8eaecc084b</CorrelationID>
+ <Version xmlns=\"urn:ebay:apis:eBLBaseComponents\">59.0</Version>
+ <Build xmlns=\"urn:ebay:apis:eBLBaseComponents\">2085867</Build>
+ <CreateRecurringPaymentsProfileResponseDetails xmlns=\"urn:ebay:apis:eBLBaseComponents\" xsi:type=\"ebl:CreateRecurringPaymentsProfileResponseDetailsType\">
+ <ProfileID xsi:type=\"xs:string\">I-G7A2FF8V75JY</ProfileID>
+ <ProfileStatus xsi:type=\"ebl:RecurringPaymentsProfileStatusType\">ActiveProfile</ProfileStatus>
+ <TransactionID xsi:type=\"xs:string\"></TransactionID>
+ </CreateRecurringPaymentsProfileResponseDetails>
+ </CreateRecurringPaymentsProfileResponse>
+ </SOAP-ENV:Body>
+ </SOAP-ENV:Envelope>"
+ RESPONSE
+ end
+
+ def successful_details_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:ed="urn:ebay:apis:EnhancedDataTypes" 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"/>
+ <Subject xsi:type="xs:string"/>
+ </Credentials>
+ </RequesterCredentials>
+ </SOAP-ENV:Header>
+ <SOAP-ENV:Body id="_0">
+ <GetExpressCheckoutDetailsResponse xmlns="urn:ebay:api:PayPalAPI">
+ <Timestamp xmlns="urn:ebay:apis:eBLBaseComponents">2011-03-01T20:19:35Z</Timestamp>
+ <Ack xmlns="urn:ebay:apis:eBLBaseComponents">Success</Ack>
+ <CorrelationID xmlns="urn:ebay:apis:eBLBaseComponents">84aff0e17b6f</CorrelationID>
+ <Version xmlns="urn:ebay:apis:eBLBaseComponents">62.0</Version>
+ <Build xmlns="urn:ebay:apis:eBLBaseComponents">1741654</Build>
+ <GetExpressCheckoutDetailsResponseDetails xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:GetExpressCheckoutDetailsResponseDetailsType">
+ <Token xsi:type="ebl:ExpressCheckoutTokenType">EC-2XE90996XX9870316</Token>
+ <PayerInfo xsi:type="ebl:PayerInfoType">
+ <Payer xsi:type="ebl:EmailAddressType">buyer@jadedpallet.com</Payer>
+ <PayerID xsi:type="ebl:UserIDType">FWRVKNRRZ3WUC</PayerID>
+ <PayerStatus xsi:type="ebl:PayPalUserStatusCodeType">verified</PayerStatus>
+ <PayerName xsi:type='ebl:PersonNameType'>
+ <Salutation xmlns='urn:ebay:apis:eBLBaseComponents'/>
+ <FirstName xmlns='urn:ebay:apis:eBLBaseComponents'>Fred</FirstName>
+ <MiddleName xmlns='urn:ebay:apis:eBLBaseComponents'/>
+ <LastName xmlns='urn:ebay:apis:eBLBaseComponents'>Brooks</LastName>
+ <Suffix xmlns='urn:ebay:apis:eBLBaseComponents'/>
+ </PayerName>
+ <PayerCountry xsi:type="ebl:CountryCodeType">US</PayerCountry>
+ <PayerBusiness xsi:type="xs:string"/>
+ <Address xsi:type="ebl:AddressType">
+ <Name xsi:type="xs:string">Fred Brooks</Name>
+ <Street1 xsi:type="xs:string">1 Infinite Loop</Street1>
+ <Street2 xsi:type="xs:string"/>
+ <CityName xsi:type="xs:string">Cupertino</CityName>
+ <StateOrProvince xsi:type="xs:string">CA</StateOrProvince>
+ <Country xsi:type="ebl:CountryCodeType">US</Country>
+ <CountryName>United States</CountryName>
+ <PostalCode xsi:type="xs:string">95014</PostalCode>
+ <AddressOwner xsi:type="ebl:AddressOwnerCodeType">PayPal</AddressOwner>
+ <AddressStatus xsi:type="ebl:AddressStatusCodeType">Confirmed</AddressStatus>
+ </Address>
+ </PayerInfo>
+ <InvoiceID xsi:type="xs:string">1230123</InvoiceID>
+ <ContactPhone>416-618-9984</ContactPhone>
+ <PaymentDetails xsi:type="ebl:PaymentDetailsType">
+ <OrderTotal xsi:type="cc:BasicAmountType" currencyID="USD">19.00</OrderTotal>
+ <ItemTotal xsi:type="cc:BasicAmountType" currencyID="USD">19.00</ItemTotal>
+ <ShippingTotal xsi:type="cc:BasicAmountType" currencyID="USD">0.00</ShippingTotal>
+ <HandlingTotal xsi:type="cc:BasicAmountType" currencyID="USD">0.00</HandlingTotal>
+ <TaxTotal xsi:type="cc:BasicAmountType" currencyID="USD">0.00</TaxTotal>
+ <ShipToAddress xsi:type="ebl:AddressType">
+ <Name xsi:type="xs:string">Fred Brooks</Name>
+ <Street1 xsi:type="xs:string">1234 Penny Lane</Street1>
+ <Street2 xsi:type="xs:string"/>
+ <CityName xsi:type="xs:string">Jonsetown</CityName>
+ <StateOrProvince xsi:type="xs:string">NC</StateOrProvince>
+ <Country xsi:type="ebl:CountryCodeType">US</Country>
+ <CountryName>United States</CountryName>
+ <Phone xsi:type="xs:string">123-456-7890</Phone>
+ <PostalCode xsi:type="xs:string">23456</PostalCode>
+ <AddressID xsi:type="xs:string"/>
+ <AddressOwner xsi:type="ebl:AddressOwnerCodeType">PayPal</AddressOwner>
+ <ExternalAddressID xsi:type="xs:string"/>
+ <AddressStatus xsi:type="ebl:AddressStatusCodeType">Confirmed</AddressStatus>
+ </ShipToAddress>
+ <PaymentDetailsItem xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:PaymentDetailsItemType">
+ <Name xsi:type="xs:string">Shopify T-Shirt</Name>
+ <Quantity>1</Quantity>
+ <Tax xsi:type="cc:BasicAmountType" currencyID="USD">0.00</Tax>
+ <Amount xsi:type="cc:BasicAmountType" currencyID="USD">19.00</Amount>
+ <EbayItemPaymentDetailsItem xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:EbayItemPaymentDetailsItemType"/>
+ </PaymentDetailsItem>
+ <InsuranceTotal xsi:type="cc:BasicAmountType" currencyID="USD">0.00</InsuranceTotal>
+ <ShippingDiscount xsi:type="cc:BasicAmountType" currencyID="USD">0.00</ShippingDiscount>
+ <InsuranceOptionOffered xsi:type="xs:string">false</InsuranceOptionOffered>
+ <SellerDetails xsi:type="ebl:SellerDetailsType"/>
+ <PaymentRequestID xsi:type="xs:string"/>
+ <OrderURL xsi:type="xs:string"/>
+ <SoftDescriptor xsi:type="xs:string"/>
+ </PaymentDetails>
+ <CheckoutStatus xsi:type="xs:string">PaymentActionNotInitiated</CheckoutStatus>
+ </GetExpressCheckoutDetailsResponseDetails>
+ </GetExpressCheckoutDetailsResponse>
+ </SOAP-ENV:Body>
+</SOAP-ENV:Envelope>
+ RESPONSE
+ end
+
+ def successful_authorization_response
+ <<-RESPONSE
+<?xml version='1.0' encoding='UTF-8'?>
+<SOAP-ENV:Envelope xmlns:cc='urn:ebay:apis:CoreComponentTypes' xmlns:sizeship='urn:ebay:api:PayPalAPI/sizeship.xsd' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/' xmlns:saml='urn:oasis:names:tc:SAML:1.0:assertion' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:wsu='http://schemas.xmlsoap.org/ws/2002/07/utility' xmlns:ebl='urn:ebay:apis:eBLBaseComponents' xmlns:ds='http://www.w3.org/2000/09/xmldsig#' xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:ns='urn:ebay:api:PayPalAPI' xmlns:market='urn:ebay:apis:Market' xmlns:ship='urn:ebay:apis:ship' xmlns:auction='urn:ebay:apis:Auction' xmlns:wsse='http://schemas.xmlsoap.org/ws/2002/12/secext' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
+ <SOAP-ENV:Header>
+ <Security xsi:type='wsse:SecurityType' xmlns='http://schemas.xmlsoap.org/ws/2002/12/secext'/>
+ <RequesterCredentials xsi:type='ebl:CustomSecurityHeaderType' xmlns='urn:ebay:api:PayPalAPI'>
+ <Credentials xsi:type='ebl:UserIdPasswordType' xmlns='urn:ebay:apis:eBLBaseComponents'>
+ <Username xsi:type='xs:string'/>
+ <Password xsi:type='xs:string'/>
+ <Subject xsi:type='xs:string'/>
+ </Credentials>
+ </RequesterCredentials>
+ </SOAP-ENV:Header>
+ <SOAP-ENV:Body id='_0'>
+ <DoExpressCheckoutPaymentResponse xmlns='urn:ebay:api:PayPalAPI'>
+ <Timestamp xmlns='urn:ebay:apis:eBLBaseComponents'>2007-02-13T00:18:50Z</Timestamp>
+ <Ack xmlns='urn:ebay:apis:eBLBaseComponents'>Success</Ack>
+ <CorrelationID xmlns='urn:ebay:apis:eBLBaseComponents'>62450a4266d04</CorrelationID>
+ <Version xmlns='urn:ebay:apis:eBLBaseComponents'>2.000000</Version>
+ <Build xmlns='urn:ebay:apis:eBLBaseComponents'>1.0006</Build>
+ <DoExpressCheckoutPaymentResponseDetails xsi:type='ebl:DoExpressCheckoutPaymentResponseDetailsType' xmlns='urn:ebay:apis:eBLBaseComponents'>
+ <Token xsi:type='ebl:ExpressCheckoutTokenType'>EC-6WS104951Y388951L</Token>
+ <PaymentInfo xsi:type='ebl:PaymentInfoType'>
+ <TransactionID>8B266858CH956410C</TransactionID>
+ <ParentTransactionID xsi:type='ebl:TransactionId'/>
+ <ReceiptID/>
+ <TransactionType xsi:type='ebl:PaymentTransactionCodeType'>express-checkout</TransactionType>
+ <PaymentType xsi:type='ebl:PaymentCodeType'>instant</PaymentType>
+ <PaymentDate xsi:type='xs:dateTime'>2007-02-13T00:18:48Z</PaymentDate>
+ <GrossAmount currencyID='USD' xsi:type='cc:BasicAmountType'>3.00</GrossAmount>
+ <TaxAmount currencyID='USD' xsi:type='cc:BasicAmountType'>0.00</TaxAmount>
+ <ExchangeRate xsi:type='xs:string'/>
+ <PaymentStatus xsi:type='ebl:PaymentStatusCodeType'>Pending</PaymentStatus>
+ <PendingReason xsi:type='ebl:PendingStatusCodeType'>authorization</PendingReason>
+ <ReasonCode xsi:type='ebl:ReversalReasonCodeType'>none</ReasonCode>
+ </PaymentInfo>
+ </DoExpressCheckoutPaymentResponseDetails>
+ </DoExpressCheckoutPaymentResponse>
+ </SOAP-ENV:Body>
+</SOAP-ENV:Envelope>
+ RESPONSE
+ end
+
+ def response_with_error
+ <<-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:market="urn:ebay:apis:Market" xmlns:auction="urn:ebay:apis:Auction" xmlns:sizeship="urn:ebay:api:PayPalAPI/sizeship.xsd" xmlns:ship="urn:ebay:apis:ship" xmlns:skype="urn:ebay:apis:skype" 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"/>
+ <Subject xsi:type="xs:string"/>
+ </Credentials>
+ </RequesterCredentials>
+ </SOAP-ENV:Header>
+ <SOAP-ENV:Body id="_0">
+ <SetExpressCheckoutResponse xmlns="urn:ebay:api:PayPalAPI">
+ <Timestamp xmlns="urn:ebay:apis:eBLBaseComponents">2008-04-02T17:38:02Z</Timestamp>
+ <Ack xmlns="urn:ebay:apis:eBLBaseComponents">Failure</Ack>
+ <CorrelationID xmlns="urn:ebay:apis:eBLBaseComponents">cdb720feada30</CorrelationID>
+ <Errors xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:ErrorType">
+ <ShortMessage xsi:type="xs:string">Shipping Address Invalid City State Postal Code</ShortMessage>
+ <LongMessage xsi:type="xs:string">A match of the Shipping Address City, State, and Postal Code failed.</LongMessage>
+ <ErrorCode xsi:type="xs:token">10736</ErrorCode>
+ <SeverityCode xmlns="urn:ebay:apis:eBLBaseComponents">Error</SeverityCode>
+ </Errors>
+ <Version xmlns="urn:ebay:apis:eBLBaseComponents">2.000000</Version>
+ <Build xmlns="urn:ebay:apis:eBLBaseComponents">543066</Build>
+ </SetExpressCheckoutResponse>
+ </SOAP-ENV:Body>
+</SOAP-ENV:Envelope>
+ RESPONSE
+ end
+
+ def response_with_errors
+ <<-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:market="urn:ebay:apis:Market" xmlns:auction="urn:ebay:apis:Auction" xmlns:sizeship="urn:ebay:api:PayPalAPI/sizeship.xsd" xmlns:ship="urn:ebay:apis:ship" xmlns:skype="urn:ebay:apis:skype" 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"/>
+ <Subject xsi:type="xs:string"/>
+ </Credentials>
+ </RequesterCredentials>
+ </SOAP-ENV:Header>
+ <SOAP-ENV:Body id="_0">
+ <SetExpressCheckoutResponse xmlns="urn:ebay:api:PayPalAPI">
+ <Timestamp xmlns="urn:ebay:apis:eBLBaseComponents">2008-04-02T17:38:02Z</Timestamp>
+ <Ack xmlns="urn:ebay:apis:eBLBaseComponents">Failure</Ack>
+ <CorrelationID xmlns="urn:ebay:apis:eBLBaseComponents">cdb720feada30</CorrelationID>
+ <Errors xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:ErrorType">
+ <ShortMessage xsi:type="xs:string">Shipping Address Invalid City State Postal Code</ShortMessage>
+ <LongMessage xsi:type="xs:string">A match of the Shipping Address City, State, and Postal Code failed.</LongMessage>
+ <ErrorCode xsi:type="xs:token">10736</ErrorCode>
+ <SeverityCode xmlns="urn:ebay:apis:eBLBaseComponents">Error</SeverityCode>
+ </Errors>
+ <Errors xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:ErrorType">
+ <ShortMessage xsi:type="xs:string">Authentication/Authorization Failed</ShortMessage>
+ <LongMessage xsi:type="xs:string">You do not have permissions to make this API call</LongMessage>
+ <ErrorCode xsi:type="xs:token">10002</ErrorCode>
+ <SeverityCode xmlns="urn:ebay:apis:eBLBaseComponents">Error</SeverityCode>
+ </Errors>
+ <Version xmlns="urn:ebay:apis:eBLBaseComponents">2.000000</Version>
+ <Build xmlns="urn:ebay:apis:eBLBaseComponents">543066</Build>
+ </SetExpressCheckoutResponse>
+ </SOAP-ENV:Body>
+ </SOAP-ENV:Envelope>
+ RESPONSE
+ end
+
+ def response_with_duplicate_errors
+ <<-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:market="urn:ebay:apis:Market" xmlns:auction="urn:ebay:apis:Auction" xmlns:sizeship="urn:ebay:api:PayPalAPI/sizeship.xsd" xmlns:ship="urn:ebay:apis:ship" xmlns:skype="urn:ebay:apis:skype" 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"/>
+ <Subject xsi:type="xs:string"/>
+ </Credentials>
+ </RequesterCredentials>
+ </SOAP-ENV:Header>
+ <SOAP-ENV:Body id="_0">
+ <SetExpressCheckoutResponse xmlns="urn:ebay:api:PayPalAPI">
+ <Timestamp xmlns="urn:ebay:apis:eBLBaseComponents">2008-04-02T17:38:02Z</Timestamp>
+ <Ack xmlns="urn:ebay:apis:eBLBaseComponents">Failure</Ack>
+ <CorrelationID xmlns="urn:ebay:apis:eBLBaseComponents">cdb720feada30</CorrelationID>
+ <Errors xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:ErrorType">
+ <ShortMessage xsi:type="xs:string">Shipping Address Invalid City State Postal Code</ShortMessage>
+ <LongMessage xsi:type="xs:string">A match of the Shipping Address City, State, and Postal Code failed.</LongMessage>
+ <ErrorCode xsi:type="xs:token">10736</ErrorCode>
+ <SeverityCode xmlns="urn:ebay:apis:eBLBaseComponents">Error</SeverityCode>
+ </Errors>
+ <Errors xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:ErrorType">
+ <ShortMessage xsi:type="xs:string">Shipping Address Invalid City State Postal Code</ShortMessage>
+ <LongMessage xsi:type="xs:string">A match of the Shipping Address City, State, and Postal Code failed.</LongMessage>
+ <ErrorCode xsi:type="xs:token">10736</ErrorCode>
+ <SeverityCode xmlns="urn:ebay:apis:eBLBaseComponents">Error</SeverityCode>
+ </Errors>
+ <Version xmlns="urn:ebay:apis:eBLBaseComponents">2.000000</Version>
+ <Build xmlns="urn:ebay:apis:eBLBaseComponents">543066</Build>
+ </SetExpressCheckoutResponse>
+ </SOAP-ENV:Body>
+ </SOAP-ENV:Envelope>
+ RESPONSE
+ end
+end

0 comments on commit 007afdb

Please sign in to comment.