offsite_payments 2.0.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/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,160 @@
|
|
1
|
+
module OffsitePayments #:nodoc:
|
2
|
+
module Integrations #:nodoc:
|
3
|
+
module Dwolla
|
4
|
+
mattr_accessor :service_url
|
5
|
+
self.service_url = 'https://www.dwolla.com/payment/pay'
|
6
|
+
|
7
|
+
def self.notification(post, options={})
|
8
|
+
Notification.new(post, options)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.return(query_string, options={})
|
12
|
+
Return.new(query_string, options)
|
13
|
+
end
|
14
|
+
|
15
|
+
module Common
|
16
|
+
def verify_signature(checkoutId, amount, notification_signature, secret)
|
17
|
+
if secret.nil?
|
18
|
+
raise ArgumentError, "You need to provide the Application secret as the option :credential3 to verify that the notification originated from Dwolla"
|
19
|
+
end
|
20
|
+
|
21
|
+
expected_signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA1.new, secret, "%s&%.2f" % [checkoutId, amount])
|
22
|
+
|
23
|
+
if notification_signature != expected_signature
|
24
|
+
raise StandardError, "Dwolla signature verification failed."
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class Helper < OffsitePayments::Helper
|
30
|
+
def initialize(order, account, options = {})
|
31
|
+
super
|
32
|
+
add_field('name', 'Store Purchase')
|
33
|
+
|
34
|
+
timestamp = Time.now.to_i.to_s
|
35
|
+
|
36
|
+
if OffsitePayments.mode == :test || options[:test]
|
37
|
+
add_field('test', 'true')
|
38
|
+
# timestamp used for test signature generation:
|
39
|
+
timestamp = "1370726016"
|
40
|
+
end
|
41
|
+
|
42
|
+
add_field('timestamp', timestamp)
|
43
|
+
add_field('allowFundingSources', 'true')
|
44
|
+
|
45
|
+
key = options[:credential2].to_s
|
46
|
+
secret = options[:credential3].to_s
|
47
|
+
orderid = order.to_s
|
48
|
+
signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA1.new, secret, "#{key}&#{timestamp}&#{orderid}")
|
49
|
+
add_field('signature', signature)
|
50
|
+
end
|
51
|
+
|
52
|
+
mapping :account, 'destinationid'
|
53
|
+
mapping :credential2, 'key'
|
54
|
+
mapping :notify_url, 'callback'
|
55
|
+
mapping :return_url, 'redirect'
|
56
|
+
mapping :description, 'description'
|
57
|
+
mapping :amount, 'amount'
|
58
|
+
mapping :tax, 'tax'
|
59
|
+
mapping :shipping, 'shipping'
|
60
|
+
mapping :order, 'orderid'
|
61
|
+
end
|
62
|
+
|
63
|
+
class Notification < OffsitePayments::Notification
|
64
|
+
include Common
|
65
|
+
|
66
|
+
def initialize(data, options)
|
67
|
+
super
|
68
|
+
end
|
69
|
+
|
70
|
+
def complete?
|
71
|
+
(status == "Completed")
|
72
|
+
end
|
73
|
+
|
74
|
+
def status
|
75
|
+
params["Status"]
|
76
|
+
end
|
77
|
+
|
78
|
+
def transaction_id
|
79
|
+
params['TransactionId']
|
80
|
+
end
|
81
|
+
|
82
|
+
def item_id
|
83
|
+
params['OrderId']
|
84
|
+
end
|
85
|
+
|
86
|
+
def currency
|
87
|
+
"USD"
|
88
|
+
end
|
89
|
+
|
90
|
+
def gross
|
91
|
+
params['Amount']
|
92
|
+
end
|
93
|
+
|
94
|
+
def error
|
95
|
+
params['Error']
|
96
|
+
end
|
97
|
+
|
98
|
+
def test?
|
99
|
+
params['TestMode'] != "false"
|
100
|
+
end
|
101
|
+
|
102
|
+
def acknowledge(authcode = nil)
|
103
|
+
true
|
104
|
+
end
|
105
|
+
|
106
|
+
private
|
107
|
+
|
108
|
+
def parse(post)
|
109
|
+
@raw = post.to_s
|
110
|
+
json_post = JSON.parse(post)
|
111
|
+
verify_signature(json_post['CheckoutId'], json_post['Amount'], json_post['Signature'], @options[:credential3])
|
112
|
+
|
113
|
+
params.merge!(json_post)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
class Return < OffsitePayments::Return
|
118
|
+
include Common
|
119
|
+
|
120
|
+
def initialize(data, options)
|
121
|
+
params = parse(data)
|
122
|
+
|
123
|
+
if params['error'] != 'failure'
|
124
|
+
verify_signature(params['checkoutId'], params['amount'], params['signature'], options[:credential3])
|
125
|
+
end
|
126
|
+
|
127
|
+
super
|
128
|
+
end
|
129
|
+
|
130
|
+
def success?
|
131
|
+
(self.error.nil? && self.callback_success?)
|
132
|
+
end
|
133
|
+
|
134
|
+
def error
|
135
|
+
params['error']
|
136
|
+
end
|
137
|
+
|
138
|
+
def error_description
|
139
|
+
params['error_description']
|
140
|
+
end
|
141
|
+
|
142
|
+
def checkout_id
|
143
|
+
params['checkoutId']
|
144
|
+
end
|
145
|
+
|
146
|
+
def transaction
|
147
|
+
params['transaction']
|
148
|
+
end
|
149
|
+
|
150
|
+
def test?
|
151
|
+
params['test'] != nil
|
152
|
+
end
|
153
|
+
|
154
|
+
def callback_success?
|
155
|
+
(params['postback'] != "failure")
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
module OffsitePayments #:nodoc:
|
2
|
+
module Integrations #:nodoc:
|
3
|
+
module EPaymentPlans
|
4
|
+
mattr_accessor :production_url
|
5
|
+
self.production_url = 'https://www.epaymentplans.com'
|
6
|
+
|
7
|
+
mattr_accessor :test_url
|
8
|
+
self.test_url = 'https://test.epaymentplans.com'
|
9
|
+
|
10
|
+
def self.service_url
|
11
|
+
mode = OffsitePayments.mode
|
12
|
+
case mode
|
13
|
+
when :production
|
14
|
+
"#{production_url}/order/purchase"
|
15
|
+
when :test
|
16
|
+
"#{test_url}/order/purchase"
|
17
|
+
else
|
18
|
+
raise StandardError, "Integration mode set to an invalid value: #{mode}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.notification_confirmation_url
|
23
|
+
mode = OffsitePayments.mode
|
24
|
+
case mode
|
25
|
+
when :production
|
26
|
+
"#{production_url}/order/confirmation"
|
27
|
+
when :test
|
28
|
+
"#{test_url}/order/confirmation"
|
29
|
+
else
|
30
|
+
raise StandardError, "Integration mode set to an invalid value: #{mode}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.notification(post, options = {})
|
35
|
+
Notification.new(post, options)
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.return(query_string, options = {})
|
39
|
+
Return.new(query_string, options)
|
40
|
+
end
|
41
|
+
|
42
|
+
class Helper < OffsitePayments::Helper
|
43
|
+
mapping :account, 'order[account]'
|
44
|
+
mapping :amount, 'order[amount]'
|
45
|
+
|
46
|
+
mapping :order, 'order[num]'
|
47
|
+
|
48
|
+
mapping :customer, :first_name => 'order[first_name]',
|
49
|
+
:last_name => 'order[last_name]',
|
50
|
+
:email => 'order[email]',
|
51
|
+
:phone => 'order[phone]'
|
52
|
+
|
53
|
+
mapping :billing_address, :city => 'order[city]',
|
54
|
+
:address1 => 'order[address1]',
|
55
|
+
:address2 => 'order[address2]',
|
56
|
+
:company => 'order[company]',
|
57
|
+
:state => 'order[state]',
|
58
|
+
:zip => 'order[zip]',
|
59
|
+
:country => 'order[country]'
|
60
|
+
|
61
|
+
mapping :notify_url, 'order[notify_url]'
|
62
|
+
mapping :return_url, 'order[return_url]'
|
63
|
+
mapping :cancel_return_url, 'order[cancel_return_url]'
|
64
|
+
mapping :description, 'order[description]'
|
65
|
+
mapping :tax, 'order[tax]'
|
66
|
+
mapping :shipping, 'order[shipping]'
|
67
|
+
end
|
68
|
+
|
69
|
+
class Notification < OffsitePayments::Notification
|
70
|
+
include ActiveMerchant::PostsData
|
71
|
+
def complete?
|
72
|
+
status == "Completed"
|
73
|
+
end
|
74
|
+
|
75
|
+
def transaction_id
|
76
|
+
params['transaction_id']
|
77
|
+
end
|
78
|
+
|
79
|
+
def item_id
|
80
|
+
params['item_id']
|
81
|
+
end
|
82
|
+
|
83
|
+
# When was this payment received by the client.
|
84
|
+
def received_at
|
85
|
+
Time.parse(params['received_at'].to_s).utc
|
86
|
+
end
|
87
|
+
|
88
|
+
def gross
|
89
|
+
params['gross']
|
90
|
+
end
|
91
|
+
|
92
|
+
def currency
|
93
|
+
params['currency']
|
94
|
+
end
|
95
|
+
|
96
|
+
def security_key
|
97
|
+
params['security_key']
|
98
|
+
end
|
99
|
+
|
100
|
+
# Was this a test transaction?
|
101
|
+
def test?
|
102
|
+
params['test'] == 'test'
|
103
|
+
end
|
104
|
+
|
105
|
+
def status
|
106
|
+
params['status'].capitalize
|
107
|
+
end
|
108
|
+
|
109
|
+
# Acknowledge the transaction to EPaymentPlans. This method has to be called after a new
|
110
|
+
# apc arrives. EPaymentPlans will verify that all the information we received are correct
|
111
|
+
# and will return ok or a fail.
|
112
|
+
#
|
113
|
+
# Example:
|
114
|
+
#
|
115
|
+
# def ipn
|
116
|
+
# notify = EPaymentPlans.notification(request.raw_post)
|
117
|
+
#
|
118
|
+
# if notify.acknowledge
|
119
|
+
# ... process order ... if notify.complete?
|
120
|
+
# else
|
121
|
+
# ... log possible hacking attempt ...
|
122
|
+
# end
|
123
|
+
def acknowledge(authcode = nil)
|
124
|
+
payload = raw
|
125
|
+
|
126
|
+
response = ssl_post(EPaymentPlans.notification_confirmation_url, payload)
|
127
|
+
|
128
|
+
# Replace with the appropriate codes
|
129
|
+
raise StandardError.new("Faulty EPaymentPlans result: #{response}") unless ["AUTHORISED", "DECLINED"].include?(response)
|
130
|
+
response == "AUTHORISED"
|
131
|
+
end
|
132
|
+
|
133
|
+
private
|
134
|
+
|
135
|
+
# Take the posted data and move the relevant data into a hash
|
136
|
+
def parse(post)
|
137
|
+
@raw = post
|
138
|
+
for line in post.split('&')
|
139
|
+
key, value = *line.scan( %r{^(\w+)\=(.*)$} ).flatten
|
140
|
+
params[key] = value
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
module OffsitePayments #:nodoc:
|
2
|
+
module Integrations #:nodoc:
|
3
|
+
# Documentation: https://ssl.easypay.by/light/
|
4
|
+
module EasyPay
|
5
|
+
mattr_accessor :signature_parameter_name
|
6
|
+
self.signature_parameter_name = 'EP_Hash'
|
7
|
+
|
8
|
+
mattr_accessor :notify_signature_parameter_name
|
9
|
+
self.notify_signature_parameter_name = 'notify_signature'
|
10
|
+
|
11
|
+
mattr_accessor :service_url
|
12
|
+
self.service_url = 'https://ssl.easypay.by/weborder/'
|
13
|
+
|
14
|
+
def self.helper(order, account, options = {})
|
15
|
+
Helper.new(order, account, options)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.notification(query_string, options = {})
|
19
|
+
Notification.new(query_string, options)
|
20
|
+
end
|
21
|
+
|
22
|
+
module Common
|
23
|
+
def generate_signature(type)
|
24
|
+
string = case type
|
25
|
+
when :request
|
26
|
+
request_signature_string
|
27
|
+
when :notify
|
28
|
+
notify_signature_string
|
29
|
+
end
|
30
|
+
|
31
|
+
Digest::MD5.hexdigest(string)
|
32
|
+
end
|
33
|
+
|
34
|
+
def request_signature_string
|
35
|
+
[
|
36
|
+
@fields[mappings[:account]],
|
37
|
+
@secret,
|
38
|
+
@fields[mappings[:order]],
|
39
|
+
@fields[mappings[:amount]]
|
40
|
+
].join
|
41
|
+
end
|
42
|
+
|
43
|
+
def notify_signature_string
|
44
|
+
[
|
45
|
+
params['order_mer_code'],
|
46
|
+
params['sum'],
|
47
|
+
params['mer_no'],
|
48
|
+
params['card'],
|
49
|
+
params['purch_date'],
|
50
|
+
secret
|
51
|
+
].join
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class Helper < OffsitePayments::Helper
|
56
|
+
include Common
|
57
|
+
|
58
|
+
def initialize(order, account, options = {})
|
59
|
+
super
|
60
|
+
@secret = options[:credential2]
|
61
|
+
end
|
62
|
+
|
63
|
+
def form_fields
|
64
|
+
@fields.merge(OffsitePayments::Integrations::EasyPay.signature_parameter_name => generate_signature(:request))
|
65
|
+
end
|
66
|
+
|
67
|
+
def params
|
68
|
+
@fields
|
69
|
+
end
|
70
|
+
|
71
|
+
mapping :account, 'EP_MerNo'
|
72
|
+
mapping :amount, 'EP_Sum'
|
73
|
+
mapping :order, 'EP_OrderNo'
|
74
|
+
mapping :comment, 'EP_Comment'
|
75
|
+
mapping :order_info, 'EP_OrderInfo'
|
76
|
+
mapping :expires, 'EP_Expires'
|
77
|
+
mapping :success_url, 'EP_Success_URL'
|
78
|
+
mapping :cancel_url, 'EP_Cancel_URL'
|
79
|
+
mapping :debug, 'EP_Debug'
|
80
|
+
mapping :url_type, 'EP_URL_Type'
|
81
|
+
mapping :encoding, 'EP_Encoding'
|
82
|
+
end
|
83
|
+
|
84
|
+
class Notification < OffsitePayments::Notification
|
85
|
+
include Common
|
86
|
+
|
87
|
+
def initialize(data, options)
|
88
|
+
if options[:credential2].nil?
|
89
|
+
raise ArgumentError, "You need to provide the md5 secret as the option :credential2 to verify that the notification originated from EasyPay"
|
90
|
+
end
|
91
|
+
|
92
|
+
super
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.recognizes?(params)
|
96
|
+
params.has_key?('order_mer_code') && params.has_key?('sum')
|
97
|
+
end
|
98
|
+
|
99
|
+
def complete?
|
100
|
+
true
|
101
|
+
end
|
102
|
+
|
103
|
+
def amount
|
104
|
+
BigDecimal.new(gross)
|
105
|
+
end
|
106
|
+
|
107
|
+
def item_id
|
108
|
+
params['order_mer_code']
|
109
|
+
end
|
110
|
+
|
111
|
+
def security_key
|
112
|
+
params[OffsitePayments::Integrations::EasyPay.notify_signature_parameter_name]
|
113
|
+
end
|
114
|
+
|
115
|
+
def gross
|
116
|
+
params['sum']
|
117
|
+
end
|
118
|
+
|
119
|
+
def status
|
120
|
+
'Completed'
|
121
|
+
end
|
122
|
+
|
123
|
+
def secret
|
124
|
+
@options[:credential2]
|
125
|
+
end
|
126
|
+
|
127
|
+
def acknowledge(authcode = nil)
|
128
|
+
security_key == generate_signature(:notify)
|
129
|
+
end
|
130
|
+
|
131
|
+
def success_response(*args)
|
132
|
+
{ :nothing => true }
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
@@ -0,0 +1,161 @@
|
|
1
|
+
module OffsitePayments #:nodoc:
|
2
|
+
module Integrations #:nodoc:
|
3
|
+
module Epay
|
4
|
+
mattr_accessor :service_url
|
5
|
+
self.service_url = 'https://ssl.ditonlinebetalingssystem.dk/integration/ewindow/Default.aspx'
|
6
|
+
|
7
|
+
def self.notification(post, options = {})
|
8
|
+
Notification.new(post)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.return(post, options = {})
|
12
|
+
Return.new(post, options)
|
13
|
+
end
|
14
|
+
|
15
|
+
class Helper < OffsitePayments::Helper
|
16
|
+
def initialize(order, merchantnumber, options = {})
|
17
|
+
super
|
18
|
+
add_field('windowstate', 3)
|
19
|
+
add_field('language', '0')
|
20
|
+
add_field('orderid', format_order_number(order))
|
21
|
+
@fields = Hash[@fields.sort]
|
22
|
+
end
|
23
|
+
|
24
|
+
def md5secret(value)
|
25
|
+
@md5secret = value
|
26
|
+
end
|
27
|
+
|
28
|
+
def form_fields
|
29
|
+
@fields.merge('hash' => generate_md5hash)
|
30
|
+
end
|
31
|
+
|
32
|
+
def generate_md5string
|
33
|
+
@fields.sort.each.map { |key, value| key != 'hash' ? value.to_s : ''} * "" + @md5secret
|
34
|
+
end
|
35
|
+
|
36
|
+
def generate_md5hash
|
37
|
+
Digest::MD5.hexdigest(generate_md5string)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Limited to 20 digits max
|
41
|
+
def format_order_number(number)
|
42
|
+
number.to_s.gsub(/[^\w_]/, '').rjust(4, "0")[0...20]
|
43
|
+
end
|
44
|
+
|
45
|
+
mapping :account, 'merchantnumber'
|
46
|
+
mapping :language, 'language'
|
47
|
+
mapping :amount, 'amount'
|
48
|
+
mapping :currency, 'currency'
|
49
|
+
mapping :return_url, 'accepturl'
|
50
|
+
mapping :cancel_return_url, 'cancelurl'
|
51
|
+
mapping :notify_url, 'callbackurl'
|
52
|
+
mapping :autocapture, 'instantcapture'
|
53
|
+
mapping :description, 'description'
|
54
|
+
mapping :credential3, 'md5secret'
|
55
|
+
mapping :customer, ''
|
56
|
+
mapping :billing_address, {}
|
57
|
+
mapping :tax, ''
|
58
|
+
mapping :shipping, ''
|
59
|
+
end
|
60
|
+
|
61
|
+
class Notification < OffsitePayments::Notification
|
62
|
+
CURRENCY_CODES = {
|
63
|
+
:ADP => '020', :AED => '784', :AFA => '004', :ALL => '008', :AMD => '051',
|
64
|
+
:ANG => '532', :AOA => '973', :ARS => '032', :AUD => '036', :AWG => '533',
|
65
|
+
:AZM => '031', :BAM => '977', :BBD => '052', :BDT => '050', :BGL => '100',
|
66
|
+
:BGN => '975', :BHD => '048', :BIF => '108', :BMD => '060', :BND => '096',
|
67
|
+
:BOB => '068', :BOV => '984', :BRL => '986', :BSD => '044', :BTN => '064',
|
68
|
+
:BWP => '072', :BYR => '974', :BZD => '084', :CAD => '124', :CDF => '976',
|
69
|
+
:CHF => '756', :CLF => '990', :CLP => '152', :CNY => '156', :COP => '170',
|
70
|
+
:CRC => '188', :CUP => '192', :CVE => '132', :CYP => '196', :CZK => '203',
|
71
|
+
:DJF => '262', :DKK => '208', :DOP => '214', :DZD => '012', :ECS => '218',
|
72
|
+
:ECV => '983', :EEK => '233', :EGP => '818', :ERN => '232', :ETB => '230',
|
73
|
+
:EUR => '978', :FJD => '242', :FKP => '238', :GBP => '826', :GEL => '981',
|
74
|
+
:GHC => '288', :GIP => '292', :GMD => '270', :GNF => '324', :GTQ => '320',
|
75
|
+
:GWP => '624', :GYD => '328', :HKD => '344', :HNL => '340', :HRK => '191',
|
76
|
+
:HTG => '332', :HUF => '348', :IDR => '360', :ILS => '376', :INR => '356',
|
77
|
+
:IQD => '368', :IRR => '364', :ISK => '352', :JMD => '388', :JOD => '400',
|
78
|
+
:JPY => '392', :KES => '404', :KGS => '417', :KHR => '116', :KMF => '174',
|
79
|
+
:KPW => '408', :KRW => '410', :KWD => '414', :KYD => '136', :KZT => '398',
|
80
|
+
:LAK => '418', :LBP => '422', :LKR => '144', :LRD => '430', :LSL => '426',
|
81
|
+
:LTL => '440', :LVL => '428', :LYD => '434', :MAD => '504', :MDL => '498',
|
82
|
+
:MGF => '450', :MKD => '807', :MMK => '104', :MNT => '496', :MOP => '446',
|
83
|
+
:MRO => '478', :MTL => '470', :MUR => '480', :MVR => '462', :MWK => '454',
|
84
|
+
:MXN => '484', :MXV => '979', :MYR => '458', :MZM => '508', :NAD => '516',
|
85
|
+
:NGN => '566', :NIO => '558', :NOK => '578', :NPR => '524', :NZD => '554',
|
86
|
+
:OMR => '512', :PAB => '590', :PEN => '604', :PGK => '598', :PHP => '608',
|
87
|
+
:PKR => '586', :PLN => '985', :PYG => '600', :QAR => '634', :ROL => '642',
|
88
|
+
:RUB => '643', :RUR => '810', :RWF => '646', :SAR => '682', :SBD => '090',
|
89
|
+
:SCR => '690', :SDD => '736', :SEK => '752', :SGD => '702', :SHP => '654',
|
90
|
+
:SIT => '705', :SKK => '703', :SLL => '694', :SOS => '706', :SRG => '740',
|
91
|
+
:STD => '678', :SVC => '222', :SYP => '760', :SZL => '748', :THB => '764',
|
92
|
+
:TJS => '972', :TMM => '795', :TND => '788', :TOP => '776', :TPE => '626',
|
93
|
+
:TRL => '792', :TRY => '949', :TTD => '780', :TWD => '901', :TZS => '834',
|
94
|
+
:UAH => '980', :UGX => '800', :USD => '840', :UYU => '858', :UZS => '860',
|
95
|
+
:VEB => '862', :VND => '704', :VUV => '548', :XAF => '950', :XCD => '951',
|
96
|
+
:XOF => '952', :XPF => '953', :YER => '886', :YUM => '891', :ZAR => '710',
|
97
|
+
:ZMK => '894', :ZWD => '716'
|
98
|
+
}
|
99
|
+
|
100
|
+
def complete?
|
101
|
+
Integer(transaction_id) > 0
|
102
|
+
end
|
103
|
+
|
104
|
+
def item_id
|
105
|
+
params['orderid']
|
106
|
+
end
|
107
|
+
|
108
|
+
def transaction_id
|
109
|
+
params['txnid']
|
110
|
+
end
|
111
|
+
|
112
|
+
def received_at
|
113
|
+
Time.mktime(params['date'][0..3], params['date'][4..5], params['date'][6..7], params['time'][0..1], params['time'][2..3])
|
114
|
+
end
|
115
|
+
|
116
|
+
def gross
|
117
|
+
"%.2f" % (gross_cents / 100.0)
|
118
|
+
end
|
119
|
+
|
120
|
+
def gross_cents
|
121
|
+
params['amount'].to_i
|
122
|
+
end
|
123
|
+
|
124
|
+
def test?
|
125
|
+
return false
|
126
|
+
end
|
127
|
+
|
128
|
+
%w(txnid orderid amount currency date time hash fraud payercountry issuercountry txnfee subscriptionid paymenttype cardno).each do |attr|
|
129
|
+
define_method(attr) do
|
130
|
+
params[attr]
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def currency
|
135
|
+
CURRENCY_CODES.invert[params['currency']].to_s
|
136
|
+
end
|
137
|
+
|
138
|
+
def amount
|
139
|
+
Money.new(params['amount'].to_i, currency)
|
140
|
+
end
|
141
|
+
|
142
|
+
def generate_md5string
|
143
|
+
md5string = String.new
|
144
|
+
for line in @raw.split('&')
|
145
|
+
key, value = *line.scan( %r{^([A-Za-z0-9_.]+)\=(.*)$} ).flatten
|
146
|
+
md5string += params[key] if key != 'hash'
|
147
|
+
end
|
148
|
+
return md5string + @options[:credential3]
|
149
|
+
end
|
150
|
+
|
151
|
+
def generate_md5hash
|
152
|
+
Digest::MD5.hexdigest(generate_md5string)
|
153
|
+
end
|
154
|
+
|
155
|
+
def acknowledge
|
156
|
+
generate_md5hash == params['hash']
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|