📄 paypal.php
字号:
'address_country' => $order->customer['country']['title'],
'address_country_code' => $order->customer['country']['iso_code_2'],
'payer_email' => $order->customer['email_address'],
);
$optionsShip = array(
//'address_override' => MODULE_PAYMENT_PAYPAL_ADDRESS_OVERRIDE,
'no_shipping' => MODULE_PAYMENT_PAYPAL_ADDRESS_REQUIRED,
);
if (MODULE_PAYMENT_PAYPAL_DETAILED_CART == 'Yes') $optionsLineItems = ipn_getLineItemDetails();
if (sizeof($optionsLineItems) > 0) {
$optionsLineItems['cmd'] = '_cart';
// $optionsLineItems['num_cart_items'] = sizeof($order->products);
if (isset($optionsLineItems['shipping'])) {
$optionsLineItems['shipping_1'] = $optionsLineItems['shipping'];
unset($optionsLineItems['shipping']);
}
if (isset($optionsLineItems['handling'])) {
$optionsLineItems['handling_1'] = $optionsLineItems['handling'];
unset($optionsLineItems['handling']);
}
unset($optionsLineItems['subtotal']);
// if line-item details couldn't be kept due to calculation mismatches or discounts etc, default to aggregate mode
if (!isset($optionsLineItems['item_name_1'])) $optionsLineItems = array();
//if ($optionsLineItems['amount'] != $this->transaction_amount) $optionsLineItems = array();
ipn_debug_email('Line Item Details (if blank, this means there was a data mismatch, and thus bypassed): ' . "\n" . print_r($optionsLineItems, true));
}
$optionsAggregate = array(
'cmd' => '_ext-enter',
'item_name' => MODULE_PAYMENT_PAYPAL_PURCHASE_DESCRIPTION_TITLE,
'item_number' => MODULE_PAYMENT_PAYPAL_PURCHASE_DESCRIPTION_ITEMNUM,
//'num_cart_items' => sizeof($order->products),
'amount' => number_format($this->transaction_amount, $currencies->get_decimal_places($my_currency)),
'shipping' => '0.00',
);
if (MODULE_PAYMENT_PAYPAL_TAX_OVERRIDE == 'true') $optionsAggregate['tax'] = '0.00';
if (MODULE_PAYMENT_PAYPAL_TAX_OVERRIDE == 'true') $optionsAggregate['tax_cart'] = '0.00';
$optionsTrans = array(
'upload' => (int)(sizeof($order->products) > 0),
'currency_code' => $my_currency,
// 'paypal_order_id' => $paypal_order_id,
//'no_note' => '1',
//'invoice' => '',
);
// if line-item info is invalid, use aggregate:
if (sizeof($optionsLineItems) > 0) $optionsAggregate = $optionsLineItems;
// prepare submission
$options = array_merge($optionsCore, $optionsCust, $optionsPhone, $optionsShip, $optionsTrans, $optionsAggregate);
ipn_debug_email('Keys for submission: ' . print_r($options, true));
// build the button fields
foreach ($options as $name => $value) {
// remove quotation marks
$value = str_replace('"', '', $value);
// check for invalid chars
if (preg_match('/[^a-zA-Z_0-9]/', $name)) {
ipn_debug_email('datacheck - ABORTING - preg_match found invalid submission key: ' . $name . ' (' . $value . ')');
break;
}
// do we need special handling for & and = symbols?
//if (strpos($value, '&') !== false || strpos($value, '=') !== false) $value = urlencode($value);
$buttonArray[] = zen_draw_hidden_field($name, $value);
}
$process_button_string = implode("\n", $buttonArray) . "\n";
$_SESSION['paypal_transaction_info'] = array($this->transaction_amount, $this->transaction_currency);
return $process_button_string;
}
/**
* Store transaction info to the order and process any results that come back from the payment gateway
*/
function before_process() {
global $order_total_modules;
list($this->transaction_amount, $this->transaction_currency) = $_SESSION['paypal_transaction_info'];
unset($_SESSION['paypal_transaction_info']);
if (isset($_GET['referer']) && $_GET['referer'] == 'paypal') {
$this->notify('NOTIFY_PAYMENT_PAYPAL_RETURN_TO_STORE');
if (MODULE_PAYMENT_PAYPAL_TESTING == 'Test') {
// simulate call to ipn_handler.php here
ipn_simulate_ipn_handler((int)$_GET['count']);
}
if (defined('MODULE_PAYMENT_PAYPAL_PDTTOKEN') && MODULE_PAYMENT_PAYPAL_PDTTOKEN != '') {
$pdtStatus = $this->_getPDTresults($this->transaction_amount, $this->transaction_currency);
} else {
$pdtStatus = false;
}
if ($pdtStatus == false) {
$_SESSION['cart']->reset(true);
unset($_SESSION['sendto']);
unset($_SESSION['billto']);
unset($_SESSION['shipping']);
unset($_SESSION['payment']);
unset($_SESSION['comments']);
unset($_SESSION['cot_gv']);
$order_total_modules->clear_posts();//ICW ADDED FOR CREDIT CLASS SYSTEM
zen_redirect(zen_href_link(FILENAME_CHECKOUT_SUCCESS, '', 'SSL'));
} else {
// PDT was good, so delete IPN session from PayPal table -- housekeeping.
global $db;
$db->Execute("delete from " . TABLE_PAYPAL_SESSION . " where session_id = '" . zen_db_input($_SESSION['ppipn_key_to_remove']) . "'");
unset($_SESSION['ppipn_key_to_remove']);
$_SESSION['paypal_transaction_PDT_passed'] = true;
return true;
}
} else {
$this->notify('NOTIFY_PAYMENT_PAYPAL_CANCELLED_DURING_CHECKOUT');
zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
}
}
/**
* Checks referrer
*
* @param string $zf_domain
* @return boolean
*/
function check_referrer($zf_domain) {
return true;
}
/**
* Build admin-page components
*
* @param int $zf_order_id
* @return string
*/
function admin_notification($zf_order_id) {
global $db;
$output = '';
$sql = "select * from " . TABLE_PAYPAL . " where order_id = '" . (int)$zf_order_id . "' order by paypal_ipn_id DESC LIMIT 1";
$ipn = $db->Execute($sql);
if ($ipn->RecordCount() > 0 && file_exists(DIR_FS_CATALOG . DIR_WS_MODULES . 'payment/paypal/paypal_admin_notification.php')) require(DIR_FS_CATALOG . DIR_WS_MODULES . 'payment/paypal/paypal_admin_notification.php');
return $output;
}
/**
* Post-processing activities
* When the order returns from the processor, if PDT was successful, this stores the results in order-status-history and logs data for subsequent reference
*
* @return boolean
*/
function after_process() {
global $insert_id, $db;
if ($_SESSION['paypal_transaction_PDT_passed'] != true) {
$_SESSION['order_created'] = '';
unset($_SESSION['paypal_transaction_PDT_passed']);
return false;
} else {
// PDT found order to be approved, so add a new OSH record for this order's PP details
unset($_SESSION['paypal_transaction_PDT_passed']);
$sql_data_array= array(array('fieldName'=>'orders_id', 'value'=>$insert_id, 'type'=>'integer'),
array('fieldName'=>'orders_status_id', 'value'=>$this->order_status, 'type'=>'integer'),
array('fieldName'=>'date_added', 'value'=>'now()', 'type'=>'noquotestring'),
array('fieldName'=>'customer_notified', 'value'=>0, 'type'=>'integer'),
array('fieldName'=>'comments', 'value'=>'PayPal status: ' . $this->pdtData['payment_status'] . ' ' . ' @ ' . $this->pdtData['payment_date'] . "\n" . ' Trans ID:' . $this->pdtData['txn_id'] . "\n" . ' Amount: ' . $this->pdtData['mc_gross'] . ' ' . $this->pdtData['mc_currency'] . '.', 'type'=>'string'));
$db->perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
ipn_debug_email('PDT NOTICE :: Order added: ' . $insert_id . "\n" . 'PayPal status: ' . $this->pdtData['payment_status'] . ' ' . ' @ ' . $this->pdtData['payment_date'] . "\n" . ' Trans ID:' . $this->pdtData['txn_id'] . "\n" . ' Amount: ' . $this->pdtData['mc_gross'] . ' ' . $this->pdtData['mc_currency']);
// store the PayPal order meta data -- used for later matching and back-end processing activities
$sql_data_array = array('order_id' => $insert_id,
'txn_type' => $this->pdtData['txn_type'],
'module_name' => $this->code . ' ' . $this->codeVersion,
'module_mode' => 'PDT',
'reason_code' => $this->pdtData['reasoncode'],
'payment_type' => $this->pdtData['payment_type'],
'payment_status' => $this->pdtData['payment_status'],
'pending_reason' => $this->pdtData['pendingreason'],
'invoice' => $this->pdtData['invoice'],
'first_name' => $this->pdtData['first_name'],
'last_name' => $this->pdtData['last_name'],
'payer_business_name' => $order->billing['company'],
'address_name' => $order->billing['name'],
'address_street' => $order->billing['street_address'],
'address_city' => $order->billing['city'],
'address_state' => $order->billing['state'],
'address_zip' => $order->billing['postcode'],
'address_country' => $this->pdtData['residence_country'], // $order->billing['country']
'address_status' => $this->pdtData['address_status'],
'payer_email' => $this->pdtData['payer_email'],
'payer_id' => $this->pdtData['payer_id'],
'payer_status' => $this->pdtData['payer_status'],
'payment_date' => trim(preg_replace('/[^0-9-:]/', ' ', $this->pdtData['payment_date'])),
'business' => $this->pdtData['business'],
'receiver_email' => $this->pdtData['receiver_email'],
'receiver_id' => $this->pdtData['receiver_id'],
'txn_id' => $this->pdtData['txn_id'],
'parent_txn_id' => $this->pdtData['parent_txn_id'],
'num_cart_items' => (float)$this->pdtData['num_cart_items'],
'mc_gross' => (float)$this->pdtData['mc_gross'],
'mc_fee' => (float)$this->pdtData['mc_fee'],
'mc_currency' => $this->pdtData['mc_currency'],
'settle_amount' => (float)$this->pdtData['settle_amount'],
'settle_currency' => $this->pdtData['settle_currency'],
'exchange_rate' => ($this->pdtData['exchange_rate'] > 0 ? $this->pdtData['exchange_rate'] : 1.0),
'notify_version' => (float)$this->pdtData['notify_version'],
'verify_sign' => $this->pdtData['verify_sign'],
'date_added' => 'now()',
'memo' => '{Successful PDT Confirmation - Record auto-generated by payment module}'
);
zen_db_perform(TABLE_PAYPAL, $sql_data_array);
}
}
/**
* Used to display error message details
*
* @return boolean
*/
function output_error() {
return false;
}
/**
* Check to see whether module is installed
*
* @return boolean
*/
function check() {
global $db;
if (IS_ADMIN_FLAG === true) {
global $sniffer;
if ($sniffer->field_exists(TABLE_PAYPAL, 'zen_order_id')) $db->Execute("ALTER TABLE " . TABLE_PAYPAL . " CHANGE COLUMN zen_order_id order_id int(11) NOT NULL default '0'");
}
if (!isset($this->_check)) {
$check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_PAYPAL_STATUS'");
$this->_check = $check_query->RecordCount();
}
return $this->_check;
}
/**
* Install the payment module and its configuration settings
*
*/
function install() {
global $db;
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('鎵撳紑PayPal鏀
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -