activemerchant 1.42.8 → 1.42.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 81edb8d2513f065dd9170ead1d0d6f72d4fc39c8
4
- data.tar.gz: b14933f6c29ebd5ed555e12238a29828a959687a
3
+ metadata.gz: baa3b2ef41f3fd7b7ee93ae111090938ffee872a
4
+ data.tar.gz: 3104e5e77e0895fc86563e6ada9381b37d827f05
5
5
  SHA512:
6
- metadata.gz: 9350271f4a9016fd5c8d0113def4e0ec6a654578d63d824b07647a59128110f6b9bd2a33c3205ad2c89debe1b013b555d08cbd51e68b2333a24a0f98a7a20326
7
- data.tar.gz: 3ce7cf004ee44048d02e6805dd2b63808c104a6cad0d42980246707fb8d50a302d4798c63ced00a2ff7526bedf93e84dfd88ebf2adac2326f10a5a51666bc32c
6
+ metadata.gz: 5eb2c499dad2b3d33e7c820ce3c2afa77ea7376e19a84a348e4577d7ec10f7b8bbc8c8c6facf881ed65ea32de8762b3a1638ad7e5e7d4019545455364c36e323
7
+ data.tar.gz: 97f099bce96fa830eccc9be8d2b2a5934a01e58c4dcb94811827fff49321f48506f1e326f9d7797570af726298664d688241cfaf59e7627627727f1eff497455
Binary file
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG CHANGED
@@ -1,5 +1,13 @@
1
1
  = ActiveMerchant CHANGELOG
2
2
 
3
+ == Version 1.42.9 (April 15, 2014)
4
+
5
+ * Spreedly: Add ip, description and gateway_specific_fields [faizalzakaria]
6
+ * Sage (US): Support store/unstore of cards. [rwdaigle]
7
+ * Pin: Add american express to supported cards [nagash]
8
+ * Raven: Update handling of CVV/AVS [bslobodin]
9
+ * Raven: Use UUID for RequestID [bslobodin]
10
+
3
11
  == Version 1.42.8 (April 4, 2014)
4
12
 
5
13
  * Cecabank: Handle invalid xml response body [duff]
@@ -1,11 +1,35 @@
1
1
  module ActiveMerchant #:nodoc:
2
2
  module Billing #:nodoc:
3
3
  class PacNetRavenGateway < Gateway
4
+
5
+ AVS_ADDRESS_CODES = {
6
+ 'avs_address_unavailable' => 'X',
7
+ 'avs_address_not_checked' => 'X',
8
+ 'avs_address_matched' => 'Y',
9
+ 'avs_address_not_matched' => 'N',
10
+ 'avs_address_partial_match' => 'N'
11
+ }
12
+
13
+ AVS_POSTAL_CODES = {
14
+ 'avs_postal_unavailable' => 'X',
15
+ 'avs_postal_not_checked' => 'X',
16
+ 'avs_postal_matched' => 'Y',
17
+ 'avs_postal_not_matched' => 'N',
18
+ 'avs_postal_partial_match' => 'N'
19
+ }
20
+
21
+ CVV2_CODES = {
22
+ 'cvv2_matched' => 'Y',
23
+ 'cvv2_not_matched' => 'N',
24
+ 'cvv2_unavailable' => 'X',
25
+ 'cvv2_not_checked' => 'X'
26
+ }
27
+
4
28
  self.test_url = 'https://demo.deepcovelabs.com/realtime/'
5
29
  self.live_url = 'https://raven.pacnetservices.com/realtime/'
6
30
 
7
31
  self.supported_countries = ['US']
8
- self.supported_cardtypes = [:visa, :master, :american_express, :discover]
32
+ self.supported_cardtypes = [:visa, :master]
9
33
  self.money_format = :cents
10
34
  self.default_currency = 'USD'
11
35
  self.homepage_url = 'http://www.pacnetservices.com/'
@@ -102,8 +126,11 @@ module ActiveMerchant #:nodoc:
102
126
  :test => test_mode,
103
127
  :authorization => response['TrackingNumber'],
