Sha256: fb3bcaa0da9de9d3888c2286822c939c70bd2617c6bfc7a82cbf14ba4cc3dbca

Contents?: true

Size: 795 Bytes

Versions: 11

Compression:

Stored size: 795 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)
    @_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

11 entries across 11 versions & 1 rubygems

Version Path
paykassa-0.1.10 lib/paykassa/order.rb
paykassa-0.1.9 lib/paykassa/order.rb
paykassa-0.1.8 lib/paykassa/order.rb
paykassa-0.1.7 lib/paykassa/order.rb
paykassa-0.1.6 lib/paykassa/order.rb
paykassa-0.1.5 lib/paykassa/order.rb
paykassa-0.1.4 lib/paykassa/order.rb
paykassa-0.1.3 lib/paykassa/order.rb
paykassa-0.1.2 lib/paykassa/order.rb
paykassa-0.1.1 lib/paykassa/order.rb
paykassa-0.1.0 lib/paykassa/order.rb