当前位置: 首页>>代码示例>>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;未经允许,请勿转载。