alfabank 0.2.0 → 1.0.0

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: 240f816190cd982f668b2f7f819600e4521cbd5f3cbed3f2cbbaf5be53af13e9
4
- data.tar.gz: ab180f05add97f32ec4e95509cd292c91ff672c389d0c2ffefb413b98e302b61
3
+ metadata.gz: f6ad3336a0939c00753f584fe9fa8102b477c96ef62e15944ed337e19f22517b
4
+ data.tar.gz: 64da11be6351507a206273486f876d8add0cad3f94baa4cad8103730748ec6e4
5
5
  SHA512:
6
- metadata.gz: fbd34cc48a3e60914801d71e3e4e49402da7376d0238e94ebf6e927a484183ddab1341d7094a5899012661d4befd8ed661f3b084722f1abcae3c6c8d8fbae731
7
- data.tar.gz: fa5f6349905f7b9c42f4204e6c12ac5619f7be6f4a541afa22aa8465833fc8654db58146175d293ddd90be09cc9dd9ad261ebdb6dae3b3fc7ffd6cc4b01ee02a
6
+ metadata.gz: 17a8e97513a81a810b82f92cdcf0a285d1267af2a50e2eeec4d7dfb7f789a54049d56b68be77caa152b5f08ed32e9465dc63213eb9ca13c66e716009cabddc5a
7
+ data.tar.gz: d46572d06bc579a2a8bf1c84c4b14846d769add0a0be0439b5aa2b250cfa618cec594c8873b9c0971401f46b4bb3fef92608ccb66b3abdbb9b5c4ffcbc2acbb1
data/.gitignore CHANGED
@@ -1,9 +1,13 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
7
6
  /pkg/
8
7
  /spec/reports/
9
8
  /tmp/
