figpay_gateway 1.0.3 → 1.0.5

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: d59cba6b47a82b9e89b53596dfacbab9d878a5d4d9cea9d8203c7b86f16437ad
4
- data.tar.gz: a1c7b968a83539aff97dd6ca9ecbcb036b7618ade945572ac6221a3c4aaf96ed
3
+ metadata.gz: 68c11ff01e6b80e582293dea14fada0b65e335f50f5125e86863522b6438173f
4
+ data.tar.gz: d1fda8b1abc5233cc39a35eb849b8896143726c4a456724e8128edcd381ecfd5
5
5
  SHA512:
6
- metadata.gz: 38b028203836e1051721ea735c616c331632833cda9eb0f15e15d9b0fa73236db8d433eb1f6715c8c692db56b918b45e3381c5d30f6738d4a214520fb6c1e8f3
7
- data.tar.gz: cc42df57043042e8daa71c4648d0698af797432390d8f00fb2df31f6fbc39c7ef7ac0355d4ec140ab8bccab6613d2b0f9b95b89dbad5acaf00a34eef3928f538
6
+ metadata.gz: e4f1b9a51388850aa23f9768e7025710f8fb8ba1140ca509800ed08c4d7c3753519abecdc07ad05870d7ff6c0d2d1de8da3bf797bf10796ec4a422d73f381140
7
+ data.tar.gz: 31ad9e10483fd543a809ad9176af4fd659b4013105f1e38454ae67586e6ac7e50617e8ac7174370ac881a86799b65672bac9296f5cd6b1676a7463ebc97da053
data/README.md CHANGED
@@ -38,6 +38,10 @@ The library needs to be configured with your account's security key, which is av
38
38
 
39
39
  ### Configuration
40
40
 
41
+ You can configure the library in two ways:
42
+
43
+ #### Option 1: Environment Variables
44
+
41
45
  Set your security key as an environment variable:
42
46
 
43
47
  ```bash
@@ -56,6 +60,22 @@ For testing, you can use the demo account security key:
56
60
  NMI_SECURITY_KEY=6457Thfj624V5r7WUwc5v6a68Zsd6YEm
57
61
  ```
58
62
 
63
+ #### Option 2: Initializer (Recommended for Rails)
64
+
65
+ Create an initializer file (e.g., `config/initializers/figpay_gateway.rb`):
66
+
67
+ ```ruby
68
+ FigpayGateway.configure do |config|
69
+ config.security_key = Rails.application.credentials.dig(:nmi, :security_key)
70
+ # Optional: customize gateway URLs (defaults shown)
71
+ # config.transaction_url = 'https://figpay.transactiongateway.com/api/transact.php'
72
+ # config.query_url = 'https://figpay.transactiongateway.com/api/query.php'
73
+ # config.test_mode = 'enabled' # Enable test mode
74
+ end
75
+ ```
76
+
77
+ **Note:** You can use either `FigpayGateway.configure` or `NMIGateway.configure` - both work identically. Configuration values set via the initializer take precedence over environment variables.
78
+
59
79
  ### Quick Start
60
80
 
61
81
  ```ruby
@@ -309,6 +329,20 @@ plan = recurring.create_plan(
309
329
  )
310
330
  ```
311
331
 
332
+ #### List All Plans
333
+
334
+ Retrieve all recurring billing plans:
335
+
336
+ ```ruby
337
+ plans = FigpayGateway::Recurring.new.list_plans
338
+
339
+ if plans.success?
340
+ puts "Plans retrieved successfully"
341
+ end
342
+ ```
343
+
344
+ **Note:** The Query API may not be available on all accounts. Contact FigPay support if you encounter issues.
345
+
312
346
  #### Subscribe Customer to a Plan
313
347
 
314
348
  Add a vaulted customer to an existing plan:
@@ -1,3 +1,3 @@
1
1
  module FigpayGateway
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.5"
3
3
  end
@@ -1,3 +1,18 @@
1
1
  # FigPay Gateway is a wrapper around the NMI Gateway
2
2
  # This allows the gem to be portable across different NMI white-label providers
3
3
  require "nmi_gateway"
4
+
5
+ module FigpayGateway
6
+ # Alias configuration methods to NMIGateway
7
+ def self.configure(&block)
8
+ NMIGateway.configure(&block)
9
+ end
10
+
11
+ def self.configuration
12
+ NMIGateway.configuration
13
+ end
14
+
15
+ def self.configuration=(config)
16
+ NMIGateway.configuration = config
17
+ end
18
+ end
@@ -1,23 +1,30 @@
1
1
  module NMIGateway
2
2
  class Api
3
- TRANSACTION_URL = ENV.fetch("NMI_TRANSACTION_URL", "https://figpay.transactiongateway.com/api/transact.php")
4
- QUERY_URL = ENV.fetch("NMI_QUERY_URL", "https://figpay.transactiongateway.com/api/query.php")
5
3
  include HTTParty
6
4
 
