drumhrd Posted March 28, 2010 Share Posted March 28, 2010 Hello all, I am building my own shopping cart, attempting to use paypals DoDirectPayment which seems to work fine. What I need is a splash page or "please wait" status image. I have my payment form on page A and my processing page on page B. page B doesn't load until the response back from paypal is finished and the server sends the generated code. I would like to be able to display a "processing please wait" or something of the sort on my page B until I get the response back from paypal. I've tried sleep() funcitons or ob_start()...but couldn't get those to work so trashed the code. Link to comment https://forums.phpfreaks.com/topic/196795-splash-or-please-wait-until-page-load/ Share on other sites More sharing options...
mrMarcus Posted March 28, 2010 Share Posted March 28, 2010 how long does it take for you receive this response from paypal? i've worked with paypal a ton, and IPN responses from their servers take milliseconds. hardly enough time to shove a "please wait" message down the users throat. anyways, you could just use javascript with a hidden div tag and onclick to display a message when the user clicks the payment button or whatever. pretty simple. Link to comment https://forums.phpfreaks.com/topic/196795-splash-or-please-wait-until-page-load/#findComment-1033164 Share on other sites More sharing options...
drumhrd Posted March 28, 2010 Author Share Posted March 28, 2010 Right now I am not worried about IPN. I am using DoDirectPayment, which in my testing agaist the sandbox site, has taken up to 2 minutes for a response. In the meantime, the page just sits on the form page..once the reponse is recieved, the response page loads. I do not like that affect. I would like to show a Please wait message with an animated status GIF to show the user the page is actually doing something. Link to comment https://forums.phpfreaks.com/topic/196795-splash-or-please-wait-until-page-load/#findComment-1033168 Share on other sites More sharing options...
mrMarcus Posted March 28, 2010 Share Posted March 28, 2010 i would recommend getting that 2 minutes eliminated, 'cause no animated .gif in the world is going to keep me entertained for that long. your users are going to close the page after 30-60 seconds, let alone 2 minutes. why don't you ask Paypal why it takes so long for the processing. see if that's normal first, then worry about entertaining your users with redundant animations. just my opinion. you can also take heed to what i already suggested with the following: anyways' date=' you could just use javascript with a hidden div tag and onclick to display a message when the user clicks the payment button or whatever. pretty simple.[/quote'] Link to comment https://forums.phpfreaks.com/topic/196795-splash-or-please-wait-until-page-load/#findComment-1033169 Share on other sites More sharing options...
drumhrd Posted March 29, 2010 Author Share Posted March 29, 2010 TCPDUMP confirmed paypal is taking 30+ seconds to fully respond I see alot of initial info being passed, then a 30+ second pause before I get a final PUSH/ACK from paypal, then the connection closes. I am using a some cURL functions to execute this..maybe I am doing something wrong? Maybe I am not closing the connection properly or something. unforturnately, the Paypal API is only available via SSL so I cannot cURL clear text so I can decode the packets with wireshark to see what's going on. DoDirectPayment API $environment = 'sandbox'; // or 'beta-sandbox' or 'live' // Set request-specific fields. $paymentType = urlencode('Sale'); $firstName = urlencode($cc_info['cc']['cc_first_name']); $lastName = urlencode($cc_info['cc']['cc_last_name']); $creditCardType = urlencode($cc_info['cc']['cc_type']); $creditCardNumber = urlencode($cc_info['cc']['cc_num']); $expDateMonth = $cc_info['cc']['cc_month']; // Month must be padded with leading zero $padDateMonth = urlencode(str_pad($expDateMonth, 2, '0', STR_PAD_LEFT)); $expDateYear = urlencode($cc_info['cc']['cc_year']); $cvv2Number = urlencode($cc_info['cc']['cc_security']); $address1 = urlencode($cc_info['billing']['address']); $address2 = urlencode($cc_info['billing']['address2']); $city = urlencode($cc_info['billing']['city']); $state = urlencode($cc_info['billing']['state']); $zip = urlencode($cc_info['billing']['zip']); $country = urlencode($cc_info['billing']['country']); // US or other valid country code $amount = urlencode($_SESSION['Payment_Amount']); $currencyID = urlencode('USD'); // or other currency ('GBP', 'EUR', 'JPY', 'CAD', 'AUD') // Add request-specific fields to the request string. $nvpStr = "&PAYMENTACTION=$paymentType&AMT=$amount&CREDITCARDTYPE=$creditCardType&ACCT=$creditCardNumber". "&EXPDATE=$padDateMonth$expDateYear&CVV2=$cvv2Number&FIRSTNAME=$firstName&LASTNAME=$lastName". "&STREET=$address1&CITY=$city&STATE=$state&ZIP=$zip&COUNTRYCODE=$country&CURRENCYCODE=$currencyID"; // Execute the API operation; see the PPHttpPost function above. $httpParsedResponseAr = PPHttpPost('DoDirectPayment', $nvpStr); if("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) { if($httpParsedResponseAr["CVV2MATCH"] == "M"){ } exit('Direct Payment Completed Successfully: '.print_r($httpParsedResponseAr, true)); } else { exit('DoDirectPayment failed: ' . print_r($httpParsedResponseAr, true)); } } PPHttpPost function using cURL function PPHttpPost($methodName_, $nvpStr_) { global $environment; // Set up your API credentials, PayPal end point, and API version. $API_UserName = urlencode('secret'); $API_Password = urlencode('secret'); $API_Signature = urlencode(secret); $API_Endpoint = "https://api-3t.paypal.com/nvp"; if("sandbox" === $environment || "beta-sandbox" === $environment) { $API_Endpoint = "https://api-3t.$environment.paypal.com/nvp"; } $version = urlencode('51.0'); // Set the curl parameters. $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $API_Endpoint); curl_setopt($ch, CURLOPT_VERBOSE, 1); // Turn off the server and peer verification (TrustManager Concept). curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); // Set the API operation, version, and API signature in the request. $nvpreq = "METHOD=$methodName_&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature$nvpStr_"; // Set the request as a POST FIELD for curl. curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq); // Get response from the server. $httpResponse = curl_exec($ch); if(!$httpResponse) { exit("$methodName_ failed: ".curl_error($ch).'('.curl_errno($ch).')'); } // Extract the response details. $httpResponseAr = explode("&", $httpResponse); $httpParsedResponseAr = array(); foreach ($httpResponseAr as $i => $value) { $tmpAr = explode("=", $value); if(sizeof($tmpAr) > 1) { $httpParsedResponseAr[$tmpAr[0]] = $tmpAr[1]; } } if((0 == sizeof($httpParsedResponseAr)) || !array_key_exists('ACK', $httpParsedResponseAr)) { exit("Invalid HTTP Response for POST request($nvpreq) to $API_Endpoint."); } return $httpParsedResponseAr; } 23:43:32.391814 IP myhost.com.46058 > 216.113.191.88.https: S 1477130283:1477130283(0) win 5840 <mss 1460,sackOK,timestamp 330132343 0,nop,wscale 6> 23:43:32.430418 IP 216.113.191.88.https > myhost.com.46058: S 2478546518:2478546518(0) ack 1477130284 win 5792 <mss 1460,sackOK,timestamp 1321850687 330132343> 23:43:32.430439 IP myhost.com.46058 > 216.113.191.88.https: . ack 1 win 5840 <nop,nop,timestamp 330132352 1321850687> 23:43:32.431642 IP myhost.com.46058 > 216.113.191.88.https: P 1:128(127) ack 1 win 5840 <nop,nop,timestamp 330132353 1321850687> 23:43:32.431818 IP 216.113.191.88.https > myhost.com.46058: . ack 128 win 5792 <nop,nop,timestamp 1321850688 330132353> 23:43:32.481927 IP 216.113.191.88.https > myhost.com.46058: P 1:1341(1340) ack 128 win 5792 <nop,nop,timestamp 1321850738 330132353> 23:43:32.481944 IP myhost.com.46058 > 216.113.191.88.https: . ack 1341 win 8040 <nop,nop,timestamp 330132365 1321850738> 23:43:32.486976 IP 216.113.191.88.https > myhost.com.46058: P 1341:2681(1340) ack 128 win 5792 <nop,nop,timestamp 1321850743 330132365> 23:43:32.486991 IP myhost.com.46058 > 216.113.191.88.https: . ack 2681 win 10720 <nop,nop,timestamp 330132366 1321850743> 23:43:32.519440 IP 216.113.191.88.https > myhost.com.46058: P 2681:3375(694) ack 128 win 5792 <nop,nop,timestamp 1321850776 330132366> 23:43:32.519453 IP myhost.com.46058 > 216.113.191.88.https: . ack 3375 win 13400 <nop,nop,timestamp 330132375 1321850776> 23:43:32.544778 IP myhost.com.46058 > 216.113.191.88.https: P 128:326(198) ack 3375 win 13400 <nop,nop,timestamp 330132381 1321850776> 23:43:32.544964 IP 216.113.191.88.https > myhost.com.46058: . ack 326 win 6432 <nop,nop,timestamp 1321850801 330132381> 23:43:32.587472 IP 216.113.191.88.https > myhost.com.46058: P 3375:3434(59) ack 326 win 6432 <nop,nop,timestamp 1321850844 330132381> 23:43:32.587927 IP myhost.com.46058 > 216.113.191.88.https: P 326:859(533) ack 3434 win 13400 <nop,nop,timestamp 330132392 1321850844> 23:43:32.589238 IP 216.113.191.88.https > myhost.com.46058: . ack 859 win 7504 <nop,nop,timestamp 1321850846 330132392> 23:44:07.363055 IP 216.113.191.88.https > myhost.com.46058: P 3434:3924(490) ack 859 win 7504 <nop,nop,timestamp 1321885621 330132392> 23:44:07.363138 IP 216.113.191.88.https > myhost.com.46058: F 3924:3924(0) ack 859 win 7504 <nop,nop,timestamp 1321885621 330132392> 23:44:07.363517 IP myhost.com.46058 > 216.113.191.88.https: P 859:896(37) ack 3925 win 16080 <nop,nop,timestamp 330141085 1321885621> 23:44:07.363702 IP 216.113.191.88.https > myhost.com.46058: . ack 896 win 7504 <nop,nop,timestamp 1321885622 330141085> 23:44:07.363923 IP myhost.com.46058 > 216.113.191.88.https: R 896:896(0) ack 3925 win 16080 <nop,nop,timestamp 330141085 1321885622> Link to comment https://forums.phpfreaks.com/topic/196795-splash-or-please-wait-until-page-load/#findComment-1033358 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.