Skip to content

Refactor: Unify transaction flow#1258

Merged
beesaferoot merged 9 commits intomainfrom
unify-transaction-flow
Feb 23, 2026
Merged

Refactor: Unify transaction flow#1258
beesaferoot merged 9 commits intomainfrom
unify-transaction-flow

Conversation

@beesaferoot
Copy link
Copy Markdown
Contributor

We previously duplicated transaction processing for Cash payments and "normal" transaction flow. This PR unifies them, thereby simplifying the overall flow.

Closes #1257

Brief summary of the change made

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.

@dmohns dmohns self-requested a review January 22, 2026 16:03
@dmohns
Copy link
Copy Markdown
Member

dmohns commented Jan 27, 2026

Hey @beesaferoot

From what I understand, currently, when using CashTransactions. The Token that is generated has device_id = NULL. With your changes, the device_id get's populated. This is an intended side effect I assume?

We need to add a migration for this right? Note that the seeded data doesn't have this problem.

@beesaferoot
Copy link
Copy Markdown
Contributor Author

Hey @beesaferoot

From what I understand, currently, when using CashTransactions. The Token that is generated has device_id = NULL. With your changes, the device_id get's populated. This is an intended side effect I assume?

We need to add a migration for this right? Note that the seeded data doesn't have this problem.

Didn't realize this side effect until you mentioned it, but yes, it is intended. I don't think we need a migration, the token is rightly tied to the right appliance (device) having the same result as previous cash processing logic.

@dmohns
Copy link
Copy Markdown
Member

dmohns commented Jan 27, 2026

Didn't realize this side effect until you mentioned it, but yes, it is intended. I don't think we need a migration, the token is rightly tied to the right appliance (device) having the same result as previous cash processing logic.

I understand it's not strictly required. But I think I'd still like to have it. Else we will be in the situation where some (older) tokns don't have device_id and newer tokens have device_id. This will almost certain lead to problems in the future, no?

@beesaferoot
Copy link
Copy Markdown
Contributor Author

Didn't realize this side effect until you mentioned it, but yes, it is intended. I don't think we need a migration, the token is rightly tied to the right appliance (device) having the same result as previous cash processing logic.

I understand it's not strictly required. But I think I'd still like to have it. Else we will be in the situation where some (older) tokns don't have device_id and newer tokens have device_id. This will almost certain lead to problems in the future, no?

With our use of Token with relation to transactions, I can't foresee issues entirely based on missing device_id. We can always get the device from the transaction that the token was generated by.

However, I could look into this to be on the safe side. To populate the missing device ids don't we need to still resort to the action above?

@beesaferoot
Copy link
Copy Markdown
Contributor Author

Added a migration to backfill empty device ids on the Token table.

@dmohns

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.

Some things seem broken with Non-PayGO devices. When I try to register a cash payment for non paygo this happens:

image

On the Demo it works fine, and registers a log here

image

@dmohns
Copy link
Copy Markdown
Member

dmohns commented Jan 29, 2026

Apart from my message above, everything seems to work! Nice, nice. I will admit that I don't fully understand everything, the different relation between all the jobs and events involved in processing. But hopefully this will become cleaner with the reworker transaction logic 🤞

@beesaferoot
Copy link
Copy Markdown
Contributor Author

Some things seem broken with Non-PayGO devices. When I try to register a cash payment for non paygo this happens:

image On the Demo it works fine, and registers a log here image

Thanks for pointing this out, will look into it.

We previously duplicated transaction processing for Cash payments and "normal" transaction flow. This commit unifies them thereby simplying the overall flow.
@beesaferoot beesaferoot force-pushed the unify-transaction-flow branch from f8aa821 to 7787b34 Compare January 30, 2026 11:49
@beesaferoot beesaferoot requested a review from dmohns January 30, 2026 13:18
@beesaferoot
Copy link
Copy Markdown
Contributor Author

The Transaction Payments for Non Paygo appliances have now been addressed.

Comment on lines +27 to +34
public function getPaymentForAppliance(Request $request, AppliancePerson $appliancePerson): array {
$creatorId = auth('api')->user()->id;
$this->paymentAmount = $amount = (float) $request->input('amount');
$applianceDetail = $this->appliancePersonService->getApplianceDetails($appliancePerson->id);
$this->validateAmount($applianceDetail, $amount);
$deviceSerial = $applianceDetail->device_serial;
$applianceOwner = $appliancePerson->person;
$companyId = $request->attributes->get('companyId');
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.

I think a lot of confusion comes from this function call. It is called getPaymentForAppliance which is highly, highly misleading.

What this does, it creates a Cash Transaction for an Appliance, and thus creates a tight coupling.

Could you move this function out here into ... for example ... ApplianceCashTransactionService.php (or something similar).

This way, we would remove the coupling between CashTransaction and AppliancePaymentService. AppliancePaymentService would then only deal with the logic of handling Appliance payments, independant of the provider.

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.

As discussed, a valid alternative would be to move this to the controller directly (assuming this the only place it's getting called.)

Comment thread src/backend/app/Jobs/TokenProcessor.php
@beesaferoot beesaferoot requested a review from dmohns February 18, 2026 16:22
@beesaferoot
Copy link
Copy Markdown
Contributor Author

Updated as discussed earlier. Please have a look. @dmohns

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.

Great work!!! Have been doing some testing locally and everything seems to work as expected.

None-the-less, it's a big change, I think we would need a stand alone release just for this.

@beesaferoot beesaferoot merged commit 27572b5 into main Feb 23, 2026
16 checks passed
@beesaferoot beesaferoot deleted the unify-transaction-flow branch February 23, 2026 09:36
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.

[Transaction Abstraction Refactoring] Unify Transaction Flow (Cash Transaction)

2 participants