Class: MonoMerchant::Wallet::Payment

Inherits:
ApiRequest show all
Defined in:
lib/mono-merchant/wallet/payment.rb

Overview

Create payment for card token todo DRY it with Invoice::Create

Constant Summary

Constants inherited from ApiRequest

ApiRequest::API_URL, ApiRequest::DEFAULT_CURRENCY

Instance Attribute Summary collapse

Attributes inherited from ApiRequest

#errors, #type

Instance Method Summary collapse

Methods inherited from ApiRequest

#url

Constructor Details

#initialize(card_token, amount, currency = DEFAULT_CURRENCY, by_client: false, items: [], reference: nil, redirect_url: nil, webhook_url: nil, email: nil, destination: nil, comment: nil) ⇒ Payment

Returns a new instance of Payment.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/mono-merchant/wallet/payment.rb', line 10

def initialize(card_token, amount, currency = DEFAULT_CURRENCY, by_client: false, items: [], reference: nil, redirect_url: nil, webhook_url: nil, email: nil, destination: nil, comment: nil)
  @card_token = card_token
  @amount = convert_to_cents(amount)
  @destination = destination
  @reference = reference
  @comment = comment
  @customer_emails = [email] if email
  @redirect_url = redirect_url
  @webhook_url = webhook_url
  @currency = Money::Currency.new(currency)
  # todo: append barcode, uktzed, tax, discounts etc.
  @items = items.map { |i| Invoice::Item.new(i).to_hash.presence }
  @initiation_kind = by_client ? 'client' : 'merchant'
  super()
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class MonoMerchant::ApiRequest

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



8
9
10
# File 'lib/mono-merchant/wallet/payment.rb', line 8

def amount
  @amount
end

#card_tokenObject (readonly)

Returns the value of attribute card_token.



8
9
10
# File 'lib/mono-merchant/wallet/payment.rb', line 8

def card_token
  @card_token
end

#commentObject (readonly)

Returns the value of attribute comment.



8
9
10
# File 'lib/mono-merchant/wallet/payment.rb', line 8

def comment
  @comment
end

#currencyObject (readonly)

Returns the value of attribute currency.



8
9
10
# File 'lib/mono-merchant/wallet/payment.rb', line 8

def currency
  @currency
end

#customer_emailsObject (readonly)

Returns the value of attribute customer_emails.



8
9
10
# File 'lib/mono-merchant/wallet/payment.rb', line 8

def customer_emails
  @customer_emails
end

#destinationObject (readonly)

Returns the value of attribute destination.



8
9
10
# File 'lib/mono-merchant/wallet/payment.rb', line 8

def destination
  @destination
end

#initiation_kindObject (readonly)

Returns the value of attribute initiation_kind.



8
9
10
# File 'lib/mono-merchant/wallet/payment.rb', line 8

def initiation_kind
  @initiation_kind
end

#itemsObject (readonly)

Returns the value of attribute items.



8
9
10
# File 'lib/mono-merchant/wallet/payment.rb', line 8

def items
  @items
end

#redirect_urlObject (readonly)

Returns the value of attribute redirect_url.



8
9
10
# File 'lib/mono-merchant/wallet/payment.rb', line 8

def redirect_url
  @redirect_url
end

#referenceObject (readonly)

Returns the value of attribute reference.



8
9
10
# File 'lib/mono-merchant/wallet/payment.rb', line 8

def reference
  @reference
end

#webhook_urlObject (readonly)

Returns the value of attribute webhook_url.



8
9
10
# File 'lib/mono-merchant/wallet/payment.rb', line 8

def webhook_url
  @webhook_url
end