opay 1.2.8 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 336e0c474cb6b68881cb017e4d4fde5e8c9c818e
4
- data.tar.gz: dd922fdf51f4680ef50c57b25b3bea7f7b307f54
3
+ metadata.gz: e0f0caea5a066b3808a988b401cad530a7fd28c3
4
+ data.tar.gz: 7f976f362a89553cf3ec02eead51a537d59e75ee
5
5
  SHA512:
6
- metadata.gz: c5ae2d0c83272bd6de36e6692c25ca475471761e7d576abbccb867c02d9ba7bceaada0d92a19e9d4243ab71970e41324a4389832690f40fa491f018dbed86b82
7
- data.tar.gz: f4801991a29a9ea3af4132ffed4650e24758ae9983a2a002b3fe717c3bd8d90244097cd0acfed7bd144142616547f428b6fcb2a12bb8681ceca6a4c10421aab9
6
+ metadata.gz: 26c4bd481500c71ab9fb89750a2120e8014885bac4facbedbc564a60a37f9ff20c4c181ba0043b62ae73f2f60d5c99f6002b439397d6055c238609ae326270ca
7
+ data.tar.gz: e01fbe6d5bb7d0fb54ec760abf933377cede209ee07463c2331a052045065caf7c0bb1239962693b8fba471ac18f7841c3c8b484c4f482c208fc0d11d99dfb2f
@@ -0,0 +1,12 @@
1
+ require_dependency 'opay/application_controller'
2
+
3
+ module Opay
4
+ class TransferujController < ApplicationController
5
+ def online
6
+ render text: Providers::Transferuj.process(params) ? 'TRUE' : ''
7
+ end
8
+
9
+ def secure
10
+ end
11
+ end
12
+ end
data/config/routes.rb CHANGED
@@ -9,6 +9,16 @@ Opay::Engine.routes.draw do
9
9
  end
10
10
  end
11
11
 
12
+ # transferuj
13
+ scope 'transferuj' do
14
+ post 'online' => 'transferuj#online', as: :transferuj_online
15
+
16
+ if Opay.config.process_payments_localy
17
+ patch 'secure' => 'transferuj#secure', as: :transferuj_new_payment
18
+ end
19
+ end
20
+
21
+
12
22
  # paypal
13
23
  scope 'paypal' do
14
24
  patch 'new' => 'paypal#new', as: :paypal_new_payment
@@ -1,5 +1,5 @@
1
1
  Opay.configure do |config|
2
- config.providers = [:payu, :paypal]
2
+ config.providers = [:payu, :transferuj, :paypal]
3
3
 
4
4
  config.test_mode = true
5
5
  # config.process_payments_localy = true if Rails.env.development?
@@ -13,6 +13,10 @@ Opay.configure do |config|
13
13
  config.payu_key1 = ENV['PAYU_KEY1']
14
14
  config.payu_key2 = ENV['PAYU_KEY2']
15
15
 
16
+ # transferuj configuration
17
+ config.transferuj_user_id = ENV['TRANSFERUJ_USER_ID']
18
+ config.transferuj_secure_code = ENV['TRANSFERUJ_SECURE_CODE']
19
+
16
20
  # paypal configuration
17
21
  config.paypal_login = ENV['PAYPAL_LOGIN']
18
22
  config.paypal_password = ENV['PAYPAL_PASSWORD']
@@ -13,6 +13,10 @@ module Opay
13
13
  config_accessor :payu_key1
14
14
  config_accessor :payu_key2
15
15
 
16
+ # transferuj configuration
17
+ config_accessor :transferuj_user_id
18
+ config_accessor :transferuj_secure_code
19
+
16
20
  # paypal configuration
17
21
  config_accessor :paypal_login
18
22
  config_accessor :paypal_password
@@ -37,7 +41,7 @@ module Opay
37
41
  # Sets configuration back to default
38
42
  def reset_config
39
43
  configure do |config|
40
- config.providers = [:payu, :paypal]
44
+ config.providers = [:payu, :transferuj, :paypal]
41
45
 
42
46
  config.success_url = :success_payment_url
43
47
  config.cancel_url = :cancel_payment_url
@@ -48,6 +52,10 @@ module Opay
48
52
  config.payu_key1 = ENV['PAYU_KEY1']
49
53
  config.payu_key2 = ENV['PAYU_KEY2']
50
54
 
55
+ # transferuj configuration
56
+ config.transferuj_user_id = ENV['TRANSFERUJ_USER_ID']
57
+ config.transferuj_secure_code = ENV['TRANSFERUJ_SECURE_CODE']
58
+
51
59
  # paypal configuration
52
60
  config.paypal_login = ENV['PAYPAL_LOGIN']
53
61
  config.paypal_password = ENV['PAYPAL_PASSWORD']
data/lib/opay/engine.rb CHANGED
@@ -18,6 +18,7 @@ module Opay
18
18
  include Opay::Helpers::FormHelper
19
19
  include Opay::Helpers::PayuHelper
20
20
  include Opay::Helpers::PaypalHelper
21
+ include Opay::Helpers::TransferujHelper
21
22
  end
22
23
  end
23
24
 
@@ -3,5 +3,6 @@ module Opay
3
3
  include Opay::Helpers::FormHelper
4
4
  include Opay::Helpers::PayuHelper
5
5
  include Opay::Helpers::PaypalHelper
6
+ include Opay::Helpers::TransferujHelper
6
7
  end
7
8
  end
@@ -12,6 +12,8 @@ module Opay
12
12
  case @payment_provider
13
13
  when :payu
14
14
  return payu_form_for(record, options, &block)
15
+ when :transferuj
16
+ return transferuj_form_for(record, options, &block)
15
17
  when :paypal
16
18
  return paypal_form_for(record, options, &block)
17
19
  end
@@ -24,6 +26,8 @@ module Opay
24
26
  case @options[:provider]
25
27
  when :payu
26
28
  payu_payment_info(options)
29
+ when :transferuj
30
+ transferuj_payment_info(options)
27
31
  when :paypal
28
32
  paypal_payment_info(options)
29
33
  end
@@ -0,0 +1,39 @@
1
+ module Opay
2
+ module Helpers
3
+
4
+ module TransferujHelper
5
+
6
+ def transferuj_form_for(record, options = {}, &block)
7
+ record.prepare_payment
8
+
9
+ options[:builder] ||= Opay::FormBuilder
10
+ options[:url] = Opay::Providers::Transferuj.url
11
+ options[:html] = { id: "transferuj_payment_form_#{record.id}", class: 'opay-form opay-transferuj-form' }
12
+
13
+ form_for(record, options, &block)
14
+ end
15
+
16
+ def transferuj_payment_info(options = {})
17
+ options[:id] ||= Opay.config.transferuj_user_id
18
+ options[:crc] ||= object.payment_session_id
19
+
20
+ options[:kwota] ||= object.amount
21
+ options[:opis] ||= options[:desc].present? ? options[:desc] : object.payment_description
22
+
23
+ options[:imie] ||= options[:first_name].present? ? options[:first_name] : object.first_name
24
+ options[:nazwisko] ||= options[:last_name].present? ? options[:last_name] : object.last_name
25
+ options[:email] ||= object.email
26
+
27
+ options[:pow_url] ||= @template.main_app.send(Opay.config.success_url)
28
+ options[:pow_url_blad] ||= @template.main_app.send(Opay.config.cancel_url)
29
+
30
+ # options[:pay_type] = 't' if Opay.config.test_mode
31
+ options[:md5sum] = Providers::Transferuj.create_form_sig(options)
32
+
33
+ options.except(:first_name, :last_name, :desc).map { |key, val| @template.hidden_field_tag(key, val) }.join("\n").html_safe
34
+ end
35
+
36
+ end
37
+
38
+ end
39
+ end
data/lib/opay/helpers.rb CHANGED
@@ -3,5 +3,6 @@ module Opay
3
3
  autoload :FormHelper, 'opay/helpers/form_helper'
4
4
  autoload :PayuHelper, 'opay/helpers/payu_helper'
5
5
  autoload :PaypalHelper, 'opay/helpers/paypal_helper'
6
+ autoload :TransferujHelper, 'opay/helpers/transferuj_helper'
6
7
  end
7
8
  end
@@ -0,0 +1,44 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+
4
+ module Opay
5
+ module Providers
6
+
7
+ class Transferuj
8
+ TRANSFERUJ_URL = 'https://secure.transferuj.pl/'
9
+
10
+ def self.process(params)
11
+ return false unless verify_sig(params[:md5sum], params[:id], params[:tr_id], params[:tr_amount], params[:tr_crc])
12
+
13
+ if params[:tr_status] == 'TRUE'
14
+ payment = Opay::Payment.where(session_id: params[:tr_crc]).first!
15
+ payment.payable.finish
16
+ end
17
+
18
+ return true
19
+ end
20
+
21
+ def self.url
22
+ Opay.config.process_payments_localy == true ? '/opay/transferuj/secure' : TRANSFERUJ_URL
23
+ end
24
+
25
+ def self.create_sig(*values)
26
+ Digest::MD5.hexdigest(values.join + Opay.config.transferuj_secure_code)
27
+ end
28
+
29
+ def self.verify_sig(sig, *values)
30
+ sig == Digest::MD5.hexdigest(values.join + Opay.config.transferuj_secure_code)
31
+ end
32
+
33
+ def self.create_form_sig(options)
34
+ sig_string = ''
35
+ %w( id kwota crc ).each do |key|
36
+ sig_string += options[key.to_sym].to_s if options.has_key?(key.to_sym)
37
+ end
38
+
39
+ create_sig(sig_string)
40
+ end
41
+ end
42
+
43
+ end
44
+ end
@@ -2,5 +2,6 @@ module Opay
2
2
  module Providers
3
3
  autoload :Payu, 'opay/providers/payu'
4
4
  autoload :Paypal, 'opay/providers/paypal'
5
+ autoload :Transferuj, 'opay/providers/transferuj'
5
6
  end
6
7
  end
data/lib/opay/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Opay
2
- VERSION = '1.2.8'
2
+ VERSION = '1.3.0'
3
3
  end
@@ -18,15 +18,20 @@
18
18
 
19
19
 
20
20
  <%= opay_form_for @order, provider: :payu do |f| %>
21
- <%= f.payment_info first_name: 'Jan', last_name: 'Kowalski', email: 'kowalski@gmail.com', desc: 'Test payment', client_ip: '127.0.0.1' %>
21
+ <%= f.payment_info first_name: 'Jan', last_name: 'Kowalski', email: 'kowalski@gmail.com', desc: @order.name, client_ip: '127.0.0.1' %>
22
22
  <%= f.submit :pay_with_payu %>
23
23
  <% end -%>
24
24
 
25
25
  <%= opay_form_for @order, provider: :paypal do |f| %>
26
- <%= f.paypal_payment_info desc: 'Test payment', client_ip: '127.0.0.1' %>
26
+ <%= f.paypal_payment_info desc: @order.name, client_ip: '127.0.0.1' %>
27
27
  <%= f.paypal_submit_tag %>
28
28
  <% end -%>
29
29
 
30
+ <%= opay_form_for @order, provider: :transferuj do |f| %>
31
+ <%= f.payment_info first_name: 'Jan', last_name: 'Kowalski', email: 'kowalski@gmail.com', desc: @order.name %>
32
+ <%= f.submit :pay_with_transferuj %>
33
+ <% end -%>
34
+
30
35
 
31
36
  <%= link_to 'Edit', edit_order_path(@order) %> |
32
37
  <%= link_to 'Back', orders_path %>
@@ -1,10 +1,10 @@
1
1
  # WebMock.disable! if Rails.env.development?
2
2
 
3
3
  Opay.configure do |config|
4
- config.providers = [:payu, :paypal]
4
+ config.providers = [:payu, :transferuj, :paypal]
5
5
 
6
- config.success_url = :root_path
7
- config.cancel_url = :root_path
6
+ config.success_url = :root_url
7
+ config.cancel_url = :root_url
8
8
 
9
9
  # payu configuration
10
10
  config.payu_pos_id = 123456
@@ -12,6 +12,10 @@ Opay.configure do |config|
12
12
  config.payu_key1 = 'c0c4b1a6b72b610f9342ea6820ee3a9c'
13
13
  config.payu_key2 = '2af5c662cab479e5471ca76326a57563'
14
14
 
15
+ # payu configuration
16
+ config.transferuj_user_id = 16059
17
+ config.transferuj_secure_code = 'EdDXG7F4L86svhcR'
18
+
15
19
  # paypal configuration
16
20
  config.paypal_login = 'ollownia-facilitator_api1.gmail.com'
17
21
  config.paypal_password = '1395743145'
Binary file