pdo - errors in PHP Paypal pay request -
i have written library program user can search books. onto part user can select item it's id , own username. sets a payment on paypal user approve. i've made start i'm quite lost. book id , fill use details stored in database - price , title set payment.
the first issue i'm having following error:
undefined index: book_id
i error price, user , title.
here code payment:
try { $dbh = new pdo('mysql:host=' . db_host . ';dbname=' . db_username, db_username, db_password); } catch (pdoexception $e) { print "error!: " . $e->getmessage() . "<br/>"; die(); } $book =$_post["book_id"]; $user =$_post["user"]; $price =$_get["price"]; $title =$_get["title"]; $sth = $dbh->prepare("select title, price books2 b_id=$book"); $sth->execute(); $payer = new payer(); $payer->setpaymentmethod("paypal"); $item1 = new item(); $item1->setname($title) ->setcurrency('usd') ->setquantity(1) ->setprice($price); $details = new details(); $details->setshipping(1.5) ->settax(1.7); $transaction = new transaction(); $transaction->setamount($price) ->setitemlist($item1) ->setdescription("payment description") ->setinvoicenumber(uniqid()); $baseurl = getbaseurl(); $redirecturls = new redirecturls(); $redirecturls->setreturnurl("$baseurl/review.php?success=true") ->setcancelurl("$baseurl/payment.php?success=false"); $payment = new payment(); $payment->setintent("sale") ->setpayer($user) ->setredirecturls($redirecturls) ->settransactions(array($transaction)); $execution = new paymentexecution(); $result = $payment->execute($execution, $apicontext); $request = clone $payment; try { $payment->create($apicontext); } catch (exception $ex) { resultprinter::printerror("created payment using paypal. please visit url approve.", "payment", null, $request, $ex); exit(1); } $approvalurl = $payment->getapprovallink(); resultprinter::printresult("setting payment using paypal. please visit url approve.", "payment", "<a href='$approvalurl' >$approvalurl</a>", $request, $payment); return $payment;
can tell why why i'm getting these errors can make code work?
undefined index means parameter you're expecting not available. apparently form not including book_id field.
what can troubleshoot add following page receives post data see receiving.
echo '<pre />'; print_r($_post);
Comments
Post a Comment