/**
  * hash_call: Function to perform the API call to PayPal using API signature
  * @methodName is name of API  method.
  * @nvpStr is nvp string.
  * returns an associtive array containing the response from the server.
*/
function hash_call($methodName, $nvpStr)
{
    $CI =& get_instance();
    $paypal = $CI->get_paypal_account();
    $API_UserName = $paypal->apiuser;
    $API_Password = $paypal->apipass;
    $API_Signature = $paypal->apisign;
    $API_Endpoint = API_ENDPOINT;
    $version = VERSION;
    $subject = SUBJECT;
    //setting the curl parameters.
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    //turning off the server and 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);
    //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
    //Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php
    if (USE_PROXY) {
        curl_setopt($ch, CURLOPT_PROXY, PROXY_HOST . ":" . PROXY_PORT);
    }
    //check if version is included in $nvpStr else include the version.
    if (strlen(str_replace('VERSION=', '', strtoupper($nvpStr))) == strlen($nvpStr)) {
        $nvpStr = "&VERSION=" . urlencode($version) . $nvpStr;
    }
    $nvpreq = "METHOD=" . urlencode($methodName) . $nvpStr;
    //setting the nvpreq as POST FIELD to curl
    curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
    //getting response from server
    $response = curl_exec($ch);
    //convrting NVPResponse to an Associative Array
    $nvpResArray = deformatNVP($response);
    $nvpReqArray = deformatNVP($nvpreq);
    $_SESSION['nvpReqArray'] = $nvpReqArray;
    if (curl_errno($ch)) {
        // moving to display page to display curl errors
        $_SESSION['curl_error_no'] = curl_errno($ch);
        $_SESSION['curl_error_msg'] = curl_error($ch);
        return false;
    } else {
        //closing the curl
        curl_close($ch);
    }
    return $nvpResArray;
}
Example #2
0
/**
  * hash_call: Function to perform the API call to PayPal using API signature
  * @methodName is name of API  method.
  * @nvpStr is nvp string.
  * returns an associtive array containing the response from the server.
*/
function hash_call($methodName, $nvpStr)
{
    $API_UserName = "******";
    $API_Password = "******";
    $API_Signature = "AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy";
    $API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp";
    $version = urlencode("53.0");
    //echo "string"; die();
    //declaring of global variables
    //global $API_Endpoint,$version,$API_UserName,$API_Password,$API_Signature,$nvp_Header;
    //setting the curl parameters.
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://api-3t.sandbox.paypal.com/nvp");
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    //turning off the server and 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);
    //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
    //Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php
    if (USE_PROXY) {
        curl_setopt($ch, CURLOPT_PROXY, PROXY_HOST . ":" . PROXY_PORT);
    }
    //NVPRequest for submitting to server
    $nvpreq = "METHOD=" . urlencode($methodName) . "&VERSION=" . urlencode("53.0") . "&PWD=" . urlencode("WX4WTU3S8MY44S7F") . "&USER="******"jb-us-seller_api1.paypal.com") . "&SIGNATURE=" . urlencode("AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy") . $nvpStr;
    //setting the nvpreq as POST FIELD to curl
    curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
    //getting response from server
    $response = curl_exec($ch);
    //	print_r($response); die();
    //convrting NVPResponse to an Associative Array
    $nvpResArray = deformatNVP($response);
    $nvpReqArray = deformatNVP($nvpreq);
    $_SESSION['nvpReqArray'] = $nvpReqArray;
    if (curl_errno($ch)) {
        // moving to display page to display curl errors
        $_SESSION['curl_error_no'] = curl_errno($ch);
        $_SESSION['curl_error_msg'] = curl_error($ch);
        $location = "APIError.php";
        header("Location: {$location}");
    } else {
        //closing the curl service
        curl_close($ch);
    }
    return $nvpResArray;
}
/**
  * hash_call: Function to perform the API call to PayPal using API signature
  * @methodName is name of API  method.
  * @nvpStr is nvp string.
  * returns an associtive array containing the response from the server.
*/
function hash_call($methodName, $nvpStr, $sandboxEmailAddress = '')
{
    //declaring of global variables
    $URL = API_ENDPOINT . $methodName;
    //setting the curl parameters.
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $URL);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    //turning off the server and peer verification(TrustManager Concept).
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
    //Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php
    if (USE_PROXY) {
        curl_setopt($ch, CURLOPT_PROXY, PROXY_HOST . ":" . PROXY_PORT);
    }
    $headers_array = setupHeaders();
    if (!empty($sandboxEmailAddress)) {
        $headers_array[] = "X-PAYPAL-SANDBOX-EMAIL-ADDRESS: " . $sandboxEmailAddress;
    }
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers_array);
    curl_setopt($ch, CURLOPT_HEADER, false);
    //setting the nvpreq as POST FIELD to curl
    curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpStr);
    //getting response from server
    $response = curl_exec($ch);
    //convrting NVPResponse to an Associative Array
    $nvpResArray = deformatNVP($response);
    //$nvpReqArray=deformatNVP($nvpreq);
    //$_SESSION['nvpReqArray']=$nvpReqArray;
    if (curl_errno($ch)) {
        // moving to display page to display curl errors
        $_SESSION['curl_error_no'] = curl_errno($ch);
        $_SESSION['curl_error_msg'] = curl_error($ch);
        $location = "APIError.php";
        header("Location: {$location}");
    } else {
        //closing the curl
        curl_close($ch);
    }
    return $nvpResArray;
}
Example #4
0
/**
  * hash_call: Function to perform the API call to PayPal using API signature
  * @methodName is name of API  method.
  * @nvpStr is nvp string.
  * returns an associtive array containing the response from the server.
*/
function hash_call($methodName, $nvpStr)
{
    //declaring of global variables
    global $API_Endpoint, $version, $API_UserName, $API_Password, $API_Signature, $nvp_Header, $subject;
    //setting the curl parameters.
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    //turning off the server and 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);
    //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
    //Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php
    if (USE_PROXY) {
        curl_setopt($ch, CURLOPT_PROXY, PROXY_HOST . ":" . PROXY_PORT);
    }
    //check if version is included in $nvpStr else include the version.
    if (strlen(str_replace('VERSION=', '', strtoupper($nvpStr))) == strlen($nvpStr)) {
        $nvpStr = "&VERSION=" . $version . $nvpStr;
    }
    $nvpreq = "METHOD=" . $methodName . $nvpStr;
    //setting the nvpreq as POST FIELD to curl
    curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
    //getting response from server
    $response = curl_exec($ch);
    //convrting NVPResponse to an Associative Array
    $nvpResArray = deformatNVP($response);
    $nvpReqArray = deformatNVP($nvpreq);
    $_SESSION['nvpReqArray'] = $nvpReqArray;
    if (curl_errno($ch)) {
        // moving to display page to display curl errors
        $_SESSION['curl_error_no'] = curl_errno($ch);
        $_SESSION['curl_error_msg'] = curl_error($ch);
        $location = "APIError.php";
        header("Location: {$location}");
    } else {
        //closing the curl
        curl_close($ch);
    }
    return $nvpResArray;
}
Example #5
0
/**
 * hash_call: Function to perform the API call to PayPal using API signature
 * @methodName is name of API  method.
 * @nvpStr is nvp string.
 * returns an associtive array containing the response from the server.
 */
