Class: QiwiPay::Cheque

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

Overview

Чек 54-ФЗ

Defined Under Namespace

Modules: TaxMode, Type, VAT

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Cheque

Returns a new instance of Cheque.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • seller_id (Integer)

    ИНН организации, для которой пробивается чек

  • cheque_type (Integer)

    Признак расчета (тэг 1054):

    1. Приход

    2. Возврат прихода

    3. Расход

    4. Возврат расхода

  • customer_contact (String)

    Телефон или электронный адрес покупателя (тэг 1008)

  • tax_system (Integer)

    Система налогообложения (тэг 1055): 0 – Общая, ОСН 1 – Упрощенная доход, УСН доход 2 – Упрощенная доход минус расход, УСН доход - расход 3 – Единый налог на вмененный доход, ЕНВД 4 – Единый сельскохозяйственный налог, ЕСН 5 – Патентная система налогообложения, Патент

  • positions (Array<Hash>)

    Массив товаров



68
69
70
# File 'lib/qiwi-pay/cheque.rb', line 68

def initialize(params)
  @json = JSON.fast_generate params
end

Instance Method Details

#encodeString

Returns Encoded cheque.

Returns:

  • (String)

    Encoded cheque



99
100
101
# File 'lib/qiwi-pay/cheque.rb', line 99

def encode
  Base64.strict_encode64(Zlib::Deflate.deflate(to_json))
end

#to_jsonString

Returns cheque as JSON.

Examples:

{
  "seller_id" : 3123011520,
  "cheque_type" : 1,
  "customer_contact" : "[email protected]",
  "tax_system" : 1,
  "positions" : [
    {
      "quantity" : 2,
      "price" : 322.94,
      "tax" : 4,
      "description" : "Товар/Услуга 1"
    },
    {
      "quantity" : 1,
      "price" : 500,
      "tax" : 4,
      "description" : "Товар/Услуга 2"
    }
  ]
}

Returns:

  • (String)

    cheque as JSON



94
95
96
# File 'lib/qiwi-pay/cheque.rb', line 94

def to_json
  @json
end