paypal-sdk-rest 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  require "spec_helper"
2
2
  require "securerandom"
3
3
 
4
- describe "Webhooks", :integration => true do
4
+ describe "Webhooks" do
5
5
 
6
6
  webhookAttributes = {
7
7
  :url => "https://www.yeowza.com/paypal_webhook_"+SecureRandom.hex(8),
@@ -15,7 +15,7 @@ describe "Webhooks", :integration => true do
15
15
  ]
16
16
  }
17
17
 
18
- describe "Notifications" do
18
+ describe "Notifications", :integration => true do
19
19
  it "create webhook" do
20
20
  $webhook = PayPal::SDK::REST::Webhook.new(webhookAttributes)
21
21
  expect($webhook.create).to be_truthy
@@ -42,7 +42,7 @@ describe "Webhooks", :integration => true do
42
42
  end
43
43
  end
44
44
 
45
- describe "Validation" do
45
+ describe "Validation", :integration => true do
46
46
 
47
47
  transmission_id = "dfb3be50-fd74-11e4-8bf3-77339302725b"
48
48
  timestamp = "2015-05-18T15:45:13Z"
@@ -50,7 +50,6 @@ describe "Webhooks", :integration => true do
50
50
  actual_signature = "thy4/U002quzxFavHPwbfJGcc46E8rc5jzgyeafWm5mICTBdY/8rl7WJpn8JA0GKA+oDTPsSruqusw+XXg5RLAP7ip53Euh9Xu3UbUhQFX7UgwzE2FeYoY6lyRMiiiQLzy9BvHfIzNIVhPad4KnC339dr6y2l+mN8ALgI4GCdIh3/SoJO5wE64Bh/ueWtt8EVuvsvXfda2Le5a2TrOI9vLEzsm9GS79hAR/5oLexNz8UiZr045Mr5ObroH4w4oNfmkTaDk9Rj0G19uvISs5QzgmBpauKr7Nw++JI0pr/v5mFctQkoWJSGfBGzPRXawrvIIVHQ9Wer48GR2g9ZiApWg=="
51
51
  event_body = '{"id":"WH-0G2756385H040842W-5Y612302CV158622M","create_time":"2015-05-18T15:45:13Z","resource_type":"sale","event_type":"PAYMENT.SALE.COMPLETED","summary":"Payment completed for $ 20.0 USD","resource":{"id":"4EU7004268015634R","create_time":"2015-05-18T15:44:02Z","update_time":"2015-05-18T15:44:21Z","amount":{"total":"20.00","currency":"USD"},"payment_mode":"INSTANT_TRANSFER","state":"completed","protection_eligibility":"ELIGIBLE","protection_eligibility_type":"ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE","parent_payment":"PAY-86C81811X5228590KKVNARQQ","transaction_fee":{"value":"0.88","currency":"USD"},"links":[{"href":"https://api.sandbox.paypal.com/v1/payments/sale/4EU7004268015634R","rel":"self","method":"GET"},{"href":"https://api.sandbox.paypal.com/v1/payments/sale/4EU7004268015634R/refund","rel":"refund","method":"POST"},{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-86C81811X5228590KKVNARQQ","rel":"parent_payment","method":"GET"}]},"links":[{"href":"https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-0G2756385H040842W-5Y612302CV158622M","rel":"self","method":"GET"},{"href":"https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-0G2756385H040842W-5Y612302CV158622M/resend","rel":"resend","method":"POST"}]}'
52
52
  cert_url = "https://api.sandbox.paypal.com/v1/notifications/certs/CERT-360caa42-fca2a594-a5cafa77"
53
- cert = PayPal::SDK::REST::WebhookEvent.get_cert(cert_url)
54
53
 
55
54
  it "verify common name" do
56
55
  cert = PayPal::SDK::REST::WebhookEvent.get_cert(cert_url)
@@ -64,11 +63,13 @@ describe "Webhooks", :integration => true do
64
63
  end
65
64
 
66
65
  it "verify expiry" do
66
+ cert = PayPal::SDK::REST::WebhookEvent.get_cert(cert_url)
67
67
  valid = PayPal::SDK::REST::WebhookEvent.verify_expiration(cert)
68
68
  expect(valid).to be_truthy
69
69
  end
70
70
 
71
71
  it "verify cert chain" do
72
+ cert = PayPal::SDK::REST::WebhookEvent.get_cert(cert_url)
72
73
  cert_store = PayPal::SDK::REST::WebhookEvent.get_cert_chain
73
74
  valid = PayPal::SDK::REST::WebhookEvent.verify_cert_chain(cert_store, cert)
74
75
  expect(valid).to be_truthy
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paypal-sdk-rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - PayPal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-02 00:00:00.000000000 Z
11
+ date: 2016-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coveralls
@@ -92,7 +92,6 @@ files:
92
92
  - lib/paypal-sdk/core/api/data_types/base.rb
93
93
  - lib/paypal-sdk/core/api/data_types/enum.rb
94
94
  - lib/paypal-sdk/core/api/data_types/simple_types.rb
95
- - lib/paypal-sdk/core/api/ipn.rb
96
95
  - lib/paypal-sdk/core/api/rest.rb
97
96
  - lib/paypal-sdk/core/authentication.rb
98
97
  - lib/paypal-sdk/core/config.rb
@@ -162,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
161
  version: '0'
163
162
  requirements: []
164
163
  rubyforge_project:
165
- rubygems_version: 2.5.0
164
+ rubygems_version: 2.5.1
166
165
  signing_key:
167
166
  specification_version: 4
168
167
  summary: The PayPal REST SDK provides Ruby APIs to create, process and manage payment.
@@ -1,66 +0,0 @@
1
- module PayPal
2
- module SDK
3
- module Core
4
- module API
5
- module IPN
6
-
7
- END_POINTS = {
8
- :sandbox => "https://www.sandbox.paypal.com/cgi-bin/webscr",
9
- :live => "https://ipnpb.paypal.com/cgi-bin/webscr"
10
- }
11
- VERIFIED = "VERIFIED"
12
- INVALID = "INVALID"
13
-
14
- class Message
15
- include Util::HTTPHelper
16
-
17
- attr_accessor :message
18
-
19
- def initialize(message, env = nil, options = {})
20
- @message = message
21
- set_config(env, options)
22
- end
23
-
24
- # Fetch end point
25
- def ipn_endpoint
26
- config.ipn_endpoint || default_ipn_endpoint
27
- end
28
-
29
- # Default IPN end point
30
- def default_ipn_endpoint
31
- endpoint = END_POINTS[(config.mode || :sandbox).to_sym] rescue nil
32
- endpoint || END_POINTS[:sandbox]
33
- end
34
-
35
- # Request IPN service for validating the content
36
- # === Return
37
- # return http response object
38
- def request
39
- uri = URI(ipn_endpoint)
40
- query_string = "cmd=_notify-validate&#{message}"
41
- http_call(:method => :post, :uri => uri, :body => query_string)
42
- end
43
-
44
- # Validate the given content
45
- # === Return
46
- # return true or false
47
- def valid?
48
- request.body == VERIFIED
49
- end
50
- end
51
-
52
- class << self
53
- def valid?(*args)
54
- Message.new(*args).valid?
55
- end
56
-
57
- def request(*args)
58
- Message.new(*args).request
59
- end
60
- end
61
-
62
- end
63
- end
64
- end
65
- end
66
- end