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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 72dddceb399000bdb12b4360983c861cc927e92a
4
- data.tar.gz: 6b60b36e2164f07b96951a51cb8dbfa423f8937e
3
+ metadata.gz: a50371cdb348785506ff61ef88aba02f119e99aa
4
+ data.tar.gz: d84d2eb117fca72ff6f50ac299cadaa1f8585331
5
5
  SHA512:
6
- metadata.gz: 39d75f76da80b4f822ccf0046172efe935a833374223ce51ce0c00b68997258034150171d4db79f3c385a6d31fab82e0687e750388bf61f862176194c7617576
7
- data.tar.gz: eb7c14092c622d5dd96428612f745e34f6b50673f84c1ef54757341df32e95cb7e5aa41038f8a773f98fa3d827736505da9827c26a7501605cf6b95b41008a71
6
+ metadata.gz: dfd06b69e27819ab06fc612695e0ac1967cf50566866a759f64eab4cb046c35776b5d37eb383ca06c00c7deccbc82a155cf57b5a4fd5a42a834d700e77b47b4b
7
+ data.tar.gz: c34219a3a6436564f26910c22399807e45d4a7b3bba0babe851a2c6f9c4b8ab562b62c750794ebb762eca1ab074c6f27188498f7b640a7eb96e8f45196f37edf
@@ -3,10 +3,7 @@ module PayPal
3
3
  module Core
4
4
  module API
5
5
  autoload :Base, "paypal-sdk/core/api/base"
6
- autoload :Merchant, "paypal-sdk/core/api/merchant"
7
- autoload :Platform, "paypal-sdk/core/api/platform"
8
6
  autoload :REST, "paypal-sdk/core/api/rest"
9
- autoload :IPN, "paypal-sdk/core/api/ipn"
10
7
 
11
8
  module DataTypes
12
9
  autoload :Base, "paypal-sdk/core/api/data_types/base"
@@ -72,19 +72,13 @@ module PayPal::SDK::Core
72
72
  :token, :token_secret, :subject,
73
73
  :http_timeout, :http_proxy,
74
74
  :device_ipaddress, :sandbox_email_address,
75
- :mode, :endpoint, :merchant_endpoint, :platform_endpoint, :ipn_endpoint,
75
+ :mode, :endpoint,
76
76
  :rest_endpoint, :rest_token_endpoint, :client_id, :client_secret,
77
77
  :openid_endpoint, :openid_redirect_uri, :openid_client_id, :openid_client_secret,
78
78
  :verbose_logging
79
79
 
80
80
  alias_method :end_point=, :endpoint=
81
81
  alias_method :end_point, :endpoint
82
- alias_method :platform_end_point=, :platform_endpoint=
83
- alias_method :platform_end_point, :platform_endpoint
84
- alias_method :merchant_end_point=, :merchant_endpoint=
85
- alias_method :merchant_end_point, :merchant_endpoint
86
- alias_method :ipn_end_point=, :ipn_endpoint=
87
- alias_method :ipn_end_point, :ipn_endpoint
88
82
  alias_method :rest_end_point, :rest_endpoint
89
83
  alias_method :rest_end_point=, :rest_endpoint=
90
84
  alias_method :rest_token_end_point, :rest_token_endpoint
@@ -221,7 +215,7 @@ module PayPal::SDK::Core
221
215
  # Get logger
222
216
  def logger
223
217
  if @@configurations[:mode] == 'live' and Logging.logger.level == Logger::DEBUG
224
- Logging.logger.warn "DEBUG log level not allowed in sandbox mode for security of confidential information. Changing log level to INFO..."
218
+ Logging.logger.warn "DEBUG log level not allowed in live mode for security of confidential information. Changing log level to INFO..."
225
219
  Logging.logger.level = Logger::INFO
226
220
  end
227
221
  Logging.logger
@@ -1262,8 +1262,8 @@ module PayPal::SDK
1262
1262
  end
1263
1263
 
1264
1264
  def get_cert_chain()
