spree_paypal_express/README.md

153 lines
5.9 KiB
Markdown
Raw Permalink Normal View History

# Official PayPal Express for Spree
2012-12-02 12:01:19 +00:00
[![Build Status](https://secure.travis-ci.org/spree/spree_paypal_express.png?branch=1-2-stable)](http://travis-ci.org/spree/spree_paypal_express)
2012-07-20 11:14:57 +00:00
This is the official PayPal Express extension for Spree, based on the extension by PaulCC it has been extended to support Spree's
Billing Integrations which allows users to configure the PayPal Express gateway including API login / password and signatures fields
via the Admin UI.
This extension allows the store to use PayPal Express from two locations:
1. Checkout Payment - When configured the PayPal Express checkout button will appear alongside the standard credit card payment
options on the payment stage of the standard checkout. The selected shipping address and shipping method / costs are automatically
sent to the PayPal review page (along with detailed order information).
2012-12-02 11:58:55 +00:00
2012-11-12 03:18:37 +00:00
2. Cart Checkout* - Presents the PayPal checkout button on the users Cart page and redirects the user to complete
2012-12-02 11:58:55 +00:00
all shipping / addressing information on PaypPal's site. This also supports PayPal's Instant Update feature to retrieve shipping options live from
2011-01-25 11:30:18 +00:00
Spree when the user selects / changes their shipping address on PayPal's site.
2012-11-12 03:18:37 +00:00
* Check "Checkout from cart" in admin for feature to work
This extension follows the documented flow for a PayPal Express Checkout, where a user is forwarded to PayPal to allow them to login and review
the order (possibly select / change shipping address and method), then the user is redirected back to Spree to confirm the order. The user
2010-05-24 09:51:04 +00:00
MUST confirm the order on the Spree site before the payment is authorized / captured from PayPal (and the order is transitioned to the New state).
2011-01-25 11:33:54 +00:00
2012-12-02 12:13:46 +00:00
## Installation
2011-01-25 11:33:54 +00:00
1. Add the following line to your application's Gemfile
2012-12-02 12:01:19 +00:00
gem 'spree_paypal_express', :git => 'git://github.com/spree/spree_paypal_express.git', :branch => '1-2-stable'
2. Install the gem using Bundler:
2012-12-02 11:58:55 +00:00
bundle install
2011-01-25 11:33:54 +00:00
3. Copy & run migrations
2011-01-25 11:33:54 +00:00
2012-12-02 11:58:55 +00:00
bundle exec rails g spree_paypal_express:install
2012-12-02 12:13:46 +00:00
## Versions
To determine the correct version of this extension, please refer to the Versionfile.
2011-01-25 11:33:54 +00:00
2012-12-02 12:13:46 +00:00
## IPN & eCheck Support
2011-01-25 11:30:18 +00:00
eCheck payments are now fully supported and PayPal's Instant Payment Notification service is also supported for receiving updates relating to eCheck payments only. To configure eCheck payments you'll need to:
2010-05-24 09:51:04 +00:00
1. Configure your PayPal account to accept eCheck payments (under Profile on PayPal's website).
2010-05-24 09:51:04 +00:00
2. Set the IPN URL on your PayPal account (under Profile on PayPal's website) to:
2011-01-25 11:30:18 +00:00
2012-12-02 12:13:46 +00:00
https://www.yourstore.com/paypal_notify
2011-01-25 11:30:18 +00:00
3. Enable auto_capture within Spree (as eCheck payments are only supported for purchase and not authorize requests).
2011-01-25 11:30:18 +00:00
2012-12-02 11:58:55 +00:00
Spree::Config.set(:auto_capture => true)
**Please note if you accept foreign currency:**
2011-01-25 11:30:18 +00:00
Auto Capture will only work if you configure your Paypal Store like so:
Profile > My Selling Tools > Payment Receiving Preferences >
(this workflow may vary as Paypal updates their UI from time to time)
Block payments sent to me in a currency I do not hold:
[ ] Yes
[x] No, accept them and convert them to [Your Default Currency]
[ ] Ask Me
2011-01-25 11:30:18 +00:00
2012-12-02 12:13:46 +00:00
## Configuration
1. Before you begin
2012-12-02 11:58:55 +00:00
2011-01-25 11:30:18 +00:00
You'll need to have a Paypal developer account (developer.paypal.com) and both buyer and seller test accounts.
2012-12-02 11:58:55 +00:00
2011-01-25 11:30:18 +00:00
**Tip:** these are sandbox only, so use email addresses and passwords that are easy to remember, e.g. buyer@example.com and seller@example.com.
2012-12-02 11:58:55 +00:00
2011-01-25 11:30:18 +00:00
Your sandbox credentials are available from the API Credentials link.
2. Setup the Payment Method
2012-12-02 11:58:55 +00:00
2011-01-25 11:30:18 +00:00
Log in as an admin and add a new **Payment Method** (under Configuration), using following details:
**Name:** Paypal Express
2012-12-02 11:58:55 +00:00
2011-01-25 11:30:18 +00:00
**Environment:** Development (or what ever environment you prefer)
2012-12-02 11:58:55 +00:00
2011-01-25 11:30:18 +00:00
**Active:** Yes
2012-12-02 11:58:55 +00:00
2012-02-21 15:49:17 +00:00
**Provider:** Spree::BillingIntegration::PaypalExpress
2012-12-02 11:58:55 +00:00
2011-01-25 11:30:18 +00:00
Click **Create* , and now add your credentials in the screen that follows:
2012-12-02 11:58:55 +00:00
2011-01-25 11:30:18 +00:00
**Review:** unchecked [1]
2012-12-02 11:58:55 +00:00
2011-01-25 11:30:18 +00:00
**Signature:** API signature from your paypal seller test account
2012-12-02 11:58:55 +00:00
2011-01-25 11:30:18 +00:00
**Server:** test (for Development or live for Production)
2012-12-02 11:58:55 +00:00
2011-01-25 11:30:18 +00:00
**Test Mode:** checked (or unchecked for Production)
2012-12-02 11:58:55 +00:00
2011-01-25 11:30:18 +00:00
**Password:** API Password from your paypal seller test account
2012-12-02 11:58:55 +00:00
2011-01-25 11:30:18 +00:00
**Login:** API Username from your paypal seller test account (care to use the API Username and not the Test Account address)
2012-12-02 11:58:55 +00:00
2011-01-25 11:30:18 +00:00
Click **Update**
2010-05-24 09:51:04 +00:00
2012-12-02 12:13:46 +00:00
## Test Drive
2010-05-24 09:51:04 +00:00
2011-01-25 11:30:18 +00:00
While testing PayPal Express checkout locally make sure you're logged into your PayPal **developer** account in another browser window before attempting a PayPal payment, as you'll be redirected and forced to sign in to your developer account.
1. Add an item to cart
2012-12-02 11:58:55 +00:00
2011-01-25 11:30:18 +00:00
2. Check out
2012-12-02 11:58:55 +00:00
2011-01-25 11:30:18 +00:00
3. Address step: complete it using a valid US address.
2012-12-02 11:58:55 +00:00
2011-01-25 11:30:18 +00:00
4. Delivery step: pick anything
2012-12-02 11:58:55 +00:00
2011-01-25 11:30:18 +00:00
5. On the Payment Step, you should see a PayPal button. You can select it directly or just click "Continue"
2012-12-02 11:58:55 +00:00
6. You will get redirected to PayPals sandbox site, be sure to log in as a **Buyer** / **Personal** test account and not the account you use to configure the Payment Method with.
2011-01-25 11:30:18 +00:00
7. You should now see the paypal order details screen with a Pay Now button.
2012-12-02 11:58:55 +00:00
2011-01-25 11:30:18 +00:00
8. Click Pay Now, and you should now be redirected back to Spree's order thank you page.
2012-12-02 11:58:55 +00:00
2011-01-25 11:30:18 +00:00
9. Log into the Admin UI and review the Order and Payment details to confirm the successful checkout.
2010-05-24 09:51:04 +00:00
2012-12-02 12:13:46 +00:00
## Running Specs
2011-01-25 11:30:18 +00:00
1. Create Test App
2011-01-25 11:30:18 +00:00
2012-12-02 11:58:55 +00:00
rake test_app
2011-01-25 11:30:18 +00:00
2. Run Specs
2011-01-25 11:30:18 +00:00
2012-12-02 11:58:55 +00:00
rake spec
2011-01-25 11:30:18 +00:00
2012-12-02 12:13:46 +00:00
## NOTES
2012-12-02 11:58:55 +00:00
To automatically capture funds or enable accepting eCheck payments, add this to you site extension's activate method:
2010-05-24 09:51:04 +00:00
if Spree::Config.instance
2012-02-21 15:49:17 +00:00
Spree::Config[:auto_capture] = true
2010-05-24 09:51:04 +00:00
end
2012-12-02 11:58:55 +00:00
[1] If you check the review checkbox in the admin section for Payment Methods/Paypal Express, the flow is slightly different. Instead of Pay Now on Paypal's order details page, it now says Continue. And the user is directed back to the spree app's Confirmation page showing a place order button. Use whichever suits your needs best. Personally, I leave review unchecked to cut down on the steps in the checkout flow.