Open scastel83 opened 4 years ago
Thank you for that, you help me a lot.
What about setting it from a param?
For example:
$apiContext->setConfig(
array(
# 'mode' => 'sandbox',
'mode' => Yii::$app->params['payPalMode'],
)
);
You can override the class like so if you still need to use composer:
Add this to web.php.
'PayPalRestApi' => [
'class'=> 'app\overrides\PaypalRestApiOverride',
'redirectUrl'=> 'products/make-payment',
]
It doesn't strictly have to be located here but just add
<?php
namespace app\overrides;
use bitcko\paypalrestapi\PayPalRestApi;
use PayPal\Api\Amount;
use PayPal\Api\Details;
use PayPal\Api\Item;
use PayPal\Api\ItemList;
use PayPal\Api\Payer;
use PayPal\Api\Payment;
use PayPal\Api\RedirectUrls;
use PayPal\Api\Transaction;
use PayPal\Api\PaymentExecution;
#add thi one it is new -------------------
use PayPal\Rest\ApiContext;
use PayPal\Exception\PayPalConnectionException;
use yii\helpers\Url;
use Yii;
class PaypalRestApiOverride extends PayPalRestApi{
// Copy all the class methods/variables from PayPalRestApi into here
}
Oh man, here is the fix : you will need to modify the file located in the vendor folder
File contents