tappay_ruby 0.10.0 → 0.12.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
2
  SHA256:
3
- metadata.gz: 4ce90cd2b717fd362fe27f9823797cbda3d53aaf94edae8d57ec012d4bcceaea
4
- data.tar.gz: 550b70b62f2c0d02414cbbce136900610badb978cec8b68ee36511daa4f23255
3
+ metadata.gz: 3c06097c577042d4efb81f434670795a3247ed8badd8e6fd7efcd41436373942
4
+ data.tar.gz: d9ff01cc3df47d3333328bf8593bd99afa91b995ea5aea00dbc98dda91b825c4
5
5
  SHA512:
6
- metadata.gz: c66bade29b78ca9518fd519d4cbcf91916af5d9cd20c04e96294ea6ad9967f409199b1af700e0e8011490a05cce4056d25c9ce1c351bd3b327acc6713b8bf7f5
7
- data.tar.gz: eb409d49cab817ad4cb31af5fc63184ee4c6458b817026d1953ef71a71e43fd8eefd2086c269393c3f6338a3bf4dda70021be74250ef0cf377d763620fbdc4ba
6
+ metadata.gz: a60520e14ad7946a7768e00f8c4044260266eb95363a18a884c4e33e0dc37610df4af584ff5883ce5799f3981556784bdb767c3d185dc4ea769d00395545a6f7
7
+ data.tar.gz: ed3fcbaae8b9154635f13c1f94e5259d33a560e3f5269f8bbf825516ebd78e5c77ef4466161f3d38b042aa903620a064fdd13f68b82f2c65644dc1dca2f73c43
data/README.md CHANGED
@@ -10,12 +10,13 @@ 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, 6, 12, 24 and 36 months)
13
+ - Instalment payments (3, 6, 12, 18, 24, 30 months)
14
14
  - Line Pay
15
15
  - JKO Pay
16
16
  - Flexible merchant identification:
17
17
  - Support for both `merchant_id` and `merchant_group_id`
18
18
  - Automatic fallback handling
19
+ - Priority-based merchant ID resolution
19
20
  - Refund processing
20
21
  - Transaction status queries
21
22
  - Comprehensive error handling
@@ -53,91 +54,37 @@ The simplest way to configure the gem:
53
54
 
54
55
  ```ruby
55
56
  Tappay.configure do |config|
56
- # Environment settings
57
- config.mode = Rails.env.production? ? :production : :sandbox
58
-
59
- # Common settings
60
- config.partner_key = 'your_partner_key'.freeze
61
- config.app_id = 'your_app_id'.freeze
57
+ config.partner_key = 'YOUR_PARTNER_KEY'
62
58
 
63
- # Merchant settings (use either merchant_id or merchant_group_id, not both)
64
- config.merchant_id = 'your_merchant_id'.freeze
59
+ # Primary merchant identification
60
+ # You can use either merchant_id or merchant_group_id
61
+ config.merchant_id = 'YOUR_MERCHANT_ID'
65
62
  # OR
66
- config.merchant_group_id = 'your_merchant_group_id'.freeze
63
+ config.merchant_group_id = 'YOUR_MERCHANT_GROUP_ID'
67
64
 
68
- # Payment-specific merchant IDs
69
- config.instalment_merchant_id = 'your_instalment_merchant_id'.freeze
70
- config.line_pay_merchant_id = 'your_line_pay_merchant_id'.freeze
71
- config.jko_pay_merchant_id = 'your_jko_pay_merchant_id'.freeze
65
+ # Optional merchant IDs for specific payment methods
66
+ # Note: These will be ignored if merchant_group_id is set
67
+ config.jko_pay_merchant_id = 'YOUR_JKO_PAY_MERCHANT_ID'
68
+ config.line_pay_merchant_id = 'YOUR_LINE_PAY_MERCHANT_ID'
69
+ config.instalment_merchant_id = 'YOUR_INSTALMENT_MERCHANT_ID'
72
70
 
73
- config.currency = 'TWD'.freeze
74
- config.vat_number = 'your_vat_number'.freeze
71
+ config.mode = :sandbox # or :production
75
72
  end
76
73
  ```
