Is a valid paypal email address or not (PHP)

后端 未结 3 1804
滥情空心
滥情空心 2020-12-15 02:00

I am using paypal adaptive payments and i need to verify email address from paypal api given by the store/seller, so that the payment can be directly given to store by custo

3条回答
  •  不思量自难忘°
    2020-12-15 02:17

        $email_pay=json_decode($this->config->item('paypal_payment')); 
        $paypal_email=$email_pay->email;
        $paypal_username=$email_pay->username;
        $paypal_password=$email_pay->password;
        $paypal_appid=$email_pay->appid;
        $paypal_signature=$email_pay->signature;
        $mode=$email_pay->mode;
        if($mode==0)
        {
            $API_Endpoint = "https://svcs.sandbox.paypal.com/AdaptiveAccounts/GetVerifiedStatus";
        }
        else
        {
            $API_Endpoint = "https://svcs.paypal.com/AdaptiveAccounts/GetVerifiedStatus";
        }
    
        $ret['error_new']='';   
        $payLoad["emailAddress"]=$_POST['paypal_email'];
        $payLoad["matchCriteria"]="NONE";       $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
        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_HTTPHEADER,  array(
            'X-PAYPAL-REQUEST-DATA-FORMAT: JSON',
            'X-PAYPAL-RESPONSE-DATA-FORMAT: JSON',
            'X-PAYPAL-SECURITY-USERID: '. $paypal_username,
            'X-PAYPAL-SECURITY-PASSWORD: '. $paypal_password,
            'X-PAYPAL-SECURITY-SIGNATURE: '. $paypal_signature,
            'X-PAYPAL-APPLICATION-ID: '. $paypal_appid
        ));  
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payLoad));
        $response = curl_exec($ch);
        $response = json_decode($response, 1); 
        if(empty($response['error'])){
            //valid account
        }
        else{
            $ret['error_new']='Please enter valid paypal email id.';    
        }
    
        }       
        else
        {           
            $ret['status']=0;
        }
        echo json_encode($ret);
    

提交回复
热议问题