9
+
10
+ Gemfile.lock
11
+
12
+ # macOS
13
+ .DS_Store
@@ -1,7 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.9
4
- - 2.3.6
5
- - 2.4.3
6
- - 2.5.0
7
- before_install: gem install bundler -v 1.11.2
3
+ - 2.5.5
4
+ - 2.6.3
5
+ before_install: gem install bundler
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016 Timur Yanberdin
3
+ Copyright (c) 2019 Timur Yanberdin
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Alfabank
2
+
2
3
  [![Build Status](https://travis-ci.org/mendab1e/alfabank.svg?branch=master)](https://travis-ci.org/mendab1e/alfabank) [![Gem Version](https://badge.fury.io/rb/alfabank.svg)](https://badge.fury.io/rb/alfabank)
3
4
 
4
5
  This gem provides support for the API of [Alfabank acquiring gateway](https://engine.paymentgate.ru/ecommerce/).
@@ -21,35 +22,27 @@ Or install it yourself as:
21
22
 
22
23
  ## Usage
23
24
 
24
- Generate initializer, model and migration:
25
-
26
- $ rails g alfabank Payment
27
-
28
- Run migration
29
-
30
- $ rake db:migrate
31
-
32
- Set credentials and other options in `config/initializers/alfabank.rb`
33
-
34
- * Use `#register` to register a new order and obtain a payment form url.
25
+ Configure the gem with the credentials provided by the bank. If you are using Ruby on Rails, you should do that in an initializer.
35
26
 
36
- * Use `#check_status` to get information about an order.
37
-
38
- Create a method to handle status request in your controller and insert a url for this method as a `return_url` param in `config/initializers/alfabank.rb`. Use `#check_status[:order_status]` to determine the status of an order and display it.
27
+ ```ruby
28
+ # config/initializers/alfabank.rb
29
+ Alfabank.configure do |config|
30
+ config.userName = Rails.application.credentials.dig(:alfabank, :userName)
31
+ config.password = Rails.application.credentials.dig(:alfabank, :password)
32
+ config.environment = Rails.application.credentials.dig(:alfabank, :environment) # 'production' or 'test'
33
+ end
34
+ ```
39
35
 
40
36
  ## Development
41
37
 
42
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
38
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
43
39
 
44
40
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
45
41
 
46
-
47
42
  ## Contributing
48
43
 
49
44
  Bug reports and pull requests are welcome on GitHub at https://github.com/mendab1e/alfabank.
50
45
 
51
-
52
46
  ## License
53
47
 
54
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
55
-
48
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -1,6 +1 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
1
+ require 'bundler/gem_tasks'
@@ -1,28 +1,26 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'alfabank/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "alfabank"
8
- spec.version = Alfabank::VERSION
9
- spec.authors = ["Timur Yanberdin"]
10
- spec.email = ["yanberdint@gmail.com"]
6
+ spec.name = 'alfabank'
7
+ spec.version = Alfabank::VERSION
8
+ spec.authors = ['Timur Yanberdin', 'Dan Kim']
9
+ spec.email = ['yanberdint@gmail.com']
11
10
 
12
- spec.summary = "Unofficial alfabank payment gateway gem"
13
- spec.homepage = "https://github.com/mendab1e/alfabank"
14
- spec.license = "MIT"
11
+ spec.summary = 'Unofficial alfabank payment gateway gem'
12
+ spec.homepage = 'https://github.com/mendab1e/alfabank'
13
+ spec.license = 'MIT'
15
14
 
16
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
- spec.bindir = "exe"
18
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
- spec.require_paths = ["lib"]
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.bindir = 'exe'
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ['lib']
20
19
 
21
- spec.add_development_dependency "bundler", "~> 1.11"
22
- spec.add_development_dependency "rake", "~> 10.0"
23
- spec.add_development_dependency "rspec", "~> 3.0"
24
- spec.add_development_dependency "webmock", "~> 1.22"
25
- spec.add_development_dependency "vcr", "~> 3.0"
20
+ spec.add_development_dependency 'bundler', '~> 1.17'
21
+ spec.add_development_dependency 'rake', '~> 12.3'
22
+ spec.add_development_dependency 'vcr', '~> 4.0'
26
23
 
27
- spec.add_dependency "httparty", "~> 0.13"
24
+ spec.add_dependency 'activesupport', '>= 5'
25
+ spec.add_dependency 'httparty', '~> 0.16'
28
26
  end
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "alfabank"
3
+ require 'bundler/setup'
4
+ require 'alfabank'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
8
8
 
9
9
  # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
10
+ # require 'pry'
11
11
  # Pry.start
12
12
 
13
- require "irb"
14
- IRB.start
13
+ require 'irb'
14
+ IRB.start(__FILE__)
@@ -1,26 +1,9 @@
1
- require "alfabank/version"
2
- require "alfabank/currency"
3
- require "alfabank/api"
4
- require "alfabank/configuration"
1
+ require 'active_support'
5
2
 
6
- module Alfabank
7
- def register(use_binding: false)
8
- Api::Registration.new(self).process(use_binding: use_binding)
9
- end
10
-
11
- def check_status(use_binding: false)
12
- Api::Status.new(self).process(use_binding: use_binding)
13
- end
14
-
15
- def payment_order_binding(binding_id)
16
- Api::PaymentOrderBinding.new(self).process(binding_id)
17
- end
3
+ require 'alfabank/client'
4
+ require 'alfabank/request'
5
+ require 'alfabank/response'
18
6
 
19
- class << self
20
- attr_accessor :logger
21
-
22
- def setup(&block)
23
- yield Configuration
24
- end
25
- end
7
+ module Alfabank
8
+ include ActiveSupport::Configurable
26
9
  end
@@ -0,0 +1,31 @@
1
+ module Alfabank
2
+ class Client
3
+ # https://web.rbsuat.com/ab/swagger/swagger.html#/register/registerOrderUsingPOST_7
4
+ def self.register(order_number:, amount:, return_url:, options: {})
5
+ params = options.merge(
6
+ orderNumber: order_number,
7
+ amount: amount,
8
+ returnUrl: return_url
9
+ )
10
+ Alfabank::Request.new('register.do', params).perform
11
+ end
12
+
13
+ # https://web.rbsuat.com/ab/swagger/swagger.html#/status/getOrderStatusExtendedUsingPOST_1
14
+ def self.status(order_id: nil, order_number: nil)
15
+ raise ArgumentError if order_id.nil? && order_number.nil?
16
+
17
+ params = { orderId: order_id, orderNumber: order_number }.compact
18
+ Alfabank::Request.new('getOrderStatusExtended.do', params).perform
19
+ end
20
+
21
+ # https://pay.alfabank.ru/ecommerce/instructions/merchantManual/pages/index/rest.html#zapros_provedenija_platezha_po_svjazke_rest_
22
+ def self.payment_order_binding(md_order:, binding_id:, ip:, options: {})
23
+ params = options.merge(
24
+ mdOrder: md_order,
25
+ binding_id: bindingId,
26
+ ip: ip
27
+ )
28
+ Alfabank::Request.new('paymentOrderBinding.do', params).perform
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,38 @@
1
+ require 'httparty'
2
+
3
+ module Alfabank
4
+ class Request
5
+ BASE_URL = 'https://engine.paymentgate.ru/payment/rest/'
6
+ TEST_BASE_URL = 'https://web.rbsuat.com/ab/rest/'
7
+
8
+ def initialize(method, params)
9
+ @method = method
10
+ @params = default_params.merge(params)
11
+ end
12
+
13
+ def perform
14
+ request = HTTParty.post(url, query: @params, format: :json)
15
+ request.parsed_response
16
+ end
17
+
18
+ private
19
+
20
+ def default_params
21
+ {
22
+ currency: Alfabank.config.currency,
23
+ language: Alfabank.config.language,
24
+ password: Alfabank.config.password,
25
+ returnUrl: Alfabank.config.return_url,
26
+ userName: Alfabank.config.userName
27
+ }.compact
28
+ end
29
+
30
+ def url
31
+ if Alfabank.config.environment.to_s == 'production'
32
+ BASE_URL + @method
33
+ else
34
+ TEST_BASE_URL + @method
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,15 @@
1
+ module Alfabank
2
+ class Response
3
+ ORDER_STATUS_APPROVED = 2
4
+
5
+ attr_reader :data
6
+
7
+ def initialize(data)
8
+ @data = data
9
+ end
10
+
11
+ def approved?
12
+ @data['orderStatus'] == ORDER_STATUS_APPROVED
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module Alfabank
2
- VERSION = "0.2.0"
2
+ VERSION = '1.0.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alfabank
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timur Yanberdin
8
+ - Dan Kim
8
9
  autorequire:
9
10
  bindir: exe
10
11
  cert_chain: []
11
- date: 2018-03-20 00:00:00.000000000 Z
12
+ date: 2019-08-20 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
@@ -16,84 +17,70 @@ dependencies:
16
17
  requirements:
17
18
  - - "~>"
18
19
  - !ruby/object:Gem::Version
19
- version: '1.11'
20
+ version: '1.17'
20
21
  type: :development
21
22
  prerelease: false
22
23
  version_requirements: !ruby/object:Gem::Requirement
23
24
  requirements:
24
25
  - - "~>"
25
26
  - !ruby/object:Gem::Version
26
- version: '1.11'
27
+ version: '1.17'
27
28
  - !ruby/object:Gem::Dependency
28
29
  name: rake
29
30
  requirement: !ruby/object:Gem::Requirement
30
31
  requirements:
31
32
  - - "~>"
32
33
  - !ruby/object:Gem::Version
33
- version: '10.0'
34
+ version: '12.3'
34
35
  type: :development
35
36
  prerelease: false
36
37
  version_requirements: !ruby/object:Gem::Requirement
37
38
  requirements:
38
39
  - - "~>"
39
40
  - !ruby/object:Gem::Version
40
- version: '10.0'
41
+ version: '12.3'
41
42
  - !ruby/object:Gem::Dependency
42
- name: rspec
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '3.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '3.0'
55
- - !ruby/object:Gem::Dependency
56
- name: webmock
43
+ name: vcr
57
44
  requirement: !ruby/object:Gem::Requirement
58
45
  requirements:
59
46
  - - "~>"
60
47
  - !ruby/object:Gem::Version
61
- version: '1.22'
48
+ version: '4.0'
62
49
  type: :development
63
50
  prerelease: false
64
51
  version_requirements: !ruby/object:Gem::Requirement
65
52
  requirements:
66
53
  - - "~>"
67
54
  - !ruby/object:Gem::Version
68
- version: '1.22'
55
+ version: '4.0'
69
56
  - !ruby/object:Gem::Dependency
70
- name: vcr
57
+ name: activesupport
71
58
  requirement: !ruby/object:Gem::Requirement
72
59
  requirements:
73
- - - "~>"
60
+ - - ">="
74
61
  - !ruby/object:Gem::Version
75
- version: '3.0'
76
- type: :development
62
+ version: '5'
63
+ type: :runtime
77
64
  prerelease: false
78
65
  version_requirements: !ruby/object:Gem::Requirement
79
66
  requirements:
80
- - - "~>"
67
+ - - ">="
81
68
  - !ruby/object:Gem::Version
82
- version: '3.0'
69
+ version: '5'
83
70
  - !ruby/object:Gem::Dependency
84
71
  name: httparty
85
72
  requirement: !ruby/object:Gem::Requirement
86
73
  requirements:
87
74
  - - "~>"
88
75
  - !ruby/object:Gem::Version
89
- version: '0.13'
76
+ version: '0.16'
90
77
  type: :runtime
91
78
  prerelease: false
92
79
  version_requirements: !ruby/object:Gem::Requirement
93
80
  requirements:
94
81
  - - "~>"
95
82
  - !ruby/object:Gem::Version
96
- version: '0.13'
83
+ version: '0.16'
97
84
  description:
98
85
  email:
99
86
  - yanberdint@gmail.com
@@ -102,7 +89,6 @@ extensions: []
102
89
  extra_rdoc_files: []
103
90
  files:
104
91
  - ".gitignore"
105
- - ".rspec"
106
92
  - ".travis.yml"
107
93
  - Gemfile
108
94
  - LICENSE.txt
@@ -112,19 +98,10 @@ files:
112
98
  - bin/console
113
99
  - bin/setup
114
100
  - lib/alfabank.rb
115
- - lib/alfabank/api.rb
116
- - lib/alfabank/api/base.rb
117
- - lib/alfabank/api/payment_order_binding.rb
118
- - lib/alfabank/api/registration.rb
119
- - lib/alfabank/api/status.rb
120
- - lib/alfabank/configuration.rb
121
- - lib/alfabank/currency.rb
101
+ - lib/alfabank/client.rb
102
+ - lib/alfabank/request.rb
103
+ - lib/alfabank/response.rb
122
104
  - lib/alfabank/version.rb
123
- - lib/generators/alfabank/USAGE
124
- - lib/generators/alfabank/alfabank_generator.rb
125
- - lib/generators/alfabank/templates/config/initializers/alfabank.rb
126
- - lib/generators/alfabank/templates/create_table_migration.rb
127
- - lib/generators/alfabank/templates/model.rb
128
105
  homepage: https://github.com/mendab1e/alfabank
129
106
  licenses:
130
107
  - MIT
@@ -144,8 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
121
  - !ruby/object:Gem::Version
145
122
  version: '0'
146
123
  requirements: []
147
- rubyforge_project:
148
- rubygems_version: 2.7.3
124
+ rubygems_version: 3.0.3
149
125
  signing_key:
150
126
  specification_version: 4
151
127
  summary: Unofficial alfabank payment gateway gem
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --format documentation
2
- --color
@@ -1,4 +0,0 @@
1
- require "alfabank/api/base"
2
- require "alfabank/api/registration"
3
- require "alfabank/api/status"
4
- require "alfabank/api/payment_order_binding"
@@ -1,33 +0,0 @@
1
- require 'httparty'
2
-
3
- module Alfabank::Api
4
- class Base
5
- attr_reader :payment, :use_binding
6
-
7
- def initialize(payment)
8
- @payment = payment
9
- end
10
-
11
- private
12
-
13
- def make_request
14
- HTTParty.post(url, body: generate_params, format: :json)
15
- end
16
-
17
- def generate_params
18
- fail NotImplementedError, "this method should be overridden"
19
- end
20
-
21
- def url
22
- Alfabank::Configuration.mode == :production ? self.class::URL : self.class::TEST_URL
23
- end
24
-
25
- def credentials
26
- if use_binding
27
- Alfabank::Configuration.binding_credentials
28
- else
29
- Alfabank::Configuration.common_credentials
30
- end
31
- end
32
- end
33
- end
@@ -1,29 +0,0 @@
1
- module Alfabank::Api
2
- class PaymentOrderBinding < Base
3
- TEST_URL = 'https://web.rbsuat.com/ab/rest/paymentOrderBinding.do'
4
- URL = "https://engine.paymentgate.ru/payment/rest/paymentOrderBinding.do"
5
-
6
- def process(binding_id)
7
- fail 'alfa_order_id is nil' if payment.alfa_order_id.nil?
8
- @binding_id = binding_id
9
-
10
- process_response(make_request.parsed_response)
11
- end
12
-
13
- private
14
-
15
- def process_response(response)
16
- response
17
- end
18
-
19
- def generate_params
20
- params = {
21
- userName: Alfabank::Configuration.binding_username,
22
- password: Alfabank::Configuration.binding_password,
23
- bindingId: @binding_id,
24
- mdOrder: payment.alfa_order_id
25
- }
26
- params.map { |k, v| "#{k}=#{v}" }.join('&')
27
- end
28
- end
29
- end
@@ -1,50 +0,0 @@
1
- module Alfabank::Api
2
- class Registration < Base
3
- TEST_URL = 'https://web.rbsuat.com/ab/rest/register.do'
4
- URL = "https://engine.paymentgate.ru/payment/rest/register.do"
5
-
6
- def process(use_binding: false)
7
- return {url: payment.alfa_form_url} if payment.alfa_order_id
8
- @use_binding = use_binding
9
-
10
- process_response(make_request.parsed_response)
11
- end
12
-
13
- private
14
-
15
- def process_response(response)
16
- if response.has_key?("orderId")
17
- set_data_from_response(response)
18
- {url: payment.alfa_form_url}
19
- else
20
- {error: response['errorMessage']}
21
- end
22
- end
23
-
24
- def generate_params
25
- params = credentials.merge(
26
- description: payment.description,
27
- language: Alfabank::Configuration.language,
28
- orderNumber: order_number,
29
- amount: payment.price * 100,
30
- currency: Alfabank::Configuration.currency,
31
- clientId: payment.user_id,
32
- returnUrl: Alfabank::Configuration.return_url
33
- )
34
-
35
- params.map { |k, v| "#{k}=#{v}" }.join('&')
36
- end
37
-
38
- def set_data_from_response(response)
39
- payment.update_attributes(
40
- alfa_order_id: response["orderId"],
41
- alfa_form_url: response["formUrl"]
42
- )
43
- end
44
-
45
- def order_number
46
- number = payment.to_order_number rescue payment.id
47
- "#{Alfabank::Configuration.order_number_prefix}#{number}"
48
- end
49
- end
50
- end
@@ -1,41 +0,0 @@
1
- module Alfabank::Api
2
- class Status < Base
3
- TEST_URL = 'https://web.rbsuat.com/ab/rest/getOrderStatus.do'
4
- URL = "https://engine.paymentgate.ru/payment/rest/getOrderStatus.do"
5
- PAID = 2
6
-
7
- def process(use_binding: false)
8
- @use_binding = use_binding
9
-
10
- response = make_request.parsed_response
11
- process_response(response)
12
-
13
- {
14
- order_status: response["OrderStatus"].to_i,
15
- binding_id: response["bindingId"],
16
- card_number: response["Pan"],
17
- error_code: response["ErrorCode"].to_i,
18
- error_message: response["ErrorMessage"]
19
- }
20
- end
21
-
22
- private
23
-
24
- def process_response(response)
25
- return unless response["OrderStatus"].to_i == PAID
26
-
27
- payment.paid = true
28
- payment.card_number = response["Pan"] if payment.respond_to?(:card_number)
29
- if payment.respond_to?(:binding_id)
30
- payment.binding_id = response["bindingId"]
31
- end
32
- payment.save(validate: false)
33
- end
34
-
35
- def generate_params
36
- credentials.merge(orderId: payment.alfa_order_id).map do |k, v|
37
- "#{k}=#{v}"
38
- end.join('&')
39
- end
40
- end
41
- end
@@ -1,23 +0,0 @@
1
- module Alfabank
2
- class Configuration
3
- class << self
4
- attr_accessor :username, :password, :language, :return_url
5
- attr_accessor :currency, :order_number_prefix, :mode
6
- attr_accessor :binding_username, :binding_password
7
-
8
- def binding_credentials
9
- {
10
- userName: binding_username,
11
- password: binding_password
12
- }
13
- end
14
-
15
- def common_credentials
16
- {
17
- userName: username,
18
- password: password
19
- }
20
- end
21
- end
22
- end
23
- end
@@ -1,5 +0,0 @@
1
- module Alfabank::Currency
2
- RUB = 810
3
- USD = 840
4
- EUR = 978
5
- end
@@ -1,10 +0,0 @@
1
- Description:
2
- Install alfabank to your app
3
-
4
- Example:
5
- rails generate alfabank Payment
6
-
7
- This will create:
8
- config/initializers/alfabank.rb
9
- db/migrate/create_payments.rb
10
- app/models/payment.rb
@@ -1,22 +0,0 @@
1
- require 'rails/generators/active_record'
2
-
3
- class AlfabankGenerator < Rails::Generators::NamedBase
4
- include Rails::Generators::Migration
5
- source_root File.expand_path('../templates', __FILE__)
6
-
7
- def generate_initializer
8
- template "config/initializers/alfabank.rb"
9
- end
10
-
11
- def generate_migration
12
- migration_template("create_table_migration.rb", "db/migrate/create_#{table_name}.rb")
13
- end
14
-
15
- def generate_model
16
- template "model.rb", "app/models/#{file_name}.rb"
17
- end
18
-
19
- def self.next_migration_number(dirname)
20
- ActiveRecord::Generators::Base.next_migration_number(dirname)
21
- end
22
- end
@@ -1,13 +0,0 @@
1
- Alfabank.setup do |config|
2
- config.username = 'username'
3
- config.password = 'password'
4
- config.language = 'ru'
5
- config.return_url = 'finish.html'
6
- config.currency = Alfabank::Currency::RUB
7
- config.order_number_prefix = 'payment-'
8
- config.binding_username = 'binding_username'
9
- config.binding_password = 'binding_password'
10
- config.mode = :test # :production
11
- end
12
-
13
- Alfabank.logger = Rails.logger
@@ -1,17 +0,0 @@
1
- class Create<%= table_name.camelize %> < ActiveRecord::Migration
2
- def change
3
- create_table :<%= table_name %> do |t|
4
- t.integer :price, null: false
5
- t.string :alfa_order_id
6
- t.string :alfa_form_url
7
- t.boolean :paid
8
- t.string :description
9
- t.integer :user_id
10
-
11
- t.timestamps null: false
12
- end
13
-
14
- add_index :<%= table_name %>, :alfa_order_id
15
- add_index :<%= table_name %>, :user_id
16
- end
17
- end
@@ -1,5 +0,0 @@
1
- class <%= class_name %> < ActiveRecord::Base
2
- include Alfabank
3
-
4
- validates_numericality_of :price, greater_than: 0
5
- end