start_activemerchant 1.50.0
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.
- checksums.yaml +7 -0
- data/CHANGELOG +1769 -0
- data/CONTRIBUTORS +540 -0
- data/MIT-LICENSE +20 -0
- data/README.md +226 -0
- data/lib/active_merchant.rb +67 -0
- data/lib/active_merchant/billing.rb +15 -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 +404 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +24 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +195 -0
- data/lib/active_merchant/billing/cvv_result.rb +38 -0
- data/lib/active_merchant/billing/gateway.rb +291 -0
- data/lib/active_merchant/billing/gateways.rb +14 -0
- data/lib/active_merchant/billing/gateways/allied_wallet.rb +203 -0
- data/lib/active_merchant/billing/gateways/app55.rb +176 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +510 -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/axcessms.rb +181 -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 +192 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +389 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +58 -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 +211 -0
- data/lib/active_merchant/billing/gateways/bpoint.rb +277 -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 +574 -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 +238 -0
- data/lib/active_merchant/billing/gateways/cashnet.rb +202 -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/cenpos.rb +262 -0
- data/lib/active_merchant/billing/gateways/certo_direct.rb +278 -0
- data/lib/active_merchant/billing/gateways/checkout.rb +216 -0
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +200 -0
- data/lib/active_merchant/billing/gateways/commercegate.rb +143 -0
- data/lib/active_merchant/billing/gateways/conekta.rb +210 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +720 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +600 -0
- data/lib/active_merchant/billing/gateways/dibs.rb +206 -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 +274 -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 +522 -0
- data/lib/active_merchant/billing/gateways/exact.rb +227 -0
- data/lib/active_merchant/billing/gateways/ezic.rb +206 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +213 -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 +413 -0
- data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
- data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +261 -0
- data/lib/active_merchant/billing/gateways/global_transport.rb +179 -0
- data/lib/active_merchant/billing/gateways/hdfc.rb +207 -0
- data/lib/active_merchant/billing/gateways/hps.rb +287 -0
- data/lib/active_merchant/billing/gateways/iats_payments.rb +277 -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 +219 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +163 -0
- data/lib/active_merchant/billing/gateways/ipp.rb +175 -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 +345 -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_partners.rb +245 -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 +326 -0
- data/lib/active_merchant/billing/gateways/metrics_global.rb +303 -0
- data/lib/active_merchant/billing/gateways/migs.rb +280 -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/monei.rb +307 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +309 -0
- data/lib/active_merchant/billing/gateways/moneris_us.rb +298 -0
- data/lib/active_merchant/billing/gateways/money_movers.rb +152 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +290 -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 +224 -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/omise.rb +319 -0
- data/lib/active_merchant/billing/gateways/openpay.rb +194 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +314 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +834 -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_conex.rb +246 -0
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +277 -0
- data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -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/paybox_direct.rb +188 -0
- data/lib/active_merchant/billing/gateways/payex.rb +412 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +308 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +220 -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 +282 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +129 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +679 -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/payu_in.rb +247 -0
- data/lib/active_merchant/billing/gateways/payway.rb +207 -0
- data/lib/active_merchant/billing/gateways/pin.rb +207 -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/quickbooks.rb +280 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +26 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +188 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +240 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +227 -0
- data/lib/active_merchant/billing/gateways/qvalent.rb +179 -0
- data/lib/active_merchant/billing/gateways/realex.rb +298 -0
- data/lib/active_merchant/billing/gateways/redsys.rb +406 -0
- data/lib/active_merchant/billing/gateways/s5.rb +226 -0
- data/lib/active_merchant/billing/gateways/sage.rb +173 -0
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +89 -0
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +115 -0
- data/lib/active_merchant/billing/gateways/sage/sage_vault.rb +149 -0
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +399 -0
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +143 -0
- data/lib/active_merchant/billing/gateways/secure_net.rb +263 -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 +451 -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 +489 -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 +259 -0
- data/lib/active_merchant/billing/gateways/vanco.rb +280 -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/webpay.rb +97 -0
- data/lib/active_merchant/billing/gateways/wepay.rb +205 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +420 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +331 -0
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +204 -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/network_tokenization_credit_card.rb +24 -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 +92 -0
- data/lib/active_merchant/connection.rb +172 -0
- data/lib/active_merchant/country.rb +332 -0
- data/lib/active_merchant/empty.rb +20 -0
- data/lib/active_merchant/errors.rb +35 -0
- data/lib/active_merchant/network_connection_retries.rb +79 -0
- data/lib/active_merchant/post_data.rb +24 -0
- data/lib/active_merchant/posts_data.rb +84 -0
- data/lib/active_merchant/version.rb +3 -0
- data/lib/activemerchant.rb +1 -0
- data/lib/certs/cacert.pem +3866 -0
- data/lib/support/gateway_support.rb +71 -0
- data/lib/support/outbound_hosts.rb +28 -0
- data/lib/support/ssl_verify.rb +93 -0
- metadata +387 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
module ActiveMerchant
|
|
2
|
+
module Billing
|
|
3
|
+
class PaywayGateway < Gateway
|
|
4
|
+
self.live_url = self.test_url = 'https://ccapi.client.qvalent.com/payway/ccapi'
|
|
5
|
+
|
|
6
|
+
self.supported_countries = [ 'AU' ]
|
|
7
|
+
self.supported_cardtypes = [ :visa, :master, :diners_club, :american_express, :bankcard ]
|
|
8
|
+
self.display_name = 'Pay Way'
|
|
9
|
+
self.homepage_url = 'http://www.payway.com.au'
|
|
10
|
+
self.default_currency = 'AUD'
|
|
11
|
+
self.money_format = :cents
|
|
12
|
+
|
|
13
|
+
SUMMARY_CODES = {
|
|
14
|
+
'0' => 'Approved',
|
|
15
|
+
'1' => 'Declined',
|
|
16
|
+
'2' => 'Erred',
|
|
17
|
+
'3' => 'Rejected'
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
RESPONSE_CODES= {
|
|
21
|
+
'00' => 'Completed Successfully',
|
|
22
|
+
'01' => 'Refer to card issuer',
|
|
23
|
+
'03' => 'Invalid merchant',
|
|
24
|
+
'04' => 'Pick-up card',
|
|
25
|
+
'05' => 'Do not honour',
|
|
26
|
+
'08' => 'Honour only with identification',
|
|
27
|
+
'12' => 'Invalid transaction',
|
|
28
|
+
'13' => 'Invalid amount',
|
|
29
|
+
'14' => 'Invalid card number (no such number)',
|
|
30
|
+
'30' => 'Format error',
|
|
31
|
+
'36' => 'Restricted card',
|
|
32
|
+
'41' => 'Lost card',
|
|
33
|
+
'42' => 'No universal card',
|
|
34
|
+
'43' => 'Stolen card',
|
|
35
|
+
'51' => 'Not sufficient funds',
|
|
36
|
+
'54' => 'Expired card',
|
|
37
|
+
'61' => 'Exceeds withdrawal amount limits',
|
|
38
|
+
'62' => 'Restricted card',
|
|
39
|
+
'65' => 'Exceeds withdrawal frequency limit',
|
|
40
|
+
'91' => 'Issuer or switch is inoperative',
|
|
41
|
+
'92' => 'Financial institution or intermediate network facility cannot be found for routing',
|
|
42
|
+
'94' => 'Duplicate transmission',
|
|
43
|
+
'Q1' => 'Unknown Buyer',
|
|
44
|
+
'Q2' => 'Transaction Pending',
|
|
45
|
+
'Q3' => 'Payment Gateway Connection Error',
|
|
46
|
+
'Q4' => 'Payment Gateway Unavailable',
|
|
47
|
+
'Q5' => 'Invalid Transaction',
|
|
48
|
+
'Q6' => 'Duplicate Transaction - requery to determine status',
|
|
49
|
+
'QA' => 'Invalid parameters or Initialisation failed',
|
|
50
|
+
'QB' => 'Order type not currently supported',
|
|
51
|
+
'QC' => 'Invalid Order Type',
|
|
52
|
+
'QD' => 'Invalid Payment Amount - Payment amount less than minimum/exceeds maximum allowed limit',
|
|
53
|
+
'QE' => 'Internal Error',
|
|
54
|
+
'QF' => 'Transaction Failed',
|
|
55
|
+
'QG' => 'Unknown Customer Order Number',
|
|
56
|
+
'QH' => 'Unknown Customer Username or Password',
|
|
57
|
+
'QI' => 'Transaction incomplete - contact Westpac to confirm reconciliation',
|
|
58
|
+
'QJ' => 'Invalid Client Certificate',
|
|
59
|
+
'QK' => 'Unknown Customer Merchant',
|
|
60
|
+
'QL' => 'Business Group not configured for customer',
|
|
61
|
+
'QM' => 'Payment Instrument not configured for customer',
|
|
62
|
+
'QN' => 'Configuration Error',
|
|
63
|
+
'QO' => 'Missing Payment Instrument',
|
|
64
|
+
'QP' => 'Missing Supplier Account',
|
|
65
|
+
'QQ' => 'Invalid Credit Card Verification Number',
|
|
66
|
+
'QR' => 'Transaction Retry',
|
|
67
|
+
'QS' => 'Transaction Successful',
|
|
68
|
+
'QT' => 'Invalid currency',
|
|
69
|
+
'QU' => 'Unknown Customer IP Address',
|
|
70
|
+
'QV' => 'Invalid Original Order Number specified for Refund, Refund amount exceeds capture amount, or Previous capture was not approved',
|
|
71
|
+
'QW' => 'Invalid Reference Number',
|
|
72
|
+
'QX' => 'Network Error has occurred',
|
|
73
|
+
'QY' => 'Card Type Not Accepted',
|
|
74
|
+
'QZ' => 'Zero value transaction'
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
TRANSACTIONS = {
|
|
78
|
+
:authorize => 'preauth',
|
|
79
|
+
:purchase => 'capture',
|
|
80
|
+
:capture => 'captureWithoutAuth',
|
|
81
|
+
:status => 'query',
|
|
82
|
+
:refund => 'refund',
|
|
83
|
+
:store => 'registerAccount'
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
def initialize(options={})
|
|
87
|
+
@options = options
|
|
88
|
+
|
|
89
|
+
@options[:merchant] ||= 'TEST' if test?
|
|
90
|
+
requires!(options, :username, :password, :merchant, :pem)
|
|
91
|
+
|
|
92
|
+
@options[:eci] ||= 'SSL'
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def authorize(amount, payment_method, options={})
|
|
96
|
+
requires!(options, :order_id)
|
|
97
|
+
|
|
98
|
+
post = {}
|
|
99
|
+
add_payment_method(post, payment_method)
|
|
100
|
+
add_order(post, amount, options)
|
|
101
|
+
commit(:authorize, post)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def capture(amount, authorization, options={})
|
|
105
|
+
requires!(options, :order_id)
|
|
106
|
+
|
|
107
|
+
post = {}
|
|
108
|
+
add_reference(post, authorization)
|
|
109
|
+
add_order(post, amount, options)
|
|
110
|
+
commit(:capture, post)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def purchase(amount, payment_method, options={})
|
|
114
|
+
requires!(options, :order_id)
|
|
115
|
+
|
|
116
|
+
post = {}
|
|
117
|
+
add_payment_method(post, payment_method)
|
|
118
|
+
add_order(post, amount, options)
|
|
119
|
+
commit(:purchase, post)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def refund(amount, authorization, options={})
|
|
123
|
+
requires!(options, :order_id)
|
|
124
|
+
|
|
125
|
+
post = {}
|
|
126
|
+
add_reference(post, authorization)
|
|
127
|
+
add_order(post, amount, options)
|
|
128
|
+
commit(:refund, post)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def store(credit_card, options={})
|
|
132
|
+
requires!(options, :billing_id)
|
|
133
|
+
|
|
134
|
+
post = {}
|
|
135
|
+
add_payment_method(post, credit_card)
|
|
136
|
+
add_payment_method(post, options[:billing_id])
|
|
137
|
+
commit(:store, post)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def status(options={})
|
|
141
|
+
requires!(options, :order_id)
|
|
142
|
+
|
|
143
|
+
commit(:status, 'customer.orderNumber' => options[:order_id])
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
private
|
|
147
|
+
|
|
148
|
+
def add_payment_method(post, payment_method)
|
|
149
|
+
if payment_method.respond_to?(:number)
|
|
150
|
+
post['card.cardHolderName'] = "#{payment_method.first_name} #{payment_method.last_name}"
|
|
151
|
+
post['card.PAN'] = payment_method.number
|
|
152
|
+
post['card.CVN'] = payment_method.verification_value
|
|
153
|
+
post['card.expiryYear'] = payment_method.year.to_s[-2,2]
|
|
154
|
+
post['card.expiryMonth'] = sprintf('%02d', payment_method.month)
|
|
155
|
+
else
|
|
156
|
+
post['customer.customerReferenceNumber'] = payment_method
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def add_reference(post, reference)
|
|
161
|
+
post['customer.originalOrderNumber'] = reference
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def add_order(post, amount, options)
|
|
165
|
+
post['order.ECI'] = @options[:eci]
|
|
166
|
+
post['order.amount'] = amount
|
|
167
|
+
post['card.currency'] = (options[:currency] || currency(amount))
|
|
168
|
+
post['customer.orderNumber'] = options[:order_id][0...20]
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def add_auth(post)
|
|
172
|
+
post['customer.username'] = @options[:username]
|
|
173
|
+
post['customer.password'] = @options[:password]
|
|
174
|
+
post['customer.merchant'] = @options[:merchant]
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
# Creates the request and returns the summarized result
|
|
178
|
+
def commit(action, post)
|
|
179
|
+
add_auth(post)
|
|
180
|
+
post.merge!('order.type' => TRANSACTIONS[action])
|
|
181
|
+
|
|
182
|
+
request = post.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join("&")
|
|
183
|
+
response = ssl_post(self.live_url, request)
|
|
184
|
+
|
|
185
|
+
params = {}
|
|
186
|
+
CGI.parse(response).each_pair do |key, value|
|
|
187
|
+
actual_key = key.split(".").last
|
|
188
|
+
params[actual_key.underscore.to_sym] = value[0]
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
message = "#{SUMMARY_CODES[params[:summary_code]]} - #{RESPONSE_CODES[params[:response_code]]}"
|
|
192
|
+
|
|
193
|
+
success = (params[:summary_code] ? (params[:summary_code] == "0") : (params[:response_code] == "00"))
|
|
194
|
+
|
|
195
|
+
Response.new(success, message, params,
|
|
196
|
+
:test => (@options[:merchant].to_s == "TEST"),
|
|
197
|
+
:authorization => post[:order_number]
|
|
198
|
+
)
|
|
199
|
+
rescue ActiveMerchant::ResponseError => e
|
|
200
|
+
raise unless e.response.code == '403'
|
|
201
|
+
return Response.new(false, "Invalid credentials", {}, :test => test?)
|
|
202
|
+
rescue ActiveMerchant::ClientCertificateError
|
|
203
|
+
return Response.new(false, "Invalid certificate", {}, :test => test?)
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
end
|
|
@@ -0,0 +1,207 @@
|
|
|
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 only part of the original
|
|
63
|
+
# authorization is currently not supported.
|
|
64
|
+
def capture(money, token, options = {})
|
|
65
|
+
commit(:put, "charges/#{CGI.escape(token)}/capture", { :amount => amount(money) }, 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
|
+
raw_response = ssl_request(method, url, post_data(params), headers(options))
|
|
152
|
+
body = parse(raw_response)
|
|
153
|
+
rescue ResponseError => e
|
|
154
|
+
body = parse(e.response.body)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
if body["response"]
|
|
158
|
+
success_response(body)
|
|
159
|
+
elsif body["error"]
|
|
160
|
+
error_response(body)
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
rescue JSON::ParserError
|
|
164
|
+
return unparsable_response(raw_response)
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def success_response(body)
|
|
168
|
+
response = body["response"]
|
|
169
|
+
Response.new(
|
|
170
|
+
true,
|
|
171
|
+
response['status_message'],
|
|
172
|
+
body,
|
|
173
|
+
:authorization => token(response),
|
|
174
|
+
:test => test?
|
|
175
|
+
)
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
def error_response(body)
|
|
179
|
+
Response.new(
|
|
180
|
+
false,
|
|
181
|
+
body['error_description'],
|
|
182
|
+
body,
|
|
183
|
+
:authorization => nil,
|
|
184
|
+
:test => test?
|
|
185
|
+
)
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def unparsable_response(raw_response)
|
|
189
|
+
message = "Invalid JSON response received from Pin Payments. Please contact support@pin.net.au if you continue to receive this message."
|
|
190
|
+
message += " (The raw response returned by the API was #{raw_response.inspect})"
|
|
191
|
+
return Response.new(false, message)
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def token(response)
|
|
195
|
+
response['token']
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
def parse(body)
|
|
199
|
+
JSON.parse(body)
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def post_data(parameters = {})
|
|
203
|
+
parameters.to_json
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
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
|