104
128
  :fraud_review => fraud_review?(response),
105
- :avs_result => { :postal_match => response['AVSPostalResponseCode'], :street_match => response['AVSAddressResponseCode'] },
106
- :cvv_result => response['CVV2ResponseCode']
129
+ :avs_result => {
130
+ :postal_match => AVS_POSTAL_CODES[response['AVSPostalResponseCode']],
131
+ :street_match => AVS_ADDRESS_CODES[response['AVSAddressResponseCode']]
132
+ },
133
+ :cvv_result => CVV2_CODES[response['CVV2ResponseCode']]
107
134
  )
108
135
  end
109
136
 
@@ -161,7 +188,7 @@ module ActiveMerchant #:nodoc:
161
188
  end
162
189
 
163
190
  def request_id
164
- (0...21).map{(65+rand(26)).chr}.join.downcase
191
+ SecureRandom.uuid
165
192
  end
166
193
 
167
194
  def signature(action, post, parameters = {})
@@ -7,7 +7,7 @@ module ActiveMerchant #:nodoc:
7
7
  self.default_currency = 'AUD'
8
8
  self.money_format = :cents
9
9
  self.supported_countries = ['AU']
10
- self.supported_cardtypes = [:visa, :master]
10
+ self.supported_cardtypes = [:visa, :master, :american_express]
11
11
  self.homepage_url = 'http://www.pin.net.au/'
12
12
  self.display_name = 'Pin'
13
13
 
@@ -1,5 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/sage/sage_bankcard'
2
2
  require File.dirname(__FILE__) + '/sage/sage_virtual_check'
3
+ require File.dirname(__FILE__) + '/sage/sage_vault'
3
4
 
4
5
  module ActiveMerchant #:nodoc:
5
6
  module Billing #:nodoc:
@@ -138,7 +139,26 @@ module ActiveMerchant #:nodoc:
138
139
  end
139
140
  end
140
141
 
142
+ # Stores a credit card in the Sage vault.
143
+ #
144
+ # ==== Parameters
145
+ #
146
+ # * <tt>credit_card</tt> - The CreditCard object to be stored.
147
+ def store(credit_card, options = {})
148
+ vault.store(credit_card, options)
149
+ end
150
+
151
+ # Deletes a stored card from the Sage vault.
152
+ #
153
+ # ==== Parameters
154
+ #
155
+ # * <tt>identification</tt> - The 'GUID' identifying the stored card.
156
+ def unstore(identification, options = {})
157
+ vault.unstore(identification, options)
158
+ end
159
+
141
160
  private
161
+
142
162
  def bankcard
143
163
  @bankcard ||= SageBankcardGateway.new(@options)
144
164
  end
@@ -146,7 +166,10 @@ module ActiveMerchant #:nodoc:
146
166
  def virtual_check
147
167
  @virtual_check ||= SageVirtualCheckGateway.new(@options)
148
168
  end
169
+
170
+ def vault
171
+ @vault ||= SageVaultGateway.new(@options)
172
+ end
149
173
  end
150
174
  end
151
175
  end
