tres_delta 0.0.2 → 0.1.0
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 +4 -4
- data/lib/tres_delta/client.rb +40 -42
- data/lib/tres_delta/credit_card.rb +35 -2
- data/lib/tres_delta/customer.rb +1 -1
- data/lib/tres_delta/gateway.rb +67 -64
- data/lib/tres_delta/vault.rb +95 -67
- data/lib/tres_delta/version.rb +1 -1
- data/spec/tres_delta/client_spec.rb +1 -1
- data/spec/tres_delta/credit_card_spec.rb +115 -0
- data/spec/tres_delta/gateway_spec.rb +28 -3
- data/spec/tres_delta/vault_spec.rb +47 -5
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c26e3ee095b7862bc852e53230559f3791b900d
|
4
|
+
data.tar.gz: 65df9b9ad5b9a8422d92ad7a7f18d8ff63e56bca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f054f0522ea8fc7b7c79ba7f65d46f6913e0cbba42e790c94abf0a8e9a032df884f08b1191c3de2d725f23a01d7d140ff52fdcbb893fa560b232dcc4b402f0c9
|
7
|
+
data.tar.gz: c439e65b3fa0e6ae07f957e0085287427a27b88cb9fa39b232533292969308ae81bd17ad62f533bf9fd4ad722ff5c1d36aec8bea790c033e1b8562b985fd60fe
|
data/lib/tres_delta/client.rb
CHANGED
@@ -2,48 +2,46 @@ require 'savon'
|
|
2
2
|
|
3
3
|
module TresDelta
|
4
4
|
class Client
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
default_savon_options
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
def config
|
46
|
-
Config.config
|
5
|
+
class << self
|
6
|
+
attr_accessor :wsdl
|
7
|
+
|
8
|
+
def request(action, soap_body)
|
9
|
+
Response.create_from_action(action, client.call(action, message: soap_body))
|
10
|
+
end
|
11
|
+
|
12
|
+
def client_credentials
|
13
|
+
{
|
14
|
+
"ClientCode" => config["client_code"],
|
15
|
+
"Password" => config["password"],
|
16
|
+
"UserName" => config["user_name"]
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def location_identifier
|
21
|
+
{
|
22
|
+
'LocationCode' => config["location_code"],
|
23
|
+
'MerchantCode' => config["merchant_code"]
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def client
|
28
|
+
# TODO: Make this configurable via file. Because right now this ain't secure. -_-
|
29
|
+
@client ||= ::Savon.client(savon_options)
|
30
|
+
end
|
31
|
+
|
32
|
+
def savon_options
|
33
|
+
default_savon_options.merge(savon_overrides || {})
|
34
|
+
end
|
35
|
+
|
36
|
+
def default_savon_options
|
37
|
+
{ wsdl: wsdl, ssl_version: :SSLv3, ssl_verify_mode: :none, log: false }
|
38
|
+
end
|
39
|
+
|
40
|
+
def savon_overrides; end
|
41
|
+
|
42
|
+
def config
|
43
|
+
Config.config
|
44
|
+
end
|
47
45
|
end
|
48
46
|
end
|
49
47
|
end
|
@@ -1,9 +1,11 @@
|
|
1
1
|
module TresDelta
|
2
2
|
class CreditCard
|
3
|
-
attr_reader :number, :
|
3
|
+
attr_reader :number, :name, :billing_address, :type, :nickname, :customer, :security_code
|
4
|
+
|
5
|
+
attr_accessor :token, :expiration_month, :expiration_year
|
4
6
|
|
5
7
|
def initialize(params = {})
|
6
|
-
@number = params[:number]
|
8
|
+
@number = params[:number] || params[:card_account_number]
|
7
9
|
@expiration_month = params[:expiration_month]
|
8
10
|
@expiration_year = params[:expiration_year]
|
9
11
|
@token = params[:token]
|
@@ -11,6 +13,37 @@ module TresDelta
|
|
11
13
|
@billing_address = Address.new(params[:billing_address] || {})
|
12
14
|
@type = params[:type]
|
13
15
|
@nickname = params[:nickname]
|
16
|
+
@customer = params[:customer] || Customer.new
|
17
|
+
@security_code = params[:security_code]
|
18
|
+
end
|
19
|
+
|
20
|
+
def save
|
21
|
+
if token.nil?
|
22
|
+
Vault.add_stored_credit_card(customer, self).success?
|
23
|
+
else
|
24
|
+
Vault.update_stored_credit_card(customer, self).success?
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class << self
|
29
|
+
def create(customer, params = {})
|
30
|
+
CreditCard.new(params).tap do |credit_card|
|
31
|
+
add_card = Vault.add_stored_credit_card(customer, credit_card)
|
32
|
+
raise InvalidCreditCard unless add_card.success?
|
33
|
+
|
34
|
+
credit_card.token = add_card.token
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def find(customer, token, load_number = false)
|
39
|
+
stored_card_details = Vault.get_stored_credit_card(customer, token, load_number)
|
40
|
+
raise CreditCardNotFound unless stored_card_details.success?
|
41
|
+
|
42
|
+
CreditCard.new(stored_card_details.credit_card.merge(customer: customer))
|
43
|
+
end
|
14
44
|
end
|
15
45
|
end
|
46
|
+
|
47
|
+
class InvalidCreditCard < Exception; end
|
48
|
+
class CreditCardNotFound < Exception; end
|
16
49
|
end
|
data/lib/tres_delta/customer.rb
CHANGED
data/lib/tres_delta/gateway.rb
CHANGED
@@ -1,81 +1,84 @@
|
|
1
1
|
module TresDelta
|
2
2
|
class Gateway < Client
|
3
|
-
def initialize
|
4
|
-
@wsdl = Config.config['transaction_wsdl']
|
5
|
-
end
|
6
3
|
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
class << self
|
5
|
+
def wsdl
|
6
|
+
Config.config['transaction_wsdl']
|
7
|
+
end
|
8
|
+
|
9
|
+
def authorize(transaction_key, credit_card, amount, order_number, customer)
|
10
|
+
request :authorize, authorize_params(transaction_key, credit_card, amount, order_number, customer)
|
11
|
+
end
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
13
|
+
def authorize_params(transaction_key, credit_card, amount, order_number, customer)
|
14
|
+
{
|
15
|
+
'clientCredentials' => client_credentials,
|
16
|
+
'authorizeParams' => {
|
17
|
+
'AddOrUpdateCard' => 'true',
|
18
|
+
'CreditCardTransaction' => {
|
19
|
+
'CreditCard' => credit_card_params(credit_card),
|
20
|
+
'CurrencyCode' => 'USDollars',
|
21
|
+
'StoredCardIdentifier' => {
|
22
|
+
'CustomerCode' => customer.vault_key
|
23
|
+
},
|
24
|
+
'TotalAmount' => amount,
|
25
|
+
'TransactionKey' => transaction_key
|
21
26
|
},
|
22
|
-
'
|
23
|
-
|
24
|
-
},
|
25
|
-
'TerminalIdentifier' => terminal_identifier
|
27
|
+
'TerminalIdentifier' => terminal_identifier
|
28
|
+
}
|
26
29
|
}
|
27
|
-
|
28
|
-
end
|
30
|
+
end
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
def card_verification(transaction_key, credit_card)
|
33
|
+
request(:card_verification, card_verification_params(transaction_key, credit_card))
|
34
|
+
end
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
36
|
+
def card_verification_params(transaction_key, credit_card)
|
37
|
+
{
|
38
|
+
'clientCredentials' => client_credentials,
|
39
|
+
'cardVerificationParams' => {
|
40
|
+
'AddOrUpdateCard' => 'false',
|
41
|
+
'CreditCard' => credit_card_params(credit_card),
|
42
|
+
'TerminalIdentifier' => terminal_identifier,
|
43
|
+
'TransactionKey' => transaction_key
|
44
|
+
}
|
42
45
|
}
|
43
|
-
|
44
|
-
end
|
46
|
+
end
|
45
47
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
48
|
+
def credit_card_params(credit_card)
|
49
|
+
{
|
50
|
+
'cc:BillingAddress' => billing_address_params(credit_card.billing_address),
|
51
|
+
'cc:CardAccountNumber' => credit_card.number,
|
52
|
+
'cc:ExpirationMonth' => credit_card.expiration_month,
|
53
|
+
'cc:ExpirationYear' => credit_card.expiration_year,
|
54
|
+
'NameOnCard' => credit_card.name,
|
55
|
+
'CardSecurityCode' => credit_card.security_code,
|
56
|
+
'CardSecurityCodeIndicator' => credit_card.security_code.nil? ? 'None' : 'Provided'
|
57
|
+
}
|
58
|
+
end
|
57
59
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
def billing_address_params(billing_address)
|
61
|
+
{
|
62
|
+
'cc:AddressLine1' => billing_address.address,
|
63
|
+
'cc:PostalCode' => billing_address.zip_code
|
64
|
+
}
|
65
|
+
end
|
64
66
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
67
|
+
def terminal_identifier
|
68
|
+
{
|
69
|
+
'LocationCode' => config['location_code'],
|
70
|
+
'MerchantCode' => config['merchant_code'],
|
71
|
+
'TerminalCode' => config['terminal_code']
|
72
|
+
}
|
73
|
+
end
|
72
74
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
75
|
+
def savon_overrides
|
76
|
+
{
|
77
|
+
namespaces: {
|
78
|
+
'xmlns:cc' => 'http://schemas.datacontract.org/2004/07/ThreeDelta.Web.Services.ECLinx.Definitions'
|
79
|
+
}
|
77
80
|
}
|
78
|
-
|
81
|
+
end
|
79
82
|
end
|
80
83
|
end
|
81
84
|
end
|
data/lib/tres_delta/vault.rb
CHANGED
@@ -1,86 +1,114 @@
|
|
1
1
|
module TresDelta
|
2
2
|
class Vault < Client
|
3
|
-
def initialize
|
4
|
-
@wsdl = Config.config['management_wsdl']
|
5
|
-
end
|
6
3
|
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
class << self
|
5
|
+
def wsdl
|
6
|
+
Config.config['management_wsdl']
|
7
|
+
end
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
9
|
+
def create_customer(customer)
|
10
|
+
request(:create_customer, create_customer_params(customer))
|
11
|
+
end
|
12
|
+
|
13
|
+
def create_customer_params(customer)
|
14
|
+
{
|
15
|
+
'clientCredentials' => client_credentials,
|
16
|
+
'createCustomerParams' => {
|
17
|
+
'Customer' => {
|
18
|
+
'Code' => customer.vault_key,
|
19
|
+
'Name' => customer.name
|
20
|
+
},
|
21
|
+
'LocationIdentifier' => location_identifier
|
22
|
+
}
|
20
23
|
}
|
21
|
-
|
22
|
-
end
|
24
|
+
end
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
26
|
+
def add_stored_credit_card(customer, credit_card)
|
27
|
+
request(:add_stored_credit_card, add_stored_credit_card_params(customer, credit_card))
|
28
|
+
end
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
30
|
+
def add_stored_credit_card_params(customer, credit_card)
|
31
|
+
{
|
32
|
+
'clientCredentials' => client_credentials,
|
33
|
+
'addStoredCardParams' => {
|
34
|
+
'CreditCard' => {
|
35
|
+
'CardAccountNumber' => credit_card.number,
|
36
|
+
'CardType' => credit_card.type,
|
37
|
+
'Cardholder' => {
|
38
|
+
'FirstName' => credit_card.name,
|
39
|
+
'LastName' => nil
|
40
|
+
},
|
41
|
+
'ExpirationMonth' => credit_card.expiration_month,
|
42
|
+
'ExpirationYear' => credit_card.expiration_year,
|
43
|
+
'NameOnCard' => credit_card.name,
|
44
|
+
'FriendlyName' => credit_card.nickname
|
38
45
|
},
|
39
|
-
'
|
40
|
-
|
41
|
-
'NameOnCard' => credit_card.name,
|
42
|
-
'FriendlyName' => credit_card.nickname
|
43
|
-
},
|
44
|
-
'CustomerIdentifier' => customer_identifier(customer)
|
46
|
+
'CustomerIdentifier' => customer_identifier(customer)
|
47
|
+
}
|
45
48
|
}
|
46
|
-
|
47
|
-
end
|
49
|
+
end
|
48
50
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
51
|
+
def customer_identifier(customer)
|
52
|
+
{
|
53
|
+
'CustomerCode' => customer.vault_key,
|
54
|
+
'LocationCode' => config["location_code"],
|
55
|
+
'MerchantCode' => config["merchant_code"]
|
56
|
+
}
|
57
|
+
end
|
56
58
|
|
57
|
-
|
58
|
-
|
59
|
-
|
59
|
+
def get_stored_credit_card(customer, token, include_card_number = false)
|
60
|
+
request(:get_stored_credit_card, get_stored_credit_card_params(customer, token, include_card_number))
|
61
|
+
end
|
60
62
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
63
|
+
def get_stored_credit_card_params(customer, token, include_card_number)
|
64
|
+
{
|
65
|
+
'clientCredentials' => client_credentials,
|
66
|
+
'getStoredCreditCardParams' => {
|
67
|
+
'CustomerIdentifier' => customer_identifier(customer),
|
68
|
+
'RetrieveCardNumber' => include_card_number ? 'true' : 'false',
|
69
|
+
'Token' => token
|
70
|
+
}
|
68
71
|
}
|
69
|
-
|
70
|
-
end
|
72
|
+
end
|
71
73
|
|
72
|
-
|
73
|
-
|
74
|
-
|
74
|
+
def get_token_for_card_number(card_number, customer)
|
75
|
+
request(:get_token_for_card_number, get_token_for_card_number_params(card_number, customer))
|
76
|
+
end
|
75
77
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
78
|
+
def get_token_for_card_number_params(card_number, customer)
|
79
|
+
{
|
80
|
+
'clientCredentials' => client_credentials,
|
81
|
+
'getTokenForCardNumberParams' => {
|
82
|
+
'AccountNumber' => card_number,
|
83
|
+
'CustomerIdentifier' => customer_identifier(customer)
|
84
|
+
}
|
85
|
+
}
|
86
|
+
end
|
87
|
+
|
88
|
+
def update_stored_credit_card(customer, credit_card)
|
89
|
+
request(:update_stored_credit_card, update_stored_credit_card_params(customer, credit_card))
|
90
|
+
end
|
91
|
+
|
92
|
+
def update_stored_credit_card_params(customer, credit_card)
|
93
|
+
{
|
94
|
+
'clientCredentials' => client_credentials,
|
95
|
+
'updateStoredCardParams' => {
|
96
|
+
'CreditCard' => {
|
97
|
+
'CardType' => credit_card.type,
|
98
|
+
'CardHolder' => {
|
99
|
+
'FirstName' => credit_card.name,
|
100
|
+
'Lastname' => nil
|
101
|
+
},
|
102
|
+
'ExpirationMonth' => credit_card.expiration_month,
|
103
|
+
'ExpirationYear' => credit_card.expiration_year,
|
104
|
+
'NameOnCard' => credit_card.name,
|
105
|
+
'FriendlyName' => credit_card.nickname,
|
106
|
+
'Token' => credit_card.token
|
107
|
+
},
|
108
|
+
'CustomerIdentifier' => customer_identifier(customer)
|
109
|
+
}
|
82
110
|
}
|
83
|
-
|
111
|
+
end
|
84
112
|
end
|
85
113
|
end
|
86
114
|
end
|
data/lib/tres_delta/version.rb
CHANGED
@@ -0,0 +1,115 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TresDelta::CreditCard do
|
4
|
+
let(:customer) { TresDelta::Customer.create(name: "Test Customer") }
|
5
|
+
|
6
|
+
let(:bad_params) do
|
7
|
+
{
|
8
|
+
number: '4111111111111111',
|
9
|
+
expiration_month: '8',
|
10
|
+
expiration_year: Time.now.strftime("%Y").to_i + 3,
|
11
|
+
name: 'Joe Customer',
|
12
|
+
type: 'MasterCard',
|
13
|
+
nickname: 'Test Visa, Yo.',
|
14
|
+
customer: customer
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:good_params) do
|
19
|
+
{
|
20
|
+
number: '4111111111111111',
|
21
|
+
expiration_month: '8',
|
22
|
+
expiration_year: Time.now.strftime("%Y").to_i + 3,
|
23
|
+
name: 'Joe Customer',
|
24
|
+
type: 'Visa',
|
25
|
+
nickname: 'Test Visa, Yo.',
|
26
|
+
customer: customer
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
let(:credit_card) { TresDelta::CreditCard.create(customer, good_params) }
|
31
|
+
|
32
|
+
describe "#create" do
|
33
|
+
context "successfully saved to vault" do
|
34
|
+
it "doesn't raise an exception" do
|
35
|
+
expect { TresDelta::CreditCard.create(customer, good_params) }.to_not raise_exception
|
36
|
+
end
|
37
|
+
|
38
|
+
it "has a token" do
|
39
|
+
expect(credit_card.token).to_not be_nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "fails to save to vault" do
|
44
|
+
it "raises an exception" do
|
45
|
+
expect { TresDelta::CreditCard.create(customer, bad_params) }.to raise_exception(TresDelta::InvalidCreditCard)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "#find" do
|
51
|
+
context "card exists" do
|
52
|
+
let(:token) { credit_card.token }
|
53
|
+
let(:found_card) { TresDelta::CreditCard.find(customer, token, true) }
|
54
|
+
|
55
|
+
it "returns a credit card object" do
|
56
|
+
expect(found_card).to be_a(TresDelta::CreditCard)
|
57
|
+
expect(found_card.number).to eq(credit_card.number)
|
58
|
+
expect(found_card.token).to eq(token)
|
59
|
+
expect(found_card.expiration_month).to eq(credit_card.expiration_month)
|
60
|
+
expect(found_card.expiration_year.to_i).to eq(credit_card.expiration_year)
|
61
|
+
expect(found_card.customer).to eq(customer)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context "not found" do
|
66
|
+
let(:token) { SecureRandom.hex(6) }
|
67
|
+
|
68
|
+
it "raises an error" do
|
69
|
+
expect { TresDelta::CreditCard.find(customer, token) }.to raise_exception(TresDelta::CreditCardNotFound)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe ".save" do
|
75
|
+
let(:credit_card) { TresDelta::CreditCard.new(params) }
|
76
|
+
let(:result) { credit_card.save }
|
77
|
+
context "card hasn't been tokenized" do
|
78
|
+
context "bad data" do
|
79
|
+
let(:params) { bad_params }
|
80
|
+
|
81
|
+
it "returns false" do
|
82
|
+
expect(result).to be_false
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context "good data" do
|
87
|
+
let(:params) { good_params }
|
88
|
+
|
89
|
+
it "returns true" do
|
90
|
+
expect(result).to be_true
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context "card has been tokenized" do
|
96
|
+
let(:token) { TresDelta::CreditCard.create(customer, good_params).token }
|
97
|
+
|
98
|
+
context "good data" do
|
99
|
+
let(:params) { good_params.merge(:token => token) }
|
100
|
+
|
101
|
+
it "returns true" do
|
102
|
+
expect(result).to be_true
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context "bad data" do
|
107
|
+
let(:params) { bad_params.merge(:token => token, :expiration_month => 13) }
|
108
|
+
|
109
|
+
it "returns false" do
|
110
|
+
expect(result).to be_false
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe TresDelta::Gateway do
|
4
|
-
let(:gateway) { TresDelta::Gateway
|
4
|
+
let(:gateway) { TresDelta::Gateway }
|
5
5
|
let(:transaction_key) { SecureRandom.hex(6) }
|
6
6
|
let(:customer) { TresDelta::Customer.new(name: 'FOO BAR') }
|
7
7
|
let(:good_address) { "10124 Brentridge Ct" }
|
8
|
+
let(:security_code) { nil }
|
8
9
|
|
9
10
|
# arbitrary: Cisco, TX
|
10
11
|
let(:zip_code_good) { '76437' }
|
@@ -17,7 +18,8 @@ describe TresDelta::Gateway do
|
|
17
18
|
name: 'Joe Customer',
|
18
19
|
type: 'Visa',
|
19
20
|
nickname: 'Test Visa, Yo.',
|
20
|
-
billing_address: address_params
|
21
|
+
billing_address: address_params,
|
22
|
+
security_code: security_code
|
21
23
|
})
|
22
24
|
end
|
23
25
|
|
@@ -44,6 +46,29 @@ describe TresDelta::Gateway do
|
|
44
46
|
|
45
47
|
let(:response) { gateway.card_verification(transaction_key, credit_card) }
|
46
48
|
|
49
|
+
context "checking card security code", :wip => true do
|
50
|
+
let(:zip_code) { zip_code_good }
|
51
|
+
subject { response.card_security_code_response }
|
52
|
+
|
53
|
+
context "no security code provided" do
|
54
|
+
it { should eq('None') }
|
55
|
+
end
|
56
|
+
|
57
|
+
context "security code provided" do
|
58
|
+
context "invalid security code" do
|
59
|
+
let(:security_code) { 123 } # fails in development mode
|
60
|
+
|
61
|
+
it { should eq('NotMatched') }
|
62
|
+
end
|
63
|
+
|
64
|
+
context "valid security code" do
|
65
|
+
let(:security_code) { 666 }
|
66
|
+
|
67
|
+
it { should eq('Matched') }
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
47
72
|
context "good zip code" do
|
48
73
|
let(:zip_code) { zip_code_good }
|
49
74
|
|
@@ -110,7 +135,7 @@ describe TresDelta::Gateway do
|
|
110
135
|
let(:amount) { 13.37 }
|
111
136
|
let(:address_params) { { address: good_address, zip_code: zip_code_good} }
|
112
137
|
let(:response) { gateway.authorize(transaction_key, credit_card, amount, order_number, customer) }
|
113
|
-
let(:vault) { TresDelta::Vault
|
138
|
+
let(:vault) { TresDelta::Vault }
|
114
139
|
|
115
140
|
before(:each) do
|
116
141
|
vault.create_customer(customer)
|
@@ -5,17 +5,21 @@ describe TresDelta::Vault do
|
|
5
5
|
let(:wsdl) { config["management_wsdl"] }
|
6
6
|
let(:customer) { TresDelta::Customer.new(name: name) }
|
7
7
|
let(:name) { SecureRandom.hex(4) }
|
8
|
-
let(:vault) { TresDelta::Vault
|
8
|
+
let(:vault) { TresDelta::Vault }
|
9
9
|
|
10
|
-
let(:
|
11
|
-
|
10
|
+
let(:good_visa_params) do
|
11
|
+
{
|
12
12
|
number: '4111111111111111',
|
13
13
|
expiration_month: '8',
|
14
14
|
expiration_year: Time.now.strftime("%Y").to_i + 3,
|
15
15
|
name: 'Joe Customer',
|
16
16
|
type: 'Visa',
|
17
17
|
nickname: 'Test Visa, Yo.'
|
18
|
-
}
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
let(:good_visa) do
|
22
|
+
TresDelta::CreditCard.new(good_visa_params)
|
19
23
|
end
|
20
24
|
|
21
25
|
it "uses the WSDL from the global config" do
|
@@ -39,7 +43,6 @@ describe TresDelta::Vault do
|
|
39
43
|
|
40
44
|
describe ".add_stored_credit_card" do
|
41
45
|
let(:customer) { TresDelta::Customer.new(name: 'Test Customer') }
|
42
|
-
let(:vault) { TresDelta::Vault.new }
|
43
46
|
|
44
47
|
before(:each) do
|
45
48
|
vault.create_customer(customer)
|
@@ -176,4 +179,43 @@ describe TresDelta::Vault do
|
|
176
179
|
end
|
177
180
|
end
|
178
181
|
end
|
182
|
+
|
183
|
+
describe "update_stored_credit_card" do
|
184
|
+
let(:customer) { TresDelta::Customer.create(name: "Test Customer") }
|
185
|
+
let(:stored_card) { TresDelta::CreditCard.create(customer, good_visa_params) }
|
186
|
+
let(:token) { stored_card.token }
|
187
|
+
let(:new_nickname) { SecureRandom.hex(6) }
|
188
|
+
let(:new_name) { SecureRandom.hex(6) }
|
189
|
+
let(:new_expiration_month) { 9 }
|
190
|
+
let(:new_expiration_year) { Time.now.strftime("%Y").to_i + 5 }
|
191
|
+
|
192
|
+
let(:updated_params) do
|
193
|
+
good_visa_params.merge({
|
194
|
+
expiration_month: new_expiration_month,
|
195
|
+
expiration_year: new_expiration_year,
|
196
|
+
nickname: new_nickname,
|
197
|
+
name: new_name,
|
198
|
+
token: token
|
199
|
+
})
|
200
|
+
end
|
201
|
+
|
202
|
+
let(:updated_card) { TresDelta::CreditCard.new(updated_params) }
|
203
|
+
|
204
|
+
context "good information" do
|
205
|
+
let!(:response) { vault.update_stored_credit_card(customer, updated_card) }
|
206
|
+
|
207
|
+
it "succeeds" do
|
208
|
+
expect(response.success?).to be_true
|
209
|
+
end
|
210
|
+
|
211
|
+
let(:reloaded_card_details) { vault.get_stored_credit_card(customer, token).credit_card }
|
212
|
+
|
213
|
+
it "updates the card" do
|
214
|
+
expect(reloaded_card_details[:expiration_month].to_i).to eq(new_expiration_month)
|
215
|
+
expect(reloaded_card_details[:expiration_year].to_i).to eq(new_expiration_year)
|
216
|
+
expect(reloaded_card_details[:friendly_name]).to eq(new_nickname)
|
217
|
+
expect(reloaded_card_details[:name_on_card]).to eq(new_name)
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
179
221
|
end
|
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
|
4
|
+
version: 0.1.0
|
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-
|
12
|
+
date: 2014-03-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: savon
|
@@ -94,6 +94,7 @@ files:
|
|
94
94
|
- lib/tres_delta/version.rb
|
95
95
|
- spec/spec_helper.rb
|
96
96
|
- spec/tres_delta/client_spec.rb
|
97
|
+
- spec/tres_delta/credit_card_spec.rb
|
97
98
|
- spec/tres_delta/customer_spec.rb
|
98
99
|
- spec/tres_delta/gateway_spec.rb
|
99
100
|
- spec/tres_delta/vault_spec.rb
|
@@ -126,6 +127,7 @@ summary: If you need to talk to 3Delta's credit card vault/payment gateway in Ru
|
|
126
127
|
test_files:
|
127
128
|
- spec/spec_helper.rb
|
128
129
|
- spec/tres_delta/client_spec.rb
|
130
|
+
- spec/tres_delta/credit_card_spec.rb
|
129
131
|
- spec/tres_delta/customer_spec.rb
|
130
132
|
- spec/tres_delta/gateway_spec.rb
|
131
133
|
- spec/tres_delta/vault_spec.rb
|