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


PHP PayPal类代码示例

本文整理汇总了PHP中PayPal的典型用法代码示例。如果您正苦于以下问题:PHP PayPal类的具体用法?PHP PayPal怎么用?PHP PayPal使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PayPal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: __construct

 /**
  * Constructor
  * @global object $objTemplate
  */
 function __construct($pageContent)
 {
     $this->pageContent = $pageContent;
     $this->_objTpl = new \Cx\Core\Html\Sigma('.');
     \Cx\Core\Csrf\Controller\Csrf::add_placeholder($this->_objTpl);
     $this->_objTpl->setErrorHandling(PEAR_ERROR_DIE);
     $this->mediaPath = ASCMS_MARKET_MEDIA_PATH . '/';
     $this->mediaWebPath = ASCMS_MARKET_MEDIA_WEB_PATH . '/';
     //get settings
     $this->settings = $this->getSettings();
     //check community modul
     $objModulManager = new \Cx\Core\ComponentManager\Controller\ComponentManager();
     $arrInstalledModules = $objModulManager->getModules();
     if (in_array(23, $arrInstalledModules)) {
         $this->communityModul = true;
     } else {
         $this->communityModul = false;
     }
     //ipn Check
     if (isset($_GET['act'])) {
         switch ($_GET['act']) {
             case "paypalIpnCheck":
                 $objPaypal = new \PayPal();
                 $objPaypal->ipnCheck();
                 exit;
                 break;
             default:
                 //nothging
                 break;
         }
     }
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:36,代码来源:Market.class.php

示例3: espresso_process_paypal_pro

function espresso_process_paypal_pro($payment_data)
{
    extract($payment_data);
    global $wpdb;
    // Included required files.
    require_once 'includes/paypal.nvp.class.php';
    $paypal_pro_settings = get_option('event_espresso_paypal_pro_settings');
    $sandbox = $paypal_pro_settings['paypal_pro_use_sandbox'];
    // Setup PayPal object
    $PayPalConfig = array('Sandbox' => $sandbox, 'APIUsername' => $paypal_pro_settings['paypal_api_username'], 'APIPassword' => $paypal_pro_settings['paypal_api_password'], 'APISignature' => $paypal_pro_settings['paypal_api_signature']);
    $PayPal = new PayPal($PayPalConfig);
    // Populate data arrays with order data.
    $DPFields = array('paymentaction' => 'Sale', 'ipaddress' => $_SERVER['REMOTE_ADDR'], 'returnfmfdetails' => '1');
    $CCDetails = array('creditcardtype' => $_POST['creditcardtype'], 'acct' => $_POST['card_num'], 'expdate' => $_POST['expmonth'] . $_POST['expyear'], 'cvv2' => $_POST['cvv'], 'startdate' => '', 'issuenumber' => '');
    $PayerInfo = array('email' => $_POST['email'], 'payerid' => '', 'payerstatus' => '', 'business' => '');
    $PayerName = array('salutation' => '', 'firstname' => $_POST['first_name'], 'middlename' => '', 'lastname' => $_POST['last_name'], 'suffix' => '');
    $BillingAddress = array('street' => $_POST['address'], 'street2' => '', 'city' => $_POST['city'], 'state' => $_POST['state'], 'countrycode' => 'US', 'zip' => $_POST['zip'], 'phonenum' => empty($_POST['phone']) ? '' : $_POST['phone']);
    $ShippingAddress = array('shiptoname' => '', 'shiptostreet' => '', 'shiptostreet2' => '', 'shiptocity' => '', 'shiptostate' => '', 'shiptozip' => '', 'shiptocountrycode' => '', 'shiptophonenum' => '');
    $PaymentDetails = array('amt' => $payment_data['total_cost'], 'currencycode' => $paypal_pro_settings['currency_format'], 'itemamt' => '', 'shippingamt' => '', 'handlingamt' => '', 'taxamt' => '', 'desc' => stripslashes_deep($event_name), 'custom' => '', 'invnum' => '', 'notifyurl' => '');
    $OrderItems = array();
    $Item = array('l_name' => stripslashes_deep($event_name), 'l_desc' => stripslashes_deep($event_name), 'l_amt' => $_POST['amount'], 'l_number' => '', 'l_qty' => '1', 'l_taxamt' => '', 'l_ebayitemnumber' => '', 'l_ebayitemauctiontxnid' => '', 'l_ebayitemorderid' => '');
    array_push($OrderItems, $Item);
    // Wrap all data arrays into a single, "master" array which will be passed into the class function.
    $PayPalRequestData = array('DPFields' => $DPFields, 'CCDetails' => $CCDetails, 'PayerName' => $PayerName, 'BillingAddress' => $BillingAddress, 'PaymentDetails' => $PaymentDetails, 'OrderItems' => $OrderItems);
    $PayPalResult = $PayPal->DoDirectPayment($PayPalRequestData);
    $payment_data['payment_status'] = 'Incomplete';
    $payment_data['txn_type'] = 'PayPal Pro';
    $payment_data['txn_id'] = 0;
    $payment_data['txn_details'] = serialize($_REQUEST);
    $payment_data = apply_filters('filter_hook_espresso_prepare_event_link', $payment_data);
    $payment_data = apply_filters('filter_hook_espresso_get_total_cost', $payment_data);
    $Errors = GetErrors($PayPalResult);
    if (!empty($PayPalResult)) {
        unset($PayPalResult['REQUESTDATA']['CREDITCARDTYPE']);
        unset($PayPalResult['REQUESTDATA']['ACCT']);
        unset($PayPalResult['REQUESTDATA']['EXPDATE']);
        unset($PayPalResult['REQUESTDATA']['CVV2']);
        unset($PayPalResult['RAWREQUEST']);
        $payment_data['txn_id'] = $PayPalResult['TRANSACTIONID'];
        $payment_data['txn_details'] = serialize($PayPalResult);
        if (!APICallSuccessful($PayPalResult['ACK'])) {
            DisplayErrors($Errors);
        } else {
            $payment_data['payment_status'] = 'Completed';
        }
    } else {
        ?>
		<p><?php 
        _e('There was no response from PayPal.', 'event_espresso');
        ?>
</p>
		<?php 
    }
    add_action('action_hook_espresso_email_after_payment', 'espresso_email_after_payment');
    return $payment_data;
}
开发者ID:sriram911,项目名称:pls,代码行数:56,代码来源:DoDirectPayment.php

示例4: do_payment

 function do_payment()
 {
     $amount = $this->input->get('amount');
     $r = new PayPal();
     $r->doExpressCheckout($amount, 'Da Greatest Library You Ever Seen');
     $final = $r->doPayment();
     if ($final['ACK'] == 'Success') {
         echo 'Succeed!';
     } else {
         echo 'Error!';
     }
 }
开发者ID:adadsa,项目名称:sosmed,代码行数:12,代码来源:c_payment.php

示例5: executeConnexion

 public function executeConnexion(sfWebRequest $request)
 {
     $class = sfConfig::get('app_sf_guard_plugin_signin_form', 'sfGuardFormSignin');
     $this->formIdentification = new $class();
     if ($request->ismethod('post')) {
         $this->formIdentification->bind($request->getParameter('signin'));
         if ($this->formIdentification->isValid()) {
             $values = $this->formIdentification->getValues();
             $this->getUser()->signin($values['user'], array_key_exists('remember', $values) ? $values['remember'] : false);
             $paypal = new PayPal();
             $ret = $paypal->doExpressCheckout($this->getUser()->getAttribute('montantLocation'), 'Location de la voiture');
             //print_r($ret);
         }
     }
 }
开发者ID:sfinx13,项目名称:appsmartproject,代码行数:15,代码来源:actions.class.php

示例6: process

 public function process($sProvider = '')
 {
     switch ($sProvider) {
         case 'paypal':
             $oPayPal = new PayPal($this->config->values['module.setting']['sandbox.enable']);
             if ($oPayPal->valid() && $this->httpRequest->postExists('item_number')) {
                 if ($this->oUserModel->updateMembership($this->httpRequest->post('item_number'), $this->iProfileId, $this->httpRequest->post('amount'), $this->dateTime->dateTime('Y-m-d H:i:s'))) {
                     $this->log($oPayPal, t('PayPal payment was made, the following information:'));
                     $this->_bStatus = true;
                     // Status is OK
                 }
             }
             unset($oPayPal);
             break;
         case '2co':
             $o2CO = new TwoCO($this->config->values['module.setting']['sandbox.enable']);
             $sVendorId = $this->config->values['module.setting']['2co.vendor_id'];
             $sSecretWord = $this->config->values['module.setting']['2co.secret_word'];
             if ($o2CO->valid($sVendorId, $sSecretWord) && $this->httpRequest->postExists('sale_id')) {
                 if ($this->oUserModel->updateMembership($this->httpRequest->post('sale_id'), $this->iProfileId, $this->httpRequest->post('price'), $this->dateTime->dateTime('Y-m-d H:i:s'))) {
                     $this->log($o2CO, t('2CheckOut payment was made, the following information:'));
                     $this->_bStatus = true;
                     // Status is OK
                 }
             }
             unset($o2CO);
             break;
         case 'ccbill':
             // In developing...
             // Contact us at <ph7software@gmail.com> if you want to help us develop the payment system CCBill
             break;
         default:
             $this->displayPageNotFound(t('Provinder Not Found!'));
     }
     // Set the page titles
     $this->sTitle = $this->_bStatus ? t('Thank you!') : t('Error occurred!');
     $this->view->page_title = $this->sTitle;
     $this->view->h2_title = $this->sTitle;
     if ($this->_bStatus) {
         $this->updateAffCom();
     }
     // Set the valid page
     $sPage = $this->_bStatus ? 'success' : 'error';
     $this->manualTplInclude($sPage . $this->view->getTplExt());
     // Output
     $this->output();
 }
开发者ID:joswilson,项目名称:NotJustOK,代码行数:47,代码来源:MainController.php

示例7: create_from_post

 static function create_from_post($postfields, $payment_id = false)
 {
     $infoarray = $_POST;
     $set = array();
     $set['info'] = PayPal::post2string();
     if (isset($infoarray['txn_id'])) {
         $set['txn_id'] = $infoarray['txn_id'];
     }
 }
开发者ID:songwork,项目名称:songwork,代码行数:9,代码来源:PayPalTxn.php

示例8: getAuthorisation

 public function getAuthorisation()
 {
     global $cookie;
     // Getting cart informations
     $cart = new Cart((int) $cookie->id_cart);
     if (!Validate::isLoadedObject($cart)) {
         $this->_logs[] = $this->l('Not a valid cart');
     }
     $currency = new Currency((int) $cart->id_currency);
     if (!Validate::isLoadedObject($currency)) {
         $this->_logs[] = $this->l('Not a valid currency');
     }
     if (sizeof($this->_logs)) {
         return false;
     }
     // Making request
     $returnURL = PayPal::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/paypal/express/submit.php';
     $cancelURL = PayPal::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'order.php';
     $paymentAmount = (double) $cart->getOrderTotal();
     $currencyCodeType = strval($currency->iso_code);
     $paymentType = Configuration::get('PAYPAL_CAPTURE') == 1 ? 'Authorization' : 'Sale';
     $request = '&Amt=' . urlencode($paymentAmount) . '&PAYMENTACTION=' . urlencode($paymentType) . '&ReturnUrl=' . urlencode($returnURL) . '&CANCELURL=' . urlencode($cancelURL) . '&CURRENCYCODE=' . urlencode($currencyCodeType);
     if ($this->_pp_integral) {
         $request .= '&SOLUTIONTYPE=Sole&LANDINGPAGE=Billing';
     } else {
         $request .= '&SOLUTIONTYPE=Mark&LANDINGPAGE=Login';
     }
     $request .= '&LOCALECODE=' . strtoupper($this->getCountryCode());
     if ($this->_header) {
         $request .= '&HDRIMG=' . urlencode($this->_header);
     }
     // Customer informations
     $customer = new Customer((int) $cart->id_customer);
     $request .= '&EMAIL=' . urlencode($customer->email);
     //customer
     // address of delivery
     $address = new Address((int) $cart->id_address_delivery);
     $country = new Country((int) $address->id_country);
     if ($address->id_state) {
         $state = new State((int) $address->id_state);
     }
     $request .= '&SHIPTONAME=' . urlencode($address->firstname . ' ' . $address->lastname);
     $request .= '&SHIPTOSTREET=' . urlencode($address->address1);
     $request .= '&SHIPTOSTREET2=' . urlencode($address->address2);
     $request .= '&SHIPTOCITY=' . urlencode($address->city);
     $request .= '&SHIPTOSTATE=' . ($address->id_state ? $state->iso_code : $country->iso_code);
     $request .= '&SHIPTOZIP=' . urlencode($address->postcode);
     $request .= '&SHIPTOCOUNTRY=' . urlencode($country->iso_code);
     $request .= '&SHIPTOPHONENUM=' . urlencode($address->phone);
     // Calling PayPal API
     include _PS_MODULE_DIR_ . 'paypal/api/paypallib.php';
     $ppAPI = new PaypalLib();
     $result = $ppAPI->makeCall($this->getAPIURL(), $this->getAPIScript(), 'SetExpressCheckout', $request);
     $this->_logs = array_merge($this->_logs, $ppAPI->getLogs());
     return $result;
 }
开发者ID:nicolasjeol,项目名称:hec-ecommerce,代码行数:56,代码来源:paypalexpress.php

示例9: done

 public function done(Request $request)
 {
     $id = $request->get('paymentId');
     $payer_id = $request->get('PayerID');
     $payment = PayPal::getById($id, $this->_apiContext);
     $paymentExecution = PayPal::PaymentExecution();
     $paymentExecution->setPayerId($payer_id);
     $executePayment = $payment->execute($paymentExecution, $this->_apiContext);
     // Clear the shopping cart, write to database, send notifications, etc.
     $request->session()->pull('likes', []);
     return view('Main/index');
 }
开发者ID:unpetitlu,项目名称:laravelcinema,代码行数:12,代码来源:MainController.php

示例10: getDone

 public function getDone(Request $request)
 {
     $id = $request->get('paymentId');
     $token = $request->get('token');
     $payer_id = $request->get('PayerID');
     $payment = PayPal::getById($id, $this->_apiContext);
     $paymentExecution = PayPal::PaymentExecution();
     $paymentExecution->setPayerId($payer_id);
     $executePayment = $payment->execute($paymentExecution, $this->_apiContext);
     \Cart::clear();
     return view('frontend.checkout.done')->with('categories', Category::all())->with('pay', $executePayment);
 }
开发者ID:nhatkhoa,项目名称:GroupBuy,代码行数:12,代码来源:PaymentController.php

示例11: logit

 static function logit($payment_id = false)
 {
     $set = array();
     $set['info'] = PayPal::post2string($_POST);
     $separate_fields = array('txn_id', 'txn_type');
     foreach ($separate_fields as $fieldname) {
         if (isset($_POST[$fieldname])) {
             $set[$fieldname] = $_POST[$fieldname];
         }
     }
     $ppt = new PayPalTxn(false);
     return $ppt->add($set);
 }
开发者ID:songwork,项目名称:songwork,代码行数:13,代码来源:PayPal.php

示例12: initContent

 public function initContent()
 {
     if (!$this->context->customer->isLogged() || empty($this->context->cart)) {
         Tools::redirect('index.php');
     }
     parent::initContent();
     $this->paypal = new PayPal();
     $this->context = Context::getContext();
     $this->id_module = (int) Tools::getValue('id_module');
     $currency = new Currency((int) $this->context->cart->id_currency);
     $this->context->smarty->assign(array('form_action' => PayPal::getShopDomainSsl(true, true) . _MODULE_DIR_ . $this->paypal->name . '/express_checkout/payment.php', 'total' => Tools::displayPrice($this->context->cart->getOrderTotal(true), $currency), 'logos' => $this->paypal->paypal_logos->getLogos(), 'use_mobile' => (bool) $this->paypal->useMobile()));
     $this->setTemplate('order-summary.tpl');
 }
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:13,代码来源:confirm.php

示例13: getDone

 public function getDone(Request $request)
 {
     $id = $request->get('paymentId');
     $token = $request->get('token');
     $payer_id = $request->get('PayerID');
     $payment = PayPal::getById($id, $this->_apiContext);
     $paymentExecution = PayPal::PaymentExecution();
     $paymentExecution->setPayerId($payer_id);
     $executePayment = $payment->execute($paymentExecution, $this->_apiContext);
     // Clear the shopping cart, write to database, send notifications, etc.
     // Thank the user for the purchase
     return view('register');
 }
开发者ID:aaffio,项目名称:guide,代码行数:13,代码来源:paypalController.php

示例14: Handle_GetPaymentMethod

 public function Handle_GetPaymentMethod($order)
 {
     $method = array();
     $method['Title'] = 'PayPal';
     $method['Description'] = 'Pay with your PayPal account';
     $method['ThumbnailUrl'] = CartAPI_Handlers_Helpers::getCartApiHomeUrl() . 'modules/paypal/icon.png';
     // config the handling module in the mobile engine
     $method['Module'] = 'WebPaymentActivity';
     $params = array();
     // new paypal module (3.4.5)
     if (defined('WPS') && defined('HSS') && defined('ECS')) {
         $paypal_method = (int) Configuration::get('PAYPAL_PAYMENT_METHOD');
         if ($paypal_method == WPS || $paypal_method == ECS) {
             $cancel_url = CartAPI_Handlers_Helpers::getCartApiHomeUrl() . 'modules/paypal/express_checkout/cancel.php';
             $params['Url'] = CartAPI_Handlers_Helpers::getShopBaseUrl() . 'modules/paypal/express_checkout/payment.php?express_checkout=payment_cart&current_shop_url=' . urlencode($cancel_url) . '&';
             $params['CompleteTrigger'] = CartAPI_Handlers_Helpers::getShopBaseUrl();
             $params['CancelTrigger'] = $cancel_url;
         }
     }
     // old paypal module (2.8.6)
     if (defined('_PAYPAL_INTEGRAL_EVOLUTION_') && defined('_PAYPAL_INTEGRAL_EVOLUTION_') && defined('_PAYPAL_INTEGRAL_EVOLUTION_')) {
         if (Configuration::get('PAYPAL_PAYMENT_METHOD') == _PAYPAL_INTEGRAL_EVOLUTION_) {
             // integral_evolution/paypal.tpl
             $params['Url'] = CartAPI_Handlers_Helpers::getShopBaseUrl() . 'modules/paypal/integral_evolution/redirect.php';
             $params['CompleteTrigger'] = PayPal::getShopDomain(true, true) . __PS_BASE_URI__ . 'order-confirmation.php';
             $params['CancelTrigger'] = PayPal::getShopDomain(true, true) . __PS_BASE_URI__;
         } elseif (Configuration::get('PAYPAL_PAYMENT_METHOD') == _PAYPAL_INTEGRAL_ or Configuration::get('PAYPAL_PAYMENT_METHOD') == _PAYPAL_OPTION_PLUS_) {
             if ($this->_isPayPalAPIAvailable()) {
                 // payment/payment.tpl
                 $params['Url'] = CartAPI_Handlers_Helpers::getCartApiHomeUrl() . 'modules/paypal/payment/submit.php';
                 $params['CompleteTrigger'] = CartAPI_Handlers_Helpers::getShopBaseUrl() . 'order-confirmation.php';
                 $params['CancelTrigger'] = PayPal::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'order';
                 // either order.php or order-opc.php
                 $params['RedirectTrigger'] = array('Trigger' => CartAPI_Handlers_Helpers::getShopBaseUrl() . 'modules/paypal/payment/submit.php', 'Redirect' => CartAPI_Handlers_Helpers::getCartApiHomeUrl() . 'modules/paypal/payment/error.php');
             } else {
                 // standard/paypal.tpl
                 $params['Url'] = CartAPI_Handlers_Helpers::getShopBaseUrl() . 'modules/paypal/standard/redirect.php';
                 $params['CompleteTrigger'] = PayPal::getShopDomain(true, true) . __PS_BASE_URI__ . 'order-confirmation.php';
                 $params['CancelTrigger'] = PayPal::getShopDomain(true, true) . __PS_BASE_URI__;
             }
         }
     }
     // very old paypal (2.0 and below)
     if (empty($params)) {
         $params['Url'] = CartAPI_Handlers_Helpers::getCartApiHomeUrl() . 'modules/paypal/old/hookpayment.php';
         $params['CompleteTrigger'] = CartAPI_Handlers_Helpers::getShopBaseUrl() . 'order-confirmation.php';
         $params['CancelTrigger'] = CartAPI_Handlers_Helpers::getShopBaseUrl();
     }
     $method['ModuleParameters'] = $params;
     return $method;
 }
开发者ID:sebastien-fauvel,项目名称:cartapi-plugin-prestashop,代码行数:51,代码来源:paypal.php

示例15: __construct

 public function __construct()
 {
     $this->config = parse_ini_file(__DOCROOT__ . '/config.ini', true);
     PayPal::$database_connect = mysql_connect($this->config['database']['host'], $this->config['database']['user'], $this->config['database']['password']);
     if (!PayPal::$database_connect) {
         echo "Unable to connect to DB: " . mysql_error(PayPal::$database_connect);
         exit;
     }
     mysql_query("SET NAMES 'UTF8'", PayPal::$database_connect);
     if (!mysql_select_db($this->config['database']['name'], PayPal::$database_connect)) {
         echo "Unable to select mydbname: " . mysql_error(PayPal::$database_connect);
         exit;
     }
 }
开发者ID:heshuai64,项目名称:ebo,代码行数:14,代码来源:PayPal.php


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