offsite_payments 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +70 -0
- data/lib/offsite_payments.rb +46 -0
- data/lib/offsite_payments/action_view_helper.rb +72 -0
- data/lib/offsite_payments/helper.rb +119 -0
- data/lib/offsite_payments/integrations.rb +14 -0
- data/lib/offsite_payments/integrations/a1agregator.rb +245 -0
- data/lib/offsite_payments/integrations/authorize_net_sim.rb +580 -0
- data/lib/offsite_payments/integrations/bit_pay.rb +150 -0
- data/lib/offsite_payments/integrations/bogus.rb +32 -0
- data/lib/offsite_payments/integrations/chronopay.rb +283 -0
- data/lib/offsite_payments/integrations/citrus.rb +227 -0
- data/lib/offsite_payments/integrations/direc_pay.rb +339 -0
- data/lib/offsite_payments/integrations/directebanking.rb +237 -0
- data/lib/offsite_payments/integrations/doku.rb +171 -0
- data/lib/offsite_payments/integrations/dotpay.rb +166 -0
- data/lib/offsite_payments/integrations/dwolla.rb +160 -0
- data/lib/offsite_payments/integrations/e_payment_plans.rb +146 -0
- data/lib/offsite_payments/integrations/easy_pay.rb +137 -0
- data/lib/offsite_payments/integrations/epay.rb +161 -0
- data/lib/offsite_payments/integrations/first_data.rb +133 -0
- data/lib/offsite_payments/integrations/gestpay.rb +201 -0
- data/lib/offsite_payments/integrations/hi_trust.rb +179 -0
- data/lib/offsite_payments/integrations/ipay88.rb +240 -0
- data/lib/offsite_payments/integrations/klarna.rb +291 -0
- data/lib/offsite_payments/integrations/liqpay.rb +216 -0
- data/lib/offsite_payments/integrations/maksuturva.rb +231 -0
- data/lib/offsite_payments/integrations/mollie_ideal.rb +213 -0
- data/lib/offsite_payments/integrations/moneybookers.rb +199 -0
- data/lib/offsite_payments/integrations/nochex.rb +228 -0
- data/lib/offsite_payments/integrations/pag_seguro.rb +255 -0
- data/lib/offsite_payments/integrations/paxum.rb +114 -0
- data/lib/offsite_payments/integrations/pay_fast.rb +269 -0
- data/lib/offsite_payments/integrations/paydollar.rb +142 -0
- data/lib/offsite_payments/integrations/payflow_link.rb +194 -0
- data/lib/offsite_payments/integrations/paypal.rb +362 -0
- data/lib/offsite_payments/integrations/paypal_payments_advanced.rb +23 -0
- data/lib/offsite_payments/integrations/paysbuy.rb +71 -0
- data/lib/offsite_payments/integrations/payu_in.rb +266 -0
- data/lib/offsite_payments/integrations/payu_in_paisa.rb +46 -0
- data/lib/offsite_payments/integrations/platron.rb +153 -0
- data/lib/offsite_payments/integrations/pxpay.rb +271 -0
- data/lib/offsite_payments/integrations/quickpay.rb +232 -0
- data/lib/offsite_payments/integrations/rbkmoney.rb +110 -0
- data/lib/offsite_payments/integrations/robokassa.rb +154 -0
- data/lib/offsite_payments/integrations/sage_pay_form.rb +425 -0
- data/lib/offsite_payments/integrations/two_checkout.rb +332 -0
- data/lib/offsite_payments/integrations/universal.rb +180 -0
- data/lib/offsite_payments/integrations/valitor.rb +200 -0
- data/lib/offsite_payments/integrations/verkkomaksut.rb +143 -0
- data/lib/offsite_payments/integrations/web_pay.rb +186 -0
- data/lib/offsite_payments/integrations/webmoney.rb +119 -0
- data/lib/offsite_payments/integrations/wirecard_checkout_page.rb +359 -0
- data/lib/offsite_payments/integrations/world_pay.rb +273 -0
- data/lib/offsite_payments/notification.rb +71 -0
- data/lib/offsite_payments/return.rb +37 -0
- data/lib/offsite_payments/version.rb +3 -0
- metadata +270 -0
@@ -0,0 +1,150 @@
|
|
1
|
+
module OffsitePayments #:nodoc:
|
2
|
+
module Integrations #:nodoc:
|
3
|
+
module BitPay
|
4
|
+
mattr_accessor :service_url
|
5
|
+
self.service_url = 'https://bitpay.com/invoice'
|
6
|
+
|
7
|
+
mattr_accessor :invoicing_url
|
8
|
+
self.invoicing_url = 'https://bitpay.com/api/invoice'
|
9
|
+
|
10
|
+
def self.notification(post, options = {})
|
11
|
+
Notification.new(post, options)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.helper(order, account, options = {})
|
15
|
+
Helper.new(order, account, options)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.return(query_string, options = {})
|
19
|
+
Return.new(query_string)
|
20
|
+
end
|
21
|
+
|
22
|
+
class Helper < OffsitePayments::Helper
|
23
|
+
def initialize(order_id, account, options)
|
24
|
+
super
|
25
|
+
@account = account
|
26
|
+
|
27
|
+
add_field('posData', {'orderId' => order_id}.to_json)
|
28
|
+
add_field('fullNotifications', true)
|
29
|
+
add_field('transactionSpeed', 'high')
|
30
|
+
end
|
31
|
+
|
32
|
+
mapping :amount, 'price'
|
33
|
+
mapping :order, 'orderID'
|
34
|
+
mapping :currency, 'currency'
|
35
|
+
|
36
|
+
mapping :customer, :first_name => 'buyerName',
|
37
|
+
:email => 'buyerEmail',
|
38
|
+
:phone => 'buyerPhone'
|
39
|
+
|
40
|
+
mapping :billing_address, :city => 'buyerCity',
|
41
|
+
:address1 => 'buyerAddress1',
|
42
|
+
:address2 => 'buyerAddress2',
|
43
|
+
:state => 'buyerState',
|
44
|
+
:zip => 'buyerZip',
|
45
|
+
:country => 'buyerCountry'
|
46
|
+
|
47
|
+
mapping :notify_url, 'notificationURL'
|
48
|
+
mapping :return_url, 'redirectURL'
|
49
|
+
mapping :id, 'id'
|
50
|
+
|
51
|
+
def form_method
|
52
|
+
"GET"
|
53
|
+
end
|
54
|
+
|
55
|
+
def form_fields
|
56
|
+
invoice = create_invoice
|
57
|
+
|
58
|
+
raise ActionViewHelperError, "Invalid response while retrieving BitPay Invoice ID. Please try again." unless invoice
|
59
|
+
|
60
|
+
{"id" => invoice['id']}
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def create_invoice
|
66
|
+
uri = URI.parse(BitPay.invoicing_url)
|
67
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
68
|
+
http.use_ssl = true
|
69
|
+
|
70
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
71
|
+
request.content_type = "application/json"
|
72
|
+
request.body = @fields.to_json
|
73
|
+
request.basic_auth @account, ''
|
74
|
+
|
75
|
+
response = http.request(request)
|
76
|
+
JSON.parse(response.body)
|
77
|
+
rescue JSON::ParserError
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
class Notification < OffsitePayments::Notification
|
82
|
+
def complete?
|
83
|
+
status == "Completed"
|
84
|
+
end
|
85
|
+
|
86
|
+
def transaction_id
|
87
|
+
params['id']
|
88
|
+
end
|
89
|
+
|
90
|
+
def item_id
|
91
|
+
JSON.parse(params['posData'])['orderId']
|
92
|
+
rescue JSON::ParserError
|
93
|
+
end
|
94
|
+
|
95
|
+
def status
|
96
|
+
case params['status']
|
97
|
+
when 'complete'
|
98
|
+
'Completed'
|
99
|
+
when 'confirmed'
|
100
|
+
'Pending'
|
101
|
+
when 'invalid'
|
102
|
+
'Failed'
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
# When was this payment received by the client.
|
107
|
+
def received_at
|
108
|
+
params['invoiceTime'].to_i
|
109
|
+
end
|
110
|
+
|
111
|
+
def currency
|
112
|
+
params['currency']
|
113
|
+
end
|
114
|
+
|
115
|
+
def gross
|
116
|
+
params['price'].to_f
|
117
|
+
end
|
118
|
+
|
119
|
+
def acknowledge(authcode = nil)
|
120
|
+
uri = URI.parse("#{OffsitePayments::Integrations::BitPay.invoicing_url}/#{transaction_id}")
|
121
|
+
|
122
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
123
|
+
http.use_ssl = true
|
124
|
+
|
125
|
+
request = Net::HTTP::Get.new(uri.path)
|
126
|
+
request.basic_auth @options[:credential1], ''
|
127
|
+
|
128
|
+
response = http.request(request)
|
129
|
+
|
130
|
+
posted_json = JSON.parse(@raw).tap { |j| j.delete('currentTime') }
|
131
|
+
parse(response.body)
|
132
|
+
retrieved_json = JSON.parse(@raw).tap { |j| j.delete('currentTime') }
|
133
|
+
|
134
|
+
posted_json == retrieved_json
|
135
|
+
rescue JSON::ParserError
|
136
|
+
end
|
137
|
+
|
138
|
+
private
|
139
|
+
def parse(body)
|
140
|
+
@raw = body
|
141
|
+
@params = JSON.parse(@raw)
|
142
|
+
rescue JSON::ParserError
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
class Return < OffsitePayments::Return
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module OffsitePayments #:nodoc:
|
2
|
+
module Integrations #:nodoc:
|
3
|
+
module Bogus
|
4
|
+
mattr_accessor :service_url
|
5
|
+
self.service_url = 'http://www.bogus.com'
|
6
|
+
|
7
|
+
def self.notification(post, options = {})
|
8
|
+
Notification.new(post)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.return(query_string, options = {})
|
12
|
+
Return.new(query_string)
|
13
|
+
end
|
14
|
+
|
15
|
+
class Helper < OffsitePayments::Helper
|
16
|
+
mapping :account, 'account'
|
17
|
+
mapping :order, 'order'
|
18
|
+
mapping :amount, 'amount'
|
19
|
+
mapping :currency, 'currency'
|
20
|
+
mapping :customer, :first_name => 'first_name',
|
21
|
+
:last_name => 'last_name'
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
class Notification < OffsitePayments::Notification
|
26
|
+
end
|
27
|
+
|
28
|
+
class Return < OffsitePayments::Return
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,283 @@
|
|
1
|
+
module OffsitePayments #:nodoc:
|
2
|
+
module Integrations #:nodoc:
|
3
|
+
module Chronopay
|
4
|
+
mattr_accessor :service_url
|
5
|
+
self.service_url = 'https://secure.chronopay.com/index_shop.cgi'
|
6
|
+
|
7
|
+
def self.notification(post, options = {})
|
8
|
+
Notification.new(post)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.return(query_string, options = {})
|
12
|
+
Return.new(query_string)
|
13
|
+
end
|
14
|
+
|
15
|
+
class Helper < OffsitePayments::Helper
|
16
|
+
# All currently supported checkout languages:
|
17
|
+
# es (Spanish)
|
18
|
+
# en (English)
|
19
|
+
# de (German)
|
20
|
+
# pt (Portuguese)
|
21
|
+
# lv (Latvian)
|
22
|
+
# cn1 (Chinese Version 1)
|
23
|
+
# cn2 (Chinese version 2)
|
24
|
+
# nl (Dutch)
|
25
|
+
# ru (Russian)
|
26
|
+
COUNTRIES_FOR_LANG = {
|
27
|
+
'ES' => %w( AR BO CL CO CR CU DO EC SV GQ GT HN MX NI PA PY PE ES UY VE),
|
28
|
+
'DE' => %w( DE AT CH LI ),
|
29
|
+
'PT' => %w( AO BR CV GW MZ PT ST TL),
|
30
|
+
'RU' => %w( BY KG KZ RU ),
|
31
|
+
'LV' => %w( LV ),
|
32
|
+
'CN1' => %w( CN ),
|
33
|
+
'NL' => %w( NL )
|
34
|
+
}
|
35
|
+
|
36
|
+
LANG_FOR_COUNTRY = COUNTRIES_FOR_LANG.inject(Hash.new("EN")) do |memo, (lang, countries)|
|
37
|
+
countries.each do |code|
|
38
|
+
memo[code] = lang
|
39
|
+
end
|
40
|
+
memo
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
self.country_format = :alpha3
|
45
|
+
|
46
|
+
def initialize(order, account, options = {})
|
47
|
+
super
|
48
|
+
add_field('cb_type', 'p')
|
49
|
+
end
|
50
|
+
|
51
|
+
# product_id
|
52
|
+
mapping :account, 'product_id'
|
53
|
+
# product_name
|
54
|
+
mapping :invoice, 'product_name'
|
55
|
+
# product_price
|
56
|
+
mapping :amount, 'product_price'
|
57
|
+
# product_price_currency
|
58
|
+
mapping :currency, 'product_price_currency'
|
59
|
+
|
60
|
+
# f_name
|
61
|
+
# s_name
|
62
|
+
# email
|
63
|
+
mapping :customer, :first_name => 'f_name',
|
64
|
+
:last_name => 's_name',
|
65
|
+
:phone => 'phone',
|
66
|
+
:email => 'email'
|
67
|
+
|
68
|
+
# city
|
69
|
+
# street
|
70
|
+
# state
|
71
|
+
# zip
|
72
|
+
# country - The country must be a 3 digit country code
|
73
|
+
# phone
|
74
|
+
|
75
|
+
mapping :billing_address, :city => 'city',
|
76
|
+
:address1 => 'street',
|
77
|
+
:state => 'state',
|
78
|
+
:zip => 'zip',
|
79
|
+
:country => 'country'
|
80
|
+
|
81
|
+
def billing_address(mapping = {})
|
82
|
+
# Gets the country code in the appropriate format or returns what we were given
|
83
|
+
# The appropriate format for Chronopay is the alpha 3 country code
|
84
|
+
country_code = lookup_country_code(mapping.delete(:country))
|
85
|
+
add_field(mappings[:billing_address][:country], country_code)
|
86
|
+
|
87
|
+
countries_with_supported_states = ['USA', 'CAN']
|
88
|
+
if !countries_with_supported_states.include?(country_code)
|
89
|
+
mapping.delete(:state)
|
90
|
+
add_field(mappings[:billing_address][:state], 'XX')
|
91
|
+
end
|
92
|
+
mapping.each do |k, v|
|
93
|
+
field = mappings[:billing_address][k]
|
94
|
+
add_field(field, v) unless field.nil?
|
95
|
+
end
|
96
|
+
add_field('language', checkout_language_from_country(country_code))
|
97
|
+
end
|
98
|
+
|
99
|
+
# card_no
|
100
|
+
# exp_month
|
101
|
+
# exp_year
|
102
|
+
mapping :credit_card, :number => 'card_no',
|
103
|
+
:expiry_month => 'exp_month',
|
104
|
+
:expiry_year => 'exp_year'
|
105
|
+
|
106
|
+
# cb_url
|
107
|
+
mapping :notify_url, 'cb_url'
|
108
|
+
|
109
|
+
# cs1
|
110
|
+
mapping :order, 'cs1'
|
111
|
+
|
112
|
+
# cs2
|
113
|
+
# cs3
|
114
|
+
# decline_url
|
115
|
+
|
116
|
+
|
117
|
+
private
|
118
|
+
|
119
|
+
def checkout_language_from_country(country_code)
|
120
|
+
country = ActiveMerchant::Country.find(country_code)
|
121
|
+
short_code = country.code(:alpha2).to_s
|
122
|
+
LANG_FOR_COUNTRY[short_code]
|
123
|
+
rescue ActiveMerchant::InvalidCountryCodeError
|
124
|
+
'EN'
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
class Notification < OffsitePayments::Notification
|
129
|
+
def complete?
|
130
|
+
status == 'Completed'
|
131
|
+
end
|
132
|
+
|
133
|
+
# Status of transaction. List of possible values:
|
134
|
+
# <tt>onetime – one time payment has been made, no repayment required;</tt>::
|
135
|
+
# <tt>initial – first payment has been made, repayment required in corresponding period;</tt>::
|
136
|
+
# <tt>decline – charge request has been rejected;</tt>::
|
137
|
+
# <tt>rebill – repayment has been made together with initial transaction;</ttt>::
|
138
|
+
# <tt>cancel – repayments has been disabled;</tt>::
|
139
|
+
# <tt>expire – customer’s access to restricted zone membership has been expired;</tt>::
|
140
|
+
# <tt>refund – request to refund has been received;</tt>::
|
141
|
+
# <tt>chargeback – request to chargeback has been received.</tt>::
|
142
|
+
#
|
143
|
+
# This implementation of Chronopay does not support subscriptions.
|
144
|
+
# The status codes used are matched to the status codes that Paypal
|
145
|
+
# sends. See Paypal::Notification#status for more details
|
146
|
+
def status
|
147
|
+
case params['transaction_type']
|
148
|
+
when 'onetime'
|
149
|
+
'Completed'
|
150
|
+
when 'refund'
|
151
|
+
'Refunded'
|
152
|
+
when 'chargeback'
|
153
|
+
'Reversed'
|
154
|
+
else
|
155
|
+
'Failed'
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
# Unique ID of transaction
|
160
|
+
def transaction_id
|
161
|
+
params['transaction_id']
|
162
|
+
end
|
163
|
+
|
164
|
+
# Unique ID of customer
|
165
|
+
def customer_id
|
166
|
+
params['customer_id']
|
167
|
+
end
|
168
|
+
|
169
|
+
# Unique ID of Merchant’s web-site
|
170
|
+
def site_id
|
171
|
+
params['site_id']
|
172
|
+
end
|
173
|
+
|
174
|
+
# ID of a product that was purchased
|
175
|
+
def product_id
|
176
|
+
params['product_id']
|
177
|
+
end
|
178
|
+
|
179
|
+
# Language
|
180
|
+
def language
|
181
|
+
params['language']
|
182
|
+
end
|
183
|
+
|
184
|
+
def received_at
|
185
|
+
# Date should be formatted "dd-mm-yy" to be parsed by 1.8 and 1.9 the same way
|
186
|
+
formatted_date = Date.strptime(date, "%m/%d/%Y").strftime("%d-%m-%Y")
|
187
|
+
Time.parse("#{formatted_date} #{time}") unless date.blank? || time.blank?
|
188
|
+
end
|
189
|
+
|
190
|
+
# Date of transaction in MM/DD/YYYY format
|
191
|
+
def date
|
192
|
+
params['date']
|
193
|
+
end
|
194
|
+
|
195
|
+
# Time of transaction in HH:MM:SS format
|
196
|
+
def time
|
197
|
+
params['time']
|
198
|
+
end
|
199
|
+
|
200
|
+
# The customer's full name
|
201
|
+
def name
|
202
|
+
params['name']
|
203
|
+
end
|
204
|
+
|
205
|
+
# The customer's email address
|
206
|
+
def email
|
207
|
+
params['email']
|
208
|
+
end
|
209
|
+
|
210
|
+
# The customer's street address
|
211
|
+
def street
|
212
|
+
params['street']
|
213
|
+
end
|
214
|
+
|
215
|
+
# The customer's country - 3 digit country code
|
216
|
+
def country
|
217
|
+
params['country']
|
218
|
+
end
|
219
|
+
|
220
|
+
# The customer's city
|
221
|
+
def city
|
222
|
+
params['city']
|
223
|
+
end
|
224
|
+
|
225
|
+
# The customer's zip
|
226
|
+
def zip
|
227
|
+
params['zip']
|
228
|
+
end
|
229
|
+
|
230
|
+
# The customer's state. Only useful for US Customers
|
231
|
+
def state
|
232
|
+
params['state']
|
233
|
+
end
|
234
|
+
|
235
|
+
# Customer’s login for restricted access zone of Merchant’s Web-site
|
236
|
+
def username
|
237
|
+
params['username']
|
238
|
+
end
|
239
|
+
|
240
|
+
# Customer's password for restricted access zone of Merchant’s Web-site, as chosen
|
241
|
+
def password
|
242
|
+
params['password']
|
243
|
+
end
|
244
|
+
|
245
|
+
# The item id passed in the first custom parameter
|
246
|
+
def item_id
|
247
|
+
params['cs1']
|
248
|
+
end
|
249
|
+
|
250
|
+
# Additional parameter
|
251
|
+
def custom2
|
252
|
+
params['cs2']
|
253
|
+
end
|
254
|
+
|
255
|
+
# Additional parameter
|
256
|
+
def custom3
|
257
|
+
params['cs3']
|
258
|
+
end
|
259
|
+
|
260
|
+
# The currency the purchase was made in
|
261
|
+
def currency
|
262
|
+
params['currency']
|
263
|
+
end
|
264
|
+
|
265
|
+
# the money amount we received in X.2 decimal.
|
266
|
+
def gross
|
267
|
+
params['total']
|
268
|
+
end
|
269
|
+
|
270
|
+
def test?
|
271
|
+
date.blank? && time.blank? && transaction_id.blank?
|
272
|
+
end
|
273
|
+
|
274
|
+
def acknowledge(authcode = nil)
|
275
|
+
true
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
class Return < OffsitePayments::Return
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
283
|
+
end
|