tappay_ruby 0.4.2 → 0.5.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 +4 -4
- data/lib/tappay/configuration.rb +2 -2
- data/lib/tappay/credit_card/pay.rb +34 -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: bc1badbabf5c5def08a9d4083c9d7d5914208a2d9854cabf0281741c386f2ae0
|
4
|
+
data.tar.gz: 82ff98a54ceb603606186c94e7bb6c9dd28173543dabc28e68cf286f84363f55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b3a89d63470d95a2d62af9a32b04048c211409a09af1a05e5c5a955a7d059e29f166c512d874a73c7f6b0af94618ed965d8b144b495e8c7df36bb17dfc528b4
|
7
|
+
data.tar.gz: a2f99fbd4e843b457249a455d6e711f4d52deb44469c727df30cd97666c31c64879c20990b1f9e96f395786c749a6f09527590744805568c28ddd2fe6815b5c4
|
data/lib/tappay/configuration.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
module Tappay
|
2
2
|
class Configuration
|
3
|
-
attr_accessor :partner_key, :merchant_id, :instalment_merchant_id, :app_id, :currency, :vat_number
|
3
|
+
attr_accessor :partner_key, :merchant_id, :merchant_group_id, :instalment_merchant_id, :app_id, :currency, :vat_number
|
4
4
|
attr_writer :api_version
|
5
5
|
|
6
6
|
def initialize
|
7
7
|
@mode = :sandbox
|
8
|
-
@api_version = '
|
8
|
+
@api_version = '3'
|
9
9
|
end
|
10
10
|
|
11
11
|
def api_version
|
@@ -17,15 +17,48 @@ module Tappay
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def payment_data
|
20
|
+
# Check configuration conflicts first
|
21
|
+
if Tappay.configuration.merchant_group_id && Tappay.configuration.merchant_id
|
22
|
+
raise Tappay::ValidationError, "merchant_group_id and merchant_id cannot be used together"
|
23
|
+
end
|
24
|
+
|
25
|
+
# Get values from options
|
26
|
+
opt_group_id = options[:merchant_group_id]
|
27
|
+
opt_merchant_id = options[:merchant_id]
|
28
|
+
|
29
|
+
# Check for conflicts in options
|
30
|
+
if opt_group_id && opt_merchant_id
|
31
|
+
raise Tappay::ValidationError, "merchant_group_id and merchant_id cannot be used together"
|
32
|
+
end
|
33
|
+
|
34
|
+
# If options has any ID, use it exclusively
|
35
|
+
if opt_group_id || opt_merchant_id
|
36
|
+
merchant_group_id = opt_group_id
|
37
|
+
merchant_id = opt_merchant_id
|
38
|
+
else
|
39
|
+
# If no options, use configuration
|
40
|
+
merchant_group_id = Tappay.configuration.merchant_group_id
|
41
|
+
merchant_id = Tappay.configuration.merchant_id
|
42
|
+
end
|
43
|
+
|
44
|
+
# Check if at least one is provided
|
45
|
+
unless merchant_group_id || merchant_id
|
46
|
+
raise Tappay::ValidationError, "Either merchant_group_id or merchant_id must be provided"
|
47
|
+
end
|
48
|
+
|
20
49
|
{
|
21
50
|
partner_key: Tappay.configuration.partner_key,
|
22
|
-
merchant_id: options[:merchant_id] || Tappay.configuration.merchant_id,
|
23
51
|
amount: options[:amount],
|
24
52
|
details: options[:details],
|
25
53
|
currency: options[:currency] || 'TWD',
|
26
54
|
order_number: options[:order_number],
|
27
55
|
three_domain_secure: options[:three_domain_secure] || false
|
28
56
|
}.tap do |data|
|
57
|
+
if merchant_group_id
|
58
|
+
data[:merchant_group_id] = merchant_group_id
|
59
|
+
else
|
60
|
+
data[:merchant_id] = merchant_id
|
61
|
+
end
|
29
62
|
data[:cardholder] = card_holder_data if options[:cardholder]
|
30
63
|
data[:instalment] = options[:instalment] if options[:instalment]
|
31
64
|
data[:payment_url] = options[:payment_url] if options[:payment_url]
|
data/lib/tappay/version.rb
CHANGED