本文整理汇总了PHP中Cart66Common::getPayPalUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Cart66Common::getPayPalUrl方法的具体用法?PHP Cart66Common::getPayPalUrl怎么用?PHP Cart66Common::getPayPalUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cart66Common
的用法示例。
在下文中一共展示了Cart66Common::getPayPalUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* Validate the PayPal IPN by posting back the data sent from PayPal.
*
* Create a request that contains exactly the same IPN variables and values in the
* same order, preceded with cmd=_notify-validate.
*/
public function validate($rawPost)
{
$isValid = false;
Cart66Common::log("Validate PayPal Post Data: \n" . print_r($rawPost, true));
// Looking for local test IPNs
if (isset($rawPost['test_ipn']) && $rawPost['test_ipn'] == '66') {
$isValid = true;
} else {
$postdata = '';
foreach ($rawPost as $i => $v) {
$postdata .= $i . '=' . urlencode(stripslashes($v)) . '&';
}
$postdata .= 'cmd=_notify-validate';
Cart66Common::log("PayPal Validation Post Back: {$postdata}");
$web = parse_url(Cart66Common::getPayPalUrl());
if ($web['scheme'] == 'https') {
$web['port'] = 443;
$ssl = 'ssl://';
} else {
$web['port'] = 80;
$ssl = '';
}
$fp = @fsockopen($ssl . $web['host'], $web['port'], $errnum, $errstr, 30);
if (!$fp) {
$socketError = "Socket error --> " . $ssl . $web['host'] . ' -- ' . $web['port'] . ' -- ' . $errnum . ' -- ' . $errstr . ' -- 30';
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] PayPal IPN Validation Socket Error: {$socketError}");
echo "IPN Socket Failure: {$socketError}";
} else {
fputs($fp, "POST " . $web['path'] . " HTTP/1.1\r\n");
fputs($fp, "Host: " . $web['host'] . "\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: " . strlen($postdata) . "\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $postdata . "\r\n\r\n");
while (!feof($fp)) {
$info[] = @fgets($fp, 1024);
}
fclose($fp);
$infoString = implode(',', $info);
if (eregi('VERIFIED', $infoString)) {
// PayPal Verification Success'
$isValid = true;
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] PayPal IPN Validation succeeded: {$infoString}");
} else {
// PayPal Verification Failed
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] PayPal Validation failed: {$infoString}");
}
}
}
return $isValid;
}
示例2: __construct
public function __construct()
{
$paypalUrl = Cart66Common::getPayPalUrl();
Cart66Common::log("Constructing PayPal Gateway for IPN using URL: {$paypalUrl}");
}