Sha256: abe8413635be31eef3cfc17f86a3c4a960466d45fb22cab521dca99cee0a20cb

Contents?: true

Size: 808 Bytes

Versions: 1

Compression:

Stored size: 808 Bytes

Contents

module WirecardCheckoutPage
  class Gateway
    DEFAULT_INIT_URL = 'https://checkout.wirecard.com/page/init.php'

    attr_accessor :customerId, :secret, :init_url

    def initialize(customerId: nil, secret: nil, init_url: nil)
      @customerId = customerId
      @secret     = secret
      @init_url   = init_url || DEFAULT_INIT_URL
    end

    def init(params = {})
      checksum = WirecardCheckoutPage::RequestChecksum.new(params.merge(authentication_params))
      InitResponse.new Typhoeus.post(init_url, body: checksum.request_parameters)
    end

    def response_valid?(params = {})
      WirecardCheckoutPage::ResponseChecksum.new(params.merge(authentication_params)).valid?
    end

    private

    def authentication_params
      { secret: secret, customerId: customerId }
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wirecard_checkout_page-0.0.0 lib/wirecard_checkout_page/gateway.rb