php - Cannot pass a negative value at paypal express checkout -
my paypal express check out work before trying add negative value coupon discount. cannot understand codding how pass negative value. please see script below:
//pass products foreach($_post['item_name'] $key=>$itmname) { $product_code = filter_var($_post['item_code'][$key], filter_sanitize_string); $results = $dbh->query("select name, price products id='$product_code' limit 1"); $obj = $results->fetch_object(); $paypal_data .= '&l_paymentrequest_0_name'.$key.'='.urlencode($obj->name). '&l_paymentrequest_0_number'.$key.'='.urlencode($_post['item_code'][$key]). '&l_paymentrequest_0_amt'.$key.'='.urlencode($obj->price). '&l_paymentrequest_0_qty'.$key.'='. urlencode($_post['item_qty'][$key]); // item price x quantity $subtotal = ($obj->price*$_post['item_qty'][$key]); //total price $itemtotalprice = $itemtotalprice + $subtotal; } ############################################## // trying pass negative value in way if($_session["coupon_discount"] > $itemtotalprice){ $cname = "coupon discount"; $ccode = "code"; $cqty = 1; $camt = 5; $paypal_data .= '&l_paymentrequest_0_name='.urlencode($cname). '&l_paymentrequest_0_number='.urlencode($ccode). '&l_paymentrequest_0_qty='.urlencode($cqty). '&l_paymentrequest_0_amt='.urlencode($camt); } ############################################## // others paypal process $totaltaxamount = 0; $handalingcost = 0; $insurancecost = 0; $shippindiscount = 0; $shippincost = 0; $grandtotal = ($itemtotalprice + $totaltaxamount + $handalingcost + $insurancecost + $shippincost + $shippindiscount); $padata = '&method=setexpresscheckout'. '&returnurl='.urlencode($paypalreturnurl ). '&cancelurl='.urlencode($paypalcancelurl). '&paymentrequest_0_paymentaction='.urlencode("sale"). $paypal_data. '&noshipping=0'. '&paymentrequest_0_itemamt='.urlencode($itemtotalprice). '&paymentrequest_0_taxamt='.urlencode($totaltaxamount). '&paymentrequest_0_shippingamt='.urlencode($shippincost). '&paymentrequest_0_handlingamt='.urlencode($handalingcost). '&paymentrequest_0_shipdiscamt='.urlencode($shippindiscount). '&paymentrequest_0_insuranceamt='.urlencode($insurancecost). '&paymentrequest_0_amt='.urlencode($grandtotal). '&paymentrequest_0_currencycode='.urlencode($paypalcurrencycode). '&localecode=gb'. '&logoimg=http://www.myweb.com/images/logo.png'. '&cartbordercolor=000000'. '&allownote=1'; // setexpresscheckout method obtain paypal token $paypal= new mypaypal(); $httpparsedresponsear = $paypal->pphttppost('setexpresscheckout', $padata, $paypalapiusername, $paypalapipassword, $paypalapisignature, $paypalmode); // success or error done here
here problem star after added these lines
if($_session["coupon_discount"] > $itemtotalprice){ $cname = "coupon discount"; $ccode = "code"; $cqty = 1; $camt = 5; $paypal_data .= '&l_paymentrequest_0_name='.urlencode($cname). '&l_paymentrequest_0_number='.urlencode($ccode). '&l_paymentrequest_0_qty='.urlencode($cqty). '&l_paymentrequest_0_amt='.urlencode($camt); }
this 1 makes me smile. can transfer money account otherwise smart person use negative values drain account. security.
Comments
Post a Comment