當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PayPal::initialize方法代碼示例

本文整理匯總了PHP中PayPal::initialize方法的典型用法代碼示例。如果您正苦於以下問題:PHP PayPal::initialize方法的具體用法?PHP PayPal::initialize怎麽用?PHP PayPal::initialize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PayPal的用法示例。


在下文中一共展示了PayPal::initialize方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: elseif

            $tpls['rsvpme.list'] = $rsvpme->getChunk($listTpl, $rsvpme->validator->errors);
        }
    }
} elseif (isset($_REQUEST['token'])) {
    if (!isset($_SESSION[$_REQUEST['token']])) {
        $modx->log(modX::LOG_LEVEL_ERROR, 'Token not set in session. How did they get here?');
        return 'PayPal token not found.';
    }
    /* paypal token is set */
    $modx->log(modX::LOG_LEVEL_INFO, '[RSVPMe] PayPal TOKEN detected. Finishing registration and processing.');
    if (!$modx->loadClass('rsvpme.payment.PayPal', $rsvpme->config['modelPath'], true, true)) {
        $modx->log(modX::LOG_LEVEL_ERROR, '[RSVPMe] Could not load PayPal class.');
        return 'Sorry, there was an error completing the transaction.';
    }
    $paypal = new PayPal($modx);
    $paypal->initialize();
    $payer = $paypal->getExpressCheckoutDetails(array('token' => $_REQUEST['token']));
    $modx->log(modX::LOG_LEVEL_INFO, 'PayPal transaction info: ' . print_r($payer, true));
    $request = array('PAYMENTACTION' => 'Sale');
    $details = array('TOKEN' => $_REQUEST['token'], 'PAYERID' => $payer['PAYERID'], 'AMT' => $_SESSION[$_REQUEST['token']]['AMT']);
    // Must re-initialize PayPal, as it closes the cURL object after each command.
    $paypal->initialize();
    $result = $paypal->doExpressCheckoutPayment($request, $details);
    if ($result['ACK'] == 'Success' || $result['ACK'] == 'SuccessWithWarning') {
        $modx->log(modX::LOG_LEVEL_INFO, 'Payment completed: ' . print_r($result, true) . print_r($payer, true));
        // Now that the payment has completed, we can finish registering the user.
        if (!($regtype = $modx->getObject('RSVPMeRegType', array('id' => $_SESSION[$_REQUEST['token']]['regtypeid'])))) {
            $modx->log(modX::LOG_LEVEL_ERROR, '[RSVPMe] There was an error when attempting to register paid guest. ' . print_r($result, true));
        }
        $guest = array('name' => $payer['FIRSTNAME'] . ' ' . $payer['LASTNAME'], 'email' => $payer['EMAIL'], 'paid' => true);
        if ($rsvpme->registerPerson($regtype->id, $guest)) {
開發者ID:josht,項目名稱:RSVPMe,代碼行數:31,代碼來源:snippet.rsvpme.php


注:本文中的PayPal::initialize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。