yukon 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/paypal-sample.yml +12 -0
- data/config/paypal.yml +12 -0
- data/errors.txt +40 -0
- data/lib/yukon/payment_gateway.rb +14 -0
- data/lib/yukon/payment_processor.rb +40 -0
- data/lib/yukon/version.rb +1 -1
- data/stest.rb +79 -0
- data/tester.rb +28 -0
- metadata +8 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a06c4256d86b894eed2f152747d778ad41952f47
|
4
|
+
data.tar.gz: d52ffd6563490f959bfbd32d82bafeba6f289a40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 536baa757caaf9bde63aa38ed9c5e9ec3cf23de4575a577dd25189fe59a5a06bae5cf18f60a0e8f538adfbf28d5b798d1f2ecfb2d124b74a3453a6756a6fdef8
|
7
|
+
data.tar.gz: 5262a50dad2ca135e8aa6591122e086f71852eb7a33ef337bb32c397009bd1b24040f8dccf0faf9e1ad2d29c723f416a49d3182a2a2b87e96540a28bb28c4d73
|
@@ -0,0 +1,12 @@
|
|
1
|
+
development: &default
|
2
|
+
username: jb-us-seller_api1.paypal.com
|
3
|
+
password: WX4WTU3S8MY44S7F
|
4
|
+
signature: AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy
|
5
|
+
app_id: APP-80W284485P519543T
|
6
|
+
http_timeout: 30
|
7
|
+
mode: sandbox
|
8
|
+
test:
|
9
|
+
<<: *default
|
10
|
+
production:
|
11
|
+
<<: *default
|
12
|
+
mode: live
|
data/config/paypal.yml
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
development: &default
|
2
|
+
username: bparan_1360459336_biz_api1.gmail.com
|
3
|
+
password: 1360459362
|
4
|
+
signature: AiPC9BjkCyDFQXbSkoZcgqH3hpacARbNPHYwGcAEv3pAorm.KuIxgJw8
|
5
|
+
app_id: APP-80W284485P519543T
|
6
|
+
http_timeout: 30
|
7
|
+
mode: sandbox
|
8
|
+
test:
|
9
|
+
<<: *default
|
10
|
+
production:
|
11
|
+
<<: *default
|
12
|
+
mode: live
|
data/errors.txt
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
Problem : Security header is not valid", "ErrorCode"=>"10002"
|
2
|
+
|
3
|
+
Possible Solution under test:
|
4
|
+
|
5
|
+
This error is shown when you are not properly logged into the sandbox account on paypal's site.
|
6
|
+
|
7
|
+
0. Login to www.paypal.com
|
8
|
+
1. Go to https://developer.paypal.com/developer/accounts
|
9
|
+
2. Copy API credentials for a sandox user with Business-Pro account.
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
1. Login to sandbox.paypal.com
|
15
|
+
2. Got to your site and checkout
|
16
|
+
3. When sent to paypal, login as one of your buyer test accounts
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
Resources
|
24
|
+
|
25
|
+
1. Bogus gateway to test PayPal
|
26
|
+
https://github.com/sideshowcoder/active_merchant/blob/192f49762172dc41450d7a3605158d45eb55b83b/lib/active_merchant/billing/gateways/paypal_bogus.rb
|
27
|
+
2. Classic API Endpoints
|
28
|
+
https://developer.paypal.com/webapps/developer/docs/classic/api/endpoints/
|
29
|
+
3. Merchant SDK Ruby
|
30
|
+
https://github.com/paypal/merchant-sdk-ruby
|
31
|
+
4. How to create and process an order using Express Checkout
|
32
|
+
https://developer.paypal.com/docs/classic/express-checkout/ht_ec-orderAuthPayment-curl-etc/
|
33
|
+
5. Sample Webapp that generates SDK code to use
|
34
|
+
https://paypal-sdk-samples.herokuapp.com/merchant/get_express_checkout_details
|
35
|
+
|
36
|
+
curl -s --insecure https://api-3t.sandbox.paypal.com/nvp -d "USER=bparan_1360459336_biz_api1.gmail.com&PWD=1360459362&SIGNATURE=AiPC9BjkCyDFQXbSkoZcgqH3hpacARbNPHYwGcAEv3pAorm.KuIxgJw8&METHOD=GetExpressCheckoutDetails&VERSION=98&TOKEN=EC-5N9794560K105682F"
|
37
|
+
|
38
|
+
|
39
|
+
TOKEN=EC-5N9794560K105682F
|
40
|
+
&BILLINGAGREEMENTACCEPTEDSTATUS=0&CHECKOUTSTATUS=PaymentActionNotInitiated&TIMESTAMP=2015-08-16T22:01:37Z&CORRELATIONID=b69a2af4426d&ACK=Success&VERSION=98&BUILD=000000&CURRENCYCODE=USD&AMT=10.00&SHIPPINGAMT=0.00&HANDLINGAMT=0.00&TAXAMT=0.00&INSURANCEAMT=0.00&SHIPDISCAMT=0.00&PAYMENTREQUEST_0_CURRENCYCODE=USD&PAYMENTREQUEST_0_AMT=10.00&PAYMENTREQUEST_0_SHIPPINGAMT=0.00&PAYMENTREQUEST_0_HANDLINGAMT=0.00&PAYMENTREQUEST_0_TAXAMT=0.00&PAYMENTREQUEST_0_INSURANCEAMT=0.00&PAYMENTREQUEST_0_SHIPDISCAMT=0.00&PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED=false&PAYMENTREQUEST_0_ADDRESSNORMALIZATIONSTATUS=None&PAYMENTREQUESTINFO_0_ERRORCODE=0
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Yukon
|
2
|
+
class PaymentProcessor
|
3
|
+
# Step 1 : SetExpressCheckout
|
4
|
+
# price (in cents), buyer_ip, return_url, cancel_return_url, notify_url (optional)
|
5
|
+
def self.set_express_checkout(price, ip, return_url, cancel_return_url)
|
6
|
+
response = express_gateway.setup_purchase(price,
|
7
|
+
ip: ip,
|
8
|
+
return_url: return_url,
|
9
|
+
cancel_return_url: cancel_return_url)
|
10
|
+
response
|
11
|
+
end
|
12
|
+
|
13
|
+
# End of Step 1 : Redirect to Paypal URL : args - response
|
14
|
+
def self.redirect_url_for(response)
|
15
|
+
express_gateway.redirect_url_for(response.token)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Step 2 : GetExpressCheckoutDetails : args - token
|
19
|
+
def self.details_for(token)
|
20
|
+
express_gateway.details_for(token)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Step 3 : DoExpressCheckoutPayment
|
24
|
+
def self.complete_purchase(price, options)
|
25
|
+
express_gateway.purchase(price, options)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def self.express_gateway
|
31
|
+
paypal_credentials = {
|
32
|
+
login: Yukon.login,
|
33
|
+
password: Yukon.password,
|
34
|
+
signature: Yukon.signature
|
35
|
+
}
|
36
|
+
PaymentGateway.create(paypal_credentials, Yukon.mode)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
data/lib/yukon/version.rb
CHANGED
data/stest.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'paypal-sdk-merchant'
|
2
|
+
|
3
|
+
PayPal::SDK.load('config/paypal.yml', ENV['RACK_ENV'] || 'development')
|
4
|
+
@api = PayPal::SDK::Merchant::API.new
|
5
|
+
|
6
|
+
# Build SetExpressCheckout request object
|
7
|
+
@set_express_checkout = @api.build_set_express_checkout({
|
8
|
+
:SetExpressCheckoutRequestDetails => {
|
9
|
+
:ReturnURL => "https://paypal-sdk-samples.herokuapp.com/merchant/do_express_checkout_payment",
|
10
|
+
:CancelURL => "https://paypal-sdk-samples.herokuapp.com/merchant/set_express_checkout",
|
11
|
+
:PaymentDetails => [{
|
12
|
+
:OrderTotal => {
|
13
|
+
:currencyID => "USD",
|
14
|
+
:value => "5.27" },
|
15
|
+
:NotifyURL => "https://paypal-sdk-samples.herokuapp.com/merchant/ipn_notify",
|
16
|
+
:PaymentDetailsItem => [{
|
17
|
+
:Name => "Item Name",
|
18
|
+
:Quantity => 1,
|
19
|
+
:Amount => {
|
20
|
+
:currencyID => "USD",
|
21
|
+
:value => "5.27" },
|
22
|
+
:ItemCategory => "Physical" }],
|
23
|
+
:PaymentAction => "Sale" }] } })
|
24
|
+
|
25
|
+
# Make API call & get response
|
26
|
+
@set_express_checkout_response = @api.set_express_checkout(@set_express_checkout)
|
27
|
+
|
28
|
+
# Access Response
|
29
|
+
if @set_express_checkout_response.success?
|
30
|
+
p "Express Token : #{@set_express_checkout_response.Token}"
|
31
|
+
else
|
32
|
+
p @set_express_checkout_response.Errors
|
33
|
+
end
|
34
|
+
|
35
|
+
p @set_express_checkout_response.inspect
|
36
|
+
|
37
|
+
|
38
|
+
# If the customer approves the payment, call GetExpressCheckoutDetails to obtain the PayerID (which uniquely identifies the customer), and any other details you might need for transaction processing.
|
39
|
+
|
40
|
+
# Build GetExpressCheckout request object
|
41
|
+
@get_express_checkout_details = @api.build_get_express_checkout_details({Token: @set_express_checkout_response.Token })
|
42
|
+
|
43
|
+
# Make API call & get response
|
44
|
+
@get_express_checkout_details_response = @api.get_express_checkout_details(@get_express_checkout_details)
|
45
|
+
|
46
|
+
# Access Response
|
47
|
+
if @get_express_checkout_details_response.success?
|
48
|
+
p "*" * 80
|
49
|
+
p 'PayerID'
|
50
|
+
p @get_express_checkout_details_response.GetExpressCheckoutDetailsResponseDetails.PayerInfo.PayerID
|
51
|
+
p "*" * 80
|
52
|
+
else
|
53
|
+
p @get_express_checkout_details_response.Errors
|
54
|
+
end
|
55
|
+
|
56
|
+
# Build DoExpressCheckout request object
|
57
|
+
@do_express_checkout_payment = @api.build_do_express_checkout_payment({
|
58
|
+
:DoExpressCheckoutPaymentRequestDetails => {
|
59
|
+
:PaymentAction => "Sale",
|
60
|
+
:Token => @set_express_checkout_response.Token,
|
61
|
+
:PayerID => "TWLK53YN7GDM6",
|
62
|
+
:PaymentDetails => [{
|
63
|
+
:OrderTotal => {
|
64
|
+
:currencyID => "USD",
|
65
|
+
:value => "5.27" },
|
66
|
+
:NotifyURL => "https://paypal-sdk-samples.herokuapp.com/merchant/ipn_notify" }] } })
|
67
|
+
|
68
|
+
# Make API call & get response
|
69
|
+
@do_express_checkout_payment_response = @api.do_express_checkout_payment(@do_express_checkout_payment)
|
70
|
+
|
71
|
+
# Access Response
|
72
|
+
if @do_express_checkout_payment_response.success?
|
73
|
+
p "Processed payment successfully"
|
74
|
+
p @do_express_checkout_payment_response.DoExpressCheckoutPaymentResponseDetails
|
75
|
+
p @do_express_checkout_payment_response.FMFDetails
|
76
|
+
else
|
77
|
+
p @do_express_checkout_payment_response.Errors
|
78
|
+
end
|
79
|
+
|
data/tester.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'active_merchant'
|
2
|
+
|
3
|
+
|
4
|
+
login = 'bparan_1360459336_biz_api1.gmail.com'
|
5
|
+
password = '1360459362'
|
6
|
+
signature = 'AiPC9BjkCyDFQXbSkoZcgqH3hpacARbNPHYwGcAEv3pAorm.KuIxgJw8'
|
7
|
+
|
8
|
+
paypal_gateway = ActiveMerchant::Billing::PaypalExpressGateway.new(login: login, password: password, signature: signature)
|
9
|
+
|
10
|
+
purchase = paypal_gateway.setup_purchase(100,
|
11
|
+
ip: '127.0.0.1',
|
12
|
+
return_url: "http://localhost:3000/return",
|
13
|
+
cancel_return_url: "http://localhost:3000/cancel",
|
14
|
+
notify_url: 'http://localhost:3000/notify',
|
15
|
+
currency: 'USD',
|
16
|
+
items: [{ name: 'Sample item', quantity: 1, amount: 100, description: 'Sample'}],
|
17
|
+
allow_guest_checkout: true)
|
18
|
+
|
19
|
+
puts purchase.inspect
|
20
|
+
|
21
|
+
|
22
|
+
Credentials Test
|
23
|
+
|
24
|
+
curl -s --insecure https://api-3t.sandbox.paypal.com/nvp -d "USER=jb-us-seller_api1.paypal.com&PWD=WX4WTU3S8MY44S7F&SIGNATURE=AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy&METHOD=SetExpressCheckout&VERSION=98&PAYMENTREQUEST_0_AMT=10&PAYMENTREQUEST_0_CURRENCYCODE=USD&PAYMENTREQUEST_0_PAYMENTACTION=SALE&cancelUrl=http://www.example.com/cancel.html&returnUrl=http://www.example.com/success.html"
|
25
|
+
TOKEN=EC%2d0L846157FP9914800&TIMESTAMP=2015%2d08%2d16T20%3a59%3a43Z&CORRELATIONID=d458bf3649e94&ACK=Success&VERSION=98&BUILD=000000
|
26
|
+
|
27
|
+
My Credetials response:
|
28
|
+
TOKEN=EC%2d7E679406DY7307812&TIMESTAMP=2015%2d08%2d16T20%3a54%3a43Z&CORRELATIONID=61233e65728ce&ACK=Success&VERSION=98&BUILD=000000
|
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.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bala Paranj
|
@@ -84,13 +84,20 @@ files:
|
|
84
84
|
- Rakefile
|
85
85
|
- bin/console
|
86
86
|
- bin/setup
|
87
|
+
- config/paypal-sample.yml
|
88
|
+
- config/paypal.yml
|
89
|
+
- errors.txt
|
87
90
|
- lib/yukon.rb
|
88
91
|
- lib/yukon/cart.rb
|
89
92
|
- lib/yukon/end_point.rb
|
90
93
|
- lib/yukon/express_checkout.rb
|
94
|
+
- lib/yukon/payment_gateway.rb
|
95
|
+
- lib/yukon/payment_processor.rb
|
91
96
|
- lib/yukon/paypal_express_gateway.rb
|
92
97
|
- lib/yukon/paypal_express_gateway_factory.rb
|
93
98
|
- lib/yukon/version.rb
|
99
|
+
- stest.rb
|
100
|
+
- tester.rb
|
94
101
|
- yukon.gemspec
|
95
102
|
homepage: http://www.rubyplus.com
|
96
103
|
licenses:
|