paypal in-context checkout reverts back to classic express checkout - paypal

I've been trying to switch over our classic express checkout to in-context express checkout.
As instructed, I've switched the URL to https://www.paypal.com/checkoutnow/
This is the HTML snippet in the cart:
<div class="col-md-6">
<a id="paypalcheckout" href="paypal_checkout/PostToPaypal.cfm?orderidentifier=XXXX">
<img class="paypal-button-hidden" src="/img/paypal.png" alt="" class="img-responsive center-block"/>
</a>
</div>
<script>
window.paypalCheckoutReady = function() {
paypal.checkout.setup("ZZZZ", {locale: 'en_US', environment: 'sandbox', button: ['paypalcheckout']});
}
</script>
<script async src="//www.paypalobjects.com/api/checkout.js"></script>
PostToPaypal.cfm makes the necessary api requests and gets back the EC-code and then redirects to this link:
https://www.sandbox.paypal.com/checkoutnow/2?incontext=1&token=EC-YYYY
The click results in a pop up window with the main window going dark. But after a few seconds, the pop up window makes the main page go to classic checkout and closes. It's letting me continue and checkout successfully with the old method. So I know the EC number is correct. Can anyone help me understand what I need to do to make in-context checkout work? Thank you in advance.

I had the exact same problem.
The solution turned out to be in the server-side settings.
In the paypalfunctions.php file (which PayPal itself generated for me), there are a couple of lines that you need to remove, ones pertaining to it being a digital item.
Look for a similar line:
$nvpstr .= "&L_PAYMENTREQUEST_0_ITEMCATEGORY" . $index . "=Digital";
It might be repeated several times.
Basically, the Digital Goods are not allowed through the in-context checkout, which is why I was getting the redirect issue.

For me the issue was the CALLBACK param when getting transaction id. When I removed it, it worked.

I have the same issue with LANDINGPAGE set to Billing.
In that particular case sandbox reverts to classic express checkout version.
In production both Billing and Login values for LANDINGPAGE parameter result in a correct popup window.

I had to remove these parameters to get it to work
FlatRateShippingOptions
cppHeaderImage
CallbackURL
CallbackTimeout

Related

How to fix a Paypal CRYPTOSERV_SERVER_ERROR

I've been using Paypal's payment standard with dynamically encrypted buttons for successfully for several years. It suddenly stopped working on 19/05/2022.
When a customer clicks on the payment button they're taken to Paypal and are shown the error page with the 'helpful' message "Things don't appear to be working at the moment. Please try again later.". The headers served by Paypal along with this page include code=CRYPTOSERV_SERVER_ERROR, which I've googled and there are no results. All certificates are still valid.
Does anyone have a clue what this error means?
The May 19th mysterious PayPal error solved by a combination of trimming white space and removing line breaks worked for me. No thanks to PayPal CS who never got back to me after a week of shop being down!
$encryptedButton = str_replace("\n", "", $encryptedButton);
$encryptedButton = trim($encryptedButton);
Same problem here. Still no resolution from PayPal after I reported that 5 days ago.
What I found in my page source is that the encrypted field's value was "split" with new lines, for better readability, like this:
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----
MIIIoQYJKoZIhvcNAQcDoIIIkjCCCI4CAQAxggEwMIIBLAIBADCBlDCBjjELMAkG
A1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQw
EgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UE
...
I removed the new lines with this simple step:
$encryptedButton = str_replace("\n", "", $encryptedButton);
And now the button seems to work again.
<input type="hidden" name="encrypted" value="$encryptedText" />
Make sure to add: $encryptedText = str_replace("\n", "", $encryptedText); so that extra spaces are removed.

Has anybody gotten PAYMENTREQUEST_0_DESC to work in the PayPal API?

I am passing my PayPal API call like this:
&METHOD=SetExpressCheckout
&RETURNURL=''
&CANCELURL=''
&PAYMENTREQUEST_0_PAYMENTACTION='SALE'
&PAYMENTREQUEST_0_NOTIFYURL=''
&BRANDNAME=''
&NOSHIPPING=0
&PAYMENTREQUEST_0_CURRENCYCODE=''
&LOCALECODE=US
&LOGOIMG=''
&CARTBORDERCOLOR=''
&ALLOWNOTE=0';
&PAYMENTREQUEST_0_CUSTOM=''
&PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID=''
&L_PAYMENTREQUEST_0_NAME1=''
&L_PAYMENTREQUEST_0_AMT1=''
'&L_PAYMENTREQUEST_0_QTY1=''
&PAYMENTREQUEST_0_ITEMAMT=''
&PAYMENTREQUEST_0_SHIPPINGAMT=''
&PAYMENTREQUEST_0_AMT=''
and obviously I am including the:
'&PAYMENTREQUEST_0_DESC='.urlencode($desc).
where $desc = "Payment made from My Website";
But it's not showing anywhere in the confirmation emails that PayPal sends. Neither in the sandbox nor in the live version.
Has anyone gotten this to work successfully?
If you don't include items information, this parameter will show on PayPal checkout page.
I found a way to do it.
It's with: '&PAYMENTREQUEST_0_NOTETEXT='.urlencode($desc).

