Permalink
Browse files

Unify TrustCommerce, Payment Express, and Braintree CC storage

  • Loading branch information...
1 parent 9629499 commit 06e59ab342c553a1ed2d9e9ea45fc3731b73f5f9 Cody Fauser committed May 22, 2008
View
@@ -1,5 +1,6 @@
= ActiveMerchant CHANGELOG
+* Unify TrustCommerce, Payment Express, and Braintree CC storage [benjamin.curtis]
* Update to use new Payflow Pro URLs [cody]
* Fix missing Content-Type header for Ruby 1.8.4 [cody]
* Fix Authorize.Net CIM response.message [patrick.t.joyce]
@@ -75,6 +75,15 @@ def delete(vault_id)
commit(nil, nil, post)
end
+ # To match the other stored-value gateways, like TrustCommerce,
+ # store and unstore need to be defined
+ def store(creditcard, options = {})
+ billing_id = options.delete(:billing_id).to_s || true
+ authorize(100, creditcard, options.merge(:store => billing_id))
+ end
+
+ alias_method :unstore, :delete
+
private
def add_customer_data(post, options)
if options.has_key? :email
@@ -265,7 +265,7 @@ def recurring(money, creditcard, options = {})
def store(creditcard, options = {})
parameters = {
:verify => options[:verify] || 'y',
- :billingid => options[:billingid] || nil,
+ :billingid => options[:billingid] || options[:billing_id] || nil,
}
add_creditcard(parameters, creditcard)
@@ -46,6 +46,13 @@ def test_successful_add_to_vault
assert_not_nil response.params["customer_vault_id"]
end
+ def test_successful_add_to_vault_with_store_method
+ assert response = @gateway.store(@credit_card)
+ assert_equal 'This transaction has been approved', response.message
+ assert_success response
+ assert_not_nil response.params["customer_vault_id"]
+ end
+
def test_successful_add_to_vault_and_use
@options[:store] = true
assert response = @gateway.purchase(@amount, @credit_card, @options)
@@ -66,6 +73,14 @@ def test_add_to_vault_with_custom_vault_id
assert_equal @options[:store], response.params["customer_vault_id"].to_i
end
+ def test_add_to_vault_with_custom_vault_id_with_store_method
+ @options[:billing_id] = rand(100000)+10001
+ assert response = @gateway.store(@credit_card, @options.dup)
+ assert_equal 'This transaction has been approved', response.message
+ assert_success response
+ assert_equal @options[:billing_id], response.params["customer_vault_id"].to_i
+ end
+
def test_update_vault
test_add_to_vault_with_custom_vault_id
@credit_card = credit_card('4111111111111111', :month => 10)
@@ -81,6 +96,13 @@ def test_delete_from_vault
assert_equal 'Customer Deleted', response.message
end
+ def test_delete_from_vault_with_unstore_method
+ test_add_to_vault_with_custom_vault_id
+ assert response = @gateway.unstore(@options[:store])
+ assert_success response
+ assert_equal 'Customer Deleted', response.message
+ end
+
def test_declined_purchase
assert response = @gateway.purchase(@declined_amount, @credit_card, @options)
assert_equal 'This transaction has been declined', response.message

0 comments on commit 06e59ab

Please sign in to comment.