aktivemerchant 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +1596 -0
- data/CONTRIBUTORS +511 -0
- data/MIT-LICENSE +20 -0
- data/README.md +18 -0
- data/lib/active_merchant.rb +108 -0
- data/lib/active_merchant/billing.rb +13 -0
- data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
- data/lib/active_merchant/billing/avs_result.rb +98 -0
- data/lib/active_merchant/billing/base.rb +72 -0
- data/lib/active_merchant/billing/check.rb +76 -0
- data/lib/active_merchant/billing/compatibility.rb +120 -0
- data/lib/active_merchant/billing/credit_card.rb +352 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +24 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +160 -0
- data/lib/active_merchant/billing/cvv_result.rb +38 -0
- data/lib/active_merchant/billing/gateway.rb +268 -0
- data/lib/active_merchant/billing/gateways.rb +17 -0
- data/lib/active_merchant/billing/gateways/adyen.rb +209 -0
- data/lib/active_merchant/billing/gateways/alfabank.rb +117 -0
- data/lib/active_merchant/billing/gateways/app55.rb +176 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +419 -0
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +417 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +976 -0
- data/lib/active_merchant/billing/gateways/balanced.rb +256 -0
- data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
- data/lib/active_merchant/billing/gateways/banwire.rb +105 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq.rb +314 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +15 -0
- data/lib/active_merchant/billing/gateways/be2bill.rb +131 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +188 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +393 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
- data/lib/active_merchant/billing/gateways/blue_pay.rb +506 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +140 -0
- data/lib/active_merchant/billing/gateways/borgun.rb +210 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +515 -0
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +20 -0
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +189 -0
- data/lib/active_merchant/billing/gateways/card_save.rb +23 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +220 -0
- data/lib/active_merchant/billing/gateways/cashnet.rb +191 -0
- data/lib/active_merchant/billing/gateways/cc5.rb +201 -0
- data/lib/active_merchant/billing/gateways/cecabank.rb +229 -0
- data/lib/active_merchant/billing/gateways/certo_direct.rb +278 -0
- data/lib/active_merchant/billing/gateways/checkout.rb +213 -0
- data/lib/active_merchant/billing/gateways/commercegate.rb +143 -0
- data/lib/active_merchant/billing/gateways/conekta.rb +209 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +709 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +600 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +219 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +348 -0
- data/lib/active_merchant/billing/gateways/epay.rb +275 -0
- data/lib/active_merchant/billing/gateways/evo_ca.rb +308 -0
- data/lib/active_merchant/billing/gateways/eway.rb +214 -0
- data/lib/active_merchant/billing/gateways/eway_managed.rb +291 -0
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +524 -0
- data/lib/active_merchant/billing/gateways/exact.rb +218 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +173 -0
- data/lib/active_merchant/billing/gateways/federated_canada.rb +160 -0
- data/lib/active_merchant/billing/gateways/finansbank.rb +23 -0
- data/lib/active_merchant/billing/gateways/first_giving.rb +143 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +160 -0
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +355 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +257 -0
- data/lib/active_merchant/billing/gateways/global_transport.rb +183 -0
- data/lib/active_merchant/billing/gateways/hdfc.rb +207 -0
- data/lib/active_merchant/billing/gateways/hps.rb +288 -0
- data/lib/active_merchant/billing/gateways/iats_payments.rb +251 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +246 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +13 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +29 -0
- data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +66 -0
- data/lib/active_merchant/billing/gateways/inspire.rb +213 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +163 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +457 -0
- data/lib/active_merchant/billing/gateways/itransact.rb +448 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +275 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +438 -0
- data/lib/active_merchant/billing/gateways/litle.rb +346 -0
- data/lib/active_merchant/billing/gateways/maxipago.rb +197 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +170 -0
- data/lib/active_merchant/billing/gateways/merchant_one.rb +114 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +319 -0
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +268 -0
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +195 -0
- data/lib/active_merchant/billing/gateways/mercury.rb +333 -0
- data/lib/active_merchant/billing/gateways/metrics_global.rb +303 -0
- data/lib/active_merchant/billing/gateways/migs.rb +265 -0
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +219 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +309 -0
- data/lib/active_merchant/billing/gateways/moneris_us.rb +291 -0
- data/lib/active_merchant/billing/gateways/money_movers.rb +152 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +280 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +198 -0
- data/lib/active_merchant/billing/gateways/netaxept.rb +181 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +190 -0
- data/lib/active_merchant/billing/gateways/netpay.rb +223 -0
- data/lib/active_merchant/billing/gateways/network_merchants.rb +242 -0
- data/lib/active_merchant/billing/gateways/nmi.rb +256 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +435 -0
- data/lib/active_merchant/billing/gateways/openpay.rb +194 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +313 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +803 -0
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +47 -0
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +207 -0
- data/lib/active_merchant/billing/gateways/pago_facil.rb +122 -0
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +261 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +390 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +112 -0
- data/lib/active_merchant/billing/gateways/pay_u_latam.rb +462 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +188 -0
- data/lib/active_merchant/billing/gateways/payex.rb +412 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +304 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +209 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +39 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +224 -0
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +15 -0
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +21 -0
- data/lib/active_merchant/billing/gateways/payment_express.rb +353 -0
- data/lib/active_merchant/billing/gateways/paymill.rb +281 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +117 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +670 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +65 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -0
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
- data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +44 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +264 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
- data/lib/active_merchant/billing/gateways/payscout.rb +162 -0
- data/lib/active_merchant/billing/gateways/paystation.rb +199 -0
- data/lib/active_merchant/billing/gateways/payway.rb +207 -0
- data/lib/active_merchant/billing/gateways/pin.rb +197 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +283 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +216 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +303 -0
- data/lib/active_merchant/billing/gateways/qbms.rb +292 -0
- data/lib/active_merchant/billing/gateways/quantum.rb +276 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +367 -0
- data/lib/active_merchant/billing/gateways/realex.rb +298 -0
- data/lib/active_merchant/billing/gateways/redsys.rb +391 -0
- data/lib/active_merchant/billing/gateways/sage.rb +175 -0
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +87 -0
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +114 -0
- data/lib/active_merchant/billing/gateways/sage/sage_vault.rb +149 -0
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +102 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +398 -0
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +143 -0
- data/lib/active_merchant/billing/gateways/secure_net.rb +252 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +201 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +281 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +105 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +452 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +283 -0
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +247 -0
- data/lib/active_merchant/billing/gateways/stripe.rb +411 -0
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +157 -0
- data/lib/active_merchant/billing/gateways/tns.rb +227 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +126 -0
- data/lib/active_merchant/billing/gateways/transax.rb +23 -0
- data/lib/active_merchant/billing/gateways/transnational.rb +10 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +416 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +25 -0
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1516 -0
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +254 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +225 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +183 -0
- data/lib/active_merchant/billing/gateways/vindicia.rb +385 -0
- data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
- data/lib/active_merchant/billing/gateways/wepay.rb +189 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +421 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +331 -0
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +181 -0
- data/lib/active_merchant/billing/model.rb +30 -0
- data/lib/active_merchant/billing/payment_token.rb +21 -0
- data/lib/active_merchant/billing/rails.rb +3 -0
- data/lib/active_merchant/billing/response.rb +91 -0
- data/lib/active_merchant/country.rb +332 -0
- data/lib/active_merchant/empty.rb +20 -0
- data/lib/active_merchant/errors.rb +29 -0
- data/lib/active_merchant/offsite_payments_shim.rb +19 -0
- data/lib/active_merchant/version.rb +3 -0
- data/lib/activemerchant.rb +1 -0
- data/lib/support/gateway_support.rb +71 -0
- data/lib/support/outbound_hosts.rb +25 -0
- data/lib/support/ssl_verify.rb +93 -0
- metadata +400 -0
@@ -0,0 +1,197 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class PinGateway < Gateway
|
4
|
+
self.test_url = 'https://test-api.pin.net.au/1'
|
5
|
+
self.live_url = 'https://api.pin.net.au/1'
|
6
|
+
|
7
|
+
self.default_currency = 'AUD'
|
8
|
+
self.money_format = :cents
|
9
|
+
self.supported_countries = ['AU']
|
10
|
+
self.supported_cardtypes = [:visa, :master, :american_express]
|
11
|
+
self.homepage_url = 'http://www.pin.net.au/'
|
12
|
+
self.display_name = 'Pin Payments'
|
13
|
+
|
14
|
+
def initialize(options = {})
|
15
|
+
requires!(options, :api_key)
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
# Create a charge using a credit card, card token or customer token
|
20
|
+
#
|
21
|
+
# To charge a credit card: purchase([money], [creditcard hash], ...)
|
22
|
+
# To charge a customer: purchase([money], [token], ...)
|
23
|
+
def purchase(money, creditcard, options = {})
|
24
|
+
post = {}
|
25
|
+
|
26
|
+
add_amount(post, money, options)
|
27
|
+
add_customer_data(post, options)
|
28
|
+
add_invoice(post, options)
|
29
|
+
add_creditcard(post, creditcard)
|
30
|
+
add_address(post, creditcard, options)
|
31
|
+
add_capture(post, options)
|
32
|
+
|
33
|
+
commit(:post, 'charges', post, options)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Create a customer and associated credit card. The token that is returned
|
37
|
+
# can be used instead of a credit card parameter in the purchase method
|
38
|
+
def store(creditcard, options = {})
|
39
|
+
post = {}
|
40
|
+
|
41
|
+
add_creditcard(post, creditcard)
|
42
|
+
add_customer_data(post, options)
|
43
|
+
add_address(post, creditcard, options)
|
44
|
+
commit(:post, 'customers', post, options)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Refund a transaction, note that the money attribute is ignored at the
|
48
|
+
# moment as the API does not support partial refunds. The parameter is
|
49
|
+
# kept for compatibility reasons
|
50
|
+
def refund(money, token, options = {})
|
51
|
+
commit(:post, "charges/#{CGI.escape(token)}/refunds", { :amount => amount(money) }, options)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Authorize an amount on a credit card. Once authorized, you can later
|
55
|
+
# capture this charge using the charge token that is returned.
|
56
|
+
def authorize(money, creditcard, options = {})
|
57
|
+
options[:capture] = false
|
58
|
+
|
59
|
+
purchase(money, creditcard, options)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Captures a previously authorized charge. Capturing a certin amount of the original
|
63
|
+
# authorization is currently not supported.
|
64
|
+
def capture(money, token, options = {})
|
65
|
+
commit(:put, "charges/#{CGI.escape(token)}/capture", {}, options)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Updates the credit card for the customer.
|
69
|
+
def update(token, creditcard, options = {})
|
70
|
+
post = {}
|
71
|
+
|
72
|
+
add_creditcard(post, creditcard)
|
73
|
+
add_customer_data(post, options)
|
74
|
+
add_address(post, creditcard, options)
|
75
|
+
commit(:put, "customers/#{CGI.escape(token)}", post, options)
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def add_amount(post, money, options)
|
81
|
+
post[:amount] = amount(money)
|
82
|
+
post[:currency] = (options[:currency] || currency(money))
|
83
|
+
post[:currency] = post[:currency].upcase if post[:currency]
|
84
|
+
end
|
85
|
+
|
86
|
+
def add_customer_data(post, options)
|
87
|
+
post[:email] = options[:email] if options[:email]
|
88
|
+
post[:ip_address] = options[:ip] if options[:ip]
|
89
|
+
end
|
90
|
+
|
91
|
+
def add_address(post, creditcard, options)
|
92
|
+
return if creditcard.kind_of?(String)
|
93
|
+
address = (options[:billing_address] || options[:address])
|
94
|
+
return unless address
|
95
|
+
|
96
|
+
post[:card] ||= {}
|
97
|
+
post[:card].merge!(
|
98
|
+
:address_line1 => address[:address1],
|
99
|
+
:address_city => address[:city],
|
100
|
+
:address_postcode => address[:zip],
|
101
|
+
:address_state => address[:state],
|
102
|
+
:address_country => address[:country]
|
103
|
+
)
|
104
|
+
end
|
105
|
+
|
106
|
+
def add_invoice(post, options)
|
107
|
+
post[:description] = options[:description] || "Active Merchant Purchase"
|
108
|
+
end
|
109
|
+
|
110
|
+
def add_capture(post, options)
|
111
|
+
capture = options[:capture]
|
112
|
+
|
113
|
+
post[:capture] = capture == false ? false : true
|
114
|
+
end
|
115
|
+
|
116
|
+
def add_creditcard(post, creditcard)
|
117
|
+
if creditcard.respond_to?(:number)
|
118
|
+
post[:card] ||= {}
|
119
|
+
|
120
|
+
post[:card].merge!(
|
121
|
+
:number => creditcard.number,
|
122
|
+
:expiry_month => creditcard.month,
|
123
|
+
:expiry_year => creditcard.year,
|
124
|
+
:cvc => creditcard.verification_value,
|
125
|
+
:name => creditcard.name
|
126
|
+
)
|
127
|
+
elsif creditcard.kind_of?(String)
|
128
|
+
if creditcard =~ /^card_/
|
129
|
+
post[:card_token] = creditcard
|
130
|
+
else
|
131
|
+
post[:customer_token] = creditcard
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def headers(params = {})
|
137
|
+
result = {
|
138
|
+
"Content-Type" => "application/json",
|
139
|
+
"Authorization" => "Basic #{Base64.strict_encode64(options[:api_key] + ':').strip}"
|
140
|
+
}
|
141
|
+
|
142
|
+
result['X-Partner-Key'] = params[:partner_key] if params[:partner_key]
|
143
|
+
result['X-Safe-Card'] = params[:safe_card] if params[:safe_card]
|
144
|
+
result
|
145
|
+
end
|
146
|
+
|
147
|
+
def commit(method, action, params, options)
|
148
|
+
url = "#{test? ? test_url : live_url}/#{action}"
|
149
|
+
|
150
|
+
begin
|
151
|
+
body = parse(ssl_request(method, url, post_data(params), headers(options)))
|
152
|
+
rescue ResponseError => e
|
153
|
+
body = parse(e.response.body)
|
154
|
+
end
|
155
|
+
|
156
|
+
if body["response"]
|
157
|
+
success_response(body)
|
158
|
+
elsif body["error"]
|
159
|
+
error_response(body)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def success_response(body)
|
164
|
+
response = body["response"]
|
165
|
+
Response.new(
|
166
|
+
true,
|
167
|
+
response['status_message'],
|
168
|
+
body,
|
169
|
+
:authorization => token(response),
|
170
|
+
:test => test?
|
171
|
+
)
|
172
|
+
end
|
173
|
+
|
174
|
+
def error_response(body)
|
175
|
+
Response.new(
|
176
|
+
false,
|
177
|
+
body['error_description'],
|
178
|
+
body,
|
179
|
+
:authorization => nil,
|
180
|
+
:test => test?
|
181
|
+
)
|
182
|
+
end
|
183
|
+
|
184
|
+
def token(response)
|
185
|
+
response['token']
|
186
|
+
end
|
187
|
+
|
188
|
+
def parse(body)
|
189
|
+
JSON.parse(body)
|
190
|
+
end
|
191
|
+
|
192
|
+
def post_data(parameters = {})
|
193
|
+
parameters.to_json
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
@@ -0,0 +1,283 @@
|
|
1
|
+
module ActiveMerchant
|
2
|
+
module Billing
|
3
|
+
class PlugnpayGateway < Gateway
|
4
|
+
class PlugnpayPostData < PostData
|
5
|
+
# Fields that will be sent even if they are blank
|
6
|
+
self.required_fields = [ :publisher_name, :publisher_password,
|
7
|
+
:card_amount, :card_name, :card_number, :card_exp, :orderID ]
|
8
|
+
end
|
9
|
+
self.live_url = self.test_url = 'https://pay1.plugnpay.com/payment/pnpremote.cgi'
|
10
|
+
|
11
|
+
CARD_CODE_MESSAGES = {
|
12
|
+
"M" => "Card verification number matched",
|
13
|
+
"N" => "Card verification number didn't match",
|
14
|
+
"P" => "Card verification number was not processed",
|
15
|
+
"S" => "Card verification number should be on card but was not indicated",
|
16
|
+
"U" => "Issuer was not certified for card verification"
|
17
|
+
}
|
18
|
+
|
19
|
+
CARD_CODE_ERRORS = %w( N S )
|
20
|
+
|
21
|
+
AVS_MESSAGES = {
|
22
|
+
"A" => "Street address matches billing information, zip/postal code does not",
|
23
|
+
"B" => "Address information not provided for address verification check",
|
24
|
+
"E" => "Address verification service error",
|
25
|
+
"G" => "Non-U.S. card-issuing bank",
|
26
|
+
"N" => "Neither street address nor zip/postal match billing information",
|
27
|
+
"P" => "Address verification not applicable for this transaction",
|
28
|
+
"R" => "Payment gateway was unavailable or timed out",
|
29
|
+
"S" => "Address verification service not supported by issuer",
|
30
|
+
"U" => "Address information is unavailable",
|
31
|
+
"W" => "9-digit zip/postal code matches billing information, street address does not",
|
32
|
+
"X" => "Street address and 9-digit zip/postal code matches billing information",
|
33
|
+
"Y" => "Street address and 5-digit zip/postal code matches billing information",
|
34
|
+
"Z" => "5-digit zip/postal code matches billing information, street address does not",
|
35
|
+
}
|
36
|
+
|
37
|
+
AVS_ERRORS = %w( A E N R W Z )
|
38
|
+
|
39
|
+
PAYMENT_GATEWAY_RESPONSES = {
|
40
|
+
"P01" => "AVS Mismatch Failure",
|
41
|
+
"P02" => "CVV2 Mismatch Failure",
|
42
|
+
"P21" => "Transaction may not be marked",
|
43
|
+
"P30" => "Test Tran. Bad Card",
|
44
|
+
"P35" => "Test Tran. Problem",
|
45
|
+
"P40" => "Username already exists",
|
46
|
+
"P41" => "Username is blank",
|
47
|
+
"P50" => "Fraud Screen Failure",
|
48
|
+
"P51" => "Missing PIN Code",
|
49
|
+
"P52" => "Invalid Bank Acct. No.",
|
50
|
+
"P53" => "Invalid Bank Routing No.",
|
51
|
+
"P54" => "Invalid/Missing Check No.",
|
52
|
+
"P55" => "Invalid Credit Card No.",
|
53
|
+
"P56" => "Invalid CVV2/CVC2 No.",
|
54
|
+
"P57" => "Expired. CC Exp. Date",
|
55
|
+
"P58" => "Missing Data",
|
56
|
+
"P59" => "Missing Email Address",
|
57
|
+
"P60" => "Zip Code does not match Billing State.",
|
58
|
+
"P61" => "Invalid Billing Zip Code",
|
59
|
+
"P62" => "Zip Code does not match Shipping State.",
|
60
|
+
"P63" => "Invalid Shipping Zip Code",
|
61
|
+
"P64" => "Invalid Credit Card CVV2/CVC2 Format.",
|
62
|
+
"P65" => "Maximum number of attempts has been exceeded.",
|
63
|
+
"P66" => "Credit Card number has been flagged and can not be used to access this service.",
|
64
|
+
"P67" => "IP Address is on Blocked List.",
|
65
|
+
"P68" => "Billing country does not match ipaddress country.",
|
66
|
+
"P69" => "US based ipaddresses are currently blocked.",
|
67
|
+
"P70" => "Credit Cards issued from this bank are currently not being accepted.",
|
68
|
+
"P71" => "Credit Cards issued from this bank are currently not being accepted.",
|
69
|
+
"P72" => "Daily volume exceeded.",
|
70
|
+
"P73" => "Too many transactions within allotted time.",
|
71
|
+
"P91" => "Missing/incorrect password",
|
72
|
+
"P92" => "Account not configured for mobil administration",
|
73
|
+
"P93" => "IP Not registered to username.",
|
74
|
+
"P94" => "Mode not permitted for this account.",
|
75
|
+
"P95" => "Currently Blank",
|
76
|
+
"P96" => "Currently Blank",
|
77
|
+
"P97" => "Processor not responding",
|
78
|
+
"P98" => "Missing merchant/publisher name",
|
79
|
+
"P99" => "Currently Blank"
|
80
|
+
}
|
81
|
+
|
82
|
+
TRANSACTIONS = {
|
83
|
+
:authorization => 'auth',
|
84
|
+
:purchase => 'auth',
|
85
|
+
:capture => 'mark',
|
86
|
+
:void => 'void',
|
87
|
+
:refund => 'return',
|
88
|
+
:credit => 'newreturn'
|
89
|
+
}
|
90
|
+
|
91
|
+
SUCCESS_CODES = [ 'pending', 'success' ]
|
92
|
+
FAILURE_CODES = [ 'badcard', 'fraud' ]
|
93
|
+
|
94
|
+
self.default_currency = 'USD'
|
95
|
+
self.supported_countries = ['US']
|
96
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
97
|
+
self.homepage_url = 'http://www.plugnpay.com/'
|
98
|
+
self.display_name = "Plug'n Pay"
|
99
|
+
|
100
|
+
def initialize(options = {})
|
101
|
+
requires!(options, :login, :password)
|
102
|
+
super
|
103
|
+
end
|
104
|
+
|
105
|
+
def purchase(money, creditcard, options = {})
|
106
|
+
post = PlugnpayPostData.new
|
107
|
+
|
108
|
+
add_amount(post, money, options)
|
109
|
+
add_creditcard(post, creditcard)
|
110
|
+
add_addresses(post, options)
|
111
|
+
add_invoice_data(post, options)
|
112
|
+
add_customer_data(post, options)
|
113
|
+
|
114
|
+
post[:authtype] = 'authpostauth'
|
115
|
+
commit(:authorization, post)
|
116
|
+
end
|
117
|
+
|
118
|
+
def authorize(money, creditcard, options = {})
|
119
|
+
post = PlugnpayPostData.new
|
120
|
+
|
121
|
+
add_amount(post, money, options)
|
122
|
+
add_creditcard(post, creditcard)
|
123
|
+
add_addresses(post, options)
|
124
|
+
add_invoice_data(post, options)
|
125
|
+
add_customer_data(post, options)
|
126
|
+
|
127
|
+
post[:authtype] = 'authonly'
|
128
|
+
commit(:authorization, post)
|
129
|
+
end
|
130
|
+
|
131
|
+
def capture(money, authorization, options = {})
|
132
|
+
post = PlugnpayPostData.new
|
133
|
+
|
134
|
+
post[:orderID] = authorization
|
135
|
+
|
136
|
+
add_amount(post, money, options)
|
137
|
+
add_customer_data(post, options)
|
138
|
+
|
139
|
+
commit(:capture, post)
|
140
|
+
end
|
141
|
+
|
142
|
+
def void(authorization, options = {})
|
143
|
+
post = PlugnpayPostData.new
|
144
|
+
|
145
|
+
post[:orderID] = authorization
|
146
|
+
post[:txn_type] = 'auth'
|
147
|
+
|
148
|
+
commit(:void, post)
|
149
|
+
end
|
150
|
+
|
151
|
+
def credit(money, identification_or_creditcard, options = {})
|
152
|
+
post = PlugnpayPostData.new
|
153
|
+
add_amount(post, money, options)
|
154
|
+
|
155
|
+
if identification_or_creditcard.is_a?(String)
|
156
|
+
ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
|
157
|
+
refund(money, identification_or_creditcard, options)
|
158
|
+
else
|
159
|
+
add_creditcard(post, identification_or_creditcard)
|
160
|
+
add_addresses(post, options)
|
161
|
+
add_customer_data(post, options)
|
162
|
+
|
163
|
+
commit(:credit, post)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def refund(money, reference, options = {})
|
168
|
+
post = PlugnpayPostData.new
|
169
|
+
add_amount(post, money, options)
|
170
|
+
post[:orderID] = reference
|
171
|
+
commit(:refund, post)
|
172
|
+
end
|
173
|
+
|
174
|
+
private
|
175
|
+
def commit(action, post)
|
176
|
+
response = parse( ssl_post(self.live_url, post_data(action, post)) )
|
177
|
+
success = SUCCESS_CODES.include?(response[:finalstatus])
|
178
|
+
message = success ? 'Success' : message_from(response)
|
179
|
+
|
180
|
+
Response.new(success, message, response,
|
181
|
+
:test => test?,
|
182
|
+
:authorization => response[:orderid],
|
183
|
+
:avs_result => { :code => response[:avs_code] },
|
184
|
+
:cvv_result => response[:cvvresp]
|
185
|
+
)
|
186
|
+
end
|
187
|
+
|
188
|
+
def parse(body)
|
189
|
+
body = CGI.unescape(body)
|
190
|
+
results = {}
|
191
|
+
body.split('&').collect { |e| e.split('=') }.each do |key,value|
|
192
|
+
results[key.downcase.to_sym] = normalize(value.to_s.strip)
|
193
|
+
end
|
194
|
+
|
195
|
+
results.delete(:publisher_password)
|
196
|
+
results[:avs_message] = AVS_MESSAGES[results[:avs_code]] if results[:avs_code]
|
197
|
+
results[:card_code_message] = CARD_CODE_MESSAGES[results[:cvvresp]] if results[:cvvresp]
|
198
|
+
|
199
|
+
results
|
200
|
+
end
|
201
|
+
|
202
|
+
def post_data(action, post)
|
203
|
+
post[:mode] = TRANSACTIONS[action]
|
204
|
+
post[:convert] = 'underscores'
|
205
|
+
post[:app_level] = 0
|
206
|
+
post[:publisher_name] = @options[:login]
|
207
|
+
post[:publisher_password] = @options[:password]
|
208
|
+
|
209
|
+
post.to_s
|
210
|
+
end
|
211
|
+
|
212
|
+
def add_creditcard(post, creditcard)
|
213
|
+
post[:card_number] = creditcard.number
|
214
|
+
post[:card_cvv] = creditcard.verification_value
|
215
|
+
post[:card_exp] = expdate(creditcard)
|
216
|
+
post[:card_name] = creditcard.name.slice(0..38)
|
217
|
+
end
|
218
|
+
|
219
|
+
def add_customer_data(post, options)
|
220
|
+
post[:email] = options[:email]
|
221
|
+
post[:dontsndmail] = 'yes' unless options[:send_email_confirmation]
|
222
|
+
post[:ipaddress] = options[:ip]
|
223
|
+
end
|
224
|
+
|
225
|
+
def add_invoice_data(post, options)
|
226
|
+
post[:shipping] = amount(options[:shipping]) unless options[:shipping].blank?
|
227
|
+
post[:tax] = amount(options[:tax]) unless options[:tax].blank?
|
228
|
+
end
|
229
|
+
|
230
|
+
def add_addresses(post, options)
|
231
|
+
if address = options[:billing_address] || options[:address]
|
232
|
+
post[:card_address1] = address[:address1]
|
233
|
+
post[:card_zip] = address[:zip]
|
234
|
+
post[:card_city] = address[:city]
|
235
|
+
post[:card_country] = address[:country]
|
236
|
+
post[:phone] = address[:phone]
|
237
|
+
|
238
|
+
case address[:country]
|
239
|
+
when 'US', 'CA'
|
240
|
+
post[:card_state] = address[:state]
|
241
|
+
else
|
242
|
+
post[:card_state] = 'ZZ'
|
243
|
+
post[:card_prov] = address[:state]
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
if shipping_address = options[:shipping_address] || address
|
248
|
+
post[:shipname] = shipping_address[:name]
|
249
|
+
post[:address1] = shipping_address[:address1]
|
250
|
+
post[:address2] = shipping_address[:address2]
|
251
|
+
post[:city] = shipping_address[:city]
|
252
|
+
|
253
|
+
case shipping_address[:country]
|
254
|
+
when 'US', 'CA'
|
255
|
+
post[:state] = shipping_address[:state]
|
256
|
+
else
|
257
|
+
post[:state] = 'ZZ'
|
258
|
+
post[:province] = shipping_address[:state]
|
259
|
+
end
|
260
|
+
|
261
|
+
post[:country] = shipping_address[:country]
|
262
|
+
post[:zip] = shipping_address[:zip]
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
def add_amount(post, money, options)
|
267
|
+
post[:card_amount] = amount(money)
|
268
|
+
post[:currency] = options[:currency] || currency(money)
|
269
|
+
end
|
270
|
+
|
271
|
+
def message_from(results)
|
272
|
+
PAYMENT_GATEWAY_RESPONSES[results[:resp_code]]
|
273
|
+
end
|
274
|
+
|
275
|
+
def expdate(creditcard)
|
276
|
+
year = sprintf("%.4i", creditcard.year)
|
277
|
+
month = sprintf("%.2i", creditcard.month)
|
278
|
+
|
279
|
+
"#{month}/#{year[-2..-1]}"
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
283
|
+
end
|