Activemerchat paypal integration is giving an error Missing required parameter: ip? - ruby-on-rails

I used the below code to test my sandbox credentials but am getting the error mentioned please help in resolving the issue
> require 'activemerchant'
> #gateway = ActiveMerchant::Billing::PaypalGateway.new(
:login "abc.cc#gmail.com,
password: "weret43435ersdfdg",
signature: "ertygdfcf343333#####frfterg")
> purchase = #gateway.purchase((10* 100),
:ip => '198.16.43.574',
:currency => "USD",
:payer_id => "2",
:token => "dsfddgfdgfdgfdgdf")
When i use the above code in irb am getting the following error
ArgumentError: Missing required parameter: ip
enter image description here

If you check the source code of ActiveMerchant here, it is expecting 3 params.
def purchase(money, credit_card_or_referenced_id, options = {})
requires!(options, :ip)
commit define_transaction_type(credit_card_or_referenced_id), build_sale_or_authorization_request('Sale', money, credit_card_or_referenced_id, options)
end
First one is the amount of money, second one is the credit card or reference id and the third one is a option, where it is expecting a required ip. As in your method call you are not passing any credit card reference, it's missing the ip from the option hash.

Related

rails activemerchant authorize.net problems

I have an Authorize.net account for CC processing on my ecommerce site, and I use ActiveMerchant to authoenticate transactions. It worked just fine until a while ago, and then it stopped. I cannot figure out why. When I run it in test mode, it works fine, creates the transactions and successfully authorizes the funds. But when I try with real account, it fails. When I run it from the console, here is the code:
cc_hash =
:first_name => 'Donald',
:last_name => 'Duck',
:number => '4007000000027',
:month => '8',
:year => Time.now.year+1,
:verification_value => '000'
}
card = ActiveMerchant::Billing::CreditCard.new(cc_hash)
#--- valid?
RYeller.bar
if card.valid?
puts "card valid"
else
puts "card not valid"
end
#ActiveMerchant::Billing::Base.mode = :test
#gateway = ActiveMerchant::Billing::AuthorizeNetGateway.new(:login=>'scrubbed',:password=>'scrubbed')
ActiveMerchant::Billing::Base.mode = :production
gateway = ActiveMerchant::Billing::AuthorizeNetGateway.new(:login=>'scrubbed',:password=>'scrubbed')
amount = rand(1000)+2500
options = {}
options[:order_id] = "WEBSITE 26"
options[:description] = 'WEBSITE TEST'
#--- authorize transaction
response = gateway.authorize(amount, card, options)
puts response.inspect
When I run this in test mode, in my sandbox account (the two lines commented out in the code above) - it works fine. When I run it on my real account (the code as is above) - I get an error: "An error occurred during processing. Call Merchant Service Provider." The full response hash is:
#<ActiveMerchant::Billing::Response:0x1078607d8 #fraud_review=false, #params={"response_reason_code"=>"35", "avs_result_code"=>"P", "transaction_id"=>"scrubbed", "response_code"=>2, "response_reason_text"=>"An error occurred during processing. Call Merchant Service Provider.", "card_code"=>"P"}, #message="An error occurred during processing. Call Merchant Service Provider", #authorization="scrubbed", #test=false, #cvv_result={"message"=>"Not Processed", "code"=>"P"}, #success=false, #avs_result={"message"=>"Postal code matches, but street address not verified.", "street_match"=>nil, "postal_match"=>"Y", "code"=>"P"}>
I am using a test CC number and the card.valid? test returns true.
When I look at the transaction in Authorize.net, I see all the transaction created and all the info properly there, but the Transaction Code is General Error.
Any ideas? Help greatly appreciated, I am at the end of my rope here and sinking fast.
Is your production Authorize.net in test mode? If not, Donanld Duck isn't going to be able to check out with a fake credit card.
You should be able to login to your production Authorize.net account and see the test order as a decline. If you do then everything is working and you will need to test with a real card to get a successful transaction. If you want to test with a fake card you will need to set you production account back to testing.