1265
- root_cert = "data/DigiCertHighAssuranceEVRootCA.pem"
1266
- intermediate_cert = "data/DigiCertSHA2ExtendedValidationServerCA.pem"
1265
+ root_cert = File.expand_path(File.join(File.dirname(__FILE__), '../../../data/DigiCertHighAssuranceEVRootCA.pem'))
1266
+ intermediate_cert = File.expand_path(File.join(File.dirname(__FILE__), '../../../data/DigiCertSHA2ExtendedValidationServerCA.pem'))
1267
1267
 
1268
1268
  cert_store = OpenSSL::X509::Store.new
1269
1269
  cert_store.add_file(root_cert)
@@ -1,7 +1,7 @@
1
1
  module PayPal
2
2
  module SDK
3
3
  module REST
4
- VERSION = "1.4.1"
4
+ VERSION = "1.4.2"
5
5
  end
6
6
  end
7
7
  end
@@ -4,31 +4,19 @@ How to run tests
4
4
  The SDK tests are composed of two groups: unit test group and integration (functional) test group. Integration test group is by default set not to run.
5
5
 
6
6
  - run a single test
7
- - ```
8
- $ bundle exec rspec <test-file>:<line-number>
9
- ```
7
+ - `$ bundle exec rspec <test-file>:<line-number>`
10
8
  - e.g., to run payment create test,
11
- - ```
12
- $ bundle exec rspec spec/payments_examples_spec.rb:53
13
- ```
9
+ - `$ bundle exec rspec spec/payments_examples_spec.rb:53`
14
10
 
15
11
  - run multiple tests in the same file
16
- - Add ```:<line-number>``` to the above command. For example, in order to execute payment create and payment list tests,
17
- - ```
18
- $ bundle exec rspec spec/payments_examples_spec.rb:53:95
19
- ```
12
+ - Add `:<line-number>` to the above command. For example, in order to execute payment create and payment list tests,
13
+ - `$ bundle exec rspec spec/payments_examples_spec.rb:53:95`
20
14
 
21
15
  - run integration tests
22
16
  - This will set the 'integration' flag and will execute functional tests against sandbox.
23
- - ```
24
- $ bundle exec rspec --tag integration
25
- ```
17
+ - `$ bundle exec rspec --tag integration`
26
18
 
27
19
  - run tests with a specific String
28
- - ```
29
- $ bundle exec rspec -e "<string>"
30
- ```
20
+ - `$ bundle exec rspec -e "<string>"`
31
21
  - e.g., to run any tests with "Sa" in test description (for the time being, it will be "Sale" tests)
32
- - ```
33
- $ bundle exec rspec -e "Sa"
34
- ```
22
+ - `$ bundle exec rspec -e "Sa"`
@@ -31,29 +31,29 @@ describe PayPal::SDK::Core::API::DataTypes::Base do
31
31
 
32
32
  it "should allow content key" do
33
33
  message = Message.new("Testing message")
34
- message.value.should eql "Testing message"
34
+ expect(message.value).to eql "Testing message"
35
35
 
36
36
  message = Message.new(:value => "Testing message")
37
- message.value.should eql "Testing message"
37
+ expect(message.value).to eql "Testing message"
38
38
  end
39
39
 
40
40
  it "should create member object automatically" do
41
41
  test_type = TestType.new
42
- test_type.fromCurrency.should be_a TestCurrency
43
- test_type.toCurrency.should be_a Array
44
- test_type.toCurrency[0].should be_a TestCurrency
45
- test_type.toCurrency[1].should be_a TestCurrency
46
- test_type.toCurrency[0].amount.should eql nil
47
- test_type.fromCurrency.amount.should eql nil
48
- test_type.fromCurrency.desciption.should eql nil
49
- test_type.fromCurrency.currencyID.should eql nil
42
+ expect(test_type.fromCurrency).to be_a TestCurrency
43
+ expect(test_type.toCurrency).to be_a Array
44
+ expect(test_type.toCurrency[0]).to be_a TestCurrency
45
+ expect(test_type.toCurrency[1]).to be_a TestCurrency
46
+ expect(test_type.toCurrency[0].amount).to eql nil
47
+ expect(test_type.fromCurrency.amount).to eql nil
48
+ expect(test_type.fromCurrency.desciption).to eql nil
49
+ expect(test_type.fromCurrency.currencyID).to eql nil
50
50
  end
