tappay_ruby 0.8.0 → 0.9.0
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 +4 -4
- data/README.md +33 -0
- data/lib/tappay/configuration.rb +6 -1
- data/lib/tappay/jko_pay/pay.rb +42 -0
- data/lib/tappay/version.rb +1 -1
- data/lib/tappay.rb +20 -8
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e47e2732e236d1bca9d0daa16466fbff08b9c43e044ccb9020e2a505632fcf2a
|
4
|
+
data.tar.gz: af086bf4adf1a925fc1beb1cfc25dc3903421592b80c73e3efc8007c8a463d75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93ab78ddbcbd031929a051fe085cd7c8b63d289e88f0defc9eb5299924795692b35145680e373c87503f893403077d0e439339cdec4b50efb9ca9d339f9e9fc9
|
7
|
+
data.tar.gz: 94023de9c35c2ac47265f3abf9f2beeee0659fd2c977a5ce7cc3962cdc55867b5313c115327b3f2a2b17340f737c59d42f08747e5dd722f3ad4ef5f9c0e6adf4
|
data/README.md
CHANGED
@@ -12,6 +12,7 @@ A Ruby library for integrating with TapPay payment services. This gem provides a
|
|
12
12
|
- Credit card payments (one-time and tokenized)
|
13
13
|
- Instalment payments (3 to 24 months)
|
14
14
|
- Line Pay
|
15
|
+
- JKO Pay
|
15
16
|
- Refund processing
|
16
17
|
- Transaction status queries
|
17
18
|
- Comprehensive error handling
|
@@ -64,6 +65,7 @@ Tappay.configure do |config|
|
|
64
65
|
# Payment-specific merchant IDs
|
65
66
|
config.instalment_merchant_id = 'your_instalment_merchant_id'.freeze
|
66
67
|
config.line_pay_merchant_id = 'your_line_pay_merchant_id'.freeze
|
68
|
+
config.jko_pay_merchant_id = 'your_jko_pay_merchant_id'.freeze
|
67
69
|
|
68
70
|
config.currency = 'TWD'.freeze
|
69
71
|
config.vat_number = 'your_vat_number'.freeze
|
@@ -81,6 +83,7 @@ The gem supports flexible merchant ID configuration:
|
|
81
83
|
2. Payment-specific merchant IDs:
|
82
84
|
- `instalment_merchant_id`: Specific merchant ID for instalment payments
|
83
85
|
- `line_pay_merchant_id`: Specific merchant ID for Line Pay transactions
|
86
|
+
- `jko_pay_merchant_id`: Specific merchant ID for JKO Pay transactions
|
84
87
|
|
85
88
|
Merchant ID Priority:
|
86
89
|
1. Payment options merchant ID (if provided in the payment call)
|
@@ -126,6 +129,7 @@ Tappay.configure do |config|
|
|
126
129
|
config.merchant_id = ENV['TAPPAY_MERCHANT_ID'].freeze
|
127
130
|
config.line_pay_merchant_id = ENV['TAPPAY_LINE_PAY_MERCHANT_ID'].freeze
|
128
131
|
config.instalment_merchant_id = ENV['TAPPAY_INSTALMENT_MERCHANT_ID'].freeze
|
132
|
+
config.jko_pay_merchant_id = ENV['TAPPAY_JKO_PAY_MERCHANT_ID'].freeze
|
129
133
|
# ... other configurations
|
130
134
|
end
|
131
135
|
```
|
@@ -174,6 +178,35 @@ result = Tappay::LinePay::Pay.new(
|
|
174
178
|
).execute
|
175
179
|
```
|
176
180
|
|
181
|
+
### JKO Pay
|
182
|
+
|
183
|
+
#### Configuration
|
184
|
+
|
185
|
+
```ruby
|
186
|
+
Tappay.configure do |config|
|
187
|
+
config.partner_key = 'YOUR_PARTNER_KEY'
|
188
|
+
config.merchant_id = 'YOUR_MERCHANT_ID'
|
189
|
+
config.jko_pay_merchant_id = 'YOUR_JKO_PAY_MERCHANT_ID' # Optional, falls back to merchant_id if not set
|
190
|
+
config.sandbox = true # Set to false for production
|
191
|
+
end
|
192
|
+
```
|
193
|
+
|
194
|
+
#### Processing a JKO Pay Payment
|
195
|
+
|
196
|
+
```ruby
|
197
|
+
payment_options = {
|
198
|
+
prime: 'jko_pay_prime',
|
199
|
+
merchant_id: 'YOUR_MERCHANT_ID',
|
200
|
+
amount: 1000,
|
201
|
+
details: 'Some item',
|
202
|
+
frontend_redirect_url: 'https://your-site.com/jko_pay/result',
|
203
|
+
backend_notify_url: 'https://your-site.com/jko_pay/notify'
|
204
|
+
}
|
205
|
+
|
206
|
+
payment = Tappay::JkoPay::Pay.new(payment_options)
|
207
|
+
result = payment.execute
|
208
|
+
```
|
209
|
+
|
177
210
|
### Error Handling
|
178
211
|
|
179
212
|
The gem provides comprehensive error handling:
|
data/lib/tappay/configuration.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Tappay
|
4
4
|
class Configuration
|
5
5
|
attr_accessor :partner_key, :merchant_id, :merchant_group_id, :instalment_merchant_id,
|
6
|
-
:line_pay_merchant_id, :app_id, :currency, :vat_number
|
6
|
+
:line_pay_merchant_id, :jko_pay_merchant_id, :app_id, :currency, :vat_number
|
7
7
|
attr_writer :api_version
|
8
8
|
|
9
9
|
def initialize
|
@@ -33,5 +33,10 @@ module Tappay
|
|
33
33
|
def mode
|
34
34
|
@mode ||= :sandbox
|
35
35
|
end
|
36
|
+
|
37
|
+
def validate!
|
38
|
+
raise ValidationError, 'partner_key is required' if partner_key.nil?
|
39
|
+
raise ValidationError, 'merchant_id is required' if merchant_id.nil?
|
40
|
+
end
|
36
41
|
end
|
37
42
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Tappay
|
4
|
+
module JkoPay
|
5
|
+
class Pay < PaymentBase
|
6
|
+
def initialize(options = {})
|
7
|
+
super
|
8
|
+
validate_jko_pay_options!
|
9
|
+
end
|
10
|
+
|
11
|
+
def endpoint_url
|
12
|
+
Endpoints::Payment.pay_by_prime_url
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def get_merchant_id
|
18
|
+
Tappay.configuration.jko_pay_merchant_id || super
|
19
|
+
end
|
20
|
+
|
21
|
+
def validate_jko_pay_options!
|
22
|
+
validate_result_urls!
|
23
|
+
end
|
24
|
+
|
25
|
+
def validate_result_urls!
|
26
|
+
raise ValidationError, 'frontend_redirect_url is required for JKO Pay' if options[:frontend_redirect_url].nil?
|
27
|
+
raise ValidationError, 'backend_notify_url is required for JKO Pay' if options[:backend_notify_url].nil?
|
28
|
+
end
|
29
|
+
|
30
|
+
def payment_data
|
31
|
+
data = super
|
32
|
+
data[:result_url] = {
|
33
|
+
frontend_redirect_url: options[:frontend_redirect_url],
|
34
|
+
backend_notify_url: options[:backend_notify_url]
|
35
|
+
}
|
36
|
+
data[:prime] = options[:prime]
|
37
|
+
data[:remember] = options[:remember] || false
|
38
|
+
data
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/tappay/version.rb
CHANGED
data/lib/tappay.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'csv'
|
4
|
+
require 'json'
|
5
|
+
require 'net/http'
|
6
|
+
require 'uri'
|
7
|
+
|
3
8
|
require_relative "tappay/version"
|
4
9
|
require_relative "tappay/configuration"
|
5
10
|
require_relative "tappay/client"
|
6
11
|
require_relative "tappay/errors"
|
12
|
+
require_relative "tappay/payment_base"
|
7
13
|
require_relative "tappay/card_holder"
|
8
14
|
require_relative "tappay/endpoints"
|
9
15
|
require_relative "tappay/transaction/query"
|
@@ -11,20 +17,26 @@ require_relative "tappay/credit_card/pay"
|
|
11
17
|
require_relative "tappay/credit_card/refund"
|
12
18
|
require_relative "tappay/credit_card/instalment"
|
13
19
|
require_relative "tappay/line_pay/pay"
|
20
|
+
require_relative "tappay/jko_pay/pay"
|
14
21
|
|
15
22
|
module Tappay
|
16
23
|
class Error < StandardError; end
|
24
|
+
class ValidationError < Error; end
|
17
25
|
|
18
26
|
class << self
|
19
|
-
|
20
|
-
end
|
27
|
+
attr_writer :configuration
|
21
28
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
29
|
+
def configuration
|
30
|
+
@configuration ||= Configuration.new
|
31
|
+
end
|
32
|
+
|
33
|
+
def configure
|
34
|
+
self.configuration ||= Configuration.new
|
35
|
+
yield(configuration) if block_given?
|
36
|
+
end
|
26
37
|
|
27
|
-
|
28
|
-
|
38
|
+
def reset
|
39
|
+
self.configuration = Configuration.new
|
40
|
+
end
|
29
41
|
end
|
30
42
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tappay_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zac
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- lib/tappay/credit_card/refund.rb
|
84
84
|
- lib/tappay/endpoints.rb
|
85
85
|
- lib/tappay/errors.rb
|
86
|
+
- lib/tappay/jko_pay/pay.rb
|
86
87
|
- lib/tappay/line_pay/pay.rb
|
87
88
|
- lib/tappay/payment_base.rb
|
88
89
|
- lib/tappay/transaction/query.rb
|