vnpay 0.0.2 → 0.0.3

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: a1cfaf461ce01c3cec27cb39139e07386d13e7242a122336b68f15e8f61ddcb6
4
- data.tar.gz: 718b20676b4b9e578a32dcc9dcee2afe09c15e727fe594b8b8bf7553459e579b
3
+ metadata.gz: e6ea2c77c749d22a99f73c651c26ec62db8fa5c6b1b04116bbe020083167c5ef
4
+ data.tar.gz: 494462d3625a556d1a90089fc7402e6fd01188a4f64ef9e18e444433a9b204aa
5
5
  SHA512:
6
- metadata.gz: 81330b3a293f8f247290138ced86bd2f19a8a99ba7883149c0b2f04c790ab1bdc1b262500268116abec8f9f18b8fd18585a4b3b03d863dd4856ff37fec8452e2
7
- data.tar.gz: 316fab10bd1381897a54def919d25850041001933375978da328cc60b93096af755fd0a7375fa3723b2937793ccf7b4abe26cffd632244f6ed826a00d9041461
6
+ metadata.gz: 4dca55f6c3f11a28eb8e2a907c4c1ced24b8722b7e43815949acf90529a8c774c90f60f75ee7ae1e81d80efe89ac9fd9d108af8d9a7e5d6069b81fc0125f73c4
7
+ data.tar.gz: f64a928f0d43ebf18a97ec35867cd0771d38cd093e5d3e5dd73a0ef0f611786747c1d878fe5d756bbd622fc18ffb9acbaf101d4c19ea201ecef8d5a2b43653f7
data/README.md CHANGED
@@ -1,2 +1,46 @@
1
- # vnpay
2
- Ruby gem for VNPay integration
1
+ VNPay
2
+ ========
3
+
4
+ A Ruby gem for VNPay integration
5
+
6
+ Introduction
7
+ ------------
8
+
9
+ VNPAY Payment Gateway is an intermediate system to transmit, exchange and process payment transactions between consumers owning card, bank account or e-wallet and enterprises providing goods, services on the Internet.
10
+
11
+ Installation
12
+ ------------
13
+
14
+ ### Bundler
15
+
16
+ Add the Airbrake gem to your Gemfile:
17
+
18
+ ```ruby
19
+ gem 'vnpay'
20
+ ```
21
+
22
+ ### Manual
23
+
24
+ Invoke the following command from your terminal:
25
+
26
+ ```bash
27
+ gem install vnpay
28
+ ```
29
+
30
+ ### Configuration
31
+
32
+ To integrate VNPay with your Rails application, you need to know your secret_key, payment URL and your website code. You can ask VNPay directly to get these information, then config them as following:
33
+
34
+ ```ruby
35
+ Vnpay::Config.configure do |config|
36
+ config.secret_key = ENV['VNPAY_SECRET_KEY']
37
+ config.payment_url = ENV['VNPAY_PAYMENT_URL']
38
+ config.website_code = ENV['VNPAY_WEBSITE_CODE']
39
+ end
40
+ ```
41
+
42
+ ### How to use
43
+
44
+ ...
45
+
46
+
@@ -1,4 +1,4 @@
1
- require 'order_info'
1
+ require 'vnpay/order_info'
2
2
  require 'vnpay/config'
3
3
  require 'vnpay/verify'
4
4
  require 'vnpay/url'
@@ -0,0 +1,15 @@
1
+ module Vnpay
2
+ class OrderInfo
3
+ attr_accessor :order_type, :payment_ref, :amount, :description, :created_at
4
+
5
+ def created_at=(value)
6
+ @created_at = value&.strftime('%Y%m%d%H%M%S')
7
+ end
8
+
9
+ def valid?
10
+ [:order_type, :payment_ref, :amount, :description, :created_at].map do |attribute|
11
+ !!send(attribute)
12
+ end.all?
13
+ end
14
+ end
15
+ end
@@ -9,6 +9,7 @@ module Vnpay
9
9
  end
10
10
 
11
11
  def generate
12
+ raise "OrderInfo missing attributes" unless order_info.valid?
12
13
  config.payment_url + query_string + "&vnp_SecureHashType=MD5&vnp_SecureHash=#{secure_hash}"
13
14
  end
14
15
 
@@ -32,7 +33,7 @@ module Vnpay
32
33
  vnp_IpAddr: ip_address,
33
34
  vnp_Locale: 'vn',
34
35
  vnp_OrderInfo: order_info.description.to_s,
35
- vnp_OrderType: "250000",
36
+ vnp_OrderType: order_info.order_type.to_s,
36
37
  vnp_ReturnUrl: callback_url,
37
38
  vnp_TmnCode: config.website_code,
38
39
  vnp_TxnRef: order_info.payment_ref.to_s,
@@ -48,4 +49,4 @@ module Vnpay
48
49
  Rack::Utils.escape(string)
49
50
  end
50
51
  end
51
- end
52
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vnpay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - nhannvu19
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '5.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: Ruby library for VNPay integration
28
42
  email:
29
43
  - nhannvu.19@gmail.com
@@ -33,9 +47,9 @@ extra_rdoc_files: []
33
47
  files:
34
48
  - README.md
35
49
  - Rakefile
36
- - lib/order_info.rb
37
50
  - lib/vnpay.rb
38
51
  - lib/vnpay/config.rb
52
+ - lib/vnpay/order_info.rb
39
53
  - lib/vnpay/url.rb
40
54
  - lib/vnpay/verify.rb
41
55
  homepage: https://github.com/nhannvu19/vnpay
@@ -1,7 +0,0 @@
1
- class OrderInfo
2
- attr_accessor :payment_ref, :amount, :description, :created_at
3
-
4
- def created_at=(value)
5
- @created_at = value.strftime('%Y%m%d%H%M%S')
6
- end
7
- end