tappay_ruby 0.15.1 → 0.15.2
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 +25 -17
- data/lib/tappay/credit_card/instalment.rb +6 -52
- data/lib/tappay/jko_pay/pay.rb +35 -8
- data/lib/tappay/line_pay/pay.rb +27 -2
- data/lib/tappay/payment_base.rb +2 -2
- data/lib/tappay/version.rb +1 -1
- metadata +57 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dba462c40f933f0b7d7ec483acdc702b63704c0efab56a7bac13b00e5e67dc0
|
4
|
+
data.tar.gz: e2f20d85ab93c4975aea48b538913a1e1e3637f47b26c0fe59c595e204b59c89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b625131496af1f8a28eb03056e26a96a06bd19784064db791a808b4e0c9c85090819f33d6134b82815fd65ee893fdbb66791b3f3ad5273f8a369acce0cb20366
|
7
|
+
data.tar.gz: c9c78dee6c4bc8de92ad699355234392a2590861be128d41e7b4651ebc56f95d85b5aed34f9c7be29e56e5a7e0267d80c066145a7fec2417517c7962c94b624e
|
data/README.md
CHANGED
@@ -49,27 +49,26 @@ $ gem install tappay_ruby
|
|
49
49
|
|
50
50
|
There are several ways to configure the gem:
|
51
51
|
|
52
|
-
### 1
|
53
|
-
|
54
|
-
The simplest way to configure the gem:
|
52
|
+
### Option 1: Using merchant_id
|
55
53
|
|
56
54
|
```ruby
|
55
|
+
# Using merchant_id with optional payment-specific merchant IDs
|
57
56
|
Tappay.configure do |config|
|
58
57
|
config.partner_key = 'YOUR_PARTNER_KEY'
|
59
|
-
|
60
|
-
# Primary merchant identification
|
61
|
-
# You can use either merchant_id or merchant_group_id
|
62
58
|
config.merchant_id = 'YOUR_MERCHANT_ID'
|
63
|
-
#
|
64
|
-
config.
|
59
|
+
config.jko_pay_merchant_id = 'YOUR_JKO_PAY_MERCHANT_ID' # Optional, falls back to merchant_id if not set
|
60
|
+
config.line_pay_merchant_id = 'YOUR_LINE_PAY_MERCHANT_ID' # Optional, falls back to merchant_id if not set
|
61
|
+
end
|
62
|
+
```
|
65
63
|
|
66
|
-
|
67
|
-
# Note: These will be ignored if merchant_group_id is set
|
68
|
-
config.jko_pay_merchant_id = 'YOUR_JKO_PAY_MERCHANT_ID'
|
69
|
-
config.line_pay_merchant_id = 'YOUR_LINE_PAY_MERCHANT_ID'
|
70
|
-
config.instalment_merchant_id = 'YOUR_INSTALMENT_MERCHANT_ID'
|
64
|
+
### Option 2: Using merchant_group_id
|
71
65
|
|
72
|
-
|
66
|
+
```ruby
|
67
|
+
# Using merchant_group_id (takes precedence over all other merchant IDs)
|
68
|
+
Tappay.configure do |config|
|
69
|
+
config.partner_key = 'YOUR_PARTNER_KEY'
|
70
|
+
config.merchant_group_id = 'YOUR_MERCHANT_GROUP_ID'
|
71
|
+
# When merchant_group_id is set, all other merchant IDs will be ignored
|
73
72
|
end
|
74
73
|
```
|
75
74
|
|
@@ -127,7 +126,12 @@ result = Tappay::LinePay::Pay.new(
|
|
127
126
|
amount: 1000,
|
128
127
|
details: 'Order Details',
|
129
128
|
frontend_redirect_url: 'https://example.com/line_pay/result',
|
130
|
-
backend_notify_url: 'https://example.com/line_pay/notify'
|
129
|
+
backend_notify_url: 'https://example.com/line_pay/notify',
|
130
|
+
cardholder: {
|
131
|
+
phone_number: '0912345678',
|
132
|
+
name: 'Test User',
|
133
|
+
email: 'test@example.com'
|
134
|
+
}
|
131
135
|
).execute
|
132
136
|
```
|
133
137
|
|
@@ -162,11 +166,15 @@ end
|
|
162
166
|
```ruby
|
163
167
|
payment_options = {
|
164
168
|
prime: 'jko_pay_prime',
|
165
|
-
merchant_id: 'YOUR_MERCHANT_ID',
|
166
169
|
amount: 1000,
|
167
170
|
details: 'Some item',
|
168
171
|
frontend_redirect_url: 'https://your-site.com/jko_pay/result',
|
169
|
-
backend_notify_url: 'https://your-site.com/jko_pay/notify'
|
172
|
+
backend_notify_url: 'https://your-site.com/jko_pay/notify',
|
173
|
+
cardholder: {
|
174
|
+
phone_number: '0912345678',
|
175
|
+
name: 'Test User',
|
176
|
+
email: 'test@example.com'
|
177
|
+
}
|
170
178
|
}
|
171
179
|
|
172
180
|
payment = Tappay::JkoPay::Pay.new(payment_options)
|
@@ -1,6 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'tappay/payment_base'
|
4
|
+
|
1
5
|
module Tappay
|
2
6
|
module CreditCard
|
3
|
-
class Instalment
|
7
|
+
class Instalment < PaymentBase
|
4
8
|
def self.by_prime(options = {})
|
5
9
|
InstalmentByPrime.new(options)
|
6
10
|
end
|
@@ -11,10 +15,6 @@ module Tappay
|
|
11
15
|
end
|
12
16
|
|
13
17
|
class InstalmentByPrime < PaymentBase
|
14
|
-
def initialize(options = {})
|
15
|
-
super(options)
|
16
|
-
end
|
17
|
-
|
18
18
|
def payment_data
|
19
19
|
super.merge(
|
20
20
|
prime: options[:prime],
|
@@ -26,39 +26,14 @@ module Tappay
|
|
26
26
|
Tappay::Endpoints::Payment.pay_by_prime_url
|
27
27
|
end
|
28
28
|
|
29
|
-
def validate_options!
|
30
|
-
super
|
31
|
-
validate_result_url_for_instalment!
|
32
|
-
end
|
33
|
-
|
34
29
|
private
|
35
30
|
|
36
|
-
def get_merchant_id
|
37
|
-
# If merchant_group_id is set, it takes precedence
|
38
|
-
return nil if Tappay.configuration.merchant_group_id
|
39
|
-
|
40
|
-
# Otherwise, use instalment_merchant_id or fall back to default merchant_id
|
41
|
-
Tappay.configuration.instalment_merchant_id || super
|
42
|
-
end
|
43
|
-
|
44
31
|
def additional_required_options
|
45
|
-
[:prime, :
|
46
|
-
end
|
47
|
-
|
48
|
-
def validate_result_url_for_instalment!
|
49
|
-
return if options[:result_url] &&
|
50
|
-
options[:result_url][:frontend_redirect_url] &&
|
51
|
-
options[:result_url][:backend_notify_url]
|
52
|
-
|
53
|
-
raise ValidationError, "result_url with frontend_redirect_url and backend_notify_url is required for instalment payments"
|
32
|
+
[:prime, :instalment]
|
54
33
|
end
|
55
34
|
end
|
56
35
|
|
57
36
|
class InstalmentByToken < PaymentBase
|
58
|
-
def initialize(options = {})
|
59
|
-
super(options)
|
60
|
-
end
|
61
|
-
|
62
37
|
def payment_data
|
63
38
|
super.merge(
|
64
39
|
card_key: options[:card_key],
|
@@ -71,32 +46,11 @@ module Tappay
|
|
71
46
|
Tappay::Endpoints::Payment.pay_by_token_url
|
72
47
|
end
|
73
48
|
|
74
|
-
def validate_options!
|
75
|
-
super
|
76
|
-
validate_result_url_for_instalment!
|
77
|
-
end
|
78
|
-
|
79
49
|
private
|
80
50
|
|
81
|
-
def get_merchant_id
|
82
|
-
# If merchant_group_id is set, it takes precedence
|
83
|
-
return nil if Tappay.configuration.merchant_group_id
|
84
|
-
|
85
|
-
# Otherwise, use instalment_merchant_id or fall back to default merchant_id
|
86
|
-
Tappay.configuration.instalment_merchant_id || super
|
87
|
-
end
|
88
|
-
|
89
51
|
def additional_required_options
|
90
52
|
[:card_key, :card_token, :instalment]
|
91
53
|
end
|
92
|
-
|
93
|
-
def validate_result_url_for_instalment!
|
94
|
-
return if options[:result_url] &&
|
95
|
-
options[:result_url][:frontend_redirect_url] &&
|
96
|
-
options[:result_url][:backend_notify_url]
|
97
|
-
|
98
|
-
raise ValidationError, "result_url with frontend_redirect_url and backend_notify_url is required for instalment payments"
|
99
|
-
end
|
100
54
|
end
|
101
55
|
end
|
102
56
|
end
|
data/lib/tappay/jko_pay/pay.rb
CHANGED
@@ -4,7 +4,7 @@ module Tappay
|
|
4
4
|
module JkoPay
|
5
5
|
class Pay < PaymentBase
|
6
6
|
def endpoint_url
|
7
|
-
Endpoints::Payment.pay_by_prime_url
|
7
|
+
Tappay::Endpoints::Payment.pay_by_prime_url
|
8
8
|
end
|
9
9
|
|
10
10
|
private
|
@@ -21,16 +21,43 @@ module Tappay
|
|
21
21
|
[:prime, :frontend_redirect_url, :backend_notify_url, :cardholder]
|
22
22
|
end
|
23
23
|
|
24
|
+
def validate_options!
|
25
|
+
super
|
26
|
+
validate_result_url_format!
|
27
|
+
end
|
28
|
+
|
29
|
+
def validate_result_url_format!
|
30
|
+
# First validate that if result_url is provided, it's a hash with required fields
|
31
|
+
if options.key?(:result_url)
|
32
|
+
raise ValidationError, "result_url must be a hash" unless options[:result_url].is_a?(Hash)
|
33
|
+
|
34
|
+
result_url = options[:result_url]
|
35
|
+
required_fields = %w[frontend_redirect_url backend_notify_url]
|
36
|
+
missing = required_fields.select { |field| result_url[field.to_sym].nil? && result_url[field].nil? }
|
37
|
+
|
38
|
+
if missing.any?
|
39
|
+
raise ValidationError, "result_url must contain both frontend_redirect_url and backend_notify_url"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Then validate frontend_redirect_url and backend_notify_url are present and not empty
|
44
|
+
if !options[:frontend_redirect_url].to_s.strip.empty? && !options[:backend_notify_url].to_s.strip.empty?
|
45
|
+
return
|
46
|
+
end
|
47
|
+
|
48
|
+
raise ValidationError, "result_url must contain both frontend_redirect_url and backend_notify_url"
|
49
|
+
end
|
50
|
+
|
24
51
|
protected
|
25
52
|
|
26
53
|
def payment_data
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
54
|
+
super.merge(
|
55
|
+
prime: options[:prime],
|
56
|
+
result_url: {
|
57
|
+
frontend_redirect_url: options[:frontend_redirect_url],
|
58
|
+
backend_notify_url: options[:backend_notify_url]
|
59
|
+
}
|
60
|
+
)
|
34
61
|
end
|
35
62
|
end
|
36
63
|
end
|
data/lib/tappay/line_pay/pay.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'tappay/payment_base'
|
4
|
-
|
5
3
|
module Tappay
|
6
4
|
module LinePay
|
7
5
|
class Pay < PaymentBase
|
@@ -23,6 +21,33 @@ module Tappay
|
|
23
21
|
[:prime, :frontend_redirect_url, :backend_notify_url, :cardholder]
|
24
22
|
end
|
25
23
|
|
24
|
+
def validate_options!
|
25
|
+
super
|
26
|
+
validate_result_url_format!
|
27
|
+
end
|
28
|
+
|
29
|
+
def validate_result_url_format!
|
30
|
+
# First validate that if result_url is provided, it's a hash with required fields
|
31
|
+
if options.key?(:result_url)
|
32
|
+
raise ValidationError, "result_url must be a hash" unless options[:result_url].is_a?(Hash)
|
33
|
+
|
34
|
+
result_url = options[:result_url]
|
35
|
+
required_fields = %w[frontend_redirect_url backend_notify_url]
|
36
|
+
missing = required_fields.select { |field| result_url[field.to_sym].nil? && result_url[field].nil? }
|
37
|
+
|
38
|
+
if missing.any?
|
39
|
+
raise ValidationError, "result_url must contain both frontend_redirect_url and backend_notify_url"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Then validate frontend_redirect_url and backend_notify_url are present and not empty
|
44
|
+
if !options[:frontend_redirect_url].to_s.strip.empty? && !options[:backend_notify_url].to_s.strip.empty?
|
45
|
+
return
|
46
|
+
end
|
47
|
+
|
48
|
+
raise ValidationError, "result_url must contain both frontend_redirect_url and backend_notify_url"
|
49
|
+
end
|
50
|
+
|
26
51
|
protected
|
27
52
|
|
28
53
|
def payment_data
|
data/lib/tappay/payment_base.rb
CHANGED
@@ -23,7 +23,7 @@ module Tappay
|
|
23
23
|
# Prioritize merchant_group_id from options, then configuration
|
24
24
|
merchant_group_id = options[:merchant_group_id] || Tappay.configuration.merchant_group_id
|
25
25
|
merchant_id = options[:merchant_id] || get_merchant_id
|
26
|
-
|
26
|
+
|
27
27
|
# Determine which identifier to use
|
28
28
|
identifier = if merchant_group_id
|
29
29
|
{ merchant_group_id: merchant_group_id }
|
@@ -83,7 +83,7 @@ module Tappay
|
|
83
83
|
def get_merchant_id
|
84
84
|
# If merchant_group_id is set, it takes precedence over all other merchant IDs
|
85
85
|
return nil if Tappay.configuration.merchant_group_id
|
86
|
-
|
86
|
+
|
87
87
|
# Otherwise, return the default merchant_id
|
88
88
|
Tappay.configuration.merchant_id
|
89
89
|
end
|
data/lib/tappay/version.rb
CHANGED
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.15.
|
4
|
+
version: 0.15.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zac
|
@@ -23,6 +23,20 @@ dependencies:
|
|
23
23
|
- - "~>"
|
24
24
|
- !ruby/object:Gem::Version
|
25
25
|
version: 0.21.0
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rake
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '13.0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '13.0'
|
26
40
|
- !ruby/object:Gem::Dependency
|
27
41
|
name: rspec
|
28
42
|
requirement: !ruby/object:Gem::Requirement
|
@@ -37,6 +51,34 @@ dependencies:
|
|
37
51
|
- - "~>"
|
38
52
|
- !ruby/object:Gem::Version
|
39
53
|
version: '3.12'
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: simplecov
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 0.22.0
|
61
|
+
type: :development
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 0.22.0
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: simplecov-cobertura
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '2.1'
|
75
|
+
type: :development
|
76
|
+
prerelease: false
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '2.1'
|
40
82
|
- !ruby/object:Gem::Dependency
|
41
83
|
name: webmock
|
42
84
|
requirement: !ruby/object:Gem::Requirement
|
@@ -65,6 +107,20 @@ dependencies:
|
|
65
107
|
- - "~>"
|
66
108
|
- !ruby/object:Gem::Version
|
67
109
|
version: '6.2'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: pry
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0.15'
|
117
|
+
type: :development
|
118
|
+
prerelease: false
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0.15'
|
68
124
|
description: A Ruby library for integrating with TapPay payment services, supporting
|
69
125
|
credit card payments, refunds, and transaction queries
|
70
126
|
email:
|