Skip to content

Commit

Permalink
Merge pull request #235 from OXID-eSales/PSPAYPAL-726_Update_module
Browse files Browse the repository at this point in the history
Pspaypal 726 update module
  • Loading branch information
mariolorenz authored Dec 7, 2023
2 parents b6d9ed0 + 2314802 commit 00be00a
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
schedule:
- cron: '16 6 * * *'
push:
branches: [ b-6.5.x ]
branches: [ b-6.3.x ]
repository_dispatch:
types: [docker-build]

Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- first Version for OXID7 with APEX-Theme as Twig-Frontend-Standard-Theme, without Smarty-Support

## [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
- reduce transmitted BN Codes from three to one

## [2.3.2] - 2023-10-05

- [0007537](https://bugs.oxid-esales.com/view.php?id=7537): Show PayNow-Button on PP-Standard instead of Continue-Button
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.8
v1.0.9
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"giggsey/libphonenumber-for-php": "^8.12",
"viison/address-splitter": "^0.3.4",
"webmozart/path-util": "^2.3.0",
"oxid-solution-catalysts/paypal-client": "v3.0.8"
"oxid-solution-catalysts/paypal-client": "v3.0.9"
},
"require-dev": {
"codeception/module-rest": "^3.3.0",
Expand Down
3 changes: 2 additions & 1 deletion src/Controller/Admin/PayPalConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ private function buildSignUpLink(
$countryCode = strtoupper($lang->getLanguageAbbr());
$localeCode = $lang->getLanguageAbbr() . '-' . $countryCode;

$partnerLogoUrl = Registry::getConfig()->getOutUrl(null, true) . 'modules/' . Module::MODULE_ID. '/img/oxid_logo.png';
$partnerLogoUrl = Registry::getConfig()->getOutUrl(null, true)
. 'modules/' . Module::MODULE_ID . '/img/oxid_logo.png';
$returnToPartnerUrl = $config->getAdminUrlForJSCalls() .
'cl=oscpaypalconfig&fnc=returnFromSignup' .
'&isSandbox=' . ($isSandbox ? '1' : '0')
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 00be00a

Please sign in to comment.