paygate-ruby 0.1.8 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
data/lib/paygate-ruby.rb CHANGED
@@ -1,48 +1,48 @@
1
- require "paygate/version"
2
-
3
- require 'paygate/configuration'
4
- require 'paygate/aes'
5
- require 'paygate/aes_ctr'
6
-
7
- require 'paygate/member'
8
- require 'paygate/response'
9
- require 'paygate/transaction'
10
- require 'paygate/profile'
11
-
12
- require 'paygate/helpers/form_helper' if defined? ActionView
13
-
14
- module Paygate
15
- class Engine < ::Rails::Engine; end
16
-
17
- CONFIG = YAML.load(File.read(File.expand_path('../data/config.yml', File.dirname(__FILE__)))).freeze
18
- LOCALES_MAP = CONFIG[:locales].freeze
19
- INTL_BRANDS_MAP = CONFIG[:intl][:brands].freeze
20
- KOREA_BIN_NUMBERS = CONFIG[:korea][:bin_numbers].freeze
21
-
22
- DEFAULT_CURRENCY = 'WON'.freeze
23
- DEFAULT_LOCALE = 'US'.freeze
24
-
25
- def mapped_currency(currency)
26
- return DEFAULT_CURRENCY unless currency.present?
27
-
28
- currency.to_s == 'KRW' ? 'WON' : currency.to_s
29
- end
30
- module_function :mapped_currency
31
-
32
- def mapped_locale(locale)
33
- locale.present? ? LOCALES_MAP[locale.to_s] : DEFAULT_LOCALE
34
- end
35
- module_function :mapped_locale
36
-
37
- class << self
38
- attr_writer :configuration
39
- end
40
-
41
- def self.configuration
42
- @configuration ||= Configuration.new
43
- end
44
-
45
- def self.configure
46
- yield configuration
47
- end
48
- end
1
+ require 'yaml'
2
+ require 'paygate/version'
3
+ require 'paygate/configuration'
4
+ require 'paygate/aes'
5
+ require 'paygate/aes_ctr'
6
+ require 'paygate/member'
7
+ require 'paygate/response'
8
+ require 'paygate/transaction'
9
+ require 'paygate/profile'
10
+ require 'paygate/helpers/form_helper' if defined?(ActionView)
11
+
12
+ module Paygate
13
+ if defined?(Rails)
14
+ class Engine < ::Rails::Engine; end
15
+ end
16
+
17
+ CONFIG = YAML.load(File.read(File.expand_path('../data/config.yml', File.dirname(__FILE__)))).freeze
18
+ LOCALES_MAP = CONFIG[:locales].freeze
19
+ INTL_BRANDS_MAP = CONFIG[:intl][:brands].freeze
20
+ KOREA_BIN_NUMBERS = CONFIG[:korea][:bin_numbers].freeze
21
+
22
+ DEFAULT_CURRENCY = 'WON'.freeze
23
+ DEFAULT_LOCALE = 'US'.freeze
24
+
25
+ def mapped_currency(currency)
26
+ return DEFAULT_CURRENCY unless currency.present?
27
+
28
+ currency.to_s == 'KRW' ? 'WON' : currency.to_s
29
+ end
30
+ module_function :mapped_currency
31
+
32
+ def mapped_locale(locale)
33
+ locale.present? ? LOCALES_MAP[locale.to_s] : DEFAULT_LOCALE
34
+ end
35
+ module_function :mapped_locale
36
+
37
+ class << self
38
+ attr_writer :configuration
39
+ end
40
+
41
+ def self.configuration
42
+ @configuration ||= Configuration.new
43
+ end
44
+
45
+ def self.configure
46
+ yield configuration
47
+ end
48
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../spec_helper'
4
+
5
+ RSpec.describe 'basic' do
6
+ it 'can load gem' do
7
+ expect(true).to eq true
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift File.dirname(__FILE__)
4
+
5
+ require 'paygate-ruby'
6
+
7
+ RSpec.configure do |config|
8
+ config.mock_with :rspec
9
+ config.order = 'random'
10
+ end
@@ -1,86 +1,86 @@
1
- window.Paygate = (function() {
2
- function Paygate() {}
3
-
4
- Paygate.fieldsMap = {
5
- mid: 'mid',
6
- locale: 'langcode',
7
- charset: 'charset',
8
- title: 'goodname',
9
- currency: 'goodcurrency',
10
- amount: 'unitprice',
11
- meta1: 'goodoption1',
12
- meta2: 'goodoption2',
13
- meta3: 'goodoption3',
14
- meta4: 'goodoption4',
15
- meta5: 'goodoption5',
16
- payMethod: 'paymethod',
17
- customerName: 'receipttoname',
18
- customerEmail: 'receipttoemail',
19
- cardNumber: 'cardnumber',
20
- expiryYear: 'cardexpireyear',
21
- expiryMonth: 'cardexpiremonth',
22
- cvv: 'cardsecretnumber',
23
- cardAuthCode: 'cardauthcode',
24
- responseCode: 'replycode',
25
- responseMessage: 'replyMsg',
26
- tid: 'tid',
27
- profileNo: 'profile_no',
28
- hashResult: 'hashresult'
29
- };
30
-
31
- Paygate.openPayApiForm = function() {
32
- return document.querySelector('form[name=PGIOForm]');
33
- };
34
-
35
- Paygate.openPayApiScreen = function() {
36
- return document.querySelector('#PGIOscreen');
37
- };
38
-
39
- Paygate.openPayApiFields = function() {
40
- var formChildren = Array.from(this.openPayApiForm().children);
41
- return formChildren.filter(function(el) {
42
- return el.tagName === 'INPUT';
43
- });
44
- }
45
-
46
- Paygate.findInputByName = function(name) {
47
- var mappedName = this.fieldsMap[name];
48
- return this.openPayApiFields().filter(function(el) {
49
- return el.name === mappedName;
50
- })[0];
51
- };
52
-
53
- Paygate.cardAuthCode = function() {
54
- return this.findInputByName('cardAuthCode').value;
55
- };
56
-
57
- Paygate.responseCode = function() {
58
- return this.findInputByName('responseCode').value;
59
- };
60
-
61
- Paygate.responseMessage = function() {
62
- return this.findInputByName('responseMessage').value;
63
- };
64
-
65
- Paygate.tid = function() {
66
- return this.findInputByName('tid').value;
67
- };
68
-
69
- Paygate.profileNo = function() {
70
- return this.findInputByName('profileNo').value;
71
- };
72
-
73
- Paygate.hashResult = function() {
74
- return this.findInputByName('hashResult').value;
75
- };
76
-
77
- Paygate.fillInput = function(field, value) {
78
- this.findInputByName(field).value = value;
79
- };
80
-
81
- Paygate.submitForm = function() {
82
- doTransaction(document.PGIOForm);
83
- };
84
-
85
- return Paygate;
86
- })();
1
+ window.Paygate = (function() {
2
+ function Paygate() {}
3
+
4
+ Paygate.fieldsMap = {
5
+ mid: 'mid',
6
+ locale: 'langcode',
7
+ charset: 'charset',
8
+ title: 'goodname',
9
+ currency: 'goodcurrency',
10
+ amount: 'unitprice',
11
+ meta1: 'goodoption1',
12
+ meta2: 'goodoption2',
13
+ meta3: 'goodoption3',
14
+ meta4: 'goodoption4',
15
+ meta5: 'goodoption5',
16
+ payMethod: 'paymethod',
17
+ customerName: 'receipttoname',
18
+ customerEmail: 'receipttoemail',
19
+ cardNumber: 'cardnumber',
20
+ expiryYear: 'cardexpireyear',
21
+ expiryMonth: 'cardexpiremonth',
22
+ cvv: 'cardsecretnumber',
23
+ cardAuthCode: 'cardauthcode',
24
+ responseCode: 'replycode',
25
+ responseMessage: 'replyMsg',
26
+ tid: 'tid',
27
+ profileNo: 'profile_no',
28
+ hashResult: 'hashresult'
29
+ };
30
+
31
+ Paygate.openPayApiForm = function() {
32
+ return document.querySelector('form[name=PGIOForm]');
33
+ };
34
+
35
+ Paygate.openPayApiScreen = function() {
36
+ return document.querySelector('#PGIOscreen');
37
+ };
38
+
39
+ Paygate.openPayApiFields = function() {
40
+ var formChildren = Array.from(this.openPayApiForm().children);
41
+ return formChildren.filter(function(el) {
42
+ return el.tagName === 'INPUT';
43
+ });
44
+ }
45
+
46
+ Paygate.findInputByName = function(name) {
47
+ var mappedName = this.fieldsMap[name];
48
+ return this.openPayApiFields().filter(function(el) {
49
+ return el.name === mappedName;
50
+ })[0];
51
+ };
52
+
53
+ Paygate.cardAuthCode = function() {
54
+ return this.findInputByName('cardAuthCode').value;
55
+ };
56
+
57
+ Paygate.responseCode = function() {
58
+ return this.findInputByName('responseCode').value;
59
+ };
60
+
61
+ Paygate.responseMessage = function() {
62
+ return this.findInputByName('responseMessage').value;
63
+ };
64
+
65
+ Paygate.tid = function() {
66
+ return this.findInputByName('tid').value;
67
+ };
68
+
69
+ Paygate.profileNo = function() {
70
+ return this.findInputByName('profileNo').value;
71
+ };
72
+
73
+ Paygate.hashResult = function() {
74
+ return this.findInputByName('hashResult').value;
75
+ };
76
+
77
+ Paygate.fillInput = function(field, value) {
78
+ this.findInputByName(field).value = value;
79
+ };
80
+
81
+ Paygate.submitForm = function() {
82
+ doTransaction(document.PGIOForm);
83
+ };
84
+
85
+ return Paygate;
86
+ })();
metadata CHANGED
@@ -1,59 +1,68 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paygate-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - jagdeepsingh
8
- autorequire:
9
- bindir: exe
8
+ autorequire:
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-11 00:00:00.000000000 Z
11
+ date: 2022-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.15'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.15'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
41
- description:
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
42
56
  email:
