diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e2129c7a..70b75b970 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [2.3.4] - 2024-??-?? + +- Transfer OXID-Ordernumber to PayPal + ## [2.3.3] - 2023-11-16 - [0007549](https://bugs.oxid-esales.com/view.php?id=7549): Optional field in shop admin -> refund "Note to buyer" is transmitted to PayPal diff --git a/metadata.php b/metadata.php index 2f1b91442..1dbe46ea8 100644 --- a/metadata.php +++ b/metadata.php @@ -56,7 +56,7 @@ 'en' => 'Use of the online payment service from PayPal. Documentation: PayPal Checkout' ], 'thumbnail' => 'out/img/paypal.png', - 'version' => '2.3.3', + 'version' => '2.3.4-rc.1', 'author' => 'OXID eSales AG', 'url' => 'https://www.oxid-esales.com', 'email' => 'info@oxid-esales.com', diff --git a/src/Controller/ProxyController.php b/src/Controller/ProxyController.php index c445ab995..9553b2502 100644 --- a/src/Controller/ProxyController.php +++ b/src/Controller/ProxyController.php @@ -60,12 +60,12 @@ public function createOrder() null, '', '', - '', Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP, null, null, false, - false + false, + null ); if ($response->id) { diff --git a/src/Core/OrderRequestFactory.php b/src/Core/OrderRequestFactory.php index dc46afb56..d3443e86e 100644 --- a/src/Core/OrderRequestFactory.php +++ b/src/Core/OrderRequestFactory.php @@ -66,7 +66,7 @@ class OrderRequestFactory * @param Basket $basket * @param string $intent Order::INTENT_CAPTURE or Order::INTENT_AUTHORIZE constant values * @param null|string $userAction USER_ACTION_CONTINUE constant values - * @param null|string $transactionId transaction id + * @param null|string $customId custom id reference * @param null|string $processingInstruction processing instruction * @param null|string $paymentSource Payment-Source Name * @param null|string $invoiceId custom invoice number @@ -81,7 +81,7 @@ public function getRequest( Basket $basket, string $intent, ?string $userAction = null, - ?string $transactionId = null, + ?string $customId = null, ?string $processingInstruction = null, ?string $paymentSource = null, ?string $invoiceId = null, @@ -98,7 +98,7 @@ public function getRequest( $request->payer = $this->getPayer(); } - $request->purchase_units = $this->getPurchaseUnits($transactionId, $invoiceId, $withArticles); + $request->purchase_units = $this->getPurchaseUnits($customId, $invoiceId, $withArticles); if ($userAction || $returnUrl || $cancelUrl) { $request->application_context = $this->getApplicationContext( diff --git a/src/Model/PaymentGateway.php b/src/Model/PaymentGateway.php index 16ac511c1..17cd1f6f7 100644 --- a/src/Model/PaymentGateway.php +++ b/src/Model/PaymentGateway.php @@ -100,6 +100,8 @@ protected function doExecutePuiPayment(EshopModelOrder $order): bool $success = false; try { + //order number must be resolved before requesting payment + $order->setOrderNumber(); $success = $paymentService->doExecutePuiPayment( $order, Registry::getSession()->getBasket(), diff --git a/src/Service/Payment.php b/src/Service/Payment.php index 5309d188e..79b991d88 100644 --- a/src/Service/Payment.php +++ b/src/Service/Payment.php @@ -109,12 +109,12 @@ public function doCreatePayPalOrder( string $processingInstruction = null, string $paymentSource = null, string $payPalClientMetadataId = '', - string $payPalRequestId = '', string $payPalPartnerAttributionId = '', string $returnUrl = null, string $cancelUrl = null, bool $withArticles = true, - bool $setProvidedAddress = true + bool $setProvidedAddress = true, + ?EshopModelOrder $order = null #): ?ApiModelOrder ) { //TODO return value @@ -127,7 +127,7 @@ public function doCreatePayPalOrder( $basket, $intent, $userAction, - null, + $order instanceof EshopModelOrder ? $order->getFieldData('oxordernr') : null, $processingInstruction, $paymentSource, null, @@ -145,7 +145,7 @@ public function doCreatePayPalOrder( $payPalPartnerAttributionId, $payPalClientMetadataId, 'return=minimal', - $payPalRequestId + $order instanceof EshopModelOrder ? $order->getId() : null ); } catch (ApiException $exception) { $this->moduleLogger->error("Api error on order create call. " . @@ -172,7 +172,6 @@ public function doCreatePatchedOrder( null, null, '', - '', Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP, null, null, @@ -309,8 +308,16 @@ public function doCapturePayPalOrder( $result = $this->fetchOrderFields($checkoutOrderId); } else { $request = new OrderCaptureRequest(); + //order number must be resolved before order patching + $order->setOrderNumber(); try { - /** @var ApiOrderModel */ + //Patching the order with OXID order number as custom value + $this->doPatchPayPalOrder( + Registry::getSession()->getBasket(), + $checkoutOrderId, + $order->getFieldData('oxordernr') + ); + /** @var $result ApiOrderModel */ $result = $orderService->capturePaymentForOrder( '', $checkoutOrderId, @@ -345,7 +352,6 @@ public function doCapturePayPalOrder( ); if ($result instanceof Order && $order->isPayPalOrderCompleted($result)) { - $order->setOrderNumber(); $order->markOrderPaid(); $order->setTransId((string)$payPalTransactionId); } @@ -530,7 +536,6 @@ public function doExecuteStandardPayment( null, null, '', - '', Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP, $returnUrl, $cancelUrl, @@ -574,7 +579,6 @@ public function doCreateUAPMOrder(EshopModelBasket $basket): string null, null, '', - '', Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP, null, null, @@ -599,8 +603,12 @@ public function doExecutePuiPayment( Constants::PAYPAL_PUI_PROCESSING_INSTRUCTIONS, PayPalDefinitions::PUI_REQUEST_PAYMENT_SOURCE_NAME, $payPalClientMetadataId, - $order->getId(), - Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP + Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP, + null, + null, + true, + true, + $order ); $payPalOrderId = $result->id; } catch (UserPhoneException $e) {