lib/paykassa.rb in paykassa-0.1.2 vs lib/paykassa.rb in paykassa-0.1.3

- old
+ new

@@ -3,11 +3,11 @@ require_relative "paykassa/version" require_relative "paykassa/order" module Paykassa class Error < StandardError; end class Paykassa - def initialize(domain, sci_id, sci_key, api_id = nil, api_key = nil, test) + def initialize(domain:, sci_id:, sci_key:, api_id: nil, api_key: nil, test:) @paykassa_order = PaykassaOrder.new({domain: domain, sci_id: sci_id, sci_key: sci_key}) if api_id.nil? @paykassa_pay = nil else @paykassa_pay = PaykassaPay.new( @@ -15,10 +15,11 @@ domain: domain, api_id: api_id, api_key: api_key, test: test } ) end end + def pay(amount: , shop: , currency: , system_name: , paid_commission: "shop", number:, tag:, priority:) raise "api_key not present!" if @paykassa_pay.nil? @paykassa_pay.pay({ amount: amount, shop: shop, @@ -28,31 +29,30 @@ number: number, tag: tag, priority: priority }) end + def balance(shop:) raise "api_key not present!" if @paykassa_pay.nil? @paykassa_pay.balance(shop: shop) end def rate(c_in, c_out) @paykassa_pay.currency_rate(c_in, c_out) end - def create_order(amount:, currency:, order_id:, system:, comment:) - create_order(amount, currency, order_id, system, comment) - end - def create_order(amount, currency, order_id, system, comment="from paykassa gem") + + def create_order(amount:, currency:, order_id:, system:, comment: "from paykassa gem") order = @paykassa_order.create_order( amount: amount, currency: currency, order_id: order_id, comment: comment, system: system ) raise StandardError.new(order[:message]) if order[:error] url = order[:data][:url] end - def confirm_order(hash) + def confirm_order(hash:) result = @paykassa_order.confirm_order(hash) raise StandardError.new(result[:message]) if result[:error] order_id = res[:data][:order_id] amount = res[:data][:amount] {order_id: order_id, amount: amount}