Skip to content

Refactor: Generialize payment initiation#1385

Open
beesaferoot wants to merge 6 commits intomainfrom
cash-transaction-flow-refactor
Open

Refactor: Generialize payment initiation#1385
beesaferoot wants to merge 6 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
* @param string $message Transaction routing key (device serial or entity ID)
* @param string $type Transaction type (e.g. 'deferred_payment', 'energy')
* @param int $customerId Person ID of the customer
* @param int $creatorId Admin user ID (used for cash transactions)
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.

$creatorId is specific to cash. I don't think we need to expose this on the high level interface. Could we find a way to pass implementation specific parameters?

) {}

/**
* Initialize a payment with any enabled 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.

I'm struggling a bit to understand what our understanding of Initialize is. Could you explains this more in the PHPDocs here?

I.e. does this have to create a transaction entry with a certain status etc?

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.

This diagram mentions Provider Validation. Where in the code does this happen?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was referencing to validations done on initializePayment for example with Paystack provider which goes through a call chain that ends up in InitializeTransactionResource which does validation on the structure of the data.

https://github.com/EnAccess/micropowermanager/pull/1385/changes#diff-d52a331b98749532774430e83f1cbed2cce947a64d05307ad552ece71ff25c4bR156

@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.

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