77
74
 
78
- Note: When both `merchant_id` and `merchant_group_id` are provided, `merchant_group_id` will be used for payment processing.
79
-
80
- ### Merchant ID Configuration
81
-
82
- The gem supports flexible merchant ID configuration:
83
-
84
- 1. Global merchant ID:
85
- - `merchant_id`: Default merchant ID for all payments
86
- - `merchant_group_id`: Group merchant ID (mutually exclusive with merchant_id)
87
-
88
- 2. Payment-specific merchant IDs:
89
- - `instalment_merchant_id`: Specific merchant ID for instalment payments
90
- - `line_pay_merchant_id`: Specific merchant ID for Line Pay transactions
91
- - `jko_pay_merchant_id`: Specific merchant ID for JKO Pay transactions
92
-
93
- Merchant ID Priority:
94
- 1. Payment options merchant ID (if provided in the payment call)
95
- 2. Payment-specific merchant ID (if configured)
96
- 3. Global merchant ID
97
-
98
- Example of merchant ID usage:
99
- ```ruby
100
- # Using default merchant ID
101
- result = Tappay::CreditCard::Pay.by_prime(
102
- prime: 'prime_from_tappay_sdk',
103
- amount: 100,
104
- order_number: 'ORDER-123'
105
- )
106
-
107
- # Using payment-specific merchant ID
108
- # This will automatically use line_pay_merchant_id if configured
109
- result = Tappay::LinePay::Pay.new(
110
- prime: 'line_pay_prime',
111
- amount: 100,
112
- frontend_redirect_url: 'https://example.com/line_pay/result',
113
- backend_notify_url: 'https://example.com/line_pay/notify'
114
- ).execute
115
-
116
- # Overriding merchant ID in payment options
117
- result = Tappay::CreditCard::Pay.by_prime(
118
- prime: 'prime_from_tappay_sdk',
119
- amount: 100,
120
- merchant_id: 'override_merchant_id', # This takes highest priority
121
- order_number: 'ORDER-123'
122
- )
123
- ```
75
+ ### Merchant ID Resolution
124
76
 
125
- ### 2. Using Environment Variables
77
+ The gem uses the following priority order when resolving merchant IDs:
126
78
 
127
- For better security, you can use environment variables:
79
+ 1. If `merchant_group_id` is set (either in configuration or options):
80
+ - Uses `merchant_group_id` for all payment types
81
+ - Ignores all other merchant IDs (including specific ones for Line Pay, JKO Pay, etc.)
128
82
 
129
- ```ruby
130
- Tappay.configure do |config|
131
- config.mode = Rails.env.production? ? :production : :sandbox
132
- config.partner_key = ENV['TAPPAY_PARTNER_KEY'].freeze
133
- config.app_id = ENV['TAPPAY_APP_ID'].freeze
134
- config.merchant_id = ENV['TAPPAY_MERCHANT_ID'].freeze
135
- config.line_pay_merchant_id = ENV['TAPPAY_LINE_PAY_MERCHANT_ID'].freeze
136
- config.instalment_merchant_id = ENV['TAPPAY_INSTALMENT_MERCHANT_ID'].freeze
137
- config.jko_pay_merchant_id = ENV['TAPPAY_JKO_PAY_MERCHANT_ID'].freeze
138
- # ... other configurations
139
- end
140
- ```
83
+ 2. If `merchant_group_id` is not set:
84
+ - For Line Pay: Uses `line_pay_merchant_id` if set, otherwise falls back to `merchant_id`
85
+ - For JKO Pay: Uses `jko_pay_merchant_id` if set, otherwise falls back to `merchant_id`
86
+ - For Instalments: Uses `instalment_merchant_id` if set, otherwise falls back to `merchant_id`
87
+ - For other payment types: Uses `merchant_id`
141
88
 
142
89
  ## Usage
143
90
 
@@ -34,6 +34,10 @@ module Tappay
34
34
  private
35
35
 
36
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
37
41
  Tappay.configuration.instalment_merchant_id || super
38
42
  end
39
43
 