hello.js not in AngularJS web app not working on iPhones and Blackberry Z10s

I have a login system that works for most people (on Chrome, Android devices, IE8, Firefox, etc), but it seems not to work for people with Z10s or iPhone 5s. I don't have access to these devices so it's difficult to test, so I wanted to ask whether I was setting up everything properly.
It's an AngularJS app, using hello.js for OAuth, and bootstrap-social and font-awesome for the sign in buttons.
To insert hello into Angular, in app.js I include:
var app = angular
.module('myapp', [
'ui.bootstrap',
'ui.router',
'hello',
])
...
.run([..., 'hello', ..., function(..., hello, ...) {
...
hello.init(...);
...
}]);
...
var helloApp = angular.module('hello', []);
helloApp.factory('hello', function() {
return window.hello; // Assumes hello has been loaded
});
Then, in my loginCtrl, I inject it with
angular.module('myapp').controller('loginCtrl', [..., 'hello', ...,
function(..., hello, $location, ...) {
...
$scope.doLogin = function(network) {
console.log('Calling hello ' + network);
hello.login(network);
};
...
}]);
And in my view, I have
<button id="facebookLogin" class="btn btn-social btn-facebook" ng-click="doLogin('facebook')">
<span class="fa fa-facebook pull-left"></span> <span>Sign in with Facebook</span>
</button>
<button id="googleLogin" class="btn btn-social btn-google-plus" ng-click="doLogin('google')">
<span class="fa fa-google-plus pull-left"></span> <span>Sign in with Google</span>
</button>
Yesterday I was using onclick="hello.login('facebook')", and I suspected that was breaking on certain devices because I shouldn't be using onclick and hello wasn't in scope, so that's why I changed it to ngClick and calling a function in scope. The specific effect of onclick on the users who had errors was to redirect the user to the default/catch-all route without accessing the server at all (I listen for hello events and call the server, so this suggests it wasn't calling hello at all.)
But still, I ask the people who are having issues to re-try (after refreshing obviously), and now they say the button simply does nothing.
Other buttons on the site work. In fact, to get to this page, they use a <button> that uses ui-router to get to this page.
I'm going to continue to search, but I just wanted to ask if I seemed to be hooking hello.js into AngularJS properly, and not making any other beginner mistakes.
I believe the problem is that iPhones and Z10s were blocking hello.js's popup OAuth authentication, but I couldn't just switch it to use page.
When I tried, Facebook returns me to my redirect_url with the fragment
#access_token=....&expires_in=4264&state={%22client_id%22%3A%22164986300332415%22%2C%22network%22%3A%22facebook%22%2C%22display%22%3A%22page%22%2C%22callback%22%3A%22_hellojs_3ojn1yy8%22%2C%22state%22%3A%22%22%2C%22oauth_proxy%22%3A%22https%3A%2F%2Fauth-server.herokuapp.com%2Fproxy%22%2C%22scope%22%3A%22basic%22%2C%22oauth%22%3A{%22version%22%3A2%2C%22auth%22%3A%22https%3A%2F%2Fwww.facebook.com%2Fdialog%2Foauth%2F%22}}
it's ugly, but the point is it starts with a hash tag. So, while hello.js can normally read this, it couldn't in this case because Angular would mangle the address immediately. I'm not sure if this is because I specify to use hash-bangs instead of hash's, but it was.
And I couldn't send this to a PHP script or anything because the fragment after the hashtag would never make it to the PHP script.
So, my solution was to point the redirect_url at an independent page that has hello.js on it, but no Angular. It saves stuff to window.sessionStorage and redirects the user back to the login page, where hello.js passes the user through.
I'm not very confident in this ugly approach yet, so I put a browser sniffer to only do it for iPhones (and use popup for everyone else), I may remove this check in the future (because it's sketchy)
#matt it uses localstorage, not sessionstorage.
Use popup for all, and define a redirect_uri page with just hello.js In it. I dont know why you might think thats sounds wrong. All the demos do it this way. It also gives you a chance to display a nifty loading screen.
Sorry about the ugly fragment. It communcates a lot of state parameters which is used for the oauth proxy... most endpoints like facebook dont need it, so I might refactor that to make it a little less daunting.

