Base Interface - app/services/payment_processors/base.rb
create_customer_profile, create_payment_token, authorize_payment, capture_authorization, refund_transaction, void_authorizationAuthorize.Net Adapter - app/services/payment_processors/authorize_net_adapter.rb
AuthorizeNetPaymentServiceprocess_payment_with_nonce for current flowPayment Processor Factory - app/services/payment_processor_factory.rb
default, for(processor_name), for_customer(customer), for_order(order)Controller Updates - app/controllers/app/quotes_controller.rb
AuthorizeNetPaymentService calls with factoryPaymentProfile Migration - db/migrate/..._add_processor_columns_to_payment_profiles.rb
processor, processor_customer_id, processor_token_idprocessor='authorize_net'PaymentTransaction Migration - db/migrate/..._add_processor_columns_to_payment_transactions.rb
processor, processor_transaction_id, metadata (jsonb)Model Updates
# Stop your dev server first (Ctrl+C)
bin/rails db:migrate
This will:
payment_profiles and payment_transactionsprocessor='authorize_net'Test a payment flow to ensure Authorize.Net still works through the adapter:
bin/devhttps://app.quarryrents.com/order/{token}/payment[AUTHORIZE_NET] prefix from the adapterThe refactoring should be backwards compatible, but verify:
app/
├── services/
│ ├── payment_processors/
│ │ ├── base.rb # Base interface
│ │ ├── authorize_net_adapter.rb # Authorize.Net adapter
│ │ └── fiserv_adapter.rb # TODO: Next phase
│ ├── payment_processor_factory.rb # Factory for routing
│ └── authorize_net_payment_service.rb # Original service (still used by adapter)
├── controllers/
│ └── app/
│ └── quotes_controller.rb # Updated to use factory
└── models/
├── payment_profile.rb # Updated with processor fields
└── payment_transaction.rb # Updated with processor fields
db/
└── migrate/
├── ..._add_processor_columns_to_payment_profiles.rb
└── ..._add_processor_columns_to_payment_transactions.rb
docs/
├── payment_processor_abstraction.md # Full implementation plan
├── fiserv_credentials.md # Fiserv sandbox credentials
└── phase1_implementation_complete.md # This file
Once testing confirms the abstraction layer works, we can proceed with:
app/services/payment_processors/fiserv_adapter.rbapp/helpers/fiserv_helper.rbpayment.html.erb.envDEFAULT_PAYMENT_PROCESSOR=fiservCurrently using Authorize.Net by default. To switch to Fiserv later:
# In .env
DEFAULT_PAYMENT_PROCESSOR=fiserv # or 'authorize_net'
authorize_customer_profile_id still workprocessor field for all existing recordsIf issues arise, you can:
DEFAULT_PAYMENT_PROCESSOR=authorize_net in .envNo code changes needed - just configuration!
Before moving to Phase 3, verify:
processor='authorize_net'Once testing is complete, we can start Phase 3:
Estimated time for Phase 3: 3-4 days
Check the following docs:
docs/payment_processor_abstraction.md - Full implementation plandocs/fiserv_credentials.md - Sandbox credentialsapp/services/payment_processors/base.rb - Interface documentation