apruve 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 768587ceb2db4b6f9cee28a0ca12c24f95b2a15a
4
+ data.tar.gz: b11a64be202300c00734e2c2374723e828ca3357
5
+ SHA512:
6
+ metadata.gz: 8881b9309a56ba775b8e9c987e9cfa62c600919072621ba64463dad5f96ca469c8709469071a09732aa12a49df47c37b3277be1f26ba29ab1e24bf64c2314fe0
7
+ data.tar.gz: 26b8c2fa1712781b992b3e22a57ae38a33bda6dede1fa43c86973289b3b7f9f1deb49e6663d8fc136574a013941c6c65c7886e5b3e6d2534cfab7576d04be96b
data/Gemfile CHANGED
@@ -16,14 +16,11 @@ group :development do
16
16
  end
17
17
 
18
18
  group :test do
19
-
20
- gem 'ruby-debug-base19x'
21
- gem 'ruby-debug-ide'
22
-
23
19
  gem 'faker'
24
20
  gem 'net-http-persistent'
25
- gem 'rspec', '~> 2.14.1'
26
- gem 'rake', '~> 10.0.3'
27
- gem 'vcr', '~> 2.4.0'
21
+ gem 'rspec'
22
+ gem 'rspec-its'
23
+ gem 'rake'
24
+ gem 'vcr'
28
25
  gem 'webmock'
29
26
  end
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- apruve (0.9.1)
5
- addressable (~> 2.3.5)
4
+ apruve (0.9.2)
5
+ addressable (~> 2.3)
6
6
  faraday (>= 0.8.6, <= 0.9.0)
7
- faraday_middleware (~> 0.9.0)
7
+ faraday_middleware (~> 0.9)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
@@ -13,7 +13,6 @@ GEM
13
13
  coderay (1.1.0)
14
14
  crack (0.4.2)
15
15
  safe_yaml (~> 1.0.0)
16
- debugger-ruby_core_source (1.3.2)
17
16
  diff-lcs (1.2.5)
18
17
  faker (1.3.0)
19
18
  i18n (~> 0.5)
@@ -37,40 +36,38 @@ GEM
37
36
  rb-fsevent (>= 0.9.3)
38
37
  rb-inotify (>= 0.9)
39
38
  rb-kqueue (>= 0.2)
40
- lumberjack (1.0.5)
39
+ lumberjack (1.0.7)
41
40
  method_source (0.8.2)
42
41
  multipart-post (2.0.0)
43
42
  net-http-persistent (2.9.4)
44
- pry (0.9.12.6)
45
- coderay (~> 1.0)
46
- method_source (~> 0.8)
43
+ pry (0.10.0)
44
+ coderay (~> 1.1.0)
45
+ method_source (~> 0.8.1)
47
46
  slop (~> 3.4)
48
- rake (10.0.4)
47
+ rake (10.3.2)
49
48
  rb-fsevent (0.9.4)
50
- rb-inotify (0.9.4)
49
+ rb-inotify (0.9.5)
51
50
  ffi (>= 0.5.0)
52
- rb-kqueue (0.2.2)
51
+ rb-kqueue (0.2.3)
53
52
  ffi (>= 0.5.0)
54
- rspec (2.14.1)
55
- rspec-core (~> 2.14.0)
56
- rspec-expectations (~> 2.14.0)
57
- rspec-mocks (~> 2.14.0)
58
- rspec-core (2.14.8)
59
- rspec-expectations (2.14.5)
53
+ rspec (2.99.0)
54
+ rspec-core (~> 2.99.0)
55
+ rspec-expectations (~> 2.99.0)
56
+ rspec-mocks (~> 2.99.0)
57
+ rspec-core (2.99.1)
58
+ rspec-expectations (2.99.1)
60
59
  diff-lcs (>= 1.1.3, < 2.0)
61
- rspec-mocks (2.14.6)
62
- ruby-debug-base19x (0.11.30.pre15)
63
- debugger-ruby_core_source (> 0)
64
- rake (>= 0.8.1)
65
- ruby-debug-ide (0.4.22)
66
- rake (>= 0.8.1)
60
+ rspec-its (1.0.1)
61
+ rspec-core (>= 2.99.0.beta1)
62
+ rspec-expectations (>= 2.99.0.beta1)
63
+ rspec-mocks (2.99.1)
67
64
  safe_yaml (1.0.3)
