yukon 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bba7f80222ef8f719c86ccb0d364357227559dc4
4
- data.tar.gz: 2954392e9acea6b9c61c7c2c164ba3c625dff812
3
+ metadata.gz: c8c49067d1c3ef61c83c1be1aaf8b29480dc903d
4
+ data.tar.gz: adba73657218708ee537f7e0019ba3e4f69fbd7b
5
5
  SHA512:
6
- metadata.gz: 673bf92bc7d6576962fa8ceabc4b198c93c0ff72821e9a91cfd5ce5ce0f5d8b8563159ae101921233ccb548648da74f25d86204c363fc6e6c94992fa044f44cb
7
- data.tar.gz: be288d48b6f3bdc44fd0972273430960a95ac4cc2eff9556abe917b638a046778748dfff9117a75891f4d72d70c62bb64438d5d3789d1c517d8ba872c0ced154
6
+ metadata.gz: 8ee64b1405b67eb789bcfc5c009751758f34cc1cdf82aec0f6d1f8d81dbe71e1ad892d87d3b4a7c4f9db6fa35ce17c1e268e459d3a2f914f749cd66a7f25e2d8
7
+ data.tar.gz: c9a68cd783db276f8cc80e7ff9c4159a50aa865da10ff639302035de5981fdca9d1681e321224ace1b9bd36d4ae7599314d9238514ccf4aec6c8020a1e993a92
data/README.md CHANGED
@@ -67,28 +67,37 @@ Once you’ve set up your test accounts and have your API test credentials, you
67
67
  The following cURL command makes an Express Checkout call to the Sandbox. Execute the request from the command line by replacing the credential values in the command with those from your Sandbox Business account. You should get success in response to the request:
68
68
 
69
69
  Request:
70
+
71
+ ```sh
70
72
  curl -s --insecure https://api-3t.sandbox.paypal.com/nvp -d "USER=bparan_1360459336_biz_api1.gmail.com&PWD=1360459362&SIGNATURE=AiPC9BjkCyDFQXbSkoZcgqH3hpacARbNPHYwGcAEv3pAorm.KuIxgJw8&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"
73
+ ```
71
74
 
72
75
  Response:
73
- TOKEN=EC%2d7E679406DY7307812&TIMESTAMP=2015%2d08%2d16T20%3a54%3a43Z&CORRELATIONID=61233e65728ce&ACK=Success&VERSION=98&BUILD=000000
74
76
 
77
+ ```sh
78
+ TOKEN=EC%2d7E679406DY7307812&TIMESTAMP=2015%2d08%2d16T20%3a54%3a43Z&CORRELATIONID=61233e65728ce&ACK=Success&VERSION=98&BUILD=000000
79
+ ```
75
80
 
76
81
  Use the following sample by replacing <tokenValue> with the token from the SetExpressCheckoutPayment response:
77
-
82
+
83
+ ```sh
78
84
  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=93&TOKEN=<tokenValue>"
85
+ ```
79
86
 
80
87
  The response from this call includes the PayerID value, which is needed to capture the payment:
81
88
 
82
89
  GetExpressCheckoutDetails response:
83
90
 
91
+ ```sh
84
92
  TOKEN=EC%2d4RX1920730957200V
85
93
  ...
86
94
 
87
95
  &PAYERID=6B9DKHQRKW4SG
88
96
  ...
89
-
97
+ ```
90
98
  Paypal Test Credentials
91
99
 
100
+ ```yaml
92
101
  test:
93
102
  username: jb-us-seller_api1.paypal.com
94
103
  password: WX4WTU3S8MY44S7F
@@ -97,6 +106,7 @@ test:
97
106
  http_timeout: 30
98
107
  mode: sandbox
99
108
  sandbox_email_address: platform.sdk.seller@gmail.com
109
+ ```
100
110
 
101
111
  ## Development
102
112
 
@@ -108,7 +118,6 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
108
118
 
