Sha256: 4b9f13c05bd20559ec1f68f91917acf62641be1a90c22487d495ba8bfa3b9991

Contents?: true

Size: 1.01 KB

Versions: 7

Compression:

Stored size: 1.01 KB

Contents

module Pay
  module PaddleBilling
    class PaymentMethod
      attr_reader :pay_payment_method

      delegate :customer, :processor_id, to: :pay_payment_method

      def self.sync(pay_customer:, attributes:)
        details = attributes.method_details
        attrs = {
          type: details.type.downcase
        }

        case details.type.downcase
        when "card"
          attrs[:brand] = details.card.type
          attrs[:last4] = details.card.last4
          attrs[:exp_month] = details.card.expiry_month
          attrs[:exp_year] = details.card.expiry_year
        end

        payment_method = pay_customer.payment_methods.find_or_initialize_by(processor_id: attributes.stored_payment_method_id)
        payment_method.update!(attrs)
        payment_method
      end

      def initialize(pay_payment_method)
        @pay_payment_method = pay_payment_method
      end

      # Sets payment method as default
      def make_default!
      end

      # Remove payment method
      def detach
      end
    end
  end
end

Version data entries

7 entries across 5 versions & 1 rubygems

Version Path
pay-7.3.0 lib/pay/lemon_squeezy/payment_method.rb
pay-7.2.1 lib/pay/lemon_squeezy/payment_method.rb
pay-7.1.1 lib/pay/paddle_billing/payment_method.rb
pay-7.1.0 lib/pay/paddle_billing/payment_method.rb
pay-7.1.0 lib/pay/lemon_squeezy/payment_method.rb
pay-7.0.0 lib/pay/lemon_squeezy/payment_method.rb
pay-7.0.0 lib/pay/paddle_billing/payment_method.rb