offsite_payments 2.7.3 → 2.7.4

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
  SHA1:
3
- metadata.gz: c6868f90410159ecc5ee57256207f32210f8be2a
4
- data.tar.gz: 238cc3e1db58f69bb44c6236fd5b9feb5d8bc692
3
+ metadata.gz: fca5c3503aa8268bc5f0b3495a8b610bd79ff955
4
+ data.tar.gz: 95634ae04ab55cf706721238b0e30fff074fa4d5
5
5
  SHA512:
6
- metadata.gz: 0ca28a713f780ebef3e0647493920b666d12d09b3002b05f464b7fe5d4318a5bc9d26f3ef19ef3207f2c71e6ec1c7b007d9aae79901ad2a45ee33328ce68efae
7
- data.tar.gz: c734ff0003ad31e2f079f0ac8c964fc76e3ea225329be4cd546ef2c23988ae7cf71403ef9e5e3adbe171ee29f7a983f97fb93a042c232445c7ae869c3eab3fad
6
+ metadata.gz: fe7b2ecbef11e6580b9ba736f92a402d8f8b8270c2b6a76a5192075d31a76757eb92b9d5f8bc340ff236eeb805560a7d5bc5d8bdf76c4a7f56c45d8cd9afa815
7
+ data.tar.gz: 4d3377a975972d0255d054749dcd8cbadb54decbd7fe76ebf6ff9fec8a797ed42ad341ca48e28ee1cc0ab227a7103c0552234d2e0722a82c7ed50ad1c60e9d93
@@ -30,6 +30,35 @@ module OffsitePayments #:nodoc:
30
30
  end
31
31
  end
32
32
 
33
+ class Helper < OffsitePayments::Helper
34
+ def credential_based_url
35
+ response = request_redirect
36
+ @transaction_id = response['id']
37
+
38
+ uri = URI.parse(response['links']['paymentUrl'])
39
+ set_form_fields_for_redirect(uri)
40
+ uri.query = ''
41
+ uri.to_s.sub(/\?\z/, '')
42
+ end
43
+
44
+ def form_method
45
+ "GET"
46
+ end
47
+
48
+ private
49
+
50
+ def set_form_fields_for_redirect(uri)
51
+ return unless uri.query
52
+
53
+ CGI.parse(uri.query).each do |key, value|
54
+ if value.is_a?(Array) && value.length == 1
55
+ add_field(key, value.first)
56
+ else
57
+ add_field(key, value)
58
+ end
59
+ end
60
+ end
61
+ end
33
62
  end
34
63
  end
35
64
  end
@@ -61,7 +61,7 @@ module OffsitePayments #:nodoc:
61
61
  true
62
62
  end
63
63
 
64
- class Helper < OffsitePayments::Helper
64
+ class Helper < Mollie::Helper
65
65
  attr_reader :transaction_id, :redirect_parameters, :token
66
66
 
67
67
  def initialize(order, account, options = {})
@@ -84,30 +84,6 @@ module OffsitePayments #:nodoc:
84
84
  raise ArgumentError, "The description option needs to be set." if options[:description].blank?
85
85
  end
86
86
 
87
- def credential_based_url
88
- response = request_redirect
89
- @transaction_id = response['id']
90
-
91
- uri = URI.parse(response['links']['paymentUrl'])
92
- set_form_fields_for_redirect(uri)
93
- uri.query = ''
94
- uri.to_s.sub(/\?\z/, '')
95
- end
96
-
97
- def form_method
98
- "GET"
99
- end
100
-
101
- def set_form_fields_for_redirect(uri)
102
- CGI.parse(uri.query).each do |key, value|
103
- if value.is_a?(Array) && value.length == 1
104
- add_field(key, value.first)
105
- else
106
- add_field(key, value)
107
- end
108
- end
109
- end
110
-
111
87
  def request_redirect
112
88
  MollieIdeal.create_payment(token, redirect_parameters)
