activemerchant 1.20.4 → 1.21.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/CHANGELOG +29 -0
- data/CONTRIBUTORS +13 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +1 -1
- data/lib/active_merchant/billing/gateway.rb +1 -1
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +104 -18
- data/lib/active_merchant/billing/gateways/beanstream.rb +29 -1
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +105 -3
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +4 -0
- data/lib/active_merchant/billing/gateways/certo_direct.rb +279 -0
- data/lib/active_merchant/billing/gateways/epay.rb +2 -2
- data/lib/active_merchant/billing/gateways/eway_managed.rb +1 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +1 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +244 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +10 -2
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +1 -1
- data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +43 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +36 -1
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +8 -3
- data/lib/active_merchant/billing/gateways/quickpay.rb +1 -0
- data/lib/active_merchant/billing/gateways/samurai.rb +1 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +136 -49
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +1 -1
- data/lib/active_merchant/billing/gateways/stripe.rb +23 -11
- data/lib/active_merchant/billing/gateways/verifi.rb +2 -2
- data/lib/active_merchant/billing/gateways/viaklix.rb +1 -1
- data/lib/active_merchant/billing/integrations/action_view_helper.rb +5 -1
- data/lib/active_merchant/billing/integrations/authorize_net_sim.rb +38 -0
- data/lib/active_merchant/billing/integrations/authorize_net_sim/helper.rb +228 -0
- data/lib/active_merchant/billing/integrations/authorize_net_sim/notification.rb +340 -0
- data/lib/active_merchant/billing/integrations/helper.rb +13 -1
- data/lib/active_merchant/billing/integrations/payflow_link/helper.rb +1 -1
- data/lib/active_merchant/version.rb +1 -1
- metadata +37 -31
- metadata.gz.sig +0 -0
@@ -94,6 +94,10 @@ module ActiveMerchant #:nodoc:
|
|
94
94
|
xml.tag! 'Description', options[:description] unless options[:description].blank?
|
95
95
|
xml.tag! 'Comment', options[:comment] unless options[:comment].blank?
|
96
96
|
xml.tag!('ExtData', 'Name'=> 'COMMENT2', 'Value'=> options[:comment2]) unless options[:comment2].blank?
|
97
|
+
xml.tag! 'TaxAmt', options[:taxamt] unless options[:taxamt].blank?
|
98
|
+
xml.tag! 'FreightAmt', options[:freightamt] unless options[:freightamt].blank?
|
99
|
+
xml.tag! 'DutyAmt', options[:dutyamt] unless options[:dutyamt].blank?
|
100
|
+
xml.tag! 'DiscountAmt', options[:discountamt] unless options[:discountamt].blank?
|
97
101
|
|
98
102
|
billing_address = options[:billing_address] || options[:address]
|
99
103
|
add_address(xml, 'BillTo', billing_address, options) if billing_address
|
@@ -122,6 +126,10 @@ module ActiveMerchant #:nodoc:
|
|
122
126
|
# Comment and Comment2 will show up in manager.paypal.com as Comment1 and Comment2
|
123
127
|
xml.tag! 'Comment', options[:comment] unless options[:comment].blank?
|
124
128
|
xml.tag!('ExtData', 'Name'=> 'COMMENT2', 'Value'=> options[:comment2]) unless options[:comment2].blank?
|
129
|
+
xml.tag! 'TaxAmt', options[:taxamt] unless options[:taxamt].blank?
|
130
|
+
xml.tag! 'FreightAmt', options[:freightamt] unless options[:freightamt].blank?
|
131
|
+
xml.tag! 'DutyAmt', options[:dutyamt] unless options[:dutyamt].blank?
|
132
|
+
xml.tag! 'DiscountAmt', options[:discountamt] unless options[:discountamt].blank?
|
125
133
|
|
126
134
|
billing_address = options[:billing_address] || options[:address]
|
127
135
|
add_address(xml, 'BillTo', billing_address, options) if billing_address
|
@@ -161,8 +169,8 @@ module ActiveMerchant #:nodoc:
|
|
161
169
|
end
|
162
170
|
|
163
171
|
def expdate(creditcard)
|
164
|
-
year = sprintf("%.4i", creditcard.year)
|
165
|
-
month = sprintf("%.2i", creditcard.month)
|
172
|
+
year = sprintf("%.4i", creditcard.year.to_s.sub(/^0+/, ''))
|
173
|
+
month = sprintf("%.2i", creditcard.month.to_s.sub(/^0+/, ''))
|
166
174
|
|
167
175
|
"#{year}#{month}"
|
168
176
|
end
|
@@ -126,6 +126,7 @@ module ActiveMerchant #:nodoc:
|
|
126
126
|
xml.tag! 'EMail', options[:email] unless options[:email].blank?
|
127
127
|
xml.tag! 'Phone', address[:phone] unless address[:phone].blank?
|
128
128
|
xml.tag! 'CustCode', options[:customer] if !options[:customer].blank? && tag == 'BillTo'
|
129
|
+
xml.tag! 'PONum', options[:po_number] if !options[:po_number].blank? && tag == 'BillTo'
|
129
130
|
|
130
131
|
xml.tag! 'Address' do
|
131
132
|
xml.tag! 'Street', address[:address1] unless address[:address1].blank?
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/paypal/paypal_common_api'
|
2
|
+
require File.dirname(__FILE__) + '/paypal/paypal_express_response'
|
3
|
+
require File.dirname(__FILE__) + '/paypal_express_common'
|
4
|
+
|
5
|
+
module ActiveMerchant #:nodoc:
|
6
|
+
module Billing #:nodoc:
|
7
|
+
class PaypalDigitalGoodsGateway < PaypalExpressGateway
|
8
|
+
self.test_redirect_url = 'https://www.sandbox.paypal.com/incontext'
|
9
|
+
self.live_redirect_url = 'https://www.paypal.com/incontext'
|
10
|
+
|
11
|
+
self.supported_countries = %w(AU CA CN FI GB ID IN IT MY NO NZ PH PL SE SG TH VN)
|
12
|
+
self.homepage_url = 'https://www.x.com/community/ppx/xspaces/digital_goods'
|
13
|
+
self.display_name = 'PayPal Express Checkout for Digital Goods'
|
14
|
+
|
15
|
+
def redirect_url_for(token, options = {})
|
16
|
+
"#{redirect_url}?token=#{token}&useraction=commit"
|
17
|
+
end
|
18
|
+
|
19
|
+
# GATEWAY.setup_purchase(100,
|
20
|
+
# :ip => "127.0.0.1",
|
21
|
+
# :description => "Test Title",
|
22
|
+
# :return_url => "http://return.url",
|
23
|
+
# :cancel_return_url => "http://cancel.url",
|
24
|
+
# :items => [ { :name => "Charge",
|
25
|
+
# :number => "1",
|
26
|
+
# :quantity => "1",
|
27
|
+
# :amount => 100,
|
28
|
+
# :description => "Description",
|
29
|
+
# :category => "Digital" } ] )
|
30
|
+
def build_setup_request(action, money, options)
|
31
|
+
requires!(options, :items)
|
32
|
+
raise ArgumentError, "Must include at least 1 Item" unless options[:items].length > 0
|
33
|
+
options[:items].each do |item|
|
34
|
+
requires!(item, :name, :number, :quantity, :amount, :description, :category)
|
35
|
+
raise ArgumentError, "Each of the items must have the category 'Digital'" unless item[:category] == 'Digital'
|
36
|
+
end
|
37
|
+
|
38
|
+
super
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -41,6 +41,12 @@ module ActiveMerchant #:nodoc:
|
|
41
41
|
commit 'DoExpressCheckoutPayment', build_sale_or_authorization_request('Sale', money, options)
|
42
42
|
end
|
43
43
|
|
44
|
+
def reference_transaction(money, options = {})
|
45
|
+
requires!(options, :reference_id, :payment_type, :invoice_id, :description, :ip)
|
46
|
+
|
47
|
+
commit 'DoReferenceTransaction', build_reference_transaction_request('Sale', money, options)
|
48
|
+
end
|
49
|
+
|
44
50
|
private
|
45
51
|
def build_get_details_request(token)
|
46
52
|
xml = Builder::XmlMarkup.new :indent => 2
|
@@ -106,6 +112,7 @@ module ActiveMerchant #:nodoc:
|
|
106
112
|
xml.tag! 'n2:NoShipping', options[:no_shipping] ? '1' : '0'
|
107
113
|
xml.tag! 'n2:AddressOverride', options[:address_override] ? '1' : '0'
|
108
114
|
xml.tag! 'n2:LocaleCode', options[:locale] unless options[:locale].blank?
|
115
|
+
xml.tag! 'n2:BrandName', options[:brand_name] unless options[:brand_name].blank?
|
109
116
|
# Customization of the payment page
|
110
117
|
xml.tag! 'n2:PageStyle', options[:page_style] unless options[:page_style].blank?
|
111
118
|
xml.tag! 'n2:cpp-header-image', options[:header_image] unless options[:header_image].blank?
|
@@ -149,6 +156,7 @@ module ActiveMerchant #:nodoc:
|
|
149
156
|
add_items_xml(xml, options, currency_code) if options[:items]
|
150
157
|
|
151
158
|
xml.tag! 'n2:PaymentAction', action
|
159
|
+
xml.tag! 'n2:Custom', options[:custom] unless options[:custom].blank?
|
152
160
|
end
|
153
161
|
|
154
162
|
if options[:shipping_options]
|
@@ -170,6 +178,32 @@ module ActiveMerchant #:nodoc:
|
|
170
178
|
xml.target!
|
171
179
|
end
|
172
180
|
|
181
|
+
def build_reference_transaction_request(action, money, options)
|
182
|
+
currency_code = options[:currency] || currency(money)
|
183
|
+
|
184
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
185
|
+
xml.tag! 'DoReferenceTransactionReq', 'xmlns' => PAYPAL_NAMESPACE do
|
186
|
+
xml.tag! 'DoReferenceTransactionRequest', 'xmlns:n2' => EBAY_NAMESPACE do
|
187
|
+
xml.tag! 'n2:Version', API_VERSION
|
188
|
+
xml.tag! 'n2:DoReferenceTransactionRequestDetails' do
|
189
|
+
xml.tag! 'n2:ReferenceID', options[:reference_id]
|
190
|
+
xml.tag! 'n2:PaymentAction', action
|
191
|
+
xml.tag! 'n2:PaymentType', options[:payment_type] || 'Any'
|
192
|
+
xml.tag! 'n2:PaymentDetails' do
|
193
|
+
xml.tag! 'n2:OrderTotal', amount(money).to_f.zero? ? localized_amount(100, currency_code) : localized_amount(money, currency_code), 'currencyID' => currency_code
|
194
|
+
xml.tag! 'n2:OrderDescription', options[:description]
|
195
|
+
xml.tag! 'n2:InvoiceID', options[:invoice_id]
|
196
|
+
xml.tag! 'n2:ButtonSource', 'ActiveMerchant'
|
197
|
+
xml.tag! 'n2:NotifyURL', ''
|
198
|
+
end
|
199
|
+
xml.tag! 'n2:IPAddress', options[:ip]
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
xml.target!
|
205
|
+
end
|
206
|
+
|
173
207
|
def build_response(success, message, response, options = {})
|
174
208
|
PaypalExpressResponse.new(success, message, response, options)
|
175
209
|
end
|
@@ -187,9 +221,10 @@ module ActiveMerchant #:nodoc:
|
|
187
221
|
end
|
188
222
|
xml.tag! 'n2:Description', item[:description]
|
189
223
|
xml.tag! 'n2:ItemURL', item[:url]
|
224
|
+
xml.tag! 'n2:ItemCategory', item[:category] if item[:category]
|
190
225
|
end
|
191
226
|
end
|
192
227
|
end
|
193
228
|
end
|
194
229
|
end
|
195
|
-
end
|
230
|
+
end
|
@@ -2,8 +2,13 @@ module ActiveMerchant
|
|
2
2
|
module Billing
|
3
3
|
module PaypalExpressCommon
|
4
4
|
def self.included(base)
|
5
|
-
base.
|
6
|
-
|
5
|
+
if base.respond_to?(:class_attribute)
|
6
|
+
base.class_attribute :test_redirect_url
|
7
|
+
base.class_attribute :live_redirect_url
|
8
|
+
else
|
9
|
+
base.class_inheritable_accessor :test_redirect_url
|
10
|
+
base.class_inheritable_accessor :live_redirect_url
|
11
|
+
end
|
7
12
|
base.live_redirect_url = 'https://www.paypal.com/cgibin/webscr'
|
8
13
|
end
|
9
14
|
|
@@ -22,4 +27,4 @@ module ActiveMerchant
|
|
22
27
|
end
|
23
28
|
end
|
24
29
|
end
|
25
|
-
end
|
30
|
+
end
|
@@ -76,6 +76,7 @@ module ActiveMerchant #:nodoc:
|
|
76
76
|
:zip => address[:zip],
|
77
77
|
:sandbox => test?
|
78
78
|
})
|
79
|
+
result.retain if options[:retain] && result.is_sensitive_data_valid && result.payment_method_token
|
79
80
|
|
80
81
|
Response.new(result.is_sensitive_data_valid,
|
81
82
|
message_from_result(result),
|
@@ -4,30 +4,33 @@ module ActiveMerchant #:nodoc:
|
|
4
4
|
module Billing #:nodoc:
|
5
5
|
class SecurePayAuGateway < Gateway
|
6
6
|
API_VERSION = 'xml-4.2'
|
7
|
-
|
7
|
+
PERIODIC_API_VERSION = 'spxml-3.0'
|
8
|
+
|
8
9
|
TEST_URL = 'https://www.securepay.com.au/test/payment'
|
9
10
|
LIVE_URL = 'https://www.securepay.com.au/xmlapi/payment'
|
10
|
-
|
11
|
+
TEST_PERIODIC_URL = "https://test.securepay.com.au/xmlapi/periodic"
|
12
|
+
LIVE_PERIODIC_URL = "https://api.securepay.com.au/xmlapi/periodic"
|
13
|
+
|
11
14
|
self.supported_countries = ['AU']
|
12
15
|
self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb]
|
13
|
-
|
16
|
+
|
14
17
|
# The homepage URL of the gateway
|
15
18
|
self.homepage_url = 'http://securepay.com.au'
|
16
|
-
|
19
|
+
|
17
20
|
# The name of the gateway
|
18
21
|
self.display_name = 'SecurePay'
|
19
|
-
|
22
|
+
|
20
23
|
class_attribute :request_timeout
|
21
24
|
self.request_timeout = 60
|
22
|
-
|
25
|
+
|
23
26
|
self.money_format = :cents
|
24
27
|
self.default_currency = 'AUD'
|
25
|
-
|
28
|
+
|
26
29
|
# 0 Standard Payment
|
27
|
-
# 4 Refund
|
28
|
-
# 6 Client Reversal (Void)
|
29
|
-
# 10 Preauthorise
|
30
|
-
# 11 Preauth Complete (Advice)
|
30
|
+
# 4 Refund
|
31
|
+
# 6 Client Reversal (Void)
|
32
|
+
# 10 Preauthorise
|
33
|
+
# 11 Preauth Complete (Advice)
|
31
34
|
TRANSACTIONS = {
|
32
35
|
:purchase => 0,
|
33
36
|
:authorization => 10,
|
@@ -35,33 +38,50 @@ module ActiveMerchant #:nodoc:
|
|
35
38
|
:void => 6,
|
36
39
|
:refund => 4
|
37
40
|
}
|
38
|
-
|
41
|
+
|
42
|
+
PERIODIC_ACTIONS = {
|
43
|
+
:add_triggered => "add",
|
44
|
+
:remove_triggered => "delete",
|
45
|
+
:trigger => "trigger"
|
46
|
+
}
|
47
|
+
|
48
|
+
PERIODIC_TYPES = {
|
49
|
+
:add_triggered => 4,
|
50
|
+
:remove_triggered => nil,
|
51
|
+
:trigger => nil
|
52
|
+
}
|
53
|
+
|
39
54
|
SUCCESS_CODES = [ '00', '08', '11', '16', '77' ]
|
40
|
-
|
55
|
+
|
41
56
|
def initialize(options = {})
|
42
57
|
requires!(options, :login, :password)
|
43
58
|
@options = options
|
44
59
|
super
|
45
60
|
end
|
46
|
-
|
61
|
+
|
47
62
|
def test?
|
48
63
|
@options[:test] || super
|
49
64
|
end
|
50
|
-
|
51
|
-
def purchase(money,
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
65
|
+
|
66
|
+
def purchase(money, credit_card_or_stored_id, options = {})
|
67
|
+
if credit_card_or_stored_id.is_a?(ActiveMerchant::Billing::CreditCard)
|
68
|
+
requires!(options, :order_id)
|
69
|
+
commit :purchase, build_purchase_request(money, credit_card_or_stored_id, options)
|
70
|
+
else
|
71
|
+
options[:billing_id] = credit_card_or_stored_id.to_s
|
72
|
+
commit_periodic(build_periodic_item(:trigger, money, nil, options))
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
56
76
|
def authorize(money, credit_card, options = {})
|
57
77
|
requires!(options, :order_id)
|
58
78
|
commit :authorization, build_purchase_request(money, credit_card, options)
|
59
79
|
end
|
60
|
-
|
80
|
+
|
61
81
|
def capture(money, reference, options = {})
|
62
82
|
commit :capture, build_reference_request(money, reference)
|
63
83
|
end
|
64
|
-
|
84
|
+
|
65
85
|
def refund(money, reference, options = {})
|
66
86
|
commit :refund, build_reference_request(money, reference)
|
67
87
|
end
|
@@ -74,54 +94,64 @@ module ActiveMerchant #:nodoc:
|
|
74
94
|
def void(reference, options = {})
|
75
95
|
commit :void, build_reference_request(nil, reference)
|
76
96
|
end
|
77
|
-
|
97
|
+
|
98
|
+
def store(creditcard, options = {})
|
99
|
+
requires!(options, :billing_id, :amount)
|
100
|
+
commit_periodic(build_periodic_item(:add_triggered, options[:amount], creditcard, options))
|
101
|
+
end
|
102
|
+
|
103
|
+
def unstore(identification, options = {})
|
104
|
+
options[:billing_id] = identification
|
105
|
+
commit_periodic(build_periodic_item(:remove_triggered, options[:amount], nil, options))
|
106
|
+
end
|
107
|
+
|
78
108
|
private
|
79
|
-
|
109
|
+
|
80
110
|
def build_purchase_request(money, credit_card, options)
|
81
111
|
xml = Builder::XmlMarkup.new
|
82
|
-
|
112
|
+
|
83
113
|
xml.tag! 'amount', amount(money)
|
84
|
-
xml.tag! 'currency', options[:currency] || currency(money)
|
114
|
+
xml.tag! 'currency', options[:currency] || currency(money)
|
85
115
|
xml.tag! 'purchaseOrderNo', options[:order_id].to_s.gsub(/[ ']/, '')
|
86
|
-
|
116
|
+
|
87
117
|
xml.tag! 'CreditCardInfo' do
|
88
118
|
xml.tag! 'cardNumber', credit_card.number
|
89
119
|
xml.tag! 'expiryDate', expdate(credit_card)
|
90
120
|
xml.tag! 'cvv', credit_card.verification_value if credit_card.verification_value?
|
91
121
|
end
|
92
|
-
|
122
|
+
|
93
123
|
xml.target!
|
94
124
|
end
|
95
|
-
|
125
|
+
|
96
126
|
def build_reference_request(money, reference)
|
97
127
|
xml = Builder::XmlMarkup.new
|
98
|
-
|
128
|
+
|
99
129
|
transaction_id, order_id, preauth_id, original_amount = reference.split("*")
|
100
130
|
xml.tag! 'amount', (money ? amount(money) : original_amount)
|
101
131
|
xml.tag! 'currency', options[:currency] || currency(money)
|
102
132
|
xml.tag! 'txnID', transaction_id
|
103
133
|
xml.tag! 'purchaseOrderNo', order_id
|
104
134
|
xml.tag! 'preauthID', preauth_id
|
105
|
-
|
135
|
+
|
106
136
|
xml.target!
|
107
137
|
end
|
108
|
-
|
138
|
+
|
109
139
|
def build_request(action, body)
|
110
140
|
xml = Builder::XmlMarkup.new
|
111
141
|
xml.instruct!
|
112
142
|
xml.tag! 'SecurePayMessage' do
|
113
143
|
xml.tag! 'MessageInfo' do
|
114
|
-
xml.tag! 'messageID', Utils.generate_unique_id.slice(0, 30)
|
144
|
+
xml.tag! 'messageID', ActiveMerchant::Utils.generate_unique_id.slice(0, 30)
|
115
145
|
xml.tag! 'messageTimestamp', generate_timestamp
|
116
146
|
xml.tag! 'timeoutValue', request_timeout
|
117
147
|
xml.tag! 'apiVersion', API_VERSION
|
118
148
|
end
|
119
|
-
|
149
|
+
|
120
150
|
xml.tag! 'MerchantInfo' do
|
121
151
|
xml.tag! 'merchantID', @options[:login]
|
122
152
|
xml.tag! 'password', @options[:password]
|
123
153
|
end
|
124
|
-
|
154
|
+
|
125
155
|
xml.tag! 'RequestType', 'Payment'
|
126
156
|
xml.tag! 'Payment' do
|
127
157
|
xml.tag! 'TxnList', "count" => 1 do
|
@@ -133,40 +163,98 @@ module ActiveMerchant #:nodoc:
|
|
133
163
|
end
|
134
164
|
end
|
135
165
|
end
|
136
|
-
|
166
|
+
|
137
167
|
xml.target!
|
138
168
|
end
|
139
|
-
|
169
|
+
|
140
170
|
def commit(action, request)
|
141
171
|
response = parse(ssl_post(test? ? TEST_URL : LIVE_URL, build_request(action, request)))
|
142
|
-
|
143
|
-
Response.new(success?(response), message_from(response), response,
|
144
|
-
:test => test?,
|
172
|
+
|
173
|
+
Response.new(success?(response), message_from(response), response,
|
174
|
+
:test => test?,
|
175
|
+
:authorization => authorization_from(response)
|
176
|
+
)
|
177
|
+
end
|
178
|
+
|
179
|
+
def build_periodic_item(action, money, credit_card, options)
|
180
|
+
xml = Builder::XmlMarkup.new
|
181
|
+
|
182
|
+
xml.tag! 'actionType', PERIODIC_ACTIONS[action]
|
183
|
+
xml.tag! 'clientID', options[:billing_id].to_s
|
184
|
+
|
185
|
+
if credit_card
|
186
|
+
xml.tag! 'CreditCardInfo' do
|
187
|
+
xml.tag! 'cardNumber', credit_card.number
|
188
|
+
xml.tag! 'expiryDate', expdate(credit_card)
|
189
|
+
xml.tag! 'cvv', credit_card.verification_value if credit_card.verification_value?
|
190
|
+
end
|
191
|
+
end
|
192
|
+
xml.tag! 'amount', amount(money)
|
193
|
+
xml.tag! 'periodicType', PERIODIC_TYPES[action] if PERIODIC_TYPES[action]
|
194
|
+
|
195
|
+
xml.target!
|
196
|
+
end
|
197
|
+
|
198
|
+
def build_periodic_request(body)
|
199
|
+
xml = Builder::XmlMarkup.new
|
200
|
+
xml.instruct!
|
201
|
+
xml.tag! 'SecurePayMessage' do
|
202
|
+
xml.tag! 'MessageInfo' do
|
203
|
+
xml.tag! 'messageID', ActiveMerchant::Utils.generate_unique_id.slice(0, 30)
|
204
|
+
xml.tag! 'messageTimestamp', generate_timestamp
|
205
|
+
xml.tag! 'timeoutValue', request_timeout
|
206
|
+
xml.tag! 'apiVersion', PERIODIC_API_VERSION
|
207
|
+
end
|
208
|
+
|
209
|
+
xml.tag! 'MerchantInfo' do
|
210
|
+
xml.tag! 'merchantID', @options[:login]
|
211
|
+
xml.tag! 'password', @options[:password]
|
212
|
+
end
|
213
|
+
|
214
|
+
xml.tag! 'RequestType', 'Periodic'
|
215
|
+
xml.tag! 'Periodic' do
|
216
|
+
xml.tag! 'PeriodicList', "count" => 1 do
|
217
|
+
xml.tag! 'PeriodicItem', "ID" => 1 do
|
218
|
+
xml << body
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
xml.target!
|
224
|
+
end
|
225
|
+
|
226
|
+
def commit_periodic(request)
|
227
|
+
my_request = build_periodic_request(request)
|
228
|
+
#puts my_request
|
229
|
+
response = parse(ssl_post(test? ? TEST_PERIODIC_URL : LIVE_PERIODIC_URL, my_request))
|
230
|
+
|
231
|
+
Response.new(success?(response), message_from(response), response,
|
232
|
+
:test => test?,
|
145
233
|
:authorization => authorization_from(response)
|
146
234
|
)
|
147
235
|
end
|
148
|
-
|
236
|
+
|
149
237
|
def success?(response)
|
150
238
|
SUCCESS_CODES.include?(response[:response_code])
|
151
239
|
end
|
152
|
-
|
240
|
+
|
153
241
|
def authorization_from(response)
|
154
242
|
[response[:txn_id], response[:purchase_order_no], response[:preauth_id], response[:amount]].join('*')
|
155
243
|
end
|
156
|
-
|
244
|
+
|
157
245
|
def message_from(response)
|
158
246
|
response[:response_text] || response[:status_description]
|
159
247
|
end
|
160
|
-
|
248
|
+
|
161
249
|
def expdate(credit_card)
|
162
250
|
"#{format(credit_card.month, :two_digits)}/#{format(credit_card.year, :two_digits)}"
|
163
251
|
end
|
164
|
-
|
252
|
+
|
165
253
|
def parse(body)
|
166
254
|
xml = REXML::Document.new(body)
|
167
255
|
|
168
256
|
response = {}
|
169
|
-
|
257
|
+
|
170
258
|
xml.root.elements.to_a.each do |node|
|
171
259
|
parse_element(response, node)
|
172
260
|
end
|
@@ -181,13 +269,12 @@ module ActiveMerchant #:nodoc:
|
|
181
269
|
response[node.name.underscore.to_sym] = node.text
|
182
270
|
end
|
183
271
|
end
|
184
|
-
|
272
|
+
|
185
273
|
# YYYYDDMMHHNNSSKKK000sOOO
|
186
274
|
def generate_timestamp
|
187
275
|
time = Time.now.utc
|
188
276
|
time.strftime("%Y%d%m%H%M%S#{time.usec}+000")
|
189
|
-
end
|
277
|
+
end
|
190
278
|
end
|
191
279
|
end
|
192
280
|
end
|
193
|
-
|