Sha256: c9f4e01cc54ca64dfcdb6933e252f9195377f3572118958fe43d2804357e4e48

Contents?: true

Size: 830 Bytes

Versions: 5

Compression:

Stored size: 830 Bytes

Contents

require 'net/http'

class PaykassaOrder
  BASE_SCI_URI = URI('https://paykassa.pro/sci/0.3/index.php')


  # def initialize(auth)
  # where auth has keys: sci_id, sci_key, domain
  def initialize(auth, logger = nil)
    @logger = logger
    @_auth = auth
  end

  # Request for create order
  def create_order(amount:, currency:, order_id:, comment:, system:)
    make_request(
      func: :sci_create_order,
      amount: amount,
      currency: currency,
      order_id: order_id,
      comment: comment,
      system: system
    )
  end

  # Check order status
  def confirm_order(private_hash)
    make_request(func: :sci_confirm_order, private_hash: private_hash)
  end

  private

  def make_request(data)
    res = Net::HTTP.post_form(BASE_SCI_URI, data.merge(@_auth))
    JSON.parse(res.body).deep_symbolize_keys
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
paykassa-0.1.15 lib/paykassa/order.rb
paykassa-0.1.14 lib/paykassa/order.rb
paykassa-0.1.13 lib/paykassa/order.rb
paykassa-0.1.12 lib/paykassa/order.rb
paykassa-0.1.11 lib/paykassa/order.rb