straight-server 0.2.1 → 0.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 833d00355a560e1e82ce97ef09a53b0f96bdd0b0
4
- data.tar.gz: 96c715dbdd8718aaaded9810738df8ce64e8b13c
3
+ metadata.gz: 52533bcd5fc953b35fd81b8bf7f4a4b974954b01
4
+ data.tar.gz: 6d43d836466f5d29f849536b08286ee7497973f8
5
5
  SHA512:
6
- metadata.gz: 7b3a8d3401e5d2116f35692996dc188bbc8adcbaad4b79d5b22ba2fcd862b3610f8a62ac5dbc022add0f1880bd5babd31a804f088060731a8ccdbcadee7a94ba
7
- data.tar.gz: 1d611882cc686cb3d5e6905630ef3ec2fd708712bcaaa1dcbbacb83eca37965ff39f29570ad4000ab0a5aa14e2f1f5a66626238b074b5a215e53bf4deab2b4f9
6
+ metadata.gz: 1350baf54ebb72e7baf2ccfefd48fe9ffd39c309436e9ed9e52f2f174736935e6b0e9d424e6bf08bff5f1fefc6ae5c0a54343bf3082e11b285c82b606d99f461
7
+ data.tar.gz: 199b84bf7ed343c417d29d92195180c753ae73da916cd45dd4297d16b62253287ffc977056a9cc2164f8ba4ac4da09c8572368283b0b0de3f0d022b9d91fb903
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -15,6 +15,8 @@
15
15
 
16
16
  <p>Use this form to generate a new order:</p>
17
17
  Gateway id: <input name="gateway_id"/><br/>
18
+ Signature: <input name="signature"/><br/>
19
+ Keychain id: <input name="order_id"/><br/>
18
20
  Amount (in default currency for the gateway, usually in satoshi, but could be USD or EUR): <input name="amount"/>
19
21
  <p><button id="create_order">Create Order</button></p>
20
22
  </div>
