I think I have it figured out. It looks like there is more than one
instance of the Gateway::AuthorizeNetCim object involved, with the
caller method instantiating one of them to use the authorize instance
method like a class method (without relying on any instance
variables). This appears to be why my instance variable was out of
scope.

Tracking down the caller code was sound advice, thank you! I was
puzzled for a long time with this one.

Pete

-----caller method-----

def authorize(amount, payment)
    # ActiveMerchant is configured to use cents so we need to multiply
order total by 100
    payment_gateway = payment.payment_method
    check_environment(payment_gateway)
    logger.debug("creditcard#authorize\n" )
    response = payment_gateway.authorize((amount * 100).round, self,
gateway_options(payment))



On Dec 11, 3:55  夨ı  <jgabrielyga... / gmail.com>
wrote:
> On Sun, Dec 11, 2011 at 1:16 AM, Cleverlemming <cleverlemm... / gmail.com> wrote:
> > Hail Caesars!
>
> > I'm wondering why the instance variable "@spree_invoice_number" is out
> > of scope in both the authorize and the create_transaction methods in
> > the appended code. Both of the aforementioned methods are called after
> > the create_profile method, where the instance variable is
> > initialized.  checked to make sure the instance variable name is
> > unique in both the application and the gem repository.
>
> > Thanks in advance for any suggestions!
>
> Can you show the caller code? From your description and the code,
> everything looks good.
> Can you try with a simpler version of your class:
>
> class Gateway::AuthorizeNetCim < Gateway
> attr_accessor :spree_invoice_number
>
> def authorize(amount, creditcard, gateway_options)
> logger.debug("variable is: #{@spree_invoice_number}")
> end
>
> def create_profile payment
> @spree_invoice_number = 42
> end
> end
>
> Jesus.