laundry 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/Gemfile +9 -0
- data/LICENSE +22 -0
- data/README.md +34 -0
- data/Rakefile +12 -0
- data/laundry.gemspec +21 -0
- data/lib/laundry/lib/soap_model.rb +113 -0
- data/lib/laundry/payments_gateway/drivers/account_driver.rb +48 -0
- data/lib/laundry/payments_gateway/drivers/client_driver.rb +73 -0
- data/lib/laundry/payments_gateway/drivers/merchant_authenticatable_driver.rb +40 -0
- data/lib/laundry/payments_gateway/drivers/socket_driver.rb +24 -0
- data/lib/laundry/payments_gateway/drivers/transaction_driver.rb +25 -0
- data/lib/laundry/payments_gateway/models/account.rb +61 -0
- data/lib/laundry/payments_gateway/models/client.rb +22 -0
- data/lib/laundry/payments_gateway/models/merchant.rb +54 -0
- data/lib/laundry/payments_gateway/models/response_model.rb +30 -0
- data/lib/laundry/payments_gateway/models/transaction.rb +17 -0
- data/lib/laundry/payments_gateway/models/transaction_response.rb +42 -0
- data/lib/laundry/payments_gateway/payments_gateway.rb +12 -0
- data/lib/laundry/version.rb +3 -0
- data/lib/laundry.rb +22 -0
- metadata +88 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Wil Gieseler
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#Laundry [![Build Status](https://secure.travis-ci.org/supapuerco/laundry.png)](http://travis-ci.org/supapuerco/laundry) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/supapuerco/laundry)
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
merchant = Laundry::PaymentsGateway::Merchant.new(id: '12345', api_login_id: 'abcd', api_password: 'secret')
|
6
|
+
merchant.clients.find(10).accounts.create!
|
7
|
+
|
8
|
+
[View the Rdoc](http://rdoc.info/github/supapuerco/laundry/master/frames)
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
gem 'laundry'
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install laundry
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
TODO: Write usage instructions here
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
1. Fork it
|
31
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
32
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
33
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
34
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/laundry.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/laundry/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
|
6
|
+
gem.authors = ["Wil Gieseler"]
|
7
|
+
gem.email = ["supapuerco@gmail.com"]
|
8
|
+
gem.description = "A soapy interface to ACH Direct's PaymentsGateway.com service."
|
9
|
+
gem.summary = "A soapy interface to ACH Direct's PaymentsGateway.com service."
|
10
|
+
gem.homepage = "https://github.com/supapuerco/laundry"
|
11
|
+
|
12
|
+
gem.files = `git ls-files`.split($\)
|
13
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
14
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
|
+
gem.name = "laundry"
|
16
|
+
gem.require_paths = ["lib"]
|
17
|
+
gem.version = Laundry::VERSION
|
18
|
+
|
19
|
+
gem.add_dependency 'savon'
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
module Laundry
|
2
|
+
|
3
|
+
# = Savon::Model
|
4
|
+
#
|
5
|
+
# Model for SOAP service oriented applications.
|
6
|
+
module SOAPModel
|
7
|
+
|
8
|
+
def self.extended(base)
|
9
|
+
base.setup
|
10
|
+
end
|
11
|
+
|
12
|
+
def setup
|
13
|
+
class_action_module
|
14
|
+
instance_action_module
|
15
|
+
end
|
16
|
+
|
17
|
+
# Accepts one or more SOAP actions and generates both class and instance methods named
|
18
|
+
# after the given actions. Each generated method accepts an optional SOAP body Hash and
|
19
|
+
# a block to be passed to <tt>Savon::Client#request</tt> and executes a SOAP request.
|
20
|
+
def actions(*actions)
|
21
|
+
actions.each do |action|
|
22
|
+
define_class_action(action)
|
23
|
+
define_instance_action(action)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
# Defines a class-level SOAP action method.
|
30
|
+
def define_class_action(action)
|
31
|
+
class_action_module.module_eval %{
|
32
|
+
def #{action.to_s.snakecase}(body = nil, &block)
|
33
|
+
client.request :wsdl, #{action.inspect}, :body => body, &block
|
34
|
+
end
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
# Defines an instance-level SOAP action method.
|
39
|
+
def define_instance_action(action)
|
40
|
+
instance_action_module.module_eval %{
|
41
|
+
def #{action.to_s.snakecase}(body = nil, &block)
|
42
|
+
self.class.#{action.to_s.snakecase} merged_default_body(body), &block
|
43
|
+
end
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
# Class methods.
|
48
|
+
def class_action_module
|
49
|
+
@class_action_module ||= Module.new do
|
50
|
+
|
51
|
+
# Returns the memoized <tt>Savon::Client</tt>.
|
52
|
+
def client(&block)
|
53
|
+
@client ||= Savon::Client.new(&block)
|
54
|
+
end
|
55
|
+
|
56
|
+
# Sets the SOAP endpoint to the given +uri+.
|
57
|
+
def endpoint(uri)
|
58
|
+
client.wsdl.endpoint = uri
|
59
|
+
end
|
60
|
+
|
61
|
+
# Sets the target namespace.
|
62
|
+
def namespace(uri)
|
63
|
+
client.wsdl.namespace = uri
|
64
|
+
end
|
65
|
+
|
66
|
+
# Sets the WSDL document to the given +uri+.
|
67
|
+
def document(uri)
|
68
|
+
client.wsdl.document = uri
|
69
|
+
end
|
70
|
+
|
71
|
+
# Sets the HTTP headers.
|
72
|
+
def headers(headers)
|
73
|
+
client.http.headers = headers
|
74
|
+
end
|
75
|
+
|
76
|
+
# Sets basic auth +login+ and +password+.
|
77
|
+
def basic_auth(login, password)
|
78
|
+
client.http.auth.basic(login, password)
|
79
|
+
end
|
80
|
+
|
81
|
+
# Sets WSSE auth credentials.
|
82
|
+
def wsse_auth(*args)
|
83
|
+
client.wsse.credentials(*args)
|
84
|
+
end
|
85
|
+
|
86
|
+
end.tap { |mod| extend(mod) }
|
87
|
+
end
|
88
|
+
|
89
|
+
# Instance methods.
|
90
|
+
def instance_action_module
|
91
|
+
@instance_action_module ||= Module.new do
|
92
|
+
|
93
|
+
# Returns the <tt>Savon::Client</tt> from the class instance.
|
94
|
+
def client(&block)
|
95
|
+
self.class.client(&block)
|
96
|
+
end
|
97
|
+
|
98
|
+
def default_body(hash)
|
99
|
+
@default_body = hash
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
def merged_default_body(body = {})
|
105
|
+
(@default_body || {}).merge (body || {})
|
106
|
+
end
|
107
|
+
|
108
|
+
end.tap { |mod| include(mod) }
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Laundry
|
2
|
+
module PaymentsGateway
|
3
|
+
|
4
|
+
class AccountDriver < MerchantAuthenticatableDriver
|
5
|
+
|
6
|
+
attr_accessor :client
|
7
|
+
def initialize(client, merchant)
|
8
|
+
super merchant
|
9
|
+
self.client = client
|
10
|
+
end
|
11
|
+
|
12
|
+
def client_driver
|
13
|
+
@client_driver ||= ClientDriver.new(self.merchant)
|
14
|
+
end
|
15
|
+
|
16
|
+
def find(payment_method_id)
|
17
|
+
r = client_driver.get_payment_method({'ClientID' => self.client.id, 'PaymentMethodID' => payment_method_id}) do
|
18
|
+
http.headers["SOAPAction"] = 'https://ws.paymentsgateway.net/v1/IClientService/getPaymentMethod'
|
19
|
+
end
|
20
|
+
Account.new(r, self.merchant)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Returns the payment method id
|
24
|
+
def create!(options = {})
|
25
|
+
options = {merchant_id: self.merchant.id, client_id: self.client.id, payment_method_id: 0}.merge(options)
|
26
|
+
options = AccountDriver.uglify_hash(options)
|
27
|
+
r = client_driver.create_payment_method({'payment' => options}) do
|
28
|
+
http.headers["SOAPAction"] = 'https://ws.paymentsgateway.net/v1/IClientService/createPaymentMethod'
|
29
|
+
end
|
30
|
+
r[:create_payment_method_response][:create_payment_method_result]
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.prettifiable_fields
|
34
|
+
['MerchantID',
|
35
|
+
'ClientID',
|
36
|
+
'PaymentMethodID',
|
37
|
+
'AcctHolderName',
|
38
|
+
'EcAccountNumber',
|
39
|
+
'EcAccountTRN',
|
40
|
+
'EcAccountType',
|
41
|
+
'Note',
|
42
|
+
'IsDefault']
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module Laundry
|
2
|
+
module PaymentsGateway
|
3
|
+
|
4
|
+
class ClientDriver < MerchantAuthenticatableDriver
|
5
|
+
|
6
|
+
# Setup WSDL
|
7
|
+
if Laundry.sandboxed?
|
8
|
+
document "https://sandbox.paymentsgateway.net/WS/Client.wsdl"
|
9
|
+
else
|
10
|
+
document "https://ws.paymentsgateway.net/Service/v1/Client.wsdl"
|
11
|
+
end
|
12
|
+
|
13
|
+
actions "createClient", "getClient", "getPaymentMethod", "createPaymentMethod"
|
14
|
+
|
15
|
+
def find(id)
|
16
|
+
r = get_client({'ClientID' => id}) do
|
17
|
+
http.headers["SOAPAction"] = 'https://ws.paymentsgateway.net/v1/IClientService/getClient'
|
18
|
+
end
|
19
|
+
Client.new(r, self.merchant)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Creates a client and returns the newly created client id.
|
23
|
+
def create!(options = {})
|
24
|
+
r = create_client({'client' => ClientDriver.default_hash.merge(options).merge({'MerchantID' => self.merchant.id, 'ClientID' => 0, 'Status' => 'Active'})} ) do
|
25
|
+
http.headers["SOAPAction"] = 'https://ws.paymentsgateway.net/v1/IClientService/createClient'
|
26
|
+
end
|
27
|
+
r[:create_client_response][:create_client_result]
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def self.default_fields
|
33
|
+
['MerchantID',
|
34
|
+
'ClientID',
|
35
|
+
'FirstName',
|
36
|
+
'LastName',
|
37
|
+
'CompanyName',
|
38
|
+
'Address1',
|
39
|
+
'Address2',
|
40
|
+
'City',
|
41
|
+
'State',
|
42
|
+
'PostalCode',
|
43
|
+
'CountryCode',
|
44
|
+
'PhoneNumber',
|
45
|
+
'FaxNumber',
|
46
|
+
'EmailAddress',
|
47
|
+
'ShiptoFirstName',
|
48
|
+
'ShiptoLastName',
|
49
|
+
'ShiptoCompanyName',
|
50
|
+
'ShiptoAddress1',
|
51
|
+
'ShiptoAddress2',
|
52
|
+
'ShiptoCity',
|
53
|
+
'ShiptoState',
|
54
|
+
'ShiptoPostalCode',
|
55
|
+
'ShiptoCountryCode',
|
56
|
+
'ShiptoPhoneNumber',
|
57
|
+
'ShiptoFaxNumber',
|
58
|
+
'ConsumerID',
|
59
|
+
'Status']
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.default_hash
|
63
|
+
h = {}
|
64
|
+
self.default_fields.each do |f|
|
65
|
+
h[f] = ""
|
66
|
+
end
|
67
|
+
h
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Laundry
|
2
|
+
module PaymentsGateway
|
3
|
+
|
4
|
+
class MerchantAuthenticatableDriver
|
5
|
+
extend Laundry::SOAPModel
|
6
|
+
|
7
|
+
attr_accessor :merchant
|
8
|
+
|
9
|
+
def initialize(merchant)
|
10
|
+
# Save the merchant.
|
11
|
+
self.merchant = merchant
|
12
|
+
|
13
|
+
# Log in via the merchant's login credentials.
|
14
|
+
default_body self.merchant.login_credentials.merge("MerchantID" => self.merchant.id)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.prettifiable_fields
|
18
|
+
[]
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.uglify_hash(hash)
|
22
|
+
translation = {}
|
23
|
+
self.prettifiable_fields.each do |f|
|
24
|
+
translation[f.snakecase.to_sym] = f
|
25
|
+
end
|
26
|
+
ugly_hash = {}
|
27
|
+
hash.each do |k, v|
|
28
|
+
if translation.has_key?(k)
|
29
|
+
ugly_hash[translation[k]] = v
|
30
|
+
else
|
31
|
+
ugly_hash[k] = v
|
32
|
+
end
|
33
|
+
end
|
34
|
+
ugly_hash
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Laundry
|
2
|
+
module PaymentsGateway
|
3
|
+
|
4
|
+
class SocketDriver < MerchantAuthenticatableDriver
|
5
|
+
|
6
|
+
# Setup WSDL
|
7
|
+
if Laundry.sandboxed?
|
8
|
+
document "https://ws.paymentsgateway.net/pgtest/paymentsgateway.asmx?WSDL"
|
9
|
+
else
|
10
|
+
document "https://ws.paymentsgateway.net/pg/paymentsgateway.asmx?WSDL"
|
11
|
+
end
|
12
|
+
|
13
|
+
actions "ExecuteSocketQuery"
|
14
|
+
|
15
|
+
def exec(options = {})
|
16
|
+
execute_socket_query(options) do
|
17
|
+
http.headers["SOAPAction"] = "http://paymentsgateway.achdirect.com/ExecuteSocketQuery"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Laundry
|
2
|
+
module PaymentsGateway
|
3
|
+
|
4
|
+
class TransactionDriver < MerchantAuthenticatableDriver
|
5
|
+
|
6
|
+
# Setup WSDL
|
7
|
+
if Laundry.sandboxed?
|
8
|
+
document 'https://sandbox.paymentsgateway.net/WS/Transaction.wsdl'
|
9
|
+
else
|
10
|
+
document 'https://ws.paymentsgateway.net/Service/v1/Transaction.wsdl'
|
11
|
+
end
|
12
|
+
|
13
|
+
actions "getTransaction"
|
14
|
+
|
15
|
+
def find(client_id, transaction_id)
|
16
|
+
r = get_transaction({'ClientID' => client_id, 'TransactionID' => transaction_id}) do
|
17
|
+
http.headers["SOAPAction"] = "https://ws.paymentsgateway.net/v1/ITransactionService/getTransaction"
|
18
|
+
end
|
19
|
+
Transaction.new(r, self.merchant)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Laundry
|
2
|
+
module PaymentsGateway
|
3
|
+
|
4
|
+
class Account < ResponseModel
|
5
|
+
|
6
|
+
def record
|
7
|
+
response[:get_payment_method_response][:get_payment_method_result][:payment_method]
|
8
|
+
end
|
9
|
+
|
10
|
+
# EFT TRANSACTION_CODES
|
11
|
+
EFT_SALE = 20
|
12
|
+
EFT_AUTH_ONLY = 21
|
13
|
+
EFT_CAPTURE = 22
|
14
|
+
EFT_CREDIT = 23
|
15
|
+
EFT_VOID = 24
|
16
|
+
EFT_FORCE = 25
|
17
|
+
EFT_VERIFY_ONLY = 26
|
18
|
+
|
19
|
+
def debit_cents(cents, *args)
|
20
|
+
debit_dollars(dollarize(cents), *args)
|
21
|
+
end
|
22
|
+
|
23
|
+
def credit_cents(cents, *args)
|
24
|
+
credit_dollars(dollarize(cents), *args)
|
25
|
+
end
|
26
|
+
|
27
|
+
def debit_dollars(dollars, *args)
|
28
|
+
perform_transaction(dollars, EFT_SALE, *args)
|
29
|
+
end
|
30
|
+
|
31
|
+
def credit_dollars(dollars, *args)
|
32
|
+
perform_transaction(dollars, EFT_CREDIT, *args)
|
33
|
+
end
|
34
|
+
|
35
|
+
def perform_transaction(dollars, type, options = {})
|
36
|
+
options = {
|
37
|
+
'pg_merchant_id' => self.merchant.id,
|
38
|
+
'pg_password' => self.merchant.transaction_password,
|
39
|
+
'pg_total_amount' => dollars,
|
40
|
+
'pg_client_id' => self.client_id,
|
41
|
+
'pg_payment_method_id' => self.id,
|
42
|
+
'pg_transaction_type' => type
|
43
|
+
}.merge(options)
|
44
|
+
r = self.merchant.socket_driver.exec(options)
|
45
|
+
TransactionResponse.new(r, self.merchant)
|
46
|
+
end
|
47
|
+
|
48
|
+
def id
|
49
|
+
payment_method_id
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def dollarize(cents)
|
55
|
+
cents.to_f / 100.0
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Laundry
|
2
|
+
module PaymentsGateway
|
3
|
+
|
4
|
+
class Client < ResponseModel
|
5
|
+
|
6
|
+
def record
|
7
|
+
response[:get_client_response][:get_client_result][:client_record]
|
8
|
+
end
|
9
|
+
|
10
|
+
def id
|
11
|
+
client_id
|
12
|
+
end
|
13
|
+
|
14
|
+
def accounts_driver
|
15
|
+
AccountDriver.new(self, self.merchant)
|
16
|
+
end
|
17
|
+
alias_method :accounts, :accounts_driver
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Laundry
|
2
|
+
module PaymentsGateway
|
3
|
+
|
4
|
+
class Merchant
|
5
|
+
extend Laundry::SOAPModel
|
6
|
+
|
7
|
+
# Setup WSDL
|
8
|
+
if Laundry.sandboxed?
|
9
|
+
document "https://sandbox.paymentsgateway.net/WS/Merchant.wsdl"
|
10
|
+
else
|
11
|
+
document "https://ws.paymentsgateway.net/Service/v1/Merchant.wsdl"
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.default_merchant(options = nil)
|
15
|
+
@@default_merchant = Merchant.new(options) if options
|
16
|
+
@@default_merchant
|
17
|
+
end
|
18
|
+
|
19
|
+
attr_accessor :id, :api_login_id, :api_password, :transaction_password
|
20
|
+
|
21
|
+
def initialize(options = {})
|
22
|
+
|
23
|
+
self.id = options[:id]
|
24
|
+
self.api_login_id = options[:api_login_id]
|
25
|
+
self.api_password = options[:api_password]
|
26
|
+
self.transaction_password = options[:transaction_password]
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
def client_driver
|
31
|
+
@client_driver ||= ClientDriver.new(self)
|
32
|
+
end
|
33
|
+
alias_method :clients, :client_driver
|
34
|
+
|
35
|
+
def transaction_driver
|
36
|
+
@transaction_driver ||= TransactionDriver.new(self)
|
37
|
+
end
|
38
|
+
alias_method :transactions, :transaction_driver
|
39
|
+
|
40
|
+
def socket_driver
|
41
|
+
@socket_driver ||= SocketDriver.new(self)
|
42
|
+
end
|
43
|
+
|
44
|
+
def login_credentials
|
45
|
+
# Time diff from 1/1/0001 00:00:00 to 1/1/1970 00:00:00
|
46
|
+
utc_time = (Time.now.to_i + 62135596800).to_s + '0000000'
|
47
|
+
ts_hash = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new('md5'), self.api_password, "#{self.api_login_id}|#{utc_time}")
|
48
|
+
{'ticket' => {'APILoginID' => self.api_login_id, 'TSHash' => ts_hash, 'UTCTime' => utc_time}}
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Laundry
|
2
|
+
module PaymentsGateway
|
3
|
+
|
4
|
+
class ResponseModel
|
5
|
+
|
6
|
+
attr_accessor :response
|
7
|
+
attr_accessor :merchant
|
8
|
+
def initialize(response, merchant)
|
9
|
+
self.response = response
|
10
|
+
self.merchant = merchant
|
11
|
+
end
|
12
|
+
|
13
|
+
# Override please.
|
14
|
+
def record
|
15
|
+
response.try(:to_hash) || {}
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_hash
|
19
|
+
record
|
20
|
+
end
|
21
|
+
|
22
|
+
def method_missing(id, *args)
|
23
|
+
return record[id.to_sym] if record.has_key? id.to_sym
|
24
|
+
super
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Laundry
|
2
|
+
module PaymentsGateway
|
3
|
+
|
4
|
+
class Transaction < ResponseModel
|
5
|
+
|
6
|
+
def record
|
7
|
+
response[:get_transaction_response][:get_transaction_result]
|
8
|
+
end
|
9
|
+
|
10
|
+
def status
|
11
|
+
record[:response][:status].downcase
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Laundry
|
2
|
+
module PaymentsGateway
|
3
|
+
|
4
|
+
class TransactionResponse < ResponseModel
|
5
|
+
|
6
|
+
attr_accessor :response_record
|
7
|
+
|
8
|
+
def initialize(response, merchant)
|
9
|
+
super
|
10
|
+
parse
|
11
|
+
end
|
12
|
+
|
13
|
+
def record
|
14
|
+
self.response_record
|
15
|
+
end
|
16
|
+
|
17
|
+
def success?
|
18
|
+
pg_response_type == 'A'
|
19
|
+
end
|
20
|
+
|
21
|
+
def full_transaction
|
22
|
+
self.merchant.transactions.find pg_payment_method_id, pg_trace_number
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def parse
|
28
|
+
data = {}
|
29
|
+
res = self.response[:execute_socket_query_response][:execute_socket_query_result].split("\n")
|
30
|
+
res.each do |key_value_pair|
|
31
|
+
kv = key_value_pair.split('=')
|
32
|
+
if kv.size == 2
|
33
|
+
data[ kv[0].to_sym ] = kv[1]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
self.response_record = data
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "laundry/payments_gateway/models/response_model"
|
2
|
+
require "laundry/payments_gateway/models/client"
|
3
|
+
require "laundry/payments_gateway/models/account"
|
4
|
+
require "laundry/payments_gateway/models/merchant"
|
5
|
+
require "laundry/payments_gateway/models/transaction_response"
|
6
|
+
require "laundry/payments_gateway/models/transaction"
|
7
|
+
|
8
|
+
require "laundry/payments_gateway/drivers/merchant_authenticatable_driver"
|
9
|
+
require "laundry/payments_gateway/drivers/account_driver"
|
10
|
+
require "laundry/payments_gateway/drivers/client_driver"
|
11
|
+
require "laundry/payments_gateway/drivers/socket_driver"
|
12
|
+
require "laundry/payments_gateway/drivers/transaction_driver"
|
data/lib/laundry.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require "laundry/version"
|
2
|
+
require 'savon'
|
3
|
+
|
4
|
+
module Laundry
|
5
|
+
|
6
|
+
@@sandboxed = true
|
7
|
+
|
8
|
+
def self.sandboxed?
|
9
|
+
@@sandboxed
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.sandboxed=(yn)
|
13
|
+
@@sandboxed = yn
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
# Lib
|
19
|
+
require "laundry/lib/soap_model"
|
20
|
+
|
21
|
+
# Payments Gateway
|
22
|
+
require "laundry/payments_gateway/payments_gateway"
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: laundry
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Wil Gieseler
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: savon
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: A soapy interface to ACH Direct's PaymentsGateway.com service.
|
31
|
+
email:
|
32
|
+
- supapuerco@gmail.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- Gemfile
|
39
|
+
- LICENSE
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- laundry.gemspec
|
43
|
+
- lib/laundry.rb
|
44
|
+
- lib/laundry/lib/soap_model.rb
|
45
|
+
- lib/laundry/payments_gateway/drivers/account_driver.rb
|
46
|
+
- lib/laundry/payments_gateway/drivers/client_driver.rb
|
47
|
+
- lib/laundry/payments_gateway/drivers/merchant_authenticatable_driver.rb
|
48
|
+
- lib/laundry/payments_gateway/drivers/socket_driver.rb
|
49
|
+
- lib/laundry/payments_gateway/drivers/transaction_driver.rb
|
50
|
+
- lib/laundry/payments_gateway/models/account.rb
|
51
|
+
- lib/laundry/payments_gateway/models/client.rb
|
52
|
+
- lib/laundry/payments_gateway/models/merchant.rb
|
53
|
+
- lib/laundry/payments_gateway/models/response_model.rb
|
54
|
+
- lib/laundry/payments_gateway/models/transaction.rb
|
55
|
+
- lib/laundry/payments_gateway/models/transaction_response.rb
|
56
|
+
- lib/laundry/payments_gateway/payments_gateway.rb
|
57
|
+
- lib/laundry/version.rb
|
58
|
+
homepage: https://github.com/supapuerco/laundry
|
59
|
+
licenses: []
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
hash: 1235405825976968960
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
hash: 1235405825976968960
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 1.8.24
|
85
|
+
signing_key:
|
86
|
+
specification_version: 3
|
87
|
+
summary: A soapy interface to ACH Direct's PaymentsGateway.com service.
|
88
|
+
test_files: []
|