Class: FakePin::Charge

Inherits:
Object
  • Object
show all
Defined in:
lib/fake_pin/charge.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Charge

Returns a new instance of Charge.



7
8
9
# File 'lib/fake_pin/charge.rb', line 7

def initialize(params)
  @params = params
end

Class Method Details

.create(params) ⇒ Object



3
4
5
# File 'lib/fake_pin/charge.rb', line 3

def self.create(params)
  new(params).create
end

Instance Method Details

#createObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/fake_pin/charge.rb', line 11

def create
  @params.require(:amount, :description)
  currency = @params["currency"] || "AUD"

  { "token"                 => Token.generate('ch'),
    "success"               => true,
    "amount"                => @params['amount'],
    "description"           => @params['description'],
    "currency"              => currency,
    "ip_address"            => "203.192.1.172",
    "email"                 => @params['email'],
    "status_message"        => "Success!",
    "error_message"         => nil,
    "captured"              => true,
    "authorisation_expired" => false,
    "transfer"              => nil,
    "created_at"            => Time.now.to_s }
end