spree_chimpy:merge_vars:sync rake aborted

I am installing the gem spree_chimpy from https://github.com/watg/spree_chimpy in my Ruby on Rails application with spree. After doing mailchimp setup I am notifying mailchimp about merge_vars which seem to cause the error. When I run the command
rake spree_chimpy:merge_vars:sync --trace
I get the error "tag" must be 10 bytes and may only contain "A-Z 0-9 _. I don't understand the error, I have nowhere added any tag variable in the configuration. For reference, my config/initializers/spree_chimpy.rb is pasted here:
Spree::Chimpy.config do |config|
# your API key as provided by MailChimp
config.key = '<#my-api-hash-key>'
# extra api options for the Mailchimp gem
# config.api_options = { throws_exceptions: false, timeout: 3600 }
# name of your list, defaults to "Members"
config.list_name = 'test'
# Allow users to be subscribed by default. Defaults to false
# If you enable this option, it's strongly advised that your enable
# double_opt_in as well. Abusing this may cause Mailchimp to suspend your account.
# config.subscribed_by_default = false
# When double-opt is enabled, the user will receive an email
# asking to confirm their subscription. Defaults to false
config.double_opt_in = false
# id of your store. max 10 letters. defaults to "spree"
# config.store_id = 'acme'
# define a list of merge vars:
# - key: a unique name that mail chimp uses. 10 letters max
# - value: the name of any method on the user class.
# default is {'EMAIL' => :email}
config.merge_vars = {
'EMAIL' => :email,
'FNAME' => :fname,
'LNAME' => :lname,
'ORDERNUMBER' => :onumber
}
end
That error is being thrown is from somewhere around here:
https://github.com/watg/spree_chimpy/blob/7ba5d855112050e1b61c2d0a3369bc08f254842d/lib/spree_chimpy.rb#L59-L62
The actual error is within the mailchimp API client. You're getting the error because ORDERNUMBER has 11 characters in it. If you trim it down to 10 characters, you should be okay.

Rails ActiveMerchant - Paypal Express Checkout Error

I am getting this error when I call this code.
response = EXPRESS_GATEWAY.setup_purchase(order.price_in_cents,
:ip => request.remote_ip,
:return_url => url_for(:action => :create, :only_path => false),
:cancel_return_url => root_path
)
redirect_to EXPRESS_GATEWAY.redirect_url_for(response.token)
Error:
This transaction is invalid. Please return to the recipient's website to complete your transaction using their regular checkout flow.
To show I setup EXPRESS_GATEWAY correctly. code development.rb file.
config.after_initialize do
ActiveMerchant::Billing::Base.mode = :test
paypal_options = {
:login => '*****************************',
:password => '*************',
:signature => '*******************************************************'
}
::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options)
end
Gem file
gem 'activemerchant', :require => 'active_merchant'
So the login, password, and sig. were created in the sandbox are of paypal. So they should be working.
What should I try to get this error fixed. Or is this Paypal's side? Is there something wrong in the ActiveMerchant gem?
UPDATE 1
After inspecting the response var, this is what I get.
#<ActiveMerchant::Billing::PaypalExpressResponse:0x00000102402790 #params={"timestamp"=>"2012-06-29T01:30:18Z", "ack"=>"Failure", "correlation_id"=>"d1cb5dbb30425", "version"=>"72", "build"=>"3067390", "message"=>"CancelURL is invalid.", "error_codes"=>"10472", "Timestamp"=>"2012-06-29T01:30:18Z", "Ack"=>"Failure", "CorrelationID"=>"d1cb5dbb30425", "Errors"=>{"ShortMessage"=>"Transaction refused because of an invalid argument. See additional error messages for details.", "LongMessage"=>"CancelURL is invalid.", "ErrorCode"=>"10472", "SeverityCode"=>"Error"}, "Version"=>"72", "Build"=>"3067390"}, #message="CancelURL is invalid.", #success=false, #test=true, #authorization=nil, #fraud_review=false, #avs_result={"code"=>nil, "message"=>nil, "street_match"=>nil, "postal_match"=>nil}, #cvv_result={"code"=>nil, "message"=>nil}>
Any feedback is appreciated.
UDPATE 2
Turns out after looking at that message above, it was the cancelURL that was invalid, so I fixed that and presto!
Thanks.
This error is shown when you are not properly logged into the sandbox account on paypal's site.
Login to http://sandbox.paypal.com/
Open your site and checkout
When sent to paypal, login as one of your buyer test accounts

