Skip to content

Commit

Permalink
Formally deprecate Money objects. Clean up contributor comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Cody Fauser committed Feb 2, 2010
1 parent 7293bda commit 0ae2fd6
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 30 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
@@ -1,5 +1,6 @@
= ActiveMerchant CHANGELOG

* Deprecate Money objects [cody]
* Update JCB rejex to catch all valid PANs [pjhyett]
* Remove old TransaXGateway constant [cody]
* Remove old ProtxGateway constant [cody]
Expand Down
8 changes: 8 additions & 0 deletions CONTRIBUTORS
Expand Up @@ -39,6 +39,14 @@ NetRegistry Gateway

* Originally contributed by George Ogata (mailto: george.ogata@gmail.com)

DataCash Gateway (March 2, 2007)

* MoneySpyder, http://moneyspyder.co.uk and E-consultancy, http://www.e-consultancy.com

PSL Card Gateway (March 27, 2007)

* MoneySpyder, http://moneyspyder.co.uk

Viaklix Gateway (Sep 3, 2007)

* Originally contributed by Sal Scotto
Expand Down
9 changes: 7 additions & 2 deletions lib/active_merchant/billing/gateway.rb
Expand Up @@ -132,10 +132,15 @@ def name

def amount(money)
return nil if money.nil?
cents = money.respond_to?(:cents) ? money.cents : money
cents = if money.respond_to?(:cents)
warn "Support for Money objects is deprecated and will be removed from a future release of ActiveMerchant. Please use an Integer value in cents"
money.cents
else
money
end

if money.is_a?(String) or cents.to_i < 0
raise ArgumentError, 'money amount must be either a Money object or a positive integer in cents.'
raise ArgumentError, 'money amount must be a positive Integer in cents.'
end

if self.money_format == :cents
Expand Down
11 changes: 5 additions & 6 deletions lib/active_merchant/billing/gateways/authorize_net.rb
Expand Up @@ -79,7 +79,7 @@ def initialize(options = {})
#
# ==== Parameters
#
# * <tt>money</tt> -- The amount to be authorized. Either an Integer value in cents or a Money object.
# * <tt>money</tt> -- The amount to be authorized as an Integer value in cents.
# * <tt>creditcard</tt> -- The CreditCard details for the transaction.
# * <tt>options</tt> -- A hash of optional parameters.
def authorize(money, creditcard, options = {})
Expand All @@ -97,7 +97,7 @@ def authorize(money, creditcard, options = {})
#
# ==== Parameters
#
# * <tt>money</tt> -- The amount to be purchased. Either an Integer value in cents or a Money object.
# * <tt>money</tt> -- The amount to be purchased as an Integer value in cents.
# * <tt>creditcard</tt> -- The CreditCard details for the transaction.
# * <tt>options</tt> -- A hash of optional parameters.
def purchase(money, creditcard, options = {})
Expand All @@ -115,7 +115,7 @@ def purchase(money, creditcard, options = {})
#
# ==== Parameters
#
# * <tt>money</tt> -- The amount to be captured. Either an Integer value in cents or a Money object.
# * <tt>money</tt> -- The amount to be captured as an Integer value in cents.
# * <tt>authorization</tt> -- The authorization returned from the previous authorize request.
def capture(money, authorization, options = {})
post = {:trans_id => authorization}
Expand All @@ -140,7 +140,7 @@ def void(authorization, options = {})
#
# ==== Parameters
#
# * <tt>money</tt> -- The amount to be credited to the customer. Either an Integer value in cents or a Money object.
# * <tt>money</tt> -- The amount to be credited to the customer as an Integer value in cents.
# * <tt>identification</tt> -- The ID of the original transaction against which the credit is being issued.
# * <tt>options</tt> -- A hash of parameters.
#
Expand All @@ -164,8 +164,7 @@ def credit(money, identification, options = {})
#
# ==== Parameters
#
# * <tt>money</tt> -- The amount to be charged to the customer at each interval. Either an Integer value in cents or
# a Money object.
# * <tt>money</tt> -- The amount to be charged to the customer at each interval as an Integer value in cents.
# * <tt>creditcard</tt> -- The CreditCard details for the transaction.
# * <tt>options</tt> -- A hash of parameters.
#
Expand Down
12 changes: 5 additions & 7 deletions lib/active_merchant/billing/gateways/data_cash.rb
@@ -1,5 +1,3 @@
# Authors:: MoneySpyder, http://moneyspyder.co.uk and E-consultancy, http://www.e-consultancy.com

