From b22a21ba839fdbd797bfa43b6080f531b9566b0e Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 10 Nov 2023 11:12:05 +0100 Subject: [PATCH] Use only one BM-Code everywhere --- CHANGELOG.md | 1 + LATEST_CLIENT_TAG | 2 +- composer.json | 2 +- .../Admin/PayPalOrderController.php | 7 +++- src/Controller/ProxyController.php | 7 +--- src/Core/Constants.php | 2 + src/Core/ViewConfig.php | 2 +- .../Handler/CheckoutOrderApprovedHandler.php | 8 +++- src/Service/Payment.php | 40 +++++++++++++++---- 9 files changed, 52 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b41d6cad..df6e7d429 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [2.3.3] - 2023-??-?? - [0007549](https://bugs.oxid-esales.com/view.php?id=7549): Optional field in shop admin -> refund "Note to buyer" is transmitted to PayPal +- reduce transmitted BN Codes from three to one ## [2.3.2] - 2023-10-05 diff --git a/LATEST_CLIENT_TAG b/LATEST_CLIENT_TAG index a5aea5c89..77989f509 100644 --- a/LATEST_CLIENT_TAG +++ b/LATEST_CLIENT_TAG @@ -1 +1 @@ -v2.0.8 \ No newline at end of file +v2.0.9 \ No newline at end of file diff --git a/composer.json b/composer.json index 9fc12079b..e8ad63dfe 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,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.8" + "oxid-solution-catalysts/paypal-client": "v2.0.9" }, "require-dev": { "codeception/module-rest": "^1.4.2", diff --git a/src/Controller/Admin/PayPalOrderController.php b/src/Controller/Admin/PayPalOrderController.php index 7f4a2d62a..9b7336f6d 100644 --- a/src/Controller/Admin/PayPalOrderController.php +++ b/src/Controller/Admin/PayPalOrderController.php @@ -229,7 +229,12 @@ public function refund(): void ); /** @var Refund $refund */ - $refund = $apiPaymentService->refundCapturedPayment($capture->id, $request, ''); + $refund = $apiPaymentService->refundCapturedPayment( + $capture->id, + $request, + '', + Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP + ); /** @var PaymentService $paymentService */ $paymentService = $this->getServiceFromContainer(PaymentService::class); diff --git a/src/Controller/ProxyController.php b/src/Controller/ProxyController.php index 474bbe7a0..c445ab995 100644 --- a/src/Controller/ProxyController.php +++ b/src/Controller/ProxyController.php @@ -61,7 +61,7 @@ public function createOrder() '', '', '', - $this->getPayPalPartnerAttributionId(), + Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP, null, null, false, @@ -268,11 +268,6 @@ protected function handleUserLogin(PayPalApiOrder $apiOrder): bool return $isLoggedIn; } - protected function getPayPalPartnerAttributionId(): string - { - return Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_EXPRESS; - } - protected function getRequestedPayPalPaymentId( $defaultPayPalPaymentId = PayPalDefinitions::EXPRESS_PAYPAL_PAYMENT_ID ): string { diff --git a/src/Core/Constants.php b/src/Core/Constants.php index edac54a0f..9455984fb 100644 --- a/src/Core/Constants.php +++ b/src/Core/Constants.php @@ -48,7 +48,9 @@ class Constants // BN Codes defined together with PayPal public const PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP = 'Oxid_Cart_Payments'; + // deprecated, we use only the PPCP-BN-Code since now 2023-11 public const PAYPAL_PARTNER_ATTRIBUTION_ID_EXPRESS = 'Oxid_Cart_PymtsShortcut'; + // deprecated, we use only the PPCP-BN-Code since now 2023-11 public const PAYPAL_PARTNER_ATTRIBUTION_ID_BANNER = 'oxid_Cart_Instbanners'; //SCA contingencies parameter diff --git a/src/Core/ViewConfig.php b/src/Core/ViewConfig.php index d5e4359e7..43e7643bd 100644 --- a/src/Core/ViewConfig.php +++ b/src/Core/ViewConfig.php @@ -293,7 +293,7 @@ public function getPayPalApiBannerUrl(): string */ public function getPayPalPartnerAttributionIdForBanner(): string { - return Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_BANNER; + return Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP; } /** diff --git a/src/Core/Webhook/Handler/CheckoutOrderApprovedHandler.php b/src/Core/Webhook/Handler/CheckoutOrderApprovedHandler.php index 77793a1b2..3aa004666 100644 --- a/src/Core/Webhook/Handler/CheckoutOrderApprovedHandler.php +++ b/src/Core/Webhook/Handler/CheckoutOrderApprovedHandler.php @@ -84,7 +84,13 @@ private function capturePayment(string $orderId): OrderResponse $service = $serviceFactory->getOrderService(); $request = new OrderCaptureRequest(); - return $service->capturePaymentForOrder('', $orderId, $request, ''); + return $service->capturePaymentForOrder( + '', + $orderId, + $request, + '', + Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP + ); } private function needsCapture(array $eventPayload): bool diff --git a/src/Service/Payment.php b/src/Service/Payment.php index f9bebd897..5309d188e 100644 --- a/src/Service/Payment.php +++ b/src/Service/Payment.php @@ -173,7 +173,7 @@ public function doCreatePatchedOrder( null, '', '', - '', + Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP, null, null, false @@ -211,7 +211,11 @@ public function doPatchPayPalOrder( // Update Order try { - $orderService->updateOrder($checkoutOrderId, $request); + $orderService->updateOrder( + $checkoutOrderId, + $request, + Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP + ); } catch (Exception $exception) { $this->moduleLogger->error("Error on order patch call.", [$exception]); throw $exception; @@ -247,7 +251,13 @@ public function doCapturePayPalOrder( // if order approved then authorize if ($payPalOrder->status === ApiOrderModel::STATUS_APPROVED) { $request = new OrderAuthorizeRequest(); - $payPalOrder = $orderService->authorizePaymentForOrder('', $checkoutOrderId, $request, ''); + $payPalOrder = $orderService->authorizePaymentForOrder( + '', + $checkoutOrderId, + $request, + '', + Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP + ); } /** @var AuthorizationWithAdditionalData $authorization */ @@ -260,7 +270,11 @@ public function doCapturePayPalOrder( + Constants::PAYPAL_AUTHORIZATION_VALIDITY; if ($timeAuthorizationValidity <= 0) { $reAuthorizeRequest = new ReauthorizeRequest(); - $paymentService->reauthorizeAuthorizedPayment($authorizationId, $reAuthorizeRequest); + $paymentService->reauthorizeAuthorizedPayment( + $authorizationId, + $reAuthorizeRequest, + Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP + ); } //track authorization @@ -276,8 +290,11 @@ public function doCapturePayPalOrder( // capture $request = new CaptureRequest(); try { - /** @var Capture $capture */ - $capture = $paymentService->captureAuthorizedPayment($authorizationId, $request, ''); + $paymentService->captureAuthorizedPayment( + $authorizationId, + $request, + Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP + ); } catch (ApiException $exception) { $this->handlePayPalApiError($exception); @@ -294,7 +311,13 @@ public function doCapturePayPalOrder( $request = new OrderCaptureRequest(); try { /** @var ApiOrderModel */ - $result = $orderService->capturePaymentForOrder('', $checkoutOrderId, $request, ''); + $result = $orderService->capturePaymentForOrder( + '', + $checkoutOrderId, + $request, + '', + Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP + ); } catch (ApiException $exception) { $this->handlePayPalApiError($exception); @@ -364,7 +387,8 @@ public function doConfirmUAPM( $response = $orderService->confirmTheOrder( $payPalClientMetadataId, $checkoutOrderId, - $request + $request, + Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP ); if (!isset($response->links)) {