113
89
  rescue ActiveUtils::ResponseError => e
@@ -3,140 +3,130 @@ module OffsitePayments #:nodoc:
3
3
  module MollieMistercash
4
4
  include Mollie
5
5
 
6
- RedirectError = Class.new(ActiveUtils::ActiveUtilsError)
6
+ RedirectError = Class.new(ActiveUtils::ActiveUtilsError)
7
7
 
8
- def self.notification(post, options = {})
9
- Notification.new(post, options)
10
- end
8
+ def self.notification(post, options = {})
9
+ Notification.new(post, options)
10
+ end
11
11
 
12
- def self.return(post, options = {})
13
- Return.new(post, options)
14
- end
12
+ def self.return(post, options = {})
13
+ Return.new(post, options)
14
+ end
15
15
 
16
- def self.live?
17
- OffsitePayments.mode == :production
18
- end
16
+ def self.live?
17
+ OffsitePayments.mode == :production
18
+ end
19
19
 
20
- def self.create_payment(token, params)
21
- API.new(token).post_request('payments', params)
22
- end
20
+ def self.create_payment(token, params)
21
+ API.new(token).post_request('payments', params)
22
+ end
23
23
 
24
- def self.check_payment_status(token, payment_id)
25
- API.new(token).get_request("payments/#{payment_id}")
26
- end
24
+ def self.check_payment_status(token, payment_id)
25
+ API.new(token).get_request("payments/#{payment_id}")
26
+ end
27
27
 
28
- def self.requires_redirect_param?
29
- false
30
- end
28
+ def self.requires_redirect_param?
29
+ false
30
+ end
31
31
 
32
- class Helper < OffsitePayments::Helper
33
- attr_reader :transaction_id, :redirect_parameters, :token
34
-
35
- def initialize(order, account, options = {})
36
- @token = account
37
- @redirect_parameters = {
38
- :amount => options[:amount],
39
- :description => options[:description],
40
- :redirectUrl => options[:return_url],
41
- :method => 'mistercash',
42
- :metadata => { :order => order }
43
- }
44
-
45
- @redirect_parameters[:webhookUrl] = options[:notify_url] if options[:notify_url]
46
-
47
- super
48
-
49
- raise ArgumentError, "The return_url option needs to be set." if options[:return_url].blank?
50
- raise ArgumentError, "The description option needs to be set." if options[:description].blank?
51
- end
52
-
53
- def credential_based_url
54
- response = request_redirect
55
- uri = URI.parse(response['links']['paymentUrl'])
56
- uri.to_s
57
- end
58
-
59
- def form_method
60
- "GET"
61
- end
62
-
63
- def request_redirect
64
- MollieMistercash.create_payment(token, redirect_parameters)
65
- rescue ActiveUtils::ResponseError => e
66
- case e.response.code
67
- when '401', '403', '422'
68
- error = JSON.parse(e.response.body)['error']['message']
69
- raise ActionViewHelperError, error
70
- when '503'
71
- raise ActionViewHelperError, 'Service temporarily unavailable. Please try again.'
72
- else
73
- raise
74
- end
75
- end
32
+ class Helper < Mollie::Helper
33
+ attr_reader :transaction_id, :redirect_parameters, :token
76
34
 
77
- end
35
+ def initialize(order, account, options = {})
36
+ @token = account
37
+ @redirect_parameters = {
38
+ :amount => options[:amount],
39
+ :description => options[:description],
40
+ :redirectUrl => options[:return_url],
41
+ :method => 'mistercash',
42
+ :metadata => { :order => order }
43
+ }
78
44
 
79
- class Notification < OffsitePayments::Notification
80
- def initialize(post_arguments, options = {})
81
- super
45
+ @redirect_parameters[:webhookUrl] = options[:notify_url] if options[:notify_url]
82
46
 
83
- raise ArgumentError, "The transaction_id needs to be included in the query string." if transaction_id.nil?
84
- raise ArgumentError, "The credential1 option needs to be set to the Mollie API key." if api_key.blank?
85
- end
47
+ super
86
48
 