43
57
  - jagdeepsingh.125k@gmail.com
44
58
  executables: []
45
59
  extensions: []
46
60
  extra_rdoc_files: []
47
61
  files:
48
- - ".gitignore"
49
62
  - CHANGELOG.md
50
- - CODE_OF_CONDUCT.md
51
- - Gemfile
52
63
  - LICENSE.txt
53
64
  - README.md
54
65
  - Rakefile
55
- - bin/console
56
- - bin/setup
57
66
  - data/card_bin_20191001.xlsx
58
67
  - data/config.yml
59
68
  - lib/paygate-ruby.rb
@@ -66,13 +75,14 @@ files:
66
75
  - lib/paygate/response.rb
67
76
  - lib/paygate/transaction.rb
68
77
  - lib/paygate/version.rb
69
- - paygate-ruby.gemspec
78
+ - spec/integration/paygate_spec.rb
79
+ - spec/spec_helper.rb
70
80
  - vendor/assets/javascripts/paygate.js
71
- homepage:
81
+ homepage:
72
82
  licenses:
73
83
  - MIT
74
84
  metadata: {}
75
- post_install_message:
85
+ post_install_message:
76
86
  rdoc_options: []
77
87
  require_paths:
78
88
  - lib
@@ -87,8 +97,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
97
  - !ruby/object:Gem::Version
