vaulted_billing-termcap 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,5 @@
1
+ This is an add-on for VaultedBilling that includes terminal capture transactions.
2
+
3
+ Currently supported:
4
+
5
+ * IP Commerce
@@ -0,0 +1 @@
1
+ require 'vaulted_billing/termcap'
@@ -0,0 +1,8 @@
1
+ require 'vaulted_billing'
2
+ require 'vaulted_billing/termcap/gateway'
3
+ require 'vaulted_billing/termcap/gateways/ipcommerce'
4
+
5
+ module VaultedBilling
6
+ module Termcap
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ require 'vaulted_billing/gateway'
2
+
3
+ VaultedBilling::Gateway.module_eval do
4
+ def capture_selective(transactions, differences = [], options = {})
5
+ raise NotImplementedError
6
+ end
7
+ end
@@ -0,0 +1,43 @@
1
+ require 'vaulted_billing/gateways/ipcommerce'
2
+
3
+ VaultedBilling::Gateways::Ipcommerce.class_eval do
4
+
5
+ ##
6
+ # Captures the passed in transaction ids.
7
+ # Optionally specify difference amounts for each transaction.
8
+ # ex.
9
+ # differences = [
10
+ # { :id => 2, :amount => 12.00 }
11
+ # ]
12
+ def capture_selective(transaction_ids, differences = [], options = {})
13
+ data = {
14
+ :"__type" => "CaptureSelective:http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest",
15
+ :ApplicationProfileId => @application_id,
16
+ :TransactionIds => transaction_ids,
17
+ :DifferenceData => (differences || []).collect { |difference| capture_difference(difference) }
18
+ }
19
+
20
+ response = http(options[:workflow_id] || @service_id).put(data, { :on_success => :decode_with_termcap })
21
+ transaction = new_transaction_from_response(response)
22
+ respond_with(transaction,
23
+ response,
24
+ :success => (transaction.code == 1))
25
+ end
26
+
27
+ private
28
+
29
+ def decode_with_termcap(response)
30
+ response.body = decode_body(response.body) || {}
31
+ response.body = (response.body.first || {}) if response.body.is_a?(Array)
32
+ response.success = [1, 2].include?(response.body['Status'])
33
+ end
34
+
35
+ def capture_difference(difference)
36
+ {
37
+ :"__type" => "BankcardCapture:http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard",
38
+ :TransactionId => difference[:id],
39
+ :Addendum => nil,
40
+ :Amount => "%.2f" % difference[:amount]
41
+ }
42
+ end
43
+ end
@@ -0,0 +1,5 @@
1
+ module VaultedBilling
2
+ module Termcap
3
+ Version = '0.0.1'
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vaulted_billing-termcap
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Adam Fortuna
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-08-19 00:00:00 -04:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: vaulted_billing
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: "1.1"
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: "2.4"
36
+ type: :development
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: vcr
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: "1.7"
47
+ type: :development
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: webmock
51
+ prerelease: false
52
+ requirement: &id004 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ version: "1.6"
58
+ type: :development
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: factory_girl
62
+ prerelease: false
63
+ requirement: &id005 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: "1.3"
69
+ type: :development
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: faker
73
+ prerelease: false
74
+ requirement: &id006 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ version: "0.9"
80
+ type: :development
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: rake
84
+ prerelease: false
85
+ requirement: &id007 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: "0.9"
91
+ type: :development
92
+ version_requirements: *id007
93
+ - !ruby/object:Gem::Dependency
94
+ name: watchr
95
+ prerelease: false
96
+ requirement: &id008 !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: "0"
102
+ type: :development
103
+ version_requirements: *id008
104
+ - !ruby/object:Gem::Dependency
105
+ name: open4
106
+ prerelease: false
107
+ requirement: &id009 !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: "0"
113
+ type: :development
114
+ version_requirements: *id009
115
+ description: Methods specific to gateways that use terminal capture.
116
+ email:
117
+ - adam@envylabs.com
118
+ executables: []
119
+
120
+ extensions: []
121
+
122
+ extra_rdoc_files: []
123
+
124
+ files:
125
+ - lib/vaulted_billing/termcap/gateway.rb
126
+ - lib/vaulted_billing/termcap/gateways/ipcommerce.rb
127
+ - lib/vaulted_billing/termcap/version.rb
128
+ - lib/vaulted_billing/termcap.rb
129
+ - lib/vaulted_billing-termcap.rb
130
+ - README.md
131
+ has_rdoc: true
132
+ homepage: http://github.com/envylabs/vaulted_billing-termcap
133
+ licenses: []
134
+
135
+ post_install_message:
136
+ rdoc_options: []
137
+
138
+ require_paths:
139
+ - lib
140
+ required_ruby_version: !ruby/object:Gem::Requirement
141
+ none: false
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: "0"
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ none: false
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: 1.3.6
152
+ requirements: []
153
+
154
+ rubyforge_project:
155
+ rubygems_version: 1.6.2
156
+ signing_key:
157
+ specification_version: 3
158
+ summary: A library for working with terminal capture gateways.
159
+ test_files: []
160
+