Sha256: 9c196a8233597767b6c8926a4177adcd5e6041cbb22eb13199bc366027723993

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

module Spree
  class PaymentMethod::Liqpay < PaymentMethod
    preference :server, :string, default: 'https://www.liqpay.com'
    preference :public_key, :string, default: ''
    preference :private_key, :string, default: ''
    preference :order_description, :string, default: -> {Spree::Store.current.name}
    preference :test_mode, :boolean, default: true

    def provider_class
      ActiveMerchant::Billing::Liqpay
    end

    def provider
      @provider ||= provider_class.new preferred_public_key, preferred_private_key
    end

    def source_required?
      false
    end

    def checkout_url
      "#{preferred_server}/api/checkout"
    end

    def cnb_form_fields order, result_url, server_url
      provider.cnb_form_fields amount: order.total,
                               currency: order.currency,
                               description: preferred_order_description,
                               order_id: order.id,
                               result_url: result_url,
                               server_url: server_url,
                               sandbox: preferred_test_mode ? 1 : 0
    end

    def check_signature data, signature
      provider.check_signature data, signature
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spree_liqpay-0.1.0 app/models/spree/payment_method/liqpay.rb