Sha256: b703026a7b99e34b163af272c4d90778e08d063e0a18086500f1ff879eade910

Contents?: true

Size: 1.3 KB

Versions: 14

Compression:

Stored size: 1.3 KB

Contents

module RockRMS
  class Client
    module PaymentDetail
      def list_payment_details(options = {})
        res = get(payment_detail_path, options)
        Response::PaymentDetail.format(res)
      end

      def create_payment_detail(payment_type:, foreign_key: nil, card_type: nil, last_4: nil)
        options = {
          'CurrencyTypeValueId' => cast_payment_type(payment_type),
          'CreditCardTypeValueId' => cast_card_type(card_type),
          'ForeignKey' => foreign_key
        }
        options['AccountNumberMasked'] = "************#{last_4}" if last_4

        post(payment_detail_path, options)
      end

      def delete_payment_detail(id)
        delete(payment_detail_path(id))
      end

      private

      def cast_payment_type(payment_type)
        case payment_type
        when 'card'
          156
        when 'bank account', 'ach'
          157
        end
      end

      def cast_card_type(card_type)
        case card_type
        when 'visa'
          7
        when 'mastercard'
          8
        when 'amex'
          159
        when 'discover'
          160
        when 'diner'
          161
        when 'jcb'
          162
        end
      end

      def payment_detail_path(id = nil)
        id ? "FinancialPaymentDetails/#{id}" : 'FinancialPaymentDetails'
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rock_rms-4.12.1 lib/rock_rms/resources/payment_detail.rb
rock_rms-4.11.0 lib/rock_rms/resources/payment_detail.rb
rock_rms-4.10.0 lib/rock_rms/resources/payment_detail.rb
rock_rms-4.9.0 lib/rock_rms/resources/payment_detail.rb
rock_rms-4.8.0 lib/rock_rms/resources/payment_detail.rb
rock_rms-4.7.0 lib/rock_rms/resources/payment_detail.rb
rock_rms-4.6.0 lib/rock_rms/resources/payment_detail.rb
rock_rms-4.5.0 lib/rock_rms/resources/payment_detail.rb
rock_rms-4.4.0 lib/rock_rms/resources/payment_detail.rb
rock_rms-4.3.0 lib/rock_rms/resources/payment_detail.rb
rock_rms-4.2.3 lib/rock_rms/resources/payment_detail.rb
rock_rms-4.2.2 lib/rock_rms/resources/payment_detail.rb
rock_rms-4.2.1 lib/rock_rms/resources/payment_detail.rb
rock_rms-4.2.0 lib/rock_rms/resources/payment_detail.rb