Sha256: 1fa7f9e4bf78bc5f7f05ea996118404c4aba189a8027f223fec516cf6aba2c84

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

require File.dirname(__FILE__) + '/modern_payments_cim'

module MerbMerchant #:nodoc:
  module Billing #:nodoc:
    class ModernPaymentsGateway < Gateway
      self.supported_countries = ModernPaymentsCimGateway.supported_countries
      self.supported_cardtypes = ModernPaymentsCimGateway.supported_cardtypes
      self.homepage_url = ModernPaymentsCimGateway.homepage_url
      self.display_name = ModernPaymentsCimGateway.display_name
      
      def initialize(options = {})
        requires!(options, :login, :password)
        @options = options
        super
      end
      
      def purchase(money, credit_card, options = {})
        customer_response = cim.create_customer(options)
        return customer_response unless customer_response.success?
        
        customer_id = customer_response.params["create_customer_result"]
        
        card_response = cim.modify_customer_credit_card(customer_id, credit_card)
        return card_response unless card_response.success?
        
        cim.authorize_credit_card_payment(customer_id, money)
      end
      
      private
      def cim
        @cim ||= ModernPaymentsCimGateway.new(@options)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
merb_merchant-1.4.1 lib/merb_merchant/billing/gateways/modern_payments.rb