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

maybe introduce feature flags to payments #264

Closed
backbone87 opened this issue Nov 28, 2014 · 2 comments · May be fixed by #518
Closed

maybe introduce feature flags to payments #264

backbone87 opened this issue Nov 28, 2014 · 2 comments · May be fixed by #518

Comments

@backbone87
Copy link

afaik the aim of this library is to provide a unified interface to handle payments via various providers. therefore an abstraction of common tasks (capture, authorize, notify, sync, status) is provided. ofc not every provider supports all tasks or specific provider have more tasks that can be used.

but even if a provider has a CaptureAction an ->execute(new Capture($model)) can fail, because the model maybe needs some conversion of model (via some extension) first.

you cant determine if a Capture failed because the payment isnt configured properly (missing extension) or the provided model is completely wrong (null or some other gibberish) or the payment simply doesnt support the specific action.

introduce a common interface to all models that can be passed to a request would solve a part of this issue.
introducing some flag system would solve another part: $payment->supports($requestClassName)

public function supports($request) {
  foreach($this->supported as $class) {
    if(!is_a($request, $class, true)) {
      return false;
    }
  }
  return true;
}
@makasim
Copy link
Member

makasim commented Nov 28, 2014

@backbone87 I dont have much time at the moment, but I'll try to respond to all your suggestion as soon as possible. Really appreciate your feedback.

Thanks for sharing this.

@makasim
Copy link
Member

makasim commented Nov 29, 2014

The feature was asked several times, we talked about it yesterday with @bojanz. There will be a solution for that. I am ok with adding supports($request) to the payment itself, but I tend to move the logic to an action

<?php

public function supports($request) 
{
    $this->execute($support = new Support($request));

    return $support->is();
}

This way one can overwrite the action, in case they add a new action or something like that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants