Skip to content

[STA-6] misc(payment_request): Migrate to TypedResult#5932

Merged
vincent-pochet merged 1 commit into
mainfrom
misc-payment-service-result3
Jul 17, 2026
Merged

[STA-6] misc(payment_request): Migrate to TypedResult#5932
vincent-pochet merged 1 commit into
mainfrom
misc-payment-service-result3

Conversation

@vincent-pochet

@vincent-pochet vincent-pochet commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Context

The TypedResults concern 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::Payments sub-services (Stripe, Adyen, Cashfree, Flutterwave, Gocardless, Moneyhash).

Each service now includes the concern, declares a RESULTS constant mapping every method to its typed Result, and exposes those methods as private — reached through Service.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_instance is removed in favor of Factory.for(provider_customer), and specs exercise the services through the .call(:method)` entry point.

@vincent-pochet
vincent-pochet force-pushed the misc-payment-service-result2 branch 2 times, most recently from 2e21b5c to 5978a5d Compare July 16, 2026 07:13
Base automatically changed from misc-payment-service-result2 to main July 16, 2026 07:24
@vincent-pochet
vincent-pochet force-pushed the misc-payment-service-result3 branch from 55e723b to 0e31060 Compare July 16, 2026 07:32
@vincent-pochet
vincent-pochet marked this pull request as ready for review July 16, 2026 07:43
@vincent-pochet
vincent-pochet force-pushed the misc-payment-service-result3 branch from 0e31060 to e3f0a20 Compare July 16, 2026 08:15
@vincent-pochet
vincent-pochet requested a review from Copilot July 16, 2026 12:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 TypedResults with RESULTS mappings 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! for update_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.

Comment thread spec/services/payment_requests/payments/flutterwave_service_spec.rb
@vincent-pochet
vincent-pochet force-pushed the misc-payment-service-result3 branch 2 times, most recently from 27e7864 to 1d87970 Compare July 17, 2026 09:50
@vincent-pochet
vincent-pochet force-pushed the misc-payment-service-result3 branch from 1d87970 to 6696f96 Compare July 17, 2026 09:53
@vincent-pochet
vincent-pochet merged commit aa7770c into main Jul 17, 2026
12 checks passed
@vincent-pochet
vincent-pochet deleted the misc-payment-service-result3 branch July 17, 2026 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants