Jump to content

Search the Community

Showing results for tags 'paypal'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (Dreamweaver, Zend, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. This is more of a Paypal question, but I'm using php on the listener and hopefully someone has run into this problem. I'm having trouble finding the correct POST name to use to get the OPTION SELECT for the item on my listener page. I tried: $option = $_POST['os0']; But, I'm not getting anything using that. I've also tried os0_x, on0, and on0_x. This is what I'm posting to Paypal: <input type="hidden" name="on0" value="Term"> <select name="os0"> <option value="1 Year">1 Year</option> <option value="3 Years">3 Years</option> <option value="5 Years">5 Years</option> </select>
  2. It seems there is conflicting information regarding this matter. I read a certain article which seems to claim that in 2016, the largest single transaction value through PayPal donation was $230,000. Elsewhere on PayPals site exist somewhat conflicting data. If the merchant and donor have verified accounts, is there any limit on the value of any single transaction? Does the donor experience any errors if the transaction amount exceeds $10,000?
  3. Using Joomla 2.5 and Virtuemart 3. I've had a client tell us that they're getting e-mails (admin order confirmation email) that are different orders from the same person at the same time. After some test orders I've seen that what happens is when PayPal is used, and the customer is being redirected or has been, they then press the back button in the browser, amend the order and send it again. This sends 2 e-mails to the shop and causes confusion. Is there a way to stop this? (Other than a big bold message warning not to do it)
  4. I have a website which shows lots of products by PHP/mysql database. Currently only cash payments are available. I want to add PayPal in, which I've never done before. Having looked at the integration guides, I found the PayPal payments standard bit but with this you need PayPal's buttons. If you have the add to cart buttons, apparently you need to write out each product into PayPal which shouldn't happen as the products are generated by a while loop so I should only paste the code once, but it looks like this needs to be posted individually for each product. Ideally I'd have the PayPal code only happen if the user chooses PayPal at the cart, and then send them to PayPal. The cart products, prices, options and option prices are all in session arrays. Is this possible? Is there a better way?
  5. hello, so i've been developing this website ( http://www.ultimate-dimension.co.uk/NewRAL/store1.php ) for a while now, and the owner wanted a shopping cart implemented. However another coder began the coding of this shopping cart. The cart works perfectly besides that fact that after the Paypal payment as been made I cannot make the system redirect the user to a page where they can download the files that they have ordered. Here is the shopping cart code... <?php session_start(); $page = 'store1.php'; if (isset($_GET['add'])) { $quantity = mysql_query('SELECT id, quantity FROM filesTable WHERE id='.mysql_real_escape_string((int)$_GET['add'])); while ($quantity_row = mysql_fetch_assoc($quantity)) { if ($quantity_row['quantity']!=$_SESSION['cart_'.(int)$_GET['add']]) { $_SESSION['cart_'.(int)$_GET['add']]+='1'; } } header('location:'.$page); } if (isset($_GET['remove'])) { $_SESSION['cart_'.(int)$_GET['remove']]--; header('location:'.$page); } if (isset($_GET['delete'])) { $_SESSION['cart_'.(int)$_GET['delete']]='0'; header('location:'.$page); } function products() { $get = mysql_query('SELECT id, name, description, price, shipping FROM filesTable WHERE quantity > 0 ORDER BY id DESC'); if (mysql_num_rows($get)==0) { echo "There are no products to display :/"; } else { while ($get_row = mysql_fetch_assoc($get)) { echo '<p>'.$get_row['name'].'<br />'.$get_row['description'].'<br /> &pound'.number_format($get_row['price'], 2).' <br /> <a href="cart.php?add='.$get_row['id'].'">ADD</a></p> <br /><hr><br />'; } } } function paypal_items() { $num==0; foreach ($_SESSION as $name => $value) { if ($value!=0) { if (substr($name, 0, 5)=='cart_') { $id = substr($name, 5, strlen($name)-5); $get = mysql_query('SELECT id, name, price, shipping FROM filesTable WHERE id='.mysql_real_escape_string((int)$id)); while ($get_row = mysql_fetch_assoc($get)) { $num++; echo '<input type="hidden" name="item_number_'.$num.'" value="'.$id.'">'; echo '<input type="hidden" name="item_name_'.$num.'" value="'.$get_row['name'].'">'; echo '<input type="hidden" name="amount_'.$num.'" value="'.$get_row['price'].'">'; echo '<input type="hidden" name="shipping_'.$num.'" value="'.$get_row['shipping'].'">'; echo '<input type="hidden" name="shipping2_'.$num.'" value="'.$get_row['shipping'].'">'; echo '<input type="hidden" name="quantity_'.$num.'" value="'.$value.'">'; } } } } } function cart() { foreach ($_SESSION as $name => $value) { if ($value>0) { if (substr($name, 0, 5)=='cart_') { $id = substr($name, 5, (strlen($name)-5)); $get = mysql_query('SELECT id, name, description, price, shipping FROM filesTable WHERE id='.mysql_real_escape_string((int)$id)); while ($get_row = mysql_fetch_assoc($get)) { $sub = $get_row['price']*$value; echo $get_row['name'].' x '.$value.' @ &pound'.number_format($get_row['price'], 2).' = &pound'.number_format($sub, 2).' <a href="cart.php?remove='.$id.'">[ - ]</a> <a href="cart.php?add='.$id.'">[ + ]</a> <a href="cart.php?delete='.$id.'">[ DELETE ]</a> <br><br>'; } } $total += $sub; } } if ($total==0) { echo "Your cart is empty :/"; } else { echo '<br><p class="rightAlignCart">Total: £'.number_format($total, 2).'</p>'; ?> <p> <form class="rightAlignCart" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="upload" value="1"> <input type="hidden" name="business" value="joshlittlewood@ultimate-dimension.co.uk"> <?php paypal_items(); ?> <input type="hidden" name="currency_code" value="GBP"> <input type="hidden" name="amount" value="<?php echo $total; ?>"> <input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but06.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> </form> </p> <?php } } ?> By the way the store is running in sandbox mode, for anyone who wants to try it. I believe that Paypal's IPN is the way to do it, but I just can't get it to work with the current shopping cart system. Any help on how do do this would be greatly appreciated!
  6. Hello all, I need some help with my database. So far I have made a program that collects information from a mysql database and I can edit the information and all. Anyways, I use that program to keep track of my job orders but as it stands now I have to enter it all myself. Is there a way that I can have paypal or a php enter the clients name, email, order ID (dont even know how to do this in paypal), and what product he bought in a table on my database? Ill provide screenshots of my program and also database table. Dont know if it will help but it might a bit. By the way, I dont have a clue about php.
  7. Hi guys I am now current trying to implement Paypal sandbox in my website for testing. I used the form generated by Paypal and it worked. However, I wish to make it more secure by verifying the POST details against my database first before posting to Paypal. I have read on the internet for a few days and download a few sample codes to try out, however I still dun understand how it works. The thing I read on is IPN (Instant Payment Notification) for Paypal. Am I reading the right thing? If I am can anyone help me out cause I do not really understand part of it.
  8. Hello Codingforums, yet again I desire some help to my coding, this time regarding a paypal button. I'm working on a local project of mine in which I wish to let my costumers type the amount of quantities for a product they wish into a text box and then want it to automatically edit the amount of quantities on the paypal page. This works when I have the input inside the form, but due to my template I wish to have my quantity text box outside the "form" code of the paypal button but still want it to connect so that it changes. Let me explain with some code This is the working code for which i can enter the amount of quantities into a text box and it will automatically change it on the paypal page as well. <div id="payment" style="margin-top:10px;"> <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="TEXT" name="quantity" value="1"> <input type="hidden" name="hosted_button_id" value="C5P9LBML2FSC6"> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynow_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypalobjects.com/da_DK/i/scr/pixel.gif" width="1" height="1"> </form> </div> This is what I want it to do, I want to be able to put the input of the quantities text box onto another div and still be able to change the amount of quantities on paypal. (Doesn't change the amount of quantities when clicked on button) <div id="anotherdiv"> <input type="TEXT" name="quantity" value="1"> </div> <div id="payment" style="margin-top:10px;"> <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="C5P9LBML2FSC6"> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynow_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypalobjects.com/da_DK/i/scr/pixel.gif" width="1" height="1"> </form> </div> Thx in advance - rec0il
  9. so I have a custom store built off of PHP, JS and CSS and it sells virtual coins for a game and the coins are sent automatically by the script however I want to start offering discounts to customers via discounts codes and I currently came across this script that I have put together: Javascript <!-- var discnt = 0; // no default percent discount var coupons = new Array ( // place to put coupon codes "MavrkHD", "TheFUTBucks", "TOTW", "Mega", "LL" ); var coupdc = new Array ( // place to put discounts for coupon vals "10", "15", "7", "10", "20" ); var coupval = "(blanket)"; // what user entered as coupon code function ChkCoup () { // check user coupon entry var i; discnt = 0; // assume the worst for (i=0; i<coupons.length; i++) { if (coupval == coupons[i]) { discnt = coupdc[i]; // remember the discount amt alert ("This is a valid promo code! \n\n" + discnt + "%" + " discount now in effect."); return; } } alert ("'" + coupval + "' is not a valid promo code!"); } function Sterling (val) { // force to valid dollar amount var str,pos,rnd=0; if (val < .995) rnd = 1; // for old Netscape browsers str = escape (val*1.0 + 0.005001 + rnd); // float, round, escape pos = str.indexOf ("."); if (pos > 0) str = str.substring (rnd, pos + 3); return str; } function ReadForm (obj1) { // apply the discount var amt,des; amt = obj1.amount.value*1.0; // base amount des = obj1.basedes.value; // base description if (discnt > 0) { // only if discount is active amt = Sterling (amt - (amt * discnt/100.0)); des = des + " - " + discnt + "% off - COUP = " + coupval; } obj1.baseamt.value = Sterling (amt); obj1.item_name.value = des; } //--> </script> PayPal Form Details <form action="https://www.paypal.com/cgi-bin/webscr" method="post" onsubmit="this.target = 'paypal'; return ReadForm (this);"> <input type="hidden" name="cmd" value="_xclick" /> <input type="hidden" name="add" value="1" /> <input type="hidden" name="business" value="<?=$functions->getPayPal();?>" /> <input type="hidden" name="item_name" value="Online Coin Currency" /> <input type="hidden" name="amount" id="amount" value="0.00" /> <input type="hidden" name="currency_code" value="GBP" /> <input type="hidden" name="baseamt" id="amount" value="0.00" /> <input type="hidden" name="basedes" value="Online Coin Currency (FUT)" /> <input type="hidden" name="custom" id="custom" value=""> <input type="hidden" name="return" value="RETURN LINK HERE";?> <input type="hidden" name="notify_url" value="<?=HOST.'files/payments/paypal.php';?>"> <input type="hidden" name="cancel_return" value="<?=HOST.'cancelled';?>"> Enter Coupon code <input type = "text" size = "10" name = "coupcode"; /> <input type="button" value="Apply code" onclick="coupval =this.form.coupcode.value; ChkCoup();" /><br/><br/> <input type="image" id="xx" src="https://www.paypalobjects.com/WEBSCR-640-20110306-1/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" onclick="CalculateOrder(this.form)" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypalobjects.com/WEBSCR-640-20110306-1/en_US/i/scr/pixel.gif" width="1" height="1"> </form> So, it all works like sending information to PayPal I have one issue about PayPal displaying the calculated prices. For example: if I take out the id of amount and baseamt and just leave value and put a value of 12.99 and then go on my store and go through the process of buying the virtual coins and then get to the discount code area and proceed to paypal I will get a discount price to pay at paypal but when I use the id="amount" which is a variable for depending on how many coins the customer to buy it'll send that price to paypal, it doesn't discount the price and I have been trying endlessly to fix this! help? Thanks.
  10. require_once ("paypalfunctions.php"); $PaymentOption = "PayPal"; if ( $PaymentOption == "PayPal") { // ================================== // PayPal Express Checkout Module // ================================== //'------------------------------------ //' The paymentAmount is the total value of //' the purchase. //' //' TODO: Enter the total Payment Amount within the quotes. //' example : $paymentAmount = "15.00"; //'------------------------------------ $paymentAmount = "99"; //'------------------------------------ //' The currencyCodeType //' is set to the selections made on the Integration Assistant //'------------------------------------ $currencyCodeType = "USD"; $paymentType = "Sale"; //'------------------------------------ //' The returnURL is the location where buyers return to when a //' payment has been succesfully authorized. //' //' This is set to the value entered on the Integration Assistant //'------------------------------------ $returnURL = "http://127.0.0.1/digitalgoodsexample/orderconfirm.php"; //'------------------------------------ //' The cancelURL is the location buyers are sent to when they hit the //' cancel button during authorization of payment during the PayPal flow //' //' This is set to the value entered on the Integration Assistant //'------------------------------------ $cancelURL = "http://127.0.0.1/digitalgoodsexample/cancel.php"; //'------------------------------------ //' Calls the SetExpressCheckout API call //' //' The CallSetExpressCheckout function is defined in the file PayPalFunctions.php, //' it is included at the top of this file. //'------------------------------------------------- $items = array(); $items[] = array('name' => 'PayPal Digital Goods Integration Guide', 'amt' => $paymentAmount, 'qty' => 1); //::ITEMS:: // to add anothe item, uncomment the lines below and comment the line above // $items[] = array('name' => 'Item Name1', 'amt' => $itemAmount1, 'qty' => 1); // $items[] = array('name' => 'Item Name2', 'amt' => $itemAmount2, 'qty' => 1); // $paymentAmount = $itemAmount1 + $itemAmount2; // assign corresponding item amounts to "$itemAmount1" and "$itemAmount2" // NOTE : sum of all the item amounts should be equal to payment amount $resArray = SetExpressCheckoutDG( $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $items ); $ack = strtoupper($resArray["ACK"]); if($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { $token = urldecode($resArray["TOKEN"]); RedirectToPayPalDG( $token ); } else { //Display a user friendly Error on the page using any of the following error information returned by PayPal $ErrorCode = urldecode($resArray["L_ERRORCODE0"]); $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]); $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]); $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); echo "SetExpressCheckout API call failed. "; echo "Detailed Error Message: " . $ErrorLongMsg; echo "Short Error Message: " . $ErrorShortMsg; echo "Error Code: " . $ErrorCode; echo "Error Severity Code: " . $ErrorSeverityCode; } }<code>I am using the above paypal function to send users to paypal for payment. However, I would like to automatically insert the product price on the line:</code>$paymentAmount = "99"<code>instead of numeric value using a meta value that is:</code>echo get_post_meta($post->ID, 'download_info_price', true I am have been perfectly able to make the paypal functions work, but only with numeric value by using it as a template page for my checkout page. I believe that I need something that help me echo meta value outside of the loop and using:`global $wp_query; $postid = $wp_query->post->ID; echo get_post_meta($postid, 'Your-Custom-Field', true);`did not get me anywhere. with the above, I tried calling /wp-load.php in the paypal functions, but no result. The price/amount I want to automate is require by my paypal checkout file that is called on the header of above codesrequire_once ("paypalfunctions.php")the paypal checkout is:`/******************************************** PayPal API Module Defines all the global variables and the wrapper functions ********************************************/ $PROXY_HOST = '127.0.0.1'; $PROXY_PORT = '808'; $SandboxFlag = true; //' TODO: //'------------------------------------ //' PayPal API Credentials //' Replace <API_USERNAME> with your API Username //' Replace <API_PASSWORD> with your API Password //' Replace <API_SIGNATURE> with your Signature //'------------------------------------ $API_UserName=//this is hidden; $API_Password=//this is hidden; $API_Signature=//this is hidden; // BN Code is only applicable for partners $sBNCode = "PP-ECWizard"; /* ' Define the PayPal Redirect URLs. ' This is the URL that the buyer is first sent to do authorize payment with their paypal account ' change the URL depending if you are testing on the sandbox or the live PayPal site ' ' For the sandbox, the URL is https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token= ' For the live site, the URL is https://www.paypal.com/webscr&cmd=_express-checkout&token= */ if ($SandboxFlag == true) { $API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp"; $PAYPAL_URL = "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token="; $PAYPAL_DG_URL = "https://www.sandbox.paypal.com/incontext?token="; } else { $API_Endpoint = "https://api-3t.paypal.com/nvp"; $PAYPAL_URL = "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token="; $PAYPAL_DG_URL = "https://www.paypal.com/incontext?token="; } $USE_PROXY = false; $version = "84"; /* An express checkout transaction starts with a token, that identifies to PayPal your transaction In this example, when the script sees a token, the script knows that the buyer has already authorized payment through paypal. If no token was found, the action is to send the buyer to PayPal to first authorize payment */ /* '------------------------------------------------------------------------------------------------------------------------------------------- ' Purpose: Prepares the parameters for the SetExpressCheckout API Call for a Digital Goods payment. ' Inputs: ' paymentAmount: Total value of the shopping cart ' currencyCodeType: Currency code value the PayPal API ' paymentType: paymentType has to be one of the following values: Sale or Order or Authorization ' returnURL: the page where buyers return to after they are done with the payment review on PayPal ' cancelURL: the page where buyers return to when they cancel the payment review on PayPal '-------------------------------------------------------------------------------------------------------------------------------------------- */ function SetExpressCheckoutDG( $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $items) { //------------------------------------------------------------------------------------------------------------------------------------ // Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation $nvpstr = "&PAYMENTREQUEST_0_AMT=". $paymentAmount; $nvpstr .= "&PAYMENTREQUEST_0_PAYMENTACTION=" . $paymentType; $nvpstr .= "&RETURNURL=" . $returnURL; $nvpstr .= "&CANCELURL=" . $cancelURL; $nvpstr .= "&PAYMENTREQUEST_0_CURRENCYCODE=" . $currencyCodeType; $nvpstr .= "&REQCONFIRMSHIPPING=0"; $nvpstr .= "&NOSHIPPING=1"; foreach($items as $index => $item) { $nvpstr .= "&L_PAYMENTREQUEST_0_NAME" . $index . "=" . urlencode($item["name"]); $nvpstr .= "&L_PAYMENTREQUEST_0_AMT" . $index . "=" . urlencode($item["amt"]); $nvpstr .= "&L_PAYMENTREQUEST_0_QTY" . $index . "=" . urlencode($item["qty"]); $nvpstr .= "&L_PAYMENTREQUEST_0_ITEMCATEGORY" . $index . "=Digital"; } //'--------------------------------------------------------------------------------------------------------------- //' Make the API call to PayPal //' If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment. //' If an error occured, show the resulting errors //'--------------------------------------------------------------------------------------------------------------- $resArray = hash_call("SetExpressCheckout", $nvpstr); $ack = strtoupper($resArray["ACK"]); if($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { $token = urldecode($resArray["TOKEN"]); $_SESSION['TOKEN'] = $token; } return $resArray; } /* '------------------------------------------------------------------------------------------- ' Purpose: Prepares the parameters for the GetExpressCheckoutDetails API Call. ' ' Inputs: ' None ' Returns: ' The NVP Collection object of the GetExpressCheckoutDetails Call Response. '------------------------------------------------------------------------------------------- */ function GetExpressCheckoutDetails( $token ) { //'-------------------------------------------------------------- //' At this point, the buyer has completed authorizing the payment //' at PayPal. The function will call PayPal to obtain the details //' of the authorization, incuding any shipping information of the //' buyer. Remember, the authorization is not a completed transaction //' at this state - the buyer still needs an additional step to finalize //' the transaction //'-------------------------------------------------------------- //'--------------------------------------------------------------------------- //' Build a second API request to PayPal, using the token as the //' ID to get the details on the payment authorization //'--------------------------------------------------------------------------- $nvpstr="&TOKEN=" . $token; //'--------------------------------------------------------------------------- //' Make the API call and store the results in an array. //' If the call was a success, show the authorization details, and provide //' an action to complete the payment. //' If failed, show the error //'--------------------------------------------------------------------------- $resArray=hash_call("GetExpressCheckoutDetails",$nvpstr); $ack = strtoupper($resArray["ACK"]); if($ack == "SUCCESS" || $ack=="SUCCESSWITHWARNING") { return $resArray; } else return false; } /* '------------------------------------------------------------------------------------------------------------------------------------------- ' Purpose: Prepares the parameters for the GetExpressCheckoutDetails API Call. ' ' Inputs: ' sBNCode: The BN code used by PayPal to track the transactions from a given shopping cart. ' Returns: ' The NVP Collection object of the GetExpressCheckoutDetails Call Response. '-------------------------------------------------------------------------------------------------------------------------------------------- */ function ConfirmPayment( $token, $paymentType, $currencyCodeType, $payerID, $FinalPaymentAmt, $items ) { /* Gather the information to make the final call to finalize the PayPal payment. The variable nvpstr holds the name value pairs */ $token = urlencode($token); $paymentType = urlencode($paymentType); $currencyCodeType = urlencode($currencyCodeType); $payerID = urlencode($payerID); $serverName = urlencode($_SERVER['SERVER_NAME']); $nvpstr = '&TOKEN=' . $token . '&PAYERID=' . $payerID . '&PAYMENTREQUEST_0_PAYMENTACTION=' . $paymentType . '&PAYMENTREQUEST_0_AMT=' . $FinalPaymentAmt; $nvpstr .= '&PAYMENTREQUEST_0_CURRENCYCODE=' . $currencyCodeType . '&IPADDRESS=' . $serverName; foreach($items as $index => $item) { $nvpstr .= "&L_PAYMENTREQUEST_0_NAME" . $index . "=" . urlencode($item["name"]); $nvpstr .= "&L_PAYMENTREQUEST_0_AMT" . $index . "=" . urlencode($item["amt"]); $nvpstr .= "&L_PAYMENTREQUEST_0_QTY" . $index . "=" . urlencode($item["qty"]); $nvpstr .= "&L_PAYMENTREQUEST_0_ITEMCATEGORY" . $index . "=Digital"; } /* Make the call to PayPal to finalize payment If an error occured, show the resulting errors */ $resArray=hash_call("DoExpressCheckoutPayment",$nvpstr); /* Display the API response back to the browser. If the response from PayPal was a success, display the response parameters' If the response was an error, display the errors received using APIError.php. */ $ack = strtoupper($resArray["ACK"]); return $resArray; } /** '------------------------------------------------------------------------------------------------------------------------------------------- * hash_call: Function to perform the API call to PayPal using API signature * @methodName is name of API method. * @nvpStr is nvp string. * returns an associtive array containing the response from the server. '------------------------------------------------------------------------------------------------------------------------------------------- */ function hash_call($methodName,$nvpStr) { //declaring of global variables global $API_Endpoint, $version, $API_UserName, $API_Password, $API_Signature; global $USE_PROXY, $PROXY_HOST, $PROXY_PORT; global $gv_ApiErrorURL; global $sBNCode; //setting the curl parameters. $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$API_Endpoint); curl_setopt($ch, CURLOPT_VERBOSE, 1); //turning 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); //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled. //Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php if($USE_PROXY) curl_setopt ($ch, CURLOPT_PROXY, $PROXY_HOST. ":" . $PROXY_PORT); //NVPRequest for submitting to server $nvpreq="METHOD=" . urlencode($methodName) . "&VERSION=" . urlencode($version) . "&PWD=" . urlencode($API_Password) . "&USER=" . urlencode($API_UserName) . "&SIGNATURE=" . urlencode($API_Signature) . $nvpStr . "&BUTTONSOURCE=" . urlencode($sBNCode); //setting the nvpreq as POST FIELD to curl curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq); //getting response from server $response = curl_exec($ch); //convrting NVPResponse to an Associative Array $nvpResArray=deformatNVP($response); $nvpReqArray=deformatNVP($nvpreq); $_SESSION['nvpReqArray']=$nvpReqArray; if (curl_errno($ch)) { // moving to display page to display curl errors $_SESSION['curl_error_no']=curl_errno($ch) ; $_SESSION['curl_error_msg']=curl_error($ch); //Execute the Error handling module to display errors. } else { //closing the curl curl_close($ch); } return $nvpResArray; } /*'---------------------------------------------------------------------------------- Purpose: Redirects to PayPal.com site. Inputs: NVP string. Returns: ---------------------------------------------------------------------------------- */ function RedirectToPayPal ( $token ) { global $PAYPAL_URL; // Redirect to paypal.com here $payPalURL = $PAYPAL_URL . $token; header("Location: ".$payPalURL); exit; } function RedirectToPayPalDG ( $token ) { global $PAYPAL_DG_URL; // Redirect to paypal.com here $payPalURL = $PAYPAL_DG_URL . $token; header("Location: ".$payPalURL); exit; } /*'---------------------------------------------------------------------------------- * This function will take NVPString and convert it to an Associative Array and it will decode the response. * It is usefull to search for a particular key and displaying arrays. * @nvpstr is NVPString. * @nvpArray is Associative Array. ---------------------------------------------------------------------------------- */ function deformatNVP($nvpstr) { $intial=0; $nvpArray = array(); while(strlen($nvpstr)) { //postion of Key $keypos= strpos($nvpstr,'='); //position of value $valuepos = strpos($nvpstr,'&') ? strpos($nvpstr,'&'): strlen($nvpstr); /*getting the Key and Value values and storing in a Associative Array*/ $keyval=substr($nvpstr,$intial,$keypos); $valval=substr($nvpstr,$keypos+1,$valuepos-$keypos-1); //decoding the respose $nvpArray[urldecode($keyval)] =urldecode( $valval); $nvpstr=substr($nvpstr,$valuepos+1,strlen($nvpstr)); } return $nvpArray; }
  11. I've been trying to get help with a PayPal button on a few different coding message boards and the only responses I get are regarding format and violating unwritten rules (apparently offering $20 thank-yous for solving my problem is a no-no). My coding skills (as I learned) are mostly limited to formatting so I'm at the end of my skill set. So rather than asking for coding help, is there a resource you all use to solve specialized coding problems like this one that would probably be very amateur for someone proficient in the area? Any help is appreciated. For context, my other post is linked below. http://forums.phpfreaks.com/topic/285418-pay-now-button-with-registration-form-on-paypal/
  12. I'm trying to set up what I thought would be an easy form with button. I want to get the registration information out of the form when someone fills it out and pays. Instead, clicking the button leads to a mess of bad information at the top of the PayPal page. I think I'm missing something that pulls the data out of the form when someone registers. Looking at some examples online, someone who has done this before could probably fix my code in a few minutes. I thought the HTML skills learned I learned in the mid/late 90s were adequate for this. Sorry for the wall of code, but I provided it below. I've spent hours to get to this point and made a bunch of changes from some other forums and it still drops and error. http://www.lifeatpathway.com/what-s-happening/mukti-5k-registration <form action="https://www.paypal.com/cgi-bin/webscr" method="post" name="mukti5k" id="5k" onsubmit="this.target='paypal'; return UpdateForm(this);" > <table> <tbody> <tr> <td>First name:</td> </tr> <tr> <td><input type="hidden" name="on0" value="First Name" /> <input type="text" name="os0" size="30" /></td> </tr> <tr> <td>Last name:</td> </tr> <tr> <td><input type="hidden" name="on1" value="Last Name" /> <input type="text" name="os1" size="30" /></td> </tr> <tr> <td>Address:</td> </tr> <tr> <td><input type="hidden" name="on2" value="Address" /> <input type="text" name="os2" size="30" /></td> </tr> <tr> <td>City:</td> </tr> <tr> <td><input type="hidden" name="on3" value="City" /> <input type="text" name="os3" size="20" /></td> </tr> <tr> <td>State:</td> </tr> <tr> <td><input type="hidden" name="on3" value="State" /> <input type="text" name="os3" size="2" /></td> </tr> <tr> <td>Zip:</td> </tr> <tr> <td><input type="hidden" name="on3" value="Zip" /> <input type="text" name="os3" size="10" /></td> </tr> <tr> <td>Phone:</td> </tr> <tr> <td><input type="hidden" name="on3" value="Phone" /> <input type="text" name="os3" size="14" /></td> </tr> <tr> <td>Email:</td> </tr> <tr> <td><input type="hidden" name="on3" value="Email" /> <input type="text" name="os3" size="30" /></td> </tr> <tr> <td>Age:</td> </tr> <tr> <td><input type="hidden" name="on3" value="Age" /> <input type="text" name="os3" size="2" /></td> </tr> <tr> <td>Gender:</td> </tr> <tr> <td><input type="radio" name="gender" value="male" /> Male <input type="radio" name="gender" value="female" /> Female</td> </tr> <tr> <td>Race:</td> </tr> <tr> <td><input type="radio" name="race" value="5k" /> Mukti 5K <input type="radio" name="race" value="1m" /> Mukti 1 Mile Fun Walk</td> </tr> <tr> <td><input type="hidden" name="on1" value="Shirt Size" />Shirt Size: </td> </tr> <tr> <td><input type="radio" name="shirt" value="ys" /> Youth Small <input type="radio" name="shirt" value="ym" /> Youth Medium <input type="radio" name="shirt" value="yl" /> Youth Large <br /><input type="radio" name="shirt" value="as" /> Adult Small <input type="radio" name="shirt" value="am" /> Adult Medium <input type="radio" name="shirt" value="al" /> Adult Large <input type="radio" name="shirt" value="axl" /> Adult XL <input type="radio" name="shirt" value="axxl" /> Adult XXL</td> </tr> <tr> <td colspan="2" align="center"> <div> </div> <div><input type="checkbox" name="agree" value="agree_terms" /> By checking this box, I, intending to be legally bound for myself, my heirs, my executors and administrators, waive, release and discharge any and all rights and claims which I may have or which hereafter may arise from all claims of damage, actions, injury or death received in any manner before, during or after participation in the 2014 Pathway Church Mukti 5K and 1 Mile Run/Walk on Saturday, May 10, 2014. I shall abide by all decisions of race officials as final. I also release the sponsoring organizations and individuals from all legal responsibility or liability for the use of any photographs involving me for the purpose of advertising or reporting.</div> </td> </tr> </tbody> </table> <input type="image" name="submit" src="https://www.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif" alt="Register Now" align="middle" /> <input type="hidden" name="cmd" value="_xclick" /> <input type="hidden" name="business" value="mikejohnston5@gmail.com" /> <input type="hidden" name="return" value="http://www.lifeatpathway.com" /> <input type="hidden" name="currency_code" value="USD" /> <input type="hidden" name="bn" value="PP-ShopCartBF" /></form>
  13. Hello, I've been struggling with an issue for a few days now and I was hoping someone could help. I bought a php script that allows me to create paypal adaptive payments. It works great, it's all set up. My only issue is that I can't find the proper place to set my code so that it will make an update call to my php database. The problem with that is I'm not sure how to set up paypal url forwarding to forward them to a webpage where the php code could run, so I either have to give them what they paid for BEFORE they pay and cancel the sale if they choose not to continue on with the transaction(which is my current problem) -OR- Call the code to update my database after I receive the transaction complete from POST data (which is what I would like to do.) I have 3 scripts. Buy.php which handles the actual transaction Paypal_API script which has the method definitions within it, and an IPN script which has the IPN listener within. Which three of these scripts should I place the code to update my database? I've tried placing it inside all three at various places, it doesn't seem to work in the IPN script at all, and the other two scripts give me the first problem I mentioned. Any help would be greatly appreciated and you might just win the "internets".
  14. Basically what I can see is that I am failing to create the apiContext object. Can anyone see where the error is? Please tell me how I can improve the question. Here is the error: Fatal error: Uncaught exception 'PayPal\Exception\PPConnectionException' with message 'Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment.' in /vendor/paypal/sdk-core-php/lib/PayPal/Core/PPHttpConnection.php:104 Stack trace: #0 /vendor/paypal/sdk-core-php/lib/PayPal/Transport/PPRestCall.php(44): PayPal\Core\PPHttpConnection->execute('{"intent":"sale...') #1 /vendor/paypal/rest-api-sdk-php/lib/PayPal/Api/Payment.php(246): PayPal\Transport\PPRestCall->execute(Array, '/v1/payments/pa...', 'POST', '{"intent":"sale...') #2 /pymt.php(38): PayPal\Api\Payment->create(Object(PayPal\Rest\ApiContext)) #3 {main} thrown in /vendor/paypal/sdk-core-php/lib/PayPal/Core/PPHttpConnection.php on line 104 This is the PHP sample I'm using. I am trying to run it off my server. If a customer clicks the pay with paypal button, it runs the following sample script: <?php require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Address; use PayPal\Api\Amount; use PayPal\Api\Payer; use PayPal\Api\Payment; use PayPal\Api\FundingInstrument; use PayPal\Api\RedirectUrls; use PayPal\Api\Transaction; session_start(); $payer = new Payer(); $payer->setPayment_method('paypal'); $amount = new Amount(); $amount->setCurrency('USD'); $amount->setTotal('1.00'); $transaction = new Transaction(); $transaction->setAmount($amount); $transaction->setDescription('This is the payment description.'); $baseUrl = getBaseUrl(); $redirectUrls = new RedirectUrls(); $redirectUrls->setReturn_url('baseUrl/sale.php'); $redirectUrls->setCancel_url('baseUrl/saleFail.php'); $payment = new Payment(); $payment->setIntent('sale'); $payment->setPayer($payer); $payment->setRedirect_urls($redirectUrls); $payment->setTransactions(array($transaction)); try { $payment->create($apiContext); } catch (\PPConnectionException $ex) { echo 'Exception: ' . $ex->getMessage() . PHP_EOL; var_dump($ex->getData()); exit(1); } foreach ($payment->getLinks() as $link) { if ($link->getRel() == 'approval_url') { $redirectUrl = $link->getHref(); } } $_SESSION['paymentId'] = $payment->getId(); if(isset($redirectUrl)) { header('Location: $redirectUrl'); exit; } ?> Here's the redacted bootstrap.php: <?php /* * Sample bootstrap file. */ // Include the composer autoloader if(!file_exists(__DIR__ .'/vendor/autoload.php')) { echo "The 'vendor' folder is missing. You must run 'composer update --no-dev' to resolve application dependencies.\nPlease see the README for more information.\n"; exit(1); } require __DIR__ . '/vendor/autoload.php'; require __DIR__ . '/common.php'; use PayPal\Rest\ApiContext; use PayPal\Auth\OAuthTokenCredential; $apiContext = getApiContext(); /** Helper method for getting an APIContext for all calls * * @return PayPal\Rest\ApiContext */ function getApiContext() { // ### Api context // Use an ApiContext object to authenticate // API calls. The clientId and clientSecret for the // OAuthTokenCredential class can be retrieved from // developer.paypal.com $apiContext = new ApiContext( new OAuthTokenCredential( 'MY CLIENT ID', 'MY SECRET' ) ); // Register the sdk_config.ini file in current directory // as the configuration source. if(!defined("PP_CONFIG_PATH")) { define("PP_CONFIG_PATH", __DIR__); } return $apiContext; } ?> Can anyone help? Let me know if you need more info. Thanks up front.
  15. We have a small Wordpress based site and we're using the WP E-commerce plugin to sell digital downloads. Everything is working, except the PayPal IPN function so when the customer pays he never receives the download e-mail until we change the transaction's status manually. Unfortunately it's not an option here because it's a digital download store so we have to fix the IPN somehow. My PHP knowledge is almost zero, so i'm here to ask some help from you guys. Store URL: http://brainwaveentrainment.eu WordPress version: 3.6.1 WP e-Commerce version: 3.8.12.1 Theme: Xyloto by Storefrontthemes I did this: Enabled IPN in Paypal with the store URL (http://brainwaveentrainment.eu) Enabled IPN in the PayPal Standard module. Send shipping details: No, Allow owerride: No. Currently i'm testing with a Sandbox account but it's not working with a live account either. I set up paypal to accept payments automatically also. I expected WP e-Commerce to do this: Modify the "Incomplete sale" status to "Accepted payment" Instead it did this: It's not changing the orders' status. It's pretty annoying. I tried everything, changed every setting, currency, IPN URL, etc but nothing helps. We want to start the store but we can't until it's not working. We purchased this theme and it's only working with this shopping cart so i can't just simply switch to a different e-commerce plugin. One IPN log from paypal: Notification URL http://brainwaveentrainment.eu/?wpsc...aypal_standard HTTP response code What's this? 200 Delivery status Sent No. of retries 0 Transaction ID 7W214573HJ105310Y IPN type Transaction made mc_gross=7.00&invoice=4151379432588&protection_eligibility=Eligible&address_status=confirmed&item_number1=531&tax=0.00&item_number2=568&payer_id=LYXHGVEQ4ASFN&address_street=1 Main St&payment_date=08:42:47 Sep 17, 2013 PDT&payment_status=Completed&charset=windows-1252&address_zip=95131&mc_shipping=0.00&mc_handling=0.00&first_name=Ferenc&mc_fee=0.50&address_country_code=US&address_name=Ferenc Szepesi's Test Store&notify_version=3.7&custom=&payer_status=verified&business=beatofficial@gmail.com&address_country=United States&num_cart_items=2&mc_handling1=0.00&mc_handling2=0.00&address_city=San Jose&verify_sign=AiPC9BjkCyDFQXbSkoZcgqH3hpacA.v.7UClmMzrTiiKgIJVSBufA1UT&payer_email=ferenc@szepesiweb.com&mc_shipping1=0.00&mc_shipping2=0.00&tax1=0.00&tax2=0.00&txn_id=7W214573HJ105310Y&payment_type=instant&payer_business_name=Ferenc Szepesi's Test Store&last_name=Szepesi&address_state=CA&item_name1=Gamma Energizer (Wind background), 45 minutes&receiver_email=beatofficial@gmail.com&item_name2=15 minutes relaxation Break (Wind chimes background)&payment_fee=0.50&quantity1=1&quantity2=1&receiver_id=5YKCMZKL6G46G&txn_type=cart&mc_gross_1=3.50&mc_currency=USD&mc_gross_2=3.50&residence_country=US&test_ipn=1&transaction_subject=&payment_gross=7.00&ipn_track_id=8542bf47e444e So it seems everything is working fine on the PayPal's side. I didn't gave up so i found this: The Paypal IPN log shows this URL in my case: http://brainwaveentrainment.eu/?wpsc...aypal_standard I tried to open this and i got this error message: "Fatal error: Cannot use object of type WP_Error as array in C:\xampp\htdocs\brainwaveentrainment.eu\wp-content\plugins\wp-e-commerce\wpsc-merchants\paypal-standard.merchant.php on line 400" On line 400 i found this: if ( 'VERIFIED' == $response['body'] ) { I googled for the error message and i found this fix: https://getsatisfaction.com/tweet_bl...error_as_array So i changed that line to look like this: if ( 'VERIFIED' == $response->body ) { Result: The error message is gone when i open that page! But... the IPN is still not working. I don't have PHP skills so i'm sure this single modification is not enough. Maybe somebody can help me with this here. I uploaded the original "paypal-standard.merchant.php" file's content to pastebin so you can check what's wrong with it: http://pastebin.com/9Dcd75LM Please help me if you can. I'm clueless and we really have to make this work somehow. I asked in the plugin's support forum too, but it's abandoned as a desert.
  16. I have been working on this website for a client. One of the features this client requires is the ability to pay for services via PayPal. They have created a Buy Now button and submitted to me the code from said button. The client would also like for some additional information not needed by PayPal to be emailed to them. Currently my form code looks like this: <form action="service.php" method="post" name="register" onSubmit="document.location='thankyou.htm';"> <?php $fName = $_POST['fName']; $lName = $_POST['lName']; $email = $_POST['email']; $cEmail = $_POST['cEmail']; $phone = $_POST['tele']; $pickUp = $_POST['pickUp']; $dropOff = $_POST['dropOff']; $date = $_POST['date']; $service = $_POST['service']; $instruct = $_POST['instruct']; $human = $_POST['human']; $thankyou = 'thankyou.htm'; $from = 'From: Joyful Xpressions'; $to = 'feliciaharried@yahoo.com'; $subject = 'Service Request'; $body = "From: $fName $lName\n E-Mail: $email\n Phone: $phone\n \n Pick Up Location: $pickUp\n Drop Off Location: $dropOff\n Pick Up Date: $date\n \n Service Requested: $service\n \n Special Instructions: $instruct"; ?> <h2>Register</h2> <p>Give us a try! Use this form to sign up for your first FREE pick up. Enter your information below and submit. You will get a Paypal button which allows you to select the service you want and proceed to Paypal's secure payment page to process your payment. You may be asked to enter some information again.</p> <hr/> <fieldset> <legend>Personal Information</legend> <label for="fName">First Name: </label> <input autocomplete="on" autofocus name="fName" placeholder="First Name" required type="text" /> <br/> <label for="lName">Last Name: </label> <input autocomplete="on" name="lName" placeholder="Last Name" required type="text" /> <br/> <label for="email">Email: </label> <input autocomplete="on" name="email" placeholder="john.doe@example.com" required type="email" /> <br/> <label for="cEmail">Confirm Email: </label> <input autocomplete="off" name="cEmail" placeholder="john.doe@example.com" required type="email" /> <br/> <label for="tele">Phone: </label> <input autocomplete="on" name="tele" placeholder="555-555-5555" required type="tel" /> </fieldset> <br/> <br/> <fieldset> <legend>Service Request</legend> <label for="pickUp">Complete Address for Pickup: </label> <textarea cols="20" name="pickUp" placeholder="Please enter your desired pickup location." required rows="3"></textarea> <br/> <label for="dropOff">Complete Address for Delivery: </label> <textarea cols="20" name="dropOff" placeholder="Please enter your desired drop off location." required rows="3"></textarea> <br/> <label for="date">Pickup Date: </label> <input autocomplete="off" min="2013-01-01" name="date" required type="date" /> <br/> <label for="service">Chore: </label> <select name="service"> <option value="1 Bag">1 Bag $35.00 USD</option> <option value="2 Bags">2 Bags $65.00 USD</option> <option value="Express Service">Express Service $15.00 USD</option> <option value="King Comforter">King Comforter $20.00 USD</option> <option value="Queen Comforter">Queen Comforter $15.00 USD</option> </select> <br/> </fieldset> <br/> <br/> <fieldset> <legend>Special Intructions</legend> <textarea cols="70" name="instruct" placeholder="Please enter any special instructions you may have regarding your service request here." rows="10"></textarea> <br/> </fieldset> <br/> <br/> <fieldset> <label>*What is 2+2? (Anti-spam)</label> <input name="human" placeholder="Type Here"> <br/> <br/> <input type="hidden" name="return" value="http://expressyourchores.com/thankyou.htm" /> <input id="submit" type="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" /> </fieldset> <br/> <? if ($_POST['submit'] && $human == '4') { if (mail ($to, $subject, $body, $from)) { echo '<p>Test Failed</p>'; } else { echo '<p>Something went wrong, go back and try again!</p>'; } } else if ($_POST['submit'] && $human != '4') { echo '<p>You answered the anti-spam question incorrectly!</p>'; } ?> </form> I have tried several different methods of submitting the email the redirecting to a Thank You page which contains the PayPal Buy Now button form. and none of my redirects have worked. I have also scoured the internet looking for ways to complete both tasks through one form and have come up with nothing. The PayPal button form looks like this: <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top"> <input type="hidden" name="cmd" value="_s-xclick" /> <input type="hidden" name="hosted_button_id" value="VPK6MXG9XGY6L" /> <table> <tr> <td><input type="hidden" name="on0" value="Chores" /> Chores</td> </tr> <tr> <td><select name="os0"> <option value="1 Bag">1 Bag $35.00 USD</option> <option value="2 Bags">2 Bags $65.00 USD</option> <option value="Express Service">Express Service $15.00 USD</option> <option value="King Comforter">King Comforter $20.00 USD</option> <option value="Queen Comforter">Queen Comforter $15.00 USD</option> </select></td> </tr> </table> <input type="hidden" name="currency_code" value="USD" /> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" /> <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1" /> </form> Is there any way to combine the two and accomplish both tasks through one form? If not, how could I rewrite the first form's code to redirect to the Thank You page that has the PayPal button? This project has done nothing but make me more and more frustrated. Please note that the variables and email format php code in the first form was moved into the form to place on here. Originally, that code was placed before the doctype of the page. I hope that someone can actually assist me in making this form work as it's the only thing preventing me from turning the project over to the client.
  17. Hi there. I'm a beginner so hopefully someone can help me. Say I have a paypal button on my site, that after using it to pay, takes you to a page with a download link on it that allows you to download a file on my sites server. How can I make it so that people can't just bypass the payment process by typing in the url of the download link page? I've looked into PayPal IPN but I find it hard to understand the underlying code, and wonder if there's another way. Any actual coding examples would be gratefully appreciated.
  18. <?php // Database variables $host = "localhost"; //database location $user = ""; //database username $pass = ""; //database password $db_name = ""; //database name // PayPal settings $paypal_email = 'paypal@example.com'; $return_url = 'http://example.com/payment-successful.htm'; $cancel_url = 'http://example.com/payment-cancelled.htm'; $notify_url = 'http://example.com/paypal/payments.php'; $item_name = 'Test Item'; //<----- this is my problem These are static variables set in the code I want to pass them from whatever the user selects in their shopping cart. $item_amount = 5.00; //<----- this is my problem // Include Functions include("functions.php"); //Database Connection $link = mysql_connect($host, $user, $pass); mysql_select_db($db_name); // Check if paypal request or response if (!isset($_POST["txn_id"]) && !isset($_POST["txn_type"])){ // Firstly Append paypal account to querystring $querystring .= "?business=".urlencode($paypal_email)."&"; // Append amount& currency (£) to quersytring so it cannot be edited in html //The item name and amount can be brought in dynamically by querying the $_POST['item_number'] variable. $querystring .= "item_name=".urlencode($item_name)."&"; $querystring .= "amount=".urlencode($item_amount)."&"; //loop for posted values and append to querystring foreach($_POST as $key => $value){ $value = urlencode(stripslashes($value)); $querystring .= "$key=$value&"; } // Append paypal return addresses $querystring .= "return=".urlencode(stripslashes($return_url))."&"; $querystring .= "cancel_return=".urlencode(stripslashes($cancel_url))."&"; $querystring .= "notify_url=".urlencode($notify_url); // Append querystring with custom field //$querystring .= "&custom=".USERID; // Redirect to paypal IPN header('location:https://www.sandbox.paypal.com/cgi-bin/webscr'.$querystring); exit(); }else{ // Response from Paypal // read the post from PayPal system and add 'cmd' $req = 'cmd=_notify-validate'; foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $value = preg_replace('/(.*[^%^0^D])(%0A)(.*)/i','${1}%0D%0A${3}',$value);// IPN fix $req .= "&$key=$value"; } // assign posted variables to local variables $data['item_name'] = $_POST['item_name']; $data['item_number'] = $_POST['item_number']; $data['payment_status'] = $_POST['payment_status']; $data['payment_amount'] = $_POST['mc_gross']; $data['payment_currency'] = $_POST['mc_currency']; $data['txn_id'] = $_POST['txn_id']; $data['receiver_email'] = $_POST['receiver_email']; $data['payer_email'] = $_POST['payer_email']; $data['custom'] = $_POST['custom']; // post back to PayPal system to validate $header = "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; $fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); if (!$fp) { // HTTP ERROR } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp($res, "VERIFIED") == 0) { // Used for debugging //@mail("you@youremail.com", "PAYPAL DEBUGGING", "Verified Response<br />data = <pre>".print_r($post, true)."</pre>"); // Validate payment (Check unique txnid & correct price) $valid_txnid = check_txnid($data['txn_id']); $valid_price = check_price($data['payment_amount'], $data['item_number']); // PAYMENT VALIDATED & VERIFIED! if($valid_txnid && $valid_price){ $orderid = updatePayments($data); if($orderid){ // Payment has been made & successfully inserted into the Database }else{ // Error inserting into DB // E-mail admin or alert user } }else{ // Payment made but data has been changed // E-mail admin or alert user } }else if (strcmp ($res, "INVALID") == 0) { // PAYMENT INVALID & INVESTIGATE MANUALY! // E-mail admin or alert user // Used for debugging //@mail("you@youremail.com", "PAYPAL DEBUGGING", "Invalid Response<br />data = <pre>".print_r($post, true)."</pre>"); } } fclose ($fp); } } ?>
  19. using paypal.class.php i can edit the amount using firebug. how to resolve it. i have attached the files. please check with the attached screen shot. after changing the amount to zero using firebug paypal-1.3.0.zip
  20. i have used paypal class file which somebody says its not safe to use this class file in payment sites. please advise on this. i have doubts regarding the paypal ipn and i have 2 files 1) paypal.class.php 2) paypal.php i am using it in localserver should i add return url in my developer paypal account. i didnt add the return url but its working fine with the below url ex: https://localhost/paypal.php?success i am getting all the response here i have attached files please check it paypal-1.3.0.zip
  21. When I use this for my payments $txt = "<form name=\"makepay\" action=\"https://www.paypal.com/uk/cgi-bin/webscr\" method=\"post\">"; No email is returned
  22. Hi Guys Anyone knows how to include paypal payment in my code? here is my code, i already created sandbox acccount my problem is how can i add that paypal integration such as API, and other stuffs thanks! in Advance!
  23. I'd like to create an application where a user can fund an account. When a user does a certain task, they will get a certain amount of their money back. If they complete all their tasks, over time, they will get all of their money back. Any suggestions as to which payment gateway to use for this? I am nervous about getting hit with a ton of transaction fees. I am thinking I could use PayPal Payments Pro so that the user can fund their account with a credit card. Whenever they complete a task, I could issue a partial refund, which would go back against their credit card. Can I even issue multiple partial refunds on the same transaction ID, though? I'm not sure. And I also don't want a bunch of transaction fees on those refunds. Maybe there is a gateway out there which would only charge a transaction fee on the original transaction? I'm thinking about changing the design. A user funds their account with their credit card, and then once they complete ALL tasks, I can issue a single refund. This would avoid the many transaction fees associated with issuing a refund per task. But in order for this to be a successful app, I think the user should get a % of their money back right away after completing each task. Any advice on which Payment Gateway to use for this? Advice, or design considerations?
  24. I successfully implemented paypal ipn on my website, I tested it on the paypal sandbox and everything worked. Then I changed the url from https://www.sandbox..../cgi-bin/webscr to https://www.paypal.com/cgi-bin/webscr. This should be standard procedure and everything should work fine. Once again, when using the sandbox provided by paypal, there are no problems. Now a few of my customers tried to buy things and nobody got there items. In my database I log everything and I logged this error: http error=Unknown SSL protocol error in connection to www.paypal.com:443 I use paypal ipn for the payment, underneath will be the ipn.php (ipn call back script that paypal will post variables to when a payment has been done) //Original source: https://cms.paypal.com/cms_content/US/en_US/files/developer/IPN_PHP_41.txt //Modified sample code by Codex-m: http://www.php-developer.org //WORKING DEMO HERE: http://www.php-developer.org/paypal_ipn_demo/ //Use your Paypal Sandbox buyer account to test. $req = 'cmd=' . urlencode('_notify-validate'); foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } //NEW CODE: using Curl instead of fsockopen $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://www.paypal.com/cgi-bin/webscr'); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_POSTFIELDS, $req); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1); //curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: www.sandbox.paypal.com')); $res = curl_exec($ch); //assign posted variables to PHP variables $payment_status = $_POST['payment_status']; $payment_amount = $_POST['mc_gross']; $payment_currency = $_POST['mc_currency']; $txn_id = $_POST['txn_id']; $receiver_email = $_POST['receiver_email']; $payer_email = $_POST['payer_email']; $account=$_POST['custom']; $productname=$_POST['item_name']; $txn_type=$_POST['txn_type']; $trans_id=$_POST['transaction[0].id']; $trans_id_2=$_POST['transaction[0].id_for_sender']; //Check if any error occured if(curl_errno($ch)) { //HTTP ERROR occurred //Log error to database for troubleshooting $log='http error='.curl_error($ch); //Here the error message gets build db_write($log); //Here it gets written to the database } else { //NO HTTP ERROR OCCURRED, CLEAN //CHECK IF VERIFIED if (strcmp ($res, "VERIFIED") == 0) { I hope somebody knows what the problem is. Additional information about my webserver: ###### ApacheFriends XAMPP version 1.7.1 ###### + Apache 2.2.11 + MySQL 5.1.33 (Community Server) + PHP 5.2.9 + PEAR (Support for PHP 4 has been discontinued) + XAMPP Control Version 2.5 from www.nat32.com + XAMPP CLI Bundle 1.3 from Carsten Wiedmann + XAMPP Security 1.0 + SQLite 2.8.15 + OpenSSL 0.9.8i + phpMyAdmin 3.1.3.1 + ADOdb 5.06a + Mercury Mail Transport System v4.62 + FileZilla FTP Server 0.9.31 + Webalizer 2.01-10 + Zend Optimizer 3.3.0 + eAccelerator 0.9.5.3 for PHP 5.2.9 (but not activated in the php.ini)
  25. Tally The Total Error When I tally the total with an quantity of 2 my php calculate turn short up in php...But when I press the checkout button to paypal everything adds up correctly..... Shipment Trouble When I can add 2 or more items to my cart and checkout with paypal my shipment increase to another 10.00 dollars How would I fix that to remain 10.00? Tax calculate error the more items I add to my database my shipment changes from 0.08% to 0.02% How Would I fix these errors without any bugs ? $shipTotal="10.00"; $taxRate ="0.08"; $pricetotal = $price * $each_item['quantity']; $getTax = $price * $taxRate; $cartTotal = $pricetotal + $getTax + $shipTotal + $cartTotal ; setlocale(LC_MONETARY, "en_US"); $pricetotal = money_format("%10.2n", $pricetotal); // Dynamic Checkout Btn Assembly $x = $i + 1; $pp_checkout_btn .= '<input type="hidden" name="item_name_' . $x . '" value="' . $product_name . '"> <input type="hidden" name="amount_' . $x . '" value="' . $price . '"> <input type="hidden" name="quantity_' . $x . '" value="' . $each_item['quantity'] . '"> <input type="hidden" name="shipping_'. $x . '"value="'. $shipTotal .'"> <input type="hidden" name="tax_'. $x . '"value="'. $taxRate * $price .'"> '; // Create the product array variable $product_id_array .= "$item_id-".$each_item['quantity'].",";
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.