Skip to content

Commit

Permalink
Merge pull request #231 from OXID-eSales/PSPAYPAL-724_BNCodes
Browse files Browse the repository at this point in the history
Use only one BM-Code everywhere
  • Loading branch information
rene-gust authored Nov 16, 2023
2 parents 96b5135 + b85eeb8 commit e56e0ae
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

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.9
v2.0.9
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 6 additions & 1 deletion src/Controller/Admin/PayPalOrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 1 addition & 6 deletions src/Controller/ProxyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function createOrder()
'',
'',
'',
$this->getPayPalPartnerAttributionId(),
Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP,
null,
null,
false,
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Core/ViewConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
8 changes: 7 additions & 1 deletion src/Core/Webhook/Handler/CheckoutOrderApprovedHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 32 additions & 8 deletions src/Service/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public function doCreatePatchedOrder(
null,
'',
'',
'',
Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP,
null,
null,
false
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand All @@ -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
Expand All @@ -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);

Expand All @@ -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);

Expand Down Expand Up @@ -364,7 +387,8 @@ public function doConfirmUAPM(
$response = $orderService->confirmTheOrder(
$payPalClientMetadataId,
$checkoutOrderId,
$request
$request,
Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP
);

if (!isset($response->links)) {
Expand Down

0 comments on commit e56e0ae

Please sign in to comment.