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

[feat] add magic method __call to call custom method of driver #230

Closed
wants to merge 1 commit into from

Conversation

alissn
Copy link
Contributor

@alissn alissn commented Mar 10, 2024

Hi,

This pull request adds the magic method __call to Shetabit\Multipay\Payment to enable the calling of custom methods of drivers.

I think it solves issue #179. This enhancement allows us to add other custom methods to other drivers.

Usage example:

$payment = Payment::via('digipay')
    ->detail([
        'type'          => 13,
        'providerId'    => '855443ff-418f-44ad-8fbf-a7a5c1ffd0c9',
        'trackingCode'  => '4405940631710064990882',
        'invoiceNumber' => '12121',
        'deliveryDate'  => '2024-03-01',
        'products'      => [
            'test',
        ],
    ]);

dd($payment->deliver());

deliver is a public method of the Digipay gateway.

If further description or clarification is needed, please let me know.

@khanzadimahdi
Copy link
Member

khanzadimahdi commented Mar 11, 2024

the __call ruines the driver interface: https://github.com/shetabit/multipay/blob/master/src/Contracts/DriverInterface.php , then the consumer of driver will be coupled with the driver itself! the purpose of defining DriverInterface is decoupling from driver implementations.

if a method has not been defined in the interface, it should not be exposed even through __call magic method.

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