Skip to content

Commit

Permalink
Fix Credit managment and Paylink
Browse files Browse the repository at this point in the history
  • Loading branch information
LucianTuriacArnia committed Oct 5, 2023
1 parent e494b36 commit c82b1fb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 23 deletions.
23 changes: 2 additions & 21 deletions Controller/Adminhtml/PayLink/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,10 @@ public function execute(): ResultInterface
$payment->save();
$order->save();

$transactionBuilder = $this->transactionBuilderFactory->get('order');

$transactionBuilder->setOrder($order)
->setServices($services)
->setAdditionalParameter('fromPayLink', 1)
->setAdditionalParameter('fromPayPerEmail', 1)
->setMethod('TransactionRequest');

try {
$commandExecutor = $this->commandManagerPool->get('buckaroo');

$commandExecutor->executeByCode(
$result = $commandExecutor->executeByCode(
'paylink',
$payment,
[
Expand All @@ -111,18 +103,7 @@ public function execute(): ResultInterface
} catch (NotFoundException|CommandException $exception) {
$this->messageManager->addErrorMessage($exception->getMessage());
} catch (\Exception $e) {
$this->_messageManager->addErrorMessage($e->getMessage());
}

if (empty($payLink)) {
$this->_messageManager->addErrorMessage('Error creating PayLink');
} else {
$this->_messageManager->addSuccess(
__(
'Your PayLink <a href="%1">%1</a>',
$payLink
)
);
$this->messageManager->addErrorMessage($e->getMessage());
}

$payment = $order->getPayment();
Expand Down
11 changes: 10 additions & 1 deletion Observer/SalesOrderShipmentAfter.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,16 @@ private function createInvoice(bool $allowPartialsWithDiscount = false)
return $invoice;
}

public function createInvoiceGeneralSetting() {
/**
* Create invoice after shipment for all buckaroo payment methods
*
* @return bool
* @throws \Exception
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function createInvoiceGeneralSetting(): bool
{
$this->logger->addDebug('[CREATE_INVOICE] | [Observer] | ['. __METHOD__ .':'. __LINE__ . '] - Save Invoice');

if (!$this->order->canInvoice() || $this->order->hasInvoices()) {
Expand Down
2 changes: 1 addition & 1 deletion etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3496,6 +3496,7 @@
<arguments>
<argument name="builders" xsi:type="array">
<item name="group" xsi:type="string">BuckarooCreditManagmentGroup</item>
<item name="phone" xsi:type="string">Buckaroo\Magento2\Gateway\Request\Address\PhoneDataBuilder</item>
<item name="email" xsi:type="string">Buckaroo\Magento2\Gateway\Request\Address\EmailAddressDataBuilder</item>
<item name="config" xsi:type="string">Buckaroo\Magento2\Gateway\Request\CreditManagement\ConfigDataBuilder</item>
<item name="invoice" xsi:type="string">Buckaroo\Magento2\Gateway\Request\CreditManagement\InvoiceDataBuilder</item>
Expand All @@ -3506,7 +3507,6 @@
<virtualType name="BuckarooCreditManagmentGroup" type="BuckarooWithIdBuilderComposite">
<arguments>
<argument name="builders" xsi:type="array">
<item name="phone" xsi:type="string">Buckaroo\Magento2\Gateway\Request\Address\PhoneDataBuilder</item>
<item name="person" xsi:type="string">Buckaroo\Magento2\Gateway\Request\CreditManagement\PersonDataBuilder</item>
<item name="address" xsi:type="string">Buckaroo\Magento2\Gateway\Request\CreditManagement\AddressDataBuilder</item>
<item name="company" xsi:type="string">Buckaroo\Magento2\Gateway\Request\CreditManagement\CompanyDataBuilder</item>
Expand Down

0 comments on commit c82b1fb

Please sign in to comment.