88
98
  version: '0'
89
99
  requirements: []
90
- rubygems_version: 3.0.3
91
- signing_key:
100
+ rubygems_version: 3.2.3
101
+ signing_key:
92
102
  specification_version: 4
93
- summary: Ruby wrapper for PayGate payment gateway
94
- test_files: []
103
+ summary: Ruby wrapper for PayGate Korea payment gateway
104
+ test_files:
105
+ - spec/integration/paygate_spec.rb
106
+ - spec/spec_helper.rb
data/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
data/CODE_OF_CONDUCT.md DELETED
@@ -1,74 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at jagdeep.singh@vinsol.com. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [http://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in paygate-ruby.gemspec
4
- gemspec
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "paygate"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/paygate-ruby.gemspec DELETED
@@ -1,24 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "paygate/version"
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "paygate-ruby"
8
- spec.version = Paygate::VERSION
9
- spec.authors = ["jagdeepsingh"]
10
- spec.email = ["jagdeepsingh.125k@gmail.com"]
11
-
12
- spec.summary = 'Ruby wrapper for PayGate payment gateway'
13
- spec.license = "MIT"
14
-
15
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
16
- f.match(%r{^(test|spec|features)/})
17
- end
18
- spec.bindir = "exe"
19
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ["lib"]
21
-
22
- spec.add_development_dependency "bundler", "~> 1.15"
23
- spec.add_development_dependency "rake", "~> 10.0"
24
- end