Paypal DoCapture batch process loop -
i trying implement batch process docapture api paypal. have code below , processes first record of database...help!! xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
<?php include("xxxxx.php");<---- database connection $query2="select * x payment_status = 'pending'"; // custom in ( // select custom // x // group custom // having count(custom) > 1 // ) //order custom"; $results=mysql_query($query2); $row2 = mysql_fetch_array($results); $row_count=mysql_num_rows($results); echo $row_count; //$auth=$row2['auth_id']; //while($row2 =mysql_fetch_array($results)){ $arrsize=sizeof($row_count); ($number = 0; $number < $arrsize; $number++) { //for($i=0; $i<$row_count; $i++){ echo $row2['auth_id']; // prints hello //echo $row2['auth_id']; /** docapture nvp example; last modified 08may23. * * capture payment. */ $environment = 'sandbox'; // or 'beta-sandbox' or 'live' /** * send http post request * * @param string api method name * @param string post message fields in &name=value pair format * @return array parsed http response body */ function pphttppost($methodname_, $nvpstr_) { //for($i=0; $i<$row_count; $i++){ global $environment; // set api credentials, paypal end point, , api version. $api_username = urlencode(''); $api_password = urlencode(''); $api_signature = urlencode('.'); $api_endpoint = "https://api-3t.sandbox.paypal.com/nvp"; if("sandbox" === $environment || "beta-sandbox" === $environment) { $api_endpoint = "https://api-3t.$environment.paypal.com/nvp"; } $version = urlencode('51.0'); // set curl parameters. $ch = curl_init(); curl_setopt($ch, curlopt_url, $api_endpoint); curl_setopt($ch, curlopt_verbose, 1); // turn off server , 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 api operation, version, , api signature in request. $nvpreq = "method=$methodname_&version=$version&pwd=$api_password&user=$api_username&signature=$api_signature$nvpstr_"; // set request post field curl. curl_setopt($ch, curlopt_postfields, $nvpreq); // response server. $httpresponse = curl_exec($ch); if(!$httpresponse) { exit("$methodname_ failed: ".curl_error($ch).'('.curl_errno($ch).')'); } // extract response details. $httpresponsear = explode("&", $httpresponse); $httpparsedresponsear = array(); foreach ($httpresponsear $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 post request($nvpreq) $api_endpoint."); } return $httpparsedresponsear; } // set request-specific fields. $authorizationid = urlencode($row2['auth_id']); $amount = urlencode('1.99'); $currency = urlencode('usd'); // or other currency ('gbp', 'eur', 'jpy', 'cad', 'aud') $completecodetype = urlencode('complete'); // or 'notcomplete' $invoiceid = urlencode('example_invoice_id'); $note = urlencode('example_note'); // add request-specific fields request string. $nvpstr="&authorizationid=$authorizationid&amt=$amount&completetype=$completecodetype¤cycode=$currency¬e=$note"; // execute api operation; see pphttppost function above. $httpparsedresponsear = pphttppost('docapture', $nvpstr); if("success" == strtoupper($httpparsedresponsear["ack"]) || "successwithwarning" == strtoupper($httpparsedresponsear["ack"])) { exit('capture completed successfully: '.print_r($httpparsedresponsear, true)); } else { exit('docapture failed: ' . print_r($httpparsedresponsear, true)); //} }} //} ?>
you're fetching 1 row out of database, because $row2 = mysql_fetch_array($results);
line outside of for
loop. essentially, you're trying capture same payment on , on again, , i'm willing bet first 1 succeeding. move fetch statement inside for
loop.