rocketgate-ruby 0.0.1.pre → 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: e174cdc0ab9153dd12a64e537d7f49da9e44b49d
4
- data.tar.gz: 64b9018aa9f8c1266aa234e638c18772a563d147
3
+ metadata.gz: 28ba6e05d3abf64e99ab11caadb6680476ddb495
4
+ data.tar.gz: 5e68e3770a729a27803d551ac538947859440f59
5
5
  SHA512:
6
- metadata.gz: a1cbd4b6a8ebc773c8c3847ad26619e69624fd268703ff23f741b6b2440be5fe919605db38dafd7c51eef12cfb177e80af48e008aa0e74458b4d3bd29778bb8c
7
- data.tar.gz: 3c1695751188219814e250c6966ee38052205fbfaf79c82dc91ffe95f485def41eb263c8bc3c9bc2e4aaba7f61c271e7986cc5f03e6fadf2983621a93179d100
6
+ metadata.gz: 269107a4cf88a3c3c590290d083f4f27519a932e2a1dde051e5131a32dd9726ae15285344f332e61a4e34244f5c032165ee28d7e5a04d27d020dc83f7cc383f4
7
+ data.tar.gz: 49ecba34b191d1388ac81c2dfd22e43d37d7f4ed95b9f242efc19667db95aaa38afc8c8e62cb27e69f174909e2c320ca6eef2631c426f85f9c3bb5e7b8f515b7
@@ -1,8 +1,10 @@
1
1
  module RocketGate
2
2
  class Authorization
3
3
  attr_accessor :auth_code, :avs_response, :cvv_response, :reason_code,
4
- :approved_amount, :approved_currency, :card_hash,
5
- :card_expiration, :card_last_four, :reference_id
4
+ :approved_amount, :approved_currency, :customer_id, :card_hash,
5
+ :card_expiration, :card_last_four, :card_type, :card_description,
6
+ :card_country, :issuer_network, :issuer_url, :issuer_name,
7
+ :issuer_phone, :reference_id
6
8
 
7
9
  def avs_ok?
8
10
  if RocketGate.configuration.require_avs
@@ -26,19 +26,21 @@ module RocketGate
26
26
  config = RocketGate.configuration
27
27
  config.validate!
28
28
 
