Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

PHP-added javascript for mobile saving of Local Storage

Check for parent window and save directly if no parent exists.  This is
due to mobile not using the lightbox.
  • Loading branch information...
commit fc263392f5b3ff2c129fe88ccaf9d860e66fe6ec 1 parent a958394
Sidney Maestre SidneyAllen authored
Showing with 34 additions and 7 deletions.
  1. +1 −1  index.html
  2. +33 −6 server/php/success.php
2  index.html
View
@@ -8,7 +8,7 @@
<script>
//INITIALIZE SESSION WITH APPROPRIATE LANGUAGE
-pptransact.init('php',false);
+pptransact.init('php',true);
//CALL BILL FUNCTION TO INITIALIZE BILL
function bill(){
39 server/php/success.php
View
@@ -3,6 +3,9 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Thank you</title>
+<script src="https://www.paypalobjects.com/js/external/dg.js"></script>
+<script src="../../client/jquery-1.6.2.min.js" type="text/javascript"></script>
+<script src="../../client/pptransact.js"></script>
<?php
require_once("pptransact.php");
@@ -13,17 +16,41 @@
?>
<script>
-function closeFlow() {
- parent.pptransact.releaseDG(<?= json_encode($returnObj); ?>);
+
+function parentExists() {
+ return (parent.location == window.location)? false : true;
+}
+
+function closeFlow(param) {
+
+ pptransact.init('cf',true);
+
+ if(!parentExists()) {
+ var jsonData = $.parseJSON('<?= $returnObj ?>');
+ pptransact.saveToLocalStorage(jsonData.userId,<?= $returnObj ?>,null);
+
+ setTimeout ( forceCloseFlow, '3000' );
+
+ } else {
+ parent.pptransact.releaseDG(<?= $returnObj ?>);
+ }
+
+}
+
+function forceCloseFlow() {
+
+ //The page you want to redirect the user after successfully storing data in local storage.
+ window.location.href = '../../index.html';
+
}
</script>
</head>
-<body onload="closeFlow()">
-<div style="background-color:#FFF;height:700px;width:300px; border-radius:8px;padding:20px;">
- Thank you for the purchase!<br />
- <button id="close" onclick="closeFlow();">close</button>
+<body onload="closeFlow(false)">
+<div style="background-color:#FFF;height:400px;width:300px; border-radius:8px;padding:20px;">
+ Thank you for the purchase! You will automatically return to your site in 3 seconds.
+ <button id="close" onclick="forceCloseFlow();">return now</button>
</div>
</body>
</html>
Please sign in to comment.
Something went wrong with that request. Please try again.