Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

order_id is now optional for the Ogone gateway

  • Loading branch information...
commit f793bad13800b9a1ae7f077693683e7a12a8898b 1 parent 7efce06
Nicolas Jacobeus authored jstorimer committed
View
4 lib/active_merchant/billing/gateways/ogone.rb
@@ -41,6 +41,8 @@ module Billing #:nodoc:
# # run request
# response = gateway.purchase(1000, creditcard, :order_id => "1") # charge 10 EUR
#
+ # If you don't provide an :order_id, the gateway will generate a random one for you.
+ #
# puts response.success? # Check whether the transaction was successful
# puts response.message # Retrieve the message returned by Ogone
# puts response.authorization # Retrieve the unique transaction ID returned by Ogone
@@ -187,7 +189,7 @@ def add_address(post, creditcard, options)
end
def add_invoice(post, options)
- add_pair post, 'orderID', options[:order_id]
+ add_pair post, 'orderID', options[:order_id] || generate_unique_id[0...30]
add_pair post, 'COM', options[:description]
end
View
11 test/remote/gateways/remote_ogone_test.rb
@@ -8,7 +8,7 @@ def setup
@credit_card = credit_card('4000100011112224')
@declined_card = credit_card('1111111111111111')
@options = {
- :order_id => (Time.now.to_i.to_s + "%015d" % rand(10000000000000000000000).to_s)[0,25],
+ :order_id => generate_unique_id[0...30],
:billing_address => address,
:description => 'Store Purchase'
}
@@ -20,6 +20,13 @@ def test_successful_purchase
assert_equal '!', response.message
end
+ def test_successful_purchase_without_order_id
+ @options.delete(:order_id)
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_success response
+ assert_equal '!', response.message
+ end
+
def test_unsuccessful_purchase
assert response = @gateway.purchase(@amount, @declined_card, @options)
assert_failure response
@@ -38,7 +45,7 @@ def test_authorize_and_capture
def test_unsuccessful_capture
assert response = @gateway.capture(@amount, '')
assert_failure response
- assert_equal ' no orderid', response.message
+ assert_equal ' no card no|no exp date|no brand', response.message
end
def test_successful_void
View
9 test/unit/gateways/ogone_test.rb
@@ -34,6 +34,15 @@ def test_successful_purchase
assert response.test?
end
+ def test_successful_purchase_without_order_id
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
+ @options.delete(:order_id)
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_success response
+ assert_equal '3014726', response.authorization
+ assert response.test?
+ end
+
def test_successful_capture
@gateway.expects(:ssl_post).returns(successful_capture_response)
assert response = @gateway.capture(@amount, "3048326")
Please sign in to comment.
Something went wrong with that request. Please try again.