tappay_ruby 0.15.1 → 0.15.3

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: 264a2d799886486e223fc853591b71c289731c9b04b1048c89b6d748e7f19d38
4
- data.tar.gz: 8450e797c8886ae57eef4478335c31621eb50260e4e657f04adb329fa8b5e171
3
+ metadata.gz: 25eb0335ebc15cc3892116340911cc3f4cf3e66c3d0864290bee488765bd8b78
4
+ data.tar.gz: 303bdd7c63c782f82a05e8708c7e6795210ea9125c8888cf417e5d0b1def1ad3
5
5
  SHA512:
6
- metadata.gz: 49df27035a8b78c26851c48b71820b246197a8278fa73c04b078471afb286293d745b99a9929d0e80a8318d36b0533110e2d90360b817e0acf6691cd1866f5b0
7
- data.tar.gz: c7d73d6633a465b8c9f65ff6da4d26ec4d2c749bdcb27fd9f21c6298904f1e3dc2dcd56401867b696959cc5bd37b99d1403711eb007d4ab95a5f4a922db269f6
6
+ metadata.gz: d8b7522b914a05d4e15ec16cef8f451a1041ad3bfa2900e527d5a3ed993b506270d35318f4ab4bff5ad90f703cc6c15c07ddd69c42e4027884a61c0d2e268224
7
+ data.tar.gz: 902bd6ebdee3945d4ae1d7219172041601df018d546e863559611d4afaf79c01423fce4f1c0bc4c8c2cf8050f0e4ae286cfb87051fc3d89dd6627445bf6f943c
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. Direct Configuration
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
- # OR
64
- config.merchant_group_id = 'YOUR_MERCHANT_GROUP_ID'
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
- # Optional merchant IDs for specific payment methods
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
- config.mode = :sandbox # or :production
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)
@@ -3,6 +3,7 @@ require 'json'
3
3
  module Tappay
4
4
  module ApplePay
5
5
  class Pay < PaymentBase
6
+
6
7
  def endpoint_url
7
8
  Tappay::Endpoints::Payment.pay_by_prime_url
8
9
  end
@@ -1,6 +1,11 @@
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
8
+
4
9
  def self.by_prime(options = {})
5
10
  InstalmentByPrime.new(options)
6
11
  end
@@ -11,10 +16,6 @@ module Tappay
11
16
  end
12
17
 
13
18
  class InstalmentByPrime < PaymentBase
14
- def initialize(options = {})
15
- super(options)
16
- end
17
-
18
19
  def payment_data
19
20
  super.merge(
20
21
  prime: options[:prime],
@@ -26,39 +27,14 @@ module Tappay
26
27
  Tappay::Endpoints::Payment.pay_by_prime_url
27
28
  end
28
29
 
29
- def validate_options!
30
- super
31
- validate_result_url_for_instalment!
32
- end
33
-
34
30
  private
35
31
 
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
32
  def additional_required_options
45
- [:prime, :cardholder, :instalment]
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"
33
+ [:prime, :instalment]
54
34
  end
55
35
  end
56
36
 
57
37
  class InstalmentByToken < PaymentBase
58
- def initialize(options = {})
59
- super(options)
60
- end
61
-
62
38
  def payment_data
63
39
  super.merge(
64
40
  card_key: options[:card_key],
@@ -71,32 +47,11 @@ module Tappay
71
47
  Tappay::Endpoints::Payment.pay_by_token_url
72
48
  end
73
49
 
74
- def validate_options!
75
- super
76
- validate_result_url_for_instalment!
77
- end
78
-
79
50
  private
80
51
 
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
52
  def additional_required_options
90
53
  [:card_key, :card_token, :instalment]
91
54
  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
55
  end
101
56
  end
102
57
  end
@@ -3,8 +3,9 @@ require 'json'
3
3
  module Tappay
4
4
  module GooglePay
5
5
  class Pay < PaymentBase
6
- def initialize(client)
7
- super(client)
6
+
7
+ def endpoint_url
8
+ Tappay::Endpoints::Payment.pay_by_prime_url
8
9
  end
9
10
 
10
11
  private
@@ -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
- data = super
28
- data[:result_url] = {
29
- frontend_redirect_url: options[:frontend_redirect_url],
30
- backend_notify_url: options[:backend_notify_url]
31
- }
32
- data[:prime] = options[:prime]
33
- data
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
@@ -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
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tappay
4
- VERSION = "0.15.1"
4
+ VERSION = "0.15.3"
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.15.1
4
+ version: 0.15.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zac
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-01-22 00:00:00.000000000 Z
10
+ date: 2025-01-23 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: httparty
@@ -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: