paypal subscription with RoR

Hi all

What i want to do is that I want to integrate my site with paypal (which i have already done) but the problem i m facing is that i have a email address field which i m getting from the user..now after the user fills out the detail and click on subscribe it will be redirected to paypal site for making payment..

Now the problem here is that i want to store the email in my db once the payment is successfully done so that i can come to know that who has actually paid for the subscription..

So has any one implemented this? IF so pls send me the code..I need to do it..

Thanks a lot

Not sure if this is exactly what you're after, but I have a site that does payment and donation processing on PayPal, and when the user comes back from PayPal, there is a boat load of params sent back. One of them is the email address the payer used on PayPal.

Peace, Phillip

Phillip Koebbe wrote:

Now the problem here is that i want to store the email in my db
once the payment is successfully done so that i can come to know that who has actually paid for the subscription..

So has any one implemented this? IF so pls send me the code..I need to do it..

Not sure if this is exactly what you're after, but I have a site that does payment and donation processing on PayPal, and when the user comes back from PayPal, there is a boat load of params sent back. One of them is the email address the payer used on PayPal.

Peace, Phillip

yes i guess its the same i want the paypal site to redirect back to my site and then store the email address in the db..

can u pls provide me the code..and ur site url so that i can clear out the concept..

I would be really thankful if u can do the same

thanks a lot

dhaval parikh

Roger Pack wrote:

Look up activemerchant integrations?

there r number of plugins which i have seen but wat i guess is that the code provide by paypal for the devt can also do the trick directly..

Have you implemented active merchant plugin??

When you submit the form to PayPal, you need to include "return" and "cancel_return" so PayPal knows where to send the user once they're either finished or cancel the process. The successful return is done by a button on the PayPal side and it makes a POST to your "return" URL, so that truckload of parameters is not visible to the naked eye. I believe there is a setting in your PayPal account that can disable that part of it. It's been a month or two since I coded that.

The site isn't live just yet, so I can't give out the URL. But all of this is in the documentation for interacting with PayPal's Web Payments Standard (I think that's what it's called).

Phillip

+1 for ActiveMerchant It was developed by/for the Shopify guys and is more than adequate for the job.

And since we're talking about paypal subscriptions here this might be useful:

http://talklikeaduck.denhaven2.com/articles/2007/09/02/how-to-cure-the-paypal-subscription-blues

yes thats wat i want but i m not able to find out that how it will return to my site once the payment is done..Can u send me the complete code for paypal and RoR so that i can implement is by making necessary changes in my application??

Hello,

You can do that :

Here's my sharing script /models/order.rb:

def process if clossed? raise "Order is closed"

begin process_with_active_merchant rescue => e logger.errror("Order #{id} faild with errir message #{e}") self.error_message = "Error while processing order" self.status = "failed" end save! self.status == 'processed'

end

def process_with_active_merchant Base.gateway_mode = :test

gateway = PayPalGateway.new( :login => 'business_account_login', :password => 'business_account_password', :cert_path => File.join(File.dirname(_FILE_), "../../config/paypal"))

gateway.connection.wiredump_dev = STDERR

creditcard = CreditCard.new(

...

)

#Buyer Information

params = {

:order_id => self.id :email => email, :address => { ..bla..bla..bla.}, :description => 'Books', :ip => customer_ip

}

response = gateway.purchase(total, creditcard, params)

if response.success? self.status = 'processed' # put your script here to save customer email and information else   self.error_message = responce.message   self.status ='failed' end

end

yeh thats perfect when we implement active merchant..but i guess paypal gives direct facility using their own code to redirect to our site and then we just need to call one method by which the details filled in will be inserted to the db.

something like the one u have give

on_successful_payment do

{ blah blah }

I think you not read my script carefully, see this :

#Buyer Information

params = {

:order_id => self.id :email => email, :address => { ..bla..bla..bla.}, :description => 'Books', :ip => customer_ip

}

response = gateway.purchase(total, creditcard, params)

if response.success? self.status = 'processed' # put your script here to save customer email and information else

Look to my comment area, What i give you is how to process order using PayPal API, once transaction success, paypal will respond back to your website and store it to your database, even your customer's credit card if your customer is new customer in paypal.

If they are existing customer in paypal, your customer only uses email and their paypal login. After order complete, their login will be sent back to you. But customer detail like address, bank account and credit card in paypal can not be sent back to you because it is already recorded in paypal.

If you are PHP expert, you can use curl php to hack PayPal so you can exploit or show all your customer's detail (bill addr, acct, and card info) using their login only. It's easy as long as paypal doesnt know what you do or they will patch your way.