Skip to content
This repository has been archived by the owner on Nov 26, 2020. It is now read-only.

Commit

Permalink
[HEIDELPAY-130] Several code optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
Niklas Gödde committed Nov 5, 2019
1 parent ff4f783 commit 6078478
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 14 deletions.
2 changes: 2 additions & 0 deletions src/Components/Document/InvoiceGenerator.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace HeidelPayment\Components\Document;

use HeidelPayment\Components\ClientFactory\ClientFactoryInterface;
Expand Down
4 changes: 2 additions & 2 deletions src/Components/WebhookHandler/PaymentStatusWebhookHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function supports(Webhook $webhook, SalesChannelContext $context): bool
*/
public function execute(Webhook $webhook, SalesChannelContext $context): void
{
$client = $client = $this->clientFactory->createClient();
$client = $this->clientFactory->createClient();
$payment = $client->getResourceService()->fetchResourceByUrl($webhook->getRetrieveUrl());

if (!$payment instanceof Payment) {
Expand All @@ -63,7 +63,7 @@ public function execute(Webhook $webhook, SalesChannelContext $context): void

$transaction = $this->getOrderTransaction($payment, $context->getContext());

if (null === $transaction) {
if ($transaction === null) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/EventListeners/Checkout/FinishPageEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function onCheckoutFinish(CheckoutFinishPageLoadedEvent $event): void
private function getInvoiceTransactions(OrderTransactionCollection $transactionCollection)
{
return $transactionCollection->filter(
function (OrderTransactionEntity $orderTransaction) {
static function (OrderTransactionEntity $orderTransaction) {
return in_array($orderTransaction->getPaymentMethodId(), InvoiceGenerator::SUPPORTED_PAYMENT_METHODS);
}
);
Expand Down
18 changes: 8 additions & 10 deletions src/HeidelPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,13 @@ public function uninstall(UninstallContext $uninstallContext): void

public function getViewPaths(): array
{
return array_merge(parent::getViewPaths(), [
'Resources/views/storefront',
'Resources/views/administration',
'Resources/views/framework',
]);
}

public function getStorefrontScriptPath(): string
{
return 'Resources/dist/storefront/js';
return array_merge(
parent::getViewPaths(),
[
'Resources/views/storefront',
'Resources/views/administration',
'Resources/views/framework',
]
);
}
}
2 changes: 1 addition & 1 deletion src/Resources/dist/storefront/js/heidel-payment.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,34 @@ export default class HeidelpayInvoiceFactoringPlugin extends Plugin {
*/
static heidelpayPlugin = null;

/**
* @type {Object}
*
* @public
*/
static b2bCustomer = null;

init() {
this.heidelpayPlugin = window.PluginManager.getPluginInstances('HeidelpayBase')[0];
this.invoiceFactoring = this.heidelpayPlugin.heidelpayInstance.InvoiceFactoring();
this.b2bCustomer = this.heidelpayPlugin.heidelpayInstance.B2BCustomer();

this._createForm();
this._registerEvents();
}

_createForm() {
this.b2bCustomer.initFormFields({
'companyInfo': {
'commercialSector': 'AIR_TRANSPORT',
},
});

this.b2bCustomer.create({
containerId: 'heidelpay-invoice-commercial-sector',
});
}

_registerEvents() {
this.heidelpayPlugin.$emitter.subscribe('heidelpayBase_createResource', () => this._onCreateResource(), {
scope: this,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
form="confirmOrderForm"
required="required"
{% if context.customer.birthday is not empty %}value="{{ context.customer.birthday|date('Y-m-d') }}"{% endif %}/>

{% if context.customer.activeBillingAddress.company %}
<div id="heidelpay-invoice-commercial-sector">

</div>
{% endif %}
</div>
{% endblock %}
</div>
Expand Down

0 comments on commit 6078478

Please sign in to comment.