Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7883117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:26:54+00:00 2026-06-03T04:26:54+00:00

I have a model Payment , use to track credit card transactions. Now I’m

  • 0

I have a model Payment, use to track credit card transactions. Now I’m trying to get it to map some values that PayPal returns on a successful credit card transaction. This is handled by a notify = ActiveMerchant::Billing::Integrations::Paypal::Notification.new(raw_post) (phew that was long)

However, the method I wrote does not work in Console. Yet if I assigned them directly, it works.

e.g. Rails Console

notify = ActiveMerchant::Billing::Integrations::Paypal::Notification.new(raw_post)
# Works
payment = Payment.new    
payment.raw_response = notify.raw
save! # Save is successful

# Does not work
payment = Payment.new
payment.map_paypal_return(notify) # save! call in this method does not trigger errors.

Please take a look at my class.

class Payment < ActiveRecord::Base
  belongs_to :order


  def map_paypal_return(notify)
    puts "in mapping" => Outputted
    raw_response = notify.raw
    payment_status = notify.status

    order_identifier = notify.item_id # Map ID to ID as a safety check bah.

    payer_email = notify.params["payer_email"]
    receiver_account = notify.account
    auth_mode = notify.params["payment_type"]

    transaction_identifier = notify.invoice
    currency = notify.currency
    amount = notify.gross
    puts self.attributes # Returns attributes without the above assignments

    save! # No errors triggered =(
  end
end

Method call in Console

1.9.2p318 :032 > notify.invoice # This should have been mapped to transaction_identifier
 => "2012-146" 

1.9.2p318 :031 > p.map_paypal_return(notify)
in mapping
{"id"=>nil, "order_id"=>nil, "order_identifier"=>nil, "card_holder_name"=>nil, "auth_mode"=>nil, "amount"=>nil, "amount_string"=>nil, "currency"=>nil, "merchant_reference"=>nil, "transaction_identifier"=>nil, "status"=>nil, "other_errors"=>nil, "received_date"=>nil, "deleted"=>nil, "created_at"=>nil, "updated_at"=>nil, "state"=>"checkout", "payment_type"=>nil, "raw_response"=>nil, "receiver_account"=>nil, "payer_email"=>nil}
  SQL (47.4ms)  INSERT INTO "payments" ("amount", "amount_string", "auth_mode", "card_holder_name", "created_at", "currency", "deleted", "merchant_reference", "order_id", "order_identifier", "other_errors", "payer_email", "payment_type", "raw_response", "received_date", "receiver_account", "state", "status", "transaction_identifier", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)  [["amount", nil], ["amount_string", nil], ["auth_mode", nil], ["card_holder_name", nil], ["created_at", Sat, 05 May 2012 20:32:33 SGT +08:00], ["currency", nil], ["deleted", nil], ["merchant_reference", nil], ["order_id", nil], ["order_identifier", nil], ["other_errors", nil], ["payer_email", nil], ["payment_type", nil], ["raw_response", nil], ["received_date", nil], ["receiver_account", nil], ["state", "checkout"], ["status", nil], ["transaction_identifier", nil], ["updated_at", Sat, 05 May 2012 20:32:33 SGT +08:00]]
 => true 

I don’t know if I made a silly fundamental misunderstanding of Ruby/Rails somewhere. Greatly appreciate the help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T04:26:56+00:00Added an answer on June 3, 2026 at 4:26 am

    I notice you have in your map_paypal_return method

    raw_response = notify.raw
    

    when raw_response is one of the object attributes. To assign an ActiveRecord-supplied attribute inside a method of the respective class, you need to do

    self.raw_response = notify.raw
    

    And similarly for the other assignments to attributes in the method.

    This is a limitation of ruby. The attribute methods are implemented by defining the attribute= method (e.g. raw_response=), and without a qualifier (obj. or self.) ruby assumes the statement is just a local variable assignment.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a credit card class and I'd like to use the simple_form f.input
I am trying to get communicate to a payment processor. When I use XmlSerializer.Serialize
We have the following model: payment.rb: class Payment < ActiveRecord::Base has_many :currencies default_scope :include
I have model Article it has field title with some text that may contain
I have a Payment Model which is polymorphic on activities class Payment belongs_to :activity,
I am trying to set expectations on a mocked ActiveRecord model. I have created
I have a model like this. #models.py class Payment(models.Model): unit_price = models.DecimalField(max_digits=12, decimal_places=2) discount
I have a model Invoice with attribute payment_status. payment_status has fixed values unpayed|partial_payed|payed that
I have a coupon system, and I'm trying to get the coupon object with
I am trying to use the localization features in cakephp. In app_model.php I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.