figpay_gateway 1.0.3 → 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 +4 -4
- data/README.md +20 -0
- data/lib/figpay_gateway/version.rb +1 -1
- data/lib/figpay_gateway.rb +15 -0
- data/lib/nmi_gateway/api.rb +15 -8
- data/lib/nmi_gateway/configuration.rb +14 -0
- data/lib/nmi_gateway.rb +15 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0fe878288323339cb8ff06b8a483a4966c21aadfbec9cac083b2fd251e3e5737
|
|
4
|
+
data.tar.gz: c44c285af844da93fbc5bf874a742156590a6d8739ba2fb31cef4ef64edeb89b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
data/lib/figpay_gateway.rb
CHANGED
|
@@ -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
|
data/lib/nmi_gateway/api.rb
CHANGED
|
@@ -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
|
-
@
|
|
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(
|
|
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(
|
|
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] =
|
|
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
|
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.
|
|
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
|