I'm assuming you are running with -e test (or production.) Spree will
use the BogusGateway automatically in development mode (perhaps we
should change that default?) Are you sure the charge is being
authorized at AM? Please verify that the authorization is going
through.
If the authorization is going through then its possible there is a bug
in the Spree capture logic. It may also be possible that we are not
storing/sending the correct information to complete the capture. Keep
digging and let me know what you find.
If I don't hear back from you I will assume you are still stuck and
will try to look at it later today.
Regards,
Sean
Anyways, I made a local fix (which I'll commit later) and was able to
see the error coming back from Authorize.net
"Authorization Error: Gateway Error ... (TESTMODE) This account has
not been given the permission(s) required for this request."
I soon realized that I had the wrong value for the login. I was using
the account login instead of the API login. You must make sure that
your gateway is configured in the Spree admin interface to use the API
login and transaction id (not the same as your developer login and
password.) You can find this under Account | Settings on https://test.authorize.net
.
So after I made sure to use the correct api parameters I was able to
successfully authorize. Were you able to get this far? I seem to
remember at one point you had a problem capturing.
After the successful authorization I took a look at the transaction
information from the admin order details page. It shows a response
code of 0. I was pretty sure that was going to be a problem and sure
enough when I try to capture I get:
"Gateway Error ... (TESTMODE) A valid referenced transaction ID is
required."
I also noticed that the authorization is not listed in my "reports" on
the Authorize.net test account. Perhaps because this is test mode
they don't show up? I think that is the most likely reason. So I'll
do a little more digging and see what the deal is with the response
code, etc.
Regards,
Sean
Please file this as a bug (including the steps to reproduce.) If you
are still looking at fixing it, please indicate that in the comments.
Otherwise I'll take a look later this week.
Sean
Yes this part seems correct already. FYI, you can also force Spree to
run your configured gateway in development mode (instead of the bogus
one) by adding Spree::Gateway::Config.set(:use_bogus => false) in your
migrations.
> gateway_option :test - This determines whether the gateway (Production
> or Dev) is hit in "test" mode. I have not hit the production URL yet,
> so I can't say what happens there, but the Dev gateway will not return
> a transaction ID in "test" mode. This means that an AUTH can't be
> captured later because there is nothing to match it to. Hitting the
> Dev URL without the "test" option will return a transaction ID and the
> full cycle can be tested.
I fixed this (locally) in the manner you suggested. Are you sure you
are getting an actual transaction id? I stepped through with the
debugger and looked at the parsing logic. This is what I get in the
local fields array after parsing the response (http://gist.github.com/27081
)
transaction id is supposedly fields[6] which is 0. Don't confuse with
fields[7] which is the invoice number. Its a little frustrating that
this array is zero based but the lookup table on AIM starts at one.
In any event, the mapping in the a_m implementation for authorize.net
appears correct.
So it doesn't look like you get a transaction id at all under the
scenario you described.
> Mike
Sean
This is killing me. Still not seeing the transaction id.
> The one thing I may do differently than you, is I installed the latest
> AM plugin from Github. Although, I would be surprised if it didn't
> work with the latest gem.
I'll have to try this next. I checked the github source though and
there were no changes to the authorize.net file since January (and I'm
pretty sure the gem we're using was released after that point.)
> Two things to check-
>
> 1) Are you running the Test environment. Dev uses bogus by default.
> (I just did this accidentally myself.)
Yes. HINT: You can type 'Spree::Gateway::Config.set(:use_bogus =>
false)' in the console and this will disable as a preference and store
the setting in your db. I'm thinking we should add a checkbox to the
gateway configuration screen to allow this setting to be changed (and
easily viewed) in the admin interface.
> 2) Is the "test" gateway_option_value ROW deleted from the
> gateway_option_values table?
Yup. Did that already based on your earlier post.
> If those two items are correct, set a breakpoint on Line 232 of the
> authorize_net.rb file in the Active Merchant plug-in.
>
> Step over this line and then check the value of parameters
> [:test_request] if it is TRUE then you will not get a transaction
> ID. I had to delete the entire row in the gateway_option_values table
> to get this to read FALSE due to the logic in line 232.
Currently reading "FALSE"
Just curious but why would you want to run in test mode? Are you
trying to test your production account API stuff? That's about the
only (and very limited) use I can think of this mode.
> When hitting the test url in live mode the Authorize.net test card
> number (4222222222222), did not generate the expected response codes.
> It only generates the expected response codes when in "test mode".
> But, as we know, in test mode the transaction IDs are not returned, so
> both are necessary.
I think you want 4111111111111111. I'm not sure if your number is
valid (which would explain the response codes.)
> I imagine I will be hitting the test server in live mode the majority
> of the time. The response code error handling appears solid.
So you are still confirming that the response code works with the test
URL, test API credentials and no "test" gateway option? This is what
I am still trying to reproduce (will try the latest plugin code now.)
> Mike
Sean
Turns out there is the test URL, test mode (at the account level) as
well as test parameters that you can POST via the active_merchant
plugin/gem. Seems a little redundant if you ask me. I mean, I'm
already posting to the Test URL, isn't that enough? I guess the test
mode at the account level is useful for testing that the production
credentials are set up properly and they are just mirroring that in
the test account.
So now everything works fine. Transaction ID is received and order is
posted to Authorize.net test account.
Sean