Simple Payments
Optional NodePremium Content - Free Preview
A basic feature that's missing from the site is the ability to buy things! If you want to add a simple way for users to buy things on your site, keep reading. (You can skip this section if you don't want to accept real money on your site right now!)
There are many payment services that integrate with your site's backend, but it's better to push off handling actual payment processing until you have some more experience! Instead, you can add a Paypal button so people can buy items on your store, and Paypal will notify you when purchases happen. In the future, you can integrate a payment service like Braintree (a subsidiary of Paypal) into your site.
First, you'll need to Signup for a basic merchant account on Paypal.
Once you've setup your account, you can go to Paypal Button management to create or edit Paypal buttons. You could use their forms to create buttons for a specific item, but it would make more sense to use one button template for your products that will automatically use the correct name and price. To do this, copy the following code and paste it into your product show page:
<form name="_xclick" action="https://www.paypal.com/us/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="[email protected]">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="item_name" value="<%[email protected]%>">
<input type="hidden" name="amount" value="<%[email protected]%>">
<input type="image" src="https://www.paypalobjects.com/webstatic/en_US/i/buttons/buy-logo-medium.png" border="0" name="submit" alt="Buy now with PayPal">
</form>
This uses a Paypal HTML button form, but replaces the name and price with Ruby code to get the name and price of the current @product
. Replace the above email with the email you used for your Paypal account. You can also adjust other values. See the Paypal logo button page for other images for your button.
End of Free Content Preview. Please Sign in or Sign up to buy premium content.