87
- def complete?
88
- true
89
- end
49
+ raise ArgumentError, "The return_url option needs to be set." if options[:return_url].blank?
50
+ raise ArgumentError, "The description option needs to be set." if options[:description].blank?
51
+ end
90
52
 
91
- def item_id
92
- params['metadata']['order']
53
+ def request_redirect
54
+ MollieMistercash.create_payment(token, redirect_parameters)
55
+ rescue ActiveUtils::ResponseError => e
56
+ case e.response.code
57
+ when '401', '403', '422'
58
+ error = JSON.parse(e.response.body)['error']['message']
59
+ raise ActionViewHelperError, error
60
+ when '503'
61
+ raise ActionViewHelperError, 'Service temporarily unavailable. Please try again.'
62
+ else
63
+ raise
93
64
  end
65
+ end
94
66
 
95
- def transaction_id
96
- params['id']
97
- end
67
+ end
98
68
 
99
- def api_key
100
- @options[:credential1]
101
- end
69
+ class Notification < OffsitePayments::Notification
70
+ def initialize(post_arguments, options = {})
71
+ super
102
72
 
103
- def currency
104
- "EUR"
105
- end
73
+ raise ArgumentError, "The transaction_id needs to be included in the query string." if transaction_id.nil?
74
+ raise ArgumentError, "The credential1 option needs to be set to the Mollie API key." if api_key.blank?
75
+ end
106
76
 
107
- # the money amount we received in X.2 decimal.
108
- def gross
109
- @params['amount']
110
- end
77
+ def complete?
78
+ true
79
+ end
111
80
 
112
- def gross_cents
113
- (BigDecimal.new(@params['amount'], 2) * 100).to_i
114
- end
81
+ def item_id
82
+ params['metadata']['order']
83
+ end
115
84
 
116
- def status
117
- case @params['status']
118
- when 'open'; 'Pending'
119
- when 'paidout', 'paid'; 'Completed'
120
- else 'Failed'
121
- end
122
- end
85
+ def transaction_id
86
+ params['id']
87
+ end
123
88
 
124
- def test?
125
- @params['mode'] == 'test'
126
- end
89
+ def api_key
90
+ @options[:credential1]
91
+ end
127
92
 
128
- def acknowledge(authcode = nil)
129
- @params = check_payment_status(transaction_id)
130
- true
131
- end
93
+ def currency
94
+ "EUR"
95
+ end
132
96
 
133
- def check_payment_status(transaction_id)
134
- MollieMistercash.check_payment_status(@options[:credential1], transaction_id)
97
+ # the money amount we received in X.2 decimal.
98
+ def gross
99
+ @params['amount']
100
+ end
101
+
102
+ def gross_cents
103
+ (BigDecimal.new(@params['amount'], 2) * 100).to_i
104
+ end
105
+
106
+ def status
107
+ case @params['status']
108
+ when 'open'; 'Pending'
109
+ when 'paidout', 'paid'; 'Completed'
110
+ else 'Failed'
135
111
  end
136
112
  end
137
113
 
138
- class Return < OffsitePayments::Return
114
+ def test?
115
+ @params['mode'] == 'test'
116
+ end
117
+
118
+ def acknowledge(authcode = nil)
119
+ @params = check_payment_status(transaction_id)
120
+ true
121
+ end
122
+
123
+ def check_payment_status(transaction_id)
124
+ MollieMistercash.check_payment_status(@options[:credential1], transaction_id)
139
125
  end
126
+ end
127
+
128
+ class Return < OffsitePayments::Return
129
+ end
140
130
 
141
131
  end
142
132
  end
@@ -1,3 +1,3 @@
1
1
  module OffsitePayments
2
- VERSION = "2.7.3"
2
+ VERSION = "2.7.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: offsite_payments
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.3
4
+ version: 2.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Luetke