function hash_call($methodName, $nvpStr)
{
    //declaring of global variables
    global $API_Endpoint, $version, $API_UserName, $API_Password, $API_Signature, $nvp_Header;
    //setting the curl parameters.
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, API_ENDPOINT);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    //turning off the server and 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);
    //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
    //Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php
    if (USE_PROXY) {
        curl_setopt($ch, CURLOPT_PROXY, PROXY_HOST . ":" . PROXY_PORT);
    }
    //NVPRequest for submitting to server
    $nvpreq = "METHOD=" . urlencode($methodName) . "&VERSION=" . urlencode(VERSION) . "&PWD=" . urlencode(API_PASSWORD) . "&USER="******"&SIGNATURE=" . urlencode(API_SIGNATURE) . $nvpStr;
    curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
    //getting response from server
    $response = curl_exec($ch);
    //convrting NVPResponse to an Associative Array
    $nvpResArray = deformatNVP($response);
    $nvpReqArray = deformatNVP($nvpreq);
    $_SESSION['nvpReqArray'] = $nvpReqArray;
    if (curl_errno($ch)) {
        // moving to display page to display curl errors
        $_SESSION['curl_error_no'] = curl_errno($ch);
        $_SESSION['curl_error_msg'] = curl_error($ch);
        /*$location = "APIError.php";
        	 header("Location: $location");*/
        require_once SITE_ABSOLUTE_PATH . 'library/core/transaction/method/paypal/APIError.php';
    } else {
        //closing the curl
        curl_close($ch);
    }
    return $nvpResArray;
}
Example #6
0
/**
  * hash_call: Function to perform the API call to PayPal using API signature
  * @methodName is name of API  method.
  * @nvpStr is nvp string.
  * returns an associtive array containing the response from the server.
*/
function hash_call($methodName, $nvpStr)
{
    //declaring of global variables
    //setting the curl parameters.
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, API_ENDPOINT);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    //turning off the server and 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);
    //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
    //Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php
    if (USE_PROXY) {
        curl_setopt($ch, CURLOPT_PROXY, PROXY_HOST . ":" . PROXY_PORT);
    }
    //NVPRequest for submitting to server
    $nvpreq = "METHOD=" . urlencode($methodName) . "&VERSION=" . urlencode(VERSION) . "&PWD=" . urlencode(API_PASSWORD) . "&USER="******"&SIGNATURE=" . urlencode(API_SIGNATURE) . $nvpStr;
    //setting the nvpreq as POST FIELD to curl
    curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
    //getting response from server
    $response = curl_exec($ch);
    //convrting NVPResponse to an Associative Array
    $nvpResArray = deformatNVP($response);
    $nvpReqArray = deformatNVP($nvpreq);
    $_SESSION['nvpReqArray'] = $nvpReqArray;
    if (curl_errno($ch)) {
        // moving to display page to display curl errors
        $_SESSION['curl_error_no'] = curl_errno($ch);
        $_SESSION['curl_error_msg'] = curl_error($ch);
        $location = $_SERVER['REQUEST_URI'] . "?paypal=error&function=callerservice";
        header("Location: {$location}");
        exit;
    } else {
        //closing the curl
        curl_close($ch);
    }
    return $nvpResArray;
}
function hash_call($methodName, $nvpStr, $API_UserName, $API_Password, $API_Signature, $API_Endpoint)
{
    //declaring of global variables
    global $nvp_Header;
    $version = '51.1';
    $PAYPAL_URL = 'https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token=';
    //setting the curl parameters.
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    //turning off the server and 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);
    //NVPRequest for submitting to server
    $nvpreq = "METHOD=" . urlencode($methodName) . "&VERSION=" . urlencode($version) . "&PWD=" . urlencode($API_Password) . "&USER="******"&SIGNATURE=" . urlencode($API_Signature) . $nvpStr;
    //setting the nvpreq as POST FIELD to curl
    curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
    //getting response from server
    $response = curl_exec($ch);
    //convrting NVPResponse to an Associative Array
    $nvpResArray = deformatNVP($response);
    $nvpReqArray = deformatNVP($nvpreq);
    $_SESSION['nvpReqArray'] = $nvpReqArray;
    if (curl_errno($ch)) {
        // moving to display page to display curl errors
        $_SESSION['curl_error_no'] = curl_errno($ch);
        $_SESSION['curl_error_msg'] = curl_error($ch);
        $location = "APIError.php";
        header("Location: {$location}");
    } else {
        //closing the curl
        curl_close($ch);
    }
    return $nvpResArray;
}
Example #8
0
/**
  '-------------------------------------------------------------------------------------------------------------------------------------------
  * hash_call: Function to perform the API call to PayPal using API signature
  * @methodName is name of API  method.
  * @nvpStr is nvp string.
  * returns an associtive array containing the response from the server.
  '-------------------------------------------------------------------------------------------------------------------------------------------
*/
function hash_call($methodName, $nvpStr)
{
    //declaring of global variables
    global $API_Endpoint, $version, $API_UserName, $API_Password, $API_Signature;
    global $USE_PROXY, $PROXY_HOST, $PROXY_PORT;
    global $gv_ApiErrorURL;
    global $sBNCode;
    //setting the curl parameters.
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    //turning off the server and 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);
    //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
    //Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php
    if ($USE_PROXY) {
        curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST . ":" . $PROXY_PORT);
    }
    //NVPRequest for submitting to server
    $nvpreq = "METHOD=" . urlencode($methodName) . "&VERSION=" . urlencode($version) . "&PWD=" . urlencode($API_Password) . "&USER="******"&SIGNATURE=" . urlencode($API_Signature) . $nvpStr . "&BUTTONSOURCE=" . urlencode($sBNCode);
    //setting the nvpreq as POST FIELD to curl
    curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
    //getting response from server
    $response = curl_exec($ch);
    //convrting NVPResponse to an Associative Array
    $nvpResArray = deformatNVP($response);
    $nvpReqArray = deformatNVP($nvpreq);
    $_SESSION['nvpReqArray'] = $nvpReqArray;
    if (curl_errno($ch)) {
        // moving to display page to display curl errors
        $_SESSION['curl_error_no'] = curl_errno($ch);
        $_SESSION['curl_error_msg'] = curl_error($ch);
        //Execute the Error handling module to display errors.
    } else {
        //closing the curl
        curl_close($ch);
    }
    return $nvpResArray;
}
Example #9
0
/**
 * hash_call: Function to perform the API call to PayPal using API signature
 * @param	methodName 	is name of API  method.
 * @param	nvpStr 		is nvp string.
 * @return	array		returns an associtive array containing the response from the server.
 */
