Skip to content

Commit

Permalink
Release 2.0.35
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrowanwallee committed Mar 20, 2023
1 parent 93f86d3 commit 0c09b04
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 87 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ This repository contains the plentymarkets extension that enables to process pay

## Documentation

* [Documentation](https://plugin-documentation.wallee.com/wallee-payment/plentymarkets/2.0.34/docs/en/documentation.html)
* [Documentation](https://plugin-documentation.wallee.com/wallee-payment/plentymarkets/2.0.35/docs/en/documentation.html)

## License

Please see the [license file](https://github.com/wallee-payment/plentymarkets/blob/2.0.34/LICENSE) for more information.
Please see the [license file](https://github.com/wallee-payment/plentymarkets/blob/2.0.35/LICENSE) for more information.
2 changes: 1 addition & 1 deletion docs/en/documentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h2>Documentation</h2> </div>
</a>
</li>
<li>
<a href="https://github.com/wallee-payment/plentymarkets/releases/tag/2.0.34/">
<a href="https://github.com/wallee-payment/plentymarkets/releases/tag/2.0.35/">
Source
</a>
</li>
Expand Down
5 changes: 5 additions & 0 deletions meta/documents/changelog_de.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Release Notes for wallee

## v2.0.35 (2023-03-10)

### Fixed
- Unnötigen Code entfernt

## v2.0.34 (2023-01-23)

### Fixed
Expand Down
5 changes: 5 additions & 0 deletions meta/documents/changelog_en.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Release Notes for wallee

## v2.0.35 (2023-03-101)

### Fixed
- Removed unneeded code

## v2.0.34 (2023-01-23)

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"namespace": "Wallee",
"type": "payment",
"version": "2.0.34",
"version": "2.0.35",
"license": " Apache License Version 2",
"isClosedSource": false,
"pluginIcon": "icon_plugin_md.png",
Expand Down
27 changes: 0 additions & 27 deletions src/Helper/WalleeServiceProviderHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
namespace Wallee\Helper;

use IO\Services\BasketService;
use Plenty\Modules\Basket\Contracts\BasketRepositoryContract;
use Plenty\Modules\Order\Contracts\OrderRepositoryContract;
use Plenty\Modules\Payment\Method\Contracts\PaymentMethodRepositoryContract;
use Plenty\Modules\Payment\Events\Checkout\GetPaymentMethodContent;
Expand All @@ -23,11 +22,6 @@ class WalleeServiceProviderHelper
*/
private $paymentHelper;

/**
* @var $basketRepository
*/
private $basketRepository;

/**
* @var $orderRepository
*/
Expand All @@ -49,45 +43,24 @@ class WalleeServiceProviderHelper
*
* @param Dispatcher $eventDispatcher
* @param PaymentHelper $paymentHelper
* @param BasketRepositoryContract $basketRepository
* @param OrderRepositoryContract $orderRepository
* @param PaymentService $paymentService
* @param PaymentMethodRepositoryContract $paymentMethodService
*/
public function __construct(
Dispatcher $eventDispatcher,
PaymentHelper $paymentHelper,
BasketRepositoryContract $basketRepository,
OrderRepositoryContract $orderRepository,
PaymentService $paymentService,
PaymentMethodRepositoryContract $paymentMethodService
) {
$this->eventDispatcher = $eventDispatcher;
$this->paymentHelper = $paymentHelper;
$this->basketRepository = $basketRepository;
$this->orderRepository = $orderRepository;
$this->paymentService = $paymentService;
$this->paymentMethodService = $paymentMethodService;
}

/**
* Adds the payment content event listener
* @return never
*/
public function addPaymentMethodContentEventListener() {
$this->eventDispatcher->listen(GetPaymentMethodContent::class, function (GetPaymentMethodContent $event) {
if ($this->paymentHelper->isWalleePaymentMopId($event->getMop())) {
$result = $this->paymentService->getPaymentContent(
$this->basketRepository->load(),
pluginApp(BasketService::class)->getBasketForTemplate(),
$this->paymentMethodService->findByPaymentMethodId($event->getMop())
);
$event->setValue(isset($result['content']) ? $result['content'] : null);
$event->setType(isset($result['type']) ? $result['type'] : '');
}
});
}

/**
* Adds the execute payment content event listener
* @return never
Expand Down
5 changes: 3 additions & 2 deletions src/Providers/WalleeServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public function boot(
PaymentMethodContainer $payContainer,
EventProceduresService $eventProceduresService,
CronContainer $cronContainer,
WalleeServiceProviderHelper $walleeServiceProviderHelper
WalleeServiceProviderHelper $walleeServiceProviderHelper,
PaymentService $paymentService
) {
$this->registerPaymentMethod($payContainer, 1457546097615, AlipayPaymentMethod::class);
$this->registerPaymentMethod($payContainer, 1457546097602, BankTransferPaymentMethod::class);
Expand Down Expand Up @@ -103,8 +104,8 @@ public function boot(
'en' => 'Refund the wallee payment'
], 'Wallee\Procedures\RefundEventProcedure@run');

$walleeServiceProviderHelper->addPaymentMethodContentEventListener();
$walleeServiceProviderHelper->addExecutePaymentContentEventListener();
$paymentService->createWebhook();

$cronContainer->add(CronContainer::EVERY_FIFTEEN_MINUTES, WebhookCronHandler::class);
}
Expand Down
55 changes: 1 addition & 54 deletions src/Services/PaymentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,60 +158,7 @@ public function __construct(WalleeSdkService $sdkService, ConfigRepository $conf
$this->orderRepository = $orderRepository;
}

/**
* Returns the payment method's content.
*
* @param Basket $basket
* @param array $basketForTemplate
* @param PaymentMethod $paymentMethod
* @return string[]
*/
public function getPaymentContent(Basket $basket, array $basketForTemplate, PaymentMethod $paymentMethod): array
{
$this->createWebhook();

$parameters = [
'transactionId' => $this->session->getPlugin()->getValue('walleeTransactionId'),
'basket' => $basket,
'basketForTemplate' => $basketForTemplate,
'paymentMethod' => $paymentMethod,
'basketItems' => $this->getBasketItems($basket),
'billingAddress' => $this->getAddress($this->getBasketBillingAddress($basket)),
'shippingAddress' => $this->getAddress($this->getBasketShippingAddress($basket)),
'language' => $this->session->getLocaleSettings()->language,
'successUrl' => $this->getSuccessUrl(),
'failedUrl' => $this->getFailedUrl(),
'checkoutUrl' => $this->getCheckoutUrl()
];
$this->getLogger(__METHOD__)->debug('wallee::TransactionParameters', $parameters);

$transaction = $this->sdkService->call('createTransactionFromBasket', $parameters);
if (is_array($transaction) && isset($transaction['error'])) {
$this->getLogger(__METHOD__)->error('wallee::TransactionError', $transaction);
return [
'type' => GetPaymentMethodContent::RETURN_TYPE_ERROR,
'content' => $transaction['error_msg']
];
}

$this->session->getPlugin()->setValue('walleeTransactionId', $transaction['id']);

$hasPossiblePaymentMethods = $this->sdkService->call('hasPossiblePaymentMethods', [
'transactionId' => $transaction['id']
]);
if (! $hasPossiblePaymentMethods) {
return [
'type' => GetPaymentMethodContent::RETURN_TYPE_ERROR,
'content' => 'The selected payment method is not available.'
];
}

return [
'type' => GetPaymentMethodContent::RETURN_TYPE_CONTINUE
];
}

private function createWebhook()
public function createWebhook()
{
/** @var \Plenty\Modules\Helper\Services\WebstoreHelper $webstoreHelper */
$webstoreHelper = pluginApp(\Plenty\Modules\Helper\Services\WebstoreHelper::class);
Expand Down

0 comments on commit 0c09b04

Please sign in to comment.