yukon 0.1.8 → 0.1.9

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: 2fc58827400ceed67f98c7a445a5519c20102a46
4
- data.tar.gz: 8047410099075c5ba2492c246c2b1ace80e99da7
3
+ metadata.gz: 0c40e8ca908722b1cd01aa28f71465b88b771859
4
+ data.tar.gz: da2e2e5dea2440e5bab52e871c532a3863db14d4
5
5
  SHA512:
6
- metadata.gz: b912303b7ad6e267314bedde3625cca9696e0847ad8c5623290adcca6129ec9b8b8940764f849e80d53663a925de950cc66ad4d1bf9f2a6d662fe0a4856b5119
7
- data.tar.gz: 50d72e2372ee88e5a0bd356f67ac88942dcb0c2409b9b92f726ec52c36b95b4ae37586ce724c828ce39c6ca87c77f5690b09198d1c0ac887d105e9cbcdc7ff88
6
+ metadata.gz: 9001590acc387d014c1629150824b022a329d10485791717959e712f8b9d0e97c7ba0048a15d52907e323a977a32486bdee50bc045d8dbeea943a4207911955d
7
+ data.tar.gz: dc00b19473d92ac4cd65fef9094b8a7baa8eb680b70a17344e66efcf357a6af4a005680fa403072178047f374fd5fe7ecc719fcfa2c26254ba82f2a5717f5d90
data/README.md CHANGED
@@ -24,10 +24,40 @@ Or install it yourself as:
24
24
 
25
25
  ## Usage
26
26
 
27
+ Steps
28
+ -------
29
+
27
30
  1. SetExpressCheckout: Makes a call to the API sending the details of the payment to obtain a token and generate a payment url
28
31
  2. GetExpressCheckout: Redirects the user to the payment url and obtains the authorization
29
32
  3. DoExpressCheckout: Uses the given authorization to make the real payment
30
33
 
34
+ Configuration
35
+ ------------
36
+
37
+ For a Rails app, create yukon.rb in config/initializers.rb:
38
+
39
+ ```ruby
40
+ paypal_config = Rails.application.config_for(:paypal)
41
+
42
+ Yukon.configuration do |config|
43
+ config.login = paypal_config['login']
44
+ config.password = paypal_config['password']
45
+ config.signature = paypal_config['signature']
46
+ end
47
+ ```
48
+
49
+ Create paypal.yml in config folder and provide the values for the Paypal credentials:
50
+
51
+ ```yaml
52
+ development:
53
+ login: your-paypal-sandbox-login-email
54
+ password: your-paypal-sandbox-login-password
55
+ signature: your-paypal-sandbox-signature
56
+ mode: :test
57
+ ```
58
+
59
+ The mode value is :test for development and test environments and :live only for production. For a sample Rails 4.2.3 app, check out : https://bitbucket.org/bparanj/paypalexpress
60
+
31
61
  ## Test Credentials
32
62
 
33
63
  Credentials Test
@@ -4,9 +4,15 @@ module Yukon
4
4
 
5
5
  class PaymentGateway
6
6
 
7
- def self.create(credentials, mode)
8
- ActiveMerchant::Billing::Base.mode = mode
9
- ActiveMerchant::Billing::PaypalExpressGateway.new(credentials)
7
+ def self.create(seller_email)
8
+ options = {
9
+ login: Yukon.login,
10
+ password: Yukon.password,
11
+ signature: Yukon.signature,
12
+ subject: seller_email
13
+ }
14
+ ActiveMerchant::Billing::Base.mode = Yukon.mode
15
+ ActiveMerchant::Billing::PaypalExpressGateway.new(options)
10
16
  end
11
17
 
12
18
  end
@@ -1,41 +1,42 @@
1
1
  module Yukon
2
2
  class PaymentProcessor
3
- # Step 1 : SetExpressCheckout
4
- # price (in cents), buyer_ip, return_url, cancel_return_url, notify_url (optional), custom
5
- def self.set_express_checkout(price, ip, return_url, cancel_return_url, custom)
6
- response = express_gateway.setup_purchase(price,
7
- ip: ip,
8
- return_url: return_url,
9
- cancel_return_url: cancel_return_url,
10
- allow_guest_checkout: true,
11
- custom: custom)
3
+ # Part of Web Request 1
4
+ # Step 1 : SetExpressCheckout
5
+ # price (in cents), buyer_ip, return_url, cancel_return_url, seller_email, notify_url (optional), custom
6
+ def self.set_express_checkout(price, ip, return_url, cancel_return_url, seller_email, custom)
7
+ @gateway = gateway_instance_for(seller_email)
8
+ response = gateway.setup_purchase(price,
9
+ ip: ip,
10
+ return_url: return_url,
11
+ cancel_return_url: cancel_return_url,
12
+ allow_guest_checkout: true,
13
+ custom: custom)
12
14
  response
13
15
  end
14
-
16
+
17
+ # Part of Web Request 1
15
18
  # End of Step 1 : Redirect to Paypal URL : args - response
16
19
  def self.redirect_url_for(response)
17
- express_gateway.redirect_url_for(response.token)
20
+ @gateway.redirect_url_for(response.token)
18
21
  end
19
22
 
23
+ # Part of Web Request 2
20
24
  # Step 2 : GetExpressCheckoutDetails : args - token
21
- def self.details_for(token)
22
- express_gateway.details_for(token)
25
+ def self.get_express_checkout_details(token, seller_email)
26
+ @gateway = gateway_instance_for(seller_email)
27
+ @gateway.details_for(token)
23
28
  end
24
29
 
30
+ # Part of Web Request 2
25
31
  # Step 3 : DoExpressCheckoutPayment
26
- def self.complete_purchase(price, options)
27
- express_gateway.purchase(price, options)
32
+ def self.do_express_checkout_payment(price, options)
33
+ @gateway.purchase(price, options)
28
34
  end
29
35
 
30
36
  private
31
-
32
- def self.express_gateway
33
- paypal_credentials = {
34
- login: Yukon.login,
35
- password: Yukon.password,
36
- signature: Yukon.signature
37
- }
38
- PaymentGateway.create(paypal_credentials, Yukon.mode)
37
+
38
+ def self.gateway_instance_for(seller_email)
39
+ PaymentGateway.create(seller_email)
39
40
  end
40
41
  end
41
42
 
data/lib/yukon/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yukon
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yukon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bala Paranj