51
51
 
52
52
  it "should convert the given data to configured type" do
53
53
  test_type = TestType.new( :fromCurrency => { :currencyID => "USD", :amount => "50.0"})
54
- test_type.fromCurrency.should be_a TestCurrency
55
- test_type.fromCurrency.currencyID.should eql "USD"
56
- test_type.fromCurrency.amount.should eql "50.0"
54
+ expect(test_type.fromCurrency).to be_a TestCurrency
55
+ expect(test_type.fromCurrency.currencyID).to eql "USD"
56
+ expect(test_type.fromCurrency.amount).to eql "50.0"
57
57
  end
58
58
 
59
59
  it "should allow block with initializer" do
@@ -63,8 +63,8 @@ describe PayPal::SDK::Core::API::DataTypes::Base do
63
63
  self.amount = "50.0"
64
64
  end
65
65
  end
66
- test_type.fromCurrency.currencyID.should eql "USD"
67
- test_type.fromCurrency.amount.should eql "50.0"
66
+ expect(test_type.fromCurrency.currencyID).to eql "USD"
67
+ expect(test_type.fromCurrency.amount).to eql "50.0"
68
68
  end
69
69
 
70
70
  it "should allow block with member" do
@@ -73,116 +73,116 @@ describe PayPal::SDK::Core::API::DataTypes::Base do
73
73
  self.currencyID = "USD"
74
74
  self.amount = "50.0"
75
75
  end
76
- test_type.fromCurrency.currencyID.should eql "USD"
77
- test_type.fromCurrency.amount.should eql "50.0"
76
+ expect(test_type.fromCurrency.currencyID).to eql "USD"
77
+ expect(test_type.fromCurrency.amount).to eql "50.0"
78
78
  end
79
79
 
80
80
  it "should assign value to attribute" do
81
81
  test_currency = TestCurrency.new( :@currencyID => "USD", :amount => "50" )
82
- test_currency.currencyID.should eql "USD"
82
+ expect(test_currency.currencyID).to eql "USD"
83
83
  end
84
84
 
85
85
  it "should allow configured Class object" do
86
86
  test_currency = TestCurrency.new( :currencyID => "USD", :amount => "50" )
87
87
  test_type = TestType.new( :fromCurrency => test_currency )
88
- test_type.fromCurrency.should eql test_currency
88
+ expect(test_type.fromCurrency).to eql test_currency
89
89
  end
90
90
 
91
91
  it "should allow snakecase" do
92
92
  test_type = TestType.new( :from_currency => {} )
93
- test_type.from_currency.should be_a TestCurrency
94
- test_type.from_currency.should eql test_type.fromCurrency
93
+ expect(test_type.from_currency).to be_a TestCurrency
94
+ expect(test_type.from_currency).to eql test_type.fromCurrency
95
95
  end
96
96
 
97
97
  it "should allow array" do
98
98
  test_type = TestType.new( :toCurrency => [{ :currencyID => "USD", :amount => "50.0" }] )
99
- test_type.toCurrency.should be_a Array
100
- test_type.toCurrency.first.should be_a TestCurrency
101
- test_type.toCurrency.first.currencyID.should eql "USD"
99
+ expect(test_type.toCurrency).to be_a Array
100
+ expect(test_type.toCurrency.first).to be_a TestCurrency
101
+ expect(test_type.toCurrency.first.currencyID).to eql "USD"
102
102
  end
103
103
 
104
104
  it "should skip undefind members on initializer" do
105
105
  test_type = TestType.new( :notExist => "testing")
106
- lambda do
106
+ expect do
107
107
  test_type.notExist
108
- end.should raise_error NoMethodError
109
- lambda do
108
+ end.to raise_error NoMethodError
109
+ expect do
110
110
  test_type.notExist = "Value"
111
- end.should raise_error NoMethodError
111
+ end.to raise_error NoMethodError
112
112
  end
113
113
 
114
114
  it "should not convert empty hash" do
115
115
  test_type = TestType.new( :fromCurrency => {} )
