activemerchant 1.114.0 → 1.120.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +183 -0
- data/README.md +4 -2
- data/lib/active_merchant.rb +1 -1
- data/lib/active_merchant/billing/avs_result.rb +1 -1
- data/lib/active_merchant/billing/check.rb +10 -0
- data/lib/active_merchant/billing/compatibility.rb +3 -3
- data/lib/active_merchant/billing/credit_card.rb +3 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +80 -15
- data/lib/active_merchant/billing/gateways/adyen.rb +44 -20
- data/lib/active_merchant/billing/gateways/allied_wallet.rb +7 -7
- data/lib/active_merchant/billing/gateways/authorize_net.rb +50 -12
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +3 -4
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +5 -1
- data/lib/active_merchant/billing/gateways/axcessms.rb +8 -9
- data/lib/active_merchant/billing/gateways/balanced.rb +4 -3
- data/lib/active_merchant/billing/gateways/bambora_apac.rb +7 -7
- data/lib/active_merchant/billing/gateways/bank_frick.rb +7 -7
- data/lib/active_merchant/billing/gateways/banwire.rb +1 -1
- data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +6 -4
- data/lib/active_merchant/billing/gateways/beanstream.rb +3 -3
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +4 -5
- data/lib/active_merchant/billing/gateways/blue_pay.rb +2 -3
- data/lib/active_merchant/billing/gateways/blue_snap.rb +22 -18
- data/lib/active_merchant/billing/gateways/bogus.rb +19 -19
- data/lib/active_merchant/billing/gateways/borgun.rb +11 -11
- data/lib/active_merchant/billing/gateways/bpoint.rb +8 -8
- data/lib/active_merchant/billing/gateways/braintree.rb +1 -1
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +60 -17
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +7 -7
- data/lib/active_merchant/billing/gateways/cams.rb +8 -8
- data/lib/active_merchant/billing/gateways/card_connect.rb +1 -1
- data/lib/active_merchant/billing/gateways/card_save.rb +1 -1
- data/lib/active_merchant/billing/gateways/card_stream.rb +2 -2
- data/lib/active_merchant/billing/gateways/cardknox.rb +7 -7
- data/lib/active_merchant/billing/gateways/cardprocess.rb +1 -1
- data/lib/active_merchant/billing/gateways/cashnet.rb +7 -2
- data/lib/active_merchant/billing/gateways/cecabank.rb +5 -5
- data/lib/active_merchant/billing/gateways/cenpos.rb +10 -10
- data/lib/active_merchant/billing/gateways/checkout.rb +2 -2
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +38 -20
- data/lib/active_merchant/billing/gateways/clearhaus.rb +7 -7
- data/lib/active_merchant/billing/gateways/commercegate.rb +1 -1
- data/lib/active_merchant/billing/gateways/conekta.rb +2 -2
- data/lib/active_merchant/billing/gateways/creditcall.rb +10 -10
- data/lib/active_merchant/billing/gateways/credorax.rb +39 -23
- data/lib/active_merchant/billing/gateways/ct_payment.rb +10 -10
- data/lib/active_merchant/billing/gateways/culqi.rb +9 -9
- data/lib/active_merchant/billing/gateways/cyber_source.rb +81 -39
- data/lib/active_merchant/billing/gateways/d_local.rb +12 -12
- data/lib/active_merchant/billing/gateways/data_cash.rb +2 -3
- data/lib/active_merchant/billing/gateways/decidir.rb +31 -10
- data/lib/active_merchant/billing/gateways/dibs.rb +8 -8
- data/lib/active_merchant/billing/gateways/digitzs.rb +5 -5
- data/lib/active_merchant/billing/gateways/ebanx.rb +9 -9
- data/lib/active_merchant/billing/gateways/efsnet.rb +2 -3
- data/lib/active_merchant/billing/gateways/elavon.rb +296 -225
- data/lib/active_merchant/billing/gateways/element.rb +8 -8
- data/lib/active_merchant/billing/gateways/evo_ca.rb +5 -6
- data/lib/active_merchant/billing/gateways/eway.rb +3 -4
- data/lib/active_merchant/billing/gateways/eway_managed.rb +6 -7
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +19 -6
- data/lib/active_merchant/billing/gateways/exact.rb +8 -9
- data/lib/active_merchant/billing/gateways/ezic.rb +7 -7
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +4 -4
- data/lib/active_merchant/billing/gateways/federated_canada.rb +2 -3
- data/lib/active_merchant/billing/gateways/first_giving.rb +1 -1
- data/lib/active_merchant/billing/gateways/first_pay.rb +6 -6
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +7 -7
- data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +21 -10
- data/lib/active_merchant/billing/gateways/flo2cash.rb +8 -8
- data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +1 -1
- data/lib/active_merchant/billing/gateways/forte.rb +26 -8
- data/lib/active_merchant/billing/gateways/global_collect.rb +35 -16
- data/lib/active_merchant/billing/gateways/global_transport.rb +7 -7
- data/lib/active_merchant/billing/gateways/hdfc.rb +9 -9
- data/lib/active_merchant/billing/gateways/hps.rb +72 -9
- data/lib/active_merchant/billing/gateways/iats_payments.rb +9 -4
- data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +1 -1
- data/lib/active_merchant/billing/gateways/inspire.rb +3 -4
- data/lib/active_merchant/billing/gateways/instapay.rb +1 -2
- data/lib/active_merchant/billing/gateways/ipp.rb +5 -5
- data/lib/active_merchant/billing/gateways/iridium.rb +14 -15
- data/lib/active_merchant/billing/gateways/iveri.rb +7 -7
- data/lib/active_merchant/billing/gateways/ixopay.rb +7 -7
- data/lib/active_merchant/billing/gateways/jetpay.rb +1 -2
- data/lib/active_merchant/billing/gateways/jetpay_v2.rb +4 -5
- data/lib/active_merchant/billing/gateways/kushki.rb +6 -6
- data/lib/active_merchant/billing/gateways/latitude19.rb +14 -14
- data/lib/active_merchant/billing/gateways/linkpoint.rb +4 -5
- data/lib/active_merchant/billing/gateways/litle.rb +32 -16
- data/lib/active_merchant/billing/gateways/mastercard.rb +10 -10
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +9 -9
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +1 -2
- data/lib/active_merchant/billing/gateways/merchant_one.rb +1 -1
- data/lib/active_merchant/billing/gateways/merchant_partners.rb +10 -10
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +5 -7
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +4 -6
- data/lib/active_merchant/billing/gateways/mercury.rb +4 -4
- data/lib/active_merchant/billing/gateways/metrics_global.rb +4 -5
- data/lib/active_merchant/billing/gateways/micropayment.rb +8 -8
- data/lib/active_merchant/billing/gateways/migs.rb +3 -4
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +2 -4
- data/lib/active_merchant/billing/gateways/monei.rb +7 -7
- data/lib/active_merchant/billing/gateways/moneris.rb +4 -3
- data/lib/active_merchant/billing/gateways/money_movers.rb +2 -3
- data/lib/active_merchant/billing/gateways/mundipagg.rb +37 -10
- data/lib/active_merchant/billing/gateways/nab_transact.rb +2 -4
- data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +7 -7
- data/lib/active_merchant/billing/gateways/net_registry.rb +1 -2
- data/lib/active_merchant/billing/gateways/netaxept.rb +6 -6
- data/lib/active_merchant/billing/gateways/netbanx.rb +45 -10
- data/lib/active_merchant/billing/gateways/netbilling.rb +4 -5
- data/lib/active_merchant/billing/gateways/network_merchants.rb +2 -3
- data/lib/active_merchant/billing/gateways/nmi.rb +21 -7
- data/lib/active_merchant/billing/gateways/ogone.rb +3 -3
- data/lib/active_merchant/billing/gateways/omise.rb +13 -13
- data/lib/active_merchant/billing/gateways/openpay.rb +3 -4
- data/lib/active_merchant/billing/gateways/opp.rb +9 -9
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +2 -3
- data/lib/active_merchant/billing/gateways/orbital.rb +225 -105
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +3 -4
- data/lib/active_merchant/billing/gateways/pagarme.rb +8 -8
- data/lib/active_merchant/billing/gateways/pago_facil.rb +2 -2
- data/lib/active_merchant/billing/gateways/pay_conex.rb +8 -8
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +6 -7
- data/lib/active_merchant/billing/gateways/pay_hub.rb +7 -8
- data/lib/active_merchant/billing/gateways/pay_junction.rb +2 -3
- data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +9 -9
- data/lib/active_merchant/billing/gateways/pay_secure.rb +2 -3
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +23 -1
- data/lib/active_merchant/billing/gateways/payeezy.rb +62 -20
- data/lib/active_merchant/billing/gateways/payex.rb +6 -7
- data/lib/active_merchant/billing/gateways/payflow.rb +1 -1
- data/lib/active_merchant/billing/gateways/payment_express.rb +11 -7
- data/lib/active_merchant/billing/gateways/paymentez.rb +26 -6
- data/lib/active_merchant/billing/gateways/paymill.rb +7 -7
- data/lib/active_merchant/billing/gateways/paypal.rb +10 -2
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +1 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +1 -1
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +1 -1
- data/lib/active_merchant/billing/gateways/payscout.rb +1 -2
- data/lib/active_merchant/billing/gateways/paystation.rb +3 -4
- data/lib/active_merchant/billing/gateways/payu_in.rb +3 -3
- data/lib/active_merchant/billing/gateways/payu_latam.rb +17 -10
- data/lib/active_merchant/billing/gateways/payway.rb +8 -9
- data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
- data/lib/active_merchant/billing/gateways/pin.rb +11 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +1 -2
- data/lib/active_merchant/billing/gateways/pro_pay.rb +8 -8
- data/lib/active_merchant/billing/gateways/psigate.rb +2 -3
- data/lib/active_merchant/billing/gateways/psl_card.rb +1 -2
- data/lib/active_merchant/billing/gateways/qbms.rb +1 -2
- data/lib/active_merchant/billing/gateways/quantum.rb +1 -2
- data/lib/active_merchant/billing/gateways/quickbooks.rb +1 -1
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +3 -4
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +1 -2
- data/lib/active_merchant/billing/gateways/qvalent.rb +31 -17
- data/lib/active_merchant/billing/gateways/realex.rb +1 -1
- data/lib/active_merchant/billing/gateways/redsys.rb +105 -9
- data/lib/active_merchant/billing/gateways/s5.rb +7 -7
- data/lib/active_merchant/billing/gateways/safe_charge.rb +51 -18
- data/lib/active_merchant/billing/gateways/sage.rb +3 -5
- data/lib/active_merchant/billing/gateways/sage_pay.rb +2 -3
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +1 -2
- data/lib/active_merchant/billing/gateways/secure_net.rb +1 -2
- data/lib/active_merchant/billing/gateways/secure_pay.rb +3 -4
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +2 -4
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +1 -2
- data/lib/active_merchant/billing/gateways/securion_pay.rb +5 -6
- data/lib/active_merchant/billing/gateways/skip_jack.rb +2 -3
- data/lib/active_merchant/billing/gateways/smart_ps.rb +5 -6
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +7 -7
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +6 -6
- data/lib/active_merchant/billing/gateways/stripe.rb +18 -18
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +91 -25
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +3 -4
- data/lib/active_merchant/billing/gateways/telr.rb +8 -8
- data/lib/active_merchant/billing/gateways/trans_first.rb +2 -2
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +12 -12
- data/lib/active_merchant/billing/gateways/transact_pro.rb +9 -9
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +1 -2
- data/lib/active_merchant/billing/gateways/usa_epay.rb +1 -1
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +32 -32
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +3 -4
- data/lib/active_merchant/billing/gateways/vanco.rb +3 -3
- data/lib/active_merchant/billing/gateways/verifi.rb +1 -2
- data/lib/active_merchant/billing/gateways/viaklix.rb +1 -2
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +10 -10
- data/lib/active_merchant/billing/gateways/vpos.rb +172 -0
- data/lib/active_merchant/billing/gateways/webpay.rb +2 -2
- data/lib/active_merchant/billing/gateways/wepay.rb +3 -2
- data/lib/active_merchant/billing/gateways/wirecard.rb +1 -2
- data/lib/active_merchant/billing/gateways/worldpay.rb +43 -22
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +14 -16
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +7 -7
- data/lib/active_merchant/billing/response.rb +3 -2
- data/lib/active_merchant/country.rb +1 -1
- data/lib/active_merchant/network_connection_retries.rb +2 -2
- data/lib/active_merchant/post_data.rb +1 -1
- data/lib/active_merchant/posts_data.rb +1 -1
- data/lib/active_merchant/version.rb +1 -1
- data/lib/certs/cacert.pem +1582 -2431
- data/lib/support/ssl_verify.rb +2 -2
- data/lib/support/ssl_version.rb +2 -2
- metadata +5 -3
@@ -0,0 +1,172 @@
|
|
1
|
+
require 'digest'
|
2
|
+
require 'jwe'
|
3
|
+
|
4
|
+
module ActiveMerchant #:nodoc:
|
5
|
+
module Billing #:nodoc:
|
6
|
+
class VposGateway < Gateway
|
7
|
+
self.test_url = 'https://vpos.infonet.com.py:8888'
|
8
|
+
self.live_url = 'https://vpos.infonet.com.py'
|
9
|
+
|
10
|
+
self.supported_countries = ['PY']
|
11
|
+
self.default_currency = 'PYG'
|
12
|
+
self.supported_cardtypes = %i[visa master]
|
13
|
+
|
14
|
+
self.homepage_url = 'https://comercios.bancard.com.py'
|
15
|
+
self.display_name = 'vPOS'
|
16
|
+
|
17
|
+
self.money_format = :dollars
|
18
|
+
|
19
|
+
ENDPOINTS = {
|
20
|
+
pci_encryption_key: '/vpos/api/0.3/application/encryption-key',
|
21
|
+
pay_pci_buy_encrypted: '/vpos/api/0.3/pci/encrypted',
|
22
|
+
pci_buy_rollback: '/vpos/api/0.3/pci_buy/rollback',
|
23
|
+
refund: '/vpos/api/0.3/refunds'
|
24
|
+
}
|
25
|
+
|
26
|
+
def initialize(options = {})
|
27
|
+
requires!(options, :private_key, :public_key)
|
28
|
+
@private_key = options[:private_key]
|
29
|
+
@public_key = options[:public_key]
|
30
|
+
@shop_process_id = options[:shop_process_id] || SecureRandom.random_number(10**15)
|
31
|
+
super
|
32
|
+
end
|
33
|
+
|
34
|
+
def purchase(money, payment, options = {})
|
35
|
+
commerce = options[:commerce] || @options[:commerce]
|
36
|
+
commerce_branch = options[:commerce_branch] || @options[:commerce_branch]
|
37
|
+
|
38
|
+
token = generate_token(@shop_process_id, 'pay_pci', commerce, commerce_branch, amount(money), currency(money))
|
39
|
+
|
40
|
+
post = {}
|
41
|
+
post[:token] = token
|
42
|
+
post[:commerce] = commerce.to_s
|
43
|
+
post[:commerce_branch] = commerce_branch.to_s
|
44
|
+
post[:shop_process_id] = @shop_process_id
|
45
|
+
post[:number_of_payments] = options[:number_of_payments] || 1
|
46
|
+
post[:recursive] = options[:recursive] || false
|
47
|
+
|
48
|
+
add_invoice(post, money, options)
|
49
|
+
add_card_data(post, payment)
|
50
|
+
add_customer_data(post, options)
|
51
|
+
|
52
|
+
commit(:pay_pci_buy_encrypted, post)
|
53
|
+
end
|
54
|
+
|
55
|
+
def void(_authorization, options = {})
|
56
|
+
token = generate_token(@shop_process_id, 'rollback', '0.00')
|
57
|
+
post = {
|
58
|
+
token: token,
|
59
|
+
shop_process_id: @shop_process_id
|
60
|
+
}
|
61
|
+
commit(:pci_buy_rollback, post)
|
62
|
+
end
|
63
|
+
|
64
|
+
def supports_scrubbing?
|
65
|
+
true
|
66
|
+
end
|
67
|
+
|
68
|
+
def scrub(transcript)
|
69
|
+
clean_transcript = remove_invalid_utf_8_byte_sequences(transcript)
|
70
|
+
clean_transcript.
|
71
|
+
gsub(/(token\\":\\")[.\-\w]+/, '\1[FILTERED]').
|
72
|
+
gsub(/(card_encrypted_data\\":\\")[.\-\w]+/, '\1[FILTERED]')
|
73
|
+
end
|
74
|
+
|
75
|
+
def remove_invalid_utf_8_byte_sequences(transcript)
|
76
|
+
transcript.encode('UTF-8', 'binary', undef: :replace, replace: '')
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
# Required to encrypt PAN data.
|
82
|
+
def one_time_public_key
|
83
|
+
token = generate_token('get_encription_public_key', @public_key)
|
84
|
+
response = commit(:pci_encryption_key, token: token)
|
85
|
+
OpenSSL::PKey::RSA.new(response.params['encryption_key'])
|
86
|
+
end
|
87
|
+
|
88
|
+
def generate_token(*elements)
|
89
|
+
Digest::MD5.hexdigest(@private_key + elements.join)
|
90
|
+
end
|
91
|
+
|
92
|
+
def add_invoice(post, money, options)
|
93
|
+
post[:amount] = amount(money)
|
94
|
+
post[:currency] = options[:currency] || currency(money)
|
95
|
+
end
|
96
|
+
|
97
|
+
def add_card_data(post, payment)
|
98
|
+
card_number = payment.number
|
99
|
+
cvv = payment.verification_value
|
100
|
+
|
101
|
+
payload = { card_number: card_number, 'cvv': cvv }.to_json
|
102
|
+
|
103
|
+
post[:card_encrypted_data] = JWE.encrypt(payload, one_time_public_key)
|
104
|
+
post[:card_month_expiration] = format(payment.month, :two_digits)
|
105
|
+
post[:card_year_expiration] = format(payment.year, :two_digits)
|
106
|
+
end
|
107
|
+
|
108
|
+
def add_customer_data(post, options)
|
109
|
+
post[:additional_data] = options[:additional_data] || '' # must be passed even if empty
|
110
|
+
end
|
111
|
+
|
112
|
+
def parse(body)
|
113
|
+
JSON.parse(body)
|
114
|
+
end
|
115
|
+
|
116
|
+
def commit(action, parameters)
|
117
|
+
url = build_request_url(action)
|
118
|
+
begin
|
119
|
+
response = parse(ssl_post(url, post_data(parameters)))
|
120
|
+
rescue ResponseError => response
|
121
|
+
# Errors are returned with helpful data,
|
122
|
+
# but get filtered out by `ssl_post` because of their HTTP status.
|
123
|
+
response = parse(response.response.body)
|
124
|
+
end
|
125
|
+
|
126
|
+
Response.new(
|
127
|
+
success_from(response),
|
128
|
+
message_from(response),
|
129
|
+
response,
|
130
|
+
authorization: authorization_from(response),
|
131
|
+
avs_result: nil,
|
132
|
+
cvv_result: nil,
|
133
|
+
test: test?,
|
134
|
+
error_code: error_code_from(response)
|
135
|
+
)
|
136
|
+
end
|
137
|
+
|
138
|
+
def success_from(response)
|
139
|
+
if code = response.dig('confirmation', 'response_code')
|
140
|
+
code == '00'
|
141
|
+
else
|
142
|
+
response['status'] == 'success'
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def message_from(response)
|
147
|
+
response.dig('confirmation', 'extended_response_description') ||
|
148
|
+
response.dig('confirmation', 'response_description') ||
|
149
|
+
response.dig('confirmation', 'response_details') ||
|
150
|
+
response.dig('messages', 0, 'key')
|
151
|
+
end
|
152
|
+
|
153
|
+
def authorization_from(response)
|
154
|
+
response.dig('confirmation', 'authorization_number')
|
155
|
+
end
|
156
|
+
|
157
|
+
def error_code_from(response)
|
158
|
+
response.dig('confirmation', 'response_code') unless success_from(response)
|
159
|
+
end
|
160
|
+
|
161
|
+
def build_request_url(action)
|
162
|
+
base_url = (test? ? test_url : live_url)
|
163
|
+
base_url + ENDPOINTS[action]
|
164
|
+
end
|
165
|
+
|
166
|
+
def post_data(data)
|
167
|
+
{ public_key: @public_key,
|
168
|
+
operation: data }.compact.to_json
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
@@ -51,7 +51,7 @@ module ActiveMerchant #:nodoc:
|
|
51
51
|
MultiResponse.run(:first) do |r|
|
52
52
|
r.process { commit(:post, "customers/#{CGI.escape(options[:customer])}/", post, options) }
|
53
53
|
|
54
|
-
return r unless options[:set_default]
|
54
|
+
return r unless options[:set_default] && r.success? && !r.params['id'].blank?
|
55
55
|
|
56
56
|
r.process { update_customer(options[:customer], default_card: r.params['id']) }
|
57
57
|
end
|
@@ -89,7 +89,7 @@ module ActiveMerchant #:nodoc:
|
|
89
89
|
'Authorization' => 'Basic ' + Base64.encode64(@api_key.to_s + ':').strip,
|
90
90
|
'User-Agent' => "Webpay/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
|
91
91
|
'X-Webpay-Client-User-Agent' => user_agent,
|
92
|
-
'X-Webpay-Client-User-Metadata' => {ip: options[:ip]}.to_json
|
92
|
+
'X-Webpay-Client-User-Metadata' => { ip: options[:ip] }.to_json
|
93
93
|
}
|
94
94
|
end
|
95
95
|
end
|
@@ -168,14 +168,15 @@ module ActiveMerchant #:nodoc:
|
|
168
168
|
JSON.parse(response)
|
169
169
|
end
|
170
170
|
|
171
|
-
def commit(action, params, options={})
|
171
|
+
def commit(action, params, options = {})
|
172
172
|
begin
|
173
173
|
response = parse(
|
174
174
|
ssl_post(
|
175
175
|
((test? ? test_url : live_url) + action),
|
176
176
|
params.to_json,
|
177
177
|
headers(options)
|
178
|
-
)
|
178
|
+
)
|
179
|
+
)
|
179
180
|
rescue ResponseError => e
|
180
181
|
response = parse(e.response.body)
|
181
182
|
end
|
@@ -183,8 +183,7 @@ module ActiveMerchant #:nodoc:
|
|
183
183
|
test: test?,
|
184
184
|
authorization: authorization,
|
185
185
|
avs_result: { code: avs_code(response, options) },
|
186
|
-
cvv_result: response[:CVCResponseCode]
|
187
|
-
)
|
186
|
+
cvv_result: response[:CVCResponseCode])
|
188
187
|
rescue ResponseError => e
|
189
188
|
if e.response.code == '401'
|
190
189
|
return Response.new(false, 'Invalid Login')
|
@@ -9,7 +9,7 @@ module ActiveMerchant #:nodoc:
|
|
9
9
|
self.default_currency = 'GBP'
|
10
10
|
self.money_format = :cents
|
11
11
|
self.supported_countries = %w(HK GB AU AD AR BE BR CA CH CN CO CR CY CZ DE DK ES FI FR GI GR HU IE IN IT JP LI LU MC MT MY MX NL NO NZ PA PE PL PT SE SG SI SM TR UM VA)
|
12
|
-
self.supported_cardtypes = %i[visa master american_express discover jcb maestro elo naranja cabal]
|
12
|
+
self.supported_cardtypes = %i[visa master american_express discover jcb maestro elo naranja cabal unionpay]
|
13
13
|
self.currencies_without_fractions = %w(HUF IDR ISK JPY KRW)
|
14
14
|
self.currencies_with_three_decimal_places = %w(BHD KWD OMR RSD TND)
|
15
15
|
self.homepage_url = 'http://www.worldpay.com/'
|
@@ -26,6 +26,7 @@ module ActiveMerchant #:nodoc:
|
|
26
26
|
'elo' => 'ELO-SSL',
|
27
27
|
'naranja' => 'NARANJA-SSL',
|
28
28
|
'cabal' => 'CABAL-SSL',
|
29
|
+
'unionpay' => 'CHINAUNIONPAY-SSL',
|
29
30
|
'unknown' => 'CARD-SSL'
|
30
31
|
}
|
31
32
|
|
@@ -57,7 +58,7 @@ module ActiveMerchant #:nodoc:
|
|
57
58
|
def purchase(money, payment_method, options = {})
|
58
59
|
MultiResponse.run do |r|
|
59
60
|
r.process { authorize(money, payment_method, options) }
|
60
|
-
r.process { capture(money, r.authorization, options.merge(authorization_validated: true)) }
|
61
|
+
r.process { capture(money, r.authorization, options.merge(authorization_validated: true)) } unless options[:skip_capture]
|
61
62
|
end
|
62
63
|
end
|
63
64
|
|
@@ -70,7 +71,7 @@ module ActiveMerchant #:nodoc:
|
|
70
71
|
def capture(money, authorization, options = {})
|
71
72
|
authorization = order_id_from_authorization(authorization.to_s)
|
72
73
|
MultiResponse.run do |r|
|
73
|
-
r.process { inquire_request(authorization, options, 'AUTHORISED') } unless options[:authorization_validated]
|
74
|
+
r.process { inquire_request(authorization, options, 'AUTHORISED', 'CAPTURED') } unless options[:authorization_validated]
|
74
75
|
if r.params
|
75
76
|
authorization_currency = r.params['amount_currency_code']
|
76
77
|
options = options.merge(currency: authorization_currency) if authorization_currency.present?
|
@@ -89,8 +90,10 @@ module ActiveMerchant #:nodoc:
|
|
89
90
|
|
90
91
|
def refund(money, authorization, options = {})
|
91
92
|
authorization = order_id_from_authorization(authorization.to_s)
|
93
|
+
success_criteria = %w(CAPTURED SETTLED SETTLED_BY_MERCHANT SENT_FOR_REFUND)
|
94
|
+
success_criteria.push('AUTHORIZED') if options[:cancel_or_refund]
|
92
95
|
response = MultiResponse.run do |r|
|
93
|
-
r.process { inquire_request(authorization, options,
|
96
|
+
r.process { inquire_request(authorization, options, *success_criteria) } unless options[:authorization_validated]
|
94
97
|
r.process { refund_request(money, authorization, options) }
|
95
98
|
end
|
96
99
|
|
@@ -111,14 +114,14 @@ module ActiveMerchant #:nodoc:
|
|
111
114
|
credit_request(money, payment_method, payment_details.merge(credit: true, **options))
|
112
115
|
end
|
113
116
|
|
114
|
-
def verify(payment_method, options={})
|
117
|
+
def verify(payment_method, options = {})
|
115
118
|
MultiResponse.run(:use_first_response) do |r|
|
116
119
|
r.process { authorize(100, payment_method, options) }
|
117
120
|
r.process(:ignore_result) { void(r.authorization, options.merge(authorization_validated: true)) }
|
118
121
|
end
|
119
122
|
end
|
120
123
|
|
121
|
-
def store(credit_card, options={})
|
124
|
+
def store(credit_card, options = {})
|
122
125
|
requires!(options, :customer)
|
123
126
|
store_request(credit_card, options)
|
124
127
|
end
|
@@ -141,7 +144,7 @@ module ActiveMerchant #:nodoc:
|
|
141
144
|
end
|
142
145
|
|
143
146
|
def capture_request(money, authorization, options)
|
144
|
-
commit('capture', build_capture_request(money, authorization, options), :ok, options)
|
147
|
+
commit('capture', build_capture_request(money, authorization, options), 'CAPTURED', :ok, options)
|
145
148
|
end
|
146
149
|
|
147
150
|
def cancel_request(authorization, options)
|
@@ -153,7 +156,7 @@ module ActiveMerchant #:nodoc:
|
|
153
156
|
end
|
154
157
|
|
155
158
|
def refund_request(money, authorization, options)
|
156
|
-
commit('refund', build_refund_request(money, authorization, options), :ok, options)
|
159
|
+
commit('refund', build_refund_request(money, authorization, options), :ok, 'SENT_FOR_REFUND', options)
|
157
160
|
end
|
158
161
|
|
159
162
|
def credit_request(money, payment_method, options)
|
@@ -205,6 +208,7 @@ module ActiveMerchant #:nodoc:
|
|
205
208
|
end
|
206
209
|
add_payment_method(xml, money, payment_method, options)
|
207
210
|
add_shopper(xml, options)
|
211
|
+
add_statement_narrative(xml, options)
|
208
212
|
add_risk_data(xml, options[:risk_data]) if options[:risk_data]
|
209
213
|
add_hcg_additional_data(xml, options) if options[:hcg_additional_data]
|
210
214
|
add_instalments_data(xml, options) if options[:instalments]
|
@@ -236,8 +240,13 @@ module ActiveMerchant #:nodoc:
|
|
236
240
|
|
237
241
|
def build_refund_request(money, authorization, options)
|
238
242
|
build_order_modify_request(authorization) do |xml|
|
239
|
-
|
240
|
-
|
243
|
+
if options[:cancel_or_refund]
|
244
|
+
# Worldpay docs claim amount must be passed. This causes an error.
|
245
|
+
xml.cancelOrRefund # { add_amount(xml, money, options.merge(debit_credit_indicator: 'credit')) }
|
246
|
+
else
|
247
|
+
xml.refund do
|
248
|
+
add_amount(xml, money, options.merge(debit_credit_indicator: 'credit'))
|
249
|
+
end
|
241
250
|
end
|
242
251
|
end
|
243
252
|
end
|
@@ -259,7 +268,10 @@ module ActiveMerchant #:nodoc:
|
|
259
268
|
end
|
260
269
|
|
261
270
|
def add_additional_3ds_data(xml, options)
|
262
|
-
|
271
|
+
additional_data = { 'dfReferenceId' => options[:session_id] }
|
272
|
+
additional_data['challengeWindowSize'] = options[:browser_size] if options[:browser_size]
|
273
|
+
|
274
|
+
xml.additional3DSData additional_data
|
263
275
|
end
|
264
276
|
|
265
277
|
def add_3ds_exemption(xml, options)
|
@@ -425,14 +437,14 @@ module ActiveMerchant #:nodoc:
|
|
425
437
|
)
|
426
438
|
end
|
427
439
|
|
428
|
-
card_holder_name = options[:execute_threed] && !options[:three_ds_version]&.start_with?('2') ? '3D' : payment_method.name
|
440
|
+
card_holder_name = test? && options[:execute_threed] && !options[:three_ds_version]&.start_with?('2') ? '3D' : payment_method.name
|
429
441
|
xml.cardHolderName card_holder_name
|
430
442
|
xml.cvc payment_method.verification_value
|
431
443
|
|
432
444
|
add_address(xml, (options[:billing_address] || options[:address]), options)
|
433
445
|
end
|
434
446
|
|
435
|
-
def add_stored_credential_options(xml, options={})
|
447
|
+
def add_stored_credential_options(xml, options = {})
|
436
448
|
if options[:stored_credential]
|
437
449
|
add_stored_credential_using_normalized_fields(xml, options)
|
438
450
|
else
|
@@ -481,6 +493,10 @@ module ActiveMerchant #:nodoc:
|
|
481
493
|
end
|
482
494
|
end
|
483
495
|
|
496
|
+
def add_statement_narrative(xml, options)
|
497
|
+
xml.statementNarrative truncate(options[:statement_narrative], 50) if options[:statement_narrative]
|
498
|
+
end
|
499
|
+
|
484
500
|
def add_authenticated_shopper_id(xml, options)
|
485
501
|
xml.authenticatedShopperID options[:customer] if options[:customer]
|
486
502
|
end
|
@@ -510,7 +526,7 @@ module ActiveMerchant #:nodoc:
|
|
510
526
|
def add_hcg_additional_data(xml, options)
|
511
527
|
xml.hcgAdditionalData do
|
512
528
|
options[:hcg_additional_data].each do |k, v|
|
513
|
-
xml.param({name: k.to_s}, v)
|
529
|
+
xml.param({ name: k.to_s }, v)
|
514
530
|
end
|
515
531
|
end
|
516
532
|
end
|
@@ -534,11 +550,10 @@ module ActiveMerchant #:nodoc:
|
|
534
550
|
|
535
551
|
def default_address
|
536
552
|
{
|
537
|
-
address1: 'N/A',
|
538
553
|
zip: '0000',
|
554
|
+
country: 'US',
|
539
555
|
city: 'N/A',
|
540
|
-
|
541
|
-
country: 'US'
|
556
|
+
address1: 'N/A'
|
542
557
|
}
|
543
558
|
end
|
544
559
|
|
@@ -546,7 +561,7 @@ module ActiveMerchant #:nodoc:
|
|
546
561
|
xml = xml.strip.gsub(/\&/, '&')
|
547
562
|
doc = Nokogiri::XML(xml, &:strict)
|
548
563
|
doc.remove_namespaces!
|
549
|
-
resp_params = {action: action}
|
564
|
+
resp_params = { action: action }
|
550
565
|
|
551
566
|
parse_elements(doc.root, resp_params)
|
552
567
|
resp_params
|
@@ -568,6 +583,8 @@ module ActiveMerchant #:nodoc:
|
|
568
583
|
end
|
569
584
|
|
570
585
|
def headers(options)
|
586
|
+
idempotency_key = options[:idempotency_key]
|
587
|
+
|
571
588
|
headers = {
|
572
589
|
'Content-Type' => 'text/xml',
|
573
590
|
'Authorization' => encoded_credentials
|
@@ -575,6 +592,8 @@ module ActiveMerchant #:nodoc:
|
|
575
592
|
if options[:cookie]
|
576
593
|
headers['Cookie'] = options[:cookie] if options[:cookie]
|
577
594
|
end
|
595
|
+
|
596
|
+
headers['Idempotency-Key'] = idempotency_key if idempotency_key
|
578
597
|
headers
|
579
598
|
end
|
580
599
|
|
@@ -646,7 +665,9 @@ module ActiveMerchant #:nodoc:
|
|
646
665
|
# - An array of strings if one of many responses could be considered a
|
647
666
|
# success.
|
648
667
|
def success_criteria_success?(raw, success_criteria)
|
649
|
-
|
668
|
+
return if raw[:error]
|
669
|
+
|
670
|
+
raw[:ok].present? || (success_criteria.include?(raw[:last_event]) if raw[:last_event])
|
650
671
|
end
|
651
672
|
|
652
673
|
def action_success?(action, raw)
|
@@ -683,11 +704,11 @@ module ActiveMerchant #:nodoc:
|
|
683
704
|
end
|
684
705
|
|
685
706
|
def order_id_from(raw)
|
686
|
-
pair = raw.detect { |k,
|
707
|
+
pair = raw.detect { |k, _v| k.to_s =~ /_order_code$/ }
|
687
708
|
(pair ? pair.last : nil)
|
688
709
|
end
|
689
710
|
|
690
|
-
def authorization_from_token_details(options={})
|
711
|
+
def authorization_from_token_details(options = {})
|
691
712
|
[options[:order_id], options[:token_id], options[:token_scope], options[:customer]].join('|')
|
692
713
|
end
|
693
714
|
|
@@ -727,7 +748,7 @@ module ActiveMerchant #:nodoc:
|
|
727
748
|
def credit_fund_transfer_attribute(options)
|
728
749
|
return unless options[:credit]
|
729
750
|
|
730
|
-
{'action' => 'REFUND'}
|
751
|
+
{ 'action' => 'REFUND' }
|
731
752
|
end
|
732
753
|
|
733
754
|
def encoded_credentials
|
@@ -13,14 +13,14 @@ module ActiveMerchant #:nodoc:
|
|
13
13
|
self.homepage_url = 'http://online.worldpay.com'
|
14
14
|
self.display_name = 'Worldpay Online Payments'
|
15
15
|
|
16
|
-
def initialize(options={})
|
16
|
+
def initialize(options = {})
|
17
17
|
requires!(options, :client_key, :service_key)
|
18
18
|
@client_key = options[:client_key]
|
19
19
|
@service_key = options[:service_key]
|
20
20
|
super
|
21
21
|
end
|
22
22
|
|
23
|
-
def authorize(money, credit_card, options={})
|
23
|
+
def authorize(money, credit_card, options = {})
|
24
24
|
response = create_token(true, credit_card.first_name + ' ' + credit_card.last_name, credit_card.month, credit_card.year, credit_card.number, credit_card.verification_value)
|
25
25
|
if response.success?
|
26
26
|
options[:authorizeOnly] = true
|
@@ -30,9 +30,9 @@ module ActiveMerchant #:nodoc:
|
|
30
30
|
response
|
31
31
|
end
|
32
32
|
|
33
|
-
def capture(money, authorization, options={})
|
33
|
+
def capture(money, authorization, options = {})
|
34
34
|
if authorization
|
35
|
-
commit(:post, "orders/#{CGI.escape(authorization)}/capture", {'captureAmount' => money}, options, 'capture')
|
35
|
+
commit(:post, "orders/#{CGI.escape(authorization)}/capture", { 'captureAmount' => money }, options, 'capture')
|
36
36
|
else
|
37
37
|
Response.new(false,
|
38
38
|
'FAILED',
|
@@ -41,12 +41,11 @@ module ActiveMerchant #:nodoc:
|
|
41
41
|
authorization: false,
|
42
42
|
avs_result: {},
|
43
43
|
cvv_result: {},
|
44
|
-
error_code: false
|
45
|
-
)
|
44
|
+
error_code: false)
|
46
45
|
end
|
47
46
|
end
|
48
47
|
|
49
|
-
def purchase(money, credit_card, options={})
|
48
|
+
def purchase(money, credit_card, options = {})
|
50
49
|
response = create_token(true, credit_card.first_name + ' ' + credit_card.last_name, credit_card.month, credit_card.year, credit_card.number, credit_card.verification_value)
|
51
50
|
if response.success?
|
52
51
|
post = create_post_for_auth_or_purchase(response.authorization, money, options)
|
@@ -55,18 +54,18 @@ module ActiveMerchant #:nodoc:
|
|
55
54
|
response
|
56
55
|
end
|
57
56
|
|
58
|
-
def refund(money, orderCode, options={})
|
59
|
-
obj = money ? {'refundAmount' => money} : {}
|
57
|
+
def refund(money, orderCode, options = {})
|
58
|
+
obj = money ? { 'refundAmount' => money } : {}
|
60
59
|
commit(:post, "orders/#{CGI.escape(orderCode)}/refund", obj, options, 'refund')
|
61
60
|
end
|
62
61
|
|
63
|
-
def void(orderCode, options={})
|
62
|
+
def void(orderCode, options = {})
|
64
63
|
response = commit(:delete, "orders/#{CGI.escape(orderCode)}", nil, options, 'void')
|
65
64
|
response = refund(nil, orderCode) if !response.success? && (response.params && response.params['customCode'] != 'ORDER_NOT_FOUND')
|
66
65
|
response
|
67
66
|
end
|
68
67
|
|
69
|
-
def verify(credit_card, options={})
|
68
|
+
def verify(credit_card, options = {})
|
70
69
|
authorize(0, credit_card, options)
|
71
70
|
end
|
72
71
|
|
@@ -85,7 +84,7 @@ module ActiveMerchant #:nodoc:
|
|
85
84
|
},
|
86
85
|
'clientKey' => @client_key
|
87
86
|
}
|
88
|
-
token_response = commit(:post, 'tokens', obj, {'Authorization' => @service_key}, 'token')
|
87
|
+
token_response = commit(:post, 'tokens', obj, { 'Authorization' => @service_key }, 'token')
|
89
88
|
token_response
|
90
89
|
end
|
91
90
|
|
@@ -121,13 +120,13 @@ module ActiveMerchant #:nodoc:
|
|
121
120
|
'Content-Type' => 'application/json',
|
122
121
|
'User-Agent' => "Worldpay/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
|
123
122
|
'X-Worldpay-Client-User-Agent' => user_agent,
|
124
|
-
'X-Worldpay-Client-User-Metadata' => {ip: options[:ip]}.to_json
|
123
|
+
'X-Worldpay-Client-User-Metadata' => { ip: options[:ip] }.to_json
|
125
124
|
}
|
126
125
|
headers['Authorization'] = options['Authorization'] if options['Authorization']
|
127
126
|
headers
|
128
127
|
end
|
129
128
|
|
130
|
-
def commit(method, url, parameters=nil, options = {}, type = false)
|
129
|
+
def commit(method, url, parameters = nil, options = {}, type = false)
|
131
130
|
raw_response = response = nil
|
132
131
|
success = false
|
133
132
|
begin
|
@@ -178,8 +177,7 @@ module ActiveMerchant #:nodoc:
|
|
178
177
|
authorization: authorization,
|
179
178
|
avs_result: {},
|
180
179
|
cvv_result: {},
|
181
|
-
error_code: success ? nil : response['customCode']
|
182
|
-
)
|
180
|
+
error_code: success ? nil : response['customCode'])
|
183
181
|
end
|
184
182
|
|
185
183
|
def test?
|