Skip to content

Commit

Permalink
Merge branch 'b-6.3.x' into PSPAYPAL-832_TplError
Browse files Browse the repository at this point in the history
  • Loading branch information
HonkDerHase authored Sep 5, 2024
2 parents 4ebb19f + 2e92af8 commit 4450ba5
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 18 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### FIX

- Fix order of closing brackets in applepay-template
- [0007711](https://bugs.oxid-esales.com/view.php?id=7711): Temporary orders that are no longer needed and already have an order number will be cancelled. Temporary orders without an order number will still be deleted
- Provide BN codes even to previously overlooked API calls

## [2.5.0] - 2024-08-16

Expand Down
2 changes: 1 addition & 1 deletion LATEST_CLIENT_TAG
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.0.15
v2.0.16
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"giggsey/libphonenumber-for-php": "^8.12",
"viison/address-splitter": "^0.3.4",
"webmozart/path-util": "^2.3.0",
"oxid-solution-catalysts/paypal-client": "v2.0.15"
"oxid-solution-catalysts/paypal-client": "v2.0.16"
},
"require-dev": {
"codeception/module-rest": "^1.4.2",
Expand Down
2 changes: 2 additions & 0 deletions src/Controller/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ public function captureGooglePayOrder(): void
$checkoutOrderId,
$request,
'',
Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP
);
} catch (ApiException $exception) {
$this->handlePayPalApiError($exception);
Expand Down Expand Up @@ -445,6 +446,7 @@ public function captureApplePayOrder()
$orderId,
$request,
'',
Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP
);
} catch (ApiException $exception) {
$logger = $this->getServiceFromContainer(Logger::class);
Expand Down
6 changes: 5 additions & 1 deletion src/Controller/ProxyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,11 @@ public function approveOrder()
$service = $serviceFactory->getOrderService();

try {
$response = $service->showOrderDetails($orderId, '');
$response = $service->showOrderDetails(
$orderId,
'',
Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP
);
} catch (Exception $exception) {
/** @var Logger $logger */
$logger = $this->getServiceFromContainer(Logger::class);
Expand Down
13 changes: 10 additions & 3 deletions src/Core/Api/VaultingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,13 @@ public function getVaultPaymentTokens($paypalCustomerId)
return null;
}

$headers = [];
$headers['Content-Type'] = 'application/x-www-form-urlencoded';
$headers['PayPal-Partner-Attribution-Id'] = Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP;

$path = '/v3/vault/payment-tokens?customer_id=' . $paypalCustomerId;

$response = $this->send('GET', $path);
$response = $this->send('GET', $path, [], $headers);
$body = $response->getBody();

return json_decode((string)$body, true);
Expand All @@ -219,11 +223,14 @@ public function getVaultPaymentTokenByIndex($paypalCustomerId, $index)
*/
public function deleteVaultedPayment($paymentTokenId)
{
$headers = [];
$headers['PayPal-Partner-Attribution-Id'] = Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP;

$path = '/v3/vault/payment-tokens/' . $paymentTokenId;

$response = $this->send('DELETE', $path);
$response = $this->send('DELETE', $path, [], $headers);

return $response->getStatusCode() == 204;
return $response->getStatusCode() === 204;
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/Core/Webhook/EventVerifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace OxidSolutionCatalysts\PayPal\Core\Webhook;

use OxidEsales\Eshop\Core\Registry;
use OxidSolutionCatalysts\PayPal\Core\Constants;
use OxidSolutionCatalysts\PayPalApi\Exception\ApiException;
use OxidSolutionCatalysts\PayPalApi\Service\GenericService;
use OxidSolutionCatalysts\PayPal\Core\Config;
Expand Down Expand Up @@ -60,9 +61,12 @@ public function verify(array $headers, string $body): bool
'webhook_event' => $normalizedBody
];

$headers = [];
$headers['PayPal-Partner-Attribution-Id'] = Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP;

/** @var GenericService $notificationService */
$notificationService = Registry::get(ServiceFactory::class)->getNotificationService();
$response = $notificationService->request('POST', $payload);
$response = $notificationService->request('POST', $payload, [], $headers);

if (
!$response['verification_status'] || (
Expand Down
7 changes: 6 additions & 1 deletion src/Core/Webhook/Handler/PaymentCaptureCompletedHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace OxidSolutionCatalysts\PayPal\Core\Webhook\Handler;

use OxidEsales\EshopCommunity\Core\Registry;
use OxidSolutionCatalysts\PayPal\Core\Constants;
use OxidSolutionCatalysts\PayPal\Service\Logger;
use OxidSolutionCatalysts\PayPal\Core\ServiceFactory;
use OxidSolutionCatalysts\PayPalApi\Exception\ApiException;
Expand Down Expand Up @@ -38,7 +39,11 @@ protected function getPayPalOrderDetails(string $payPalOrderId): ?PayPalApiModel
try {
$apiOrder = Registry::get(ServiceFactory::class)
->getOrderService()
->showOrderDetails($payPalOrderId, '');
->showOrderDetails(
$payPalOrderId,
'',
Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP
);
} catch (ApiException $exception) {
$apiOrder = null;
}
Expand Down
6 changes: 5 additions & 1 deletion src/Model/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,11 @@ public function getPayPalCheckoutOrder($payPalOrderId = ''): PayPalApiOrder
if (!$this->payPalApiOrder) {
/** @var Orders $orderService */
$orderService = Registry::get(ServiceFactory::class)->getOrderService();
$this->payPalApiOrder = $orderService->showOrderDetails($payPalOrderId, '');
$this->payPalApiOrder = $orderService->showOrderDetails(
$payPalOrderId,
'',
Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP
);
}

return $this->payPalApiOrder;
Expand Down
5 changes: 2 additions & 3 deletions src/Service/OrderRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ public function cleanUpNotFinishedOrders(): void
$sessiontime = (int)$this->config->getConfigParam('oscPayPalStartTimeCleanUpOrders');
$shopId = $this->config->getShopId();

/** @var QueryBuilder $queryBuilder */
$queryBuilder = $this->queryBuilderFactory->create();

$parameters = [
Expand All @@ -160,11 +159,11 @@ public function cleanUpNotFinishedOrders(): void
'oxpaymenttype',
$queryBuilder->expr()->literal('%' . $parameters['oxpaymenttype'] . '%')
))
->andWhere('oxorderdate + interval :sessiontime MINUTE > now()');
->andWhere('oxorderdate < now() - interval :sessiontime MINUTE');

$ids = $queryBuilder->setParameters($parameters)
->execute()
->fetchAll(PDO::FETCH_COLUMN);
->fetchAllAssociative();

foreach ($ids as $id) {
$order = oxNew(EshopModelOrder::class);
Expand Down
23 changes: 17 additions & 6 deletions src/Service/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@ public function doCapturePayPalOrder(
'',
$checkoutOrderId,
$request,
''
'',
Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP
);
} catch (ApiException $exception) {
$this->handlePayPalApiError($exception);
Expand Down Expand Up @@ -490,14 +491,20 @@ public function removeTemporaryOrder(): void
$orderModel->load($sessionOrderId);

if (
$orderModel->isLoaded() &&
!$orderModel->hasOrderNumber()
$orderModel->isLoaded()
) {
$orderModel->delete();
$orderModel->cancelOrder();
$this->logger->log('debug', sprintf(
'Temporary order without Order number and with id %s was deleted',
'Temporary order with id %s was canceled',
$sessionOrderId
));
if (!$orderModel->hasOrderNumber()) {
$orderModel->delete();
$this->logger->log('debug', sprintf(
'Temporary order without Order number and with id %s was deleted',
$sessionOrderId
));
}
}

PayPalSession::unsetPayPalOrderId();
Expand Down Expand Up @@ -741,7 +748,11 @@ public function fetchOrderFields(string $paypalOrderId, string $fields = ''): Ap
{
return $this->serviceFactory
->getOrderService()
->showOrderDetails($paypalOrderId, $fields);
->showOrderDetails(
$paypalOrderId,
$fields,
Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP
);
}

/**
Expand Down

0 comments on commit 4450ba5

Please sign in to comment.