Skip to content

Commit

Permalink
refs #48852 MX/BR displaying paypal button
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan202 committed Nov 29, 2024
1 parent 80bc1d4 commit 1b0fadf
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 23 deletions.
2 changes: 1 addition & 1 deletion classes/MethodEC.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function getConfig(PayPal $module)
public function logOut($sandbox = null)
{
if ($sandbox == null) {
$mode = Configuration::get('PAYPAL_SANDBOX') ? 'SANDBOX' : 'LIVE';
$mode = $this->isSandbox() ? 'SANDBOX' : 'LIVE';
} else {
$mode = (int) $sandbox ? 'SANDBOX' : 'LIVE';
}
Expand Down
2 changes: 1 addition & 1 deletion classes/MethodMB.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function setParameters($values)
public function logOut($sandbox = null)
{
if ($sandbox == null) {
$mode = Configuration::get('PAYPAL_SANDBOX') ? 'SANDBOX' : 'LIVE';
$mode = $this->isSandbox() ? 'SANDBOX' : 'LIVE';
} else {
$mode = (int) $sandbox ? 'SANDBOX' : 'LIVE';
}
Expand Down
2 changes: 1 addition & 1 deletion classes/MethodPPP.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function setParameters($values)
public function logOut($sandbox = null)
{
if ($sandbox == null) {
$mode = Configuration::get('PAYPAL_SANDBOX') ? 'SANDBOX' : 'LIVE';
$mode = $this->isSandbox() ? 'SANDBOX' : 'LIVE';
} else {
$mode = (int) $sandbox ? 'SANDBOX' : 'LIVE';
}
Expand Down
6 changes: 0 additions & 6 deletions classes/Shortcut/ShortcutPaymentStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
namespace PaypalAddons\classes\Shortcut;

use Configuration;
use MethodMB;
use PaypalAddons\classes\AbstractMethodPaypal;
use PaypalAddons\classes\Constants\PaypalConfigurations;
use Tools;

Expand All @@ -42,10 +40,6 @@ class ShortcutPaymentStep extends ShortcutAbstract
public function __construct()
{
parent::__construct();

if ($this->method instanceof MethodMB) {
$this->method = AbstractMethodPaypal::load('EC');
}
}

public function getTemplatePath()
Expand Down
8 changes: 4 additions & 4 deletions controllers/front/mbValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ public function init()
public function postProcess()
{
$paypal = Module::getInstanceByName($this->name);
$payemtData = json_decode(Tools::getValue('paymentData'));
$this->method->setPaymentId($payemtData->paymentId);
$this->method->setPayerId($payemtData->result->payer->payer_info->payer_id);
$this->method->setRememberedCards($payemtData->result->rememberedCards);
$paymentData = $this->parsePaymentData(Tools::getValue('paymentData'));
$this->method->setPaymentId($paymentData->getPaymentID());
$this->method->setPayerId($paymentData->getPaymentID());
$this->method->setRememberedCards($paymentData->getRememberedCards());

try {
$this->method->validation();
Expand Down
49 changes: 39 additions & 10 deletions services/PaymentData.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,42 +34,57 @@
class PaymentData
{
/** @var string */
protected $orderId;
protected $orderId = '';

/** @var string */
protected $payerID;
protected $payerID = '';

/** @var string */
protected $paymentID;
protected $paymentID = '';

/** @var string */
protected $billingToken;
protected $billingToken = '';

/** @var string */
protected $facilitatorAccessToken;
protected $facilitatorAccessToken = '';

/** @var string */
protected $rememberedCards = '';

public function fromArray($data)
{
if (false == empty($data['orderID'])) {
if (false === empty($data['orderID'])) {
$this->setOrderId($data['orderID']);
}

if (false == empty($data['payerID'])) {
if (false === empty($data['payerID'])) {
$this->setPayerId($data['payerID']);
}

if (false == empty($data['paymentID'])) {
if (false === empty($data['paymentID'])) {
$this->setPaymentID($data['paymentID']);
}

if (false == empty($data['billingToken'])) {
if (false === empty($data['paymentId'])) {
$this->setPaymentID($data['paymentId']);
}

if (false === empty($data['billingToken'])) {
$this->setBillingToken($data['billingToken']);
}

if (false == empty($data['facilitatorAccessToken'])) {
if (false === empty($data['facilitatorAccessToken'])) {
$this->setFacilitatorAccessToken($data['facilitatorAccessToken']);
}

if (false === empty($data['result']['payer']['payer_info']['payer_id'])) {
$this->setPayerId($data['result']['payer']['payer_info']['payer_id']);
}

if (false === empty($data['result']['rememberedCards'])) {
$this->setRememberedCards($data['result']['rememberedCards']);
}

return $this;
}

Expand Down Expand Up @@ -118,6 +133,15 @@ protected function setFacilitatorAccessToken($facilitatorAccessToken)
return $this;
}

protected function setRememberedCards($rememberedCards)
{
if (is_string($rememberedCards)) {
$this->rememberedCards = $rememberedCards;
}

return $this;
}

/**
* @return string
*/
Expand Down Expand Up @@ -157,4 +181,9 @@ public function getFacilitatorAccessToken()
{
return $this->facilitatorAccessToken;
}

public function getRememberedCards()
{
return $this->rememberedCards;
}
}

0 comments on commit 1b0fadf

Please sign in to comment.