Skip to content

Commit

Permalink
Release 4.0.44
Browse files Browse the repository at this point in the history
  • Loading branch information
edgaraswallee committed Oct 11, 2022
1 parent 6c99bb3 commit a59df35
Show file tree
Hide file tree
Showing 12 changed files with 142 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ tail -f var/log/wallee_payment*.log

## Documentation

[Documentation](https://plugin-documentation.wallee.com/wallee-payment/shopware-6/4.0.43/docs/en/documentation.html)
[Documentation](https://plugin-documentation.wallee.com/wallee-payment/shopware-6/4.0.44/docs/en/documentation.html)

## License

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@
"wallee/sdk": "3.0.1"
},
"type": "shopware-platform-plugin",
"version": "4.0.43"
"version": "4.0.44"
}
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/shopware-6/releases/tag/4.0.43/">
<a href="https://github.com/wallee-payment/shopware-6/releases/tag/4.0.44/">
Source
</a>
</li>
Expand Down
92 changes: 90 additions & 2 deletions src/Core/Api/Transaction/Service/TransactionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Wallee\Sdk\{
Model\Transaction,
Model\TransactionPending
Model\TransactionPending,
Model\ChargeAttempt,
Model\CreationEntityState,
Model\CriteriaOperator,
Model\EntityQuery,
Model\EntityQueryFilter,
Model\EntityQueryFilterType,
};

