Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dashboard page to list details of payments? #877

Closed
mlocati opened this issue May 28, 2024 · 7 comments · Fixed by #878
Closed

Add dashboard page to list details of payments? #877

mlocati opened this issue May 28, 2024 · 7 comments · Fixed by #878

Comments

@mlocati
Copy link
Contributor

mlocati commented May 28, 2024

I developed two payment methods (this and this) that store the details of the payment messages associated to every order (e.g. the data sent to the payment servers and the data received back from them).

At the moment, the only way to check these messages is by accessing the database directly.

What about adding to Community Store a new dashboard page where users can see the details of such messages?

I was thinking about something like this:

  1. in the on_start method of packages providing payment methods, we could introduce some code like this:
    use Concrete\Package\CommunityStore\Src\CommunityStore\Payment\LogProviderFactory;
    
    public funciton on_start()
    {
        $this->app->extend(LogProviderFactory::class, function(LogProviderFactory $factory) {
            $factory->registerProvider($this->app->make(ThisPaymentMethodLogProvider::class));
            return $factory;
        });
    }
  2. the new dashboard page would query the registered log providers, displaying the details of the messages (by date or for a specific order)
  3. in the details page of an order, we could add a link to that new dashboard page, passing it the order we want the log for

If that's ok, I can create a pull request that implements this new feature.

@mlocati
Copy link
Contributor Author

mlocati commented May 28, 2024

The log providers could implement an interface like this:

<?php

declare(strict_types=1);

namespace Concrete\Package\CommunityStore\Src\CommunityStore\Payment;

use Concrete\Package\CommunityStore\Src\CommunityStore\Order\Order;
use DateTimeInterface;

interface LogProvider
{
    /**
     * Get the handle that uniquely identifies this log provider.
     */
    public function getHandle(): string;

    /**
     * Get the display name of this log provider.
     */
    public function getName(): string;

    /**
     * Find the log entries in the specified date/time range.
     *
     * @return \Concrete\Package\CommunityStore\Src\CommunityStore\Payment\LogEntry[]
     */
    public function findByDate(DateTimeInterface $from, DateTimeInterface $to): array;

    /**
     * Find the log entries associated to a specific order.
     *
     * @return \Concrete\Package\CommunityStore\Src\CommunityStore\Payment\LogEntry[]
     */
    public function findByOrder(Order $order): array;
}

@Mesuva
Copy link
Collaborator

Mesuva commented May 28, 2024

Is the main benefit of this that it's a different log 'channel'?
Im just looking to understand why we'd use this, and not just standard logs.

@mlocati
Copy link
Contributor Author

mlocati commented May 28, 2024

It'd be rather hard to find order-specific entries in the standard logs...

@Mesuva
Copy link
Collaborator

Mesuva commented May 28, 2024

That makes sense. Would you then suggest that once this is place that all payment gateways should be adjusted to work with logs the same way?

@mlocati
Copy link
Contributor Author

mlocati commented May 29, 2024

That's just an opt-in feature, which requires that the payment gateways store the data of each step.

Of course that'd be nice.

And here's an example of a session of the code I'm developing:

  • if at least one payment method implements this feature, in the order details page we have this new button:
    immagine
  • by clicking it, we go to this new dashboard page:
    immagine
  • if we click on the View button, we see the details of the data sent/received:
    immagine

@Mesuva
Copy link
Collaborator

Mesuva commented May 29, 2024

That's very cool - I see what you're looking to do here.
With there being so many different ways that payment gateways work, each one has their own quirks and sometimes fiddly ways to debug.

@mlocati
Copy link
Contributor Author

mlocati commented May 29, 2024

And here it is: #878

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 a pull request may close this issue.

2 participants