当前位置: 首页>>代码示例>>PHP>>正文


PHP PayPal::doRequest方法代码示例

本文整理汇总了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."));
    }
}
开发者ID:sharedRoutine,项目名称:ShopFix,代码行数:29,代码来源:checkout.php

示例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']);
开发者ID:sharedRoutine,项目名称:ShopFix,代码行数:31,代码来源:process.php


注:本文中的PayPal::doRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。