yukon 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +30 -0
- data/lib/yukon/payment_gateway.rb +9 -3
- data/lib/yukon/payment_processor.rb +24 -23
- data/lib/yukon/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c40e8ca908722b1cd01aa28f71465b88b771859
|
4
|
+
data.tar.gz: da2e2e5dea2440e5bab52e871c532a3863db14d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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(
|
8
|
-
|
9
|
-
|
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
|
-
#
|
4
|
-
#
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
-
|
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.
|
22
|
-
|
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.
|
27
|
-
|
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.
|
33
|
-
|
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