creative-paypal-express 1.2.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/circle.yml +6 -0
- data/creative-paypal-express.gemspec +3 -2
- data/lib/paypal/express/request.rb +4 -5
- data/lib/paypal/express/response.rb +1 -1
- data/lib/paypal/nvp/request.rb +3 -3
- data/lib/paypal/nvp/response.rb +7 -2
- data/lib/paypal/payment/response.rb +4 -1
- data/lib/paypal/util.rb +2 -2
- data/spec/helpers/fake_response_helper.rb +32 -1
- data/spec/paypal/exception/api_error_spec.rb +1 -3
- data/spec/paypal/exception/http_error_spec.rb +1 -3
- data/spec/paypal/express/request_spec.rb +17 -9
- data/spec/paypal/ipn_spec.rb +1 -3
- data/spec/paypal/nvp/request_spec.rb +1 -3
- data/spec/paypal/nvp/response_spec.rb +16 -2
- data/spec/paypal/util_spec.rb +1 -3
- data/spec/spec_helper.rb +4 -0
- metadata +12 -12
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5dd169c91e9532a067b8d075e4b2024b5780026c
|
|
4
|
+
data.tar.gz: 61519d004da8d2b51dc79cd5f832dec82fd711e1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b9b3991b6e6fd62441d38beac1d41324be5716a18ce3199beb11e37d5dee2f375cc4db841c1e477c540b6fcd25b3a4e96f3629875334117093156d8ea9948f0b
|
|
7
|
+
data.tar.gz: fd01eee4f2c878d650543b690f910a07eb43adfb14819e9191e2a9f824ffedfbe3d27774ed157d722a25113495726b3b63c356d384d45dea79e8e81f5e7c4948
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.
|
|
1
|
+
1.3.0
|
data/circle.yml
ADDED
|
@@ -16,13 +16,14 @@ Gem::Specification.new do |s|
|
|
|
16
16
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
17
17
|
|
|
18
18
|
s.add_dependency "activesupport", ">= 4"
|
|
19
|
-
s.add_dependency "rest-client"
|
|
19
|
+
s.add_dependency "rest-client", "~> 2.0.0"
|
|
20
20
|
s.add_dependency "attr_required", ">= 0.0.5"
|
|
21
21
|
|
|
22
22
|
# s.add_development_dependency "activesupport", "4.1" # uses this for development, but will probably work with higher versions
|
|
23
|
-
s.add_development_dependency "rake", "
|
|
23
|
+
s.add_development_dependency "rake", "~> 10.5.0"
|
|
24
24
|
s.add_development_dependency "simplecov"
|
|
25
25
|
s.add_development_dependency "rspec", "< 2.99"
|
|
26
26
|
s.add_development_dependency "fakeweb", ">= 1.3.0"
|
|
27
|
+
# s.add_development_dependency "webmock", "~> 2.3.1"
|
|
27
28
|
s.add_development_dependency "pry"
|
|
28
29
|
end
|
|
@@ -31,12 +31,12 @@ module Paypal
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
Array(payment_requests).each_with_index do |payment_request, index|
|
|
34
|
-
params.merge!
|
|
34
|
+
params.merge!(payment_request.to_params(index))
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
response = request(:SetExpressCheckout, params)
|
|
38
38
|
|
|
39
|
-
Response.new
|
|
39
|
+
Response.new(response, options)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
def details(token)
|
|
@@ -98,8 +98,8 @@ module Paypal
|
|
|
98
98
|
params = {
|
|
99
99
|
:PROFILEID => profile_id
|
|
100
100
|
}
|
|
101
|
-
response = self.request
|
|
102
|
-
Response.new
|
|
101
|
+
response = self.request(:GetRecurringPaymentsProfileDetails, params)
|
|
102
|
+
Response.new(response)
|
|
103
103
|
end
|
|
104
104
|
|
|
105
105
|
def renew!(profile_id, action, options = {})
|
|
@@ -185,7 +185,6 @@ module Paypal
|
|
|
185
185
|
Response.new response
|
|
186
186
|
end
|
|
187
187
|
|
|
188
|
-
|
|
189
188
|
#== Refund Specific
|
|
190
189
|
def refund!(transaction_id, options = {})
|
|
191
190
|
params = {
|
data/lib/paypal/nvp/request.rb
CHANGED
|
@@ -44,20 +44,20 @@ module Paypal
|
|
|
44
44
|
def post(method, params)
|
|
45
45
|
rest_params = common_params.merge(params).merge(METHOD: method)
|
|
46
46
|
|
|
47
|
-
response = RestClient.post(
|
|
47
|
+
response = RestClient.post(send(:class).endpoint, rest_params)
|
|
48
48
|
|
|
49
49
|
puts ">> Paypal::NVP Got response to POST request <<"
|
|
50
50
|
puts "Request arguments:\nendpoint: #{self.class.endpoint}\nparams: #{rest_params})\n"
|
|
51
51
|
puts "Response string:\n#{response}"
|
|
52
52
|
puts "=============================================="
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
response
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
def handle_response
|
|
58
58
|
response = yield
|
|
59
59
|
response = CGI.parse(response).inject({}) do |res, (k, v)|
|
|
60
|
-
res.merge!(k.to_sym => v.first)
|
|
60
|
+
res.merge!(k.to_sym => v.first.to_s)
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
case response[:ACK]
|
data/lib/paypal/nvp/response.rb
CHANGED
|
@@ -193,8 +193,9 @@ module Paypal
|
|
|
193
193
|
payment_responses[index.to_i][key.to_sym] = attrs.delete(_attr_)
|
|
194
194
|
end
|
|
195
195
|
end
|
|
196
|
+
|
|
196
197
|
@payment_responses = payment_responses.collect do |_attrs_|
|
|
197
|
-
Payment::Response.new
|
|
198
|
+
Payment::Response.new(_attrs_)
|
|
198
199
|
end
|
|
199
200
|
|
|
200
201
|
# payment_info
|
|
@@ -234,7 +235,11 @@ module Paypal
|
|
|
234
235
|
end
|
|
235
236
|
|
|
236
237
|
def to_s
|
|
237
|
-
|
|
238
|
+
@raw_response.to_s
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
def to_json
|
|
242
|
+
@raw_response.to_json
|
|
238
243
|
end
|
|
239
244
|
end
|
|
240
245
|
end
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
module Paypal
|
|
2
2
|
module Payment
|
|
3
3
|
class Response < Base
|
|
4
|
-
attr_accessor :amount, :ship_to, :bill_to, :description, :note, :items,
|
|
4
|
+
attr_accessor :amount, :ship_to, :bill_to, :description, :note, :items,
|
|
5
|
+
:notify_url, :insurance_option_offered, :currency_code, :short_message,
|
|
6
|
+
:long_message, :error_code, :severity_code, :ack, :transaction_id,
|
|
7
|
+
:billing_agreement_id, :request_id, :seller_id
|
|
5
8
|
|
|
6
9
|
def initialize(attributes = {})
|
|
7
10
|
attrs = attributes.dup
|
data/lib/paypal/util.rb
CHANGED
|
@@ -3,7 +3,7 @@ module Paypal
|
|
|
3
3
|
|
|
4
4
|
def self.formatted_amount(x)
|
|
5
5
|
# Thanks @nahi ;)
|
|
6
|
-
sprintf "%0.2f", BigDecimal.new(x.to_s).truncate(2)
|
|
6
|
+
sprintf "%0.2f", BigDecimal.new(x.to_f.to_s).truncate(2)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def self.to_numeric(x)
|
|
@@ -25,4 +25,4 @@ module Paypal
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
end
|
|
28
|
-
end
|
|
28
|
+
end
|
|
@@ -30,4 +30,35 @@ module FakeResponseHelper
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
FakeWeb.allow_net_connect = false
|
|
33
|
-
include FakeResponseHelper
|
|
33
|
+
include FakeResponseHelper
|
|
34
|
+
|
|
35
|
+
# require 'webmock'
|
|
36
|
+
# WebMock.enable!
|
|
37
|
+
# WebMock.disable_net_connect!(allow_localhost: true)
|
|
38
|
+
|
|
39
|
+
# module FakeResponseHelper
|
|
40
|
+
# def fake_response(file_path, api = :NVP, options = {})
|
|
41
|
+
# endpoint = case api
|
|
42
|
+
# when :NVP
|
|
43
|
+
# Paypal::NVP::Request.endpoint
|
|
44
|
+
# when :IPN
|
|
45
|
+
# Paypal::IPN.endpoint
|
|
46
|
+
# else
|
|
47
|
+
# raise "Non-supported API: #{api}"
|
|
48
|
+
# end
|
|
49
|
+
|
|
50
|
+
# body = File.read(File.join(File.dirname(__FILE__), '../fake_response', "#{file_path}.txt"))
|
|
51
|
+
|
|
52
|
+
# WebMock.stub_request(:post, %r'#{endpoint}').
|
|
53
|
+
# to_return(body: body, status: 200, headers: {})
|
|
54
|
+
# end
|
|
55
|
+
|
|
56
|
+
# def request_to(endpoint, method = :get)
|
|
57
|
+
# raise_error(
|
|
58
|
+
# RuntimeError,
|
|
59
|
+
# "Real HTTP connections are disabled. Unregistered request: #{method.to_s.upcase} #{endpoint}"
|
|
60
|
+
# )
|
|
61
|
+
# end
|
|
62
|
+
# end
|
|
63
|
+
|
|
64
|
+
# include FakeResponseHelper
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
require 'spec_helper.rb'
|
|
2
|
-
|
|
3
1
|
describe Paypal::Exception::APIError do
|
|
4
2
|
let(:error) { Paypal::Exception::APIError.new(params) }
|
|
5
3
|
|
|
@@ -75,4 +73,4 @@ describe Paypal::Exception::APIError do
|
|
|
75
73
|
its(:response) { should == params }
|
|
76
74
|
its(:message) { should == "PayPal API Error" }
|
|
77
75
|
end
|
|
78
|
-
end
|
|
76
|
+
end
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
require 'spec_helper.rb'
|
|
2
|
-
|
|
3
1
|
describe Paypal::Exception::HttpError do
|
|
4
2
|
subject { Paypal::Exception::HttpError.new(400, 'BadRequest', 'You are bad man!') }
|
|
5
3
|
its(:code) { should == 400 }
|
|
6
4
|
its(:message) { should == 'BadRequest' }
|
|
7
5
|
its(:body) { should == 'You are bad man!' }
|
|
8
|
-
end
|
|
6
|
+
end
|
|
@@ -2,14 +2,21 @@
|
|
|
2
2
|
describe Paypal::Express::Request do
|
|
3
3
|
class Paypal::Express::Request
|
|
4
4
|
attr_accessor :_sent_params_, :_method_
|
|
5
|
-
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
module Verbose
|
|
8
|
+
def request(method, params = {})
|
|
6
9
|
self._method_ = method
|
|
7
10
|
self._sent_params_ = params
|
|
8
|
-
|
|
11
|
+
|
|
12
|
+
handle_response do
|
|
13
|
+
post(method, params)
|
|
14
|
+
end
|
|
9
15
|
end
|
|
10
|
-
alias_method_chain :post, :logging
|
|
11
16
|
end
|
|
12
17
|
|
|
18
|
+
Paypal::Express::Request.include(Verbose)
|
|
19
|
+
|
|
13
20
|
let(:return_url) { 'http://example.com/success' }
|
|
14
21
|
let(:cancel_url) { 'http://example.com/cancel' }
|
|
15
22
|
let(:nvp_endpoint) { Paypal::NVP::Request::ENDPOINT[:production] }
|
|
@@ -103,16 +110,17 @@ describe Paypal::Express::Request do
|
|
|
103
110
|
end
|
|
104
111
|
|
|
105
112
|
describe '#setup' do
|
|
106
|
-
it '
|
|
113
|
+
it 'returns Paypal::Express::Response' do
|
|
107
114
|
fake_response 'SetExpressCheckout/success'
|
|
108
|
-
response = instance.setup
|
|
115
|
+
response = instance.setup(recurring_payment_request, return_url, cancel_url)
|
|
109
116
|
response.should be_instance_of Paypal::Express::Response
|
|
110
117
|
end
|
|
111
118
|
|
|
112
|
-
it '
|
|
113
|
-
expect
|
|
114
|
-
instance.setup
|
|
115
|
-
|
|
119
|
+
it 'supports no_shipping option' do
|
|
120
|
+
expect {
|
|
121
|
+
instance.setup(instant_payment_request, return_url, cancel_url, :no_shipping => true)
|
|
122
|
+
}.to(request_to(nvp_endpoint, :post))
|
|
123
|
+
|
|
116
124
|
instance._method_.should == :SetExpressCheckout
|
|
117
125
|
instance._sent_params_.should == {
|
|
118
126
|
:PAYMENTREQUEST_0_DESC => 'Instant Payment Request',
|
data/spec/paypal/ipn_spec.rb
CHANGED
|
@@ -124,7 +124,7 @@ describe Paypal::NVP::Response do
|
|
|
124
124
|
|
|
125
125
|
it 'should handle all attributes' do
|
|
126
126
|
Paypal.logger.should_not_receive(:warn)
|
|
127
|
-
response = request.subscription
|
|
127
|
+
response = request.subscription('profile_id')
|
|
128
128
|
response.recurring.billing.amount.total.should == 1000
|
|
129
129
|
response.recurring.regular_billing.paid.should == 1000
|
|
130
130
|
response.recurring.summary.next_billing_date.should == '2011-03-04T10:00:00Z'
|
|
@@ -148,11 +148,25 @@ describe Paypal::NVP::Response do
|
|
|
148
148
|
fake_response 'SetExpressCheckout/success'
|
|
149
149
|
end
|
|
150
150
|
|
|
151
|
-
it "
|
|
151
|
+
it "returns a stringified representation of the response->hash conversion" do
|
|
152
152
|
response = request.setup(payment_request, return_url, cancel_url)
|
|
153
153
|
|
|
154
154
|
expect(response.to_s).to eq("{:ACK=>\"Success\", :BUILD=>\"1721431\", :CORRELATIONID=>\"5549ea3a78af1\", :TIMESTAMP=>\"2011-02-02T02:02:18Z\", :TOKEN=>\"EC-5YJ90598G69065317\", :VERSION=>\"66.0\"}")
|
|
155
155
|
end
|
|
156
156
|
end
|
|
157
157
|
|
|
158
|
+
describe "#to_json" do
|
|
159
|
+
before do
|
|
160
|
+
fake_response 'SetExpressCheckout/success'
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
it "returns a JSON representation of the response->hash conversion" do
|
|
164
|
+
response = request.setup(payment_request, return_url, cancel_url)
|
|
165
|
+
|
|
166
|
+
expect(response.to_json).to eq(
|
|
167
|
+
"{\"ACK\":\"Success\",\"BUILD\":\"1721431\",\"CORRELATIONID\":\"5549ea3a78af1\",\"TIMESTAMP\":\"2011-02-02T02:02:18Z\",\"TOKEN\":\"EC-5YJ90598G69065317\",\"VERSION\":\"66.0\"}"
|
|
168
|
+
)
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
|
|
158
172
|
end
|
data/spec/paypal/util_spec.rb
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
require 'spec_helper.rb'
|
|
2
|
-
|
|
3
1
|
describe Paypal::Util do
|
|
4
2
|
describe '.formatted_amount' do
|
|
5
3
|
it 'should return String in "xx.yy" format' do
|
|
@@ -29,4 +27,4 @@ describe Paypal::Util do
|
|
|
29
27
|
Paypal::Util.to_numeric('10.25').should == 10.25
|
|
30
28
|
end
|
|
31
29
|
end
|
|
32
|
-
end
|
|
30
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: creative-paypal-express
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- nov matake
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2017-
|
|
12
|
+
date: 2017-10-12 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activesupport
|
|
@@ -29,16 +29,16 @@ dependencies:
|
|
|
29
29
|
name: rest-client
|
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
|
31
31
|
requirements:
|
|
32
|
-
- - "
|
|
32
|
+
- - "~>"
|
|
33
33
|
- !ruby/object:Gem::Version
|
|
34
|
-
version:
|
|
34
|
+
version: 2.0.0
|
|
35
35
|
type: :runtime
|
|
36
36
|
prerelease: false
|
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
|
38
38
|
requirements:
|
|
39
|
-
- - "
|
|
39
|
+
- - "~>"
|
|
40
40
|
- !ruby/object:Gem::Version
|
|
41
|
-
version:
|
|
41
|
+
version: 2.0.0
|
|
42
42
|
- !ruby/object:Gem::Dependency
|
|
43
43
|
name: attr_required
|
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -57,16 +57,16 @@ dependencies:
|
|
|
57
57
|
name: rake
|
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
|
59
59
|
requirements:
|
|
60
|
-
- - "
|
|
60
|
+
- - "~>"
|
|
61
61
|
- !ruby/object:Gem::Version
|
|
62
|
-
version:
|
|
62
|
+
version: 10.5.0
|
|
63
63
|
type: :development
|
|
64
64
|
prerelease: false
|
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
|
66
66
|
requirements:
|
|
67
|
-
- - "
|
|
67
|
+
- - "~>"
|
|
68
68
|
- !ruby/object:Gem::Version
|
|
69
|
-
version:
|
|
69
|
+
version: 10.5.0
|
|
70
70
|
- !ruby/object:Gem::Dependency
|
|
71
71
|
name: simplecov
|
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -135,13 +135,13 @@ files:
|
|
|
135
135
|
- ".document"
|
|
136
136
|
- ".gitignore"
|
|
137
137
|
- ".rspec"
|
|
138
|
-
- ".travis.yml"
|
|
139
138
|
- CHANGELOG.md
|
|
140
139
|
- Gemfile
|
|
141
140
|
- LICENSE
|
|
142
141
|
- README.md
|
|
143
142
|
- Rakefile
|
|
144
143
|
- VERSION
|
|
144
|
+
- circle.yml
|
|
145
145
|
- creative-paypal-express.gemspec
|
|
146
146
|
- lib/paypal.rb
|
|
147
147
|
- lib/paypal/base.rb
|
|
@@ -238,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
238
238
|
version: 1.3.6
|
|
239
239
|
requirements: []
|
|
240
240
|
rubyforge_project:
|
|
241
|
-
rubygems_version: 2.2.
|
|
241
|
+
rubygems_version: 2.5.2.1
|
|
242
242
|
signing_key:
|
|
243
243
|
specification_version: 4
|
|
244
244
|
summary: PayPal Express Checkout API Client for Instance, Recurring and Digital Goods
|