68
65
  slop (3.5.0)
69
66
  terminal-table (1.4.5)
70
67
  thor (0.19.1)
71
- vcr (2.4.0)
72
- webmock (1.17.4)
73
- addressable (>= 2.2.7)
68
+ vcr (2.9.2)
69
+ webmock (1.18.0)
70
+ addressable (>= 2.3.6)
74
71
  crack (>= 0.3.2)
75
72
  yard (0.8.7.4)
76
73
 
@@ -89,10 +86,9 @@ DEPENDENCIES
89
86
  json
90
87
  listen (~> 1.3.1)
91
88
  net-http-persistent
92
- rake (~> 10.0.3)
93
- rspec (~> 2.14.1)
94
- ruby-debug-base19x
95
- ruby-debug-ide
96
- vcr (~> 2.4.0)
89
+ rake
90
+ rspec
91
+ rspec-its
92
+ vcr
97
93
  webmock
98
94
  yard
data/README.md CHANGED
@@ -18,22 +18,106 @@ Or install it yourself as:
18
18
 
19
19
  $ gem install apruve
20
20
 
21
- ## Usage
21
+ ## Usage (merchant integration)
22
22
 
23
- ### Create a store on Apruve. Use test.apruve.com for test accounts.
23
+ The following snippets are based on our apruve-ruby-demo project, which is a functional demo of how a merchant can
24
+ integrate Apruve.
25
+
26
+ [https://github.com/apruve/apruve-ruby-demo](https://github.com/apruve/apruve-ruby-demo)
27
+
28
+ ### Create an account on Apruve.
29
+
30
+ Have a look though our [Getting Started documentation](https://www.apruve.com/doc/developers/) and be sure to use
31
+ test.apruve.com for test accounts.
32
+
33
+ ### Initialize the library
34
+
35
+ For [test.apruve.com](test.apruve.com)
36
+ Apruve.configure('YOUR_APRUVE_API_KEY', 'test')
37
+
38
+ For [www.apruve.com](www.apruve.com)
39
+ Apruve.configure('YOUR_APRUVE_API_KEY', 'prod')
24
40
 
25
41
  ### Create a PaymentRequest
26
- @pr = Apruve::PaymentRequest.new
27
- @pr.merchant_id =
28
42
 
29
- ### On your web page, declare apruve.js
43
+ @payment_request = Apruve::PaymentRequest.new(
44
+ merchant_id: your_merchant_id,
45
+ currency: 'USD',
46
+ amount_cents: 6000,
47
+ shipping_cents: 500
48
+ )
49
+
50
+ @payment_request.line_items << Apruve::LineItem.new(
51
+ title: 'Letter Paper',
52
+ description: '20 lb ream (500 Sheets). Paper dimensions are 8.5 x 11.00 inches.',
53
+ sku: 'LTR-20R',
54
+ price_ea_cents: 1200,
55
+ quantity: 3,
56
+ amount_cents: 3600,
57
+ view_product_url: 'https://www.example.com/letter-paper'
58
+ )
59
+
60
+ ### On your web page...
61
+
62
+ (example in ERB...)
63
+
64
+ At the top of the file, import the apruve.js script.
65
+
66
+ <%= Apruve.js %>
67
+
68
+ Write a little Javascript to configure apruve.js
69
+
70
+ 1. set the secure hash
71
+ 2. set the payment request
72
+ 3. register a callback to capture apruve.paymentRequestId
73
+
74
+ ``` javascript
75
+ apruve.secureHash = '<%= @payment_request.secure_hash %>';
76
+ apruve.paymentRequest = <%= @payment_request.to_json %>;
77
+ apruve.registerApruveCallback(apruve.APRUVE_COMPLETE_EVENT, function () {
78
+ $('#paymentRequestId').val(apruve.paymentRequestId)
79
+ $('#finishOrder').submit();
80
+ });
81
+ ```
82
+
83
+ Decide where to put the Apruve button
84
+
85
+ <%= Apruve.button %>
86
+
87
+ ### Back on your server...
88
+
89
+ Use the paymentRequestId to create a Payment
90
+
91
+ apruve_payment = Apruve::Payment.new(payment_request_id: params[:payment_request_id], amount_cents: 12345)
92
+ apruve_payment.save!
93
+
94
+ Save the status and the payment ID with the payment in your database
95
+
96
+ # dependent on your system, but something like this...
97
+ my_payment.apruve_payment_id = apruve_payment.id
98
+ my_payment.apruve_payment_status = apruve_payment.status
99
+ my_payment.save!
100
+
101
+ (optional) If you track orders separately from payments, save the paymentRequestId with your order in your database
102
+
103
+ # dependent on your system, but something like this...
104
+ my_order.apruve_payment_request = params[:payment_request_id]
105
+ my_order.save
30
106
 
107
+ ### Create a web hook listener
31
108
 
32
- 3. Load the PaymentRequest and it's hash into apruve.js
33
- 4. Decide where to put the Apruve button
34
- 5. Register a call-back function to get the transaction ID back to your server
35
- 6. Tell Apruve to create a payment against the transaction ID
36
- 7. Process the webhook from Apruve when payment is received
109
+ # dependent on your system, but if you use Sinatra, it might look something like this...
110
+ post '/webhook_notify' do
111
+ # We got a webhook. You should look up the order in your database and complete or cancel it as appropriate.
112
+ puts "GOT WEBHOOK DATA FOR PAYMENT #{@webhook_data}"
113
+ my_payment.find_by_apruve_payment_id(@webhook_data[:payment_id])
114
+ my_payment.apruve_payment_status = @webhook_data[:status]
115
+ if my_payment.apruve_payment_status == 'captured'
116
+ my_payment.complete_order
117
+ elsif my_payment.apruve_payment_status == 'rejected'
118
+ my_payment.cancel_order
119
+ end
120
+ end
37
121
 
38
122
  ## Contributing
39
123
 
@@ -19,9 +19,9 @@ Gem::Specification.new do |gem|
19
19
  gem.require_paths = ['lib']
20
20
 
21
21
  gem.add_development_dependency 'bundler', '~> 1.5'
22
- gem.add_development_dependency 'rake'
22
+ gem.add_development_dependency 'rake', '~> 10.3'
23
23
 
24
24
  gem.add_dependency('faraday', ['>= 0.8.6', '<= 0.9.0'])
25
- gem.add_dependency('faraday_middleware', '~> 0.9.0')
26
- gem.add_dependency('addressable', '~> 2.3.5')
25
+ gem.add_dependency('faraday_middleware', '~> 0.9')
26
+ gem.add_dependency('addressable', '~> 2.3')
27
27
  end
@@ -1,7 +1,7 @@
1
1
  module Apruve
2
2
  class SubscriptionAdjustment < Apruve::ApruveObject
3
3
  attr_accessor :id, :subscription_id, :status, :title, :amount_cents, :price_ea_cents, :quantity, :description,
4
- :variant_info, :sku, :vendor, :view_product_url
4
+ :variant_info, :sku, :vendor, :view_product_url, :api_url
5
5
 
6
6
  def self.find(subscription_id, id)
7
7
  response = Apruve.get("subscriptions/#{subscription_id}/adjustments/#{id}")
@@ -1,3 +1,3 @@
1
1
  module Apruve
2
- VERSION = '0.9.1'
2
+ VERSION = '0.9.2'
3
3
  end
@@ -34,9 +34,9 @@ describe Faraday::Response::RaiseApruveError, :type => :response do
34
34
  })]
