Integrating PayPal Plus with REST API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hallo,
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 self::loadPayment(); $payer = new PayPal\Api\Payer(); $payer->setPaymentMethod("paypal"); $item1 = new PayPal\Api\Item(); $item1->setName('Ground Coffee 40 oz') ->setDescription('Ground Coffee 40 oz') ->setCurrency('EUR') ->setQuantity(1) ->setTax(0.3) ->setPrice(7.50); $itemList = new PayPal\Api\ItemList(); $itemList->setItems(array($item1)); $details = new PayPal\Api\Details(); $details->setShipping(1.2) ->setTax(0.3) ->setSubtotal(7.5); $amount = new PayPal\Api\Amount(); $amount->setCurrency("EUR") ->setTotal(9) ->setDetails($details); $transaction = new PayPal\Api\Transaction(); $transaction->setAmount($amount) ->setItemList($itemList) ->setDescription("Payment description."); $baseUrl = 'http://mypage.com'; $redirectUrls = new PayPal\Api\RedirectUrls(); $redirectUrls->setReturnUrl("$baseUrl/ExecutePayment.php?success=true") ->setCancelUrl("$baseUrl/ExecutePayment.php?success=false"); $payment = new PayPal\Api\Payment(); $payment->setIntent("sale") ->setPayer($payer) ->setRedirectUrls($redirectUrls) ->setTransactions(array($transaction)); $request = clone $payment; try { $result = $payment->create(self::$apiContext); } catch (Exception $ex) { echo 'Authorize a Payment'; var_dump($payment->getId(), $ex); exit(1); } 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="https://www.paypalobjects.com/webstatic/ppplus/ppplus.min.js" type="text/javascript"></script> <div id="ppplus"> </div> <script type="application/javascript"> var ppp = PAYPAL.apps.PPP({ "approvalUrl": "http://beta.vintecture.com", "placeholder": "ppplus", "mode": "sandbox", "country": "DE" }); </script>
The IFrame respond is: "Sorry, at the moment no payments can be processed for technical reasons".
Is it normal, or my code is wrong.
Thanks
Konstantin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-...". The result was a iFrame like yours. After I decode the URL - it work.
OT: decode with JS -> https://stackoverflow.com/questions/1147359/how-to-decode-html-entities-using-jquery
Viele Grüsse
Dirk 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
any other solutions to the payment wall not displayed?
I've installed Paypal php SDK, ceated payment and "Sorry, at the moment no payments can be processed for technical reasons" is my only result.
cheers thomas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What is causing the problem? I have the same issue as described above
my javascriptcode for the payment-selection:
<script type="application/javascript"> var ppp = PAYPAL.apps.PPP({ "approvalUrl": "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-123465766655", "placeholder": "ppplus", "country": "DE", "mode":"sandbox", "payerEmail":"test_at_myMail.de", "payerFirstName":"my", "payerLastName":"name", "payerTaxId":"", "language":"de_DE", }); </script>
I got the approvialURL from the PHP-SDK
I get also JavaScript-Errors like
"Failed to load resource: the server responded with a status of 500 (Internal Server Error)" (by loading https://www.sandbox.paypal.com/inlinepaymentwall/payment-selection)
and
"Refused to set the document's base URI to 'https://www.paypalobjects.com/web/res/fb5/81d00dad305f2f71ed3fa5dc43f86' because it violates the following Content Security Policy directive: "base-uri 'self' https://*.paypal.com"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you find a solution? We are experiencing the same problem (base-uri error in "live" mode).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
did you read Niederbobi answer?
Did you set all setups to live mode? online at paypal and your code?
set display errors on (paypal (!) and / or php)
cheers
thomas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have the same Problem, on 2 separate instances (Wordpress and Shopware).
Any fixes?
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- Getting errors when integrating standard checkout with my web site. Probably a beginner problem. in SDKs
- Need help to integrate Advanced Checkout (PPCP) With WHMCS in PayPal Upgrade Community
- How can I integrate PayPal to enable direct tipping features between users on a content platform? in REST APIs
- Need help to integrate PayPal Checkout with Ecwid in PayPal Upgrade Community
- Recurring payment with credit card in REST APIs