Closed sydekumf closed 6 years ago
Can you provide me with some details about what you're trying to do? I'm not quite sure I understand correctly.
As I see it, a capture is always order-specific so you'd definitely need the order details to send a capture.
I mean line 81 in https://github.com/PAYONE-GmbH/magento-2/blob/master/Model/Api/Request/Capture.php#L81.
You rely on a request object which you do not have if you write some command line logic to capture on cli :-) We rewrited that functionality so that it uses the registry.
Hi @fjbender, currently, it is not possible to run an online capture more than one time in one PHP process. For big merchants, it is required to use asynchronous processing over logic to capture over cli or cron jobs.
Example:
/** @var Magento\Sales\Api\Data\OrderInterface[] $orderList */
foreach($orderList as $order) {
$payment = $order->getPayment();
$payment->setParentTransactionId($order->getData('payone_txid'));
/** @var $paymentMethod MethodInterface */
$paymentMethod = $payment->getMethodInstance();
$paymentMethod->capture($payment, $amount);
}
There should be a possibility, that the module resets all necessary information (parameters in classes etc) for every request like a capture or refund.
@larsroettig I see. However, I'm not sure what's best practice here.
Should we implicitly reset everything when capture()
is called (https://github.com/PAYONE-GmbH/magento-2/blob/master/Model/Methods/BaseMethod.php#L300), or implement an explicit reset()
method?
@fjbender There are some implementations like I said in the first comment, like the request object or maybe the Magento registry which definitely should not be used here in the first place, because they are not designed to work on cli or in an environment where you do not have single requests.
Altogether I think the module should be completely searched for possible parameters which should be reseted, i.e. Payone\Core\Model\Api\Invoice
. Or basically Payone\Core\Model\Methods\PayoneMethod
which has all the functions like catpure
, debit
etc. which need a clean environment for every call.
I think it makes sense, when this is done implicitly as the module itself knows when to reset.
@sydekumf I just added a new pull request concerning this problem. I added a new option to send the order items to the invoice and the creditmemo calls without a request context. ( PayoneMethod->setInvoiceData(), PayoneMethod->setCreditmemoData() ) I also added that the Payone Request object resets itself after a finished call, so that the request can be executed again for another call.
Okay thanks, is this everything which needs to be reseted? We have overwritten several pieces of the Payone module, and we similar reseted some variables etc. But there always have been further issues (when article data overwrites itself and so on) and we debugged further and found out more code which has to be rewritten. But if you say, this is everything, than it's fine :-)
Well I dont know of all your problems - since we never use the module in the way you do. I just fixed the issues you mentioned here. If there is more stuff that needs to be fixed, then you could add more information about those problems.
Anything new here @sydekumf @larsroettig ?
@fjbenderI think we close this issue because of we already refactored the code base for refund.
best regards,
lars
Hi,
during an online capture the order items are collected here in order to be sent to Payone: https://github.com/PAYONE-GmbH/magento-2/blob/master/Model/Api/Request/Capture.php getInvoiceList()
As you can see it expects request parameter, this means an online capture can only be done from the backend. There should be another solution so that you can create an online capture maybe on command line or in some other scope.
The only way now is to fake the request parameters, if possible.
Thanks :-)