本文整理汇总了PHP中deformatNVP函数的典型用法代码示例。如果您正苦于以下问题:PHP deformatNVP函数的具体用法?PHP deformatNVP怎么用?PHP deformatNVP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了deformatNVP函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hash_call
/**
* 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;
}
示例2: hash_call
/**
* 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 = "jb-us-seller_api1.paypal.com";
$API_Password = "WX4WTU3S8MY44S7F";
$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=" . urlencode("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;
}
示例3: hash_call
/**
* 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;
}
示例4: hash_call
/**
* 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;
}
示例5: hash_call
/**
* 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=" . urlencode(API_USERNAME) . "&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;
}
示例6: hash_call
/**
* 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=" . urlencode(API_USERNAME) . "&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;
}
示例7: hash_call
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=" . urlencode($API_UserName) . "&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;
}
示例8: hash_call
/**
'-------------------------------------------------------------------------------------------------------------------------------------------
* 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=" . urlencode($API_UserName) . "&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;
}
示例9: hash_call
/**
* 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=" . urlencode($PAYPAL_API_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;
}
示例10: hash_call
/**
* 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=" . urlencode($API_UserName);
if (PAYPAL_API_CERTIFICATE != '' && file_exists(CLASSPATH . 'payment/paypal_api/certificate/' . PAYPAL_API_CERTIFICATE)) {
$tc = PAYPAL_API_CERTIFICATE;
//Check to make sure we have a certificate file
if (empty($tc) === false) {
$certLoc = CLASSPATH . 'payment/paypal_api/certificate/' . PAYPAL_API_CERTIFICATE;
curl_setopt($ch, CURLOPT_SSLCERT, $certLoc);
}
//Check for sandbox mode
if (PAYPAL_API_DEBUG == '1') {
$API_Endpoint = 'https://api.sandbox.paypal.com/nvp';
} else {
$API_Endpoint = 'https://api.paypal.com/nvp';
}
} else {
//Check for sandbox mode
if (PAYPAL_API_DEBUG == '1') {
$API_Endpoint = 'https://api-3t.sandbox.paypal.com/nvp';
} else {
$API_Endpoint = 'https://api-3t.paypal.com/nvp';
}
$nvpreq .= "&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=" . urlencode($API_UserName) . "&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;
}
示例11: hash_call
/**
* 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;
}
示例12: hash_call
/**
'-------------------------------------------------------------------------------------------------------------------------------------------
* 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=" . $API_User . '&VENDOR=' . $API_Vendor . '&PARTNER=' . $API_Partner . '&PWD=' . $API_Password . $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;
}
示例13: hash_call
/**
'-------------------------------------------------------------------------------------------------------------------------------------------
* 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 = "univer_1332350170_biz_api1.gmail.com";
$API_Password = "1332350195";
$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=" . urlencode($API_UserName) . "&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;
}
示例14: hash_call
/**
* 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;
}
示例15: hash_call
/**
* 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;
}