tappay_ruby 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a31a7dd2dae54e34e6cb67c26d2063bb55ee28a313c87164ff362ff0b3cff405
4
- data.tar.gz: 8103f3a1bb11d48a7781a735eeba2afc75bb4a6b1d2d2d590b1bd3dcb211fc63
3
+ metadata.gz: bc1badbabf5c5def08a9d4083c9d7d5914208a2d9854cabf0281741c386f2ae0
4
+ data.tar.gz: 82ff98a54ceb603606186c94e7bb6c9dd28173543dabc28e68cf286f84363f55
5
5
  SHA512:
6
- metadata.gz: d575276fde2cb8fcb25404efb44b504079075243c9c72293825edb967e0f97a418a65928fc94f69a120ae7c664528038e941ad9332d9b7abcee4d3313fbd85e1
7
- data.tar.gz: 8f3851d3008f156ecf7c63b9ae4d24ff79604271b2d056d662c24bc4183a7c97187cdb5d4540d16e989789af9e3bf226a63756d8d4b0c750326f3a2586f11891
6
+ metadata.gz: 7b3a89d63470d95a2d62af9a32b04048c211409a09af1a05e5c5a955a7d059e29f166c512d874a73c7f6b0af94618ed965d8b144b495e8c7df36bb17dfc528b4
7
+ data.tar.gz: a2f99fbd4e843b457249a455d6e711f4d52deb44469c727df30cd97666c31c64879c20990b1f9e96f395786c749a6f09527590744805568c28ddd2fe6815b5c4
@@ -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 = '2'
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]
@@ -1,3 +1,3 @@
1
1
  module Tappay
2
- VERSION = "0.4.2"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tappay_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zac