116
- test_type.to_hash.should eql({})
116
+ expect(test_type.to_hash).to eql({})
117
117
  end
118
118
 
119
119
  it "should not convert empty array" do
120
120
  test_type = TestType.new( :toCurrency => [] )
121
- test_type.to_hash.should eql({})
121
+ expect(test_type.to_hash).to eql({})
122
122
  end
123
123
 
124
124
  it "should not convert array of empty hash" do
125
125
  test_type = TestType.new( :toCurrency => [ {} ] )
126
- test_type.to_hash.should eql({})
126
+ expect(test_type.to_hash).to eql({})
127
127
  end
128
128
 
129
129
  it "should return empty hash" do
130
130
  test_type = TestType.new
131
- test_type.to_hash.should eql({})
131
+ expect(test_type.to_hash).to eql({})
132
132
  end
133
133
 
134
134
  it "should convert to hash" do
135
135
  test_currency = TestCurrency.new(:amount => "500")
136
- test_currency.to_hash.should eql("amount" => "500")
136
+ expect(test_currency.to_hash).to eql("amount" => "500")
137
137
  end
138
138
 
139
139
  it "should convert to hash with key as symbol" do
140
140
  test_currency = TestCurrency.new(:amount => "500")
141
- test_currency.to_hash(:symbol => true).should eql(:amount => "500")
141
+ expect(test_currency.to_hash(:symbol => true)).to eql(:amount => "500")
142
142
  end
143
143
 
144
144
  it "should convert attribute key with @" do
145
145
  test_currency = TestCurrency.new( :currencyID => "USD", :amount => "50" )
146
- test_currency.to_hash["@currencyID"].should eql "USD"
146
+ expect(test_currency.to_hash["@currencyID"]).to eql "USD"
147
147
  end
148
148
 
149
149
  it "should convert attribute key without @" do
150
150
  test_currency = TestCurrency.new( :currencyID => "USD", :amount => "50" )
151
- test_currency.to_hash(:attribute => false)["currencyID"].should eql "USD"
151
+ expect(test_currency.to_hash(:attribute => false)["currencyID"]).to eql "USD"
152
152
  end
153
153
 
154
154
  it "should convert to hash with namespace" do
155
155
  test_currency = TestCurrency.new(:currencyID => "USD", :amount => "500", :desciption => "Testing" )
156
156
  hash = test_currency.to_hash
157
- hash["amount"].should eql "500"
158
- hash["ns:desciption"].should eql "Testing"
159
- hash["@currencyID"].should eql "USD"
157
+ expect(hash["amount"]).to eql "500"
158
+ expect(hash["ns:desciption"]).to eql "Testing"
159
+ expect(hash["@currencyID"]).to eql "USD"
160
160
  hash = test_currency.to_hash(:namespace => false)
161
- hash["amount"].should eql "500"
162
- hash["desciption"].should eql "Testing"
163
- hash["@currencyID"].should eql "USD"
161
+ expect(hash["amount"]).to eql "500"
162
+ expect(hash["desciption"]).to eql "Testing"
163
+ expect(hash["@currencyID"]).to eql "USD"
164
164
  end
165
165
 
166
166
  it "should allow namespace" do
167
167
  test_currency = TestCurrency.new(:amount => "500", :"ns:desciption" => "Testing" )
168
- test_currency.desciption.should eql "Testing"
168
+ expect(test_currency.desciption).to eql "Testing"
169
169
  end
170
170
 
171
171
  it "should use name option in members" do
172
172
  test_type = TestType.new( :firstname => "FirstName")
173
- test_type.to_hash.should eql({"first-name" => "FirstName" })
173
+ expect(test_type.to_hash).to eql({"first-name" => "FirstName" })
174
174
  end
175
175
 
176
176
  it "should allow date" do
177
177
  date_time = "2010-10-10T10:10:10"
178
178
  test_simple_type = TestSimpleType.new( :created_on => date_time, :created_at => date_time )
179
- test_simple_type.created_on.should be_a Date
180
- test_simple_type.created_at.should be_a DateTime
179
+ expect(test_simple_type.created_on).to be_a Date
180
+ expect(test_simple_type.created_at).to be_a DateTime
181
181
  end
