figpay_gateway 1.0.1 → 1.0.4

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: 03aa3ece2a07c3c8357a821ae7132f426d662e5eaf4d83953742fc42edb35946
4
- data.tar.gz: 8c0ea4eaad5351909cef1f25a41ecebc92fa47b1bb3ba9bf2850dce07d30b104
3
+ metadata.gz: 0fe878288323339cb8ff06b8a483a4966c21aadfbec9cac083b2fd251e3e5737
4
+ data.tar.gz: c44c285af844da93fbc5bf874a742156590a6d8739ba2fb31cef4ef64edeb89b
5
5
  SHA512:
6
- metadata.gz: 88183bb02b6029d9da56ae4ea077375a57e851bb7de00eeeebfe08284e16a4debeece51f624174e157b062a854f9084fbd0aab88f980c4343b593add65722b29
7
- data.tar.gz: ed560173896abfe6ea4de038b9d5ff880b45e12598bfc7f26a282936f88f80f10cf165bcbafd989e6fec612fec5637bebe8b223cd8df5a555234c86e49d54eef
6
+ metadata.gz: db4f813d03fdd3fdbc398206c2ced3dc0e4043376b72c5a41cb4f882cbb5918285b9f8e170732021445579eddf00c123a9794e3989d00756eab12bfb3cddbdfc
7
+ data.tar.gz: 2863a295a038446ae9a2fb07e422ce754e75db67cd4ab47e2e2067925158a01129e546543a105822940c436bb3da8840b1980f518a54f0efd4e17a1f920e8eb3
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
@@ -86,6 +106,17 @@ The FigPay Gateway library is organized around three main API sets:
86
106
 
87
107
  Process credit card transactions including sales, authorizations, captures, and refunds.
88
108
 
109
+ #### Recommendation - use collect.js to tokenize cards client side
110
+
111
+ The payment gateway supports credit card tokenization via [Collect.js](https://figpay.transactiongateway.com//merchants/resources/integration/integration_portal.php#cjs_methodology). The benefit of this approach is that sensitive PCI information will be submitted directly to payment processor servers, they will return a token that you would send back to your servers, and reduce the PCI SAQ compliance requirements from SAQ-C or SAQ-D to SAQ-A. This greatly simplifies compliance, as no credit information would ever touch your logs or servers.
112
+
113
+ Test Token example: `00000000-000000-000000-000000000000`
114
+ This is tied to a test card: `Card: 4111111111111111, Expiration: October 2025, CVV: 999`
115
+
116
+ Usage, in all examples, rather than passing in `ccnumber` and `ccexp`, these can be updated to use the token obtained via Collect.js and passed in as a `payment_token` param instead.
117
+
118
+ There is a Test Public Key that can be used with Collect.js: `48r3R6-M39Jx5-467srN-VWVbD3`
119
+
89
120
  #### Create a Sale
90
121
 
91
122
  Process a direct sale (authorization and capture combined):
@@ -186,7 +217,7 @@ Retrieve transaction details:
186
217
 
187
218
  ```ruby
188
219
  details = FigpayGateway::Transaction.new.find(
189
- transactionid: '3261844010'
220
+ transaction_id: '3261844010'
190
221
  )
191
222
  ```
192
223
 
@@ -1,3 +1,3 @@
1
1
  module FigpayGateway
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.4"
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
 
@@ -67,6 +74,9 @@ module NMIGateway
67
74
  query[:ccexp] = options[:ccexp] # FORMAT MMYY
68
75
  query[:cvv] = options[:cvv] # Recommended
69
76
 
77
+ # Payment Token
78
+ query[:payment_token] = options[:payment_token] # from Collect.js
79
+
70
80
  # Payment
71
81
  query[:amount] = options[:amount]
72
82
  query[:currency] = options[:currency] || 'USD'
@@ -83,7 +93,7 @@ module NMIGateway
83
93
  # Recurring Billing
84
94
  query[:recurring] = options[:recurring ] # add_subscription
85
95
  query[:plan_id] = options [:plan_id]
86
- query[:plan_name] = options [:plan_name]
96
+ query[:plan_name] = options [:plan_name]
87
97
  query[:plan_payments] = options [:plan_payments] # 0 until canceled
88
98
  query[:plan_amount] = options [:plan_amount]
89
99
  query[:day_frequency] = options [:day_frequency]
@@ -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
@@ -2,11 +2,15 @@ module NMIGateway
2
2
  class CustomerVault < Api
3
3
 
4
4
  # NMIGateway::CustomerVault.new.create ccnumber: '4111111111111111', ccexp: "0219", first_name: "John", last_name: "Doe"
5
+ # NMIGateway::CustomerVault.new.create payment_token: "00000000-000000-000000-000000000000", first_name: "John", last_name: "Doe"
5
6
  def create(options = {})
6
7
  query = set_query(options)
7
8
  query[:customer_vault] = 'add_customer'
8
-
9
- require_fields(:ccnumber, :ccexp)
9
+ if query[:payment_token]
10
+ require_fields(:payment_token, :first_name, :last_name)
11
+ else
12
+ require_fields(:ccnumber, :ccexp, :first_name, :last_name)
13
+ end
10
14
  post query
11
15
  end
12
16
 
@@ -65,7 +65,7 @@ module NMIGateway
65
65
  post query
66
66
  end
67
67
 
68
- # NMIGateway::Transaction.new.find transactionid: 3261844010
68
+ # NMIGateway::Transaction.new.find transaction_id: 3261844010
69
69
  def find(options = {})
70
70
  query = set_query(options)
71
71
  query[:report_type] ||= 'transaction'
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.1
4
+ version: 1.0.4
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