[STA-6] misc(payment): Migrate to TypedResult#5930
Open
vincent-pochet wants to merge 1 commit into
Open
Conversation
6639576 to
df98a2d
Compare
jdenquin
approved these changes
Jul 13, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates the Invoices::Payments::*Service provider implementations (Stripe, Adyen, Cashfree, Flutterwave, GoCardless, Moneyhash) to the TypedResults multi-method bridge so they return typed BaseResult objects via Service.call(:method, ...) / call!, and updates provider webhook handlers and specs to use the new call style.
Changes:
- Introduce
TypedResults+RESULTSmaps inInvoices::Payments::*Serviceclasses and route method calls through.call(:method, ...). - Update webhook event handlers to call
klass.call(:update_payment_status, ...)when the target service supportsTypedResults, with a temporary fallback for legacy services. - Update factories, payment intent services, and specs to use
Factory.for(invoice)+provider_class.call!/callinstead of instantiating provider services.
Reviewed changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| spec/services/payment_providers/moneyhash/handle_event_service_spec.rb | Stubs provider payment update via .call entry point. |
| spec/services/payment_providers/gocardless/handle_event_service_spec.rb | Verifies GoCardless event routing now uses .call(:update_payment_status, ...). |
| spec/services/payment_providers/flutterwave/webhooks/charge_completed_service_spec.rb | Adjusts webhook specs for typed-results call path and result objects. |
| spec/services/payment_providers/cashfree/webhooks/payment_link_event_service_spec.rb | Updates expectations to .call(:update_payment_status, ...). |
| spec/services/payment_providers/adyen/handle_event_service_spec.rb | Updates Adyen webhook routing expectations to .call(...). |
| spec/services/payment_intents/fetch_service_spec.rb | Switches to Factory.for(invoice) returning a provider class and calling call!. |
| spec/services/payment_intents/expire_service_spec.rb | Switches to Factory.for(invoice) and call! for expiring provider URLs. |
| spec/services/invoices/payments/stripe_service_spec.rb | Refactors tests to exercise .call(:method) while still testing internal helpers. |
| spec/services/invoices/payments/payment_providers/factory_spec.rb | Updates factory contract: .for(invoice) returns a provider service class. |
| spec/services/invoices/payments/moneyhash_service_spec.rb | Updates Moneyhash invoice-payment service specs to .call(:method, ...). |
| spec/services/invoices/payments/gocardless_service_spec.rb | Updates GoCardless invoice-payment service specs to .call(:update_payment_status, ...). |
| spec/services/invoices/payments/generate_payment_url_service_spec.rb | Updates stubs to reflect provider services being called via .call. |
| spec/services/invoices/payments/flutterwave_service_spec.rb | Updates Flutterwave invoice-payment service specs to .call(:method, ...). |
| spec/services/invoices/payments/cashfree_service_spec.rb | Updates Cashfree invoice-payment service specs to .call(:method, ...). |
| spec/services/invoices/payments/adyen_service_spec.rb | Updates Adyen invoice-payment service specs to .call(:method, ...). |
| app/services/payment_providers/stripe/webhooks/base_service.rb | Adds temporary TypedResults/legacy branching for payment status updates. |
| app/services/payment_providers/moneyhash/handle_event_service.rb | Routes Moneyhash events through TypedResults when supported, else legacy path. |
| app/services/payment_providers/gocardless/handle_event_service.rb | Routes GoCardless events through TypedResults when supported, else legacy path. |
| app/services/payment_providers/flutterwave/webhooks/charge_completed_service.rb | Routes Flutterwave webhook through TypedResults when supported, else legacy path. |
| app/services/payment_providers/cashfree/webhooks/payment_link_event_service.rb | Routes Cashfree webhook through TypedResults when supported, else legacy path. |
| app/services/payment_providers/adyen/handle_event_service.rb | Routes Adyen webhook updates through TypedResults when supported, else legacy path. |
| app/services/payment_intents/fetch_service.rb | Uses Factory.for(invoice).call! to generate provider URLs. |
| app/services/payment_intents/expire_service.rb | Uses Factory.for(invoice).call! to expire provider sessions. |
| app/services/invoices/payments/stripe_service.rb | Adds TypedResults + typed RESULTS; updates method signatures for .call dispatch. |
| app/services/invoices/payments/payment_providers/factory.rb | Changes factory to return a provider service class via .for(invoice). |
| app/services/invoices/payments/moneyhash_service.rb | Adds TypedResults + typed RESULTS; updates URL generation signature for .call. |
| app/services/invoices/payments/gocardless_service.rb | Adds TypedResults + typed RESULTS; routes updates via .call. |
| app/services/invoices/payments/flutterwave_service.rb | Adds TypedResults + typed RESULTS; updates URL generation signature for .call. |
| app/services/invoices/payments/cashfree_service.rb | Adds TypedResults + typed RESULTS; updates URL generation signature for .call. |
| app/services/invoices/payments/adyen_service.rb | Adds TypedResults + typed RESULTS; updates URL generation signature for .call. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
df98a2d to
2e21b5c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
The
TypedResultsconcern was introduced to let legacy multi-method services return typed Results instead of the deprecated LegacyResult (OpenStruct), as an intermediate step before a full single-call refactor.Description
This PR applies the pattern to the
Invoices::Paymentssub-services (Stripe, Adyen, Cashfree, Flutterwave, Gocardless, Moneyhash).Each service now includes the concern, declares a
RESULTSconstant mapping every method to its typed Result, and exposes those methods as private — reached throughService.call(:method_name, *args). The former per-instance constructor is dropped in favor of arguments passed to each method.Call sites are updated accordingly: jobs use
call!,Factory#new_instanceis removed in favor of Factory.for(provider_customer), and specs exercise the services through the.call(:method)` entry point.