Class: QiwiPay::PaymentOperation

Inherits:
Object
  • Object
show all
Defined in:
lib/qiwi-pay/payment_operation.rb

Overview

General patment operation

Constant Summary collapse

ATTRIBUTES =
%i[
  txn_id
  merchant_site currency sign amount order_id
  email country city region address phone
  cf1 cf2 cf3 cf4 cf5
  product_name merchant_uid modifiers card_token order_expire
  callback_url success_url decline_url
  cheque merchant_cheque
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(credentials, params = {}) ⇒ PaymentOperation

Returns a new instance of PaymentOperation.



31
32
33
34
35
36
# File 'lib/qiwi-pay/payment_operation.rb', line 31

def initialize(credentials, params = {})
  params.each do |k, v|
    send("#{k}=", v) if in_params.include?(k.to_sym)
  end
  @credentials = credentials
end

Instance Attribute Details

#credentials=(value) ⇒ Object

Sets the attribute credentials

Parameters:

  • value

    the value to set the attribute credentials to.



29
30
31
# File 'lib/qiwi-pay/payment_operation.rb', line 29

def credentials=(value)
  @credentials = value
end

Class Method Details

.descriptionObject

Описание операции

Raises:

  • (NotImplementedError)


14
15
16
# File 'lib/qiwi-pay/payment_operation.rb', line 14

def self.description
  raise NotImplementedError
end

.opcodeObject

Код операции

Raises:

  • (NotImplementedError)


9
10
11
# File 'lib/qiwi-pay/payment_operation.rb', line 9

def self.opcode
  raise NotImplementedError
end

Instance Method Details

#amountString

Formatted amount

Returns:

  • (String)


48
49
50
51
# File 'lib/qiwi-pay/payment_operation.rb', line 48

def amount
  return unless @amount
  format '%.2f', @amount
end

#callback_url=(url) ⇒ Object

Raises:

  • (ArgumentError)


53
54
55
56
# File 'lib/qiwi-pay/payment_operation.rb', line 53

def callback_url=(url)
  raise ArgumentError, 'Use https URI as callback_url' unless url.start_with?('https://')
  @callback_url = url
end

#descriptionObject



42
43
44
# File 'lib/qiwi-pay/payment_operation.rb', line 42

def description
  self.class.description
end

#opcodeObject



38
39
40
# File 'lib/qiwi-pay/payment_operation.rb', line 38

def opcode
  self.class.opcode
end

#order_expire=(time) ⇒ Object

Examples:

op.order_expire = Time.now + 3600
op.order_expire = 15.minutes.since

Parameters:

  • time (String;Time)

    time to expire order at Must be a string in format YYYY-MM-DDThh:mm:ss±hh:mm or anything responding to strftime message



64
65
66
67
68
69
70
71
# File 'lib/qiwi-pay/payment_operation.rb', line 64

def order_expire=(time)
  @order_expire =
    if time.respond_to? :strftime
      time.strftime('%FT%T%:z')
    else
      time.to_s
    end
end