kasikornbank 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9cf36a56e69c6380aaffa034607a26e27ef498d5
4
+ data.tar.gz: 25223ffd508044c931361f2c8786caeeb4ea5e28
5
+ SHA512:
6
+ metadata.gz: af1fcd8258fd374c50b0bf65063731f05c41d2c1e723a7db7be1c998a0f200eeabe403b412ba2defb3e39e9232bfba63d6bf7a407d09c3dd8dc9485b0110ec06
7
+ data.tar.gz: d66980da36aec381c7ae1fddeac441b65c99bc2d871cf2f9567aab86f7cb1f8d79e445110bc9f80b17c3f7fea5fc6cf77652b5ebd713bf97172cbcbeafd05d46
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ - 2.3.3
6
+ - 2.2.6
7
+ before_install: gem install bundler -v 1.13.7
@@ -0,0 +1,74 @@
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 frizbee@vivaldi.net. 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 ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in kasikornbank.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Frizbee Vivaldi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,116 @@
1
+ [![Build Status](https://travis-ci.org/frizbee/kasikornbank.svg?branch=master)](https://travis-ci.org/frizbee/kasikornbank)
2
+
3
+ # Kasikorn Bank Payment Gateway (Thailand)
4
+
5
+ This gem provides support for the accepting a credit cards payments with
6
+ K-Payment Gateway (Kasikorn Bank Payment Gateway)
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'kasikornbank', :git => 'git://github.com:frizbee/kasikornbank.git'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install kasikornbank
23
+
24
+ ## Usage
25
+
26
+ ### 1 - Configuration
27
+
28
+ Generate initializer
29
+
30
+ ```
31
+ rails g kasikornbank:install
32
+ ```
33
+ Set credentials and other options in `config/initializers/kasikornbank.rb`
34
+ ```
35
+ Kasikornbank.configure do |config|
36
+ config.merchant2 = ENV["KBANK_MERCHANT2"]
37
+ config.term2 = ENV["KBANK_TERM2"]
38
+ config.kbank_secret = ENV["KBANK_SECRET"]
39
+ config.url2 = "https://www.example.com/kbank_back_url"
40
+ config.respurl = "https://www.example.com/kbank_notify_url"
41
+ end
42
+ ```
43
+
44
+ `config.merchant2` = Merchant ID Your merchant number issued by KBank. Numeric 15 digits e.g. 401001234567001.
45
+ `config.term2` = Terminal ID Your terminal ID issued by KBank. Numeric 8 digits e.g. 70123456.
46
+ `config.kbank_secret` = Secret key (salt) to make md5 hash. Issued by KBank.
47
+ `config.url2` = URL where cardholder will be redirected back to merchant website.
48
+ `config.respurl` = Notify url. Must be SSL/TLS URL where KBank will send a variable PMGWRESP2.
49
+
50
+ ### 2 - Render Form
51
+
52
+ In your `checkout#create` method call
53
+ ```
54
+ kbank = Kasikornbank::Render.new({
55
+ invmerchant: "987",
56
+ details2: "Electric Fan = Model XYZ103",
57
+ ip_address: "111.111.111.205",
58
+ amount: 10.99,
59
+ shop_id: "00",
60
+ payterm2: "10"
61
+ })
62
+ ```
63
+
64
+ `invmerchant` = Invoice number, should be a unique number.
65
+ `details2` = Product description.
66
+ `ip_address` = IP address of merchant's server.
67
+ `amount` = Total amount of purchased order.
68
+ `shop_id` = <**Optional**> Shop ID, for payment template, see documentation.
69
+ `payterm2` = <**Optional**> Number of month for installment.
70
+
71
+ > :exclamation: Unfortunately, Kasikorn Bank doesn't have a proper way to handle payment API. In this case `Kasikornbank::Render.new()` will generage auto submit form and return it with `form` method. This form should be placed in `checkout#create` view file.
72
+
73
+ #### Example
74
+
75
+ _\# app/controllers/checkout_controller.rb_
76
+ ```
77
+ require 'kasikornbank'
78
+
79
+ def create
80
+ kbank = Kasikornbank::Render.new({
81
+ invmerchant: "987",
82
+ details2: "Electric Fan = Model XYZ103",
83
+ ip_address: "111.111.111.205",
84
+ amount: 10.99
85
+ })
86
+ @form = kbank.form
87
+ end
88
+ ```
89
+ _\# app/views/checkout/create.html.erb_
90
+ ```
91
+ <%= @form.html_safe if @form.present? %>
92
+ ```
93
+
94
+ ### 3 - Response
95
+
96
+ To be able to receive response from KBank you have to create another action in your checkout controller with post request as it is mandatory by KBank.
97
+
98
+ In your `routes.rb` file add `post 'checkout/kbank_response', to: 'checkout#kbank_response'` make sure that this line is out of scope of your locale.
99
+
100
+ Next step is to avoid blocking request by CSRF rule. This post request will come directly from KBank server, you need to make sure that `checkout#kbank_response` action is not blocked by CSRF. To do that, go to `checkout_controller.rb` and add this line:  `skip_before_action :verify_authenticity_token, :only => [:kbank_response]` this will give access to post anything to your action. Scary huh?
101
+
102
+ ## Development
103
+
104
+ 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.
105
+
106
+ 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).
107
+
108
+ ## Contributing
109
+
110
+ Bug reports and pull requests are welcome on GitHub at https://github.com/frizbee/kasikornbank. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
111
+
112
+
113
+ ## License
114
+
115
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
116
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "kasikornbank"
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
data/bin/setup ADDED
@@ -0,0 +1,8 @@
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
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'kasikornbank/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "kasikornbank"
8
+ spec.version = Kasikornbank::VERSION
9
+ spec.authors = ["Andre Antonov"]
10
+ spec.email = ["mail2andrewa@gmail.com"]
11
+
12
+ spec.summary = %q{This gem provides support for the accepting a credit cards payments with K-Payment Gatewak (Kasikorn bank)}
13
+ spec.description = %q{K-Payment Gateway is a payment service for processing credit card transactions that accept VISA Cards, MasterCard Cards, JCB Cards and China UnionPay Cards issued by banks worldwide. Participating online merchants can receive real time approval of credit card online transactions 24 hours a day in 35 different currencies. Moreover, the Dynamic Currency Conversion (DCC) Service will automatically convert the payment amount in Baht into the card holder’s home currency, allowing the cardholder choose between paying in Baht or in the home currency.}
14
+ spec.homepage = "https://github.com/frizbee/kasikornbank"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ #spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against " \
23
+ "public gem pushes."
24
+ end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.13"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rspec", "~> 3.0"
36
+ spec.add_development_dependency 'pry', '~> 0.10.4'
37
+ end
data/lib/.DS_Store ADDED
Binary file
Binary file
@@ -0,0 +1,16 @@
1
+ # require 'rails/generators/active_record'
2
+
3
+ module Kasikornbank
4
+ module Generators
5
+ class InstallGenerator < Rails::Generators::Base
6
+ # include Rails::Generators::Migration
7
+ source_root File.expand_path('../templates',__FILE__)
8
+
9
+ desc "Creates KBank initializer to your application"
10
+
11
+ def generate_initializer
12
+ template "config/initializers/kasikornbank.rb", 'config/initializers/kasikornbank.rb'
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,30 @@
1
+ # Cardholder/customer checks out from the merchant website and merchant website redirects
2
+ # cardholder to K-Payment Gateway with pre-agreed parameters. The following parameters need to
3
+ # be passed to K-Payment Gateway to process the transaction with Method = POST.
4
+
5
+ # Use this hook to configure KBank variables
6
+ Kasikornbank.configure do |config|
7
+
8
+ # Merchant ID Your merchant number issued by KBank
9
+ # Numeric 15 digits e.g. 401001234567001
10
+ config.merchant2 = ENV["KBANK_MERCHANT2"]
11
+
12
+ # Terminal ID Your terminal ID issued by KBank
13
+ # Numeric 8 digits e.g. 70123456
14
+ config.term2 = ENV["KBANK_TERM2"]
15
+
16
+ # Secret key (salt) to make md5 hash
17
+ # Issued by KBank Merchant must keep „MD5 Secret Key‟
18
+ # as secret between merchant and Kbank.
19
+ # Please strictly do not reveal this key to any other
20
+ # persons who are not concerned.
21
+ # MD5 Key issued by Kasikorn Bank
22
+ config.kbank_secret = ENV["KBANK_SECRET"]
23
+
24
+ # URL where cardholder will be redirected
25
+ # back to merchant website
26
+ config.url2 = "https://www.example.com"
27
+
28
+ # Must be SSL/TLS URL where KBank will send a variable PMGWRESP2
29
+ config.respurl = "https://www.example.com"
30
+ end
@@ -0,0 +1,18 @@
1
+ class Configuration
2
+ attr_accessor :merchant2
3
+ attr_accessor :term2
4
+ attr_accessor :kbank_secret
5
+ attr_accessor :url2
6
+ attr_accessor :respurl
7
+
8
+ def initialize
9
+ # Those are testing details
10
+ # provided by KBanks documentation
11
+ # for testing purpose only
12
+ @merchant2 = '401001234567001'
13
+ @term2 = '70123456'
14
+ @kbank_secret = 'Rtn6DPfR7XCPpc_v8Fx0Fcv40m0XtcVR'
15
+ @url2 = 'https://www.example.com'
16
+ @respurl = 'https://www.example.com'
17
+ end
18
+ end
@@ -0,0 +1,55 @@
1
+ module Kasikornbank
2
+ class Response
3
+ attr_accessor :params
4
+
5
+ def initialize(params)
6
+ @params = params
7
+ end
8
+
9
+ def kbank_response
10
+ response = Hash.new
11
+ if @params[:PMGWRESP2]
12
+ str = @params[:PMGWRESP2]
13
+ response[:response] = response_code(str[97...99])
14
+ response[:invoice] = remove_lead_zero(str[32...44])
15
+ response[:amount] = amount(str[85...97])
16
+ response[:auth_code] = nil
17
+ elsif @params[:HOSTRESP]
18
+ response[:response] = response_code(@params[:HOSTRESP])
19
+ response[:invoice] = remove_lead_zero(@params[:RETURNINV])
20
+ response[:amount] = amount(@params[:AMOUNT])
21
+ response[:auth_code] = @params[:AUTHCODE]
22
+ elsif @params[:PMGWRESP]
23
+ str = @params[:PMGWRESP]
24
+ response[:response] = response_code(str[0...2])
25
+ response[:invoice] = remove_lead_zero(str[56...68])
26
+ response[:amount] = amount(str[82...94])
27
+ response[:auth_code] = str[14...20]
28
+ end
29
+ response
30
+ end
31
+
32
+ private
33
+
34
+ # Converting amount and
35
+ # returning in decimal
36
+ def amount(value)
37
+ value = remove_lead_zero(value)
38
+ value.to_f / 100
39
+ end
40
+
41
+ # Removing all leading zeros
42
+ def remove_lead_zero(value)
43
+ value.sub!(/^[0]+/,'')
44
+ end
45
+
46
+ def response_code(value)
47
+ case value
48
+ when "00"
49
+ code = "success"
50
+ else
51
+ code = "fail"
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,3 @@
1
+ module Kasikornbank
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,108 @@
1
+ require "kasikornbank/version"
2
+ require "kasikornbank/response"
3
+ require "kasikornbank/configuration"
4
+ require 'pry'
5
+ require 'digest/md5'
6
+
7
+ module Kasikornbank
8
+ class << self
9
+ attr_accessor :configuration
10
+ end
11
+
12
+ def self.configure
13
+ self.configuration ||= Configuration.new
14
+ yield(configuration)
15
+ end
16
+
17
+ class Render
18
+ @@fillspace = "Y"
19
+ @@kbank_url = "https://rt05.kasikornbank.com/pggroup/payment.aspx"
20
+ attr_accessor :args
21
+
22
+ def initialize(*args)
23
+ @args = args
24
+ end
25
+
26
+ # For testing purpose, will be removed
27
+ def string
28
+ "#{Kasikornbank.configuration.merchant2}#{Kasikornbank.configuration.term2}#{amount_in_cents}#{Kasikornbank.configuration.url2}#{Kasikornbank.configuration.respurl}#{remote_ip}#{order_details}#{invoice_number}#{@@fillspace}#{Kasikornbank.configuration.kbank_secret}"
29
+ end
30
+
31
+ def form
32
+ form = "<form name='sendform' method='post' action='#{@@kbank_url}'>"
33
+ form << "<input type='hidden' id=MERCHANT2 name=MERCHANT2 value='#{Kasikornbank.configuration.merchant2}'>"
34
+ form << "<input type='hidden' id=TERM2 name=TERM2 value='#{Kasikornbank.configuration.term2}'>"
35
+ form << "<input type='hidden' id=AMOUNT2 name=AMOUNT2 value='#{amount_in_cents}'>"
36
+ form << "<input type='hidden' id=URL2 name=URL2 value='#{Kasikornbank.configuration.url2}'>"
37
+ form << "<input type='hidden' id=RESPURL name=RESPURL value='#{Kasikornbank.configuration.respurl}'>"
38
+ form << "<input type='hidden' id=IPCUST2 name=IPCUST2 value='#{remote_ip}'>"
39
+ form << "<input type='hidden' id=DETAIL2 name=DETAIL2 value='#{order_details}'>"
40
+ form << "<input type='hidden' id=INVMERCHANT name=INVMERCHANT value='#{invoice_number}'>"
41
+ form << "<input type='hidden' id=FILLSPACE name=FILLSPACE value='#{@@fillspace}'>"
42
+ form << "<input type='text' name='SHOPID' id='SHOPID' value='#{shop_id}'>"
43
+ form << "<input type='text' id=Payterm2 name=Payterm2 value='#{payterm2}'>"
44
+ form << "<input type='text' id='CHECKSUM' name='CHECKSUM' value='#{checksum}'>"
45
+ form << "</form>"
46
+ form << "<script>"
47
+ form << "window.onload = function(){document.forms['sendform'].submit()}"
48
+ form << "</script>"
49
+ form
50
+ end
51
+
52
+ def checksum
53
+ # Accoording to the documentation we have to create
54
+ # MD5 checksum. Should be in this order:
55
+ # MERCHANT2 + TERM2 + AMOUNT2 + URL2 + RESURL + IPCUST2 + DETAIL2 + INVMERCHANT + FILLSPACE + SHOPID + PAYTERM2 + MD5 Key
56
+ # Optional fields can be skipped (Fillspace, ShopId, payterm2)
57
+ Digest::MD5.hexdigest(
58
+ "#{Kasikornbank.configuration.merchant2}#{Kasikornbank.configuration.term2}#{amount_in_cents}#{Kasikornbank.configuration.url2}#{Kasikornbank.configuration.respurl}#{remote_ip}#{order_details}#{invoice_number}#{@@fillspace}#{shop_id}#{payterm2}#{Kasikornbank.configuration.kbank_secret}"
59
+ )
60
+ end
61
+
62
+ # Invoice numebr
63
+ # should be Numeric
64
+ # should be 12 digits long
65
+ def invoice_number
66
+ sprintf("%012d",@args[0][:invmerchant])
67
+ end
68
+
69
+ # Field DETAIL2
70
+ # Order detail name
71
+ # e.g. Electric Fan - Toshiba Model CM203
72
+ def order_details
73
+ @args[0][:details2]
74
+ end
75
+
76
+ # Optional
77
+ # Shop ID. for payment template
78
+ def shop_id
79
+ @args[0][:shop_id]
80
+ end
81
+
82
+ # Optional
83
+ # Number of month for installment
84
+ # 2 digits = 3,6,10 month
85
+ def payterm2
86
+ @args[0][:payterm2]
87
+ end
88
+
89
+ # Get the client's IP address
90
+ def remote_ip
91
+ # This can be used with api.ipify.org service
92
+ # public_ip = `curl https://api.ipify.org`
93
+ # Extra call not worth it
94
+ @args[0][:ip_address]
95
+ end
96
+
97
+ # Amount should be converted
98
+ # to be in cents before send to KBank
99
+ # 10.99 * 100 = 1099
100
+ # Should be 12 digits number
101
+ def amount_in_cents
102
+ amount = (@args[0][:amount].to_f * 100).to_i
103
+ sprintf("%012d",amount)
104
+ end
105
+
106
+ end
107
+
108
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kasikornbank
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Andre Antonov
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-01-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.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: '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: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.10.4
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.10.4
69
+ description: K-Payment Gateway is a payment service for processing credit card transactions
70
+ that accept VISA Cards, MasterCard Cards, JCB Cards and China UnionPay Cards issued
71
+ by banks worldwide. Participating online merchants can receive real time approval
72
+ of credit card online transactions 24 hours a day in 35 different currencies. Moreover,
73
+ the Dynamic Currency Conversion (DCC) Service will automatically convert the payment
74
+ amount in Baht into the card holder’s home currency, allowing the cardholder choose
75
+ between paying in Baht or in the home currency.
76
+ email:
77
+ - mail2andrewa@gmail.com
78
+ executables: []
79
+ extensions: []
80
+ extra_rdoc_files: []
81
+ files:
82
+ - ".gitignore"
83
+ - ".rspec"
84
+ - ".travis.yml"
85
+ - CODE_OF_CONDUCT.md
86
+ - Gemfile
87
+ - KBANK-Merchant-Integration-Guide-EN-7.1.6.pdf
88
+ - LICENSE.txt
89
+ - README.md
90
+ - Rakefile
91
+ - bin/console
92
+ - bin/setup
93
+ - kasikornbank.gemspec
94
+ - lib/.DS_Store
95
+ - lib/generators/.DS_Store
96
+ - lib/generators/kasikornbank/install_generator.rb
97
+ - lib/generators/kasikornbank/templates/config/initializers/kasikornbank.rb
98
+ - lib/kasikornbank.rb
99
+ - lib/kasikornbank/configuration.rb
100
+ - lib/kasikornbank/response.rb
101
+ - lib/kasikornbank/version.rb
102
+ homepage: https://github.com/frizbee/kasikornbank
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.6.8
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: This gem provides support for the accepting a credit cards payments with
126
+ K-Payment Gatewak (Kasikorn bank)
127
+ test_files: []