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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e47e2732e236d1bca9d0daa16466fbff08b9c43e044ccb9020e2a505632fcf2a
4
- data.tar.gz: af086bf4adf1a925fc1beb1cfc25dc3903421592b80c73e3efc8007c8a463d75
3
+ metadata.gz: 4ce90cd2b717fd362fe27f9823797cbda3d53aaf94edae8d57ec012d4bcceaea
4
+ data.tar.gz: 550b70b62f2c0d02414cbbce136900610badb978cec8b68ee36511daa4f23255
5
5
  SHA512:
6
- metadata.gz: 93ab78ddbcbd031929a051fe085cd7c8b63d289e88f0defc9eb5299924795692b35145680e373c87503f893403077d0e439339cdec4b50efb9ca9d339f9e9fc9
7
- data.tar.gz: 94023de9c35c2ac47265f3abf9f2beeee0659fd2c977a5ce7cc3962cdc55867b5313c115327b3f2a2b17340f737c59d42f08747e5dd722f3ad4ef5f9c0e6adf4
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 to 24 months)
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
@@ -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
@@ -20,48 +20,26 @@ module Tappay
20
20
  end
21
21
 
22
22
  def payment_data
23
- # Check configuration conflicts first
24
- if Tappay.configuration.merchant_group_id && Tappay.configuration.merchant_id
25
- raise Tappay::ValidationError, "merchant_group_id and merchant_id cannot be used together"
26
- end
27
-
28
- # Get values from options
29
- opt_group_id = options[:merchant_group_id]
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
- # If no options, use configuration
43
- merchant_group_id = Tappay.configuration.merchant_group_id
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tappay
4
- VERSION = "0.9.0"
4
+ VERSION = "0.10.0"
5
5
  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.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zac