Class: Payzilla::Gateways::Beeline

Inherits:
Gateway
  • Object
show all
Defined in:
lib/payzilla/gateways/beeline.rb

Instance Attribute Summary

Attributes inherited from Gateway

#config, #logger, #revision_page_size

Instance Method Summary collapse

Methods inherited from Gateway

available_attachments, available_settings, available_switches, can_list_providers, #can_list_providers?, can_list_providers?, #initialize, register_attachments, register_settings, register_switches, require_payment_fields, required_payment_fields, requires_revision, requires_revision?, #requires_revision?, #revise

Constructor Details

This class inherits a constructor from Payzilla::Gateways::Gateway

Instance Method Details

#check(payment) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/payzilla/gateways/beeline.rb', line 12

def check(payment)
  begin
    result = request :create_payment,
      {
        :partnerId      => @config.setting_partner_id,
        :paymentPointId => @config.setting_payment_point_id,
        :money => "",
        :phone       => payment.,
        :amountAll => "",
        :attributes! => {
          :money => {
            :amount => payment.enrolled_amount,
            :code   => 'RUR'
          },
          :amountAll => {
            :amount => payment.paid_amount,
            :code => 'RUR'
          }
        }
      }, payment

    return retval(result.to_hash[:paymentResponse][:error][:error])
  rescue Errno::ECONNRESET
    return retval(-1000)
  end
end

#generate_revision(revision) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/payzilla/gateways/beeline.rb', line 66

def generate_revision(revision)
  return retval(-1001) if settings_miss?

  builder = []
  paginate_payments(revision.payments, builder) do |slice,buidler|
    generate_revision_page(slice, builder)
  end
  data = {
    :partnerId => @config.setting_partner_id,
    :paymentsList => builder,

    :attributes! => {
      :partnerId => { :xmlns => "http://payment.beepayxp.jetinfosoft.ru/PaymentTypes.xsd" },
      :paymentsList => { :xmlns => "http://payment.beepayxp.jetinfosoft.ru/PaymentTypes.xsd" }
    }
  }
  [:xml, data]
end

#pay(payment) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/payzilla/gateways/beeline.rb', line 39

def pay(payment)
  return retval(-1001) if settings_miss?

  begin
    result = request :immediate_payment,
      {
        :partnerId      => @config.setting_partner_id,
        :subagentId     => payment.subagent_id,
        :paymentPointId => @config.setting_payment_point_id,
        :money => "",
        :phone       => payment.,
        :discountCardNumber => payment.discount_card,

        :attributes! => {
          :money => {
            :amount => payment.enrolled_amount,
            :code   => 'RUR'
          }
        }
      }, payment

    return retval(result.to_hash[:paymentResponse][:error][:error])
  rescue Errno::ECONNRESET
    return retval(-1000)
  end
end

#send_revision(revision) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/payzilla/gateways/beeline.rb', line 85

def send_revision(revision)
  return retval(-1001) if settings_miss?
  opts = {
    :method => "reconciliation",
    :startTime => revision.date.to_date.to_datetime.strftime("%Y-%m-%dT%H:%M:%SZ%:z"),
    :endTime => DateTime.new(
                  revision.date.year,
                  revision.date.month,
                  revision.date.day,
                  23,
                  59,
                  59
                ).strftime("%Y-%m-%dT%H:%M:%SZ%:z")
  }
  revision = generate_revision(revision)[1]

  begin
    result = request :register_transfer, revision, opts
    return retval(result.to_hash[:reconciliationResponse][:error][:error])
  rescue Errno::ECONNRESET
    return retval(-1000)
  end
end