function hash_call($methodName, $nvpStr)
{
    //declaring of global variables
    global $conf, $langs;
    global $API_Endpoint, $API_Url, $API_version, $USE_PROXY, $PROXY_HOST, $PROXY_PORT, $PROXY_USER, $PROXY_PASS;
    global $PAYPAL_API_USER, $PAYPAL_API_PASSWORD, $PAYPAL_API_SIGNATURE;
    // TODO problem with triggers
    $API_version = "56";
    if ($conf->global->PAYPAL_API_SANDBOX) {
        $API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp";
        $API_Url = "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=";
    } else {
        $API_Endpoint = "https://api-3t.paypal.com/nvp";
        $API_Url = "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=";
    }
    // Clean parameters
    $PAYPAL_API_USER = "";
    if ($conf->global->PAYPAL_API_USER) {
        $PAYPAL_API_USER = $conf->global->PAYPAL_API_USER;
    }
    $PAYPAL_API_PASSWORD = "";
    if ($conf->global->PAYPAL_API_PASSWORD) {
        $PAYPAL_API_PASSWORD = $conf->global->PAYPAL_API_PASSWORD;
    }
    $PAYPAL_API_SIGNATURE = "";
    if ($conf->global->PAYPAL_API_SIGNATURE) {
        $PAYPAL_API_SIGNATURE = $conf->global->PAYPAL_API_SIGNATURE;
    }
    $PAYPAL_API_SANDBOX = "";
    if ($conf->global->PAYPAL_API_SANDBOX) {
        $PAYPAL_API_SANDBOX = $conf->global->PAYPAL_API_SANDBOX;
    }
    // TODO END problem with triggers
    dol_syslog("Paypal API endpoint " . $API_Endpoint);
    //setting the curl parameters.
    $ch = curl_init();
    /*print $API_Endpoint."-".$API_version."-".$PAYPAL_API_USER."-".$PAYPAL_API_PASSWORD."-".$PAYPAL_API_SIGNATURE."<br>";
      print $USE_PROXY."-".$gv_ApiErrorURL."<br>";
      print $nvpStr;
      exit;*/
    curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    //turning off the server and 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);
    //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
    if ($USE_PROXY) {
        dol_syslog("Paypal API hash_call set proxy to " . $PROXY_HOST . ":" . $PROXY_PORT . " - " . $PROXY_USER . ":" . $PROXY_PASS);
        //curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); // Curl 7.10
        curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST . ":" . $PROXY_PORT);
        if ($PROXY_USER) {
            curl_setopt($ch, CURLOPT_PROXYUSERPWD, $PROXY_USER . ":" . $PROXY_PASS);
        }
    }
    //NVPRequest for submitting to server
    $nvpreq = "METHOD=" . urlencode($methodName) . "&VERSION=" . urlencode($API_version) . "&PWD=" . urlencode($PAYPAL_API_PASSWORD) . "&USER="******"&SIGNATURE=" . urlencode($PAYPAL_API_SIGNATURE) . $nvpStr;
    $nvpreq .= "&LOCALE=" . strtoupper($langs->getDefaultLang(1));
    //$nvpreq.="&BRANDNAME=".urlencode();       // Override merchant name
    //$nvpreq.="&NOTIFYURL=".urlencode();       // For Instant Payment Notification url
    dol_syslog("Paypal API hash_call nvpreq=" . $nvpreq);
    //setting the nvpreq as POST FIELD to curl
    curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
    //getting response from server
    $response = curl_exec($ch);
    $nvpReqArray = deformatNVP($nvpreq);
    $_SESSION['nvpReqArray'] = $nvpReqArray;
    //convrting NVPResponse to an Associative Array
    dol_syslog("Paypal API hash_call Response nvpresp=" . $response);
    $nvpResArray = deformatNVP($response);
    if (curl_errno($ch)) {
        // moving to display page to display curl errors
        $_SESSION['curl_error_no'] = curl_errno($ch);
        $_SESSION['curl_error_msg'] = curl_error($ch);
        //Execute the Error handling module to display errors.
    } else {
        //closing the curl
        curl_close($ch);
    }
    return $nvpResArray;
}
Example #10
0
/**
  * hash_call: Function to perform the API call to PayPal using API signature
  * @methodName is name of API  method.
  * @nvpStr is nvp string.
  * returns an associtive array containing the response from the server.
*/
function hash_call($methodName, $nvpStr)
{
    global $vmLogger;
    $API_UserName = PAYPAL_API_API_USERNAME;
    $API_Password = PAYPAL_API_API_PASSWORD;
    $API_Signature = PAYPAL_API_API_SIGNATURE;
    $version = PAYPAL_API_VERSION;
    $nvpreq = "METHOD=" . urlencode($methodName) . "&VERSION=" . urlencode($version) . "&PWD=" . urlencode($API_Password) . "&USER="******"&SIGNATURE=" . urlencode($API_Signature);
    }
    $nvpreq .= $nvpStr;
    //setting the curl parameters.
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    //turning off the server and 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);
    if (VM_PROXY_URL != '') {
        curl_setopt($ch, CURLOPT_PROXY, VM_PROXY_URL . ":" . VM_PROXY_PORT);
    }
    //NVPRequest for submitting to server
    $nvpreq = "METHOD=" . urlencode($methodName) . "&VERSION=" . urlencode($version) . "&PWD=" . urlencode($API_Password) . "&USER="******"&SIGNATURE=" . urlencode($API_Signature) . $nvpStr;
    //setting the nvpreq as POST FIELD to curl
    curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
    //getting response from server
    $response = curl_exec($ch);
    //Write Logs for PayPal Certification
    //writeToLog($nvpreq, $response, $methodName);
    //convrting NVPResponse to an Associative Array
    $nvpResArray = deformatNVP($response);
    $nvpReqArray = deformatNVP($nvpreq);
    $_SESSION['nvpReqArray'] = $nvpReqArray;
    if (curl_errno($ch)) {
        // moving to display page to display curl errors
        $vmLogger->err(curl_errno($ch) . ' - ' . curl_error($ch));
        return false;
    } else {
        //closing the curl
        curl_close($ch);
    }
    return $nvpResArray;
}
 /**
  * hash_call: Function to perform the API call to PayPal using API signature
  * @methodName is name of API  method.
  * @nvpStr is nvp string.
  * returns an associtive array containing the response from the server.
  */
 public static function hash_call($methodName, $nvpStr)
 {
     //declaring of global variables
     $API_UserName = PayPalConfig::$API_USERNAME;
     $API_Password = PayPalConfig::$API_PASSWORD;
     $API_Signature = PayPalConfig::$API_SIGNATURE;
     $API_Endpoint = PayPalConfig::$API_ENDPOINT;
     //
     $version = PayPalConfig::$VERSION;
     $subject = PayPalConfig::$SUBJECT;
     $AUTH_token = PayPalConfig::$AUTH_TOKEN;
     $AUTH_signature = PayPalConfig::$AUTH_SIGNATURE;
     $AUTH_timestamp = PayPalConfig::$AUTH_TIMESTAMP;
     // form header string
     $nvpheader = PayPalCallerService::nvpHeader();
     //setting the curl parameters.
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
     curl_setopt($ch, CURLOPT_VERBOSE, 1);
     //turning off the server and 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);
     //in case of permission APIs send headers as HTTPheders
     if (!empty($AUTH_token) && !empty($AUTH_signature) && !empty($AUTH_timestamp)) {
         $headers_array[] = "X-PP-AUTHORIZATION: " . $nvpheader;
         curl_setopt($ch, CURLOPT_HTTPHEADER, $headers_array);
         curl_setopt($ch, CURLOPT_HEADER, false);
     } else {
         $nvpStr = $nvpheader . $nvpStr;
     }
     //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
     //Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php
     if (USE_PROXY) {
         curl_setopt($ch, CURLOPT_PROXY, PROXY_HOST . ":" . PROXY_PORT);
     }
     //check if version is included in $nvpStr else include the version.
     if (strlen(str_replace('VERSION=', '', strtoupper($nvpStr))) == strlen($nvpStr)) {
         $nvpStr = "&VERSION=" . urlencode($version) . $nvpStr;
     }
     $nvpreq = "METHOD=" . urlencode($methodName) . $nvpStr;
     //setting the nvpreq as POST FIELD to curl
     curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
     //getting response from server
     $response = curl_exec($ch);
     //convrting NVPResponse to an Associative Array
     $nvpResArray = deformatNVP($response);
     $nvpReqArray = deformatNVP($nvpreq);
     $_SESSION['nvpReqArray'] = $nvpReqArray;
     if (curl_errno($ch)) {
         // moving to display page to display curl errors
         $_SESSION['curl_error_no'] = curl_errno($ch);
         $_SESSION['curl_error_msg'] = curl_error($ch);
         $location = "APIError.php";
         header("Location: {$location}");
     } else {
         //closing the curl
         curl_close($ch);
     }
     return $nvpResArray;
 }