182
182
 
183
183
  it "should allow date with value 0" do
184
184
  test_simple_type = TestSimpleType.new( :created_at => "0" )
185
- test_simple_type.created_at.should be_a DateTime
185
+ expect(test_simple_type.created_at).to be_a DateTime
186
186
  end
187
187
 
188
188
  end
@@ -22,68 +22,68 @@ describe PayPal::SDK::Core::API::REST do
22
22
  describe "Configuration" do
23
23
  it "create api with prefix" do
24
24
  api = create_api("v1/payments")
25
- api.uri.path.should eql "/v1/payments"
25
+ expect(api.uri.path).to eql "/v1/payments"
26
26
  end
27
27
 
28
28
  it "service endpoint for sandbox" do
29
29
  api = create_api
30
- api.service_endpoint.should eql "https://api.sandbox.paypal.com"
31
- api.token_endpoint.should eql "https://api.sandbox.paypal.com"
30
+ expect(api.service_endpoint).to eql "https://api.sandbox.paypal.com"
31
+ expect(api.token_endpoint).to eql "https://api.sandbox.paypal.com"
32
32
  api = create_api( :mode => "sandbox" )
33
- api.service_endpoint.should eql "https://api.sandbox.paypal.com"
34
- api.token_endpoint.should eql "https://api.sandbox.paypal.com"
33
+ expect(api.service_endpoint).to eql "https://api.sandbox.paypal.com"
34
+ expect(api.token_endpoint).to eql "https://api.sandbox.paypal.com"
35
35
  api = create_api( :mode => :sandbox )
36
- api.service_endpoint.should eql "https://api.sandbox.paypal.com"
37
- api.token_endpoint.should eql "https://api.sandbox.paypal.com"
36
+ expect(api.service_endpoint).to eql "https://api.sandbox.paypal.com"
37
+ expect(api.token_endpoint).to eql "https://api.sandbox.paypal.com"
38
38
  api = create_api( :mode => "invalid" )
39
- api.service_endpoint.should eql "https://api.sandbox.paypal.com"
40
- api.token_endpoint.should eql "https://api.sandbox.paypal.com"
39
+ expect(api.service_endpoint).to eql "https://api.sandbox.paypal.com"
40
+ expect(api.token_endpoint).to eql "https://api.sandbox.paypal.com"
41
41
  api = create_api( :mode => nil )
42
- api.service_endpoint.should eql "https://api.sandbox.paypal.com"
43
- api.token_endpoint.should eql "https://api.sandbox.paypal.com"
42
+ expect(api.service_endpoint).to eql "https://api.sandbox.paypal.com"
43
+ expect(api.token_endpoint).to eql "https://api.sandbox.paypal.com"
44
44
  end
45
45
 
46
46
  it "service endpoint for live" do
47
47
  api = create_api( :mode => "live" )
48
- api.service_endpoint.should eql "https://api.paypal.com"
49
- api.token_endpoint.should eql "https://api.paypal.com"
48
+ expect(api.service_endpoint).to eql "https://api.paypal.com"
49
+ expect(api.token_endpoint).to eql "https://api.paypal.com"
50
50
  api = create_api( :mode => :live )
51
- api.service_endpoint.should eql "https://api.paypal.com"
52
- api.token_endpoint.should eql "https://api.paypal.com"
51
+ expect(api.service_endpoint).to eql "https://api.paypal.com"
52
+ expect(api.token_endpoint).to eql "https://api.paypal.com"
53
53
  end
54
54
 
55
55
  it "override service endpoint" do
56
56
  api = create_api( :rest_endpoint => "https://testing.api.paypal.com" )
57
- api.service_endpoint.should eql "https://testing.api.paypal.com"
58
- api.token_endpoint.should eql "https://testing.api.paypal.com"
57
+ expect(api.service_endpoint).to eql "https://testing.api.paypal.com"
58
+ expect(api.token_endpoint).to eql "https://testing.api.paypal.com"
59
59
  api = create_api( :endpoint => "https://testing.api.paypal.com" )
