tres_delta 0.0.1 → 0.0.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: 42fa12ff320aeb5b1c3e547012cfb12de4750034
4
- data.tar.gz: 41d94636dc3b346b47eb20a60347944bf837c878
3
+ metadata.gz: 578097ac40a7cc64e1263c8777d67bb5da106185
4
+ data.tar.gz: 12dfb29a0c45465e36cced8451387645753ef6a8
5
5
  SHA512:
6
- metadata.gz: d71952aecaebdd6e3790d2fa9e5bc5555e11a16859aad80ea3bd571b569e8d4cedada9b9a4d08fd47c75ca95c85c0d358fdd6f97a8314e2d8681bdbd45e7c60f
7
- data.tar.gz: 64e8999d46eef97455ff886b03a3555bca270099615639303ca17f412b95781307b091a62c25e90a6eb437e65a1fef9a9eea555ee96d36db890ed8bcdeffbe88
6
+ metadata.gz: 5bdb1907718fea6b0e862330838848744d9b9c65a1eabf2cbfcc5e8ee78dd437f5079b99dcf1505dc769659954426da588f63f0c0127f4d8e81312c011523799
7
+ data.tar.gz: f9e25484ef3dbf7290ea0eaa6e2263d025cb54b7f24e32858d987f152592ee93aa5c7b05609682bafb5ce477c43e46a667619382df8a8720e57d6333f62fe806
@@ -10,5 +10,17 @@ module TresDelta
10
10
  def vault_key
11
11
  @vault_key ||= SecureRandom.hex(12)
12
12
  end
13
+
14
+ class << self
15
+ def create(params = {})
16
+ Customer.new(params).tap do |customer|
17
+ unless Vault.new.create_customer(customer).success?
18
+ raise InvalidCustomer
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ class InvalidCustomer < Exception; end
13
25
  end
14
26
  end
@@ -4,6 +4,29 @@ module TresDelta
4
4
  @wsdl = Config.config['transaction_wsdl']
5
5
  end
6
6
 
7
+ def authorize(transaction_key, credit_card, amount, order_number, customer)
8
+ request :authorize, authorize_params(transaction_key, credit_card, amount, order_number, customer)
9
+ end
10
+
11
+ def authorize_params(transaction_key, credit_card, amount, order_number, customer)
12
+ {
13
+ 'clientCredentials' => client_credentials,
14
+ 'authorizeParams' => {
15
+ 'AddOrUpdateCard' => 'true',
16
+ 'CreditCardTransaction' => {
17
+ 'CreditCard' => credit_card_params(credit_card),
18
+ 'CurrencyCode' => 'USDollars',
19
+ 'StoredCardIdentifier' => {
20
+ 'CustomerCode' => customer.vault_key
21
+ },
22
+ 'TotalAmount' => amount,
23
+ 'TransactionKey' => transaction_key
24
+ },
25
+ 'TerminalIdentifier' => terminal_identifier
26
+ }
27
+ }
28
+ end
29
+
7
30
  def card_verification(transaction_key, credit_card)
8
31
  request(:card_verification, card_verification_params(transaction_key, credit_card))
9
32
  end
@@ -54,8 +77,5 @@ module TresDelta
54
77
  }
55
78
  }
56
79
  end
57
-
58
- def authorize(transaction_key, credit_card, transaction_total, order_number)
59
- end
60
80
  end
61
81
  end
@@ -68,5 +68,19 @@ module TresDelta
68
68
  }
69
69
  }
70
70
  end
71
+
72
+ def get_token_for_card_number(card_number, customer)
73
+ request(:get_token_for_card_number, get_token_for_card_number_params(card_number, customer))
74
+ end
75
+
76
+ def get_token_for_card_number_params(card_number, customer)
77
+ {
78
+ 'clientCredentials' => client_credentials,
79
+ 'getTokenForCardNumberParams' => {
80
+ 'AccountNumber' => card_number,
81
+ 'CustomerIdentifier' => customer_identifier(customer)
82
+ }
83
+ }
84
+ end
71
85
  end
72
86
  end
@@ -1,3 +1,3 @@
1
1
  module TresDelta
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -25,4 +25,30 @@ describe TresDelta::Customer do
25
25
  end
26
26
  end
27
27
  end
28
+
29
+ describe "#create" do
30
+ let(:customer) { TresDelta::Customer.create(customer_data) }
31
+
32
+ context "good customer info" do
33
+ let(:vault_key) { SecureRandom.hex(6) }
34
+ let(:customer_data) { { name: "Joe Tester", vault_key: vault_key } }
35
+
36
+ it "creates the customer" do
37
+ expect(customer).to be_a(TresDelta::Customer)
38
+ end
39
+
40
+ it "has the initialized values" do
41
+ expect(customer.vault_key).to eq(vault_key)
42
+ expect(customer.name).to eq(customer_data[:name])
43
+ end
44
+ end
45
+
46
+ context "bad customer info" do
47
+ let(:customer_data) { Hash.new }
48
+
49
+ it "raises an error" do
50
+ expect { customer }.to raise_exception(TresDelta::Customer::InvalidCustomer)
51
+ end
52
+ end
53
+ end
28
54
  end
@@ -4,6 +4,10 @@ describe TresDelta::Gateway do
4
4
  let(:gateway) { TresDelta::Gateway.new }
5
5
  let(:transaction_key) { SecureRandom.hex(6) }
6
6
  let(:customer) { TresDelta::Customer.new(name: 'FOO BAR') }
7
+ let(:good_address) { "10124 Brentridge Ct" }
8
+
9
+ # arbitrary: Cisco, TX
10
+ let(:zip_code_good) { '76437' }
7
11
 
8
12
  let(:credit_card) do