35
35
  }
36
36
 
37
- lambda {
37
+ expect {
38
38
  connection.get('/error')
39
- }.should raise_error(Apruve::BadRequest)
39
+ }.to raise_error(Apruve::BadRequest)
40
40
  end
41
41
 
42
42
  end
@@ -9,6 +9,7 @@ end
9
9
  require 'rubygems'
10
10
  require 'faker'
11
11
  require 'vcr'
12
+ require 'rspec/its'
12
13
 
13
14
  RSpec.configure do |config|
14
15
  # config.include Rack::Test::Methods
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apruve
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
5
- prerelease:
4
+ version: 0.9.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Apruve, Inc.
@@ -10,94 +9,84 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2014-05-15 00:00:00.000000000 Z
12
+ date: 2014-06-23 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: bundler
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ~>
18
+ - - "~>"
21
19
  - !ruby/object:Gem::Version
22
20
  version: '1.5'
23
21
  type: :development
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ~>
25
+ - - "~>"
29
26
  - !ruby/object:Gem::Version
30
27
  version: '1.5'
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: rake
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
- - - ! '>='
32
+ - - "~>"
37
33
  - !ruby/object:Gem::Version
38
- version: '0'
34
+ version: '10.3'
39
35
  type: :development
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
- - - ! '>='
39
+ - - "~>"
45
40
  - !ruby/object:Gem::Version