152
-
@@ -0,0 +1,149 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class SageVaultGateway < Gateway #:nodoc:
4
+ self.live_url = 'https://www.sagepayments.net/web_services/wsVault/wsVault.asmx'
5
+
6
+ def initialize(options = {})
7
+ requires!(options, :login, :password)
8
+ super
9
+ end
10
+
11
+ def store(credit_card, options = {})
12
+ request = build_store_request(credit_card, options)
13
+ commit(:store, request)
14
+ end
15
+
16
+ def unstore(identification, options = {})
17
+ request = build_unstore_request(identification, options)
18
+ commit(:unstore, request)
19
+ end
20
+
21
+ private
22
+
23
+ # A valid request example, since the Sage docs have none:
24
+ #
25
+ # <?xml version="1.0" encoding="UTF-8" ?>
26
+ # <SOAP-ENV:Envelope
27
+ # xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
28
+ # xmlns:ns1="https://www.sagepayments.net/web_services/wsVault/wsVault">
29
+ # <SOAP-ENV:Body>
30
+ # <ns1:INSERT_CREDIT_CARD_DATA>
31
+ # <ns1:M_ID>279277516172</ns1:M_ID>
32
+ # <ns1:M_KEY>O3I8G2H8V6A3</ns1:M_KEY>
33
+ # <ns1:CARDNUMBER>4111111111111111</ns1:CARDNUMBER>
34
+ # <ns1:EXPIRATION_DATE>0915</ns1:EXPIRATION_DATE>
35
+ # </ns1:INSERT_CREDIT_CARD_DATA>
36
+ # </SOAP-ENV:Body>
37
+ # </SOAP-ENV:Envelope>
38
+ def build_store_request(credit_card, options)
39
+ xml = Builder::XmlMarkup.new
40
+ add_credit_card(xml, credit_card, options)
41
+ xml.target!
42
+ end
43
+
44
+ def build_unstore_request(identification, options)
45
+ xml = Builder::XmlMarkup.new
46
+ add_identification(xml, identification, options)
47
+ xml.target!
48
+ end
49
+
50
+ def add_customer_data(xml)
51
+ xml.tag! 'ns1:M_ID', @options[:login]
52
+ xml.tag! 'ns1:M_KEY', @options[:password]
53
+ end
54
+
55
+ def add_credit_card(xml, credit_card, options)
56
+ xml.tag! 'ns1:CARDNUMBER', credit_card.number
57
+ xml.tag! 'ns1:EXPIRATION_DATE', exp_date(credit_card)
58
+ end
59
+
60
+ def add_identification(xml, identification, options)
61
+ xml.tag! 'ns1:GUID', identification
62
+ end
63
+
64
+ def exp_date(credit_card)
65
+ year = sprintf("%.4i", credit_card.year)
66
+ month = sprintf("%.2i", credit_card.month)
67
+
68
+ "#{month}#{year[-2..-1]}"
69
+ end
70
+
71
+ def commit(action, request)
72
+ response = parse(ssl_post(live_url,
73
+ build_soap_request(action, request),
74
+ build_headers(action))
75
+ )
76
+
77
+ case action
78
+ when :store
79
+ success = response[:success] == 'true'
80
+ message = response[:message].downcase.capitalize if response[:message]
81
+ when :unstore
82
+ success = response[:delete_data_result] == 'true'
83
+ message = success ? 'Succeeded' : 'Failed'
84
+ end
85
+
86
+ Response.new(success, message, response,
87
+ authorization: response[:guid]
88
+ )
89
+ end
90
+
91
+ ENVELOPE_NAMESPACES = {
92
+ 'xmlns:SOAP-ENV' => "http://schemas.xmlsoap.org/soap/envelope/",
93
+ 'xmlns:ns1' => "https://www.sagepayments.net/web_services/wsVault/wsVault"
94
+ }
95
+
96
+ ACTION_ELEMENTS = {
97
+ store: 'INSERT_CREDIT_CARD_DATA',
98
+ unstore: 'DELETE_DATA'
99
+ }
100
+
101
+ def build_soap_request(action, body)
102
+ xml = Builder::XmlMarkup.new
103
+
104
+ xml.instruct!
105
+ xml.tag! 'SOAP-ENV:Envelope', ENVELOPE_NAMESPACES do
106
+ xml.tag! 'SOAP-ENV:Body' do
107
+ xml.tag! "ns1:#{ACTION_ELEMENTS[action]}" do
108
+ add_customer_data(xml)
109
+ xml << body
110
+ end
111
+ end
112
+ end
113
+ xml.target!
114
+ end
115
+
116
+ SOAP_ACTIONS = {
117
+ store: 'https://www.sagepayments.net/web_services/wsVault/wsVault/INSERT_CREDIT_CARD_DATA',
118
+ unstore: 'https://www.sagepayments.net/web_services/wsVault/wsVault/DELETE_DATA'
119
+ }
120
+
121
+ def build_headers(action)
122
+ {
123
+ "SOAPAction" => SOAP_ACTIONS[action],
124
+ "Content-Type" => "text/xml; charset=utf-8"
125
+ }
126
+ end
127
+
128
+ def parse(body)
129
+ response = {}
130
+ hashify_xml!(body, response)
131
+ response
132
+ end
133
+
134
+ def hashify_xml!(xml, response)
135
+ xml = REXML::Document.new(xml)
136
+
137
+ # Store
138
+ xml.elements.each("//Table1/*") do |node|
139
+ response[node.name.underscore.to_sym] = node.text
140
+ end
141
+
142
+ # Unstore
143
+ xml.elements.each("//DELETE_DATAResponse/*") do |node|
144
+ response[node.name.underscore.to_sym] = node.text
145
+ end
146
+ end
147
+ end
148
+ end
149
+ end
@@ -110,7 +110,7 @@ module ActiveMerchant #:nodoc:
110
110
  def save_card(retain, credit_card, options)