use WalleePayment\Core\{
Api\OrderDeliveryState\Handler\OrderDeliveryStateHandler,
Api\Refund\Entity\RefundEntityCollection,
Expand Down Expand Up @@ -55,6 +62,8 @@ class TransactionService {
* @var \WalleePayment\Core\Settings\Service\SettingsService
*/
private $settingsService;

const PSEUDO_CODE_KEY = '1485172176673';

/**
* TransactionService constructor.
Expand Down Expand Up @@ -144,13 +153,17 @@ public function create(
$redirectUrl = $apiClient->getTransactionPaymentPageService()
->paymentPageUrl($settings->getSpaceId(), $createdTransaction->getId());
}



$this->upsert(
$createdTransaction,
$salesChannelContext->getContext(),
$transaction->getOrderTransaction()->getPaymentMethodId(),
$transaction->getOrder()->getSalesChannelId()
);



$this->holdDelivery($transaction->getOrder()->getId(), $salesChannelContext->getContext());

Expand Down Expand Up @@ -197,13 +210,43 @@ public function upsert(
{
try {

$transactionId = $transaction->getId();
$transactionMetaData = $transaction->getMetaData();

if (!$salesChannelId) {
$salesChannelId = $transactionMetaData['salesChannelId'] ?? '';
}

$orderId = $transactionMetaData[TransactionPayload::WALLEE_METADATA_ORDER_ID];
$orderTransactionId = $transactionMetaData[TransactionPayload::WALLEE_METADATA_ORDER_TRANSACTION_ID];

$pseudoCardNumber = $this->getTransactionPseudoCardNumber($salesChannelId, $transactionId);

$dataParamValue = json_decode(strval($transaction), true);
$brandName = '';
if (isset($dataParamValue['paymentConnectorConfiguration'])) {
$brandName = $dataParamValue['paymentConnectorConfiguration']
? $dataParamValue['paymentConnectorConfiguration']['name']
: '';
}
$dataParamValue['brandName'] = $brandName;

$paymentMethodName = '';
if (isset($dataParamValue['paymentConnectorConfiguration'])) {
$paymentMethodName = $dataParamValue['paymentConnectorConfiguration']
? $dataParamValue['paymentConnectorConfiguration']['paymentMethodConfiguration']['name']
: '';
}
$dataParamValue['paymentMethodName'] = $paymentMethodName;

$dataParamValue['pseudoCardNumber'] = $pseudoCardNumber;
$dataParamValue['customerName'] = isset($transactionMetaData[TransactionPayload::WALLEE_METADATA_CUSTOMER_NAME])
? $transactionMetaData[TransactionPayload::WALLEE_METADATA_CUSTOMER_NAME]
: '';

$data = [
'id' => $orderId,
'data' => json_decode(strval($transaction), true),
'data' => $dataParamValue,
'paymentMethodId' => $paymentMethodId,
'orderId' => $orderId,
'orderTransactionId' => $orderTransactionId,
Expand Down Expand Up @@ -351,5 +394,50 @@ public function getRefundEntityCollectionByTransactionId(int $transactionId, Con
)
->getEntities();
}

/**
* @param int $transactionId
* @return string
*/
public function getTransactionPseudoCardNumber(string $salesChannelId, int $transactionId): string
{
/** @noinspection PhpParamsInspection */
$entityQueryFilter = (new EntityQueryFilter())
->setType(EntityQueryFilterType::LEAF)
->setOperator(CriteriaOperator::EQUALS)
->setFieldName('charge.transaction')
->setValue($transactionId);

$query = (new EntityQuery())->setFilter($entityQueryFilter);

$settings = $this->settingsService->getSettings($salesChannelId);

/**
* ChargeAttempt $chargeAttempt
*/
$chargeAttempt = $settings->getApiClient()->getChargeAttemptService()->search($settings->getSpaceId(), $query);
if (!$chargeAttempt) {
return '';
}

$labels = $chargeAttempt[0]->getLabels() ?? [];

if (empty($labels)) {
return '';
}

$pseudoCardCode = '';
foreach ($labels as $label) {
$descriptor = $label->getDescriptor();
if ((string) $descriptor->getId() !== self::PSEUDO_CODE_KEY) {
continue;
}

$pseudoCardCode = $label->getContentAsString();
break;
}

return $pseudoCardCode;
}

}
14 changes: 14 additions & 0 deletions src/Core/Util/Payload/TransactionPayload.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
use Symfony\Contracts\Translation\TranslatorInterface;
use Wallee\Sdk\{
Model\AddressCreate,
Model\ChargeAttempt,
Model\CreationEntityState,
Model\CriteriaOperator,
Model\EntityQuery,
Model\EntityQueryFilter,
Model\EntityQueryFilterType,
Model\LineItemAttributeCreate,
Model\LineItemCreate,
Model\LineItemType,
Expand Down Expand Up @@ -48,6 +54,7 @@ class TransactionPayload extends AbstractPayload
public const WALLEE_METADATA_SALES_CHANNEL_ID = 'salesChannelId';
public const WALLEE_METADATA_ORDER_ID = 'orderId';
public const WALLEE_METADATA_ORDER_TRANSACTION_ID = 'orderTransactionId';
public const WALLEE_METADATA_CUSTOMER_NAME = 'customerName';


/**
Expand Down Expand Up @@ -121,8 +128,14 @@ public function get(): TransactionCreate


$customerId = null;
$customerName = null;
if ($customer->getGuest() === false) {
$customerId = $customer->getCustomerNumber();
$customerName = '';
if ($customer->getGuest() === false) {
$customerId = $customer->getCustomerNumber();
$customerName = $customer->getSalutation()->getDisplayName() . ' ' . $customer->getFirstName() . ' ' . $customer->getLastName();
}
}

$transactionData = [
Expand All @@ -135,6 +148,7 @@ public function get(): TransactionCreate
self::WALLEE_METADATA_ORDER_ID => $this->transaction->getOrder()->getId(),
self::WALLEE_METADATA_ORDER_TRANSACTION_ID => $this->transaction->getOrderTransaction()->getId(),
self::WALLEE_METADATA_SALES_CHANNEL_ID => $this->salesChannelContext->getSalesChannel()->getId(),
self::WALLEE_METADATA_CUSTOMER_NAME => $customerName,
],
'shipping_method' => $this->salesChannelContext->getShippingMethod()->getName() ? $this->fixLength($this->salesChannelContext->getShippingMethod()->getName(), 200) : null,
'space_view_id' => $this->settings->getSpaceViewId() ?? null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,16 @@
{% block wallee_order_transaction_history_grid %}
<sw-data-grid :dataSource="transactionData.transactions"
:columns="relatedResourceColumns"
:showActions="false"
:showActions="true"
:showSelection="false">

<template #actions="{ item }">
<sw-context-menu-item v-if="item.customerId">{{ $tc('wallee-order.transactionHistory.customerId') }}: {{ item.customerId }}</sw-context-menu-item>
<sw-context-menu-item v-if="item.customerName">{{ $tc('wallee-order.transactionHistory.customerName') }}: {{ item.customerName }}</sw-context-menu-item>
<sw-context-menu-item v-if="item.paymentMethodName">{{ $tc('wallee-order.transactionHistory.paymentMethod') }}: {{ item.paymentMethodName }}</sw-context-menu-item>
<sw-context-menu-item v-if="item.brandName">{{ $tc('wallee-order.transactionHistory.paymentMethodBrand') }}: {{ item.brandName }}</sw-context-menu-item>
<sw-context-menu-item v-if="item.pseudoCardNumber">{{ $tc('wallee-order.transactionHistory.PseudoCreditCardNumber') }}: {{ item.pseudoCardNumber }}</sw-context-menu-item>
</template>
</sw-data-grid>
{% endblock %}
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Component.register('wallee-order-detail', {
relatedResourceColumns() {
return [
{
property: 'paymentConnectorConfiguration.name',
property: 'paymentMethodName',
label: this.$tc('wallee-order.transactionHistory.types.payment_method'),
rawData: true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@
"payment_method": "Zahlungsweise",
"state": "Staat",
"transaction": "Transaktion"
}
},
"customerId": "Customer ID",
"customerName": "Customer Name",
"paymentMethod": "Zahlungsart",
"paymentMethodBrand": "Marke der Zahlungsmethode",
"PseudoCreditCardNumber": "Pseudo-Kreditkartennummer"
},
"voidAction": {
"confirm": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@
"payment_method": "Payment Method",
"state": "State",
"transaction": "Transaction"
}
},
"customerId": "Customer ID",
"customerName": "Customer Name",
"paymentMethod": "Payment Method",
"paymentMethodBrand": "Payment Method Brand",
"PseudoCreditCardNumber": "Pseudo Credit Card Number"
},
"voidAction": {
"confirm": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@
"payment_method": "Mode de paiement",
"state": "État",
"transaction": "Transaction"
}
},
"customerId": "Customer ID",
"customerName": "Customer Name",
"paymentMethod": "Mode de paiement",
"paymentMethodBrand": "Marque du mode de paiement",
"PseudoCreditCardNumber": "Pseudo numéro de carte de crédit"
},
"voidAction": {
"confirm": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@
"payment_method": "Metodo di pagamento",
"state": "Stato",
"transaction": "Transazione"
}
},
"customerId": "Customer ID",
"customerName": "Customer Name",
"paymentMethod": "Metodo di pagamento",
"paymentMethodBrand": "Metodo di pagamento Marca",
"PseudoCreditCardNumber": "Numero di carta di credito pseudo"
},
"voidAction": {
"confirm": {
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/public/administration/js/wallee-payment.js

Large diffs are not rendered by default.

0 comments on commit a59df35

Please sign in to comment.