curl - sandbox paypal account transferring money to invalid accounts through php code -


in api, i'm using php code automatically transfer money amount 1 sandbox paypal account sandbox paypal account.but through php code, transactions occurring both valid invalid sandbox user accounts must not not happen @ all.

furthermore, cannot find way check in code whether receiver's sandbox account valid or not. if it's valid, transfer money receiver's account.

here code....

    //   paypal_class.php       class paypal {      public function __construct($username, $password, $signature) {     $this->username = urlencode($username);     $this->password = urlencode($password);     $this->signature = urlencode($signature);     $this->version = urlencode("122.0");     $this->api = "https://api-3t.sandbox.paypal.com/nvp";      //the functions can modified need urlencoded     $this->type = urlencode("emailaddress");     $this->currency = urlencode("usd");     $this->subject = urlencode("instant paypal payment"); }  public function pay($email, $amount, $note="instant payment") {     $string = "&emailsubject=".$this->subject."&receivertype=".$this->type."&currencycode=".$this->currency;      $string .= "&l_email0=".urlencode($email)."&l_amt0=".urlencode($amount)."&l_note0=".urlencode($note);      $ch = curl_init();     curl_setopt($ch, curlopt_url, $this->api);     curl_setopt($ch, curlopt_followlocation, true);     curl_setopt($ch, curlopt_verbose, 1);     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);     curl_setopt($ch, curlopt_failonerror, true);      curl_setopt($ch, curlopt_header, 0);     curl_setopt($ch, curlopt_post, 1);     $request = "method=masspay&version=".$this->version."&pwd=".$this->password."&user=".$this->username."&signature=".$this->signature."$string";      curl_setopt($ch, curlopt_postfields, $request);     $httpresponse = curl_exec($ch);      if(!$httpresponse) {         exit("masspay failed: ".curl_error($ch).'('.curl_errno($ch).')');     }      $httpresponsearray = explode("&", $httpresponse);     $httpparsedresponse = array();     foreach ($httpresponsearray $i => $value) {         $temparray = explode("=", $value);         if(sizeof($temparray) > 1) {             $httpparsedresponse[$temparray[0]] = $temparray[1];         }     }      if((0 == sizeof($httpparsedresponse)) || !array_key_exists('ack', $httpparsedresponse)) {         exit("invalid http response post request($request) ".$this->api);     }      return $httpparsedresponse; }  } ?> 

here code calling above functions.....

   // pay.php      <?php     require "paypal_class.php";      $paypal = new paypal("xxxxxxxxxxxxxxxxxxxxx", "xxxxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");      $send_payment = $paypal->pay("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "10.00", "thanks amazing service");     if("success" == strtoupper($send_payment["ack"]) || "successwithwarning" == strtoupper($send_payment["ack"])) {     exit('pay completed successfully: '.print_r($send_payment, true)); }  else  {     exit('pay failed: ' . print_r($send_payment, true)); } ?> 

the problem here whenever hit api, money transaction occurs on putting in wrong or invalid account id (sandbox).... can me code ... need code can check whether receiver's account valid or not.. if not shouldn't make transactions...rather must return "failure" message in response.

please help


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -