activemerchant 1.56.0 → 1.66.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +331 -0
- data/README.md +9 -9
- data/lib/active_merchant/billing/check.rb +3 -0
- data/lib/active_merchant/billing/credit_card.rb +8 -3
- data/lib/active_merchant/billing/credit_card_methods.rb +41 -1
- data/lib/active_merchant/billing/gateway.rb +14 -6
- data/lib/active_merchant/billing/gateways/adyen.rb +228 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +157 -44
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +7 -4
- data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +283 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +68 -2
- data/lib/active_merchant/billing/gateways/blue_pay.rb +2 -2
- data/lib/active_merchant/billing/gateways/blue_snap.rb +348 -0
- data/lib/active_merchant/billing/gateways/bpoint.rb +1 -1
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +58 -20
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +37 -8
- data/lib/active_merchant/billing/gateways/card_stream.rb +161 -40
- data/lib/active_merchant/billing/gateways/cashnet.rb +1 -0
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +5 -2
- data/lib/active_merchant/billing/gateways/citrus_pay.rb +24 -0
- data/lib/active_merchant/billing/gateways/clearhaus.rb +24 -40
- data/lib/active_merchant/billing/gateways/conekta.rb +6 -1
- data/lib/active_merchant/billing/gateways/creditcall.rb +1 -1
- data/lib/active_merchant/billing/gateways/credorax.rb +310 -0
- data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +80 -64
- data/lib/active_merchant/billing/gateways/data_cash.rb +10 -304
- data/lib/active_merchant/billing/gateways/digitzs.rb +292 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +40 -26
- data/lib/active_merchant/billing/gateways/element.rb +356 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +16 -2
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +6 -1
- data/lib/active_merchant/billing/gateways/forte.rb +10 -2
- data/lib/active_merchant/billing/gateways/global_collect.rb +311 -0
- data/lib/active_merchant/billing/gateways/global_transport.rb +1 -0
- data/lib/active_merchant/billing/gateways/iats_payments.rb +13 -0
- data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
- data/lib/active_merchant/billing/gateways/iveri.rb +251 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +33 -19
- data/lib/active_merchant/billing/gateways/kushki.rb +217 -0
- data/lib/active_merchant/billing/gateways/latitude19.rb +416 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +2 -0
- data/lib/active_merchant/billing/gateways/litle.rb +29 -13
- data/lib/active_merchant/billing/gateways/mastercard.rb +268 -0
- data/lib/active_merchant/billing/gateways/maxipago.rb +145 -122
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +15 -1
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +10 -7
- data/lib/active_merchant/billing/gateways/mercury.rb +13 -5
- data/lib/active_merchant/billing/gateways/metrics_global.rb +1 -1
- data/lib/active_merchant/billing/gateways/migs.rb +23 -1
- data/lib/active_merchant/billing/gateways/monei.rb +1 -1
- data/lib/active_merchant/billing/gateways/moneris.rb +21 -1
- data/lib/active_merchant/billing/gateways/nab_transact.rb +12 -0
- data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +165 -0
- data/lib/active_merchant/billing/gateways/netbanx.rb +245 -0
- data/lib/active_merchant/billing/gateways/nmi.rb +30 -9
- data/lib/active_merchant/billing/gateways/omise.rb +9 -5
- data/lib/active_merchant/billing/gateways/openpay.rb +10 -1
- data/lib/active_merchant/billing/gateways/opp.rb +362 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +28 -7
- data/lib/active_merchant/billing/gateways/pagarme.rb +248 -0
- data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +190 -0
- data/lib/active_merchant/billing/gateways/payeezy.rb +61 -12
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -1
- data/lib/active_merchant/billing/gateways/payflow.rb +6 -0
- data/lib/active_merchant/billing/gateways/payment_express.rb +1 -1
- data/lib/active_merchant/billing/gateways/paymill.rb +29 -11
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +1 -1
- data/lib/active_merchant/billing/gateways/paypal_express.rb +1 -6
- data/lib/active_merchant/billing/gateways/payu_in.rb +3 -2
- data/lib/active_merchant/billing/gateways/payu_latam.rb +402 -0
- data/lib/active_merchant/billing/gateways/pin.rb +6 -3
- data/lib/active_merchant/billing/gateways/pro_pay.rb +326 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +3 -3
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +1 -1
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +0 -2
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +1 -1
- data/lib/active_merchant/billing/gateways/quickpay.rb +3 -3
- data/lib/active_merchant/billing/gateways/qvalent.rb +44 -1
- data/lib/active_merchant/billing/gateways/redsys.rb +3 -0
- data/lib/active_merchant/billing/gateways/s5.rb +8 -5
- data/lib/active_merchant/billing/gateways/safe_charge.rb +220 -0
- data/lib/active_merchant/billing/gateways/sage.rb +397 -128
- data/lib/active_merchant/billing/gateways/sage_pay.rb +45 -20
- data/lib/active_merchant/billing/gateways/secure_net.rb +0 -5
- data/lib/active_merchant/billing/gateways/secure_pay.rb +1 -1
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +12 -0
- data/lib/active_merchant/billing/gateways/securion_pay.rb +46 -17
- data/lib/active_merchant/billing/gateways/stripe.rb +125 -29
- data/lib/active_merchant/billing/gateways/telr.rb +275 -0
- data/lib/active_merchant/billing/gateways/tns.rb +13 -222
- data/lib/active_merchant/billing/gateways/trans_first.rb +40 -16
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +606 -0
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +114 -9
- data/lib/active_merchant/billing/gateways/vanco.rb +14 -10
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +209 -0
- data/lib/active_merchant/billing/gateways/wepay.rb +73 -38
- data/lib/active_merchant/billing/gateways/wirecard.rb +1 -0
- data/lib/active_merchant/billing/gateways/world_net.rb +344 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +48 -16
- data/lib/active_merchant/billing/network_tokenization_credit_card.rb +15 -0
- data/lib/active_merchant/country.rb +6 -4
- data/lib/active_merchant/posts_data.rb +1 -1
- data/lib/active_merchant/version.rb +1 -1
- metadata +32 -13
- data/lib/active_merchant/billing/gateways/app55.rb +0 -176
- data/lib/active_merchant/billing/gateways/barclays_epdq.rb +0 -314
- data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -278
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +0 -89
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +0 -115
- data/lib/active_merchant/billing/gateways/sage/sage_vault.rb +0 -149
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +0 -97
@@ -30,7 +30,7 @@ module ActiveMerchant #:nodoc:
|
|
30
30
|
def purchase(amount, payment_method, options={})
|
31
31
|
post = {}
|
32
32
|
add_invoice(post, amount, options)
|
33
|
-
add_payment_method(post, payment_method)
|
33
|
+
add_payment_method(post, payment_method, options)
|
34
34
|
add_customer_data(post, options)
|
35
35
|
add_merchant_defined_fields(post, options)
|
36
36
|
|
@@ -40,7 +40,7 @@ module ActiveMerchant #:nodoc:
|
|
40
40
|
def authorize(amount, payment_method, options={})
|
41
41
|
post = {}
|
42
42
|
add_invoice(post, amount, options)
|
43
|
-
add_payment_method(post, payment_method)
|
43
|
+
add_payment_method(post, payment_method, options)
|
44
44
|
add_customer_data(post, options)
|
45
45
|
add_merchant_defined_fields(post, options)
|
46
46
|
|
@@ -59,6 +59,7 @@ module ActiveMerchant #:nodoc:
|
|
59
59
|
def void(authorization, options={})
|
60
60
|
post = {}
|
61
61
|
add_reference(post, authorization)
|
62
|
+
add_payment_type(post, authorization)
|
62
63
|
|
63
64
|
commit("void", post)
|
64
65
|
end
|
@@ -67,6 +68,7 @@ module ActiveMerchant #:nodoc:
|
|
67
68
|
post = {}
|
68
69
|
add_invoice(post, amount, options)
|
69
70
|
add_reference(post, authorization)
|
71
|
+
add_payment_type(post, authorization)
|
70
72
|
|
71
73
|
commit("refund", post)
|
72
74
|
end
|
@@ -74,7 +76,7 @@ module ActiveMerchant #:nodoc:
|
|
74
76
|
def credit(amount, payment_method, options={})
|
75
77
|
post = {}
|
76
78
|
add_invoice(post, amount, options)
|
77
|
-
add_payment_method(post, payment_method)
|
79
|
+
add_payment_method(post, payment_method, options)
|
78
80
|
add_customer_data(post, options)
|
79
81
|
|
80
82
|
commit("credit", post)
|
@@ -82,7 +84,7 @@ module ActiveMerchant #:nodoc:
|
|
82
84
|
|
83
85
|
def verify(payment_method, options={})
|
84
86
|
post = {}
|
85
|
-
add_payment_method(post, payment_method)
|
87
|
+
add_payment_method(post, payment_method, options)
|
86
88
|
add_customer_data(post, options)
|
87
89
|
add_merchant_defined_fields(post, options)
|
88
90
|
|
@@ -92,13 +94,18 @@ module ActiveMerchant #:nodoc:
|
|
92
94
|
def store(payment_method, options = {})
|
93
95
|
post = {}
|
94
96
|
add_invoice(post, nil, options)
|
95
|
-
add_payment_method(post, payment_method)
|
97
|
+
add_payment_method(post, payment_method, options)
|
96
98
|
add_customer_data(post, options)
|
97
99
|
add_merchant_defined_fields(post, options)
|
98
100
|
|
99
101
|
commit("add_customer", post)
|
100
102
|
end
|
101
103
|
|
104
|
+
def verify_credentials
|
105
|
+
response = void("0")
|
106
|
+
response.message != "Authentication Failed"
|
107
|
+
end
|
108
|
+
|
102
109
|
def supports_scrubbing?
|
103
110
|
true
|
104
111
|
end
|
@@ -125,7 +132,7 @@ module ActiveMerchant #:nodoc:
|
|
125
132
|
end
|
126
133
|
end
|
127
134
|
|
128
|
-
def add_payment_method(post, payment_method)
|
135
|
+
def add_payment_method(post, payment_method, options)
|
129
136
|
if(payment_method.is_a?(String))
|
130
137
|
post[:customer_vault_id] = payment_method
|
131
138
|
elsif(card_brand(payment_method) == 'check')
|
@@ -135,7 +142,7 @@ module ActiveMerchant #:nodoc:
|
|
135
142
|
post[:checkaccount] = payment_method.account_number
|
136
143
|
post[:account_holder_type] = payment_method.account_holder_type
|
137
144
|
post[:account_type] = payment_method.account_type
|
138
|
-
post[:sec_code] = 'WEB'
|
145
|
+
post[:sec_code] = options[:sec_code] || 'WEB'
|
139
146
|
else
|
140
147
|
post[:payment] = 'creditcard'
|
141
148
|
post[:firstname] = payment_method.first_name
|
@@ -182,7 +189,13 @@ module ActiveMerchant #:nodoc:
|
|
182
189
|
end
|
183
190
|
|
184
191
|
def add_reference(post, authorization)
|
185
|
-
|
192
|
+
transaction_id, _ = split_authorization(authorization)
|
193
|
+
post[:transactionid] = transaction_id
|
194
|
+
end
|
195
|
+
|
196
|
+
def add_payment_type(post, authorization)
|
197
|
+
_, payment_type = split_authorization(authorization)
|
198
|
+
post[:payment] = payment_type if payment_type
|
186
199
|
end
|
187
200
|
|
188
201
|
def exp_date(payment_method)
|
@@ -203,13 +216,21 @@ module ActiveMerchant #:nodoc:
|
|
203
216
|
succeeded,
|
204
217
|
message_from(succeeded, response),
|
205
218
|
response,
|
206
|
-
authorization: response[:
|
219
|
+
authorization: authorization_from(response, params[:payment]),
|
207
220
|
avs_result: AVSResult.new(code: response[:avsresponse]),
|
208
221
|
cvv_result: CVVResult.new(response[:cvvresponse]),
|
209
222
|
test: test?
|
210
223
|
)
|
211
224
|
end
|
212
225
|
|
226
|
+
def authorization_from(response, payment_type)
|
227
|
+
[ response[:transactionid], payment_type ].join("#")
|
228
|
+
end
|
229
|
+
|
230
|
+
def split_authorization(authorization)
|
231
|
+
authorization.split("#")
|
232
|
+
end
|
233
|
+
|
213
234
|
def headers
|
214
235
|
{ "Content-Type" => "application/x-www-form-urlencoded;charset=UTF-8" }
|
215
236
|
end
|
@@ -14,18 +14,20 @@ module ActiveMerchant #:nodoc:
|
|
14
14
|
self.live_url = self.test_url = API_URL
|
15
15
|
|
16
16
|
# Currency supported by Omise
|
17
|
-
# * Thai Baht with Satang,
|
17
|
+
# * Thai Baht with Satang, 50000 (THB500.00)
|
18
|
+
# * Japanese Yen, 500 (JPY500)
|
18
19
|
self.default_currency = 'THB'
|
19
20
|
self.money_format = :cents
|
20
21
|
|
21
22
|
#Country supported by Omise
|
22
23
|
# * Thailand
|
23
|
-
self.supported_countries = %w( TH )
|
24
|
+
self.supported_countries = %w( TH JP )
|
24
25
|
|
25
26
|
# Credit cards supported by Omise
|
26
27
|
# * VISA
|
27
28
|
# * MasterCard
|
28
|
-
|
29
|
+
# * JCB
|
30
|
+
self.supported_cardtypes = [:visa, :master, :jcb]
|
29
31
|
|
30
32
|
# Omise main page
|
31
33
|
self.homepage_url = 'https://www.omise.co/'
|
@@ -39,8 +41,10 @@ module ActiveMerchant #:nodoc:
|
|
39
41
|
#
|
40
42
|
# ==== Options
|
41
43
|
#
|
42
|
-
# * <tt>:public_key</tt>
|
43
|
-
# * <tt>:secret_key</tt>
|
44
|
+
# * <tt>:public_key</tt> -- Omise's public key (REQUIRED).
|
45
|
+
# * <tt>:secret_key</tt> -- Omise's secret key (REQUIRED).
|
46
|
+
# * <tt>:api_version</tt> -- Omise's API Version (OPTIONAL), default version is '2014-07-27'
|
47
|
+
# See version at page https://dashboard.omise.co/api-version/edit
|
44
48
|
|
45
49
|
def initialize(options={})
|
46
50
|
requires!(options, :public_key, :secret_key)
|
@@ -52,6 +52,13 @@ module ActiveMerchant #:nodoc:
|
|
52
52
|
commit(:post, "charges/#{CGI.escape(identification)}/refund", post, options)
|
53
53
|
end
|
54
54
|
|
55
|
+
def verify(credit_card, options = {})
|
56
|
+
MultiResponse.run(:use_first_response) do |r|
|
57
|
+
r.process { authorize(100, credit_card, options) }
|
58
|
+
r.process(:ignore_result) { void(r.authorization, options) }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
55
62
|
def store(creditcard, options = {})
|
56
63
|
card_params = {}
|
57
64
|
add_creditcard(card_params, creditcard, options)
|
@@ -105,6 +112,8 @@ module ActiveMerchant #:nodoc:
|
|
105
112
|
post[:description] = options[:description]
|
106
113
|
post[:order_id] = options[:order_id]
|
107
114
|
post[:device_session_id] = options[:device_session_id]
|
115
|
+
post[:currency] = (options[:currency] || currency(money)).upcase
|
116
|
+
post[:use_card_points] = options[:use_card_points] if options[:use_card_points]
|
108
117
|
add_creditcard(post, creditcard, options)
|
109
118
|
post
|
110
119
|
end
|
@@ -143,7 +152,7 @@ module ActiveMerchant #:nodoc:
|
|
143
152
|
def headers(options = {})
|
144
153
|
{
|
145
154
|
"Content-Type" => "application/json",
|
146
|
-
"Authorization" => "Basic " + Base64.
|
155
|
+
"Authorization" => "Basic " + Base64.strict_encode64(@api_key.to_s + ":").strip,
|
147
156
|
"User-Agent" => "Openpay/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
|
148
157
|
"X-Openpay-Client-User-Agent" => user_agent
|
149
158
|
}
|
@@ -0,0 +1,362 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class OppGateway < Gateway
|
4
|
+
# = Open Payment Platform
|
5
|
+
#
|
6
|
+
# The Open Payment Platform includes a powerful omni-channel transaction processing API,
|
7
|
+
# enabling you to quickly and flexibly build new applications and services on the platform.
|
8
|
+
#
|
9
|
+
# This plugin enables connectivity to the Open Payment Platform for activemerchant.
|
10
|
+
#
|
11
|
+
# For any questions or comments please contact support@payon.com
|
12
|
+
#
|
13
|
+
# == Usage
|
14
|
+
#
|
15
|
+
# gateway = ActiveMerchant::Billing::OppGateway.new(
|
16
|
+
# user_id: 'merchant user id',
|
17
|
+
# password: 'password',
|
18
|
+
# entity_id: 'entity id',
|
19
|
+
# )
|
20
|
+
#
|
21
|
+
# # set up credit card object as in main ActiveMerchant example
|
22
|
+
# creditcard = ActiveMerchant::Billing::CreditCard.new(
|
23
|
+
# :type => 'visa',
|
24
|
+
# :number => '4242424242424242',
|
25
|
+
# :month => 8,
|
26
|
+
# :year => 2009,
|
27
|
+
# :first_name => 'Bob',
|
28
|
+
# :last_name => 'Bobsen'
|
29
|
+
# :verification_value: '123')
|
30
|
+
#
|
31
|
+
# # Request: complete example, including address, billing address, shipping address
|
32
|
+
# complete_request_options = {
|
33
|
+
# order_id: "your merchant/shop order id", # alternative is to set merchantInvoiceId
|
34
|
+
# merchant_transaction_id: "your merchant/shop transaction id",
|
35
|
+
# address: address,
|
36
|
+
# description: 'Store Purchase - Books',
|
37
|
+
# risk_workflow: false,
|
38
|
+
# test_mode: 'EXTERNAL' # or 'INTERNAL', valid only for test system
|
39
|
+
# create_registration: false, # payment details will be stored on the server an latter can be referenced
|
40
|
+
#
|
41
|
+
# billing_address: {
|
42
|
+
# address1: '123 Test Street',
|
43
|
+
# city: 'Test',
|
44
|
+
# state: 'TE',
|
45
|
+
# zip: 'AB12CD',
|
46
|
+
# country: 'GB',
|
47
|
+
# },
|
48
|
+
# shipping_address: {
|
49
|
+
# name: 'Muton DeMicelis',
|
50
|
+
# address1: 'My Street On Upiter, Apt 3.14/2.78',
|
51
|
+
# city: 'Munich',
|
52
|
+
# state: 'Bov',
|
53
|
+
# zip: '81675',
|
54
|
+
# country: 'DE',
|
55
|
+
# },
|
56
|
+
# customer: {
|
57
|
+
# merchant_customer_id: "your merchant/customer id",
|
58
|
+
# givenname: 'Jane',
|
59
|
+
# surname: 'Jones',
|
60
|
+
# birth_date: '1965-05-01',
|
61
|
+
# phone: '(?!?)555-5555',
|
62
|
+
# mobile: '(?!?)234-23423',
|
63
|
+
# email: 'jane@jones.com',
|
64
|
+
# company_name: 'JJ Ltd.',
|
65
|
+
# identification_doctype: 'PASSPORT',
|
66
|
+
# identification_docid: 'FakeID2342431234123',
|
67
|
+
# ip: 101.102.103.104,
|
68
|
+
# },
|
69
|
+
# }
|
70
|
+
#
|
71
|
+
# # Request: minimal example
|
72
|
+
# minimal_request_options = {
|
73
|
+
# order_id: "your merchant/shop order id", # alternative is to set merchantInvoiceId
|
74
|
+
# description: 'Store Purchase - Books',
|
75
|
+
# }
|
76
|
+
#
|
77
|
+
# options =
|
78
|
+
# # run request
|
79
|
+
# response = gateway.purchase(754, creditcard, options) # charge 7,54 EUR
|
80
|
+
#
|
81
|
+
# response.success? # Check whether the transaction was successful
|
82
|
+
# response.error_code # Retrieve the error message - it's mapped to Gateway::STANDARD_ERROR_CODE
|
83
|
+
# response.message # Retrieve the message returned by opp
|
84
|
+
# response.authorization # Retrieve the unique transaction ID returned by opp
|
85
|
+
# response.params['result']['code'] # Retrieve original return code returned by opp server
|
86
|
+
#
|
87
|
+
# == Errors
|
88
|
+
# If transaction is not successful, response.error_code contains mapped to Gateway::STANDARD_ERROR_CODE error message.
|
89
|
+
# Complete list of opp error codes can be viewed on https://docs.oppwa.com/
|
90
|
+
# Because this list is much bigger than Gateway::STANDARD_ERROR_CODE, only fraction is mapped to Gateway::STANDARD_ERROR_CODE.
|
91
|
+
# All other codes are mapped as Gateway::STANDARD_ERROR_CODE[:processing_error], so if this is the case,
|
92
|
+
# you may check the original result code from OPP that can be found in response.params['result']['code']
|
93
|
+
#
|
94
|
+
# == Special features
|
95
|
+
# For purchase method risk check can be forced when options[:risk_workflow] = true
|
96
|
+
# This will split (on OPP server side) the transaction into two separate transactions: authorize and capture,
|
97
|
+
# but capture will be executed only if risk checks are successful.
|
98
|
+
#
|
99
|
+
# For testing you may use the test account details listed fixtures.yml under opp. It is important to note that there are two test modes available:
|
100
|
+
# options[:test_mode]='EXTERNAL' causes test transactions to be forwarded to the processor's test system for 'end-to-end' testing
|
101
|
+
# options[:test_mode]='INTERNAL' causes transactions to be sent to opp simulators, which is useful when switching to the live endpoint for connectivity testing.
|
102
|
+
# If no test_mode parameter is sent, test_mode=INTERNAL is the default behaviour.
|
103
|
+
#
|
104
|
+
# Billing Address, Shipping Address, Custom Parameters are supported as described under https://docs.oppwa.com/parameters
|
105
|
+
# See complete example above for details.
|
106
|
+
#
|
107
|
+
# == Tokenization
|
108
|
+
# When create_registration is set to true, the payment details will be stored and a token will be returned in registrationId response field,
|
109
|
+
# which can subsequently be used to reference the stored payment.
|
110
|
+
|
111
|
+
self.test_url = 'https://test.oppwa.com/v1/payments'
|
112
|
+
self.live_url = 'https://oppwa.com/v1/payments'
|
113
|
+
|
114
|
+
self.supported_countries = %w(AD AI AG AR AU AT BS BB BE BZ BM BR BN BG CA HR CY CZ DK DM EE FI FR DE GR GD GY HK HU IS IN IL IT JP LV LI LT LU MY MT MX MC MS NL PA PL PT KN LC MF VC SM SG SK SI ZA ES SR SE CH TR GB US UY)
|
115
|
+
self.default_currency = 'EUR'
|
116
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :discover, :jcb, :maestro, :dankort]
|
117
|
+
|
118
|
+
self.homepage_url = 'https://docs.oppwa.com'
|
119
|
+
self.display_name = 'Open Payment Platform'
|
120
|
+
|
121
|
+
def initialize(options={})
|
122
|
+
requires!(options, :user_id, :password, :entity_id)
|
123
|
+
super
|
124
|
+
end
|
125
|
+
|
126
|
+
def purchase(money, payment, options={})
|
127
|
+
# debit
|
128
|
+
execute_dbpa(options[:risk_workflow] ? 'PA.CP': 'DB',
|
129
|
+
money, payment, options)
|
130
|
+
end
|
131
|
+
|
132
|
+
def authorize(money, payment, options={})
|
133
|
+
# preauthorization PA
|
134
|
+
execute_dbpa('PA', money, payment, options)
|
135
|
+
end
|
136
|
+
|
137
|
+
def capture(money, authorization, options={})
|
138
|
+
# capture CP
|
139
|
+
execute_referencing('CP', money, authorization, options)
|
140
|
+
end
|
141
|
+
|
142
|
+
def refund(money, authorization, options={})
|
143
|
+
# refund RF
|
144
|
+
execute_referencing('RF', money, authorization, options)
|
145
|
+
end
|
146
|
+
|
147
|
+
def void(authorization, options={})
|
148
|
+
# reversal RV
|
149
|
+
execute_referencing('RV', nil, authorization, options)
|
150
|
+
end
|
151
|
+
|
152
|
+
def verify(credit_card, options={})
|
153
|
+
MultiResponse.run(:use_first_response) do |r|
|
154
|
+
r.process { authorize(100, credit_card, options) }
|
155
|
+
r.process(:ignore_result) { void(r.authorization, options) }
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def supports_scrubbing?
|
160
|
+
true
|
161
|
+
end
|
162
|
+
|
163
|
+
def scrub(transcript)
|
164
|
+
transcript.
|
165
|
+
gsub(%r((authentication\.password=)\w+), '\1[FILTERED]').
|
166
|
+
gsub(%r((authentication\.userId=)\w+), '\1[FILTERED]').
|
167
|
+
gsub(%r((authentication\.entityId=)\w+), '\1[FILTERED]').
|
168
|
+
gsub(%r((card\.number=)\d+), '\1[FILTERED]').
|
169
|
+
gsub(%r((card\.cvv=)\d+), '\1[FILTERED]')
|
170
|
+
end
|
171
|
+
|
172
|
+
private
|
173
|
+
|
174
|
+
def execute_dbpa(txtype, money, payment, options)
|
175
|
+
post = {}
|
176
|
+
post[:paymentType] = txtype
|
177
|
+
add_invoice(post, money, options)
|
178
|
+
add_payment_method(post, payment, options)
|
179
|
+
add_address(post, options)
|
180
|
+
add_customer_data(post, options)
|
181
|
+
add_options(post, options)
|
182
|
+
commit(post, nil, options)
|
183
|
+
end
|
184
|
+
|
185
|
+
def execute_referencing(txtype, money, authorization, options)
|
186
|
+
post = {}
|
187
|
+
post[:paymentType] = txtype
|
188
|
+
add_invoice(post, money, options)
|
189
|
+
commit(post, authorization, options)
|
190
|
+
end
|
191
|
+
|
192
|
+
def add_authentication(post)
|
193
|
+
post[:authentication] = { entityId: @options[:entity_id], password: @options[:password], userId: @options[:user_id]}
|
194
|
+
end
|
195
|
+
|
196
|
+
def add_customer_data(post, options)
|
197
|
+
if options[:customer]
|
198
|
+
post[:customer] = {
|
199
|
+
merchantCustomerId: options[:customer][:merchant_customer_id],
|
200
|
+
givenName: options[:customer][:givenname],
|
201
|
+
surname: options[:customer][:surname],
|
202
|
+
birthDate: options[:customer][:birth_date],
|
203
|
+
phone: options[:customer][:phone],
|
204
|
+
mobile: options[:customer][:mobile],
|
205
|
+
email: options[:customer][:email],
|
206
|
+
companyName: options[:customer][:company_name],
|
207
|
+
identificationDocType: options[:customer][:identification_doctype],
|
208
|
+
identificationDocId: options[:customer][:identification_docid],
|
209
|
+
ip: options[:customer][:ip],
|
210
|
+
}
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
def add_address(post, options)
|
215
|
+
if billing_address = options[:billing_address]
|
216
|
+
address(post, billing_address, 'billing')
|
217
|
+
end
|
218
|
+
if shipping_address = options[:shipping_address]
|
219
|
+
address(post, billing_address, 'shipping')
|
220
|
+
if shipping_address[:name]
|
221
|
+
firstname, lastname = shipping_address[:name].split(' ')
|
222
|
+
post[:shipping] = { givenName: firstname, surname: lastname }
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
def address(post, address, prefix)
|
228
|
+
post[prefix] = {
|
229
|
+
street1: address[:address1],
|
230
|
+
street2: address[:address2],
|
231
|
+
city: address[:city],
|
232
|
+
state: address[:state],
|
233
|
+
postcode: address[:zip],
|
234
|
+
country: address[:country],
|
235
|
+
}
|
236
|
+
end
|
237
|
+
|
238
|
+
def add_invoice(post, money, options)
|
239
|
+
post[:amount] = amount(money)
|
240
|
+
post[:currency] = (currency(money) || @options[:currency]) if 'RV'!=(post[:paymentType])
|
241
|
+
post[:descriptor] = options[:description] || options[:descriptor]
|
242
|
+
post[:merchantInvoiceId] = options[:merchantInvoiceId] || options[:order_id]
|
243
|
+
post[:merchantTransactionId] = options[:merchant_transaction_id]
|
244
|
+
end
|
245
|
+
|
246
|
+
def add_payment_method(post, payment, options)
|
247
|
+
if options[:registrationId]
|
248
|
+
#post[:recurringType] = 'REPEATED'
|
249
|
+
post[:card] = {
|
250
|
+
cvv: payment.verification_value,
|
251
|
+
}
|
252
|
+
else
|
253
|
+
post[:paymentBrand] = payment.brand.upcase
|
254
|
+
post[:card] = {
|
255
|
+
holder: payment.name,
|
256
|
+
number: payment.number,
|
257
|
+
expiryMonth: "%02d" % payment.month,
|
258
|
+
expiryYear: payment.year,
|
259
|
+
cvv: payment.verification_value,
|
260
|
+
}
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
def add_options(post, options)
|
265
|
+
post[:createRegistration] = options[:create_registration] if options[:create_registration] && !options[:registrationId]
|
266
|
+
post[:testMode] = options[:test_mode] if test? && options[:test_mode]
|
267
|
+
options.each {|key, value| post[key] = value if key.to_s.match('customParameters\[[a-zA-Z0-9\._]{3,64}\]') }
|
268
|
+
post['customParameters[SHOPPER_pluginId]'] = 'activemerchant'
|
269
|
+
end
|
270
|
+
|
271
|
+
def build_url(url, authorization, options)
|
272
|
+
if options[:registrationId]
|
273
|
+
"#{url.gsub(/payments/, 'registrations')}/#{options[:registrationId]}/payments"
|
274
|
+
elsif authorization
|
275
|
+
"#{url}/#{authorization}"
|
276
|
+
else
|
277
|
+
url
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
def commit(post, authorization, options)
|
282
|
+
url = (test? ? test_url : live_url)
|
283
|
+
add_authentication(post)
|
284
|
+
post = flatten_hash(post)
|
285
|
+
|
286
|
+
url = build_url(url, authorization, options)
|
287
|
+
raw_response = raw_ssl_request(:post, url,
|
288
|
+
post.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&"),
|
289
|
+
"Content-Type" => "application/x-www-form-urlencoded;charset=UTF-8")
|
290
|
+
|
291
|
+
success = success_from(raw_response)
|
292
|
+
response = raw_response.body
|
293
|
+
begin
|
294
|
+
response = JSON.parse(response)
|
295
|
+
rescue JSON::ParserError
|
296
|
+
response = json_error(response)
|
297
|
+
end
|
298
|
+
|
299
|
+
Response.new(
|
300
|
+
success,
|
301
|
+
message_from(response),
|
302
|
+
response,
|
303
|
+
authorization: authorization_from(response),
|
304
|
+
test: test?,
|
305
|
+
error_code: success ? nil : error_code_from(response),
|
306
|
+
)
|
307
|
+
end
|
308
|
+
|
309
|
+
def success_from(raw_response)
|
310
|
+
raw_response.code.to_i.between?(200,299)
|
311
|
+
end
|
312
|
+
|
313
|
+
def message_from(response)
|
314
|
+
response['result']['description']
|
315
|
+
end
|
316
|
+
|
317
|
+
def authorization_from(response)
|
318
|
+
response['id']
|
319
|
+
end
|
320
|
+
|
321
|
+
def error_code_from(response)
|
322
|
+
case response['result']['code']
|
323
|
+
when '100.100.101'
|
324
|
+
Gateway::STANDARD_ERROR_CODE[:incorrect_number]
|
325
|
+
when '100.400.317'
|
326
|
+
Gateway::STANDARD_ERROR_CODE[:invalid_number]
|
327
|
+
when '100.100.600', '100.100.601', '800.100.153', '800.100.192'
|
328
|
+
Gateway::STANDARD_ERROR_CODE[:invalid_cvc]
|
329
|
+
when '100.100.303'
|
330
|
+
Gateway::STANDARD_ERROR_CODE[:expired_card]
|
331
|
+
when '100.800.200', '100.800.201', '100.800.202', '800.800.202'
|
332
|
+
Gateway::STANDARD_ERROR_CODE[:incorrect_zip]
|
333
|
+
when '100.400.000', '100.400.086', '100.400.305', '800.400.150'
|
334
|
+
Gateway::STANDARD_ERROR_CODE[:incorrect_address]
|
335
|
+
when '800.100.159'
|
336
|
+
Gateway::STANDARD_ERROR_CODE[:pickup_card]
|
337
|
+
when '800.100.151', '800.100.158', '800.100.160'
|
338
|
+
Gateway::STANDARD_ERROR_CODE[:card_declined]
|
339
|
+
else
|
340
|
+
Gateway::STANDARD_ERROR_CODE[:processing_error]
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
344
|
+
def json_error(raw_response)
|
345
|
+
message = "Invalid response received #{raw_response.inspect}"
|
346
|
+
{ 'result' => {'description' => message, 'code' => 'unknown' } }
|
347
|
+
end
|
348
|
+
|
349
|
+
def flatten_hash(hash)
|
350
|
+
hash.each_with_object({}) do |(k, v), h|
|
351
|
+
if v.is_a? Hash
|
352
|
+
flatten_hash(v).map do |h_k, h_v|
|
353
|
+
h["#{k}.#{h_k}".to_sym] = h_v
|
354
|
+
end
|
355
|
+
else
|
356
|
+
h[k] = v
|
357
|
+
end
|
358
|
+
end
|
359
|
+
end
|
360
|
+
end
|
361
|
+
end
|
362
|
+
end
|
@@ -28,6 +28,8 @@ module ActiveMerchant #:nodoc:
|
|
28
28
|
# Company will automatically be affiliated.
|
29
29
|
|
30
30
|
class OrbitalGateway < Gateway
|
31
|
+
include Empty
|
32
|
+
|
31
33
|
API_VERSION = "5.6"
|
32
34
|
|
33
35
|
POST_HEADERS = {
|
@@ -82,7 +84,9 @@ module ActiveMerchant #:nodoc:
|
|
82
84
|
|
83
85
|
CURRENCY_CODES = {
|
84
86
|
"AUD" => '036',
|
87
|
+
"BRL" => '986',
|
85
88
|
"CAD" => '124',
|
89
|
+
"CLP" => '152',
|
86
90
|
"CZK" => '203',
|
87
91
|
"DKK" => '208',
|
88
92
|
"HKD" => '344',
|
@@ -101,7 +105,9 @@ module ActiveMerchant #:nodoc:
|
|
101
105
|
|
102
106
|
CURRENCY_EXPONENTS = {
|
103
107
|
"AUD" => '2',
|
108
|
+
"BRL" => '2',
|
104
109
|
"CAD" => '2',
|
110
|
+
"CLP" => '2',
|
105
111
|
"CZK" => '2',
|
106
112
|
"DKK" => '2',
|
107
113
|
"HKD" => '2',
|
@@ -175,7 +181,7 @@ module ActiveMerchant #:nodoc:
|
|
175
181
|
USE_ORDER_ID = 'O' # Use OrderID field
|
176
182
|
USE_COMMENTS = 'D' # Use Comments field
|
177
183
|
|
178
|
-
SENSITIVE_FIELDS = [:account_num]
|
184
|
+
SENSITIVE_FIELDS = [:account_num, :cc_account_num]
|
179
185
|
|
180
186
|
def initialize(options = {})
|
181
187
|
requires!(options, :merchant_id)
|
@@ -291,6 +297,19 @@ module ActiveMerchant #:nodoc:
|
|
291
297
|
commit(order, :delete_customer_profile)
|
292
298
|
end
|
293
299
|
|
300
|
+
def supports_scrubbing?
|
301
|
+
true
|
302
|
+
end
|
303
|
+
|
304
|
+
def scrub(transcript)
|
305
|
+
transcript.
|
306
|
+
gsub(%r((<OrbitalConnectionUsername>).+(</OrbitalConnectionUsername>)), '\1[FILTERED]\2').
|
307
|
+
gsub(%r((<OrbitalConnectionPassword>).+(</OrbitalConnectionPassword>)), '\1[FILTERED]\2').
|
308
|
+
gsub(%r((<AccountNum>).+(</AccountNum>)), '\1[FILTERED]\2').
|
309
|
+
gsub(%r((<CardSecVal>).+(</CardSecVal>)), '\1[FILTERED]\2').
|
310
|
+
gsub(%r((<MerchantID>).+(</MerchantID>)), '\1[FILTERED]\2')
|
311
|
+
end
|
312
|
+
|
294
313
|
private
|
295
314
|
|
296
315
|
def authorization_string(*args)
|
@@ -328,7 +347,7 @@ module ActiveMerchant #:nodoc:
|
|
328
347
|
|
329
348
|
def add_address(xml, creditcard, options)
|
330
349
|
if(address = (options[:billing_address] || options[:address]))
|
331
|
-
avs_supported = AVS_SUPPORTED_COUNTRIES.include?(address[:country].to_s)
|
350
|
+
avs_supported = AVS_SUPPORTED_COUNTRIES.include?(address[:country].to_s) || empty?(address[:country])
|
332
351
|
|
333
352
|
if avs_supported
|
334
353
|
xml.tag! :AVSzip, byte_limit(format_address_field(address[:zip]), 10)
|
@@ -338,9 +357,9 @@ module ActiveMerchant #:nodoc:
|
|
338
357
|
xml.tag! :AVSstate, byte_limit(format_address_field(address[:state]), 2)
|
339
358
|
xml.tag! :AVSphoneNum, (address[:phone] ? address[:phone].scan(/\d/).join.to_s[0..13] : nil)
|
340
359
|
end
|
341
|
-
|
360
|
+
|
342
361
|
xml.tag! :AVSname, ((creditcard && creditcard.name) ? creditcard.name[0..29] : nil)
|
343
|
-
xml.tag! :AVScountryCode, (avs_supported ? address[:country] : '')
|
362
|
+
xml.tag! :AVScountryCode, (avs_supported ? (byte_limit(format_address_field(address[:country]), 2)) : '')
|
344
363
|
|
345
364
|
# Needs to come after AVScountryCode
|
346
365
|
add_destination_address(xml, address) if avs_supported
|
@@ -398,10 +417,12 @@ module ActiveMerchant #:nodoc:
|
|
398
417
|
# Do not submit the attribute at all.
|
399
418
|
# - http://download.chasepaymentech.com/docs/orbital/orbital_gateway_xml_specification.pdf
|
400
419
|
unless creditcard.nil?
|
401
|
-
if
|
402
|
-
|
420
|
+
if creditcard.verification_value?
|
421
|
+
if %w( visa discover ).include?(creditcard.brand)
|
422
|
+
xml.tag! :CardSecValInd, '1'
|
423
|
+
end
|
424
|
+
xml.tag! :CardSecVal, creditcard.verification_value
|
403
425
|
end
|
404
|
-
xml.tag! :CardSecVal, creditcard.verification_value if creditcard.verification_value?
|
405
426
|
end
|
406
427
|
end
|
407
428
|
|