Example #12
0
/**
  '-------------------------------------------------------------------------------------------------------------------------------------------
  * hash_call: Function to perform the API call to Payflow
  * @nvpStr is nvp string.
  * returns an associtive array containing the response from the server.
  '-------------------------------------------------------------------------------------------------------------------------------------------
*/
function hash_call($nvpStr, $unique_id)
{
    //declaring of global variables
    global $API_Endpoint, $API_User, $API_Password, $API_Vendor, $API_Partner;
    global $USE_PROXY, $PROXY_HOST, $PROXY_PORT;
    global $gv_ApiErrorURL;
    global $sBNCode;
    $len = strlen($nvpStr);
    $headers[] = "Content-Type: text/namevalue";
    $headers[] = "Content-Length: " . $len;
    // Set the server timeout value to 45, but notice below in the cURL section, the timeout
    // for cURL is set to 90 seconds.  Make sure the server timeout is less than the connection.
    $headers[] = "X-VPS-CLIENT-TIMEOUT: 45";
    $headers[] = "X-VPS-REQUEST-ID:" . $unique_id;
    // set the host header
    if ($Env == "pilot") {
        $headers[] = "Host: pilot-payflowpro.paypal.com";
    } else {
        $headers[] = "Host: payflowpro.paypal.com";
    }
    //setting the curl parameters.
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    //turning off the server and 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_TIMEOUT, 90);
    // times out after 90 secs
    curl_setopt($ch, CURLOPT_POST, 1);
    //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
    //Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php
    if ($USE_PROXY) {
        curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST . ":" . $PROXY_PORT);
    }
    //NVPRequest for submitting to server
    $nvpreq = "USER="******"&BUTTONSOURCE=" . urlencode($sBNCode);
    //setting the nvpreq as POST FIELD to curl
    curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
    //getting response from server
    $response = curl_exec($ch);
    //convrting NVPResponse to an Associative Array
    $nvpResArray = deformatNVP($response);
    $nvpReqArray = deformatNVP($nvpreq);
    $_SESSION['nvpReqArray'] = $nvpReqArray;
    if (curl_errno($ch)) {
        // moving to display page to display curl errors
        $_SESSION['curl_error_no'] = curl_errno($ch);
        $_SESSION['curl_error_msg'] = curl_error($ch);
        //Execute the Error handling module to display errors.
    } else {
        //closing the curl
        curl_close($ch);
    }
    return $nvpResArray;
}
Example #13
0
/**
  '-------------------------------------------------------------------------------------------------------------------------------------------
  * hash_call: Function to perform the API call to PayPal using API signature
  * @methodName is name of API  method.
  * @nvpStr is nvp string.
  * returns an associtive array containing the response from the server.
  '-------------------------------------------------------------------------------------------------------------------------------------------
*/
function hash_call($methodName, $nvpStr)
{
    $PROXY_HOST = '127.0.0.1';
    $PROXY_PORT = '808';
    $SandboxFlag = true;
    //'------------------------------------
    //' PayPal API Credentials
    //' Replace <API_USERNAME> with your API Username
    //' Replace <API_PASSWORD> with your API Password
    //' Replace <API_SIGNATURE> with your Signature
    //'------------------------------------
    $API_UserName = "******";
    $API_Password = "******";
    $API_Signature = "AAi6CWPybjLDCnq96kqzJlVNxN9IAiMmDzmtD-c0wQNDghNMJ.aq5qof";
    // BN Code 	is only applicable for partners
    $sBNCode = "PP-ECWizard";
    /*	
    ' Define the PayPal Redirect URLs.  
    ' 	This is the URL that the buyer is first sent to do authorize payment with their paypal account
    ' 	change the URL depending if you are testing on the sandbox or the live PayPal site
    '
    ' For the sandbox, the URL is       https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token=
    ' For the live site, the URL is        https://www.paypal.com/webscr&cmd=_express-checkout&token=
    */
    if ($SandboxFlag == true) {
        $API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp";
        $PAYPAL_URL = "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=";
    } else {
        $API_Endpoint = "https://api-3t.paypal.com/nvp";
        $PAYPAL_URL = "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=";
    }
    $USE_PROXY = false;
    $version = "64";
    if (session_id() == "") {
        session_start();
    }
    //setting the curl parameters.
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    //turning off the server and 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);
    //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
    //Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php
    if ($USE_PROXY) {
        curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST . ":" . $PROXY_PORT);
    }
    //NVPRequest for submitting to server
    $nvpreq = "METHOD=" . urlencode($methodName) . "&VERSION=" . urlencode($version) . "&PWD=" . urlencode($API_Password) . "&USER="******"&SIGNATURE=" . urlencode($API_Signature) . $nvpStr . "&BUTTONSOURCE=" . urlencode($sBNCode);
    echo $nvpreq . "<br>";
    //setting the nvpreq as POST FIELD to curl
    curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
    //getting response from server
    $response = curl_exec($ch);
    print_r($ch);
    //convrting NVPResponse to an Associative Array
    $nvpResArray = deformatNVP($response);
    $nvpReqArray = deformatNVP($nvpreq);
    $_SESSION['nvpReqArray'] = $nvpReqArray;
    if (curl_errno($ch)) {
        // moving to display page to display curl errors
        $_SESSION['curl_error_no'] = curl_errno($ch);
        $_SESSION['curl_error_msg'] = curl_error($ch);
        //Execute the Error handling module to display errors.
    } else {
        //closing the curl
        curl_close($ch);
    }
    return $nvpResArray;
}
Example #14
0
/**
  * hash_call: Function to perform the API call to PayPal using API signature
  * @methodName is name of API  method.
  * @nvpStr is nvp string.
  * returns an associtive array containing the response from the server.
*/
function hash_call($methodName, $nvpStr)
{
    global $WCMp, $API_Endpoint, $version, $API_UserName, $API_Password, $API_Signature, $nvp_Header, $subject, $AUTH_token, $AUTH_signature, $AUTH_timestamp;
    // form header string
    $nvpheader = nvpHeader();
    //setting the curl parameters.
    $ch = curl_init();
    //doProductVendorLOG(API_ENDPOINT);
    curl_setopt($ch, CURLOPT_URL, API_ENDPOINT);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    //turning off the server and 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);
    //in case of permission APIs send headers as HTTPheders
    if (defined('AUTH_TOKEN') && defined('AUTH_SIGNATURE') && defined('AUTH_TIMESTAMP')) {
        $headers_array[] = "X-PP-AUTHORIZATION: " . $nvpheader;
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers_array);
        curl_setopt($ch, CURLOPT_HEADER, false);
    } else {
        $nvpStr = $nvpheader . $nvpStr;
    }
    //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
    //Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php
    if (USE_PROXY) {
        curl_setopt($ch, CURLOPT_PROXY, PROXY_HOST . ":" . PROXY_PORT);
    }
    //check if version is included in $nvpStr else include the version.
    if (strlen(str_replace('VERSION=', '', strtoupper($nvpStr))) == strlen($nvpStr)) {
        $nvpStr = "&VERSION=" . urlencode(VERSION) . $nvpStr;
    }
    $nvpreq = "METHOD=" . urlencode($methodName) . $nvpStr;
    //setting the nvpreq as POST FIELD to curl
    curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
    //getting response from server
    $response = curl_exec($ch);
    //convrting NVPResponse to an Associative Array
    $nvpResArray = deformatNVP($response);
    $nvpReqArray = deformatNVP($nvpreq);
    $_SESSION['nvpReqArray'] = $nvpReqArray;
    if (curl_errno($ch)) {
        // moving to display page to display curl errors
        $_SESSION['curl_error_no'] = curl_errno($ch);
        $_SESSION['curl_error_msg'] = curl_error($ch);
    }
    //closing the curl
    curl_close($ch);
    return $nvpResArray;
}
Example #15
0
/**
  * hash_call: Function to perform the API call to PayPal using API signature
  * @methodName is name of API  method.
  * @nvpStr is nvp string.
  * returns an associtive array containing the response from the server.
*/
function hash_call($methodName, $nvpStr)
{
    //declaring of global variables
    global $API_Endpoint, $version, $API_UserName, $API_Password, $API_Signature, $nvp_Header, $subject, $AUTH_token, $AUTH_signature, $AUTH_timestamp;
    // form header string
    $nvpheader = nvpHeader();
    //setting the curl parameters.
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    //turning off the server and 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);
    //in case of permission APIs send headers as HTTPheders
    if (!empty($AUTH_token) && !empty($AUTH_signature) && !empty($AUTH_timestamp)) {
        $headers_array[] = "X-PP-AUTHORIZATION: " . $nvpheader;
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers_array);
        curl_setopt($ch, CURLOPT_HEADER, false);
    } else {
        $nvpStr = $nvpheader . $nvpStr;
    }
    //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
    //Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php
    if (USE_PROXY) {
        curl_setopt($ch, CURLOPT_PROXY, PROXY_HOST . ":" . PROXY_PORT);
    }
    //check if version is included in $nvpStr else include the version.
    if (strlen(str_replace('VERSION=', '', strtoupper($nvpStr))) == strlen($nvpStr)) {
        $nvpStr = "&VERSION=" . urlencode($version) . $nvpStr;
    }
    $nvpreq = "METHOD=" . urlencode($methodName) . $nvpStr;
    //setting the nvpreq as POST FIELD to curl
    curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
    //getting response from server
    $response = curl_exec($ch);
    //print_r($response);exit;
    //convrting NVPResponse to an Associative Array
    $nvpResArray = deformatNVP($response);
    $nvpReqArray = deformatNVP($nvpreq);
    $_SESSION['nvpReqArray'] = $nvpReqArray;
    if (curl_errno($ch)) {
        //moving to display page to display curl errors
        $_SESSION['curl_error_no'] = curl_errno($ch);
        $_SESSION['curl_error_msg'] = curl_error($ch);
        $_SESSION['reshash'] = array('Error' => 'Payment Gateway Error', 'Error Message' => curl_error($ch));
        $location = DOCROOT . 'orderdetails.html';
        header("Location: {$location}");
        exit;
    } else {
        //closing the curl
        curl_close($ch);
    }
    return $nvpResArray;
}
/**
  '-------------------------------------------------------------------------------------------------------------------------------------------
  * hash_call: Function to perform the API call to PayPal using API signature
  * @methodName is name of API method.
  * @nvpStr is nvp string.
  * returns an associative array containing the response from the server.
  '-------------------------------------------------------------------------------------------------------------------------------------------
*/
function hash_call($methodName, $nvpStr)
{
    //declaring of global variables
    global $API_Endpoint, $API_UserName, $API_Password, $API_Signature, $API_AppID;
    global $USE_PROXY, $PROXY_HOST, $PROXY_PORT;
    $API_Endpoint .= "/" . $methodName;
    //setting the curl parameters.
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    //turning off the server and 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 the HTTP Headers
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-PAYPAL-REQUEST-DATA-FORMAT: NV', 'X-PAYPAL-RESPONSE-DATA-FORMAT: NV', 'X-PAYPAL-SECURITY-USERID: ' . $API_UserName, 'X-PAYPAL-SECURITY-PASSWORD: '******'X-PAYPAL-SECURITY-SIGNATURE: ' . $API_Signature, 'X-PAYPAL-SERVICE-VERSION: 1.3.0', 'X-PAYPAL-APPLICATION-ID: ' . $API_AppID));
    //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
    //Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php
    if ($USE_PROXY) {
        curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST . ":" . $PROXY_PORT);
    }
    // RequestEnvelope fields
    $detailLevel = urlencode("ReturnAll");
    // See DetailLevelCode in the WSDL for valid enumerations
    $errorLanguage = urlencode("en_US");
    // This should be the standard RFC 3066 language identification tag, e.g., en_US
    // NVPRequest for submitting to server
    $nvpreq = "requestEnvelope.errorLanguage={$errorLanguage}&requestEnvelope.detailLevel={$detailLevel}";
    $nvpreq .= "&{$nvpStr}";
    //setting the nvpreq as POST FIELD to curl
    curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
    //getting response from server
    $response = curl_exec($ch);
    //converting NVPResponse to an Associative Array
    $nvpResArray = deformatNVP($response);
    $nvpReqArray = deformatNVP($nvpreq);
    $_SESSION['nvpReqArray'] = $nvpReqArray;
    if (curl_errno($ch)) {
        // moving to display page to display curl errors
        $_SESSION['curl_error_no'] = curl_errno($ch);
        $_SESSION['curl_error_msg'] = curl_error($ch);
        //Execute the Error handling module to display errors.
    } else {
        //closing the curl
        curl_close($ch);
    }
    return $nvpResArray;
}