Skip to content

Commit

Permalink
Paypal Express gateway: Reduce param requirements
Browse files Browse the repository at this point in the history
For reference transactions, Paypal Express does not require a payment
type, an invoice_id, a description, or an IP.  We shouldn't require them
either.

They can certainly be specified and we pass them to Paypal
appropriately, but they're not required.

Closes activemerchant#657.
  • Loading branch information
duff authored and ntalbott committed Apr 11, 2013
1 parent 6610816 commit e99842b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -10,6 +10,7 @@
* Pin: Fix special headers [duff]
* PayPal Express gateway: Remember the billing agreement id as Response#authorization [duff]
* PayPal Express gateway: Allow an amount of 0 [duff]
* PayPal Express gateway: Reduce parameter requirements [duff]

== Version 1.32.1 (April 4, 2013)

Expand Down
2 changes: 1 addition & 1 deletion lib/active_merchant/billing/gateways/paypal_express.rb
Expand Up @@ -70,7 +70,7 @@ def authorize_reference_transaction(money, options = {})
end

def reference_transaction(money, options = {})
requires!(options, :reference_id, :payment_type, :invoice_id, :description, :ip)
requires!(options, :reference_id)

commit 'DoReferenceTransaction', build_reference_transaction_request('Sale', money, options)
end
Expand Down
22 changes: 3 additions & 19 deletions test/unit/gateways/paypal_express_test.rb
Expand Up @@ -403,32 +403,16 @@ def test_authorize_reference_transaction
def test_reference_transaction
@gateway.expects(:ssl_post).returns(successful_reference_transaction_response)

response = @gateway.reference_transaction(2000, {
:reference_id => "ref_id",
:payment_type => 'Any',
:invoice_id => 'invoice_id',
:description => 'Description',
:ip => '127.0.0.1' })
response = @gateway.reference_transaction(2000, { :reference_id => "ref_id" })

assert_equal "Success", response.params['ack']
assert_equal "Success", response.message
assert_equal "9R43552341412482K", response.authorization
end

def test_reference_transaction_requires_fields
valid_options = {
:reference_id => "ref_id",
:payment_type => 'Any',
:invoice_id => 'invoice_id',
:description => 'Description',
:ip => '127.0.0.1' }

[:reference_id, :payment_type, :invoice_id, :description, :ip].each do |field|
options = valid_options.dup
options.delete(field)
assert_raise ArgumentError do
@gateway.reference_transaction(2000, options)
end
assert_raise ArgumentError do
@gateway.reference_transaction(2000, {})
end
end

Expand Down

0 comments on commit e99842b

Please sign in to comment.