Sha256: 28dcdb535de54d4c099ee62167d42f27f61274b5f6a048e58d5fb0779434f4c9

Contents?: true

Size: 815 Bytes

Versions: 1

Compression:

Stored size: 815 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 check_response(params = {})
      WirecardCheckoutPage::CheckedResponse.new(
        params.merge(authentication_params)
      )
    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.1 lib/wirecard_checkout_page/gateway.rb