29
- params = {
29
+ base_params = {
30
30
  version: config.request_version,
31
31
  merchantID: config.merchant_id,
32
32
  merchantPassword: config.merchant_password
33
33
  }
34
+ verification_params = {}
34
35
 
35
- params.merge!({
36
- avsCheck: yes_or_ignore(config.require_avs),
37
- cvv2Check: yes_or_ignore(config.require_cvv),
38
- scrub: yes_or_ignore(config.require_scrub)
39
- }) unless transaction && transaction.is_referenced?
36
+ unless transaction.nil?
37
+ verification_params[:cvv2Check] = yes_or_ignore(config.require_cvv) unless transaction.is_hashed?
38
+ verification_params[:avsCheck] = yes_or_ignore(config.require_avs)
39
+ verification_params[:scrub] = yes_or_ignore(config.require_scrub)
40
+ base_params.merge!(verification_params) unless transaction.is_referenced?
41
+ end
40
42
 
41
- params
43
+ base_params
42
44
  end
43
45
 
44
46
  def yes_or_ignore(boolean)
@@ -14,17 +14,31 @@ module RocketGate
14
14
  def build!
15
15
  @response_code = RocketGate::ResponseCode::RESPONSE[find_value('responseCode')]
16
16
 
17
+ card_type = RocketGate::ResponseCode::CARD_TYPE[find_value('cardDebitCredit')]
18
+ pay_type = find_value('payType').downcase.to_sym rescue :credit
19
+
17
20
  @authorization = RocketGate::Authorization.new.tap do |auth|
18
21
  auth.avs_response = RocketGate::ResponseCode::AVS[find_value('avsResponse')]
19
22
  auth.cvv_response = RocketGate::ResponseCode::CVV[find_value('cvv2Code')]
20
23
  auth.reason_code = RocketGate::ResponseCode::REASON[find_value('reasonCode')]
24
+ auth.card_type = card_type || pay_type
25
+
26
+ auth.issuer_network = RocketGate::ResponseCode::CARD_BRAND[find_value('cardType')]
27
+ auth.issuer_name = find_value('cardIssuerName')
28
+ auth.issuer_phone = find_value('cardIssuerPhone')
29
+ auth.issuer_url = find_value('cardIssuerURL')
30
+
21
31
  auth.auth_code = find_value('authNo')
22
32
  auth.reference_id = find_value('guidNo')
23
33
  auth.approved_amount = find_value('approvedAmount').to_f
24
34
  auth.approved_currency = find_value('approvedCurrency')
35
+ auth.customer_id = find_value('merchantCustomerID')
36
+
25
37
  auth.card_hash = find_value('cardHash')
26
38
  auth.card_expiration = find_value('cardExpiration')
27
39
  auth.card_last_four = find_value('cardLastFour')
40
+ auth.card_description = find_value('cardDescription')
41
+ auth.card_country = find_value('cardCountry')
28
42
  end
29
43
  end
30
44
 
@@ -35,7 +49,12 @@ module RocketGate
35
49
  tx.type = RocketGate::Transaction::TYPE[:confirmation]
36
50
  end
37
51
 
38
- RocketGate.send_request!(RocketGate::Request.new(confirmation))
52
+ confirmation_response = RocketGate.send_request!(RocketGate::Request.new(confirmation))
53
+ if confirmation_response.success?
54
+ return self # return self instead of the empty confirmation response
55
+ else
56
+ raise RocketGate::AuthorizationError.new("Unable to confirm transaction: #{confirmation_response.response_code}")
57
+ end
39
58
  else
40
59
  raise RocketGate::AuthorizationError.new('Unable to confirm unauthorized transaction')
41
60
  end
@@ -64,12 +64,16 @@ module RocketGate
64
64
  @type ||= TYPE[:auth]
65
65
  end
66
66
 
67
+ def is_hashed?
68
+ credit_card && !credit_card.card_hash.nil?
69
+ end
70
+
67
71
  def is_referenced?
68
72
  [ TYPE[:confirmation], TYPE[:ticket], TYPE[:void] ].include?(type) && !reference_id.nil?
69
73
  end
70
74
 
71
75
  def valid?
72
- is_referenced? || super
76
+ is_referenced? || is_hashed? || super
73
77
  end
74
78
  end
75
79
  end
@@ -1,3 +1,3 @@
1
1
  module RocketGate
2
- VERSION = "0.0.1.pre"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -51,7 +51,7 @@ describe RocketGate::Connection do
51
51
  expect(Net::HTTP::Post).to receive(:new).with('/path', {
52
52
  'Accept' => 'text/xml',
53
53
  'Content-Type' => 'text/xml',
54
- 'User-Agent' => 'rocketgate-ruby/0.0.1.pre'
54
+ 'User-Agent' => 'rocketgate-ruby/0.0.2'
55
55
  }).and_return(request)
56
56
  expect(request).to receive(:body=).with('test')
57
57
  subject
@@ -29,7 +29,7 @@ describe 'RocketGate Integration Certification Test Cases', integration: true do
29
29
  cc.number = '4012 8888 8888 1881'
30
30
  cc.exp_month = '08'
31
31
  cc.exp_year = '2042'
32
- cc.cvv = '1111'
32
+ cc.cvv = '111'
33
33
  end
34
34
  end
35
35
  end
@@ -60,6 +60,8 @@ describe 'RocketGate Integration Certification Test Cases', integration: true do
60
60
  expect(ticket_response.authorization.card_last_four).to eq '1881'
61
61
  expect(ticket_response.authorization.card_expiration).to eq '0842'
62
62
  expect(ticket_response.authorization.card_hash).to eq '3RPN+a+d07r0bOlq7NcWPKvzgcyyHmPxXw+hCxxmP6k='
63
+ expect(ticket_response.authorization.card_type).to eq :credit
64
+ expect(ticket_response.authorization.issuer_network).to eq :visa
63
65
  expect(ticket_response.authorization.reference_id).not_to be_nil
64
66
  end
65
67
  end
@@ -20,6 +20,7 @@ describe RocketGate::Request do
20
20
  let(:config) { RocketGate.configuration }
21
21
 
22
22
  it 'returns a hash that respects configuration' do
23
+ request.transaction = double(:transaction, is_referenced?: false, is_hashed?: false)
23
24
  expect(subject[:version]).to eq 'R1.2'
24
25
  expect(subject[:merchantID]).to eq '1'
25
26
  expect(subject[:merchantPassword]).to eq 'testpassword'
@@ -29,7 +30,7 @@ describe RocketGate::Request do
29
30
  end
30
31
 
31
32
  context 'when the transaction is referenced' do
32
- before { request.transaction = double(:transaction, is_referenced?: true) }
33
+ before { request.transaction = double(:transaction, is_referenced?: true, is_hashed?: true) }
33
34
 
34
35
  it 'does not include AVS, CVV or Scrub configuration' do
35
36
  expect(subject[:version]).to eq 'R1.2'
@@ -75,7 +76,7 @@ describe RocketGate::Request do
75
76
  end
76
77
 
77
78
  it 'matches the expected xml output' do
78
- expected = %Q{<?xml version="1.0" encoding="UTF-8"?><gatewayRequest><version>R1.2</version><merchantID>1</merchantID><merchantPassword>testpassword</merchantPassword><avsCheck>IGNORE</avsCheck><cvv2Check>YES</cvv2Check><scrub>YES</scrub><amount>10.97</amount><currency>GBP</currency><merchantInvoiceID>abbb2170-6a71-4d96-aa8f-ceb8b7d1a7ca</merchantInvoiceID><transactionType>CC_AUTH</transactionType><cardNo>4111111111111111</cardNo><expireMonth>02</expireMonth><expireYear>2015</expireYear><cvv2>999</cvv2><merchantCustomerID>Customer-1</merchantCustomerID><customerFirstName>Test</customerFirstName><customerLastName>Person</customerLastName><billingAddress>123 Fake Street</billingAddress><billingCity>Beverly Hills</billingCity><billingState>CA</billingState><billingZipCode>90210</billingZipCode><billingCountry>US</billingCountry><email>test@example.com</email><ipAddress>127.0.0.1</ipAddress></gatewayRequest>}
79
+ expected = %Q{<?xml version="1.0" encoding="UTF-8"?><gatewayRequest><version>R1.2</version><merchantID>1</merchantID><merchantPassword>testpassword</merchantPassword><cvv2Check>YES</cvv2Check><avsCheck>IGNORE</avsCheck><scrub>YES</scrub><amount>10.97</amount><currency>GBP</currency><merchantInvoiceID>abbb2170-6a71-4d96-aa8f-ceb8b7d1a7ca</merchantInvoiceID><transactionType>CC_AUTH</transactionType><cardNo>4111111111111111</cardNo><expireMonth>02</expireMonth><expireYear>2015</expireYear><cvv2>999</cvv2><merchantCustomerID>Customer-1</merchantCustomerID><customerFirstName>Test</customerFirstName><customerLastName>Person</customerLastName><billingAddress>123 Fake Street</billingAddress><billingCity>Beverly Hills</billingCity><billingState>CA</billingState><billingZipCode>90210</billingZipCode><billingCountry>US</billingCountry><email>test@example.com</email><ipAddress>127.0.0.1</ipAddress></gatewayRequest>}
79
80
  expect(subject).to eq expected
80
81
  end
81
82
  end
@@ -52,7 +52,7 @@ describe RocketGate::Response do
52
52
 
53
53
  before do
54
54
  allow(response).to receive(:success?).and_return(success)
55
- allow(RocketGate).to receive(:send_request!).and_return(:ok)
55
+ allow(RocketGate).to receive(:send_request!).and_return(response)
56
56
  end
57
57
 
58
58
  context 'when the request was successful' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rocketgate-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.pre
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Cashwell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-07 00:00:00.000000000 Z
11
+ date: 2014-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -236,12 +236,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
236
236
  version: '0'
237
237
  required_rubygems_version: !ruby/object:Gem::Requirement
238
238
  requirements:
239
- - - ">"
239
+ - - ">="
240
240
  - !ruby/object:Gem::Version
241
- version: 1.3.1
241
+ version: '0'
242
242
  requirements: []
243
243
  rubyforge_project:
244
- rubygems_version: 2.2.2
244
+ rubygems_version: 2.4.2
245
245
  signing_key:
246
246
  specification_version: 4
247
247
  summary: RocketGate Payment Gateway integration for Ruby