tappay_ruby 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -76
- data/lib/tappay/credit_card/instalment.rb +8 -0
- data/lib/tappay/jko_pay/pay.rb +4 -0
- data/lib/tappay/line_pay/pay.rb +4 -0
- data/lib/tappay/payment_base.rb +5 -1
- 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: 920fd5c582914989062cb76fc47306e6ec3b4714b2558e2d4f04e2e43c4c11a0
|
4
|
+
data.tar.gz: 85a9f5331b47bdfbb78f81da3236d5123086f873e1260fb68b5c757bb7984e1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fb651e7b40a652a725896d697a75a3e47484f58bc64102b057bfa2a8b049f0427b8c1bdb0dcaa229d84f999898e291b9bfd36548e0ce012fdff4cb706201b03
|
7
|
+
data.tar.gz: 62b665b0e9d15c07966cc61998d215ff2e531a1664d5dffd824b9fc116db93a4c031f1f5271e5701cc445793056bd167ca561c6688064a281707dcba17e27839
|
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
|
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
|
-
|
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
|
-
#
|
64
|
-
|
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 = '
|
63
|
+
config.merchant_group_id = 'YOUR_MERCHANT_GROUP_ID'
|
67
64
|
|
68
|
-
#
|
69
|
-
|
70
|
-
config.
|
71
|
-
config.
|
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.
|
74
|
-
config.vat_number = 'your_vat_number'.freeze
|
71
|
+
config.mode = :sandbox # or :production
|
75
72
|
end
|
76
73
|
```
|
77
74
|
|
78
|
-
|
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
|
-
|
77
|
+
The gem uses the following priority order when resolving merchant IDs:
|
126
78
|
|
127
|
-
|
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
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
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
|
|
data/lib/tappay/jko_pay/pay.rb
CHANGED
@@ -15,6 +15,10 @@ module Tappay
|
|
15
15
|
private
|
16
16
|
|
17
17
|
def get_merchant_id
|
18
|
+
# If merchant_group_id is set, it takes precedence
|
19
|
+
return nil if Tappay.configuration.merchant_group_id
|
20
|
+
|
21
|
+
# Otherwise, use jko_pay_merchant_id or fall back to default merchant_id
|
18
22
|
Tappay.configuration.jko_pay_merchant_id || super
|
19
23
|
end
|
20
24
|
|
data/lib/tappay/line_pay/pay.rb
CHANGED
@@ -23,6 +23,10 @@ module Tappay
|
|
23
23
|
private
|
24
24
|
|
25
25
|
def get_merchant_id
|
26
|
+
# If merchant_group_id is set, it takes precedence
|
27
|
+
return nil if Tappay.configuration.merchant_group_id
|
28
|
+
|
29
|
+
# Otherwise, use line_pay_merchant_id or fall back to default merchant_id
|
26
30
|
Tappay.configuration.line_pay_merchant_id || super
|
27
31
|
end
|
28
32
|
|
data/lib/tappay/payment_base.rb
CHANGED
@@ -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
|
|
data/lib/tappay/version.rb
CHANGED