tappay 1.0.0 → 1.0.1

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
- SHA1:
3
- metadata.gz: dbea2463bcce294e9cd5c09df6f2ad4c68616bde
4
- data.tar.gz: 7940b43a0be475f917dbee009fe64a5ae6741224
2
+ SHA256:
3
+ metadata.gz: c80c6879c24468637180dc99def0c0e7727e79d5e342935dab5ae39021870065
4
+ data.tar.gz: bf4707515ffca803365a5c7abbd2192dc9d9e24a1f43abea7a536cf6a80b5b3f
5
5
  SHA512:
6
- metadata.gz: e9607512bffdc66755bff9993b89b3f59655315ade0e5af4fb7f09e7ed5c96fe606ba43fb81c3d68480b1b557c79fd2dee573658b547f1317589008fa1d681c9
7
- data.tar.gz: 571ead5ac836480ad7dafe7ad515d42aa3ec45b579bfd570ce21213d4661ddeec2a69feacb07fd577ae8cdd4440459865bae07390684e5da256f6a04547afd96
6
+ metadata.gz: 002b2c137bfc4beded5f8ca10d4315b64d1dda5d1c1cf80cd3eaeef1979c8c660831cfa2bc264d7e44a68b6ecf0a54282f2d1c70516deaf9820066cf2176b062
7
+ data.tar.gz: b138932f859f31b52083d59bb95055413a45851f6ab9737ab3e30e567911c0af3ea11402fa4da1941b26466438c333147327586fb8a8dbb845b7f290513ca7b3
data/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+ * Removed merchant_id support from configuration options.
9
+ * Removed support for Ruby 2.0
10
+
11
+ ## [1.0.1] - 2019-09-05
12
+ * Added deprecation warning when setting merchant_id, app_id, app_key in config options.
13
+
14
+ ## [1.0.0] - 2018-06-29
15
+ * Use semantic versioning.
16
+ * Start running in https://statementdog.com production environment.
data/README.md CHANGED
@@ -26,23 +26,56 @@ See [TapPay Backend API](https://docs.tappaysdk.com/tutorial/zh/back.html#back).
26
26
 
27
27
  ## Usage
28
28
 
29
+ **Settings**
30
+
29
31
  You need to setup mode which affects requests sent to sandbox or production server.
30
32
  The partner_key and merchant_id are optional, they could also be specified in request params.
31
33
 
32
34
  ```ruby
33
- # sandbox or production
34
- TapPay.mode = :sandbox
35
-
36
35
  TapPay.setup do |config|
36
+ config.mode = Rails.env.production? ? :production : :sandbox # sandbox or production
37
37
  config.partner_key = 'your_partner_key' # optional
38
- config.merchant_id = 'your_merchant_id' # optional
39
38
  end
40
39
  ```
41
40
 
41
+ **Map API Resources to Module and Action**
42
+
43
+ It is easy to map api resources to the TapPay module's namespace and action.
44
+ For example, the **pay by prime** api is:
45
+ https://sandbox.tappaysdk.com/tpc/payment/pay-by-prime ,
46
+ the last two parts `payment` and `pay-by-prime` are mapped to
47
+ namespace `Payment` and action `pay_by_prime`, so it could be called by
48
+ `TapPay::Payment.pay_by_prime(params)`.
49
+
50
+ Another example is *bind card*, the bind card api is:
51
+ https://sandbox.tappaysdk.com/tpc/card/bind , so the api could be called by `TapPay::Card.bind(params)` as you expect.
52
+
53
+ ### Supported APIs
54
+ **Payment**
55
+
56
+ * pay_by_prime
57
+ * pay_by_token
58
+
59
+ **Card**
60
+
61
+ * bind
62
+ * remove
63
+
64
+ **Transaction**
65
+
66
+ * cap
67
+ * query
68
+ * refund
69
+ * trade_history
70
+
71
+ For more details about api request params and responses, please refer to the [TapPay Backend API Documentation](https://docs.tappaysdk.com/tutorial/zh/back.html#back).
72
+
73
+ ## More Examples
42
74
  ### Pay By Prime
43
75
  ```ruby
44
76
  params = {
45
77
  prime: 'test_3a2fb2b7e892b914a03c95dd4dd5dc7970c908df67a49527c0a648b2bc9',
78
+ merchant_id: 'your_merchant_id',
46
79
  details: "TapPay Test",
47
80
  amount: 100,
48
81
  cardholder: {
@@ -56,13 +89,13 @@ params = {
56
89
  remember: true
57
90
  }
58
91
 
59
- res = TapPay.pay_by_prime(params)
92
+ res = TapPay::Payment.pay_by_prime(params)
60
93
  res #=> {"status"=>0, "msg"=>"Success", "amount"=>100, ...}
61
94
  res['status'] #=> 0
62
95
  res['msg'] #=> Success
63
96
 
64
97
  # Block Style
65
- TapPay.pay_by_prime(params) do |res|
98
+ TapPay::Payment.pay_by_prime(params) do |res|
66
99
  res #=> {"status"=>0, "msg"=>"Success", "amount"=>100, ...}
67
100
  end
68
101
  ```
@@ -70,6 +103,7 @@ end
70
103
  ### Pay By Token
71
104
  ```ruby
72
105
  params = {
106
+ merchant_id: 'your_merchant_id',
73
107
  card_key: 'your_card_key_after_pay_by_prime_with_remember_true',
74
108
  card_token: 'your_card_token_after_pay_by_prime_with_remember_true',
75
109
  amount: 1,
@@ -77,10 +111,10 @@ params = {
77
111
  details: "An apple and a pen."
78
112
  }
79
113
 
80
- res = TapPay.pay_by_token(params)
114
+ res = TapPay::Payment.pay_by_token(params)
81
115
 
82
116
  # Block Style
83
- TapPay.pay_by_token(params) do |res|
117
+ TapPay::Payment.pay_by_token(params) do |res|
84
118
  res #=> {"status"=>0, "msg"=>"Success", "amount"=>100, ...}
85
119
  end
86
120
  ```
@@ -91,10 +125,10 @@ params = {
91
125
  rec_trade_id: 'your_rec_trade_id'
92
126
  }
93
127
 
94
- res = TapPay.refund(params)
128
+ res = TapPay::Transaction.refund(params)
95
129
 
96
130
  # Block Style
97
- TapPay.refund(params) do |res|
131
+ TapPay::Transaction.refund(params) do |res|
98
132
  res
99
133
  end
100
134
  ```
@@ -103,6 +137,8 @@ end
103
137
  ```ruby
104
138
  # bind
105
139
  params = {
140
+ prime: 'test_3a2fb2b7e892b914a03c95dd4dd5dc7970c908df67a49527c0a648b2bc9',
141
+ merchant_id: 'your_merchant_id',
106
142
  currency: 'TWD',
107
143
  cardholder: {
108
144
  phone_number: "+886923456789",
@@ -129,20 +165,7 @@ TapPay::Card.remove(params) do |res|
129
165
  end
130
166
  ```
131
167
 
132
- ### Transaction
133
- ```ruby
134
- # cap
135
- TapPay::Transaction.cap(params) do |res|
136
- res
137
- end
138
-
139
- # trade-history
140
- TapPay::Transaction.trade_history(params) do |res|
141
- res
142
- end
143
- ```
144
168
 
145
169
  ## License
146
170
 
147
171
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
148
-
data/lib/tappay.rb CHANGED
@@ -32,14 +32,23 @@ module TapPay
32
32
  end
33
33
 
34
34
  def merchant_id=(merchant_id)
35
+ warn <<-DEPRECATION_WARNING
36
+ [Deprecation] setting `merchant_id` in config options will be deprecated in the future releases.
37
+ It is recommaned to pass `merchant_id` to request params directly.
38
+ DEPRECATION_WARNING
39
+
35
40
  @merchant_id = merchant_id.to_s
36
41
  end
37
42
 
38
43
  def app_id=(app_id)
44
+ warn '[Deprecation] setting `app_id` in config options will be deprecated in the future releases.'
45
+
39
46
  @app_id = app_id
40
47
  end
41
48
 
42
49
  def app_key=(app_key)
50
+ warn '[Deprecation] setting `app_key` in config options will be deprecated in the future releases.'
51
+
43
52
  @app_key = app_key
44
53
  end
45
54
 
@@ -1,21 +1,21 @@
1
1
  module TapPay
2
2
  module APIResources
3
3
  CARD = [
4
- 'bind'.freeze,
5
- 'remove'.freeze
6
- ]
4
+ 'bind',
5
+ 'remove'
6
+ ].freeze
7
7
 
8
8
  PAYMENT = [
9
- 'pay_by_prime'.freeze,
10
- 'pay_by_token'.freeze
11
- ]
9
+ 'pay_by_prime',
10
+ 'pay_by_token'
11
+ ].freeze
12
12
 
13
13
  TRANSACTION = [
14
- 'cap'.freeze,
15
- 'query'.freeze,
16
- 'refund'.freeze,
17
- 'trade_history'.freeze
18
- ]
14
+ 'cap',
15
+ 'query',
16
+ 'refund',
17
+ 'trade_history'
18
+ ].freeze
19
19
 
20
20
  def base_url
21
21
  if TapPay.mode == :production
@@ -21,10 +21,11 @@ module TapPay
21
21
  end
22
22
 
23
23
  def self.default_params
24
- {
25
- partner_key: TapPay.partner_key,
26
- merchant_id: TapPay.merchant_id
27
- }
24
+ params = {}
25
+ params[:partner_key] = TapPay.partner_key unless TapPay.partner_key.nil?
26
+ params[:merchant_id] = TapPay.merchant_id unless TapPay.merchant_id.nil?
27
+
28
+ params
28
29
  end
29
30
 
30
31
  private_class_method :default_params
@@ -1,3 +1,3 @@
1
1
  module TapPay
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tappay
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - HzChris
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-29 00:00:00.000000000 Z
11
+ date: 2019-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -77,6 +77,7 @@ files:
77
77
  - ".gitignore"
78
78
  - ".rspec"
79
79
  - ".travis.yml"
80
+ - CHANGELOG.md
80
81
  - Gemfile
81
82
  - LICENSE.txt
82
83
  - README.md
@@ -111,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
112
  version: '0'
112
113
  requirements: []
113
114
  rubyforge_project:
114
- rubygems_version: 2.6.12
115
+ rubygems_version: 2.7.8
115
116
  signing_key:
116
117
  specification_version: 4
117
118
  summary: A very simple TapPay API wrapper for ruby.