Sha256: 278efec75f600f38303feb583144d203f3efc05d3c65d4d7a91b77ab82855245

Contents?: true

Size: 1.53 KB

Versions: 4

Compression:

Stored size: 1.53 KB

Contents

require 'digest/md5'

module VaultedBilling
  module Gateways
    class Bogus
      include VaultedBilling::Gateway

      def initialize(options = {})
      end

      def add_customer(customer)
        respond_with(customer.to_vaulted_billing) { |c| c.vault_id = new_identifier }
      end

      def update_customer(customer)
        respond_with customer.to_vaulted_billing
      end

      def remove_customer(customer)
        respond_with customer.to_vaulted_billing
      end

      def add_customer_credit_card(customer, credit_card)
        respond_with(credit_card.to_vaulted_billing) { |c| c.vault_id = new_identifier }
      end

      def update_customer_credit_card(customer, credit_card)
        respond_with credit_card.to_vaulted_billing
      end

      def remove_customer_credit_card(customer, credit_card)
        respond_with credit_card.to_vaulted_billing
      end

      def authorize(customer, credit_card, amount)
        transaction_response
      end

      def void(transaction_id)
        transaction_response
      end

      def capture(transaction_id, amount)
        transaction_response
      end

      def refund(transaction_id, amount)
        transaction_response
      end


      private


      def new_identifier
        Digest::MD5.hexdigest("--#{Time.now.to_f}--#{rand(1_000_000)}--#{rand(1_000_000)}--")
      end

      def transaction_response
        respond_with VaultedBilling::Transaction.new({
          :id => new_identifier,
          :authcode => new_identifier[0..5]
        })
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vaulted_billing-0.0.10 lib/vaulted_billing/gateways/bogus.rb
vaulted_billing-0.0.9 lib/vaulted_billing/gateways/bogus.rb
vaulted_billing-0.0.8 lib/vaulted_billing/gateways/bogus.rb
vaulted_billing-0.0.7 lib/vaulted_billing/gateways/bogus.rb