111
111
  request = build_xml_request('payment_method') do |doc|
112
112
  add_credit_card(doc, credit_card, options)
113
- add_data(doc, options)
113
+ add_extra_options(:data, doc, options)
114
114
  doc.retained(true) if retain
115
115
  end
116
116
 
@@ -130,6 +130,8 @@ module ActiveMerchant #:nodoc:
130
130
  def auth_purchase_request(money, payment_method_token, options)
131
131
  build_xml_request('transaction') do |doc|
132
132
  add_invoice(doc, money, options)
133
+ doc.ip(options[:ip])
134
+ add_extra_options(:gateway_specific_fields, doc, options)
133
135
  doc.payment_method_token(payment_method_token)
134
136
  doc.retain_on_success(true) if options[:store]
135
137
  end
@@ -139,6 +141,7 @@ module ActiveMerchant #:nodoc:
139
141
  doc.amount amount(money)
140
142
  doc.currency_code(options[:currency] || currency(money) || default_currency)
141
143
  doc.order_id(options[:order_id])
144
+ doc.description(options[:description])
142
145
  end
143
146
 
144
147
  def add_credit_card(doc, credit_card, options)
@@ -159,17 +162,17 @@ module ActiveMerchant #:nodoc:
159
162
  end
160
163
  end
161
164
 
162
- def add_data(doc, options)
163
- doc.data do
164
- data_to_doc(doc, options[:data])
165
+ def add_extra_options(type, doc, options)
166
+ doc.send(type) do
167
+ extra_options_to_doc(doc, options[type])
165
168
  end
166
169
  end
167
170
 
168
- def data_to_doc(doc, value)
171
+ def extra_options_to_doc(doc, value)
169
172
  return doc.text value unless value.kind_of? Hash
170
173
  value.each do |k, v|
171
174
  doc.send(k) do
172
- data_to_doc(doc, v)
175
+ extra_options_to_doc(doc, v)
173
176
  end
174
177
  end
175
178
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveMerchant
2
- VERSION = "1.42.8"
2
+ VERSION = "1.42.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activemerchant
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.42.8
4
+ version: 1.42.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Luetke
@@ -30,7 +30,7 @@ cert_chain:
30
30
  ZJB9YPQZG+vWBdDSca3sUMtvFxpLUFwdKF5APSPOVnhbFJ3vSXY1ulP/R6XW9vnw
31
31
  6kkQi2fHhU20ugMzp881Eixr+TjC0RvUerLG7g==
32
32
  -----END CERTIFICATE-----
33
- date: 2014-04-04 00:00:00.000000000 Z
33
+ date: 2014-04-15 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: activesupport
@@ -350,6 +350,7 @@ files:
350
350
  - lib/active_merchant/billing/gateways/sage.rb
351
351
  - lib/active_merchant/billing/gateways/sage/sage_bankcard.rb
352
352
  - lib/active_merchant/billing/gateways/sage/sage_core.rb
353
+ - lib/active_merchant/billing/gateways/sage/sage_vault.rb
353
354
  - lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb
354
355
  - lib/active_merchant/billing/gateways/sage_pay.rb
355
356
  - lib/active_merchant/billing/gateways/sallie_mae.rb
metadata.gz.sig CHANGED
Binary file