tappay_ruby 0.5.1 → 0.6.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 +50 -1
- data/lib/tappay/credit_card/instalment.rb +26 -0
- data/lib/tappay/credit_card/pay.rb +10 -0
- 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: 1396c7927613825f5182660db63871bc06c114cc38ef334b6143929e7e88f730
|
4
|
+
data.tar.gz: a6e2fcf2e65a3fa7d47e2a6f7f621d149e189f8be2ec980391e767ecc0000d27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d9e6b6a5394f54f846562e38053a490145f0c779aca7e61096ec43e3c2ee6055387639790352885b52db8a0918119469897e8b83fcef910965ad7e0d8f5e278
|
7
|
+
data.tar.gz: ae5f360a2e89ede2df5c0f5d104105aeaefa10c0409b075074a903141d822690328a3e11ee7a55f8fb0256f632d72dac2f76f066b00440dd6cb89351c0c2d8f5
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# TapPay Ruby Gem
|
2
2
|
|
3
|
+
![Gem Version](https://img.shields.io/gem/v/tappay_ruby)
|
3
4
|
[![RSpec](https://github.com/7a6163/tappay/actions/workflows/rspec.yml/badge.svg)](https://github.com/7a6163/tappay/actions/workflows/rspec.yml)
|
4
5
|
[![codecov](https://codecov.io/gh/7a6163/tappay/branch/main/graph/badge.svg)](https://codecov.io/gh/7a6163/tappay)
|
5
6
|
|
@@ -197,6 +198,24 @@ if result['status'] == 0
|
|
197
198
|
end
|
198
199
|
```
|
199
200
|
|
201
|
+
## URL Properties
|
202
|
+
|
203
|
+
The `result_url` (JSONObject) property is required when using LINE Pay, JKOPAY, 悠遊付, Atome, Pi錢包, 全盈支付, or when three_domain_secure is true. It contains the following URL fields:
|
204
|
+
|
205
|
+
```json
|
206
|
+
{
|
207
|
+
"frontend_redirect_url": "https://example.com/redirect", // Required - URL where consumer will be redirected after completing the transaction
|
208
|
+
"backend_notify_url": "https://example.com/notify", // Required - URL where your server receives transaction results (only port 443)
|
209
|
+
"go_back_url": "https://example.com/back" // Optional - URL for 3D verification error cases (E.SUN, Cathay United, Taishin banks)
|
210
|
+
}
|
211
|
+
```
|
212
|
+
|
213
|
+
- `frontend_redirect_url` (String): After the consumer completes the transaction process in LINE Pay, JKOPAY, 悠遊付, Atome, Pi錢包, 全盈支付, or 3D verification, they will be redirected to this frontend URL. Must start with https.
|
214
|
+
|
215
|
+
- `backend_notify_url` (String): URL where your server receives transaction results. Must start with https and only supports port 443.
|
216
|
+
|
217
|
+
- `go_back_url` (String): For 3D verification transactions, this URL is used when consumers are redirected to the TapPay Error page due to improper operation. This scenario only occurs with E.SUN Bank, Cathay United Bank, and Taishin Bank. You can define this URL in the transaction request or set it in TapPay Portal > Developer Content > System Settings > Redirect Link Settings. It's strongly recommended to define this field for 3D transactions to ensure consumers can return to complete the transaction or view results.
|
218
|
+
|
200
219
|
## Usage
|
201
220
|
|
202
221
|
### Pay by Prime
|
@@ -224,7 +243,7 @@ if result['status'] == 0
|
|
224
243
|
card_token = result['card_secret']['card_token']
|
225
244
|
# Store card_key and card_token securely for future payments
|
226
245
|
end
|
227
|
-
|
246
|
+
|
228
247
|
# Handle payment URL if present (for 3D Secure, LINE Pay, JKO Pay)
|
229
248
|
if result['payment_url']
|
230
249
|
redirect_to result['payment_url']
|
@@ -324,6 +343,36 @@ rescue Tappay::ValidationError => e
|
|
324
343
|
end
|
325
344
|
```
|
326
345
|
|
346
|
+
### Example Usage with result_url
|
347
|
+
|
348
|
+
```ruby
|
349
|
+
# Example of payment with result_url for LINE Pay
|
350
|
+
result = Tappay::LinePay::Pay.create(
|
351
|
+
prime: 'prime_from_tappay_sdk',
|
352
|
+
amount: 100,
|
353
|
+
merchant_id: 'your_merchant_id',
|
354
|
+
details: 'Product Item',
|
355
|
+
result_url: {
|
356
|
+
frontend_redirect_url: 'https://example.com/payment/complete',
|
357
|
+
backend_notify_url: 'https://example.com/payment/notify',
|
358
|
+
go_back_url: 'https://example.com/payment/error'
|
359
|
+
}
|
360
|
+
)
|
361
|
+
|
362
|
+
# Example of payment with result_url for 3D verification
|
363
|
+
result = Tappay::CreditCard::Pay.by_prime(
|
364
|
+
prime: 'prime_from_tappay_sdk',
|
365
|
+
amount: 100,
|
366
|
+
merchant_id: 'your_merchant_id',
|
367
|
+
three_domain_secure: true,
|
368
|
+
result_url: {
|
369
|
+
frontend_redirect_url: 'https://example.com/3d/complete',
|
370
|
+
backend_notify_url: 'https://example.com/3d/notify',
|
371
|
+
go_back_url: 'https://example.com/3d/error'
|
372
|
+
}
|
373
|
+
)
|
374
|
+
```
|
375
|
+
|
327
376
|
## Development
|
328
377
|
|
329
378
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.
|
@@ -26,11 +26,24 @@ module Tappay
|
|
26
26
|
Tappay::Endpoints::CreditCard.payment_by_prime_url
|
27
27
|
end
|
28
28
|
|
29
|
+
def validate_options!
|
30
|
+
super
|
31
|
+
validate_result_url_for_instalment!
|
32
|
+
end
|
33
|
+
|
29
34
|
private
|
30
35
|
|
31
36
|
def additional_required_options
|
32
37
|
[:prime, :cardholder, :instalment]
|
33
38
|
end
|
39
|
+
|
40
|
+
def validate_result_url_for_instalment!
|
41
|
+
return if options[:result_url] &&
|
42
|
+
options[:result_url][:frontend_redirect_url] &&
|
43
|
+
options[:result_url][:backend_notify_url]
|
44
|
+
|
45
|
+
raise ValidationError, "result_url with frontend_redirect_url and backend_notify_url is required for instalment payments"
|
46
|
+
end
|
34
47
|
end
|
35
48
|
|
36
49
|
class InstalmentByToken < PaymentBase
|
@@ -50,11 +63,24 @@ module Tappay
|
|
50
63
|
Tappay::Endpoints::CreditCard.payment_by_token_url
|
51
64
|
end
|
52
65
|
|
66
|
+
def validate_options!
|
67
|
+
super
|
68
|
+
validate_result_url_for_instalment!
|
69
|
+
end
|
70
|
+
|
53
71
|
private
|
54
72
|
|
55
73
|
def additional_required_options
|
56
74
|
[:card_key, :card_token, :instalment]
|
57
75
|
end
|
76
|
+
|
77
|
+
def validate_result_url_for_instalment!
|
78
|
+
return if options[:result_url] &&
|
79
|
+
options[:result_url][:frontend_redirect_url] &&
|
80
|
+
options[:result_url][:backend_notify_url]
|
81
|
+
|
82
|
+
raise ValidationError, "result_url with frontend_redirect_url and backend_notify_url is required for instalment payments"
|
83
|
+
end
|
58
84
|
end
|
59
85
|
end
|
60
86
|
end
|
@@ -61,6 +61,7 @@ module Tappay
|
|
61
61
|
end
|
62
62
|
data[:cardholder] = card_holder_data if options[:cardholder]
|
63
63
|
data[:instalment] = options[:instalment] if options[:instalment]
|
64
|
+
data[:result_url] = options[:result_url] if options[:result_url]
|
64
65
|
end
|
65
66
|
end
|
66
67
|
|
@@ -83,6 +84,7 @@ module Tappay
|
|
83
84
|
raise ValidationError, "Missing required options: #{missing.join(', ')}" if missing.any?
|
84
85
|
|
85
86
|
validate_instalment! if options[:instalment]
|
87
|
+
validate_result_url! if options[:three_domain_secure]
|
86
88
|
end
|
87
89
|
|
88
90
|
private
|
@@ -100,6 +102,14 @@ module Tappay
|
|
100
102
|
raise ValidationError, "Invalid instalment value. Must be between 1 and 12"
|
101
103
|
end
|
102
104
|
end
|
105
|
+
|
106
|
+
def validate_result_url!
|
107
|
+
return if options[:result_url] &&
|
108
|
+
options[:result_url][:frontend_redirect_url] &&
|
109
|
+
options[:result_url][:backend_notify_url]
|
110
|
+
|
111
|
+
raise ValidationError, "result_url with frontend_redirect_url and backend_notify_url is required when three_domain_secure is true"
|
112
|
+
end
|
103
113
|
end
|
104
114
|
|
105
115
|
class Pay < PaymentBase
|
data/lib/tappay/version.rb
CHANGED