# ActiveMerchant, Authorize.net and Email Receipts

**URL:** <https://www.ruby-forum.com/t/activemerchant-authorize-net-and-email-receipts/185573>\
**Category:** Rails\
**Created:** [March 23, 2010, 12:14am UTC](https://www.ruby-forum.com/t/activemerchant-authorize-net-and-email-receipts/185573 "2010-03-23T00:14:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aawilson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@aawilson](https://www.ruby-forum.com/u/aawilson)\
**Post date:** [March 23, 2010, 12:14am UTC](https://www.ruby-forum.com/t/activemerchant-authorize-net-and-email-receipts/185573/1 "2010-03-23T00:14:09Z")

</div>

I’ve posted this on [RailsForum.com](http://RailsForum.com) and in the ActiveMerchant talk  
group, and haven’t received an answer, so I figure I’ll try here.

Hello. I’ve been searching for information on this for a while, but my  
google fu is evidently weak–hardly anyone even talks about email  
receipts re: ActiveMerchant, much less my specific problem.  
In any case, I have a client whose customers, we had just discovered,  
had not been receiving email receipts from [Authorize.net](http://Authorize.net). All was  
correct on the [Auth.net](http://Auth.net) config–what I discovered was that my app was  
not sending the customer email. I fixed this problem, but it didn’t  
fix the issue–even though the email was getting sent, using the  
options hash in AuthorizeNetGateway#purchase, [Authorize.net](http://Authorize.net) was still  
not sending receipts. I investigated further, and found this in the  
ActiveMerchant code:

BEGIN RUBY

module ActiveMerchant #:nodoc:  
module Billing #:nodoc:  
class AuthorizeNetGateway \< Gateway

…snip…

def add\_customer\_data(post, options)  
if options.has\_key? :email  
post[:email] = options[:email]  
post[:email\_customer] = false  
end

```
    if options.has_key? :customer
      post[:cust_id] = options[:customer]
    end

    if options.has_key? :ip
      post[:customer_ip] = options[:ip]
    end
  end

```

…etc…

END RUBY

add\_customer\_data is called within purchase to process its options  
hash. My question is in reference to the line that processes the email  
key: Why on earth does it, after checking to see if the email entry  
exists, set customer\_email explicitly to false? Why is this not based  
on some sort of configurable option, or just let alone ([Authorize.net](http://Authorize.net)  
will check the merchant-set options if no customer\_email field is  
sent)? It’s remarkably puzzling, so if any of you fine fellows knows  
the answer, please let me know.

Cheers,  
A. Wilson

---

<div class="post-metadata">

**Author:** ![aawilson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@aawilson](https://www.ruby-forum.com/u/aawilson)\
**Post date:** [March 27, 2010, 1:31am UTC](https://www.ruby-forum.com/t/activemerchant-authorize-net-and-email-receipts/185573/2 "2010-03-27T01:31:45Z")

</div>

I didn’t have the time to sit down and work out overriding it, but  
it’s a good idea, and Ruby definitely supports the paradigm, so I’ll  
probably do that. And, yeah, who knows, maybe I’ll even go in with a  
patch. Thanks for the response!

Cheers,  
AW

---

<div class="post-metadata">

**Author:** ![aawilson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@aawilson](https://www.ruby-forum.com/u/aawilson)\
**Post date:** [March 23, 2010, 2:02pm UTC](https://www.ruby-forum.com/t/activemerchant-authorize-net-and-email-receipts/185573/3 "2010-03-23T14:02:02Z")

</div>

> add\_customer\_data is called within purchase to process its options  
> hash. My question is in reference to the line that processes the email  
> key: Why on earth does it, after checking to see if the email entry  
> exists, set customer\_email explicitly to false?

No idea, probably either it was easier, it wouldn’t fit with their  
gateway api (i.e. other vendors might not have that functionality), it  
worked for them at the time.

Have you tried overriding it in your own app? You could always submit a  
patch to  
[https://jadedpixel.lighthouseapp.com/projects/11599-active-merchant/tickets](https://jadedpixel.lighthouseapp.com/projects/11599-active-merchant/tickets)

🙂

Cheers  
Luke
