Skip to content

Commit

Permalink
refs #49333 authorize mode for mx/br
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan202 committed Dec 10, 2024
1 parent 14fe751 commit d441322
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 16 deletions.
2 changes: 2 additions & 0 deletions classes/AbstractMethodPaypal.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@

abstract class AbstractMethodPaypal extends AbstractMethod
{
const AUTHORIZE = 'AUTHORIZE';
const SALE = 'CAPTURE';
/** @var bool */
protected $isSandbox;

Expand Down
4 changes: 0 additions & 4 deletions classes/MethodEC.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@
*/
class MethodEC extends AbstractMethodPaypal
{
const AUTHORIZE = 'AUTHORIZE';

const SALE = 'CAPTURE';

/** @var bool pay with card without pp account */
public $credit_card;

Expand Down
4 changes: 3 additions & 1 deletion classes/MethodMB.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,15 @@ public function validation()
*/
public function confirmCapture($orderPayPal)
{
return $this->paypalApiManager->getCaptureAuthorizeRequest($orderPayPal)->execute();
}

/**
* @see AbstractMethodPaypal::void()
*/
public function void($orderPayPal)
{
return $this->paypalApiManager->getAuthorizationVoidRequest($orderPayPal)->execute();
}

/**
Expand Down Expand Up @@ -454,7 +456,7 @@ public function getPaypalPartnerId()

public function getIntent()
{
return Configuration::get('PAYPAL_API_INTENT') == 'sale' ? 'CAPTURE' : 'AUTHORIZE';
return Configuration::get('PAYPAL_API_INTENT') == 'sale' ? self::SALE : self::AUTHORIZE;
}

public function getMerchantId()
Expand Down
2 changes: 1 addition & 1 deletion classes/MethodPPP.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public function getSecret($sandbox = null)

public function getIntent()
{
return 'CAPTURE';
return self::SALE;
}

public function getReturnUrl()
Expand Down
11 changes: 1 addition & 10 deletions services/StatusMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
use Configuration;
use MethodEC;
use MethodMB;
use MethodPPP;
use PaypalAddons\classes\AbstractMethodPaypal;
use PaypalAddons\classes\Constants\PaypalConfigurations;
use PaypalAddons\classes\Constants\WebHookType;
Expand Down Expand Up @@ -182,15 +181,7 @@ public function isModeSale($method = null)
$method = AbstractMethodPaypal::load();
}

if ($method instanceof MethodPPP) {
return true;
}

if ($method instanceof MethodMB) {
return true;
}

return Configuration::get('PAYPAL_API_INTENT') == 'sale';
return $method->getIntent() === AbstractMethodPaypal::SALE;
}

/**
Expand Down

0 comments on commit d441322

Please sign in to comment.