module ActiveMerchant
module Billing
class DataCashGateway < Gateway
Expand Down Expand Up @@ -58,7 +56,7 @@ def initialize(options = {})
# Perform a purchase, which is essentially an authorization and capture in a single operation.
#
# ==== Parameters
# * <tt>money</tt> The amount to be authorized. Either an Integer value in cents or a Money object.
# * <tt>money</tt> The amount to be authorized as an Integer value in cents.
# * <tt>authorization_or_credit_card</tt>:: The continuous authority reference or CreditCard details for the transaction.
# * <tt>options</tt> A hash of optional parameters.
# * <tt>:order_id</tt> A unique reference for this order (corresponds to merchantreference in datacash documentation)
Expand Down Expand Up @@ -86,7 +84,7 @@ def purchase(money, authorization_or_credit_card, options = {})
#
# ==== Parameters
#
# * <tt>money</tt> The amount to be authorized. Either an Integer value in cents or a Money object.
# * <tt>money</tt> The amount to be authorized as an Integer value in cents.
# * <tt>authorization_or_credit_card</tt>:: The continuous authority reference or CreditCard details for the transaction.
# * <tt>options</tt> A hash of optional parameters.
# * <tt>:order_id</tt> A unique reference for this order (corresponds to merchantreference in datacash documentation)
Expand All @@ -113,7 +111,7 @@ def authorize(money, authorization_or_credit_card, options = {})
#
# ==== Parameters
#
# * <tt>money</tt> -- The amount to be captured. Either an Integer value in cents or a Money object.
# * <tt>money</tt> -- The amount to be captured as anInteger value in cents.
# * <tt>authorization</tt> -- The authorization returned from the previous authorize request.
def capture(money, authorization, options = {})
commit(build_void_or_capture_request(FULFILL_TYPE, money, authorization, options))
Expand All @@ -134,7 +132,7 @@ def void(authorization, options = {})
#
# ==== Parameters
#
# * <tt>money</tt> The amount to be refunded. Either an Integer value in cents or a Money object. Set to nil for a full refund on existing transaction.
# * <tt>money</tt> The amount to be refunded as an Integer value in cents. Set to nil for a full refund on existing transaction.
# * <tt>reference_or_credit_card</tt> The credit card you want to refund OR the datacash_reference for the existing transaction you are refunding
# * <tt>options</tt> Are ignored when refunding via reference to an existing transaction, otherwise
# * <tt>:order_id</tt> A unique reference for this order (corresponds to merchantreference in datacash documentation)
Expand Down Expand Up @@ -177,7 +175,7 @@ def test?
#
# Parameters:
# * <tt>type</tt> must be FULFILL_TYPE or CANCEL_TYPE
# * <tt>money</tt> - optional - Money object or value in cents
# * <tt>money</tt> - optional - Integer value in cents
# * <tt>authorization</tt> - the Datacash authorization from a previous succesful authorize transaction
# * <tt>options</tt>
# * <tt>order_id</tt> - A unique reference for the transaction
Expand Down
4 changes: 2 additions & 2 deletions lib/active_merchant/billing/gateways/elavon.rb
Expand Up @@ -48,7 +48,7 @@ class ElavonGateway < ViaklixGateway
# Authorize a credit card for a given amount.
#
# ==== Parameters
# * <tt>money</tt> - The amount to be authorized. Either an Integer value in cents or a Money object.
# * <tt>money</tt> - The amount to be authorized as an Integer value in cents.
# * <tt>credit_card</tt> - The CreditCard details for the transaction.
# * <tt>options</tt>
# * <tt>:billing_address</tt> - The billing address for the cardholder.
Expand All @@ -64,7 +64,7 @@ def authorize(money, creditcard, options = {})
# Capture authorized funds from a credit card.
#
# ==== Parameters
# * <tt>money</tt> - The amount to be captured. Either an Integer value in cents or a Money object.
# * <tt>money</tt> - The amount to be captured as an Integer value in cents.
# * <tt>authorization</tt> - The approval code returned from the initial authorization.
# * <tt>options</tt>
# * <tt>:credit_card</tt> - The CreditCard details from the initial transaction (required).
Expand Down
8 changes: 4 additions & 4 deletions lib/active_merchant/billing/gateways/merchant_ware.rb
Expand Up @@ -42,7 +42,7 @@ def initialize(options = {})
# Authorize a credit card for a given amount.
#
# ==== Parameters
# * <tt>money</tt> - The amount to be authorized. Either an Integer value in cents or a Money object.
# * <tt>money</tt> - The amount to be authorized as an Integer value in cents.
# * <tt>credit_card</tt> - The CreditCard details for the transaction.
# * <tt>options</tt>
# * <tt>:order_id</tt> - A unique reference for this order (required).
Expand All @@ -55,7 +55,7 @@ def authorize(money, credit_card, options = {})
# Authorize and immediately capture funds from a credit card.
#
# ==== Parameters
# * <tt>money</tt> - The amount to be authorized. Either an Integer value in cents or a Money object.
# * <tt>money</tt> - The amount to be authorized as anInteger value in cents.
# * <tt>credit_card</tt> - The CreditCard details for the transaction.
# * <tt>options</tt>
# * <tt>:order_id</tt> - A unique reference for this order (required).
Expand All @@ -68,7 +68,7 @@ def purchase(money, credit_card, options = {})
# Capture authorized funds from a credit card.
#
# ==== Parameters
# * <tt>money</tt> - The amount to be captured. Either an Integer value in cents or a Money object.
# * <tt>money</tt> - The amount to be captured as anInteger value in cents.
# * <tt>authorization</tt> - The authorization string returned from the initial authorization.
def capture(money, authorization, options = {})
request = build_capture_request(:capture, money, authorization, options)
Expand All @@ -92,7 +92,7 @@ def void(authorization, options = {})
#
# ==== Parameters
#
# * <tt>money</tt> - The amount to be refunded. Either an Integer value in cents or a Money object.
# * <tt>money</tt> - The amount to be refunded as an Integer value in cents.
# * <tt>identification</tt> - The credit card you want to refund or the authorization for the existing transaction you are refunding.
# * <tt>options</tt>
# * <tt>:order_id</tt> - A unique reference for this order (required when performing a non-referenced credit)
Expand Down
10 changes: 4 additions & 6 deletions lib/active_merchant/billing/gateways/psl_card.rb
@@ -1,5 +1,3 @@
# Author:: MoneySpyder, http://moneyspyder.co.uk

