traffic_mansion 0.0.9 → 0.0.10

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: 5fd0d891c5043002516f7658449f0d980723689c
4
- data.tar.gz: 0686b27051379746f8860383fb1741088355f94c
3
+ metadata.gz: ff1308d4d6ced5174e0b95dc29240b31bd6e343d
4
+ data.tar.gz: aab8cf042cad93d8b732505c9a6777142c635043
5
5
  SHA512:
6
- metadata.gz: 0c2a6962f9d35831e648d5409bfaa199afd51c2117a814170e6d68bc75be2824fecc9b68f54b9d78419116a5e6fba215c0c6986e77f2bbedb53ad2de126ffe61
7
- data.tar.gz: 1985dffbab5e836014f7e91756aa5c65f5896b0d2323d30c6968e2deb797a7d6bc4ccc521655dffcc151c98b45ead0cbcba2e81681d342aba897f101c698cd2d
6
+ metadata.gz: 0e8f552ccddabf0c9c4d402b68ebe6ff3d3efe9ec1e2f9ceca2c8c709fc50ae7c82e62ce6ff95764194c5a5f1c1d0062332673e35fa08c27af16710e7f780f8c
7
+ data.tar.gz: 8a3d5ce6ecbdc87b1343ae250c98a3b037661ef4c23e842684dd60c73c964c7800226dff93da4c40ed8b6b1ee5d839d3b3068e1be0b16dc58ee016dfe8b58009
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use ruby-2.0.0
@@ -63,6 +63,22 @@ module TrafficMansion
63
63
  TrafficMansion::Queue::add "rebill", nil, event_data
64
64
  end
65
65
 
66
+ def self.add_refund user_id, payment_id, amount, product_code, transaction_type, remote_ip, referer
67
+ event_data = {
68
+ "user_id" => user_id,
69
+ "timestamp" => Time.now.to_i,
70
+ "transaction" => payment_id,
71
+ "amount" => amount,
72
+ "product_code" => product_code,
73
+ "remote_addr" => remote_ip,
74
+ "http_referer" => referer,
75
+ "is_rebill" => transaction_type.to_s == "rebill" ? 1 : 0,
76
+ "refund_transid" => payment_id,
77
+ "penalty" => 0, # normally it's not used anymore, but, who knows?...
78
+ }
79
+ TrafficMansion::Queue::add "refund", nil, event_data
80
+ end
81
+
66
82
  def self.add type, parent_event_id = nil, data = {}
67
83
  user_id = data["user_id"]
68
84
  event = TrafficMansion::Queue.create :type => type, :parent_event_id => parent_event_id, :user_id => user_id, :data => data
@@ -49,6 +49,10 @@ module TrafficMansion
49
49
  payment "rebill", options
50
50
  end
51
51
 
52
+ def refund options = {}
53
+ payment "refund", options
54
+ end
55
+
52
56
 
53
57
  private
54
58
 
@@ -1,3 +1,3 @@
1
1
  module TrafficMansion
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
data/spec/queue_spec.rb CHANGED
@@ -163,6 +163,71 @@ describe TrafficMansion::Queue do
163
163
  end
164
164
  end
165
165
 
166
+ describe "self.add_refund" do
167
+ let(:user_id) { "user_id" }
168
+ let(:payment_id) { "payment_id" }
169
+ let(:amount) { "amount" }
170
+ let(:product_code) { "product_code" }
171
+ let(:transaction_type) { :rebill }
172
+ let(:remote_ip) { "remote_ip" }
173
+ let(:referer) { "referer" }
174
+
175
+ it "persists the rebill" do
176
+ TrafficMansion::Queue.add_refund user_id, payment_id, amount, product_code, transaction_type, remote_ip, referer
177
+ TrafficMansion::Queue.last.type.should eql "refund"
178
+ end
179
+
180
+ it "persists the user id" do
181
+ TrafficMansion::Queue.add_refund user_id, payment_id, amount, product_code, transaction_type, remote_ip, referer
182
+ TrafficMansion::Queue.last.user_id.should eql user_id
183
+ end
184
+
185
+ it "persists the user id" do
186
+ TrafficMansion::Queue.add_refund user_id, payment_id, amount, product_code, transaction_type, remote_ip, referer
187
+ TrafficMansion::Queue.last.data["user_id"].should eql user_id
188
+ end
189
+
190
+ it "persists the transaction id" do
191
+ TrafficMansion::Queue.add_refund user_id, payment_id, amount, product_code, transaction_type, remote_ip, referer
192
+ TrafficMansion::Queue.last.data["transaction"].should eql payment_id
193
+ end
194
+
195
+ it "persists the amount" do
196
+ TrafficMansion::Queue.add_refund user_id, payment_id, amount, product_code, transaction_type, remote_ip, referer
197
+ TrafficMansion::Queue.last.data["amount"].should eql amount
198
+ end
199
+
200
+ it "persists the product code" do
201
+ TrafficMansion::Queue.add_refund user_id, payment_id, amount, product_code, transaction_type, remote_ip, referer
202
+ TrafficMansion::Queue.last.data["product_code"].should eql product_code
203
+ end
204
+
205
+ it "persists the transaction type" do
206
+ TrafficMansion::Queue.add_refund user_id, payment_id, amount, product_code, transaction_type, remote_ip, referer
207
+ TrafficMansion::Queue.last.data["is_rebill"].should eql 1
208
+ end
209
+
210
+ it "persists the refund transaction id" do
211
+ TrafficMansion::Queue.add_refund user_id, payment_id, amount, product_code, transaction_type, remote_ip, referer
212
+ TrafficMansion::Queue.last.data["refund_transid"].should eql payment_id
213
+ end
214
+
215
+ it "persists the penalty" do
216
+ TrafficMansion::Queue.add_refund user_id, payment_id, amount, product_code, transaction_type, remote_ip, referer
217
+ TrafficMansion::Queue.last.data["penalty"].should eql 0
218
+ end
219
+
220
+ it "persists the remote ip" do
221
+ TrafficMansion::Queue.add_refund user_id, payment_id, amount, product_code, transaction_type, remote_ip, referer
222
+ TrafficMansion::Queue.last.data["remote_addr"].should eql remote_ip
223
+ end
224
+
225
+ it "persists the referer" do
226
+ TrafficMansion::Queue.add_refund user_id, payment_id, amount, product_code, transaction_type, remote_ip, referer
227
+ TrafficMansion::Queue.last.data["http_referer"].should eql referer
228
+ end
229
+ end
230
+
166
231
  describe "self.find_parent_by_user" do
167
232
  before :each do
168
233
  TrafficMansion::Queue.add_signup "parent_event_id", "user_id", "remote_ip", "referer"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: traffic_mansion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - AgileWings
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-10 00:00:00.000000000 Z
11
+ date: 2013-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -130,6 +130,7 @@ extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
132
  - .gitignore
133
+ - .rvmrc
133
134
  - Gemfile
134
135
  - LICENSE.txt
135
136
  - README.md