effective_orders 1.7.0 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 880e18d649a95f87eba2e87fd7fc941849fd08be
|
4
|
+
data.tar.gz: 8c8fc70f4bc7f85a2c63bddcf50cbee72ac64396
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c950647d5032d3ef4f95751f822f22377a4c1e78e1d0037fb3b76c6cc5791b768c206aec0fd936b52d5ed7f841d95eb36c6b279886abec958a6b15b00f3395c5
|
7
|
+
data.tar.gz: 5b761e368af7fd83c8cd272b568aea5dac030b30920e483907c11c9733c803833382bd2603f6289448fed782696f6f01da491b04b9e745a3b35b494102a34903
|
data/README.md
CHANGED
@@ -852,9 +852,86 @@ Register an additional Webhook, to accept Stripe subscription creation events fr
|
|
852
852
|
root_url/webhooks/stripe
|
853
853
|
|
854
854
|
|
855
|
-
|
855
|
+
## Paying Via PayPal
|
856
856
|
|
857
|
-
|
857
|
+
Use the following to set up a PayPal sandbox store.
|
858
|
+
|
859
|
+
### PayPal Account
|
860
|
+
|
861
|
+
Start by creating a PayPal Account. [Sign up or login](http://paypal.com/). You'll need a business account for use in production but a personal account is fine for creating sandbox apps.
|
862
|
+
|
863
|
+
_During sign up of a personal account, you may go to the next step in these directions when PayPal asks you to link a credit card or bank with your account._
|
864
|
+
|
865
|
+
_During sign up of a business account, you may go to the next step in these directions when PayPal asks "How do you want to set up PayPal on your website?"._
|
866
|
+
|
867
|
+
Confirm your email address using the email sent to you by PayPal.
|
868
|
+
|
869
|
+
|
870
|
+
### Configuring Your App With a PayPal Sandbox
|
871
|
+
|
872
|
+
PayPal uses a series of public and private certificates and keys to communicate with third party applications.
|
873
|
+
|
874
|
+
You need to generate your application's private key (so that it is private!). To generate these, we'll use OpenSSL. If you're on Mac/Linux, you can run these commands inside `#{Rails.root}/config/paypalcerts/development/`:
|
875
|
+
|
876
|
+
```
|
877
|
+
openssl genrsa -out app_key.pem 1024
|
878
|
+
openssl req -new -key app_key.pem -x509 -days 999 -out app_cert.pem
|
879
|
+
```
|
880
|
+
|
881
|
+
The app_key.pem file is your private key and the app_cert.pem is the public certificate. We require one more certificate, the PayPal public certificate. This certificate will come from your sandbox seller account.
|
882
|
+
|
883
|
+
To login to the sandbox seller account:
|
884
|
+
|
885
|
+
1. Visit the [PayPal developer portal](https://developer.paypal.com/) and click on "Sandbox" -> "Accounts".
|
886
|
+
It might take some time for the two default sandbox accounts to show up here if you just created your account (~10 minutes).
|
887
|
+
2. Click on the facilitator account accordion, then click 'Profile'.
|
888
|
+
3. Change the password of the facilitator account to whatever you want and copy the facilitator account email address.
|
889
|
+
4. Go to the [PayPal sandbox site](https://www.sandbox.paypal.com/).
|
890
|
+
5. Sign in using the facilitator account credentials
|
891
|
+
|
892
|
+
**If the seller account is from Canada, you can follow these directions:**
|
893
|
+
|
894
|
+
1. Click "Profile". Then click "Encrypted Payment Settings" under the "Selling Preferences" column.
|
895
|
+
2. Download the PayPal public certicate in the middle of the page and save it as `#{Rails.root}/config/paypalcerts/development/paypal_cert.pem`.
|
896
|
+
3. Upload the public certificate that you generated earlier, `app_cert.pem`, at the bottom of the page.
|
897
|
+
4. Copy the new `Cert ID` of the new public certificiate and add it to the effective_orders initializer with other PayPal settings as the `:cert_id`.
|
898
|
+
|
899
|
+
While you're logged in to the seller account, you should disable non-encrypted instant payment notifications (IPNs):
|
900
|
+
|
901
|
+
1. Click on "Profile".
|
902
|
+
2. Click on "Website Payment Preferences" under the "Selling Preferences" column.
|
903
|
+
3. Under "Encrypted Website Payments", turn "Block Non-encrypted Website Payment" to "On"
|
904
|
+
|
905
|
+
**If the seller account is from elsewhere, please contribute what you find. =)**
|
906
|
+
|
907
|
+
Make sure all of the certificates/keys are available in the proper config directory (i.e. `#{Rails.root}/config/paypalcerts/development/paypal_cert.pem`)
|
908
|
+
or set up environment variables to hold the full text or file location.
|
909
|
+
|
910
|
+
Finally, finish adding config values in the effective_orders initializer. Set `config.paypal_enabled = true` and fill out the `config.paypal` settings:
|
911
|
+
|
912
|
+
* seller_email - email that you logged into the sandbox site with above
|
913
|
+
* secret - can be any string (see below)
|
914
|
+
* cert_id - provided by PayPal after uploading your public `app_cert.pem`
|
915
|
+
* paypal_url - https://www.sandbox.paypal.com/cgi-bin/webscr for sandbox or https://www.paypal.com/cgi-bin/webscr for real payments
|
916
|
+
* currency - [choose your preference](https://developer.paypal.com/docs/integration/direct/rest-api-payment-country-currency-support/)
|
917
|
+
* paypal_cert - PayPal's public certificate for your app, downloaded from PayPal earlier (this can be a string with `\n` in it or a path to the file)
|
918
|
+
* app_cert - Your generated public certificate (this can be a string with `\n` in it or a path to the file)
|
919
|
+
* app_key - Your generated private key (this can be a string with `\n` in it or a path to the file)
|
920
|
+
|
921
|
+
The secret can be any string. Here's a good way to come up with a secret:
|
922
|
+
|
923
|
+
```irb
|
924
|
+
& irb
|
925
|
+
> require 'securerandom'
|
926
|
+
=> true
|
927
|
+
> SecureRandom.base64
|
928
|
+
=> "KWidsksL/KR4LAf2EcRSdQ=="
|
929
|
+
```
|
930
|
+
|
931
|
+
### Configuring PayPal For Use With Real Payments
|
932
|
+
|
933
|
+
This process should be very similar although you'll create and configure a seller account on paypal.com rather than the sandbox site.
|
934
|
+
You should generate separate private and public certificates/keys for this and it is advisable to not keep production certificates/keys in version control.
|
858
935
|
|
859
936
|
|
860
937
|
## License
|
@@ -143,7 +143,7 @@ module Effective
|
|
143
143
|
def order_purchased(details = nil, redirect_url = nil, declined_redirect_url = nil)
|
144
144
|
begin
|
145
145
|
@order.purchase!(details)
|
146
|
-
|
146
|
+
Cart.where(user_id: @order.user_id).try(:destroy_all) # current_cart won't work for provider post backs here
|
147
147
|
|
148
148
|
if EffectiveOrders.mailer[:send_order_receipt_to_buyer]
|
149
149
|
flash[:success] = "Payment successful! Please check your email for a receipt."
|
@@ -1,8 +1,18 @@
|
|
1
1
|
module EffectivePaypalHelper
|
2
|
+
class ConfigReader
|
3
|
+
def self.cert_or_key(config)
|
4
|
+
if File.exist?(EffectiveOrders.paypal[config])
|
5
|
+
File.read(EffectiveOrders.paypal[config]) rescue {}
|
6
|
+
else
|
7
|
+
EffectiveOrders.paypal[config] || {}
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
2
12
|
# These're constants so they only get read once, not every order request
|
3
|
-
PAYPAL_CERT_PEM =
|
4
|
-
APP_CERT_PEM
|
5
|
-
APP_KEY_PEM
|
13
|
+
PAYPAL_CERT_PEM = ConfigReader.cert_or_key(:paypal_cert)
|
14
|
+
APP_CERT_PEM = ConfigReader.cert_or_key(:app_cert)
|
15
|
+
APP_KEY_PEM = ConfigReader.cert_or_key(:app_key)
|
6
16
|
|
7
17
|
def paypal_encrypted_payload(order)
|
8
18
|
raise ArgumentError.new("unable to read EffectiveOrders PayPal paypal_cert #{EffectiveOrders.paypal[:paypal_cert]}") unless PAYPAL_CERT_PEM.present?
|
@@ -122,11 +122,6 @@ module ActsAsPurchasable
|
|
122
122
|
end
|
123
123
|
|
124
124
|
def purchased!(order = nil, order_item = nil)
|
125
|
-
# begin
|
126
|
-
# self.quantity_purchased = (self.quantity_purchased + 1)
|
127
|
-
# rescue
|
128
|
-
# end
|
129
|
-
|
130
125
|
after_purchase(order, order_item) if self.respond_to?(:after_purchase)
|
131
126
|
save!
|
132
127
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_orders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|