9
13
  TresDelta::CreditCard.new({
@@ -30,8 +34,6 @@ describe TresDelta::Gateway do
30
34
  end
31
35
 
32
36
  describe "credit card zip code verification" do
33
- # arbitrary: Cisco, TX
34
- let(:zip_code_good) { '76437' }
35
37
 
36
38
  # magic numbers, see ThreeDelta docs
37
39
  let(:zip_code_failure) { '20151' }
@@ -79,7 +81,6 @@ describe TresDelta::Gateway do
79
81
  end
80
82
 
81
83
  describe "credit card address verificaiton" do
82
- let(:good_address) { "10124 Brentridge Ct" }
83
84
  let(:bad_address) { "14151 Brentridge Ct" }
84
85
  let(:address_params) { { :address => address } }
85
86
 
@@ -103,4 +104,39 @@ describe TresDelta::Gateway do
103
104
  end
104
105
  end
105
106
  end
107
+
108
+ describe "authorize" do
109
+ let(:order_number) { SecureRandom.hex(6) }
110
+ let(:amount) { 13.37 }
111
+ let(:address_params) { { address: good_address, zip_code: zip_code_good} }
112
+ let(:response) { gateway.authorize(transaction_key, credit_card, amount, order_number, customer) }
113
+ let(:vault) { TresDelta::Vault.new }
114
+
115
+ before(:each) do
116
+ vault.create_customer(customer)
117
+ end
118
+
119
+ context "good transaction" do
120
+ it "is successful" do
121
+ expect(response.success?).to be_true
122
+ end
123
+ end
124
+
125
+ context "card declined" do
126
+ let(:amount) { "0.20" } # see 3Delta docs
127
+
128
+ it "isn't successful" do
129
+ expect(response.success?).to be_false
130
+ end
131
+ end
132
+
133
+ context "bad expiration" do
134
+ let(:amount) { "0.29" } # see 3Delta docs
135
+
136
+ it "isn't successful" do
137
+ expect(response.success?).to be_false
138
+ expect(response.credit_card_response_status).to eq('ExpirationDateIncorrect')
139
+ end
140
+ end
141
+ end
106
142
  end
@@ -98,7 +98,7 @@ describe TresDelta::Vault do
98
98
  end
99
99
  end
100
100
 
101
- describe "get_stored_credit_card", :focus => true do
101
+ describe "get_stored_credit_card" do
102
102
  let(:include_card_number) { false }
103
103
  let(:response) { vault.get_stored_credit_card(customer, token, include_card_number) }
104
104
 
@@ -150,4 +150,30 @@ describe TresDelta::Vault do
150
150
  end
151
151
  end
152
152
  end
153
+
154
+ describe "get_token_for_card_number" do
155
+ let(:response) { vault.get_token_for_card_number(card_number, customer) }
156
+
157
+ context "credit card doesn't exist" do
158
+ let(:card_number) { '4111111111111111' }
159
+
160
+ it "isn't successful" do
161
+ expect(response.success?).to be_false
162
+ end
163
+ end
164
+
165
+ context "credit card does exist" do
166
+ let(:card_number) { good_visa.number }
167
+
168
+ let!(:token) { vault.create_customer(customer); vault.add_stored_credit_card(customer, good_visa).token }
169
+
170
+ it "is successful" do
171
+ expect(response.success?).to be_true
172
+ end
173
+
174
+ it "has the card's token" do
175
+ expect(response.token).to eq(token)
176
+ end
177
+ end
178
+ end
153
179
  end
data/tres_delta.gemspec CHANGED
@@ -8,9 +8,9 @@ Gem::Specification.new do |spec|
8
8
  spec.version = TresDelta::VERSION
9
9
  spec.authors = ["1000Bulbs", "Zachary Danger Campbell"]
10
10
  spec.email = ["zacharydangercampbell@gmail.com"]
11
- spec.description = %q{A Ruby client for ThreeDelta's credit card vault and payment gateway.}
12
- spec.summary = %q{A Ruby client for ThreeDelta's credit card vault and payment gateway.}
13
- spec.homepage = ""
11
+ spec.description = %q{A Ruby client for 3Delta's credit card vault and payment gateway.}
12
+ spec.summary = %q{If you need to talk to 3Delta's credit card vault/payment gateway in Ruby... this is an ok start.}
13
+ spec.homepage = "https://github.com/1000Bulbs/tres-delta"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tres_delta
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - 1000Bulbs
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-18 00:00:00.000000000 Z
12
+ date: 2014-03-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: savon
@@ -67,7 +67,7 @@ dependencies:
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
- description: A Ruby client for ThreeDelta's credit card vault and payment gateway.
70
+ description: A Ruby client for 3Delta's credit card vault and payment gateway.
71
71
  email:
72
72
  - zacharydangercampbell@gmail.com
73
73
  executables: []
@@ -98,7 +98,7 @@ files:
98
98
  - spec/tres_delta/gateway_spec.rb
99
99
  - spec/tres_delta/vault_spec.rb
100
100
  - tres_delta.gemspec
101
- homepage: ''
101
+ homepage: https://github.com/1000Bulbs/tres-delta
102
102
  licenses:
103
103
  - MIT
104
104
  metadata: {}
@@ -121,7 +121,8 @@ rubyforge_project:
121
121
  rubygems_version: 2.1.11
122
122
  signing_key:
123
123
  specification_version: 4
124
- summary: A Ruby client for ThreeDelta's credit card vault and payment gateway.
124
+ summary: If you need to talk to 3Delta's credit card vault/payment gateway in Ruby...
125
+ this is an ok start.
125
126
  test_files:
126
127
  - spec/spec_helper.rb
127
128
  - spec/tres_delta/client_spec.rb