tappay_ruby 0.9.0 → 0.10.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 +7 -1
- data/lib/tappay/configuration.rb +1 -1
- data/lib/tappay/payment_base.rb +11 -33
- data/lib/tappay/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ce90cd2b717fd362fe27f9823797cbda3d53aaf94edae8d57ec012d4bcceaea
|
4
|
+
data.tar.gz: 550b70b62f2c0d02414cbbce136900610badb978cec8b68ee36511daa4f23255
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c66bade29b78ca9518fd519d4cbcf91916af5d9cd20c04e96294ea6ad9967f409199b1af700e0e8011490a05cce4056d25c9ce1c351bd3b327acc6713b8bf7f5
|
7
|
+
data.tar.gz: eb409d49cab817ad4cb31af5fc63184ee4c6458b817026d1953ef71a71e43fd8eefd2086c269393c3f6338a3bf4dda70021be74250ef0cf377d763620fbdc4ba
|
data/README.md
CHANGED
@@ -10,9 +10,12 @@ A Ruby library for integrating with TapPay payment services. This gem provides a
|
|
10
10
|
|
11
11
|
- Multiple payment methods:
|
12
12
|
- Credit card payments (one-time and tokenized)
|
13
|
-
- Instalment payments (3
|
13
|
+
- Instalment payments (3, 6, 12, 24 and 36 months)
|
14
14
|
- Line Pay
|
15
15
|
- JKO Pay
|
16
|
+
- Flexible merchant identification:
|
17
|
+
- Support for both `merchant_id` and `merchant_group_id`
|
18
|
+
- Automatic fallback handling
|
16
19
|
- Refund processing
|
17
20
|
- Transaction status queries
|
18
21
|
- Comprehensive error handling
|
@@ -72,6 +75,8 @@ Tappay.configure do |config|
|
|
72
75
|
end
|
73
76
|
```
|
74
77
|
|
78
|
+
Note: When both `merchant_id` and `merchant_group_id` are provided, `merchant_group_id` will be used for payment processing.
|
79
|
+
|
75
80
|
### Merchant ID Configuration
|
76
81
|
|
77
82
|
The gem supports flexible merchant ID configuration:
|
@@ -186,6 +191,7 @@ result = Tappay::LinePay::Pay.new(
|
|
186
191
|
Tappay.configure do |config|
|
187
192
|
config.partner_key = 'YOUR_PARTNER_KEY'
|
188
193
|
config.merchant_id = 'YOUR_MERCHANT_ID'
|
194
|
+
config.merchant_group_id = 'YOUR_MERCHANT_GROUP_ID' # Optional, mutually exclusive with merchant_id
|
189
195
|
config.jko_pay_merchant_id = 'YOUR_JKO_PAY_MERCHANT_ID' # Optional, falls back to merchant_id if not set
|
190
196
|
config.sandbox = true # Set to false for production
|
191
197
|
end
|
data/lib/tappay/configuration.rb
CHANGED
@@ -36,7 +36,7 @@ module Tappay
|
|
36
36
|
|
37
37
|
def validate!
|
38
38
|
raise ValidationError, 'partner_key is required' if partner_key.nil?
|
39
|
-
raise ValidationError, 'merchant_id is required' if merchant_id.nil?
|
39
|
+
raise ValidationError, 'Either merchant_id or merchant_group_id is required' if merchant_id.nil? && merchant_group_id.nil?
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
data/lib/tappay/payment_base.rb
CHANGED
@@ -20,48 +20,26 @@ module Tappay
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def payment_data
|
23
|
-
#
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
opt_merchant_id = options[:merchant_id]
|
31
|
-
|
32
|
-
# Check for conflicts in options
|
33
|
-
if opt_group_id && opt_merchant_id
|
34
|
-
raise Tappay::ValidationError, "merchant_group_id and merchant_id cannot be used together"
|
35
|
-
end
|
36
|
-
|
37
|
-
# If options has any ID, use it exclusively
|
38
|
-
if opt_group_id || opt_merchant_id
|
39
|
-
merchant_group_id = opt_group_id
|
40
|
-
merchant_id = opt_merchant_id
|
23
|
+
# Prioritize merchant_group_id from options, then configuration
|
24
|
+
merchant_group_id = options[:merchant_group_id] || Tappay.configuration.merchant_group_id
|
25
|
+
merchant_id = options[:merchant_id] || get_merchant_id
|
26
|
+
|
27
|
+
# Determine which identifier to use
|
28
|
+
identifier = if merchant_group_id
|
29
|
+
{ merchant_group_id: merchant_group_id }
|
41
30
|
else
|
42
|
-
|
43
|
-
|
44
|
-
merchant_id = get_merchant_id
|
45
|
-
end
|
46
|
-
|
47
|
-
# Check if at least one is provided
|
48
|
-
unless merchant_group_id || merchant_id
|
49
|
-
raise Tappay::ValidationError, "Either merchant_group_id or merchant_id must be provided"
|
31
|
+
raise Tappay::ValidationError, "Either merchant_group_id or merchant_id must be provided" unless merchant_id
|
32
|
+
{ merchant_id: merchant_id }
|
50
33
|
end
|
51
34
|
|
52
|
-
{
|
35
|
+
identifier.merge({
|
53
36
|
partner_key: Tappay.configuration.partner_key,
|
54
37
|
amount: options[:amount],
|
55
38
|
details: options[:details],
|
56
39
|
currency: options[:currency] || 'TWD',
|
57
40
|
order_number: options[:order_number],
|
58
41
|
three_domain_secure: options[:three_domain_secure] || false
|
59
|
-
}.tap do |data|
|
60
|
-
if merchant_group_id
|
61
|
-
data[:merchant_group_id] = merchant_group_id
|
62
|
-
else
|
63
|
-
data[:merchant_id] = merchant_id
|
64
|
-
end
|
42
|
+
}).tap do |data|
|
65
43
|
data[:cardholder] = card_holder_data if options[:cardholder]
|
66
44
|
data[:result_url] = options[:result_url] if options[:result_url]
|
67
45
|
data[:instalment] = options[:instalment] || 0
|
data/lib/tappay/version.rb
CHANGED