7
- attr_accessor :security_key, :query
5
+ attr_accessor :security_key, :query, :configuration
8
6
 
9
- def initialize(options = {})
10
- @security_key = options[:security_key] || ENV["NMI_SECURITY_KEY"]
7
+ def initialize(options = {}, configuration = NMIGateway.configuration)
8
+ @configuration = configuration
9
+ @security_key = options[:security_key] || configuration.security_key
10
+ end
11
+
12
+ def transaction_url
13
+ @configuration.transaction_url
14
+ end
15
+
16
+ def query_url
17
+ @configuration.query_url
11
18
  end
12
19
 
13
20
  def get(options={})
14
- response = self.class.get(QUERY_URL, query: options.merge(credentials), timeout: 30, headers: headers)
21
+ response = self.class.get(query_url, query: options.merge(credentials), timeout: 30, headers: headers)
15
22
  api_type = options[:type] || options[:report_type]
16
23
  handle_response(response, api_type)
17
24
  end
18
25
 
19
26
  def post(options={})
20
- response = self.class.get(TRANSACTION_URL, query: options.merge(credentials), timeout: 30, headers: headers)
27
+ response = self.class.get(transaction_url, query: options.merge(credentials), timeout: 30, headers: headers)
21
28
  api_type = options[:type] || options[:customer_vault]
22
29
  handle_response(response, api_type)
23
30
  end
@@ -38,7 +45,7 @@ module NMIGateway
38
45
 
39
46
  def credentials
40
47
  creds = {security_key: security_key}
41
- creds[:test_mode] = ENV['NMI_TEST_MODE'] if ENV['NMI_TEST_MODE']
48
+ creds[:test_mode] = configuration.test_mode if configuration.test_mode
42
49
  creds
43
50
  end
44
51
 
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NMIGateway
4
+ class Configuration
5
+ attr_accessor :security_key, :transaction_url, :query_url, :test_mode
6
+
7
+ def initialize(options = {})
8
+ @security_key = options.dig(:security_key) || ENV["NMI_SECURITY_KEY"]
9
+ @transaction_url = options.dig(:transaction_url) || ENV.fetch("NMI_TRANSACTION_URL", "https://figpay.transactiongateway.com/api/transact.php")
10
+ @query_url = options.dig(:query_url) || ENV.fetch("NMI_QUERY_URL", "https://figpay.transactiongateway.com/api/query.php")
11
+ @test_mode = options.dig(:test_mode) || ENV["NMI_TEST_MODE"]
12
+ end
13
+ end
14
+ end
@@ -11,6 +11,12 @@ module NMIGateway
11
11
  post query
12
12
  end
13
13
 
14
+ # NMIGateway::Recurring.new.list_plans
15
+ def list_plans(options = {})
16
+ query = set_query(options)
17
+ query[:report_type] = 'recurring_plans'
18
+ get query
19
+ end
14
20
 
15
21
  # NMIGateway::Recurring.new.add_subscription_to_plan plan_id: "test-1", customer_vault_id: 664625840
16
22
  def add_subscription_to_plan(options = {})
@@ -89,6 +89,10 @@ module NMIGateway
89
89
  parsed_response
90
90
  end
91
91
 
92
+ def set_recurring_plans
93
+ parsed_response
94
+ end
95
+
92
96
  def set_customer_vault
93
97
  parsed_response
94
98
  if parsed_response && parsed_response['nm_response'] && parsed_response['nm_response']['customer_vault'] && customers = parsed_response['nm_response']['customer_vault']['customer']
data/lib/nmi_gateway.rb CHANGED
@@ -5,6 +5,7 @@ require "ostruct"
5
5
 
6
6
  require "figpay_gateway/version"
7
7
 
8
+ require "nmi_gateway/configuration"
8
9
  require "nmi_gateway/api"
9
10
  require "nmi_gateway/data"
10
11
  require "nmi_gateway/result/action"
@@ -17,6 +18,20 @@ require "nmi_gateway/recurring"
17
18
  require "nmi_gateway/response"
18
19
  require "nmi_gateway/transaction"
19
20
 
21
+ module NMIGateway
22
+ class << self
23
+ attr_writer :configuration
24
+ end
25
+
26
+ def self.configure
27
+ yield(configuration)
28
+ end
29
+
30
+ def self.configuration
31
+ @configuration ||= NMIGateway::Configuration.new
32
+ end
33
+ end
34
+
20
35
  module FigpayGateway
21
36
  # Expose NMIGateway classes under the FigpayGateway namespace
22
37
  Api = NMIGateway::Api
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: figpay_gateway
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Eggett
@@ -233,6 +233,7 @@ files:
233
233
  - lib/figpay_gateway/version.rb
234
234
  - lib/nmi_gateway.rb
235
235
  - lib/nmi_gateway/api.rb
236
+ - lib/nmi_gateway/configuration.rb
236
237
  - lib/nmi_gateway/customer_vault.rb
237
238
  - lib/nmi_gateway/data.rb
238
239
  - lib/nmi_gateway/error.rb