activemerchant 1.133.0 → 1.137.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +240 -0
- data/lib/active_merchant/billing/check.rb +2 -2
- data/lib/active_merchant/billing/compatibility.rb +4 -4
- data/lib/active_merchant/billing/credit_card.rb +11 -8
- data/lib/active_merchant/billing/credit_card_formatting.rb +4 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +59 -6
- data/lib/active_merchant/billing/gateway.rb +9 -0
- data/lib/active_merchant/billing/gateways/adyen.rb +162 -43
- data/lib/active_merchant/billing/gateways/airwallex.rb +26 -12
- data/lib/active_merchant/billing/gateways/alelo.rb +23 -5
- data/lib/active_merchant/billing/gateways/authorize_net.rb +43 -35
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +10 -6
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +1 -3
- data/lib/active_merchant/billing/gateways/axcessms.rb +6 -2
- data/lib/active_merchant/billing/gateways/banwire.rb +4 -2
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +7 -3
- data/lib/active_merchant/billing/gateways/blue_pay.rb +13 -5
- data/lib/active_merchant/billing/gateways/blue_snap.rb +5 -5
- data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +65 -20
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +226 -73
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +1 -1
- data/lib/active_merchant/billing/gateways/card_connect.rb +5 -2
- data/lib/active_merchant/billing/gateways/card_stream.rb +4 -6
- data/lib/active_merchant/billing/gateways/cashnet.rb +1 -1
- data/lib/active_merchant/billing/gateways/cecabank/cecabank_common.rb +36 -0
- data/lib/active_merchant/billing/gateways/cecabank/cecabank_json.rb +316 -0
- data/lib/active_merchant/billing/gateways/cecabank/cecabank_xml.rb +220 -0
- data/lib/active_merchant/billing/gateways/cecabank.rb +7 -240
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +238 -34
- data/lib/active_merchant/billing/gateways/commerce_hub.rb +63 -6
- data/lib/active_merchant/billing/gateways/credorax.rb +3 -5
- data/lib/active_merchant/billing/gateways/cyber_source.rb +185 -47
- data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +102 -58
- data/lib/active_merchant/billing/gateways/d_local.rb +26 -15
- data/lib/active_merchant/billing/gateways/data_cash.rb +21 -17
- data/lib/active_merchant/billing/gateways/datatrans.rb +279 -0
- data/lib/active_merchant/billing/gateways/decidir.rb +53 -18
- data/lib/active_merchant/billing/gateways/decidir_plus.rb +4 -1
- data/lib/active_merchant/billing/gateways/deepstack.rb +382 -0
- data/lib/active_merchant/billing/gateways/ebanx.rb +40 -36
- data/lib/active_merchant/billing/gateways/efsnet.rb +6 -2
- data/lib/active_merchant/billing/gateways/elavon.rb +99 -33
- data/lib/active_merchant/billing/gateways/element.rb +36 -7
- data/lib/active_merchant/billing/gateways/epay.rb +6 -2
- data/lib/active_merchant/billing/gateways/evo_ca.rb +6 -2
- data/lib/active_merchant/billing/gateways/eway.rb +4 -2
- data/lib/active_merchant/billing/gateways/eway_managed.rb +6 -2
- data/lib/active_merchant/billing/gateways/exact.rb +6 -2
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +31 -3
- data/lib/active_merchant/billing/gateways/federated_canada.rb +6 -2
- data/lib/active_merchant/billing/gateways/first_pay/first_pay_common.rb +15 -0
- data/lib/active_merchant/billing/gateways/first_pay/first_pay_json.rb +190 -0
- data/lib/active_merchant/billing/gateways/first_pay/first_pay_xml.rb +183 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +6 -172
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +6 -2
- data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +7 -3
- data/lib/active_merchant/billing/gateways/flex_charge.rb +347 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +4 -2
- data/lib/active_merchant/billing/gateways/global_collect.rb +45 -37
- data/lib/active_merchant/billing/gateways/hi_pay.rb +286 -0
- data/lib/active_merchant/billing/gateways/hps.rb +1 -1
- data/lib/active_merchant/billing/gateways/iats_payments.rb +7 -2
- data/lib/active_merchant/billing/gateways/inspire.rb +6 -4
- data/lib/active_merchant/billing/gateways/instapay.rb +7 -4
- data/lib/active_merchant/billing/gateways/ipg.rb +9 -5
- data/lib/active_merchant/billing/gateways/iridium.rb +15 -5
- data/lib/active_merchant/billing/gateways/itransact.rb +6 -2
- data/lib/active_merchant/billing/gateways/iveri.rb +3 -3
- data/lib/active_merchant/billing/gateways/ixopay.rb +2 -2
- data/lib/active_merchant/billing/gateways/jetpay.rb +4 -2
- data/lib/active_merchant/billing/gateways/jetpay_v2.rb +4 -2
- data/lib/active_merchant/billing/gateways/kushki.rb +72 -12
- data/lib/active_merchant/billing/gateways/linkpoint.rb +6 -2
- data/lib/active_merchant/billing/gateways/litle.rb +33 -50
- data/lib/active_merchant/billing/gateways/mastercard.rb +4 -4
- data/lib/active_merchant/billing/gateways/maxipago.rb +2 -2
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +8 -5
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +11 -4
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +11 -4
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +19 -3
- data/lib/active_merchant/billing/gateways/mercury.rb +6 -2
- data/lib/active_merchant/billing/gateways/metrics_global.rb +8 -6
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +1 -0
- data/lib/active_merchant/billing/gateways/migs.rb +6 -2
- data/lib/active_merchant/billing/gateways/mit.rb +8 -3
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +18 -10
- data/lib/active_merchant/billing/gateways/monei.rb +1 -1
- data/lib/active_merchant/billing/gateways/moneris.rb +9 -3
- data/lib/active_merchant/billing/gateways/money_movers.rb +6 -2
- data/lib/active_merchant/billing/gateways/nab_transact.rb +12 -4
- data/lib/active_merchant/billing/gateways/net_registry.rb +6 -2
- data/lib/active_merchant/billing/gateways/netbanx.rb +1 -3
- data/lib/active_merchant/billing/gateways/netbilling.rb +6 -2
- data/lib/active_merchant/billing/gateways/network_merchants.rb +6 -2
- data/lib/active_merchant/billing/gateways/nmi.rb +18 -6
- data/lib/active_merchant/billing/gateways/ogone.rb +6 -2
- data/lib/active_merchant/billing/gateways/openpay.rb +4 -2
- data/lib/active_merchant/billing/gateways/opp.rb +1 -2
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +6 -2
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +1 -3
- data/lib/active_merchant/billing/gateways/orbital.rb +83 -24
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +7 -4
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +6 -2
- data/lib/active_merchant/billing/gateways/pay_hub.rb +4 -2
- data/lib/active_merchant/billing/gateways/pay_junction.rb +6 -2
- data/lib/active_merchant/billing/gateways/pay_secure.rb +6 -2
- data/lib/active_merchant/billing/gateways/pay_trace.rb +31 -18
- data/lib/active_merchant/billing/gateways/payeezy.rb +19 -8
- data/lib/active_merchant/billing/gateways/payex.rb +4 -2
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -1
- data/lib/active_merchant/billing/gateways/payflow.rb +1 -3
- data/lib/active_merchant/billing/gateways/payment_express.rb +8 -4
- data/lib/active_merchant/billing/gateways/paymentez.rb +23 -11
- data/lib/active_merchant/billing/gateways/paysafe.rb +12 -11
- data/lib/active_merchant/billing/gateways/payscout.rb +7 -4
- data/lib/active_merchant/billing/gateways/paystation.rb +7 -3
- data/lib/active_merchant/billing/gateways/payway.rb +6 -2
- data/lib/active_merchant/billing/gateways/payway_dot_com.rb +2 -2
- data/lib/active_merchant/billing/gateways/pin.rb +22 -4
- data/lib/active_merchant/billing/gateways/plexo.rb +49 -10
- data/lib/active_merchant/billing/gateways/plugnpay.rb +6 -2
- data/lib/active_merchant/billing/gateways/priority.rb +6 -5
- data/lib/active_merchant/billing/gateways/psigate.rb +6 -2
- data/lib/active_merchant/billing/gateways/psl_card.rb +6 -2
- data/lib/active_merchant/billing/gateways/qbms.rb +6 -2
- data/lib/active_merchant/billing/gateways/quantum.rb +6 -2
- data/lib/active_merchant/billing/gateways/quickbooks.rb +6 -5
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +7 -4
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +6 -2
- data/lib/active_merchant/billing/gateways/rapyd.rb +148 -46
- data/lib/active_merchant/billing/gateways/reach.rb +11 -4
- data/lib/active_merchant/billing/gateways/redsys.rb +2 -10
- data/lib/active_merchant/billing/gateways/redsys_rest.rb +507 -0
- data/lib/active_merchant/billing/gateways/s5.rb +3 -3
- data/lib/active_merchant/billing/gateways/safe_charge.rb +36 -16
- data/lib/active_merchant/billing/gateways/sage.rb +12 -4
- data/lib/active_merchant/billing/gateways/sage_pay.rb +79 -5
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +6 -2
- data/lib/active_merchant/billing/gateways/secure_net.rb +6 -2
- data/lib/active_merchant/billing/gateways/secure_pay.rb +8 -6
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +12 -4
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +6 -2
- data/lib/active_merchant/billing/gateways/securion_pay.rb +24 -10
- data/lib/active_merchant/billing/gateways/shift4.rb +17 -20
- data/lib/active_merchant/billing/gateways/shift4_v2.rb +117 -0
- data/lib/active_merchant/billing/gateways/simetrik.rb +17 -11
- data/lib/active_merchant/billing/gateways/skip_jack.rb +6 -2
- data/lib/active_merchant/billing/gateways/smart_ps.rb +7 -4
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +4 -2
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +2 -4
- data/lib/active_merchant/billing/gateways/stripe.rb +53 -21
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +199 -50
- data/lib/active_merchant/billing/gateways/sum_up.rb +223 -0
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +4 -2
- data/lib/active_merchant/billing/gateways/telr.rb +3 -4
- data/lib/active_merchant/billing/gateways/trans_first.rb +1 -2
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +8 -16
- data/lib/active_merchant/billing/gateways/transact_pro.rb +1 -1
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +6 -2
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +9 -8
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +6 -2
- data/lib/active_merchant/billing/gateways/vanco.rb +2 -4
- data/lib/active_merchant/billing/gateways/vantiv_express.rb +587 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +6 -2
- data/lib/active_merchant/billing/gateways/viaklix.rb +6 -2
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +2 -2
- data/lib/active_merchant/billing/gateways/vpos.rb +3 -3
- data/lib/active_merchant/billing/gateways/wirecard.rb +7 -3
- data/lib/active_merchant/billing/gateways/wompi.rb +5 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +140 -73
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +13 -10
- data/lib/active_merchant/billing/gateways/xpay.rb +242 -0
- data/lib/active_merchant/billing/network_tokenization_credit_card.rb +1 -1
- data/lib/active_merchant/billing/response.rb +2 -2
- data/lib/active_merchant/connection.rb +3 -17
- data/lib/active_merchant/country.rb +1 -0
- data/lib/active_merchant/errors.rb +10 -0
- data/lib/active_merchant/version.rb +1 -1
- data/lib/support/gateway_support.rb +2 -2
- data/lib/support/ssl_verify.rb +4 -4
- data/lib/support/ssl_version.rb +6 -6
- metadata +30 -9
@@ -0,0 +1,190 @@
|
|
1
|
+
require 'active_merchant/billing/gateways/first_pay/first_pay_common'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
class FirstPayJsonGateway < Gateway
|
6
|
+
include FirstPayCommon
|
7
|
+
|
8
|
+
ACTIONS = {
|
9
|
+
purchase: 'Sale',
|
10
|
+
authorize: 'Auth',
|
11
|
+
capture: 'Settle',
|
12
|
+
refund: 'Refund',
|
13
|
+
void: 'Void'
|
14
|
+
}.freeze
|
15
|
+
|
16
|
+
WALLET_TYPES = {
|
17
|
+
apple_pay: 'ApplePay',
|
18
|
+
google_pay: 'GooglePay'
|
19
|
+
}.freeze
|
20
|
+
|
21
|
+
self.test_url = 'https://secure-v.1stPaygateway.net/secure/RestGW/Gateway/Transaction/'
|
22
|
+
self.live_url = 'https://secure.1stPaygateway.net/secure/RestGW/Gateway/Transaction/'
|
23
|
+
|
24
|
+
# Creates a new FirstPayJsonGateway
|
25
|
+
#
|
26
|
+
# The gateway requires two values for connection to be passed
|
27
|
+
# in the +options+ hash.
|
28
|
+
#
|
29
|
+
# ==== Options
|
30
|
+
#
|
31
|
+
# * <tt>:merchant_key</tt> -- FirstPay's merchant_key (REQUIRED)
|
32
|
+
# * <tt>:processor_id</tt> -- FirstPay's processor_id or processorId (REQUIRED)
|
33
|
+
def initialize(options = {})
|
34
|
+
requires!(options, :merchant_key, :processor_id)
|
35
|
+
super
|
36
|
+
end
|
37
|
+
|
38
|
+
def purchase(money, payment, options = {})
|
39
|
+
post = {}
|
40
|
+
add_invoice(post, money, options)
|
41
|
+
add_payment(post, payment, options)
|
42
|
+
add_address(post, payment, options)
|
43
|
+
|
44
|
+
commit(:purchase, post)
|
45
|
+
end
|
46
|
+
|
47
|
+
def authorize(money, payment, options = {})
|
48
|
+
post = {}
|
49
|
+
add_invoice(post, money, options)
|
50
|
+
add_payment(post, payment, options)
|
51
|
+
add_address(post, payment, options)
|
52
|
+
|
53
|
+
commit(:authorize, post)
|
54
|
+
end
|
55
|
+
|
56
|
+
def capture(money, authorization, options = {})
|
57
|
+
post = {}
|
58
|
+
add_invoice(post, money, options)
|
59
|
+
add_reference(post, authorization)
|
60
|
+
|
61
|
+
commit(:capture, post)
|
62
|
+
end
|
63
|
+
|
64
|
+
def refund(money, authorization, options = {})
|
65
|
+
post = {}
|
66
|
+
add_invoice(post, money, options)
|
67
|
+
add_reference(post, authorization)
|
68
|
+
|
69
|
+
commit(:refund, post)
|
70
|
+
end
|
71
|
+
|
72
|
+
def void(authorization, options = {})
|
73
|
+
post = {}
|
74
|
+
add_reference(post, authorization)
|
75
|
+
|
76
|
+
commit(:void, post)
|
77
|
+
end
|
78
|
+
|
79
|
+
def scrub(transcript)
|
80
|
+
transcript.
|
81
|
+
gsub(%r(("processorId\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
|
82
|
+
gsub(%r(("merchantKey\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
|
83
|
+
gsub(%r(("cardNumber\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
|
84
|
+
gsub(%r(("paymentCryptogram\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
|
85
|
+
gsub(%r(("cvv\\?"\s*:\s*\\?)[^,]*)i, '\1[FILTERED]')
|
86
|
+
end
|
87
|
+
|
88
|
+
private
|
89
|
+
|
90
|
+
def add_address(post, creditcard, options)
|
91
|
+
if address = options[:billing_address] || options[:address]
|
92
|
+
post[:ownerName] = address[:name]
|
93
|
+
post[:ownerStreet] = address[:address1]
|
94
|
+
post[:ownerCity] = address[:city]
|
95
|
+
post[:ownerState] = address[:state]
|
96
|
+
post[:ownerZip] = address[:zip]
|
97
|
+
post[:ownerCountry] = address[:country]
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def add_invoice(post, money, options)
|
102
|
+
post[:orderId] = options[:order_id]
|
103
|
+
post[:transactionAmount] = amount(money)
|
104
|
+
end
|
105
|
+
|
106
|
+
def add_payment(post, payment, options)
|
107
|
+
post[:cardNumber] = payment.number
|
108
|
+
post[:cardExpMonth] = payment.month
|
109
|
+
post[:cardExpYear] = format(payment.year, :two_digits)
|
110
|
+
post[:cvv] = payment.verification_value
|
111
|
+
post[:recurring] = options[:recurring] if options[:recurring]
|
112
|
+
post[:recurringStartDate] = options[:recurring_start_date] if options[:recurring_start_date]
|
113
|
+
post[:recurringEndDate] = options[:recurring_end_date] if options[:recurring_end_date]
|
114
|
+
|
115
|
+
case payment
|
116
|
+
when NetworkTokenizationCreditCard
|
117
|
+
post[:walletType] = WALLET_TYPES[payment.source]
|
118
|
+
other_fields = post[:otherFields] = {}
|
119
|
+
other_fields[:paymentCryptogram] = payment.payment_cryptogram
|
120
|
+
other_fields[:eciIndicator] = payment.eci || '07'
|
121
|
+
when CreditCard
|
122
|
+
post[:cvv] = payment.verification_value
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def add_reference(post, authorization)
|
127
|
+
post[:refNumber] = authorization
|
128
|
+
end
|
129
|
+
|
130
|
+
def commit(action, parameters)
|
131
|
+
response = parse(api_request(base_url + ACTIONS[action], post_data(parameters)))
|
132
|
+
|
133
|
+
Response.new(
|
134
|
+
success_from(response),
|
135
|
+
message_from(response),
|
136
|
+
response,
|
137
|
+
authorization: authorization_from(response),
|
138
|
+
error_code: error_code_from(response),
|
139
|
+
test: test?
|
140
|
+
)
|
141
|
+
end
|
142
|
+
|
143
|
+
def base_url
|
144
|
+
test? ? self.test_url : self.live_url
|
145
|
+
end
|
146
|
+
|
147
|
+
def api_request(url, data)
|
148
|
+
ssl_post(url, data, headers)
|
149
|
+
rescue ResponseError => e
|
150
|
+
e.response.body
|
151
|
+
end
|
152
|
+
|
153
|
+
def parse(data)
|
154
|
+
JSON.parse data
|
155
|
+
end
|
156
|
+
|
157
|
+
def headers
|
158
|
+
{ 'Content-Type' => 'application/json' }
|
159
|
+
end
|
160
|
+
|
161
|
+
def format_messages(messages)
|
162
|
+
return unless messages.present?
|
163
|
+
|
164
|
+
messages.map { |message| message['message'] || message }.join('; ')
|
165
|
+
end
|
166
|
+
|
167
|
+
def success_from(response)
|
168
|
+
response['isSuccess']
|
169
|
+
end
|
170
|
+
|
171
|
+
def message_from(response)
|
172
|
+
format_messages(response['errorMessages'] + response['validationFailures']) || response['data']['authResponse']
|
173
|
+
end
|
174
|
+
|
175
|
+
def error_code_from(response)
|
176
|
+
return 'isError' if response['isError']
|
177
|
+
|
178
|
+
return 'validationHasFailed' if response['validationHasFailed']
|
179
|
+
end
|
180
|
+
|
181
|
+
def authorization_from(response)
|
182
|
+
response.dig('data', 'referenceNumber') || ''
|
183
|
+
end
|
184
|
+
|
185
|
+
def post_data(params)
|
186
|
+
params.merge({ processorId: @options[:processor_id], merchantKey: @options[:merchant_key] }).to_json
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
@@ -0,0 +1,183 @@
|
|
1
|
+
require 'active_merchant/billing/gateways/first_pay/first_pay_common'
|
2
|
+
require 'nokogiri'
|
3
|
+
|
4
|
+
module ActiveMerchant #:nodoc:
|
5
|
+
module Billing #:nodoc:
|
6
|
+
class FirstPayXmlGateway < Gateway
|
7
|
+
include FirstPayCommon
|
8
|
+
|
9
|
+
self.live_url = 'https://secure.goemerchant.com/secure/gateway/xmlgateway.aspx'
|
10
|
+
|
11
|
+
# Creates a new FirstPayXmlGateway
|
12
|
+
#
|
13
|
+
# The gateway requires two values for connection to be passed
|
14
|
+
# in the +options+ hash
|
15
|
+
#
|
16
|
+
# ==== Options
|
17
|
+
#
|
18
|
+
# * <tt>:gateway_id</tt> -- FirstPay's gateway_id (REQUIRED)
|
19
|
+
# * <tt>:transaction_center_id</tt> -- FirstPay's transaction_center_id or processorId (REQUIRED)
|
20
|
+
# Otherwise, perform transactions against the production server.
|
21
|
+
def initialize(options = {})
|
22
|
+
requires!(options, :gateway_id, :transaction_center_id)
|
23
|
+
super
|
24
|
+
end
|
25
|
+
|
26
|
+
def purchase(money, payment, options = {})
|
27
|
+
post = {}
|
28
|
+
add_invoice(post, money, options)
|
29
|
+
add_payment(post, payment, options)
|
30
|
+
add_address(post, payment, options)
|
31
|
+
add_customer_data(post, options)
|
32
|
+
|
33
|
+
commit('sale', post)
|
34
|
+
end
|
35
|
+
|
36
|
+
def authorize(money, payment, options = {})
|
37
|
+
post = {}
|
38
|
+
add_invoice(post, money, options)
|
39
|
+
add_payment(post, payment, options)
|
40
|
+
add_address(post, payment, options)
|
41
|
+
add_customer_data(post, options)
|
42
|
+
|
43
|
+
commit('auth', post)
|
44
|
+
end
|
45
|
+
|
46
|
+
def capture(money, authorization, options = {})
|
47
|
+
post = {}
|
48
|
+
add_reference(post, 'settle', money, authorization)
|
49
|
+
commit('settle', post)
|
50
|
+
end
|
51
|
+
|
52
|
+
def refund(money, authorization, options = {})
|
53
|
+
post = {}
|
54
|
+
add_reference(post, 'credit', money, authorization)
|
55
|
+
commit('credit', post)
|
56
|
+
end
|
57
|
+
|
58
|
+
def void(authorization, options = {})
|
59
|
+
post = {}
|
60
|
+
add_reference(post, 'void', nil, authorization)
|
61
|
+
commit('void', post)
|
62
|
+
end
|
63
|
+
|
64
|
+
def scrub(transcript)
|
65
|
+
transcript.
|
66
|
+
gsub(%r((gateway_id)[^<]*(</FIELD>))i, '\1[FILTERED]\2').
|
67
|
+
gsub(%r((card_number)[^<]*(</FIELD>))i, '\1[FILTERED]\2').
|
68
|
+
gsub(%r((cvv2)[^<]*(</FIELD>))i, '\1[FILTERED]\2')
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def add_authentication(post, options)
|
74
|
+
post[:transaction_center_id] = options[:transaction_center_id]
|
75
|
+
post[:gateway_id] = options[:gateway_id]
|
76
|
+
end
|
77
|
+
|
78
|
+
def add_customer_data(post, options)
|
79
|
+
post[:owner_email] = options[:email] if options[:email]
|
80
|
+
post[:remote_ip_address] = options[:ip] if options[:ip]
|
81
|
+
post[:processor_id] = options[:processor_id] if options[:processor_id]
|
82
|
+
end
|
83
|
+
|
84
|
+
def add_address(post, creditcard, options)
|
85
|
+
if address = options[:billing_address] || options[:address]
|
86
|
+
post[:owner_name] = address[:name]
|
87
|
+
post[:owner_street] = address[:address1]
|
88
|
+
post[:owner_street2] = address[:address2] if address[:address2]
|
89
|
+
post[:owner_city] = address[:city]
|
90
|
+
post[:owner_state] = address[:state]
|
91
|
+
post[:owner_zip] = address[:zip]
|
92
|
+
post[:owner_country] = address[:country]
|
93
|
+
post[:owner_phone] = address[:phone] if address[:phone]
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def add_invoice(post, money, options)
|
98
|
+
post[:order_id] = options[:order_id]
|
99
|
+
post[:total] = amount(money)
|
100
|
+
end
|
101
|
+
|
102
|
+
def add_payment(post, payment, options)
|
103
|
+
post[:card_name] = payment.brand # Unclear if need to map to known names or open text field??
|
104
|
+
post[:card_number] = payment.number
|
105
|
+
post[:card_exp] = expdate(payment)
|
106
|
+
post[:cvv2] = payment.verification_value
|
107
|
+
post[:recurring] = options[:recurring] if options[:recurring]
|
108
|
+
post[:recurring_start_date] = options[:recurring_start_date] if options[:recurring_start_date]
|
109
|
+
post[:recurring_end_date] = options[:recurring_end_date] if options[:recurring_end_date]
|
110
|
+
post[:recurring_type] = options[:recurring_type] if options[:recurring_type]
|
111
|
+
end
|
112
|
+
|
113
|
+
def add_reference(post, action, money, authorization)
|
114
|
+
post[:"#{action}_amount1"] = amount(money) if money
|
115
|
+
post[:total_number_transactions] = 1
|
116
|
+
post[:reference_number1] = authorization
|
117
|
+
end
|
118
|
+
|
119
|
+
def parse(xml)
|
120
|
+
response = {}
|
121
|
+
|
122
|
+
doc = Nokogiri::XML(xml)
|
123
|
+
doc.root&.xpath('//RESPONSE/FIELDS/FIELD')&.each do |field|
|
124
|
+
response[field['KEY']] = field.text
|
125
|
+
end
|
126
|
+
|
127
|
+
response
|
128
|
+
end
|
129
|
+
|
130
|
+
def commit(action, parameters)
|
131
|
+
response = parse(ssl_post(live_url, post_data(action, parameters)))
|
132
|
+
|
133
|
+
Response.new(
|
134
|
+
success_from(response),
|
135
|
+
message_from(response),
|
136
|
+
response,
|
137
|
+
authorization: authorization_from(response),
|
138
|
+
error_code: error_code_from(response),
|
139
|
+
test: test?
|
140
|
+
)
|
141
|
+
end
|
142
|
+
|
143
|
+
def success_from(response)
|
144
|
+
(
|
145
|
+
(response['status'] == '1') ||
|
146
|
+
(response['status1'] == '1')
|
147
|
+
)
|
148
|
+
end
|
149
|
+
|
150
|
+
def message_from(response)
|
151
|
+
# Silly inconsistent gateway. Always make capitalized (but not all caps)
|
152
|
+
msg = (response['auth_response'] || response['response1'])
|
153
|
+
msg&.downcase&.capitalize
|
154
|
+
end
|
155
|
+
|
156
|
+
def error_code_from(response)
|
157
|
+
response['error']
|
158
|
+
end
|
159
|
+
|
160
|
+
def authorization_from(response)
|
161
|
+
response['reference_number'] || response['reference_number1']
|
162
|
+
end
|
163
|
+
|
164
|
+
def post_data(action, parameters = {})
|
165
|
+
parameters[:transaction_center_id] = @options[:transaction_center_id]
|
166
|
+
parameters[:gateway_id] = @options[:gateway_id]
|
167
|
+
|
168
|
+
parameters[:operation_type] = action
|
169
|
+
|
170
|
+
xml = Builder::XmlMarkup.new
|
171
|
+
xml.instruct!
|
172
|
+
xml.tag! 'TRANSACTION' do
|
173
|
+
xml.tag! 'FIELDS' do
|
174
|
+
parameters.each do |key, value|
|
175
|
+
xml.tag! 'FIELD', value, { 'KEY' => key }
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
xml.target!
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
@@ -1,181 +1,15 @@
|
|
1
|
-
require '
|
1
|
+
require 'active_merchant/billing/gateways/first_pay/first_pay_xml'
|
2
|
+
require 'active_merchant/billing/gateways/first_pay/first_pay_json'
|
2
3
|
|
3
4
|
module ActiveMerchant #:nodoc:
|
4
5
|
module Billing #:nodoc:
|
5
6
|
class FirstPayGateway < Gateway
|
6
|
-
self.
|
7
|
+
self.abstract_class = true
|
7
8
|
|
8
|
-
self.
|
9
|
-
|
10
|
-
self.money_format = :dollars
|
11
|
-
self.supported_cardtypes = %i[visa master american_express discover]
|
9
|
+
def self.new(options = {})
|
10
|
+
return FirstPayJsonGateway.new(options) if options[:merchant_key]
|
12
11
|
|
13
|
-
|
14
|
-
self.display_name = '1stPayGateway.Net'
|
15
|
-
|
16
|
-
def initialize(options = {})
|
17
|
-
requires!(options, :transaction_center_id, :gateway_id)
|
18
|
-
super
|
19
|
-
end
|
20
|
-
|
21
|
-
def purchase(money, payment, options = {})
|
22
|
-
post = {}
|
23
|
-
add_invoice(post, money, options)
|
24
|
-
add_payment(post, payment, options)
|
25
|
-
add_address(post, payment, options)
|
26
|
-
add_customer_data(post, options)
|
27
|
-
|
28
|
-
commit('sale', post)
|
29
|
-
end
|
30
|
-
|
31
|
-
def authorize(money, payment, options = {})
|
32
|
-
post = {}
|
33
|
-
add_invoice(post, money, options)
|
34
|
-
add_payment(post, payment, options)
|
35
|
-
add_address(post, payment, options)
|
36
|
-
add_customer_data(post, options)
|
37
|
-
|
38
|
-
commit('auth', post)
|
39
|
-
end
|
40
|
-
|
41
|
-
def capture(money, authorization, options = {})
|
42
|
-
post = {}
|
43
|
-
add_reference(post, 'settle', money, authorization)
|
44
|
-
commit('settle', post)
|
45
|
-
end
|
46
|
-
|
47
|
-
def refund(money, authorization, options = {})
|
48
|
-
post = {}
|
49
|
-
add_reference(post, 'credit', money, authorization)
|
50
|
-
commit('credit', post)
|
51
|
-
end
|
52
|
-
|
53
|
-
def void(authorization, options = {})
|
54
|
-
post = {}
|
55
|
-
add_reference(post, 'void', nil, authorization)
|
56
|
-
commit('void', post)
|
57
|
-
end
|
58
|
-
|
59
|
-
def supports_scrubbing?
|
60
|
-
true
|
61
|
-
end
|
62
|
-
|
63
|
-
def scrub(transcript)
|
64
|
-
transcript.
|
65
|
-
gsub(%r((gateway_id)[^<]*(</FIELD>))i, '\1[FILTERED]\2').
|
66
|
-
gsub(%r((card_number)[^<]*(</FIELD>))i, '\1[FILTERED]\2').
|
67
|
-
gsub(%r((cvv2)[^<]*(</FIELD>))i, '\1[FILTERED]\2')
|
68
|
-
end
|
69
|
-
|
70
|
-
private
|
71
|
-
|
72
|
-
def add_authentication(post, options)
|
73
|
-
post[:transaction_center_id] = options[:transaction_center_id]
|
74
|
-
post[:gateway_id] = options[:gateway_id]
|
75
|
-
end
|
76
|
-
|
77
|
-
def add_customer_data(post, options)
|
78
|
-
post[:owner_email] = options[:email] if options[:email]
|
79
|
-
post[:remote_ip_address] = options[:ip] if options[:ip]
|
80
|
-
post[:processor_id] = options[:processor_id] if options[:processor_id]
|
81
|
-
end
|
82
|
-
|
83
|
-
def add_address(post, creditcard, options)
|
84
|
-
if address = options[:billing_address] || options[:address]
|
85
|
-
post[:owner_name] = address[:name]
|
86
|
-
post[:owner_street] = address[:address1]
|
87
|
-
post[:owner_street2] = address[:address2] if address[:address2]
|
88
|
-
post[:owner_city] = address[:city]
|
89
|
-
post[:owner_state] = address[:state]
|
90
|
-
post[:owner_zip] = address[:zip]
|
91
|
-
post[:owner_country] = address[:country]
|
92
|
-
post[:owner_phone] = address[:phone] if address[:phone]
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def add_invoice(post, money, options)
|
97
|
-
post[:order_id] = options[:order_id]
|
98
|
-
post[:total] = amount(money)
|
99
|
-
end
|
100
|
-
|
101
|
-
def add_payment(post, payment, options)
|
102
|
-
post[:card_name] = payment.brand # Unclear if need to map to known names or open text field??
|
103
|
-
post[:card_number] = payment.number
|
104
|
-
post[:card_exp] = expdate(payment)
|
105
|
-
post[:cvv2] = payment.verification_value
|
106
|
-
post[:recurring] = options[:recurring] if options[:recurring]
|
107
|
-
post[:recurring_start_date] = options[:recurring_start_date] if options[:recurring_start_date]
|
108
|
-
post[:recurring_end_date] = options[:recurring_end_date] if options[:recurring_end_date]
|
109
|
-
post[:recurring_type] = options[:recurring_type] if options[:recurring_type]
|
110
|
-
end
|
111
|
-
|
112
|
-
def add_reference(post, action, money, authorization)
|
113
|
-
post[:"#{action}_amount1"] = amount(money) if money
|
114
|
-
post[:total_number_transactions] = 1
|
115
|
-
post[:reference_number1] = authorization
|
116
|
-
end
|
117
|
-
|
118
|
-
def parse(xml)
|
119
|
-
response = {}
|
120
|
-
|
121
|
-
doc = Nokogiri::XML(xml)
|
122
|
-
doc.root&.xpath('//RESPONSE/FIELDS/FIELD')&.each do |field|
|
123
|
-
response[field['KEY']] = field.text
|
124
|
-
end
|
125
|
-
|
126
|
-
response
|
127
|
-
end
|
128
|
-
|
129
|
-
def commit(action, parameters)
|
130
|
-
response = parse(ssl_post(live_url, post_data(action, parameters)))
|
131
|
-
|
132
|
-
Response.new(
|
133
|
-
success_from(response),
|
134
|
-
message_from(response),
|
135
|
-
response,
|
136
|
-
authorization: authorization_from(response),
|
137
|
-
error_code: error_code_from(response),
|
138
|
-
test: test?
|
139
|
-
)
|
140
|
-
end
|
141
|
-
|
142
|
-
def success_from(response)
|
143
|
-
(
|
144
|
-
(response['status'] == '1') ||
|
145
|
-
(response['status1'] == '1')
|
146
|
-
)
|
147
|
-
end
|
148
|
-
|
149
|
-
def message_from(response)
|
150
|
-
# Silly inconsistent gateway. Always make capitalized (but not all caps)
|
151
|
-
msg = (response['auth_response'] || response['response1'])
|
152
|
-
msg&.downcase&.capitalize
|
153
|
-
end
|
154
|
-
|
155
|
-
def error_code_from(response)
|
156
|
-
response['error']
|
157
|
-
end
|
158
|
-
|
159
|
-
def authorization_from(response)
|
160
|
-
response['reference_number'] || response['reference_number1']
|
161
|
-
end
|
162
|
-
|
163
|
-
def post_data(action, parameters = {})
|
164
|
-
parameters[:transaction_center_id] = @options[:transaction_center_id]
|
165
|
-
parameters[:gateway_id] = @options[:gateway_id]
|
166
|
-
|
167
|
-
parameters[:operation_type] = action
|
168
|
-
|
169
|
-
xml = Builder::XmlMarkup.new
|
170
|
-
xml.instruct!
|
171
|
-
xml.tag! 'TRANSACTION' do
|
172
|
-
xml.tag! 'FIELDS' do
|
173
|
-
parameters.each do |key, value|
|
174
|
-
xml.tag! 'FIELD', value, { 'KEY' => key }
|
175
|
-
end
|
176
|
-
end
|
177
|
-
end
|
178
|
-
xml.target!
|
12
|
+
FirstPayXmlGateway.new(options)
|
179
13
|
end
|
180
14
|
end
|
181
15
|
end
|
@@ -354,12 +354,16 @@ module ActiveMerchant #:nodoc:
|
|
354
354
|
response = parse_error(e.response)
|
355
355
|
end
|
356
356
|
|
357
|
-
Response.new(
|
357
|
+
Response.new(
|
358
|
+
successful?(response),
|
359
|
+
message_from(response),
|
360
|
+
response,
|
358
361
|
test: test?,
|
359
362
|
authorization: successful?(response) ? response_authorization(action, response, credit_card) : '',
|
360
363
|
avs_result: { code: response[:avs] },
|
361
364
|
cvv_result: response[:cvv2],
|
362
|
-
error_code: standard_error_code(response)
|
365
|
+
error_code: standard_error_code(response)
|
366
|
+
)
|
363
367
|
end
|
364
368
|
|
365
369
|
def successful?(response)
|
@@ -316,7 +316,7 @@ module ActiveMerchant #:nodoc:
|
|
316
316
|
def strip_line_breaks(address)
|
317
317
|
return unless address.is_a?(Hash)
|
318
318
|
|
319
|
-
|
319
|
+
address.map { |k, s| [k, s&.tr("\r\n", ' ')&.strip] }.to_h
|
320
320
|
end
|
321
321
|
|
322
322
|
def add_invoice(xml, options)
|
@@ -380,12 +380,16 @@ module ActiveMerchant #:nodoc:
|
|
380
380
|
response = parse_error(e.response)
|
381
381
|
end
|
382
382
|
|
383
|
-
Response.new(
|
383
|
+
Response.new(
|
384
|
+
successful?(response),
|
385
|
+
message_from(response),
|
386
|
+
response,
|
384
387
|
test: test?,
|
385
388
|
authorization: successful?(response) ? response_authorization(action, response, credit_card) : '',
|
386
389
|
avs_result: { code: response[:avs] },
|
387
390
|
cvv_result: response[:cvv2],
|
388
|
-
error_code: standard_error_code(response)
|
391
|
+
error_code: standard_error_code(response)
|
392
|
+
)
|
389
393
|
end
|
390
394
|
|
391
395
|
def headers(method, url, request)
|