dns_nx dns_nx - 1 year ago 203
Javascript Question

PayPal payment wall not rendered - Error "Invalid approval URL"

I'm integrating the

PayPal Plus
environment on our site. We are using the current version of
(1.7.4) available on Github https://github.com/paypal/PayPal-PHP-SDK. We are using
7.0.7 on

First we create a payment as explained in the integration guide. We receive a valid approval url from the payment (format:
I checked the url in the browser manually.

The payment is created in a controller and is given to the view.


function showPaymentWall() {
$payment = $this->createPayment();
return view("payments.paypal.paymentWall",['payment'=>$payment, 'approval_url'=> $this->approvalUrl]);

is set in the method

Here is the code from the view:

<div class="container">
<div class="row">
<div class="form-group col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div>{{ $approval_url }}</div>
<div id="ppplus"></div>


<script src="https://www.paypalobjects.com/webstatic/ppplus/ppplus.min.js" type="text/javascript"></script>
<script type="application/javascript">
var ppp = PAYPAL.apps.PPP({
"approvalUrl": "{{ $approval_url }}",
"placeholder": "ppplus",
"mode": "sandbox",
"country": "DE"

As you can see the valid url is displayed before the ppplus container. So that it is clear, that the url is valid and correctly given by the controller.
But when I visit the page, I always get this error:

enter image description here

When I check the reason via console it says "Invalid approval url".

enter image description here

Anybody an idea why or what I can check to get forward?
Thanks in advance for any help!

Answer Source

I found the reason after a long search.

It comes out, that the &amp; in the approval URL has to be replaced with &. Then it worked. Here is my code for the javascript part:

<script type="application/javascript">
             var ppp = PAYPAL.apps.PPP({
                "approvalUrl": "<?php echo htmlspecialchars_decode($approval_url); ?>",
                "placeholder": "ppplus",
                "mode": "sandbox",
                "country": "DE",
                "language": "de_DE"

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download