46
- version: '0'
41
+ version: '10.3'
47
42
  - !ruby/object:Gem::Dependency
48
43
  name: faraday
49
44
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
45
  requirements:
52
- - - ! '>='
46
+ - - ">="
53
47
  - !ruby/object:Gem::Version
54
48
  version: 0.8.6
55
- - - <=
49
+ - - "<="
56
50
  - !ruby/object:Gem::Version
57
51
  version: 0.9.0
58
52
  type: :runtime
59
53
  prerelease: false
60
54
  version_requirements: !ruby/object:Gem::Requirement
61
- none: false
62
55
  requirements:
63
- - - ! '>='
56
+ - - ">="
64
57
  - !ruby/object:Gem::Version
65
58
  version: 0.8.6
66
- - - <=
59
+ - - "<="
67
60
  - !ruby/object:Gem::Version
68
61
  version: 0.9.0
69
62
  - !ruby/object:Gem::Dependency
70
63
  name: faraday_middleware
71
64
  requirement: !ruby/object:Gem::Requirement
72
- none: false
73
65
  requirements:
74
- - - ~>
66
+ - - "~>"
75
67
  - !ruby/object:Gem::Version
76
- version: 0.9.0
68
+ version: '0.9'
77
69
  type: :runtime
78
70
  prerelease: false
79
71
  version_requirements: !ruby/object:Gem::Requirement
80
- none: false
81
72
  requirements:
82
- - - ~>
73
+ - - "~>"
83
74
  - !ruby/object:Gem::Version
84
- version: 0.9.0
75
+ version: '0.9'
85
76
  - !ruby/object:Gem::Dependency
86
77
  name: addressable
87
78
  requirement: !ruby/object:Gem::Requirement
88
- none: false
89
79
  requirements:
90
- - - ~>
80
+ - - "~>"
91
81
  - !ruby/object:Gem::Version
92
- version: 2.3.5
82
+ version: '2.3'
93
83
  type: :runtime
94
84
  prerelease: false
95
85
  version_requirements: !ruby/object:Gem::Requirement
96
- none: false
97
86
  requirements:
98
- - - ~>
87
+ - - "~>"
99
88
  - !ruby/object:Gem::Version
100
- version: 2.3.5
89
+ version: '2.3'
101
90
  description: Easily integrate the Apruve B2B payment network into your ruby-based
102
91
  application.
103
92
  email:
@@ -106,8 +95,8 @@ executables: []
106
95
  extensions: []
107
96
  extra_rdoc_files: []
108
97
  files:
109
- - .gitignore
110
- - .rspec
98
+ - ".gitignore"
99
+ - ".rspec"
111
100
  - Gemfile
112
101
  - Gemfile.lock
113
102
  - LICENSE.txt
@@ -144,27 +133,26 @@ files:
144
133
  homepage: https://www.apruve.com
145
134
  licenses:
146
135
  - MIT
136
+ metadata: {}
147
137
  post_install_message:
148
138
  rdoc_options: []
149
139
  require_paths:
150
140
  - lib
151
141
  required_ruby_version: !ruby/object:Gem::Requirement
152
- none: false
153
142
  requirements:
154
- - - ! '>='
143
+ - - ">="
155
144
  - !ruby/object:Gem::Version
156
145
  version: '0'
157
146
  required_rubygems_version: !ruby/object:Gem::Requirement
158
- none: false
159
147
  requirements:
160
- - - ! '>='
148
+ - - ">="
161
149
  - !ruby/object:Gem::Version
162
150
  version: '0'
163
151
  requirements: []
164
152
  rubyforge_project:
165
- rubygems_version: 1.8.23
153
+ rubygems_version: 2.2.2
166
154
  signing_key:
167
- specification_version: 3
155
+ specification_version: 4
168
156
  summary: Helper library for integrating Apruve into a ruby app.
169
157
  test_files:
170
158
  - spec/apruve/apruve_spec.rb