@@ -5,7 +5,7 @@ jQuery(function($) {
5
5
  url: '/gateways/' + $("input[name=gateway_id]").val() + '/orders',
6
6
  type: 'POST',
7
7
  dataType: 'json',
8
- data: { amount: $("input[name=amount]").val() },
8
+ data: { amount: $("input[name=amount]").val(), signature: $("input[name=signature]").val(), order_id :$("input[name=order_id]").val() },
9
9
  success: function(response) {
10
10
  window.location = '/pay/' + response.payment_id
11
11
  }
@@ -111,11 +111,11 @@ module StraightServer
111
111
 
112
112
  StraightServer.logger.info "Creating new order with attrs: #{attrs}"
113
113
  signature = attrs.delete(:signature)
114
- if !check_signature || sign_with_secret(attrs[:id]) == signature
115
- raise InvalidOrderId if check_signature && (attrs[:id].nil? || attrs[:id].to_i <= 0)
114
+ if !check_signature || sign_with_secret(attrs[:keychain_id]) == signature
115
+ raise InvalidOrderId if check_signature && (attrs[:keychain_id].nil? || attrs[:keychain_id].to_i <= 0)
116
116
  order = order_for_keychain_id(
117
117
  amount: attrs[:amount],
118
- keychain_id: increment_last_keychain_id!,
118
+ keychain_id: attrs[:keychain_id] || increment_last_keychain_id!,
119
119
  currency: attrs[:currency],
120
120
  btc_denomination: attrs[:btc_denomination]
121
121
  )
@@ -24,7 +24,7 @@ module StraightServer
24
24
  amount: @params['amount'], # this is satoshi
25
25
  currency: @params['currency'],
26
26
  btc_denomination: @params['btc_denomination'],
27
- id: @params['order_id'],
27
+ keychain_id: @params['order_id'],
28
28
  signature: @params['signature'],
29
29
  data: @params['data']
30
30
  }
@@ -56,6 +56,12 @@ module StraightServer
56
56
  end
57
57
 
58
58
  def show
59
+
60
+ unless @gateway
61
+ StraightServer.logger.warn "Gateway not found"
62
+ return [404, {}, "Gateway not found" ]
63
+ end
64
+
59
65
  order = Order[@params['id']] || (@params['id'] =~ /[^\d]+/ && Order[:payment_id => @params['id']])
60
66
  if order
61
67
  order.status(reload: true)
@@ -14,7 +14,7 @@ RSpec.describe StraightServer::Gateway do
14
14
  @gateway.last_keychain_id = 0
15
15
  expect( -> { @gateway.create_order(amount: 1, signature: 'invalid', id: 1) }).to raise_exception(StraightServer::GatewayModule::InvalidSignature)
16
16
  expect(@gateway).to receive(:order_for_keychain_id).with(@order_for_keychain_id_args).once.and_return(@order_mock)
17
- @gateway.create_order(amount: 1, signature: hmac_sha256(1, 'secret'), id: 1)
17
+ @gateway.create_order(amount: 1, signature: hmac_sha256(1, 'secret'), keychain_id: 1)
18
18
  end
19
19
 
20
20
  it "checks md5 signature only if that setting is set ON for a particular gateway" do
@@ -164,12 +164,13 @@ RSpec.describe StraightServer::Gateway do
164
164
  end
165
165
 
166
166
  it "saves and retrieves last_keychain_id from the file in the .straight dir" do
167
+ @gateway.check_signature = false
167
168
  expect(File.read("#{ENV['HOME']}/.straight/default_last_keychain_id").to_i).to eq(0)
168
169
  @gateway.increment_last_keychain_id!
169
170
  expect(File.read("#{ENV['HOME']}/.straight/default_last_keychain_id").to_i).to eq(1)
170
171
 
171
172
  expect(@gateway).to receive(:order_for_keychain_id).with(@order_for_keychain_id_args.merge({ keychain_id: 2})).once.and_return(@order_mock)
172
- @gateway.create_order(amount: 1, signature: hmac_sha256(1, 'secret'), id: 1)
173
+ @gateway.create_order(amount: 1)
173
174
  expect(File.read("#{ENV['HOME']}/.straight/default_last_keychain_id").to_i).to eq(2)
174
175
  end
175
176
 
@@ -197,13 +198,14 @@ RSpec.describe StraightServer::Gateway do
197
198
  end
198
199
 
199
200
  it "saves and retrieves last_keychain_id from the db" do
201
+ @gateway.check_signature = false
200
202
  @gateway.save
201
203
  expect(DB[:gateways][:name => 'default'][:last_keychain_id]).to eq(0)
202
204
  @gateway.increment_last_keychain_id!
203
205
  expect(DB[:gateways][:name => 'default'][:last_keychain_id]).to eq(1)
204
206
 
205
207
  expect(@gateway).to receive(:order_for_keychain_id).with(@order_for_keychain_id_args.merge({ keychain_id: 2})).once.and_return(@order_mock)
206
- @gateway.create_order(amount: 1, signature: hmac_sha256(1, 'secret'), id: 1)
208
+ @gateway.create_order(amount: 1)
207
209
  expect(DB[:gateways][:name => 'default'][:last_keychain_id]).to eq(2)
208
210
  end
209
211
 
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: straight-server 0.2.1 ruby lib
5
+ # stub: straight-server 0.2.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "straight-server"
9
- s.version = "0.2.1"
9
+ s.version = "0.2.2"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Roman Snitko"]
14
- s.date = "2015-05-07"
14
+ s.date = "2015-05-10"
15
15
  s.description = "Accepts orders via http, returns payment info via http or streams updates via websockets, stores orders in a DB"
16
16
  s.email = "roman.snitko@gmail.com"
17
17
  s.executables = ["goliath.log", "goliath.log_stdout.log", "straight-console", "straight-server", "straight-server-benchmark"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: straight-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Snitko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-07 00:00:00.000000000 Z
11
+ date: 2015-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: straight