📄 paypal.php
字号:
<?php
/**
* paypal.php payment module class for Paypal IPN payment method
*
* @package paymentMethod
* @copyright Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: paypal.php 3279 2006-03-27 22:51:19Z wilt $
*/
define('MODULE_PAYMENT_PAYPAL_RM', '2');
if (IS_ADMIN_FLAG === true) {
include_once(DIR_FS_CATALOG_MODULES . 'payment/paypal/paypal_functions.php');
} else {
include_once(DIR_WS_MODULES . 'payment/paypal/paypal_functions.php');
}
/**
* paypal IPN pyment method class
*
*/
class paypal extends base {
/**
* string repesenting the payment method
*
* @var string
*/
var $code;
/**
* $title is the displayed name for this payment method
*
* @var string
*/
var $title;
/**
* $description is a soft name for this payment method
*
* @var string
*/
var $description;
/**
* $enabled determines whether this module shows or not... in catalog.
*
* @var boolean
*/
var $enabled;
/**
* constructor
*
* @param int $paypal_ipn_id
* @return paypal
*/
function paypal($paypal_ipn_id = '') {
global $order;
$this->code = 'paypal';
if ($_GET['main_page'] != '') {
$this->title = MODULE_PAYMENT_PAYPAL_TEXT_CATALOG_TITLE; // Payment Module title in Catalog
} else {
$this->title = MODULE_PAYMENT_PAYPAL_TEXT_ADMIN_TITLE; // Payment Module title in Admin
}
$this->description = MODULE_PAYMENT_PAYPAL_TEXT_DESCRIPTION;
$this->sort_order = MODULE_PAYMENT_PAYPAL_SORT_ORDER;
$this->enabled = ((MODULE_PAYMENT_PAYPAL_STATUS == 'True') ? true : false);
if ((int)MODULE_PAYMENT_PAYPAL_ORDER_STATUS_ID > 0) {
$this->order_status = MODULE_PAYMENT_PAYPAL_ORDER_STATUS_ID;
}
if (is_object($order)) $this->update_status();
if (MODULE_PAYMENT_PAYPAL_TESTING == 'Live') {
$this->form_action_url = 'https://' . MODULE_PAYMENT_PAYPAL_HANDLER;
} else {
$this->form_action_url = DIR_WS_CATALOG . 'ipn_test.php';
}
}
/**
* calculate zone matches and flag settings to determine whether this module should display to customers or not
*
*/
function update_status() {
global $order, $db;
if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_PAYPAL_ZONE > 0) ) {
$check_flag = false;
$check_query = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_PAYPAL_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");
while (!$check_query->EOF) {
if ($check_query->fields['zone_id'] < 1) {
$check_flag = true;
break;
} elseif ($check_query->fields['zone_id'] == $order->billing['zone_id']) {
$check_flag = true;
break;
}
$check_query->MoveNext();
}
if ($check_flag == false) {
$this->enabled = false;
}
}
}
/**
* JS validation which does error-checking of data-entry if this module is selected for use
* (Number, Owner, and CVV Lengths)
*
* @return string
*/
function javascript_validation() {
return false;
}
/**
* Displays Credit Card Information Submission Fields on the Checkout Payment Page
* In the case of paypal, this only displays the paypal title
*
* @return array
*/
function selection() {
return array('id' => $this->code,
'module' => $this->title);
}
/**
* Normally evaluates the Credit Card Type for acceptance and the validity of the Credit Card Number & Expiration Date
* Since paypal module is not collecting info, it simply skips this step.
*
* @return boolean
*/
function pre_confirmation_check() {
return false;
}
/**
* Display Credit Card Information on the Checkout Confirmation Page
* Since none is collected for paypal before forwarding to paypal site, this is skipped
*
* @return boolean
*/
function confirmation() {
return false;
}
/**
* Build the data and actions to process when the "Submit" button is pressed on the order-confirmation screen.
* This sends the data to the payment gateway for processing.
* (These are hidden fields on the checkout confirmation page)
*
* @return string
*/
function process_button() {
global $db, $order, $currencies, $currency;
$this->totalsum = $order->info['total'];
// save the session stuff permanently in case paypal loses the session
$db->Execute("delete from " . TABLE_PAYPAL_SESSION . " where session_id = '" . session_id() . "'");
$sql = "insert into " . TABLE_PAYPAL_SESSION . " (session_id, saved_session, expiry) values (
'" . session_id() . "',
'" . base64_encode(serialize($_SESSION)) . "',
'" . (time() + (1*60*60*24*2)) . "')";
$db->Execute($sql);
if (MODULE_PAYMENT_PAYPAL_CURRENCY == 'Selected Currency') {
$my_currency = $_SESSION['currency'];
} else {
$my_currency = substr(MODULE_PAYMENT_PAYPAL_CURRENCY, 5);
}
if (!in_array($my_currency, array('CAD', 'EUR', 'GBP', 'JPY', 'USD', 'AUD'))) {
$my_currency = 'USD';
}
$telephone = preg_replace('/\D/', '', $order->customer['telephone']);
$process_button_string = zen_draw_hidden_field('business', MODULE_PAYMENT_PAYPAL_BUSINESS_ID) .
zen_draw_hidden_field('cmd', '_ext-enter') .
zen_draw_hidden_field('return', zen_href_link(FILENAME_CHECKOUT_PROCESS, 'referer=paypal', 'SSL')) .
zen_draw_hidden_field('cancel_return', zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL')) .
zen_draw_hidden_field('notify_url', zen_href_link('ipn_main_handler.php', '', 'SSL',false,false,true)) .
zen_draw_hidden_field('rm', MODULE_PAYMENT_PAYPAL_RM) .
zen_draw_hidden_field('currency_code', $my_currency) .
// zen_draw_hidden_field('address_override', MODULE_PAYMENT_PAYPAL_ADDRESS_OVERRIDE) .
// zen_draw_hidden_field('no_shipping', MODULE_PAYMENT_PAYPAL_ADDRESS_REQUIRED) .
zen_draw_hidden_field('bn', 'zencart') .
zen_draw_hidden_field('mrb', 'R-6C7952342H795591R') .
zen_draw_hidden_field('pal', '9E82WJBKKGPLQ') .
zen_draw_hidden_field('cbt', MODULE_PAYMENT_PAYPAL_CBT) .
// zen_draw_hidden_field('handling', MODULE_PAYMENT_PAYPAL_HANDLING) .
zen_draw_hidden_field('image_url', MODULE_PAYMENT_PAYPAL_IMAGE_URL) .
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -