rmoolah 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/README.md +14 -2
- data/lib/rmoolah/transaction.rb +73 -0
- data/lib/rmoolah/version.rb +1 -1
- data/test/fixtures/create_success.json +1 -0
- data/test/fixtures/fetch_success.json +1 -0
- data/test/helper.rb +11 -0
- data/test/test_transaction.rb +24 -0
- metadata +14 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c41bfa853f04b54b57b64a660bf616394d8ada92
|
4
|
+
data.tar.gz: d3dcbba3ff5b642ad3d18b124704f18e2c0e4ffe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbd412283417d5de43cf32211bf4fa530e2c01503ff0b4eb680b8c6737813235cddab95854467933149162b9e30119e868557d245fa415ac9c6468eae41e5c34
|
7
|
+
data.tar.gz: f9d98ddc89693ca047dca46cfeda30c794570721f609e8c99112d521611591cf98cf1978498376752a274733f110b6d9fa46037bd852cf30a43361ceffc0f705
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rmoolah
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.1
|
data/README.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# Rmoolah
|
2
2
|
|
3
|
-
|
3
|
+
[![Build Status](https://travis-ci.org/egze/rmoolah.svg?branch=master)](https://travis-ci.org/egze/rmoolah)
|
4
|
+
|
5
|
+
With moolah.io you can process payments in-store and online. Rmoolah is a API wrapper for moolah.io
|
6
|
+
|
7
|
+
Developed by [@egze] for [9flats.com]
|
8
|
+
|
4
9
|
|
5
10
|
## Installation
|
6
11
|
|
@@ -42,10 +47,17 @@ transaction.status
|
|
42
47
|
=> "pending"
|
43
48
|
```
|
44
49
|
|
50
|
+
Look at tests for further examples.
|
51
|
+
|
45
52
|
## Contributing
|
46
53
|
|
47
|
-
1. Fork it ( https://github.com/
|
54
|
+
1. Fork it ( https://github.com/egze/rmoolah/fork )
|
48
55
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
49
56
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
50
57
|
4. Push to the branch (`git push origin my-new-feature`)
|
51
58
|
5. Create a new Pull Request
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
[@egze]:http://www.github.com/egze/
|
63
|
+
[9flats.com]:http://www.9flats.com/
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module Rmoolah
|
2
|
+
|
3
|
+
class Transaction
|
4
|
+
|
5
|
+
include HTTParty
|
6
|
+
|
7
|
+
debug_output $stderr
|
8
|
+
|
9
|
+
base_uri 'https://moolah.io'
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def fetch(tx)
|
13
|
+
self.new(nil, nil, nil, nil, nil).fetch(tx)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
attr_reader :tx,
|
18
|
+
:address,
|
19
|
+
:amount_requested,
|
20
|
+
:currency_requested,
|
21
|
+
:amount_to_pay,
|
22
|
+
:currency_to_pay,
|
23
|
+
:url,
|
24
|
+
:guid,
|
25
|
+
:product,
|
26
|
+
:return_url,
|
27
|
+
:ipn,
|
28
|
+
:status,
|
29
|
+
:received
|
30
|
+
|
31
|
+
def initialize(guid, amount_requested, currency_requested, product, return_url, ipn = nil)
|
32
|
+
@guid = guid
|
33
|
+
@amount_requested = amount_requested
|
34
|
+
@currency_requested = currency_requested
|
35
|
+
@product = product
|
36
|
+
@return_url = return_url
|
37
|
+
@ipn = ipn
|
38
|
+
end
|
39
|
+
|
40
|
+
def create
|
41
|
+
response = self.class.get("/api/pay", query: {
|
42
|
+
guid: guid,
|
43
|
+
amount: amount_requested,
|
44
|
+
currency: currency_requested,
|
45
|
+
product: product,
|
46
|
+
return: return_url
|
47
|
+
})
|
48
|
+
update!(response.body)
|
49
|
+
self
|
50
|
+
end
|
51
|
+
|
52
|
+
def fetch(tx = @tx)
|
53
|
+
response = self.class.get("/api/pay/check/#{tx}")
|
54
|
+
update!(response.body)
|
55
|
+
self
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
def update!(json)
|
60
|
+
h = JSON.parse(json)
|
61
|
+
@status ||= h['status']
|
62
|
+
@tx ||= h['tx']
|
63
|
+
@url ||= h['url']
|
64
|
+
@address ||= h['address']
|
65
|
+
@amount_to_pay ||= h['amount']
|
66
|
+
@currency_to_pay ||= h['currency']
|
67
|
+
@received ||= h['received']
|
68
|
+
self
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
data/lib/rmoolah/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
{"address":"DMU2tcx9Fe8nsDXEUA2SkBynJt1KXXXXXX","amount":1337.1337,"currency":"DOGE","tx":"322fabc5-1111-1111-1111-688eb8271204","url":"https:\/\/moolah.io\/api\/tx\/322fabc5-1111-1111-1111-688eb8271204"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"address":"DMU2tcx9Fe8nsDXEUA2SkBynJt1KXXXXXX","received":0,"status":"pending","tx":"322fabc5-1111-1111-1111-688eb8271204"}
|
data/test/helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
4
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
5
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'fixtures'))
|
6
|
+
|
7
|
+
gem 'minitest'
|
8
|
+
|
9
|
+
require "minitest/autorun"
|
10
|
+
require 'webmock/minitest'
|
11
|
+
require 'rmoolah'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestTransaction < MiniTest::Unit::TestCase
|
4
|
+
|
5
|
+
def test_should_create_transaction
|
6
|
+
stub_request(:get, /.*moolah.*/).to_return(:body => File.new(File.dirname(__FILE__) + '/fixtures/create_success.json'), :status => 200)
|
7
|
+
tr = Rmoolah::Transaction.new("abababab", 50, "USD", "My Product", "http://cligs.com", "http://cligs.com").create
|
8
|
+
assert_equal "DMU2tcx9Fe8nsDXEUA2SkBynJt1KXXXXXX", tr.address
|
9
|
+
assert_equal 1337.1337, tr.amount_to_pay
|
10
|
+
assert_equal "DOGE", tr.currency_to_pay
|
11
|
+
assert_equal "322fabc5-1111-1111-1111-688eb8271204", tr.tx
|
12
|
+
assert_equal 'https://moolah.io/api/tx/322fabc5-1111-1111-1111-688eb8271204', tr.url
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_should_fetch_transaction
|
16
|
+
stub_request(:get, /.*moolah.*/).to_return(:body => File.new(File.dirname(__FILE__) + '/fixtures/fetch_success.json'), :status => 200)
|
17
|
+
tr = Rmoolah::Transaction.fetch("322fabc5-1111-1111-1111-688eb8271204")
|
18
|
+
assert_equal "DMU2tcx9Fe8nsDXEUA2SkBynJt1KXXXXXX", tr.address
|
19
|
+
assert_equal 0, tr.received
|
20
|
+
assert_equal "pending", tr.status
|
21
|
+
assert_equal "322fabc5-1111-1111-1111-688eb8271204", tr.tx
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rmoolah
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aleksandr Lossenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -89,13 +89,20 @@ extensions: []
|
|
89
89
|
extra_rdoc_files: []
|
90
90
|
files:
|
91
91
|
- ".gitignore"
|
92
|
+
- ".ruby-gemset"
|
93
|
+
- ".ruby-version"
|
92
94
|
- Gemfile
|
93
95
|
- LICENSE.txt
|
94
96
|
- README.md
|
95
97
|
- Rakefile
|
96
98
|
- lib/rmoolah.rb
|
99
|
+
- lib/rmoolah/transaction.rb
|
97
100
|
- lib/rmoolah/version.rb
|
98
101
|
- rmoolah.gemspec
|
102
|
+
- test/fixtures/create_success.json
|
103
|
+
- test/fixtures/fetch_success.json
|
104
|
+
- test/helper.rb
|
105
|
+
- test/test_transaction.rb
|
99
106
|
homepage: https://github.com/egze/rmoolah
|
100
107
|
licenses:
|
101
108
|
- MIT
|
@@ -120,4 +127,8 @@ rubygems_version: 2.2.2
|
|
120
127
|
signing_key:
|
121
128
|
specification_version: 4
|
122
129
|
summary: API wrapper for moolah.io
|
123
|
-
test_files:
|
130
|
+
test_files:
|
131
|
+
- test/fixtures/create_success.json
|
132
|
+
- test/fixtures/fetch_success.json
|
133
|
+
- test/helper.rb
|
134
|
+
- test/test_transaction.rb
|