Troubleshooting Active Merchant returning "Failed with 500 Internal Server Error"

The following code
purchase = #order.authorize_payment(#credit_card, options)
is_success = purchase.success?
if is_success
...
else
flash[:notice] = "!! " + purchase.message + "" +
purchase.params['missingField'].to_s
redirect_to :action => :payment, :id => #order.id
end
results in "!! Failed with 500 Internal Server Error" in my flash[:notice]. There is no stacktrace, no webserver error, all that I know is that purchase.message is populated and purchase.success? is false.
I am really at a loss to figure out how to troubleshoot this. I think it might be an ssl requirement, but I can't either see the soap request, or test basic connectivity with cybersource (my payment gateway).
I establish my gateway with this code (after config.after_initialize do):
ActiveMerchant::Billing::Base.mode = :production # :test
ActiveMerchant::Billing::CreditCard.require_verification_value = false
ActiveMerchant::Billing::CyberSourceGateway.wiredump_device = File.new(File.join([Rails.root, "log", "cybersource.log"]), "a") # doesn't work (!)
# we need to open an external file to get the password
mypassphrase = File.open('/var/www/foo/shared/passphrase.txt').read
OrderTransaction.gateway = ActiveMerchant::Billing::CyberSourceGateway.new(:login => 'vxxxxxxx',
:password => mypassphrase.to_s,
:test => false,
:vat_reg_number => 'your VAT registration number',
# sets the states/provinces where you have a physical presense for tax purposes
:nexus => "GA OH",
# don‘t want to use AVS so continue processing even if AVS would have failed
:ignore_avs => true,
# don‘t want to use CVV so continue processing even if CVV would have failed
:ignore_cvv => true,
:money_format => :dollars
)
Can I see the soap request? Are there ways to test part of this? Any help greatly appreciated.
Best,
Tim
ActiveMerchant::Billing::CyberSourceGateway.logger = your_logger
So, late response but...
I've done a good amount of work with the Cybersource gateway, and the only way to see the SOAP request/response of the cybersource gateway currently is to open up the gem and edit it.
If you modify the commit method of lib/active_merchant/billing/gateways/cybersource.rb, you can do something like this:
def commit(request, options)
puts "*** POSTING TO: #{test? ? TEST_URL : LIVE_URL}"
request = build_request(request, options)
puts "*** POSTING:"
puts request
begin
post_response = ssl_post(test? ? TEST_URL : LIVE_URL, request)
rescue ActiveMerchant::ResponseError => e
puts "ERROR!"
puts e.response
end
puts post_response
It would be nice if there was a way to get that response without going through that hassle, I'll see if there's a way to pass that information up through the response object that's returned and add it to my fork.

Fail:(TESTMODE) Transactions of this market type cannot be processed on this system

I have created a test account with Authorize.net and am using ActiveMerchant to process
credit card payments for a website. What error I always get is Error#*87 - "Transactions of this market type cannot be processed on this system" mentioned in ActiveMerchant documentations. Any suggestions how to resolve this error ?
Following is how i created my gateway. I also checked gateway.test? and it returns true.
gateway = ActiveMerchant::Billing::Base.gateway(:authorized_net).new(
:login =>'API Login ID',
:password =>'Transaction Key',
:test => true)
Try
gateway = ActiveMerchant::Billing::AuthorizeNetGateway.new(
:login => 'API Login ID',
:password => 'Transaction Key',
:test => true)

Resources