109
119
  Bug reports and pull requests are welcome on GitHub at https://bitbucket.orb/bparanj/yukon.
110
120
 
111
-
112
121
  ## License
113
122
 
114
123
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,79 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api-3t.sandbox.paypal.com/2.0/
6
+ body:
7
+ encoding: UTF-8
8
+ string: |-
9
+ <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><env:Header><RequesterCredentials xmlns="urn:ebay:api:PayPalAPI" xmlns:n1="urn:ebay:apis:eBLBaseComponents" env:mustUnderstand="0"><n1:Credentials><n1:Username>bparan_1360459336_biz_api1.gmail.com</n1:Username><n1:Password>1360459362</n1:Password><n1:Subject>sell_1342421142_biz@gmail.com</n1:Subject><n1:Signature>AiPC9BjkCyDFQXbSkoZcgqH3hpacARbNPHYwGcAEv3pAorm.KuIxgJw8</n1:Signature></n1:Credentials></RequesterCredentials></env:Header><env:Body><SetExpressCheckoutReq xmlns="urn:ebay:api:PayPalAPI">
10
+ <SetExpressCheckoutRequest xmlns:n2="urn:ebay:apis:eBLBaseComponents">
11
+ <n2:Version>72</n2:Version>
12
+ <n2:SetExpressCheckoutRequestDetails>
13
+ <n2:ReturnURL>http://www.rubyplus.com</n2:ReturnURL>
14
+ <n2:CancelURL>http://www.rubyplus.com/about</n2:CancelURL>
15
+ <n2:ReqBillingAddress>0</n2:ReqBillingAddress>
16
+ <n2:NoShipping>0</n2:NoShipping>
17
+ <n2:AddressOverride>0</n2:AddressOverride>
18
+ <n2:SolutionType>Sole</n2:SolutionType>
19
+ <n2:LandingPage>Billing</n2:LandingPage>
20
+ <n2:PaymentDetails>
21
+ <n2:OrderTotal currencyID="USD">2.00</n2:OrderTotal>
22
+ <n2:Custom>custom</n2:Custom>
23
+ <n2:ButtonSource>ActiveMerchant</n2:ButtonSource>
24
+ <n2:PaymentAction>Sale</n2:PaymentAction>
25
+ </n2:PaymentDetails>
26
+ </n2:SetExpressCheckoutRequestDetails>
27
+ </SetExpressCheckoutRequest>
28
+ </SetExpressCheckoutReq>
29
+ </env:Body></env:Envelope>
30
+ headers:
31
+ Content-Type:
32
+ - application/x-www-form-urlencoded
33
+ Accept-Encoding:
34
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
35
+ Accept:
36
+ - "*/*"
37
+ User-Agent:
38
+ - Ruby
39
+ response:
40
+ status:
41
+ code: 200
42
+ message: OK
43
+ headers:
44
+ Date:
45
+ - Sat, 22 Aug 2015 19:09:59 GMT
46
+ Server:
47
+ - Apache
48
+ Connection:
49
+ - close
50
+ Content-Length:
51
+ - '1788'
52
+ Set-Cookie:
53
+ - X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT
54
+ - X-PP-SILOVER=name%3DSANDBOX3.API.1%26silo_version%3D880%26app%3Dappdispatcher_apit%26TIME%3D130668629;
55
+ domain=.paypal.com; path=/; Secure; HttpOnly
56
+ Content-Type:
57
+ - text/xml; charset=utf-8
58
+ body:
59
+ encoding: UTF-8
60
+ string: <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
61
+ xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
62
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema"
63
+ xmlns:cc="urn:ebay:apis:CoreComponentTypes" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility"
64
+ xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
65
+ xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext" xmlns:ed="urn:ebay:apis:EnhancedDataTypes"
66
+ xmlns:ebl="urn:ebay:apis:eBLBaseComponents" xmlns:ns="urn:ebay:api:PayPalAPI"><SOAP-ENV:Header><Security
67
+ xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext" xsi:type="wsse:SecurityType"></Security><RequesterCredentials
68
+ xmlns="urn:ebay:api:PayPalAPI" xsi:type="ebl:CustomSecurityHeaderType"><Credentials
69
+ xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:UserIdPasswordType"><Username
70
+ xsi:type="xs:string"></Username><Password xsi:type="xs:string"></Password><Signature
71
+ xsi:type="xs:string"></Signature><Subject xsi:type="xs:string"></Subject></Credentials></RequesterCredentials></SOAP-ENV:Header><SOAP-ENV:Body
72
+ id="_0"><SetExpressCheckoutResponse xmlns="urn:ebay:api:PayPalAPI"><Timestamp
73
+ xmlns="urn:ebay:apis:eBLBaseComponents">2015-08-22T19:09:59Z</Timestamp><Ack
74
+ xmlns="urn:ebay:apis:eBLBaseComponents">Success</Ack><CorrelationID xmlns="urn:ebay:apis:eBLBaseComponents">defb9c6abee52</CorrelationID><Version
75
+ xmlns="urn:ebay:apis:eBLBaseComponents">72</Version><Build xmlns="urn:ebay:apis:eBLBaseComponents">000000</Build><Token
76
+ xsi:type="ebl:ExpressCheckoutTokenType">EC-5TC81926SR152035B</Token></SetExpressCheckoutResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
77
+ http_version:
78
+ recorded_at: Sat, 22 Aug 2015 19:10:00 GMT
79
+ recorded_with: VCR 2.9.3
@@ -14,7 +14,4 @@ module Yukon
14
14
  # ActiveMerchant gateway mode
