Trying to use with Paypal adaptive payments

689 views
Skip to first unread message

planon

unread,
May 10, 2011, 2:38:19 PM5/10/11
to Active Merchant
I am new to ActiveMerchant and trying to set it up to split payment
between multiple sellers, using Paypal adaptive payments. This thread
was very helpful in that regard:

http://groups.google.com/group/activemerchant/browse_thread/thread/165c3e0bf4d10c02/bbec1d565ada11aa?lnk=gst&q=adaptive+payments#bbec1d565ada11aa

I merged the current version of ActiveMerchant with Scott's fork, but
now I'm stuck with a whiny_nils bug that won't go away. Here is the
backtrace:

undefined method `strip' for nil:NilClass

Rails.root: /Users/newuser/Dropbox/Xperiments/Ruby/activemerchant
Application Trace | Framework Trace | Full Trace

activesupport (3.0.3) lib/active_support/whiny_nil.rb:48:in
`method_missing'
../lib/ruby/1.9.1/net/http.rb:1296:in `block in
initialize_http_header'
../lib/ruby/1.9.1/net/http.rb:1294:in `each'
../lib/ruby/1.9.1/net/http.rb:1294:in `initialize_http_header'
../lib/ruby/1.9.1/net/http.rb:1662:in `initialize'
../lib/ruby/1.9.1/net/http.rb:1779:in `initialize'
../lib/ruby/1.9.1/net/http.rb:970:in `new'
../lib/ruby/1.9.1/net/http.rb:970:in `post'
../bundler/gems/active_merchant-4cee3005f3b4/lib/active_merchant/
common/connection.rb:69:in `block (2 levels) in request'

planon

unread,
May 10, 2011, 3:51:27 PM5/10/11
to Active Merchant
Trying to monkeypatch the Net class, but it's not working.



On May 10, 2:38 pm, planon <spockspla...@gmail.com> wrote:
> I am new to ActiveMerchant and trying to set it up to split payment
> between multiple sellers, using Paypal adaptive payments. This thread
> was very helpful in that regard:
>
> http://groups.google.com/group/activemerchant/browse_thread/thread/16...

planon

unread,
May 10, 2011, 3:54:59 PM5/10/11
to Active Merchant

sijokg

unread,
May 12, 2011, 8:52:13 AM5/12/11
to Active Merchant
Hi

You can clone
https://github.com/sijokg/active_merchant
Contains Paypal adaptive account and Paypal adaptive payment
apis .Tested in 1.8.7 ruby. Have to complete tests

planon

unread,
May 13, 2011, 2:08:48 PM5/13/11
to Active Merchant
Hey sijokg,

Thank you for the response. Quick question -- I'm making payments to 2
parties in the sandbox, but at the checkout page only one of them is
getting listed.

http://cl.ly/6jGK

I checked both accounts to make sure the money gets distributed
properly, and it does, but you only see one of their names at
checkout.

Do you know how I could get both of them on that panel?

thanks again!

sijokg

unread,
May 14, 2011, 2:37:24 AM5/14/11
to Active Merchant
Hi
There is at most one primary receiver and 1-5 secondary receivers.
Are you specifying about primary receiver here?

planon

unread,
May 14, 2011, 3:00:15 AM5/14/11
to Active Merchant
I have one primary receiver and one secondary receiver. I just adapted
the demo code in the source code basically.

# gateway.pay [1000, 'fr...@example.com'],
# [2450, 'wi...@example.com', :primary => true],
# [2000, 'bar...@example.com'],
# :sender_email => "jo...@example.com",
# :return_url => "http://example.com/return",
# :cancel_url => "http://example.com/cancel"


What I'd like to happen is to see both wilma and barney in the list of
recipients. Maybe there is a way?

sijokg

unread,
May 16, 2011, 4:36:32 AM5/16/11
to Active Merchant
Hi
If you use the Pay api, by paypal behavoiur what you see is
primary receiver info. Example Business Name for primary receiver. To
customize checkout page header you can use SetPaymentOptions API
operation. By using it you can specify headerImageUrl and
businessName. These values will allow you to change header image and
text displayed in the header (You can contact paypal developer team
for more details) . In my plugin extension i have not added code for
SetPaymentOptions. But you can easily extend it to "active_merchant/
lib/active_merchant/billing/gateways/paypal_adaptive_payment.rb".


On May 14, 12:00 pm, planon <spockspla...@gmail.com> wrote:
> I have one primary receiver and one secondary receiver. I just adapted
> the demo code in the source code basically.
>
>       #   gateway.pay [1000, 'f...@example.com'],
>       #     [2450, 'wi...@example.com', :primary => true],
>       #     [2000, 'bar...@example.com'],
>       #     :sender_email => "j...@example.com",

planon

unread,
May 16, 2011, 11:46:34 PM5/16/11
to Active Merchant
Hi sijokg,

Thanks to your help I'm almost there. I wonder if you are implementing
the IPN notification url, as well. The problem I'm seeing now is after
I return from Paypal, the hits to the IPN url are failing with the
following error:

> Started POST "/checkout/complete?id=1&amount=3445&authenticity_token=NkOwgJ1H2TEmwO6T+hROu96kWr4yGcTzHD6MbTswgyU="
> ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):

I'm just passing the authenticity_token of the user form as part of
the ipn_notification_url. Apparently, that's not valid. I wonder if
there is another way to do this... :(

sijokg

unread,
May 17, 2011, 12:10:04 AM5/17/11
to Active Merchant
To the Pay api options you can pass ipnnotification url
like :ipn_notification_url => paypal_ipn_url(:secret =>
APP_CONFIG[:paypal_secret]). I dont know why you are passing
authenticity token. If it for security you can refer the railscasts by
Ryan
http://railscasts.com/episodes/143-paypal-security and pass secret
like above. It is set as configuration in config/app_config.yml

Sijo

planon

unread,
May 17, 2011, 1:13:55 AM5/17/11
to Active Merchant
I'm using signature, rather than the certificate, but I think I found
the answer from one of the tutorials. Adding this:

> protect_from_forgery :except => [:complete]

..makes the invalid authenticity token error go away. It's working
now!

Thank you so much for your help! :)



On May 17, 12:10 am, sijokg <sijovenn...@gmail.com> wrote:
>   To the Pay api options you can pass ipnnotification url
> like   :ipn_notification_url => paypal_ipn_url(:secret =>
> APP_CONFIG[:paypal_secret]). I dont know why you are passing
> authenticity token. If it for security you can refer the railscasts by
> Ryanhttp://railscasts.com/episodes/143-paypal-securityand pass secret
Reply all
Reply to author
Forward
0 new messages