60
- api.service_endpoint.should eql "https://testing.api.paypal.com"
61
- api.token_endpoint.should eql "https://testing.api.paypal.com"
60
+ expect(api.service_endpoint).to eql "https://testing.api.paypal.com"
61
+ expect(api.token_endpoint).to eql "https://testing.api.paypal.com"
62
62
  end
63
63
 
64
64
  it "override token endpoint" do
65
65
  api = create_api( :rest_token_endpoint => "https://testing.api.paypal.com" )
66
- api.service_endpoint.should eql "https://api.sandbox.paypal.com"
67
- api.token_endpoint.should eql "https://testing.api.paypal.com"
66
+ expect(api.service_endpoint).to eql "https://api.sandbox.paypal.com"
67
+ expect(api.token_endpoint).to eql "https://testing.api.paypal.com"
68
68
  end
69
69
  end
70
70
 
71
71
  describe "Validation" do
72
72
  it "Invalid client_id and client_secret" do
73
73
  api = create_api(:with_authentication, :client_id => "XYZ", :client_secret => "ABC")
74
- lambda {
74
+ expect {
75
75
  api.token
76
- }.should raise_error PayPal::SDK::Core::Exceptions::UnauthorizedAccess
76
+ }.to raise_error PayPal::SDK::Core::Exceptions::UnauthorizedAccess
77
77
  end
78
78
 
79
79
  xit "Should handle expired token" do
80
80
  old_token = @api.token
81
81
  @api.token_hash[:expires_in] = 0
82
- @api.token.should_not eql old_token
82
+ expect(@api.token).not_to eql old_token
83
83
  end
84
84
 
85
85
  it "Get token" do
86
- @api.token.should_not be_nil
86
+ expect(@api.token).not_to be_nil
87
87
  end
88
88
  end
89
89
 
@@ -104,13 +104,13 @@ describe PayPal::SDK::Core::API::REST do
104
104
  "amount" => {
105
105
  "total" => "7.47",
106
106
  "currency" => "USD" }}]})
107
- response["error"].should be_nil
107
+ expect(response["error"]).to be_nil
108
108
  end
109
109
 
110
110
  it "List Payments" do
111
111
  response = @api.get("payment", { "count" => 10 })
112
- response["error"].should be_nil
113
- response["count"].should_not be_nil
112
+ expect(response["error"]).to be_nil
113
+ expect(response["count"]).not_to be_nil
114
114
  end
115
115
 
116
116
  it "Execute Payment"
@@ -122,26 +122,26 @@ describe PayPal::SDK::Core::API::REST do
122
122
  "expire_month" => "11", "expire_year" => "2018",
123
123
  "cvv2" => "874",
124
124
  "first_name" => "Joe", "last_name" => "Shopper" })
125
- new_funding_instrument["error"].should be_nil
126
- new_funding_instrument["id"].should_not be_nil
125
+ expect(new_funding_instrument["error"]).to be_nil
126
+ expect(new_funding_instrument["id"]).not_to be_nil
127
127
 
128
128
  funding_instrument = @vault_api.get("credit-card/#{new_funding_instrument["id"]}")
129
- funding_instrument["error"].should be_nil
130
- funding_instrument["id"].should eql new_funding_instrument["id"]
129
+ expect(funding_instrument["error"]).to be_nil
130
+ expect(funding_instrument["id"]).to eql new_funding_instrument["id"]
131
131
  end
132
132
 
133
133
  end
134
134
 
135
135
  describe "Failure request", :integration => true do
136
136
  it "Invalid Resource ID" do
137
- lambda {
137
+ expect {
138
138
  response = @api.get("payment/PAY-1234")
139
- }.should raise_error PayPal::SDK::Core::Exceptions::ResourceNotFound
139
+ }.to raise_error PayPal::SDK::Core::Exceptions::ResourceNotFound
140
140
  end
141
141
 
142
142
  it "Invalid parameters" do
143
143
  response = @api.post("payment")
144
- response["error"]["name"].should eql "VALIDATION_ERROR"
144
+ expect(response["error"]["name"]).to eql "VALIDATION_ERROR"
145
145
  end
146
146
  end
147
147
  end