Jump to content
Larry Ullman's Book Forums

Michael vdP

  • Content Count

  • Joined

  • Last visited

  • Days Won


Michael vdP last won the day on June 14 2013

Michael vdP had the most liked content!

Community Reputation

2 Neutral

About Michael vdP

  • Rank
  1. Hi Larry, Not a problem, just something I wanted to share with the forum: Someone at work pointed me to an open-source web analytics tool, that runs on your own server. I had never heard of it before and last night I installed on my server in a bit more than the 5 minutes it claims to need. It looks very promising and stores all the relevant data in your very own MySQL database. I expect it to be better than Google Analytics. This is their site: http://piwik.org/ Greetings from Ireland! Michael
  2. Yes, there is an errata page here http://www.larryullman.com/books/effortless-e-commerce-with-php-and-mysql/errata/
  3. Hi Stephen, Difficult to tell at this stage, which payment methods Stripe will offer in Ireland. It seems, it will at least be Mastercard and Visa but I hope, they will add other methods as soon as they get past the beta stage, especially the debit card of Irish choice: Laser. On their Help page, Ireland isn't mentioned yet: https://support.stripe.com/questions/what-types-of-payments-can-i-accept-with-stripe. Regards, Michael
  4. Hi all, I had checked out https://stripe.com but as I live in Ireland, I couldn't use it. Still, Stripe offered the opportunity to sign up for an alert for when they would be available. True to their word, they sent me an email today and invited me to take part in their "private beta". I am already impressed with them! Thanks, by the way, Larry, for your excellent introduction to Stripe: http://www.larryullman.com/2012/11/07/creating-a-stripe-payments-test-account/ Greetings from the Emerald Island! Michael
  5. Hi Sean and Larry, PayPal has made some changes to the Sandbox in the last week. I ran into the same issue yesterday when code that worked previously, suddenly broke. PayPal is apparently preparing to move to PHP5.2 with cURL and have updated their sample code (https://www.x.com/developers/PayPal/documentation-tools/code-sample/216623). These changes don't have impacted the "real" PayPal yet. You can find comments about this unexpected change on several sites (e.g., http://stackoverflow.com/questions/11810344/paypal-ipn-bad-request-400-error) I got everything working again by adding $header .= "Host: www.sandbox.paypal.com\r\n" but it has to come AFTER the POST: $header = "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Host: www.sandbox.paypal.com\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; fputs ($fp, $header . $req); It is also important not to change to HTTP/1.1, otherwise you get those empty or 0 responses. By retaining HTTP/1.0, you will get "Received: VERIFIED" at the end of the response again so it can be nicely used as a trigger. Larry, you may have to update your book and the downloadable code with this change. But with that new desk of yours, that shouldn't be a problem ;-) Greetings from Ireland! Michael
  6. Hi all, I came across a very nice bit of jQuery -courtesy of the SpaceNinja (??)- that integrates perfectly with the second example on this site: http://spaceninja.com/2010/02/jquery-slide-down-language-selector You will have to add this in the footer.hmtl file: <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript" charset="utf-8"></script> <script> // scroll the page to display the languages $('#util-int').toggle(function() { $("#util-regions").remove().prependTo("#header").slideToggle('swing'); }, function() { $("#util-regions").slideToggle('swing'); }); </script> Then include the following in the <ul class="top-links"> on the header.html page: <ul class="top-links" id="utilities"> <li><a href="/index.php" class="first"><img alt="" src="/images/icon-home.gif" /></a></li> <li><a href="/cart.php"><img alt="" src="/images/icon-cart.gif" /></a></li> <li><a href="/contact.php"><img alt="" src="/images/icon-mail.gif" /></a></li> <li><a href="/sitemap.php"><img alt="" src="/images/icon-map.gif" /></a></li> <li id="util-int"><a href="#">International</a> <div id="util-regions"> <h4>Select your language</h4> <ul> <li><a href="http://www.mysite.com">English</a></li> <li><a href="http://www.mysite.es">español</a></li> <li><a href="http://www.mysite.de">deutsch</a></li> </ul> </div> </li> </ul> And finally, you make an addition to the style.css file #util-int { z-index: 1000; } #util-regions { display: none; /* hidden by default, will be shown by jQuery */ width: 948px; margin: 0 auto; height: 60px; position: relative; } #placeholder-regions { background: #666; } Of course, you may want to tweak the css but I like the way the page slides down and it looks a lot better than those flags. I hope, you find this useful. Regards, Michael
  7. First "Úll conference" in Dublin :-) http://www.irishtimes.com/newspaper/finance/2012/0430/1224315361556.html
  8. Hi Larry, Thanks for your helpful reply. Yes, I have been checking with various browsers and I can see how their difference in handling the HTTP_ACCEPT_LANGUAGE could cause trouble. I have tackled things differently, while still using the HTTP_ACCEPT_LANGUAGE header. I have invested in the following extensions for my domain: .com, .co.uk, .de, .es and .nl because I want my site to be in English, German, Spanish and Dutch. The language is primarily determined by the country extension but if there is a usable HTTP_ACCEPT_LANGUAGE header, it will be picked up with a simple IF statement, e.g.: $lang = getenv("HTTP_ACCEPT_LANGUAGE"); $set_lang = explode(',', $lang); IF (SUBSTR($set_lang[0],0,2)=='de' || $_SERVER['SERVER_NAME']=='www.mydomain.de' || $_SERVER['SERVER_NAME']=='mydomain.de') The resulting 'language_id' is then set as a cookie. I have used the concept for the "Message Board" in chapter 17 in your "PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)" book. One little difference: I have created a separate table for all language elements in each .php page (table 'index' for 'index.php', table 'shop' for 'shop.php', etc.) and the $words[] array is created at the start of each page with a pretty basic query: "SELECT * FROM `".SUBSTR(basename($_SERVER['PHP_SELF']),0,-4)."` WHERE language_id = {$_COOKIE['language_id']}" That seems to work very nicely because there is a lot more text than in your example. I am still testing (and translating text!) but I impressed how well that works. Thanks for all your guidance! I couldn't have done it without your help and books! Regards, Michael
  9. Hi Larry, But couldn't I use the "HTTP_ACCEPT_LANGUAGE" header to determine the browser's language? Or are there disadvantages to that approach? Of course, I would still offer the user the possibility to change the language to one of their preference. Regards, Michael
  10. Hi Larry, No to worry. It is working very nicely now and I am very happy with the new process (no values in the PayPal button, but passed on through HEADER() in 'gateway_process.php'). But as the user moves to the PayPal site, the sending of the confirmation email depends on his completing the process and returning to the 'final.php' on my site . If for some reason the user abandons that process after his payment, he won't receive the email. So at the moment, I am working on integrating email_receipt.php into the ipn.php file. That shouldn't be too difficult because PayPal returns the order_id that can be used in a stored procedure that runs a simple query: SELECT c.email FROM customers c, orders o, transactions t WHERE c.id=o.customer_id AND o.id=t.id AND t.id= [PayPal's returned order_id] Once that works, I am done! Regards, Michael
  11. BTW, the good thing from this approach is that all those important "hidden" values are no longer in the PayPal button and therefore not visible in the source code. Recently, there was a scam that affected third party sellers on Amazon: scammers used the seller email address to fool sellers into believing that Amazon had received payment from buyers and goods could be released!
  12. Hi all, I have the PayPal Website Payments Standard for the second example working. I have moved most of the values that have to be passed on to PayPal, to the 'gateway_setup.php' file: $data['cmd'] = '_xclick'; $data['business'] = 'seller@gmail.com'; $data['currency_code'] = 'EUR'; $data['button_subtype'] = 'services'; $data['no_note'] = '0'; $data['cn'] = 'Add special instructions to seller'; $data['no_shipping'] = '1'; $data['rm'] = '1'; $data['return'] = 'https://mysite.com/final.php'; $data['cancel_return'] = 'https://mysitecom/cart.php'; $data['bn'] = 'PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted'; $data['address_override'] = '0'; $data['item_name'] = 'Invoice # '.$customer_id; $data['email'] = $_SESSION['email']; $data['first_name'] = $cc_first_name; $data['last_name'] = $cc_last_name; $data['address1'] = $cc_address; $data['city'] = $cc_city; $data['zip'] = $cc_zip; $data['country'] = $cc_state; to the gateway_setup.php file In gateway_process.php, the variable values are established: $data['amount'] = $order_total - $_SESSION['shipping']; $data['shipping'] = $_SESSION['shipping']; $data['custom'] = $customer_id; $data['invoice'] = $_SESSION['order_id']; And in the same file, HEADER() redirects the user to PayPal's site while passing on the information to PayPal: // Convert the data: $post_string = ''; foreach( $data as $k => $v ) { $post_string .= "$k=" . urlencode($v) . "&"; } $post_string = rtrim($post_string, '& '); header("location:https://www.sandbox.paypal.com/cgi-bin/webscr?".$post_string); Finally, I am using the extended ipn.php file to retrieve PayPal's response and add it to the 'transactions' table. That requires minor change to the table and the stored procedure ('CALL add_transaction') because the response values from PayPal are slightly different from the one Authorize returns, mainly I had to change 'tid' from BIGINT to VARCHAR(20). Of course, the flow for the second example is now a bit different so there is some work left. I think, I will have to add a check for the PayPal response to the final.php so a value can be assigned to '$_SESSION['response_code']' there instead of on the 'billing.php' page. Almost there, almost! :-) Regards , Michael
  13. Hi Larry, Or let me rephrase the issue: how can I use something like the 'gateway_process.php' file to submit the POST to PayPal and to re-direct the user to PayPal's site, while 'billing.php' does the POST that calls the stored procedure and inserts the order into the 'order' and 'order_contents' tables? Using 'gateway_process.php' would have the added benefit of hiding all those values (including my PayPal ID or seller email) from prying eyes. I have only a vague understanding of cURL, maybe a cURL session could accomplish that. Obviously, I also have to retrieve PayPal's response (your ipn script in the 1st example) so the 'transaction' table can be updated. I hope, I have explained things clearly! Kind regards, Michael
  14. Hi Larry, Yeah, that issue is still open for me ;-( How can I POST the two forms in billing.php? It took me a while to figure out how to pass values to PayPal and I got that working. I thought, I'd share that on this forum because it is so simple to accomplish but nowhere is it explained on PayPal's help pages. But now with the button, the call to the stored procedure is being bypassed so there are no values for 'order_total' and 'order_id'. Somehow, I have a feeling that the jQuery script can do that but I don't see how (yet). Any help/suggestions are most welcome! Yes, Ireland is a beautiful place, especially Kerry, Clare (Cliffs of Moher!) and Galway. I live in Cork which calls itself "the real capital". I hope, you get to make that second trip! Kind regards, Michael
  • Create New...