Sha256: 087844df65f2c150345f93d15d1824b5ddb037952e645f3f469f21afd9d520b3

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

module Paysure
    class GetToken < Paysure::RequestBase
      include Validatable
      attr_accessor :merchant_id,:callback_url, :amount,:data_request
      attr_reader   :response,:config
      validates_presence_of :amount
      validates_length_of :amount, :within => 1000..500000000
      validates_format_of :amount, :with => /^\d*$/, :if => Proc.new { !amount.nil? }
      
      def initialize(args = {})
        super
        @ACTION_NAME = [:get_token,'json'].join('.').freeze
        @amount      = args.fetch(:amount)
        @callback_url = args.fetch(:callback_url,Paysure.configuration.callback_url)
        @merchant_id = args.fetch(:merchant_id,Paysure.configuration.merchant_id)
        @response    = ResponseGetToken.new
      end
      
      
      def call
          connection = Faraday.new(url: "#{@API_URL}/transaction/") do |faraday|
            faraday.adapter Faraday.default_adapter
            faraday.response :json
          end
            response = connection.get(@ACTION_NAME, callback_url: @callback_url, amount: @amount,merchant_id: @merchant_id)
            @response.validate(response.body)
      end
      
    end
  
  end 
  

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
paysure-0.1.9.1 lib/paysure/requests/get_token.rb