summaryrefslogtreecommitdiff
path: root/billing/app/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'billing/app/helpers')
-rw-r--r--billing/app/helpers/braintree_helper.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/billing/app/helpers/braintree_helper.rb b/billing/app/helpers/braintree_helper.rb
index 3d6e887..bc78c02 100644
--- a/billing/app/helpers/braintree_helper.rb
+++ b/billing/app/helpers/braintree_helper.rb
@@ -7,6 +7,7 @@ module BraintreeHelper
super
@braintree_params = @options[:params]
@braintree_errors = @options[:errors]
+ @braintree_existing = @options[:existing]
end
def fields_for(record_name, *args, &block)
@@ -31,6 +32,19 @@ module BraintreeHelper
def determine_value(method)
if @braintree_params
@braintree_params[method]
+ elsif @braintree_existing
+
+ if @braintree_existing.kind_of?(Braintree::CreditCard)
+
+ case method
+ when :number
+ method = :masked_number
+ when :cvv
+ return nil
+ end
+ end
+
+ @braintree_existing.send(method)
else
nil
end