@@ -75,6 +79,10 @@ module Tappay
75
79
  private
76
80
 
77
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
78
86
  Tappay.configuration.instalment_merchant_id || super
79
87
  end
80
88
 
@@ -3,11 +3,6 @@
3
3
  module Tappay
4
4
  module JkoPay
5
5
  class Pay < PaymentBase
6
- def initialize(options = {})
7
- super
8
- validate_jko_pay_options!
9
- end
10
-
11
6
  def endpoint_url
12
7
  Endpoints::Payment.pay_by_prime_url
13
8
  end
@@ -15,17 +10,18 @@ module Tappay
15
10
  private
16
11
 
17
12
  def get_merchant_id
13
+ # If merchant_group_id is set, it takes precedence
14
+ return nil if Tappay.configuration.merchant_group_id
15
+
16
+ # Otherwise, use jko_pay_merchant_id or fall back to default merchant_id
18
17
  Tappay.configuration.jko_pay_merchant_id || super
19
18
  end
20
19
 
21
- def validate_jko_pay_options!
22
- validate_result_urls!
20
+ def additional_required_options
21
+ [:prime, :frontend_redirect_url, :backend_notify_url]
23
22
  end
24
23
 
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
24
+ protected
29
25
 
30
26
  def payment_data
31
27
  data = super
@@ -34,7 +30,6 @@ module Tappay
34
30
  backend_notify_url: options[:backend_notify_url]
35
31
  }
36
32
  data[:prime] = options[:prime]
37
- data[:remember] = options[:remember] || false
38
33
  data
39
34
  end
40
35
  end
@@ -5,17 +5,6 @@ require 'tappay/payment_base'
5
5
  module Tappay
6
6
  module LinePay
7
7
  class Pay < PaymentBase
8
- def payment_data
9
- super.merge(
10
- prime: options[:prime],
11
- result_url: {
12
- frontend_redirect_url: options[:frontend_redirect_url],
13
- backend_notify_url: options[:backend_notify_url]
14
- },
15
- remember: options[:remember] || false
16
- )
17
- end
18
-
19
8
  def endpoint_url
20
9
  Tappay::Endpoints::Payment.pay_by_prime_url
21
10
  end
@@ -23,12 +12,28 @@ module Tappay
23
12
  private
24
13
 
25
14
  def get_merchant_id
15
+ # If merchant_group_id is set, it takes precedence
16
+ return nil if Tappay.configuration.merchant_group_id
17
+
18
+ # Otherwise, use line_pay_merchant_id or fall back to default merchant_id
26
19
  Tappay.configuration.line_pay_merchant_id || super
27
20
  end
28
21
 
29
22
  def additional_required_options
30
23
  [:prime, :frontend_redirect_url, :backend_notify_url]
31
24
  end
25
+
26
+ protected
27
+
28
+ def payment_data
29
+ super.merge(
30
+ prime: options[:prime],
31
+ result_url: {
32
+ frontend_redirect_url: options[:frontend_redirect_url],
33
+ backend_notify_url: options[:backend_notify_url]
34
+ }
35
+ )
36
+ end
32
37
  end
33
38
  end
34
- end
39
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Tappay
4
4
  class PaymentBase < Client
5
- VALID_INSTALMENT_VALUES = [0, 3, 6, 12, 24, 30].freeze
5
+ VALID_INSTALMENT_VALUES = [0, 3, 6, 12, 18, 24, 30].freeze
6
6
 
7
7
  def initialize(options = {})
8
8
  super
@@ -81,6 +81,10 @@ module Tappay
81
81
  end
82
82
 
83
83
  def get_merchant_id
84
+ # If merchant_group_id is set, it takes precedence over all other merchant IDs
85
+ return nil if Tappay.configuration.merchant_group_id
86
+
87
+ # Otherwise, return the default merchant_id
84
88
  Tappay.configuration.merchant_id
85
89
  end
86
90
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tappay
4
- VERSION = "0.10.0"
4
+ VERSION = "0.12.1"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tappay_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zac
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-01-02 00:00:00.000000000 Z
10
+ date: 2025-01-12 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: httparty