Sha256: a680654e18d2d7a7a1bbd4230d2f4ff840b6bc7b5f57c3aaf6b625e0913416cb
Contents?: true
Size: 1.68 KB
Versions: 2
Compression:
Stored size: 1.68 KB
Contents
module Workarea module Forter class Payment attr_reader :payment, :options def initialize(payment, options = {}) @payment = payment @options = options end # @return Array def to_a payment_tenders.map do | tender| tender_hash = build_tender_details(tender) billing_details_hash = { billingDetails: { personalDetails: { firstName: address.first_name, lastName: address.last_name }, address: forter_address, phone: [{ phone: address.phone_number.to_s }] }, amount: { amountUSD: tender.amount.to_s } } tender_hash.merge!(billing_details_hash) end end private def build_tender_details(tender) case tender.slug when :credit_card Tender::CreditCard.new(tender).to_h when :gift_card Tender::GiftCard.new(tender).to_h when :store_credit Tender::StoreCredit.new(tender).to_h when :paypal Tender::Paypal.new(tender).to_h else Tender::General.new(tender).to_h end end def address payment.address end def forter_address { address1: address.street, address2: address.street_2, city: address.city, country: address.country.alpha2, zip: address.postal_code, region: address.region } end def payment_tenders payment.tenders.reject { |t| t.transactions.empty? } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
workarea-forter-1.3.2 | app/services/workarea/forter/payment.rb |
workarea-forter-1.3.1 | app/services/workarea/forter/payment.rb |