How to use IPN/PDT to display receipt and digital and/or downloadable products after purchase and redirection with PayPal

I have a webshop: energyshop.se which I have successfully managed to setup a Sandbox account at PayPal and to create a Buyer and a Seller account, created a button which I implemented to my site (from the Seller account) and I manage to make a payment through my Buyer account and got redirection to work too, to energyshop.se/tack.
So far so good, now I wonder how do I reach the "product ID" that IPN/PDT sends when the user is redirected? How do I use that holder to display files for download or just for play/listening? And what are the holders/variable that holds the receipt information? I would like to say for example when returned to /tack to display the receipt and then the downloadable item.
Any help is very welcome I have worked n this site for ages now and just want it done, it is for a customer too.
I tried to do something like this (i use wordpress at my thankyoupage):
<div id="receiptform">
<form method=post action="https://www.paypal.com/cgi-bin/webscr">
<input type="hidden" name="cmd" value="_notify-synch">
<input type="hidden" name="tx" value="TransactionID">
<input type="hidden" name="at" value="P0d7_HmQSAuXh9r-7hG1Rzf_npI2LaFgYHQJyWUsjQHg7WhZARqs3sq6IW4">
<input type="submit" value="PDT">
</form>
</div>
But that just displays a button PDT that when clicked displyas FAIL ERROR: 4002
How do I edit this to just display the content nicely in tx?
Also, I can tell that "its" working because in the address field, when redirected to thank-you-page this reads: http://energyshop.se/tack/?tx=9LJ24270G46097059&st=Completed&amt=10.00&cc=USD&cm=&item_number=1 which leads me to think its A) completed and B) got the info I need. Now is the question how i present this data? What am I supposed to do? A php-script that I...? I cant seem to find any examples on it, just the defnition of the variables for IPN/PDT but that doesnt help me if I dont know where to put or do with it...
You would want to use PDT as you are. When you receive the tx variable and etc back, you have to do a post back to PayPal to verify all of the inforamtion. Then once you have varified the post, PayPal will then send all of the variables back to your script. You can find a bit more on how PDT works at https://www.x.com/developers/paypal/documentation-tools/ipn/integration-guide/IPNPDTAnAlternativetoIPN. There are also some sample scripts on that site as well at https://www.x.com/developers/PayPal/documentation-tools/code-sample/216627 and https://paypaltech.com/PDTGen/

Display users's email after purchase with Paypal Website Payments Standard

I have a simple button created with Paypal's Website Payments Standard, and I'm using the feature "Take customers to this URL when they finish checkout".
On that page which users are being redirected to when the purchase is successful (on my site) I'd like to simply display the email associated with their paypal purchase, telling them something like "an invoice will be sent to this email address: xxx".
Is that possible without using the API or IPN (which I'd rather avoid because it seems like I can't set different IPN urls for deifferent buttons/products.)
Ended up using PDT, there's a great example of how to simply do this here:
http://www.geekality.net/2010/10/19/php-tutorial-paypal-payment-data-transfers-pdt/
Thanks PP_MTS_Chad, I wouldn't have found it if it wasn't for you pointing out that option.
You could use 1 of 2 ways to get information back to your return URL, without having to use IPN or an API. You could use PDT to return information back to your site, or you could use the return method which uses the variable "rm". You can find more out about IPN here, and there are also some sample scripts you can use on that site as well.
If you want to use the return method, this is a little different from PDT. With the return method you do not have to post the information back to PayPal to verify it. If you wanted PayPal to post the information over to your return page you would just simply enable auto return in your account under your profile. Then you would just include the following lines of code in your button code.
<input type="hidden" name="rm" value="2">
<input type="hidden" name="return" value="http://www.mysite.com/return.php">
The variable "rm", controls how you want the information sent back to you. You can set it to be a GET or a POST.
Allowable values are:
0 – all shopping cart payments use the GET method
1 – the buyer's browser is redirected to the return URL by using the GET method, but no payment variables are included
2 – the buyer's browser is redirected to the return URL by using the POST method, and all payment variables are included
The default is 0.
Note: The rm variable takes effect only if the return variable is set.