module ActiveMerchant
module Billing
#
Expand Down Expand Up @@ -99,7 +97,7 @@ def initialize(options = {})
# Purchase the item straight away
#
# Parameters:
# -money: Money object for the total to be charged
# -money: Amount to be charged as an Integer value in cents
# -authorization: the PSL cross reference from the previous authorization
# -options:
#
Expand Down Expand Up @@ -127,7 +125,7 @@ def purchase(money, credit_card, options = {})
# is available and only 'reserves' the nominal amount (currently a pound and a penny)
#
# Parameters:
# -money: Money object for the total to be charged
# -money: Amount to be charged as an Integer value in cents
# -authorization: the PSL cross reference from the previous authorization
# -options:
#
Expand All @@ -151,7 +149,7 @@ def authorize(money, credit_card, options = {})
# Captures the funds from an authorized transaction.
#
# Parameters:
# -money: Money object for the total to be charged
# -money: Amount to be charged as an Integer value in cents
# -authorization: The PSL Cross Reference
# -options:
#
Expand Down Expand Up @@ -230,7 +228,7 @@ def add_purchase_details(post)
# however PSL requires the ISO 4217:2001 Numeric code.
#
# Parameters:
# -money: Money object with the amount and currency
# -money: Integer value in cents
#
# Returns:
# -the ISO 4217:2001 Numberic currency code
Expand Down
1 change: 0 additions & 1 deletion test/remote/gateways/remote_data_cash_test.rb
@@ -1,4 +1,3 @@
# Author:: MoneySpyder, www.moneyspyder.co.uk
require 'test_helper'

class RemoteDataCashTest < Test::Unit::TestCase
Expand Down
2 changes: 0 additions & 2 deletions test/remote/gateways/remote_psl_card_test.rb
@@ -1,5 +1,3 @@
# Author:: MoneySpyder, http://moneyspyder.co.uk

require 'test_helper'

class RemotePslCardTest < Test::Unit::TestCase
Expand Down

0 comments on commit 0ae2fd6

Please sign in to comment.