本文整理汇总了PHP中PayPal::doRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP PayPal::doRequest方法的具体用法?PHP PayPal::doRequest怎么用?PHP PayPal::doRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PayPal
的用法示例。
在下文中一共展示了PayPal::doRequest方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkoutWithPaypal
function checkoutWithPaypal($total, $cart)
{
try {
$paypal = new PayPal(true);
} catch (Exception $e) {
Logger::i()->writeLog("Caught Exception: " . $e->getMessage(), 'dev');
die;
}
$params = array('RETURNURL' => createURLForScript("process.php"), 'CANCELURL' => createURLForScript("cancel.php"), 'PAYMENTREQUEST_0_AMT' => floatval(number_format(floatval($total), 2)), 'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR');
$params['SOLUTIONTYPE'] = "Sole";
$params['LANDINGPAGE'] = "Billing";
$k = 0;
foreach ($cart as $key => $value) {
$info = (array) $value;
$params['L_PAYMENTREQUEST_0_NAME' . $k] = $info["name"];
$params['L_PAYMENTREQUEST_0_DESCR' . $k] = $info["description"];
$params['L_PAYMENTREQUEST_0_AMT' . $k] = floatval(number_format(floatval($info['price']), 2));
$params['L_PAYMENTREQUEST_0_QTY' . $k] = intval($info['quantity']);
$k++;
}
$response = $paypal->doRequest("SetExpressCheckout", $params);
if ($response) {
Logger::i()->writeLog("Starting PayPal checkout");
return $paypal->generateURL($response['TOKEN']);
} else {
Logger::i()->writeLog("Could not get token, error = " . $paypal->error, 'dev');
die(Submission::createResult("Can not checkout at the moment. Please try again later."));
}
}
示例2: PayPal
$message .= "- Your " . Settings::i()->title . " Team";
return $message;
}
if (isset($_GET['token'])) {
Logger::i()->writeLog("Processing PayPal Payment");
if (!SessionManager::i()->isLoggedIn()) {
Logger::i()->writeLog("User not logged in", 'dev');
die;
}
try {
$paypal = new PayPal(true);
} catch (Exception $e) {
Logger::i()->writeLog("Caught Exception: " . $e->getMessage(), 'dev');
die;
}
$response = $paypal->doRequest("GetExpressCheckoutDetails", array("TOKEN" => $_GET['token']));
$first_name = $response['FIRSTNAME'];
if (!$response) {
Logger::i()->writeLog("Could not get express checkout details, error = " . $paypal->error, 'dev');
header("Location: index.php");
die;
}
$response = $paypal->doRequest("DoExpressCheckoutPayment", array("TOKEN" => $response['TOKEN'], "PAYERID" => $response['PAYERID'], "PAYMENTACTION" => "Sale", "PAYMENTREQUEST_0_AMT" => $response['PAYMENTREQUEST_0_AMT'], "PAYMENTREQUEST_0_CURRENCYCODE" => $response['PAYMENTREQUEST_0_CURRENCYCODE']));
if ($response) {
if ($response['PAYMENTINFO_0_PAYMENTSTATUS'] == "Completed" && $response['ACK'] == "Success" && $response['PAYMENTINFO_0_ACK'] == "Success") {
//did pay
$userid = intval($_SESSION['userid']);
if (isset($_SESSION['shopping-cart'])) {
$token = base64_encode(DbManager::i()->escapeString($_GET['token']));
$payerid = base64_encode(DbManager::i()->escapeString($_GET['PayerID']));
$cart = DbManager::i()->escapeString($_SESSION['shopping-cart']);