Skip to content

Refactor: Generialize payment initiation#1385

Merged
beesaferoot merged 16 commits intomainfrom
cash-transaction-flow-refactor
Apr 16, 2026
Merged

Refactor: Generialize payment initiation#1385
beesaferoot merged 16 commits intomainfrom
cash-transaction-flow-refactor

Conversation

@beesaferoot
Copy link
Copy Markdown
Contributor

@beesaferoot beesaferoot commented Mar 18, 2026

This changes attempts to consolidate Payment initiation in on central location PaymentInitialization. It also introduces another payment method with sold appliance.

Makes progress on #1243

Brief summary of the change made

Screenshot 2026-03-18 at 3 05 40 PM

Are there any other side effects of this change that we should be aware of?

Describe how you tested your changes?

Pull Request checklist

Please confirm you have completed any of the necessary steps below.

  • Meaningful Pull Request title and description
  • Changes tested as described above
  • Added appropriate documentation for the change.
  • Created GitHub issues for any relevant followup/future enhancements if appropriate.

This changes attempts to consolidate Payment initiation in on central location PaymentInitialization. It also introduces another payment method with sold appliance.
@beesaferoot beesaferoot requested a review from dmohns March 18, 2026 14:07
Comment thread src/backend/app/Services/TransactionPaymentProcessor.php Outdated
Comment thread docs/usage-guide/images/payment-flow.excalidraw.svg
Comment thread src/backend/app/Services/PluginsService.php
Comment thread src/backend/app/Services/CashTransactionService.php Outdated
Comment thread src/backend/app/Services/PaymentInitializationService.php Outdated
Comment thread src/backend/app/Services/PaymentInitializationService.php Outdated
Comment thread src/backend/app/Services/PaymentInitializationService.php
Comment thread docs/usage-guide/images/payment-flow.excalidraw.svg
@beesaferoot beesaferoot requested a review from dmohns April 2, 2026 14:17
Copy link
Copy Markdown
Member

@dmohns dmohns left a comment

Choose a reason for hiding this comment

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

I'm still struggling a little bit to follow the payment processing flow. Both, with and without your changes 😅

After coming back to this multiple times, I think one of the confusions for me lies in the redundancy between Transaction Providers (Providers here mean Laravel Providers, not Payment Providers) and Transaction Services

For Providers we already have a Contract ITransactionProvider. For Services we have AbstractPaymentAggregatorTransactionService

Now, looking at ITransactionProvider it seems like it was intended to already cover a lot of aspects that you are trying to add here.

For example it has

public function init(BasePaymentProviderTransaction $transaction): void;

Do you think it within the scope of this PR to clean up this redundancy?

@beesaferoot
Copy link
Copy Markdown
Contributor Author

beesaferoot commented Apr 2, 2026

I'm still struggling a little bit to follow the payment processing flow. Both, with and without your changes 😅

After coming back to this multiple times, I think one of the confusions for me lies in the redundancy between Transaction Providers (Providers here mean Laravel Providers, not Payment Providers) and Transaction Services

For Providers we already have a Contract ITransactionProvider. For Services we have AbstractPaymentAggregatorTransactionService

Now, looking at ITransactionProvider it seems like it was intended to already cover a lot of aspects that you are trying to add here.

For example it has

public function init(BasePaymentProviderTransaction $transaction): void;

Do you think it within the scope of this PR to clean up this redundancy?

If I understand your comment correctly ITransactionProvider should essentially also cover what PaymentInitializer is trying do to here.

Do you think it within the scope of this PR to clean up this redundancy?

Yes, this is very much part of the chain of refactor we are ultimately aiming to achieve.

I'm still struggling a little bit to follow the payment processing flow. Both, with and without your changes 😅

To be fair, this only PR tries to make it possible to bring all payment initiation steps in one place. My hope is that this will open up better abstractions that could simplify the entire flow, which is still rather complex.

@dmohns
Copy link
Copy Markdown
Member

dmohns commented Apr 15, 2026

Hey @beesaferoot coming back to this one. Can you resolve merge conflicts?

@beesaferoot beesaferoot requested a review from dmohns April 15, 2026 15:29
Copy link
Copy Markdown
Member

@dmohns dmohns left a comment

Choose a reason for hiding this comment

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

Couple of comments, hope they make sense

Comment on lines +92 to +94
if ($providerId === $this::CASH_TRANSACTION_PROVIVER) {
dispatch(new ProcessPayment($companyId, $result['transaction']->id));
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Having this here feel odd. Can we move this into CashTransactionService::initializePayment(...). I.e. for a CashTransaction if it's get "initialised" it get's immediate processed. By design of cash transaction

Comment thread src/backend/app/Http/Controllers/AppliancePaymentController.php Outdated
Comment thread src/backend/app/Http/Controllers/AppliancePaymentController.php Outdated
Comment thread src/backend/app/Http/Controllers/AppliancePersonController.php Outdated
@beesaferoot beesaferoot requested a review from dmohns April 16, 2026 14:42
@dmohns
Copy link
Copy Markdown
Member

dmohns commented Apr 16, 2026

LGTM, can you fix the larastan then I can approve

Copy link
Copy Markdown
Member

@dmohns dmohns left a comment

Choose a reason for hiding this comment

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

Nice!!! Let's go with this

@beesaferoot beesaferoot merged commit f3f2904 into main Apr 16, 2026
17 checks passed
@beesaferoot beesaferoot deleted the cash-transaction-flow-refactor branch April 16, 2026 15:20
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.

2 participants