Class: Laundry::PaymentsGateway::AccountDriver
- Inherits:
-
MerchantAuthenticatableDriver
- Object
- MerchantAuthenticatableDriver
- Laundry::PaymentsGateway::AccountDriver
- Defined in:
- lib/laundry/payments_gateway/drivers/account_driver.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Attributes inherited from MerchantAuthenticatableDriver
Class Method Summary collapse
Instance Method Summary collapse
- #client_driver ⇒ Object
-
#create!(options = {}) ⇒ Object
Returns the payment method id.
- #find(payment_method_id) ⇒ Object
-
#initialize(client, merchant) ⇒ AccountDriver
constructor
A new instance of AccountDriver.
Methods inherited from MerchantAuthenticatableDriver
#default_body, #setup_client!, uglify_hash
Methods included from SOAPModel
Constructor Details
#initialize(client, merchant) ⇒ AccountDriver
Returns a new instance of AccountDriver.
7 8 9 10 |
# File 'lib/laundry/payments_gateway/drivers/account_driver.rb', line 7 def initialize(client, merchant) super merchant self.client = client end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
6 7 8 |
# File 'lib/laundry/payments_gateway/drivers/account_driver.rb', line 6 def client @client end |
Class Method Details
.prettifiable_fields ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/laundry/payments_gateway/drivers/account_driver.rb', line 34 def self.prettifiable_fields ['MerchantID', 'ClientID', 'PaymentMethodID', 'AcctHolderName', 'EcAccountNumber', 'EcAccountTRN', 'EcAccountType', 'Note', 'IsDefault'] end |
Instance Method Details
#client_driver ⇒ Object
12 13 14 |
# File 'lib/laundry/payments_gateway/drivers/account_driver.rb', line 12 def client_driver @client_driver ||= ClientDriver.new(self.merchant) end |
#create!(options = {}) ⇒ Object
Returns the payment method id
24 25 26 27 28 29 30 31 32 |
# File 'lib/laundry/payments_gateway/drivers/account_driver.rb', line 24 def create!( = {}) raise ArgumentError, "Tried to create an account on an invalid client." if self.client.nil? || self.client.blank? = {merchant_id: self.merchant.id, client_id: self.client.id, payment_method_id: 0}.merge() = AccountDriver.uglify_hash() r = client_driver.create_payment_method({'payment' => }) do http.headers["SOAPAction"] = 'https://ws.paymentsgateway.net/v1/IClientService/createPaymentMethod' end r[:create_payment_method_response][:create_payment_method_result] end |
#find(payment_method_id) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/laundry/payments_gateway/drivers/account_driver.rb', line 16 def find(payment_method_id) r = client_driver.get_payment_method({'ClientID' => self.client.id, 'PaymentMethodID' => payment_method_id}) do http.headers["SOAPAction"] = 'https://ws.paymentsgateway.net/v1/IClientService/getPaymentMethod' end Account.from_response(r, self.merchant) end |