Showing results for 
Search instead for 
Did you mean: 

Integrating PayPal Plus with REST API

Integrating PayPal Plus with REST API


i need some help with the code by integrating PayPal Plus with REST API. I have read the PayPal PDF, but it don't work or i don't understand.

At the end, the customer shall select the pay method!


(If i redirect after the call to PayPal, then the pay method is PayPal.)


Here is my PayPal Plus method (is an modified example from paypal):

    public static function paypalplus()
        // Set clientId and secret

        $payer = new PayPal\Api\Payer();

        $item1 = new PayPal\Api\Item();
        $item1->setName('Ground Coffee 40 oz')
            ->setDescription('Ground Coffee 40 oz')

        $itemList = new PayPal\Api\ItemList();

        $details = new PayPal\Api\Details();

        $amount = new PayPal\Api\Amount();

        $transaction = new PayPal\Api\Transaction();
            ->setDescription("Payment description.");

        $baseUrl = '';
        $redirectUrls = new PayPal\Api\RedirectUrls();

        $payment = new PayPal\Api\Payment();

        $request = clone $payment;

        try {
            $result = $payment->create(self::$apiContext);
        } catch (Exception $ex) {
            echo 'Authorize a Payment';
            var_dump($payment->getId(), $ex);

        echo 'Authorize a Payment ID: ' . $payment->getId();
        echo "<br><br>";

        $redirectUrl = "";
        foreach ($payment->getLinks() as $link) {
            if ($link->getRel() == 'approval_url')
                $redirectUrl = $link->getHref();

        if (strlen($redirectUrl))
            echo '<a href="'.$redirectUrl.'">'.$redirectUrl.'</a>';

        // $transactions = $payment->getTransactions();
        // $relatedResources = $transactions[0]->getRelatedResources();

        // var_dump($result);
        // $authorization = $relatedResources[0]->getAuthorization();
        // var_dump($authorization);

In the same PHP Requet (after the method call), i output the PayPal JavaScript (IFrame):

<script src="" type="text/javascript"></script>

<div id="ppplus"> </div>
<script type="application/javascript">
    var ppp = PAYPAL.apps.PPP({
        "approvalUrl": "",
        "placeholder": "ppplus",
        "mode": "sandbox",
        "country": "DE"

The IFrame respond is: "Sorry, at the moment no payments can be processed for technical reasons".

Is it normal, or my code is wrong.





New Community Member

Re: Integrating PayPal Plus with REST API

Hi Konst,


I have the same problem. Take a look on the generated URL for the ppp.approvalUrl.


I see (in my case) a encoded URL like ";token=EC-...". The result was a iFrame like yours. After I decode the URL - it work.


OT: decode with JS ->


Viele Grüsse

Dirk Smiley Happy