[STA-6] misc(payment_request): Migrate to TypedResult#5932
Merged
Conversation
vincent-pochet
force-pushed
the
misc-payment-service-result2
branch
2 times, most recently
from
July 16, 2026 07:13
2e21b5c to
5978a5d
Compare
vincent-pochet
force-pushed
the
misc-payment-service-result3
branch
from
July 16, 2026 07:32
55e723b to
0e31060
Compare
vincent-pochet
marked this pull request as ready for review
July 16, 2026 07:43
vincent-pochet
force-pushed
the
misc-payment-service-result3
branch
from
July 16, 2026 08:15
0e31060 to
e3f0a20
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates PaymentRequests::Payments::* provider services to the TypedResults multi-method service pattern, and updates jobs/webhooks/specs to call provider services via .call/.call! with typed results instead of per-instance invocation.
Changes:
- Convert PaymentRequest payment provider services (Stripe/Adyen/Cashfree/Flutterwave/GoCardless/Moneyhash) to
include TypedResultswithRESULTSmappings and private method dispatch. - Update factories, jobs, webhook handlers, and tests to use
Service.call(:method, ...)/Service.call!(:method, ...). - Simplify provider webhook routing by removing legacy branching and always using
call!forupdate_payment_status.
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| spec/services/payment_requests/payments/stripe_service_spec.rb | Updates tests to use described_class.call(:generate_payment_url/ :update_payment_status, ...). |
| spec/services/payment_requests/payments/payment_providers/factory_spec.rb | Adjusts expectations now that the factory returns a service class (not an instance). |
| spec/services/payment_requests/payments/moneyhash_service_spec.rb | Updates tests to call Moneyhash service methods via .call(:create/ :update_payment_status, ...). |
| spec/services/payment_requests/payments/gocardless_service_spec.rb | Updates tests for .call(:update_payment_status, ...) and removes constructor-based scenario. |
| spec/services/payment_requests/payments/generate_payment_url_service_spec.rb | Stubs provider services via .call to support .call! execution path. |
| spec/services/payment_requests/payments/flutterwave_service_spec.rb | Updates tests to .call(:generate_payment_url/ :update_payment_status, ...). |
| spec/services/payment_requests/payments/cashfree_service_spec.rb | Updates tests for .call(:generate_payment_url/ :update_payment_status, ...). |
| spec/services/payment_requests/payments/adyen_service_spec.rb | Updates tests for .call(:generate_payment_url/ :update_payment_status, ...). |
| spec/services/payment_providers/gocardless/handle_event_service_spec.rb | Updates webhook routing expectations to use .call(:update_payment_status, ...). |
| spec/services/payment_providers/flutterwave/webhooks/charge_completed_service_spec.rb | Updates webhook routing expectations to use .call(:update_payment_status, ...). |
| spec/services/payment_providers/cashfree/webhooks/payment_link_event_service_spec.rb | Updates webhook routing expectations to use .call(:update_payment_status, ...). |
| spec/services/payment_providers/adyen/handle_event_service_spec.rb | Updates webhook routing expectations to use .call(:update_payment_status, ...). |
| app/services/payment_requests/payments/stripe_service.rb | Migrates Stripe PaymentRequest service to TypedResults and method-arg based entry points. |
| app/services/payment_requests/payments/payment_providers/factory.rb | Replaces new_instance(payable:) with .for(payable) returning the service class. |
| app/services/payment_requests/payments/moneyhash_service.rb | Migrates Moneyhash PaymentRequest service to TypedResults and method-arg based entry points. |
| app/services/payment_requests/payments/gocardless_service.rb | Migrates GoCardless PaymentRequest service to TypedResults. |
| app/services/payment_requests/payments/generate_payment_url_service.rb | Uses provider service class from Factory and calls call!(:generate_payment_url, ...). |
| app/services/payment_requests/payments/flutterwave_service.rb | Migrates Flutterwave PaymentRequest service to TypedResults (generate_payment_url method). |
| app/services/payment_requests/payments/cashfree_service.rb | Migrates Cashfree PaymentRequest service to TypedResults. |
| app/services/payment_requests/payments/adyen_service.rb | Migrates Adyen PaymentRequest service to TypedResults. |
| app/services/payment_providers/stripe/webhooks/base_service.rb | Simplifies webhook update path to payment_service_klass.call!. |
| app/services/payment_providers/moneyhash/handle_event_service.rb | Routes Moneyhash webhooks via payment_service_klass(...).call!. |
| app/services/payment_providers/gocardless/handle_event_service.rb | Routes GoCardless webhooks via payment_service_klass(...).call!. |
| app/services/payment_providers/flutterwave/webhooks/charge_completed_service.rb | Routes Flutterwave webhook completion via payment_service_class.call!. |
| app/services/payment_providers/cashfree/webhooks/payment_link_event_service.rb | Routes Cashfree payment link events via payment_service_class.call!. |
| app/services/payment_providers/adyen/handle_event_service.rb | Routes Adyen events via payment_service_klass(...).call! and removes legacy branching. |
| app/jobs/payment_requests/payments/moneyhash_create_job.rb | Uses PaymentRequests::Payments::MoneyhashService.call!(:create, payable) instead of instance call. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
vincent-pochet
force-pushed
the
misc-payment-service-result3
branch
2 times, most recently
from
July 17, 2026 09:50
27e7864 to
1d87970
Compare
vincent-pochet
force-pushed
the
misc-payment-service-result3
branch
from
July 17, 2026 09:53
1d87970 to
6696f96
Compare
toommz
approved these changes
Jul 17, 2026
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
PaymentRequests::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.