Sha256: 0fa89b0b56db4ad7da553172d5df7e000d75cd8b2a06fb5e6400c5331ff12ccf

Contents?: true

Size: 829 Bytes

Versions: 3

Compression:

Stored size: 829 Bytes

Contents

# frozen_string_literal: true

require 'active_model'

module SolidusPaypalBraintree
  class Transaction
    include ActiveModel::Model

    attr_accessor :nonce, :payment_method, :payment_type, :paypal_funding_source, :address, :email, :phone

    validates :nonce, presence: true
    validates :payment_method, presence: true
    validates :payment_type, presence: true
    validates :email, presence: true

    validate do
      unless payment_method.is_a? SolidusPaypalBraintree::Gateway
        errors.add(:payment_method, 'Must be braintree')
      end
      if address && !address.valid?
        address.errors.each do |error|
          errors.add(:address, error.full_message)
        end
      end
    end

    def address_attributes=(attributes)
      self.address = TransactionAddress.new attributes
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
solidus_paypal_braintree-1.2.0 app/models/solidus_paypal_braintree/transaction.rb
solidus_paypal_braintree-1.1.2 app/models/solidus_paypal_braintree/transaction.rb
solidus_paypal_braintree-1.1.1 app/models/solidus_paypal_braintree/transaction.rb