Skip to content

Commit 1b0fadf

Browse files
committed
refs #48852 MX/BR displaying paypal button
1 parent 80bc1d4 commit 1b0fadf

File tree

6 files changed

+46
-23
lines changed

6 files changed

+46
-23
lines changed

classes/MethodEC.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public function getConfig(PayPal $module)
137137
public function logOut($sandbox = null)
138138
{
139139
if ($sandbox == null) {
140-
$mode = Configuration::get('PAYPAL_SANDBOX') ? 'SANDBOX' : 'LIVE';
140+
$mode = $this->isSandbox() ? 'SANDBOX' : 'LIVE';
141141
} else {
142142
$mode = (int) $sandbox ? 'SANDBOX' : 'LIVE';
143143
}

classes/MethodMB.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function setParameters($values)
107107
public function logOut($sandbox = null)
108108
{
109109
if ($sandbox == null) {
110-
$mode = Configuration::get('PAYPAL_SANDBOX') ? 'SANDBOX' : 'LIVE';
110+
$mode = $this->isSandbox() ? 'SANDBOX' : 'LIVE';
111111
} else {
112112
$mode = (int) $sandbox ? 'SANDBOX' : 'LIVE';
113113
}

classes/MethodPPP.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function setParameters($values)
120120
public function logOut($sandbox = null)
121121
{
122122
if ($sandbox == null) {
123-
$mode = Configuration::get('PAYPAL_SANDBOX') ? 'SANDBOX' : 'LIVE';
123+
$mode = $this->isSandbox() ? 'SANDBOX' : 'LIVE';
124124
} else {
125125
$mode = (int) $sandbox ? 'SANDBOX' : 'LIVE';
126126
}

classes/Shortcut/ShortcutPaymentStep.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
namespace PaypalAddons\classes\Shortcut;
2929

3030
use Configuration;
31-
use MethodMB;
32-
use PaypalAddons\classes\AbstractMethodPaypal;
3331
use PaypalAddons\classes\Constants\PaypalConfigurations;
3432
use Tools;
3533

@@ -42,10 +40,6 @@ class ShortcutPaymentStep extends ShortcutAbstract
4240
public function __construct()
4341
{
4442
parent::__construct();
45-
46-
if ($this->method instanceof MethodMB) {
47-
$this->method = AbstractMethodPaypal::load('EC');
48-
}
4943
}
5044

5145
public function getTemplatePath()

controllers/front/mbValidation.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ public function init()
5252
public function postProcess()
5353
{
5454
$paypal = Module::getInstanceByName($this->name);
55-
$payemtData = json_decode(Tools::getValue('paymentData'));
56-
$this->method->setPaymentId($payemtData->paymentId);
57-
$this->method->setPayerId($payemtData->result->payer->payer_info->payer_id);
58-
$this->method->setRememberedCards($payemtData->result->rememberedCards);
55+
$paymentData = $this->parsePaymentData(Tools::getValue('paymentData'));
56+
$this->method->setPaymentId($paymentData->getPaymentID());
57+
$this->method->setPayerId($paymentData->getPaymentID());
58+
$this->method->setRememberedCards($paymentData->getRememberedCards());
5959

6060
try {
6161
$this->method->validation();

services/PaymentData.php

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,42 +34,57 @@
3434
class PaymentData
3535
{
3636
/** @var string */
37-
protected $orderId;
37+
protected $orderId = '';
3838

3939
/** @var string */
40-
protected $payerID;
40+
protected $payerID = '';
4141

4242
/** @var string */
43-
protected $paymentID;
43+
protected $paymentID = '';
4444

4545
/** @var string */
46-
protected $billingToken;
46+
protected $billingToken = '';
4747

4848
/** @var string */
49-
protected $facilitatorAccessToken;
49+
protected $facilitatorAccessToken = '';
50+
51+
/** @var string */
52+
protected $rememberedCards = '';
5053

5154
public function fromArray($data)
5255
{
53-
if (false == empty($data['orderID'])) {
56+
if (false === empty($data['orderID'])) {
5457
$this->setOrderId($data['orderID']);
5558
}
5659

57-
if (false == empty($data['payerID'])) {
60+
if (false === empty($data['payerID'])) {
5861
$this->setPayerId($data['payerID']);
5962
}
6063

61-
if (false == empty($data['paymentID'])) {
64+
if (false === empty($data['paymentID'])) {
6265
$this->setPaymentID($data['paymentID']);
6366
}
6467

65-
if (false == empty($data['billingToken'])) {
68+
if (false === empty($data['paymentId'])) {
69+
$this->setPaymentID($data['paymentId']);
70+
}
71+
72+
if (false === empty($data['billingToken'])) {
6673
$this->setBillingToken($data['billingToken']);
6774
}
6875

69-
if (false == empty($data['facilitatorAccessToken'])) {
76+
if (false === empty($data['facilitatorAccessToken'])) {
7077
$this->setFacilitatorAccessToken($data['facilitatorAccessToken']);
7178
}
7279

80+
if (false === empty($data['result']['payer']['payer_info']['payer_id'])) {
81+
$this->setPayerId($data['result']['payer']['payer_info']['payer_id']);
82+
}
83+
84+
if (false === empty($data['result']['rememberedCards'])) {
85+
$this->setRememberedCards($data['result']['rememberedCards']);
86+
}
87+
7388
return $this;
7489
}
7590

@@ -118,6 +133,15 @@ protected function setFacilitatorAccessToken($facilitatorAccessToken)
118133
return $this;
119134
}
120135

136+
protected function setRememberedCards($rememberedCards)
137+
{
138+
if (is_string($rememberedCards)) {
139+
$this->rememberedCards = $rememberedCards;
140+
}
141+
142+
return $this;
143+
}
144+
121145
/**
122146
* @return string
123147
*/
@@ -157,4 +181,9 @@ public function getFacilitatorAccessToken()
157181
{
158182
return $this->facilitatorAccessToken;
159183
}
184+
185+
public function getRememberedCards()
186+
{
187+
return $this->rememberedCards;
188+
}
160189
}

0 commit comments

Comments
 (0)