Sha256: cc137f6055fdb8f1adb462c1a1fd5e72aa1d0db1cb1b220de90a11e8690f9b86

Contents?: true

Size: 1.87 KB

Versions: 22

Compression:

Stored size: 1.87 KB

Contents

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    class OrbitalSoftDescriptors < Model
      PHONE_FORMAT_1 = /\A\d{3}-\d{3}-\d{4}\z/
      PHONE_FORMAT_2 = /\A\d{3}-\w{7}\z/

      # ==== Tampa PNS Soft Descriptors
      # The support for Soft Descriptors via the PNS Host is only for customers processing through Chase
      # Paymentech Canada.

      # Unlike Salem, the only value that gets passed on the cardholder statement is the Merchant Name field.
      # And for these customers, it is a maximum of 25 bytes of data.
      #
      # All other Soft Descriptor fields can optionally be sent, but will not be submitted to the settlement host
      # and will not display on the cardholder statement.

      attr_accessor :merchant_name, :product_description, :merchant_city, :merchant_phone, :merchant_url, :merchant_email

      def initialize(options = {})
        self.merchant_name = options[:merchant_name]
        self.merchant_city = options[:merchant_city]
        self.merchant_phone = options[:merchant_phone]
        self.merchant_url = options[:merchant_url]
        self.merchant_email = options[:merchant_email]
      end

      def validate
        errors = []

        errors << [:merchant_name, 'is required'] if self.merchant_name.blank?
        errors << [:merchant_name, 'is required to be 25 bytes or less'] if self.merchant_name.bytesize > 25

        if(!empty?(self.merchant_phone) && !self.merchant_phone.match(PHONE_FORMAT_1) && !self.merchant_phone.match(PHONE_FORMAT_2))
          errors << [:merchant_phone, 'is required to follow "NNN-NNN-NNNN" or "NNN-AAAAAAA" format']
        end

        [:merchant_email, :merchant_url].each do |attr|
          unless self.send(attr).blank?
            errors << [attr, 'is required to be 13 bytes or less'] if(self.send(attr).bytesize > 13)
          end
        end

        errors_hash(errors)
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
activemerchant-1.100.0 lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb
activemerchant-1.99.0 lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb
activemerchant-1.98.0 lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb
active_accountability_merchant-1.97.1 lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb
activemerchant-1.97.0 lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb
activemerchant-1.96.0 lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb
activemerchant-1.95.0 lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb
activemerchant-1.94.0 lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb
activemerchant-1.93.0 lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb
activemerchant-1.92.0 lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb
activemerchant-1.91.0 lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb
activemerchant-1.90.0 lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb
activemerchant-1.89.0 lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb
activemerchant-1.88.0 lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb
activemerchant-1.87.0 lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb
activemerchant-1.86.0 lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb
activemerchant-1.85.0 lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb
activemerchant-1.84.0 lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb
activemerchant-1.83.0 lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb
activemerchant-1.82.0 lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb