How do I go about making a donation script, and which host would be the best for my site.
2 replies, posted
Two questions, first is I want to go about making a donation script in php. One that will direct you to paypal after submitting the amount, then receive a message(to my database) when it is confirmed paid to the account. This way I can have an automated donation system that can update other stuff on the website and game for donators without me needing to confirm it. I wanna know how the process works, is it simple or is it more complex, and do they have template type scripts out for this already or is something that needs some more personal work.
The second question would be, what would be the best host for my website? All the site will have is a blog, a few single pages for information/pictures, and a forums. Not too much, but I want to make sure I get a good host. Last time we did this I had to contact the host a few times to have them set a couple setting for my site I didn't have access to so I could get the previous donation script working.
I don't know much about php, it's not my strong point. But I just need as much information on these two things as I can get as these are just as crucial as the rest of the project. And I want to make sure they are done right and not tooo sloppy haha.
This is probably what you're looking for:
[url]https://www.paypal.com/cgi-bin/webscr?cmd=_dcc_hub-outside[/url]
I've never integrated paypal into my sites so I can't give you any examples of implementations. It would probably work along the following line: get input from user, sanitize input, post to paypal api, wait for a response, once response received render a page accordingly. Since paypal would send you a response you could use that response in your site. IE, they said the transaction was successfully processed? Then you can take the user's input amount and add it to your donation.
[code]
class TransactionsController < ApplicationController
include ActiveMerchant::Billing::Integrations
load_and_authorize_resource except: :ipn
def new
@denominations = Transaction::DENOMINATIONS
end
def create
@denominations = Transaction::DENOMINATIONS
@transaction = Transaction.new params[:transaction]
@transaction.user = current_user
if @transaction.save
@callback_domain = AppConfig[:public_url]
@return_domain = AppConfig[:site_url]
render "create"
else
@errors = @transaction.errors.full_messages
render "new"
end
end
def ipn
notify = Paypal::Notification.new request.raw_post
txn = Transaction.find notify.item_id
if notify.acknowledge && notify.complete?
txn.paypal_transaction_id = notify.transaction_id
txn.save
txn.user.credit += Money.new (BigDecimal.new(params[:mc_gross]) * 100).to_i
txn.user.save
end
render nothing: true
end
end
[/code]
Sorry, you need to Log In to post a reply to this thread.