1

I've integrated paypal plus on my site according to this tutorial https://www.paypalobjects.com/webstatic/de_DE/downloads/PayPal-PLUS-IntegrationGuide.pdf

all work pretty fine on sandbox mode, but when I try go to live, I've got an error Forbidden, when displaying payment wall. In firebug NetworkError: 403 Forbidden - https://www.paypal.com/paymentwall/payment-selection. It looks like this http://joxi.ru/VrwVoeMIKDg5QA

my php code for getting approval url

$apiContext = new \PayPal\Rest\ApiContext(
    new \PayPal\Auth\OAuthTokenCredential(
        Yii::app()->params['paypal']['ClientID'],     // ClientID
        Yii::app()->params['paypal']['ClientSecret']      // ClientSecret
    )
);

$apiContext->setConfig(
      array(
        'mode' => 'live',                        
      )
);  

$item1 = new \PayPal\Api\Item();
$item1->setName('Test item')
    ->setCurrency('USD')
    ->setQuantity(1)
    ->setPrice(1);

$itemList = new \PayPal\Api\ItemList();
$itemList->setItems(array($item1));

$payer = new \PayPal\Api\Payer();
$payer->setPaymentMethod('paypal');

$amount = new \PayPal\Api\Amount();
$amount->setCurrency('USD');
$amount->setTotal('1');

$transaction = new \PayPal\Api\Transaction();
$transaction->setAmount($amount);
$transaction->setItemList($itemList);
$transaction->setInvoiceNumber(uniqid());
$transaction->setDescription('Payment for fashion.com');

$host = 'http' . (isset($_SERVER['HTTPS']) ? 's' : '') . '://' . $_SERVER['HTTP_HOST'];

$redirectUrl = new \PayPal\Api\RedirectUrls();
$redirectUrl->setReturnUrl($host . '/shop/pay');
$redirectUrl->setCancelUrl($host . '/shop/pay');

$payment = new \PayPal\Api\Payment();
$payment->setIntent('sale');
$payment->setPayer($payer);
$payment->setRedirectUrls($redirectUrl);
$payment->setTransactions(array($transaction));

$payment = $payment->create($apiContext);

$approvalUrl = $payment->getApprovalLink();

Then I using it in js

    <script type="application/javascript" src="https://www.paypalobjects.com/webstatic/ppplus/ppplus.min.js"></script>
<script>
    PAYPAL.apps.PPP({
        "approvalUrl": "<?=$approvalUrl?>",
        "placeholder": "ppplus",
        "mode": "live",
        "country": "DE",
        "buttonLocation": "outside",
        "disableContinue": "continueButton",
        "enableContinue": "continueButton",
        "showLoadingIndicator": true,
        onContinue: function () {
        }
    });
</script>
<div id="ppplus"></div>

Paypal header in response

Paypal-Debug-Id:    bfd9325f785dd, bfd9325f785dd

Our client told us that he got in touch with the paypal and activate his account for paypal plus. Maybe we had some errors in out code? Or maybe we are trying to do this in a country that restricted for paypal?

Update

I use live credentials. And in request to the www.paypal.com/paymentwall/payment-selection there is User-Agent header -

User-Agent  
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0

And I'm using standart paypal api https://github.com/paypal/PayPal-PHP-SDK

sam3434
  • 121
  • 1
  • 4
  • Possible duplicate of [Why do I keep getting a 403 forbidden with PayPal?](http://stackoverflow.com/questions/26013941/why-do-i-keep-getting-a-403-forbidden-with-paypal) – Ionut Necula Apr 27 '16 at 10:09
  • @lonut necula I guess it's not duplicated. It's a different case. Currently, I am facing the same issue. The link you are referring to is different than this issue. – tisuchi Oct 22 '20 at 04:36
  • @sam3434 btw, how did you overcome the issue? Was that working? – tisuchi Oct 22 '20 at 04:40

1 Answers1

-3

Change your code from:

$apiContext->setConfig(
  array(
    'mode' => 'live',                        
  )
);

To:

$apiContext->setConfig(
  array(
    'mode' => 'live'                      
  )
); 

Note: After 'live' no COMMA

rocambille
  • 15,398
  • 12
  • 50
  • 68