activemerchant 1.28.0 → 1.29.1
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.
- data/CHANGELOG +41 -0
- data/CONTRIBUTORS +12 -0
- data/README.md +6 -0
- data/lib/active_merchant/billing/gateway.rb +2 -1
- data/lib/active_merchant/billing/gateways/authorize_net.rb +3 -2
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +77 -78
- data/lib/active_merchant/billing/gateways/balanced.rb +0 -1
- data/lib/active_merchant/billing/gateways/banwire.rb +1 -2
- data/lib/active_merchant/billing/gateways/barclays_epdq.rb +19 -20
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +35 -36
- data/lib/active_merchant/billing/gateways/blue_pay.rb +135 -140
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +12 -4
- data/lib/active_merchant/billing/gateways/card_stream.rb +54 -59
- data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -1
- data/lib/active_merchant/billing/gateways/cyber_source.rb +19 -14
- data/lib/active_merchant/billing/gateways/data_cash.rb +106 -112
- data/lib/active_merchant/billing/gateways/efsnet.rb +29 -34
- data/lib/active_merchant/billing/gateways/elavon.rb +7 -1
- data/lib/active_merchant/billing/gateways/epay.rb +0 -1
- data/lib/active_merchant/billing/gateways/eway.rb +88 -93
- data/lib/active_merchant/billing/gateways/eway_managed.rb +47 -51
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +300 -0
- data/lib/active_merchant/billing/gateways/exact.rb +45 -54
- data/lib/active_merchant/billing/gateways/federated_canada.rb +3 -4
- data/lib/active_merchant/billing/gateways/first_pay.rb +37 -38
- data/lib/active_merchant/billing/gateways/garanti.rb +1 -2
- data/lib/active_merchant/billing/gateways/hdfc.rb +207 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +5 -8
- data/lib/active_merchant/billing/gateways/inspire.rb +52 -52
- data/lib/active_merchant/billing/gateways/instapay.rb +10 -11
- data/lib/active_merchant/billing/gateways/iridium.rb +38 -39
- data/lib/active_merchant/billing/gateways/itransact.rb +7 -9
- data/lib/active_merchant/billing/gateways/jetpay.rb +45 -46
- data/lib/active_merchant/billing/gateways/linkpoint.rb +104 -108
- data/lib/active_merchant/billing/gateways/litle.rb +1 -5
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +153 -155
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +49 -50
- data/lib/active_merchant/billing/gateways/mercury.rb +272 -0
- data/lib/active_merchant/billing/gateways/metrics_global.rb +9 -10
- data/lib/active_merchant/billing/gateways/migs.rb +5 -3
- data/lib/active_merchant/billing/gateways/modern_payments.rb +6 -7
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +40 -41
- data/lib/active_merchant/billing/gateways/moneris.rb +46 -50
- data/lib/active_merchant/billing/gateways/moneris_us.rb +52 -55
- data/lib/active_merchant/billing/gateways/nab_transact.rb +0 -5
- data/lib/active_merchant/billing/gateways/net_registry.rb +20 -21
- data/lib/active_merchant/billing/gateways/netaxept.rb +30 -36
- data/lib/active_merchant/billing/gateways/netbilling.rb +2 -2
- data/lib/active_merchant/billing/gateways/ogone.rb +0 -5
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +1 -6
- data/lib/active_merchant/billing/gateways/orbital/avs_result.rb +93 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +25 -21
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +1 -6
- data/lib/active_merchant/billing/gateways/pay_junction.rb +62 -63
- data/lib/active_merchant/billing/gateways/pay_secure.rb +29 -30
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +0 -5
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +33 -38
- data/lib/active_merchant/billing/gateways/payment_express.rb +48 -51
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +7 -11
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +7 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +3 -0
- data/lib/active_merchant/billing/gateways/paystation.rb +62 -64
- data/lib/active_merchant/billing/gateways/payway.rb +2 -9
- data/lib/active_merchant/billing/gateways/plugnpay.rb +0 -1
- data/lib/active_merchant/billing/gateways/psigate.rb +102 -94
- data/lib/active_merchant/billing/gateways/psl_card.rb +66 -67
- data/lib/active_merchant/billing/gateways/qbms.rb +0 -6
- data/lib/active_merchant/billing/gateways/quantum.rb +2 -8
- data/lib/active_merchant/billing/gateways/quickpay.rb +2 -3
- data/lib/active_merchant/billing/gateways/realex.rb +6 -16
- data/lib/active_merchant/billing/gateways/redsys.rb +394 -0
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +25 -26
- data/lib/active_merchant/billing/gateways/sage.rb +15 -16
- data/lib/active_merchant/billing/gateways/sage_pay.rb +51 -56
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +1 -2
- data/lib/active_merchant/billing/gateways/samurai.rb +1 -4
- data/lib/active_merchant/billing/gateways/secure_net.rb +0 -1
- data/lib/active_merchant/billing/gateways/secure_pay.rb +5 -8
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +0 -5
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +17 -18
- data/lib/active_merchant/billing/gateways/skip_jack.rb +29 -34
- data/lib/active_merchant/billing/gateways/smart_ps.rb +55 -56
- data/lib/active_merchant/billing/gateways/stripe.rb +8 -3
- data/lib/active_merchant/billing/gateways/trans_first.rb +28 -29
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +85 -87
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +27 -28
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +0 -5
- data/lib/active_merchant/billing/gateways/verifi.rb +86 -87
- data/lib/active_merchant/billing/gateways/viaklix.rb +42 -47
- data/lib/active_merchant/billing/gateways/vindicia.rb +30 -28
- data/lib/active_merchant/billing/gateways/webpay.rb +45 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +0 -6
- data/lib/active_merchant/billing/gateways/worldpay.rb +4 -9
- data/lib/active_merchant/billing/gateways.rb +6 -7
- data/lib/active_merchant/billing/integrations/a1agregator/helper.rb +31 -0
- data/lib/active_merchant/billing/integrations/a1agregator/notification.rb +186 -0
- data/lib/active_merchant/billing/integrations/a1agregator/status.rb +38 -0
- data/lib/active_merchant/billing/integrations/a1agregator.rb +26 -0
- data/lib/active_merchant/billing/integrations/liqpay/helper.rb +43 -0
- data/lib/active_merchant/billing/integrations/liqpay/notification.rb +89 -0
- data/lib/active_merchant/billing/integrations/liqpay/return.rb +83 -0
- data/lib/active_merchant/billing/integrations/liqpay.rb +30 -0
- data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +17 -1
- data/lib/active_merchant/billing/integrations/notification.rb +4 -0
- data/lib/active_merchant/billing/integrations/pay_fast/common.rb +42 -0
- data/lib/active_merchant/billing/integrations/pay_fast/helper.rb +50 -0
- data/lib/active_merchant/billing/integrations/pay_fast/notification.rb +134 -0
- data/lib/active_merchant/billing/integrations/pay_fast/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/pay_fast.rb +70 -0
- data/lib/active_merchant/billing/integrations/paypal/notification.rb +64 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +10 -7
- data/lib/active_merchant/billing/integrations/webmoney/notification.rb +12 -0
- data/lib/active_merchant/billing/response.rb +17 -4
- data/lib/active_merchant/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +46 -27
- metadata.gz.sig +0 -0
|
@@ -2,29 +2,29 @@ require 'rexml/document'
|
|
|
2
2
|
|
|
3
3
|
module ActiveMerchant #:nodoc:
|
|
4
4
|
module Billing #:nodoc:
|
|
5
|
-
|
|
6
|
-
# In NZ DPS supports ANZ, Westpac, National Bank, ASB and BNZ.
|
|
7
|
-
# In Australia DPS supports ANZ, NAB, Westpac, CBA, St George and Bank of South Australia.
|
|
5
|
+
|
|
6
|
+
# In NZ DPS supports ANZ, Westpac, National Bank, ASB and BNZ.
|
|
7
|
+
# In Australia DPS supports ANZ, NAB, Westpac, CBA, St George and Bank of South Australia.
|
|
8
8
|
# The Maybank in Malaysia is supported and the Citibank for Singapore.
|
|
9
9
|
class PaymentExpressGateway < Gateway
|
|
10
10
|
self.default_currency = 'NZD'
|
|
11
|
-
# PS supports all major credit cards; Visa, Mastercard, Amex, Diners, BankCard & JCB.
|
|
12
|
-
# Various white label cards can be accepted as well; Farmers, AirNZCard and Elders etc.
|
|
11
|
+
# PS supports all major credit cards; Visa, Mastercard, Amex, Diners, BankCard & JCB.
|
|
12
|
+
# Various white label cards can be accepted as well; Farmers, AirNZCard and Elders etc.
|
|
13
13
|
# Please note that not all acquirers and Eftpos networks can support some of these card types.
|
|
14
14
|
# VISA, Mastercard, Diners Club and Farmers cards are supported
|
|
15
15
|
#
|
|
16
16
|
# However, regular accounts with DPS only support VISA and Mastercard
|
|
17
17
|
self.supported_cardtypes = [ :visa, :master, :american_express, :diners_club, :jcb ]
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
self.supported_countries = %w[ AU MY NZ SG ZA GB US ]
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
self.homepage_url = 'http://www.paymentexpress.com/'
|
|
22
22
|
self.display_name = 'PaymentExpress'
|
|
23
23
|
|
|
24
24
|
self.live_url = self.test_url = 'https://sec.paymentexpress.com/pxpost.aspx'
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
APPROVED = '1'
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
TRANSACTIONS = {
|
|
29
29
|
:purchase => 'Purchase',
|
|
30
30
|
:credit => 'Refund',
|
|
@@ -32,7 +32,7 @@ module ActiveMerchant #:nodoc:
|
|
|
32
32
|
:capture => 'Complete',
|
|
33
33
|
:validate => 'Validate'
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
# We require the DPS gateway username and password when the object is created.
|
|
37
37
|
#
|
|
38
38
|
# The PaymentExpress gateway also supports a :use_custom_payment_token boolean option.
|
|
@@ -40,25 +40,22 @@ module ActiveMerchant #:nodoc:
|
|
|
40
40
|
# then the token will be sent as the DPS specified "DpsBillingId". This is per the documentation at
|
|
41
41
|
# http://www.paymentexpress.com/technical_resources/ecommerce_nonhosted/pxpost.html#Tokenbilling
|
|
42
42
|
def initialize(options = {})
|
|
43
|
-
# A DPS username and password must exist
|
|
44
43
|
requires!(options, :login, :password)
|
|
45
|
-
# Make the options an instance variable
|
|
46
|
-
@options = options
|
|
47
44
|
super
|
|
48
45
|
end
|
|
49
|
-
|
|
46
|
+
|
|
50
47
|
# Funds are transferred immediately.
|
|
51
48
|
#
|
|
52
49
|
# `payment_source` can be a usual ActiveMerchant credit_card object, or can also
|
|
53
|
-
# be a string of the `DpsBillingId` or `BillingId` which can be gotten through the
|
|
50
|
+
# be a string of the `DpsBillingId` or `BillingId` which can be gotten through the
|
|
54
51
|
# store method. If you are using a `BillingId` instead of `DpsBillingId` you must
|
|
55
52
|
# also set the instance method `#use_billing_id_for_token` to true, see the `#store`
|
|
56
53
|
# method for an example of how to do this.
|
|
57
54
|
def purchase(money, payment_source, options = {})
|
|
58
55
|
request = build_purchase_or_authorization_request(money, payment_source, options)
|
|
59
|
-
commit(:purchase, request)
|
|
56
|
+
commit(:purchase, request)
|
|
60
57
|
end
|
|
61
|
-
|
|
58
|
+
|
|
62
59
|
# NOTE: Perhaps in options we allow a transaction note to be inserted
|
|
63
60
|
# Verifies that funds are available for the requested card and amount and reserves the specified amount.
|
|
64
61
|
# See: http://www.paymentexpress.com/technical_resources/ecommerce_nonhosted/pxpost.html#Authcomplete
|
|
@@ -68,19 +65,19 @@ module ActiveMerchant #:nodoc:
|
|
|
68
65
|
request = build_purchase_or_authorization_request(money, payment_source, options)
|
|
69
66
|
commit(:authorization, request)
|
|
70
67
|
end
|
|
71
|
-
|
|
68
|
+
|
|
72
69
|
# Transfer pre-authorized funds immediately
|
|
73
70
|
# See: http://www.paymentexpress.com/technical_resources/ecommerce_nonhosted/pxpost.html#Authcomplete
|
|
74
71
|
def capture(money, identification, options = {})
|
|
75
|
-
request = build_capture_or_credit_request(money, identification, options)
|
|
72
|
+
request = build_capture_or_credit_request(money, identification, options)
|
|
76
73
|
commit(:capture, request)
|
|
77
74
|
end
|
|
78
|
-
|
|
75
|
+
|
|
79
76
|
# Refund funds to the card holder
|
|
80
77
|
def refund(money, identification, options = {})
|
|
81
78
|
requires!(options, :description)
|
|
82
|
-
|
|
83
|
-
request = build_capture_or_credit_request(money, identification, options)
|
|
79
|
+
|
|
80
|
+
request = build_capture_or_credit_request(money, identification, options)
|
|
84
81
|
commit(:credit, request)
|
|
85
82
|
end
|
|
86
83
|
|
|
@@ -88,9 +85,9 @@ module ActiveMerchant #:nodoc:
|
|
|
88
85
|
deprecated CREDIT_DEPRECATION_MESSAGE
|
|
89
86
|
refund(money, identification, options)
|
|
90
87
|
end
|
|
91
|
-
|
|
88
|
+
|
|
92
89
|
# Token Based Billing
|
|
93
|
-
#
|
|
90
|
+
#
|
|
94
91
|
# Instead of storing the credit card details locally, you can store them inside the
|
|
95
92
|
# Payment Express system and instead bill future transactions against a token.
|
|
96
93
|
#
|
|
@@ -102,7 +99,7 @@ module ActiveMerchant #:nodoc:
|
|
|
102
99
|
# initialization of your gateway object.
|
|
103
100
|
#
|
|
104
101
|
# To specify and use your own token, you need to do two things.
|
|
105
|
-
#
|
|
102
|
+
#
|
|
106
103
|
# Firstly, pass in a `:billing_id` as an option in the hash of this store method. No
|
|
107
104
|
# validation is done on this BillingId by PaymentExpress so you must ensure that it is unique.
|
|
108
105
|
#
|
|
@@ -124,37 +121,37 @@ module ActiveMerchant #:nodoc:
|
|
|
124
121
|
request = build_token_request(credit_card, options)
|
|
125
122
|
commit(:validate, request)
|
|
126
123
|
end
|
|
127
|
-
|
|
124
|
+
|
|
128
125
|
private
|
|
129
126
|
|
|
130
127
|
def use_custom_payment_token?
|
|
131
128
|
@options[:use_custom_payment_token]
|
|
132
129
|
end
|
|
133
|
-
|
|
130
|
+
|
|
134
131
|
def build_purchase_or_authorization_request(money, payment_source, options)
|
|
135
|
-
result = new_transaction
|
|
132
|
+
result = new_transaction
|
|
136
133
|
|
|
137
134
|
if payment_source.is_a?(String)
|
|
138
135
|
add_billing_token(result, payment_source)
|
|
139
136
|
else
|
|
140
137
|
add_credit_card(result, payment_source)
|
|
141
138
|
end
|
|
142
|
-
|
|
139
|
+
|
|
143
140
|
add_amount(result, money, options)
|
|
144
141
|
add_invoice(result, options)
|
|
145
142
|
add_address_verification_data(result, options)
|
|
146
143
|
result
|
|
147
144
|
end
|
|
148
|
-
|
|
145
|
+
|
|
149
146
|
def build_capture_or_credit_request(money, identification, options)
|
|
150
147
|
result = new_transaction
|
|
151
|
-
|
|
148
|
+
|
|
152
149
|
add_amount(result, money, options)
|
|
153
150
|
add_invoice(result, options)
|
|
154
151
|
add_reference(result, identification)
|
|
155
152
|
result
|
|
156
153
|
end
|
|
157
|
-
|
|
154
|
+
|
|
158
155
|
def build_token_request(credit_card, options)
|
|
159
156
|
result = new_transaction
|
|
160
157
|
add_credit_card(result, credit_card)
|
|
@@ -162,26 +159,26 @@ module ActiveMerchant #:nodoc:
|
|
|
162
159
|
add_token_request(result, options)
|
|
163
160
|
result
|
|
164
161
|
end
|
|
165
|
-
|
|
162
|
+
|
|
166
163
|
def add_credentials(xml)
|
|
167
164
|
xml.add_element("PostUsername").text = @options[:login]
|
|
168
165
|
xml.add_element("PostPassword").text = @options[:password]
|
|
169
166
|
end
|
|
170
|
-
|
|
167
|
+
|
|
171
168
|
def add_reference(xml, identification)
|
|
172
169
|
xml.add_element("DpsTxnRef").text = identification
|
|
173
170
|
end
|
|
174
|
-
|
|
171
|
+
|
|
175
172
|
def add_credit_card(xml, credit_card)
|
|
176
173
|
xml.add_element("CardHolderName").text = credit_card.name
|
|
177
174
|
xml.add_element("CardNumber").text = credit_card.number
|
|
178
175
|
xml.add_element("DateExpiry").text = format_date(credit_card.month, credit_card.year)
|
|
179
|
-
|
|
176
|
+
|
|
180
177
|
if credit_card.verification_value?
|
|
181
178
|
xml.add_element("Cvc2").text = credit_card.verification_value
|
|
182
179
|
xml.add_element("Cvc2Presence").text = "1"
|
|
183
180
|
end
|
|
184
|
-
|
|
181
|
+
|
|
185
182
|
if requires_start_date_or_issue_number?(credit_card)
|
|
186
183
|
xml.add_element("DateStart").text = format_date(credit_card.start_month, credit_card.start_year) unless credit_card.start_month.blank? || credit_card.start_year.blank?
|
|
187
184
|
xml.add_element("IssueNumber").text = credit_card.issue_number unless credit_card.issue_number.blank?
|
|
@@ -195,37 +192,37 @@ module ActiveMerchant #:nodoc:
|
|
|
195
192
|
xml.add_element("DpsBillingId").text = token
|
|
196
193
|
end
|
|
197
194
|
end
|
|
198
|
-
|
|
195
|
+
|
|
199
196
|
def add_token_request(xml, options)
|
|
200
197
|
xml.add_element("BillingId").text = options[:billing_id] if options[:billing_id]
|
|
201
198
|
xml.add_element("EnableAddBillCard").text = 1
|
|
202
199
|
end
|
|
203
|
-
|
|
200
|
+
|
|
204
201
|
def add_amount(xml, money, options)
|
|
205
202
|
xml.add_element("Amount").text = amount(money)
|
|
206
203
|
xml.add_element("InputCurrency").text = options[:currency] || currency(money)
|
|
207
204
|
end
|
|
208
|
-
|
|
205
|
+
|
|
209
206
|
def add_transaction_type(xml, action)
|
|
210
207
|
xml.add_element("TxnType").text = TRANSACTIONS[action]
|
|
211
208
|
end
|
|
212
|
-
|
|
209
|
+
|
|
213
210
|
def add_invoice(xml, options)
|
|
214
211
|
xml.add_element("TxnId").text = options[:order_id].to_s.slice(0, 16) unless options[:order_id].blank?
|
|
215
212
|
xml.add_element("MerchantReference").text = options[:description] unless options[:description].blank?
|
|
216
213
|
end
|
|
217
|
-
|
|
214
|
+
|
|
218
215
|
def add_address_verification_data(xml, options)
|
|
219
216
|
address = options[:billing_address] || options[:address]
|
|
220
217
|
return if address.nil?
|
|
221
|
-
|
|
218
|
+
|
|
222
219
|
xml.add_element("EnableAvsData").text = 1
|
|
223
220
|
xml.add_element("AvsAction").text = 1
|
|
224
|
-
|
|
221
|
+
|
|
225
222
|
xml.add_element("AvsStreetAddress").text = address[:address1]
|
|
226
223
|
xml.add_element("AvsPostCode").text = address[:zip]
|
|
227
224
|
end
|
|
228
|
-
|
|
225
|
+
|
|
229
226
|
def new_transaction
|
|
230
227
|
REXML::Document.new.add_element("Txn")
|
|
231
228
|
end
|
|
@@ -234,10 +231,10 @@ module ActiveMerchant #:nodoc:
|
|
|
234
231
|
def commit(action, request)
|
|
235
232
|
add_credentials(request)
|
|
236
233
|
add_transaction_type(request, action)
|
|
237
|
-
|
|
234
|
+
|
|
238
235
|
# Parse the XML response
|
|
239
236
|
response = parse( ssl_post(self.live_url, request.to_s) )
|
|
240
|
-
|
|
237
|
+
|
|
241
238
|
# Return a response
|
|
242
239
|
PaymentExpressResponse.new(response[:success] == APPROVED, response[:card_holder_help_text], response,
|
|
243
240
|
:test => response[:test_mode] == '1',
|
|
@@ -249,7 +246,7 @@ module ActiveMerchant #:nodoc:
|
|
|
249
246
|
def parse(xml_string)
|
|
250
247
|
response = {}
|
|
251
248
|
|
|
252
|
-
xml = REXML::Document.new(xml_string)
|
|
249
|
+
xml = REXML::Document.new(xml_string)
|
|
253
250
|
|
|
254
251
|
# Gather all root elements such as HelpText
|
|
255
252
|
xml.elements.each('Txn/*') do |element|
|
|
@@ -262,15 +259,15 @@ module ActiveMerchant #:nodoc:
|
|
|
262
259
|
xml.elements.each('Txn/Transaction/*') do |element|
|
|
263
260
|
response[element.name.underscore.to_sym] = element.text
|
|
264
261
|
end
|
|
265
|
-
|
|
262
|
+
|
|
266
263
|
response
|
|
267
264
|
end
|
|
268
|
-
|
|
265
|
+
|
|
269
266
|
def format_date(month, year)
|
|
270
267
|
"#{format(month, :two_digits)}#{format(year, :two_digits)}"
|
|
271
268
|
end
|
|
272
269
|
end
|
|
273
|
-
|
|
270
|
+
|
|
274
271
|
class PaymentExpressResponse < Response
|
|
275
272
|
# add a method to response so we can easily get the token
|
|
276
273
|
# for Validate transactions
|
|
@@ -65,22 +65,18 @@ module ActiveMerchant #:nodoc:
|
|
|
65
65
|
requires!(options, :login, :password)
|
|
66
66
|
|
|
67
67
|
headers = {'X-PP-AUTHORIZATION' => options.delete(:auth_signature), 'X-PAYPAL-MESSAGE-PROTOCOL' => 'SOAP11'} if options[:auth_signature]
|
|
68
|
-
|
|
68
|
+
options = {
|
|
69
69
|
:pem => pem_file,
|
|
70
70
|
:signature => signature,
|
|
71
71
|
:headers => headers || {}
|
|
72
72
|
}.update(options)
|
|
73
73
|
|
|
74
74
|
|
|
75
|
-
if
|
|
75
|
+
if options[:pem].blank? && options[:signature].blank?
|
|
76
76
|
raise ArgumentError, "An API Certificate or API Signature is required to make requests to PayPal"
|
|
77
77
|
end
|
|
78
78
|
|
|
79
|
-
super
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def test?
|
|
83
|
-
@options[:test] || Base.gateway_mode == :test
|
|
79
|
+
super(options)
|
|
84
80
|
end
|
|
85
81
|
|
|
86
82
|
def reauthorize(money, authorization, options = {})
|
|
@@ -509,10 +505,10 @@ module ActiveMerchant #:nodoc:
|
|
|
509
505
|
def add_credentials(xml)
|
|
510
506
|
xml.tag! 'RequesterCredentials', CREDENTIALS_NAMESPACES do
|
|
511
507
|
xml.tag! 'n1:Credentials' do
|
|
512
|
-
xml.tag! 'Username', @options[:login]
|
|
513
|
-
xml.tag! 'Password', @options[:password]
|
|
514
|
-
xml.tag! 'Subject', @options[:subject]
|
|
515
|
-
xml.tag! 'Signature', @options[:signature] unless @options[:signature].blank?
|
|
508
|
+
xml.tag! 'n1:Username', @options[:login]
|
|
509
|
+
xml.tag! 'n1:Password', @options[:password]
|
|
510
|
+
xml.tag! 'n1:Subject', @options[:subject]
|
|
511
|
+
xml.tag! 'n1:Signature', @options[:signature] unless @options[:signature].blank?
|
|
516
512
|
end
|
|
517
513
|
end
|
|
518
514
|
end
|
|
@@ -44,6 +44,13 @@ module ActiveMerchant #:nodoc:
|
|
|
44
44
|
'phone' => (contact_phone || address['Phone'])
|
|
45
45
|
}
|
|
46
46
|
end
|
|
47
|
+
|
|
48
|
+
def shipping
|
|
49
|
+
shipping = (@params['UserSelectedOptions']||{})
|
|
50
|
+
{ 'amount' => shipping['ShippingOptionAmount'],
|
|
51
|
+
'name' => shipping['ShippingOptionName']
|
|
52
|
+
}
|
|
53
|
+
end
|
|
47
54
|
end
|
|
48
55
|
end
|
|
49
56
|
end
|
|
@@ -202,6 +202,9 @@ commit 'ManageRecurringPaymentsProfileStatus', build_manage_profile_request(prof
|
|
|
202
202
|
if options.has_key?(:start_date)
|
|
203
203
|
xml.tag! 'n2:BillingStartDate', (options[:start_date].is_a?(Date) ? options[:start_date].to_time : options[:start_date]).utc.iso8601
|
|
204
204
|
end
|
|
205
|
+
if options.has_key?(:outstanding_balance)
|
|
206
|
+
xml.tag! 'n2:OutstandingBalance', amount(options[:outstanding_balance]), 'currencyID' => options[:currency] || 'USD'
|
|
207
|
+
end
|
|
205
208
|
end
|
|
206
209
|
end
|
|
207
210
|
end
|
|
@@ -1,97 +1,95 @@
|
|
|
1
1
|
module ActiveMerchant #:nodoc:
|
|
2
2
|
module Billing #:nodoc:
|
|
3
3
|
class PaystationGateway < Gateway
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
self.live_url = self.test_url = "https://www.paystation.co.nz/direct/paystation.dll"
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
# an "error code" of "0" means "No error - transaction successful"
|
|
8
8
|
SUCCESSFUL_RESPONSE_CODE = '0'
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
# an "error code" of "34" means "Future Payment Stored OK"
|
|
11
11
|
SUCCESSFUL_FUTURE_PAYMENT = '34'
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
# TODO: check this with paystation
|
|
14
14
|
self.supported_countries = ['NZ']
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
# TODO: check this with paystation (amex and diners need to be enabled)
|
|
17
17
|
self.supported_cardtypes = [:visa, :master, :american_express, :diners_club ]
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
self.homepage_url = 'http://paystation.co.nz'
|
|
20
20
|
self.display_name = 'Paystation'
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
self.default_currency = 'NZD'
|
|
23
23
|
self.money_format = :cents
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
def initialize(options = {})
|
|
26
|
-
# You need to pass your Paystation ID and Gateway ID
|
|
27
26
|
requires!(options, :paystation_id, :gateway_id)
|
|
28
|
-
@options = options
|
|
29
27
|
super
|
|
30
|
-
end
|
|
31
|
-
|
|
28
|
+
end
|
|
29
|
+
|
|
32
30
|
def authorize(money, credit_card, options = {})
|
|
33
31
|
post = new_request
|
|
34
|
-
|
|
32
|
+
|
|
35
33
|
add_invoice(post, options)
|
|
36
34
|
add_amount(post, money, options)
|
|
37
|
-
|
|
35
|
+
|
|
38
36
|
add_credit_card(post, credit_card)
|
|
39
|
-
|
|
37
|
+
|
|
40
38
|
add_authorize_flag(post, options)
|
|
41
|
-
|
|
39
|
+
|
|
42
40
|
commit(post)
|
|
43
41
|
end
|
|
44
|
-
|
|
42
|
+
|
|
45
43
|
def capture(money, authorization_token, options = {})
|
|
46
44
|
post = new_request
|
|
47
|
-
|
|
45
|
+
|
|
48
46
|
add_invoice(post, options)
|
|
49
47
|
add_amount(post, money, options)
|
|
50
|
-
|
|
48
|
+
|
|
51
49
|
add_authorization_token(post, authorization_token, options[:credit_card_verification])
|
|
52
|
-
|
|
50
|
+
|
|
53
51
|
commit(post)
|
|
54
52
|
end
|
|
55
|
-
|
|
53
|
+
|
|
56
54
|
def purchase(money, payment_source, options = {})
|
|
57
55
|
post = new_request
|
|
58
|
-
|
|
56
|
+
|
|
59
57
|
add_invoice(post, options)
|
|
60
58
|
add_amount(post, money, options)
|
|
61
|
-
|
|
59
|
+
|
|
62
60
|
if payment_source.is_a?(String)
|
|
63
|
-
add_token(post, payment_source)
|
|
61
|
+
add_token(post, payment_source)
|
|
64
62
|
else
|
|
65
63
|
add_credit_card(post, payment_source)
|
|
66
64
|
end
|
|
67
|
-
|
|
65
|
+
|
|
68
66
|
add_customer_data(post, options) if options.has_key?(:customer)
|
|
69
|
-
|
|
67
|
+
|
|
70
68
|
commit(post)
|
|
71
|
-
end
|
|
72
|
-
|
|
69
|
+
end
|
|
70
|
+
|
|
73
71
|
def store(credit_card, options = {})
|
|
74
72
|
post = new_request
|
|
75
|
-
|
|
73
|
+
|
|
76
74
|
add_invoice(post, options)
|
|
77
75
|
add_credit_card(post, credit_card)
|
|
78
76
|
store_credit_card(post, options)
|
|
79
|
-
|
|
77
|
+
|
|
80
78
|
commit(post)
|
|
81
79
|
end
|
|
82
|
-
|
|
83
|
-
private
|
|
84
|
-
|
|
80
|
+
|
|
81
|
+
private
|
|
82
|
+
|
|
85
83
|
def new_request
|
|
86
|
-
{
|
|
84
|
+
{
|
|
87
85
|
:pi => @options[:paystation_id], # paystation account id
|
|
88
86
|
:gi => @options[:gateway_id], # paystation gateway id
|
|
89
87
|
"2p" => "t", # two-party transaction type
|
|
90
88
|
:nr => "t", # -- redirect??
|
|
91
89
|
:df => "yymm" # date format: optional sometimes, required others
|
|
92
|
-
}
|
|
90
|
+
}
|
|
93
91
|
end
|
|
94
|
-
|
|
92
|
+
|
|
95
93
|
def add_customer_data(post, options)
|
|
96
94
|
post[:mc] = options[:customer]
|
|
97
95
|
end
|
|
@@ -103,78 +101,78 @@ module ActiveMerchant #:nodoc:
|
|
|
103
101
|
post[:mo] = options[:invoice] # "Order Details", displayed in Paystation Admin
|
|
104
102
|
post[:mr] = options[:description] # "Merchant Reference Code", seen from Paystation Admin
|
|
105
103
|
end
|
|
106
|
-
|
|
107
|
-
def add_credit_card(post, credit_card)
|
|
108
|
-
|
|
104
|
+
|
|
105
|
+
def add_credit_card(post, credit_card)
|
|
106
|
+
|
|
109
107
|
post[:cn] = credit_card.number
|
|
110
108
|
post[:ct] = credit_card.brand
|
|
111
109
|
post[:ex] = format_date(credit_card.month, credit_card.year)
|
|
112
110
|
post[:cc] = credit_card.verification_value if credit_card.verification_value?
|
|
113
|
-
|
|
111
|
+
|
|
114
112
|
end
|
|
115
|
-
|
|
113
|
+
|
|
116
114
|
# bill a token (stored via "store") rather than a Credit Card
|
|
117
115
|
def add_token(post, token)
|
|
118
116
|
post[:fp] = "t" # turn on "future payments" - what paystation calls Token Billing
|
|
119
117
|
post[:ft] = token
|
|
120
118
|
end
|
|
121
|
-
|
|
119
|
+
|
|
122
120
|
def store_credit_card(post, options)
|
|
123
|
-
|
|
121
|
+
|
|
124
122
|
post[:fp] = "t" # turn on "future payments" - what paystation calls Token Billing
|
|
125
123
|
post[:fs] = "t" # tells paystation to store right now, not bill
|
|
126
124
|
post[:ft] = options[:token] if options[:token] # specify a token to use that, or let Paystation generate one
|
|
127
|
-
|
|
125
|
+
|
|
128
126
|
end
|
|
129
|
-
|
|
127
|
+
|
|
130
128
|
def add_authorize_flag(post, options)
|
|
131
129
|
post[:pa] = "t" # tells Paystation that this is a pre-auth authorisation payment (account must be in pre-auth mode)
|
|
132
130
|
end
|
|
133
|
-
|
|
131
|
+
|
|
134
132
|
def add_authorization_token(post, auth_token, verification_value = nil)
|
|
135
133
|
post[:cp] = "t" # Capture Payment flag – tells Paystation this transaction should be treated as a capture payment
|
|
136
134
|
post[:cx] = auth_token
|
|
137
135
|
post[:cc] = verification_value
|
|
138
136
|
end
|
|
139
|
-
|
|
137
|
+
|
|
140
138
|
def add_amount(post, money, options)
|
|
141
|
-
|
|
139
|
+
|
|
142
140
|
post[:am] = amount(money)
|
|
143
141
|
post[:cu] = options[:currency] || currency(money)
|
|
144
|
-
|
|
142
|
+
|
|
145
143
|
end
|
|
146
|
-
|
|
144
|
+
|
|
147
145
|
def parse(xml_response)
|
|
148
146
|
response = {}
|
|
149
|
-
|
|
147
|
+
|
|
150
148
|
xml = REXML::Document.new(xml_response)
|
|
151
|
-
|
|
149
|
+
|
|
152
150
|
# for normal payments, the root node is <Response>
|
|
153
151
|
# for "future payments", it's <PaystationFuturePaymentResponse>
|
|
154
152
|
xml.elements.each("#{xml.root.name}/*") do |element|
|
|
155
153
|
response[element.name.underscore.to_sym] = element.text
|
|
156
154
|
end
|
|
157
|
-
|
|
155
|
+
|
|
158
156
|
response
|
|
159
|
-
end
|
|
160
|
-
|
|
157
|
+
end
|
|
158
|
+
|
|
161
159
|
def commit(post)
|
|
162
|
-
|
|
160
|
+
|
|
163
161
|
post[:tm] = "T" if test? # test mode
|
|
164
|
-
|
|
162
|
+
|
|
165
163
|
pstn_prefix_params = post.collect { |key, value| "pstn_#{key}=#{CGI.escape(value.to_s)}" }.join("&")
|
|
166
|
-
|
|
164
|
+
|
|
167
165
|
# need include paystation param as "initiator flag for payment engine"
|
|
168
166
|
data = ssl_post(self.live_url, "#{pstn_prefix_params}&paystation=_empty")
|
|
169
167
|
response = parse(data)
|
|
170
168
|
message = message_from(response)
|
|
171
|
-
|
|
172
|
-
PaystationResponse.new(success?(response), message, response,
|
|
169
|
+
|
|
170
|
+
PaystationResponse.new(success?(response), message, response,
|
|
173
171
|
:test => (response[:tm] && response[:tm].downcase == "t"),
|
|
174
172
|
:authorization => response[:paystation_transaction_id]
|
|
175
173
|
)
|
|
176
174
|
end
|
|
177
|
-
|
|
175
|
+
|
|
178
176
|
def success?(response)
|
|
179
177
|
(response[:ec] == SUCCESSFUL_RESPONSE_CODE) || (response[:ec] == SUCCESSFUL_FUTURE_PAYMENT)
|
|
180
178
|
end
|
|
@@ -182,13 +180,13 @@ module ActiveMerchant #:nodoc:
|
|
|
182
180
|
def message_from(response)
|
|
183
181
|
response[:em]
|
|
184
182
|
end
|
|
185
|
-
|
|
183
|
+
|
|
186
184
|
def format_date(month, year)
|
|
187
185
|
"#{format(year, :two_digits)}#{format(month, :two_digits)}"
|
|
188
186
|
end
|
|
189
|
-
|
|
187
|
+
|
|
190
188
|
end
|
|
191
|
-
|
|
189
|
+
|
|
192
190
|
class PaystationResponse < Response
|
|
193
191
|
# add a method to response so we can easily get the token
|
|
194
192
|
# for Validate transactions
|
|
@@ -86,13 +86,10 @@ module ActiveMerchant
|
|
|
86
86
|
def initialize(options={})
|
|
87
87
|
@options = options
|
|
88
88
|
|
|
89
|
-
options[:merchant] ||= 'TEST' if test?
|
|
90
|
-
|
|
89
|
+
@options[:merchant] ||= 'TEST' if test?
|
|
91
90
|
requires!(options, :username, :password, :merchant, :pem)
|
|
92
91
|
|
|
93
|
-
@options[:eci]
|
|
94
|
-
|
|
95
|
-
super
|
|
92
|
+
@options[:eci] ||= 'SSL'
|
|
96
93
|
end
|
|
97
94
|
|
|
98
95
|
def authorize(amount, payment_method, options={})
|
|
@@ -205,10 +202,6 @@ module ActiveMerchant
|
|
|
205
202
|
rescue ActiveMerchant::ClientCertificateError
|
|
206
203
|
return Response.new(false, "Invalid certificate", {}, :test => test?)
|
|
207
204
|
end
|
|
208
|
-
|
|
209
|
-
def test?
|
|
210
|
-
(@options[:test] || super)
|
|
211
|
-
end
|
|
212
205
|
end
|
|
213
206
|
end
|
|
214
207
|
end
|