offsite_payments 2.7.21 → 2.7.22

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 11d3af9b6ea7b963a53bba9b38c1c0495aa8a676a5d15a081fff92461ea7848c
4
- data.tar.gz: d68bbaabd36c6e31f4ccdd9c77245dfb8adc1596dd9e8b71ba2042f1de010760
3
+ metadata.gz: 49a788e055321691469e48ea06db510414df18ddb513bde74dc4aff2901c6d9b
4
+ data.tar.gz: e1bf2836b3a773832bb49858f1584e1dceb0a18d2503ede84ee0632c76da8a2f
5
5
  SHA512:
6
- metadata.gz: 57c6f0dda0656e8a528eec91ff862d7580c2603559011d0ee2ddc7fbb437244ef2c3ee111fcf2b7a35ca34c68235a85debc77f33477b5bdb7b07beaa3b759db6
7
- data.tar.gz: 50b50027b8cd16ed325e3e12692f775d615d32f6caa187882e89dfedb10cbdc63c4170278e8ae20ddd5e5ea056c1feaa85292efe4290bb4066204d25825b68d5
6
+ metadata.gz: 9684dbe104d37f359263b0af474f62ab8e3fabe13462047a06e3939840fa09a70d6f5d5cbe3293630d961ef70d63f16b4d74d76b972c4c6e6da5fd848cf444a0
7
+ data.tar.gz: bcc832909f3bf9a165088afefc476766a24adbfb52abcab9a7b003eb7bce258e2434aeba424b65c8f3a28038a3c258aed6d975b1eef0faf1c92e45bc525ceb6f
data/README.md CHANGED
@@ -78,6 +78,7 @@ one.
78
78
  * [PayDollar](http://www.paydollar.com)
79
79
  * [Paysbuy](https://www.paysbuy.com/) - TH
80
80
  * [Platron](https://www.platron.ru/) - RU
81
+ * [QuickPay](http://quickpay.net/dk/) - AT, DE, DK, EE, LT, LV, FO, NL, NO, SE, UK
81
82
  * [RBK Money](https://rbkmoney.ru/) - RU
82
83
  * [Robokassa](http://robokassa.ru/) - RU
83
84
  * [SagePay Form](http://www.sagepay.com/products_services/sage_pay_go/integration/form)
@@ -40,5 +40,5 @@ module OffsitePayments
40
40
  self.mode == :test
41
41
  end
42
42
 
43
- CURRENCIES_WITHOUT_FRACTIONS = [ 'BIF', 'BYR', 'CLP', 'CVE', 'DJF', 'GNF', 'HUF', 'ISK', 'JPY', 'KMF', 'KRW', 'PYG', 'RWF', 'TWD', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF' ]
43
+ CURRENCIES_WITHOUT_FRACTIONS = [ 'BIF', 'BYR', 'CLP', 'CVE', 'DJF', 'GNF', 'ISK', 'JPY', 'KMF', 'KRW', 'PYG', 'RWF', 'TWD', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF' ]
44
44
  end
@@ -2,7 +2,7 @@ module OffsitePayments #:nodoc:
2
2
  module Integrations #:nodoc:
3
3
  module Quickpay
4
4
  mattr_accessor :service_url
5
- self.service_url = 'https://secure.quickpay.dk/form/'
5
+ self.service_url = 'https://legacy-proxy.quickpay.net/form/'
6
6
 
7
7
  def self.notification(post, options = {})
8
8
  Notification.new(post, options)
@@ -0,0 +1,173 @@
1
+ require 'openssl'
2
+
3
+ module OffsitePayments #:nodoc:
4
+ module Integrations #:nodoc:
5
+ module QuickpayV10
6
+ mattr_accessor :service_url
7
+ self.service_url = 'https://payment.quickpay.net'
8
+
9
+ def self.notification(post, options = {})
10
+ Notification.new(post)
11
+ end
12
+
13
+ def self.return(post, options = {})
14
+ Return.new(post, options)
15
+ end
16
+
17
+ # credential2: Payment window API key
18
+ class Helper < OffsitePayments::Helper
19
+ def initialize(order, account, options = {})
20
+ payment_window_api_key options.delete(:credential2)
21
+ super
22
+ add_field('version', 'v10')
23
+ add_field('type', 'payment')
24
+ add_field('language', 'da')
25
+ add_field('autocapture', 0)
26
+ add_field('order_id', format_order_number(order))
27
+ end
28
+
29
+ def payment_window_api_key(value)
30
+ @payment_window_api_key = value
31
+ end
32
+
33
+ def form_fields
34
+ @fields.merge('checksum' => generate_checksum)
35
+ end
36
+
37
+ def flatten_params(obj, result = {}, path = [])
38
+ case obj
39
+ when Hash
40
+ obj.each do |k, v|
41
+ flatten_params(v, result, [*path, k])
42
+ end
43
+ when Array
44
+ obj.each_with_index do |v, i|
45
+ flatten_params(v, result, [*path, i])
46
+ end
47
+ else
48
+ result[path.map{|p| "[#{p}]"}.join.to_sym] = obj
49
+ end
50
+ result
51
+ end
52
+
53
+ def generate_checksum
54
+ flattened_params = flatten_params(@fields)
55
+ values = flattened_params.sort.map { |_, value| value }
56
+ base = values.join(' ')
57
+ OpenSSL::HMAC.hexdigest('sha256', @payment_window_api_key, base)
58
+ end
59
+
60
+ # Limited to 20 digits max
61
+ def format_order_number(number)
62
+ number.to_s.gsub(/[^\w]/, '').rjust(4, "0")[0...20]
63
+ end
64
+
65
+ mapping :version, 'version'
66
+ mapping :type, 'type'
67
+ mapping :account, 'merchant_id'
68
+ mapping :language, 'language'
69
+ mapping :amount, 'amount'
70
+ mapping :currency, 'currency'
71
+
72
+ mapping :return_url, 'continueurl'
73
+ mapping :cancel_return_url, 'cancelurl'
74
+ mapping :notify_url, 'callbackurl'
75
+
76
+ mapping :autocapture, 'autocapture'
77
+ mapping :autofee, 'autofee'
78
+
79
+ mapping :description, 'description'
80
+ mapping :payment_methods, 'payment_methods'
81
+ mapping :acquirer, 'acquirer'
82
+ mapping :branding_id, 'branding_id'
83
+ mapping :google_analytics_tracking_id, 'google_analytics_tracking_id'
84
+ mapping :google_analytics_client_id, 'google_analytics_client_id'
85
+ mapping :variables, 'variables'
86
+ mapping :text_on_statement, 'text_on_statement'
87
+ mapping :customer_email, 'customer_email'
88
+
89
+ mapping :splitpayment, 'splitpayment'
90
+ mapping :forcemobile, 'forcemobile'
91
+ mapping :deadline, 'deadline'
92
+ mapping :cardhash, 'cardhash'
93
+
94
+ mapping :invoice_address, {}
95
+ mapping :billing_address, {}
96
+ end
97
+
98
+ # credential3: private key
99
+ # checksum_header: QuickPay-Checksum-Sha256 request header value
100
+ class Notification < OffsitePayments::Notification
101
+ # http://tech.quickpay.net/appendixes/errors/
102
+ def complete?
103
+ status == '20000'
104
+ end
105
+
106
+ def item_id
107
+ params['order_id']
108
+ end
109
+
110
+ def transaction_id
111
+ params['id']
112
+ end
113
+
114
+ def received_at
115
+ Time.iso8601(params['created_at'])
116
+ end
117
+
118
+ def gross
119
+ "%.2f" % (gross_cents / 100.0)
120
+ end
121
+
122
+ def gross_cents
123
+ last_operation['amount']
124
+ end
125
+
126
+ def last_operation
127
+ params['operations'].last
128
+ end
129
+
130
+ def status
131
+ last_operation['qp_status_code'] if last_operation
132
+ end
133
+
134
+ # Provide access to raw fields from quickpay
135
+ %w(
136
+ accepted
137
+ test_mode
138
+ branding_id
139
+ variables
140
+ acquirer
141
+ operations
142
+ metadata
143
+ balance
144
+ currency
145
+ ).each do |attr|
146
+ define_method(attr) do
147
+ params[attr]
148
+ end
149
+ end
150
+
151
+ def generate_checksum
152
+ OpenSSL::HMAC.hexdigest('sha256', @options[:credential3], @raw)
153
+ end
154
+
155
+ def checksum_header
156
+ @options[:checksum_header]
157
+ end
158
+
159
+ # Quickpay doesn't do acknowledgements of callback notifications
160
+ # Instead it provides a SHA256 checksum header
161
+ def acknowledge(authcode = nil)
162
+ generate_checksum == checksum_header
163
+ end
164
+
165
+ # Take the posted data and move the relevant data into a hash
166
+ def parse(post)
167
+ @raw = post.to_s
168
+ @params = JSON.parse(post)
169
+ end
170
+ end
171
+ end
172
+ end
173
+ end
@@ -22,7 +22,6 @@ module OffsitePayments #:nodoc:
22
22
  'CVE' => 0,
23
23
  'DJF' => 0,
24
24
  'GNF' => 0,
25
- 'HUF' => 0,
26
25
  'ISK' => 0,
27
26
  'JPY' => 0,
28
27
  'KMF' => 0,
@@ -1,3 +1,3 @@
1
1
  module OffsitePayments
2
- VERSION = "2.7.21"
2
+ VERSION = "2.7.22"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: offsite_payments
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.21
4
+ version: 2.7.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Luetke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-23 00:00:00.000000000 Z
11
+ date: 2020-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -257,6 +257,7 @@ files:
257
257
  - lib/offsite_payments/integrations/platron.rb
258
258
  - lib/offsite_payments/integrations/pxpay.rb
259
259
  - lib/offsite_payments/integrations/quickpay.rb
260
+ - lib/offsite_payments/integrations/quickpay_v10.rb
260
261
  - lib/offsite_payments/integrations/rbkmoney.rb
261
262
  - lib/offsite_payments/integrations/realex_offsite.rb
262
263
  - lib/offsite_payments/integrations/robokassa.rb