15
15
  define_setting :mode, :test
16
16
 
17
- end
18
-
19
-
20
-
17
+ end
@@ -1,10 +1,15 @@
1
1
  module Yukon
2
2
  class PaymentProcessor
3
+
4
+ def initialize(seller_email)
5
+ @gateway = PaymentGateway.create(seller_email)
6
+ end
7
+ #
3
8
  # Part of Web Request 1
9
+ #
4
10
  # Step 1 : SetExpressCheckout
5
11
  # 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)
12
+ def set_express_checkout(price, ip, return_url, cancel_return_url, custom)
8
13
  response = @gateway.setup_purchase(price,
9
14
  ip: ip,
10
15
  return_url: return_url,
@@ -14,30 +19,30 @@ module Yukon
14
19
  response
15
20
  end
16
21
 
22
+ #
17
23
  # Part of Web Request 1
24
+ #
18
25
  # End of Step 1 : Redirect to Paypal URL : args - response
19
- def self.redirect_url_for(response)
26
+ def redirect_url_for(response)
20
27
  @gateway.redirect_url_for(response.token)
21
28
  end
22
-
29
+
30
+ #
23
31
  # Part of Web Request 2
32
+ #
24
33
  # Step 2 : GetExpressCheckoutDetails : args - token
25
- def self.get_express_checkout_details(token, seller_email)
26
- @gateway = gateway_instance_for(seller_email)
34
+ def get_express_checkout_details(token)
27
35
  @gateway.details_for(token)
28
36
  end
29
37
 
38
+ #
30
39
  # Part of Web Request 2
40
+ #
31
41
  # Step 3 : DoExpressCheckoutPayment
32
- def self.do_express_checkout_payment(price, options)
42
+ def do_express_checkout_payment(price, options)
33
43
  @gateway.purchase(price, options)
34
44
  end
35
45
 
36
- private
37
-
38
- def self.gateway_instance_for(seller_email)
39
- PaymentGateway.create(seller_email)
40
- end
41
46
  end
42
47
 
43
48
  end
@@ -1,3 +1,3 @@
1
1
  module Yukon
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -25,4 +25,6 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency "bundler", "~> 1.10"
26
26
  spec.add_development_dependency "rake", "~> 10.0"
27
27
  spec.add_development_dependency "rspec", "~> 3.3"
28
+ spec.add_development_dependency "vcr", "~> 2.9"
29
+ spec.add_development_dependency "webmock", "~> 1.21"
28
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yukon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bala Paranj
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-22 00:00:00.000000000 Z
11
+ date: 2015-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemerchant
@@ -80,6 +80,34 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: vcr
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.9'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.9'
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.21'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.21'
83
111
  description: Express checkout using ActiveMerchant Paypal API.
84
112
  email:
85
113
  - bparanj@gmail.com
@@ -100,18 +128,11 @@ files:
100
128
  - bin/setup
101
129
  - config/paypal-sample.yml
102
130
  - config/paypal.yml
103
- - errors.txt
131
+ - fixtures/vcr_cassettes/payments.yml
104
132
  - lib/yukon.rb
105
- - lib/yukon/cart.rb
106
- - lib/yukon/end_point.rb
107
- - lib/yukon/express_checkout.rb
108
133
  - lib/yukon/payment_gateway.rb
109
134
  - lib/yukon/payment_processor.rb
110
- - lib/yukon/paypal_express_gateway.rb
111
- - lib/yukon/paypal_express_gateway_factory.rb
112
135
  - lib/yukon/version.rb
113
- - stest.rb
114
- - tester.rb
115
136
  - yukon.gemspec
116
137
  homepage: http://www.rubyplus.com
117
138
  licenses:
data/errors.txt DELETED
@@ -1,40 +0,0 @@
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
@@ -1,26 +0,0 @@
1
- module Yukon
2
- class Cart
3
-
4
- def initialize(product)
5
- @product = product
6
- end
7
-
8
- def total_amount
9
- contents[:items][0][:amount]
10
- end
11
-
12
- def contents
13
- {
14
- items: [
15
- {
16
- name: @product.name,
17
- amount: @product.price_in_cents,
18
- quantity: 1,
19
- description: "Digital product purchase"
20
- }
21
- ]
22
- }
23
- end
24
- end
25
-
26
- end
@@ -1,3 +0,0 @@
1
- module Yukon
2
- EndPoint = Struct.new(:return_url, :cancel_return_url, :notify_url)
3
- end
@@ -1,25 +0,0 @@
1
- module Yukon
2
- # Value object
3
- class ExpressCheckout
4
- attr_reader :end_point, :cart, :buyer_ip, :custom
5
-
6
- def initialize(end_point, cart, buyer_ip, custom)
7
- @end_point = end_point
8
- @cart = cart
9
- @buyer_ip = buyer_ip
10
- @custom = custom
11
- end
12
-
13
- def to_h
14
- {
15
- ip: @buyer_ip,
16
- return_url: @end_point.return_url,
17
- cancel_return_url: @end_point.cancel_return_url,
18
- notify_url: @end_point.notify_url,
19
- allow_guest_checkout: true,
20
- custom: @custom
21
- }.merge(@cart.contents)
22
- end
23
- end
24
-
25
- end
@@ -1,14 +0,0 @@
1
- module Yukon
2
- class PaypalExpressGateway
3
- def initialize(product, gateway)
4
- @product = product
5
- @gateway = gateway
6
- end
7
-
8
- def set_express_checkout(express_checkout)
9
- cart = express_checkout.cart
10
-
11
- @gateway.setup_purchase(cart.total_amount, express_checkout.to_h)
12
- end
13
- end
14
- end
@@ -1,18 +0,0 @@
1
- require 'active_merchant'
2
-
3
- module Yukon
4
- class PaypalExpressGatewayFactory
5
- def self.instance(login, password, signature, seller_email)
6
- options = {
7
- login: login,
8
- password: password,
9
- signature: signature,
10
- subject: seller_email
11
- }
12
-
13
- ActiveMerchant::Billing::PaypalExpressGateway.new(options)
14
- end
15
- end
16
-
17
- end
18
-
data/stest.rb DELETED
@@ -1,79 +0,0 @@
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 DELETED
@@ -1,28 +0,0 @@
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