function fn_paypal_set_express_checkout($payment_id, $order_id = 0, $order_info = array(), $cart = array(), $area = AREA) { $processor_data = fn_get_payment_method_data($payment_id); if (!empty($order_id)) { $return_url = fn_url("payment_notification.notify?payment=paypal_express&order_id={$order_id}", $area, 'current'); $cancel_url = fn_url("payment_notification.cancel?payment=paypal_express&order_id={$order_id}", $area, 'current'); } else { $return_url = fn_payment_url('current', "paypal_express.php?mode=express_return&payment_id={$payment_id}"); $cancel_url = fn_url("checkout.cart", $area, 'current'); } $request = array('PAYMENTREQUEST_0_PAYMENTACTION' => 'SALE', 'PAYMENTREQUEST_0_CURRENCYCODE' => $processor_data['processor_params']['currency'], 'LOCALECODE' => CART_LANGUAGE, 'RETURNURL' => $return_url, 'CANCELURL' => $cancel_url, 'METHOD' => 'SetExpressCheckout', 'SOLUTIONTYPE' => 'Sole'); if (isset($_SESSION['paypal_token'])) { $request['IDENTITYACCESSTOKEN'] = $_SESSION['paypal_token']; } $paypal_settings = fn_get_paypal_settings(); if (!empty($paypal_settings) && !empty($paypal_settings['main_pair']['detailed'])) { $request['LOGOIMG'] = !empty($paypal_settings['main_pair']['detailed']['http_image_path']) ? $paypal_settings['main_pair']['detailed']['http_image_path'] : $paypal_settings['main_pair']['detailed']['image_path']; $exploded_logo = explode('?', $request['LOGOIMG']); $request['LOGOIMG'] = $exploded_logo[0]; } fn_paypal_build_request($processor_data, $request, $post_url, $cert_file); $order_details = !empty($order_info) ? fn_paypal_build_details($order_info, $processor_data, false) : fn_paypal_build_details($cart, $processor_data); $request = array_merge($request, $order_details); if (!empty($order_info)) { //We need to minus taxes when it based on unit price because product subtotal already include this tax. if (Registry::get('settings.General.tax_calculation') == 'unit_price') { $sum_taxes = fn_paypal_sum_taxes($order_info); $request['PAYMENTREQUEST_0_ITEMAMT'] -= $sum_taxes['P']; $request['PAYMENTREQUEST_0_SHIPPINGAMT'] -= $sum_taxes['S']; } } $result = fn_paypal_request($request, $post_url, $cert_file); return $result; }
function fn_process_paypal_ipn($order_id, $data) { $order_info = fn_get_order_info($order_id); if (!empty($order_info) && !empty($data['txn_id']) && (empty($order_info['payment_info']['txn_id']) || $data['payment_status'] != 'Completed' || $data['payment_status'] == 'Completed' && $order_info['payment_info']['txn_id'] !== $data['txn_id'])) { //Can't check refund transactions. if (isset($data['txn_type']) && !fn_validate_paypal_order_info($data, $order_info)) { return false; } $pp_settings = fn_get_paypal_settings(); fn_clear_cart($cart, true); $customer_auth = fn_fill_auth(array(), array(), false, 'C'); fn_form_cart($order_id, $cart, $customer_auth); if ($pp_settings['override_customer_info'] == 'Y') { $cart['user_data'] = fn_paypal_get_customer_info($data); } $cart['order_id'] = $order_id; $cart['payment_info'] = $order_info['payment_info']; $cart['payment_info']['protection_eligibility'] = !empty($data['protection_eligibility']) ? $data['protection_eligibility'] : ''; $cart['payment_id'] = $order_info['payment_id']; if (!empty($data['memo'])) { //Save customer notes $cart['notes'] = $data['memo']; } if ($data['payment_status'] == 'Completed') { //save uniq ipn id to avoid double ipn processing $cart['payment_info']['txn_id'] = $data['txn_id']; } if (!empty($data['payer_email'])) { $cart['payment_info']['customer_email'] = $data['payer_email']; } if (!empty($data['payer_id'])) { $cart['payment_info']['client_id'] = $data['payer_id']; } //Sometimes, for some reasons cart_id in product products calculated incorrectle, so we need recalculate it. $cart['change_cart_products'] = true; fn_calculate_cart_content($cart, $customer_auth); $cart['payment_info']['order_status'] = $pp_settings['pp_statuses'][strtolower($data['payment_status'])]; list($order_id, ) = fn_update_order($cart, $order_id); if ($order_id) { fn_change_order_status($order_id, $pp_settings['pp_statuses'][strtolower($data['payment_status'])]); if (fn_allowed_for('MULTIVENDOR')) { $child_order_ids = db_get_fields("SELECT order_id FROM ?:orders WHERE parent_order_id = ?i", $order_id); if (!empty($child_order_ids)) { foreach ($child_order_ids as $child_order_id) { fn_update_order_payment_info($child_order_id, $cart['payment_info']); } } } } return true; } }
<?php /*************************************************************************** * * * (c) 2004 Vladimir V. Kalynyak, Alexey V. Vinokurov, Ilya M. Shalnev * * * * This is commercial software, only users who have purchased a valid * * license and accept to the terms of the License Agreement can install * * and use this program. * * * **************************************************************************** * PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE * * "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. * ****************************************************************************/ use Tygh\Registry; use Tygh\Settings; if (!defined('BOOTSTRAP')) { die('Access denied'); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($mode == 'update' && $_REQUEST['addon'] == 'paypal' && (!empty($_REQUEST['pp_settings']) || !empty($_REQUEST['paypal_logo_image_data']))) { $pp_settings = isset($_REQUEST['pp_settings']) ? $_REQUEST['pp_settings'] : array(); fn_update_paypal_settings($pp_settings); } } if ($mode == 'update') { if ($_REQUEST['addon'] == 'paypal') { Registry::get('view')->assign('pp_settings', fn_get_paypal_settings()); } }
<?php /*************************************************************************** * * * (c) 2004 Vladimir V. Kalynyak, Alexey V. Vinokurov, Ilya M. Shalnev * * * * This is commercial software, only users who have purchased a valid * * license and accept to the terms of the License Agreement can install * * and use this program. * * * **************************************************************************** * PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE * * "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. * ****************************************************************************/ use Tygh\Registry; use Tygh\Settings; if (!defined('BOOTSTRAP')) { die('Access denied'); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($mode == 'update' && $_REQUEST['addon'] == 'paypal' && (!empty($_REQUEST['pp_settings']) || !empty($_REQUEST['paypal_logo_image_data']))) { $pp_settings = isset($_REQUEST['pp_settings']) ? $_REQUEST['pp_settings'] : array(); fn_update_paypal_settings($pp_settings); } } if ($mode == 'update') { if ($_REQUEST['addon'] == 'paypal') { Tygh::$app['view']->assign('pp_settings', fn_get_paypal_settings()); } }
function fn_process_paypal_ipn($order_id, $data) { $order_info = fn_get_order_info($order_id); if (!empty($order_info) && !empty($data['txn_id']) && (empty($order_info['payment_info']['txn_id']) || $data['payment_status'] != 'Completed' || $data['payment_status'] == 'Completed' && $order_info['payment_info']['txn_id'] !== $data['txn_id'])) { //Can't check refund transactions. if (isset($data['txn_type']) && !fn_validate_paypal_order_info($data, $order_info)) { return false; } $pp_settings = fn_get_paypal_settings(); $data['payment_status'] = strtolower($data['payment_status']); fn_clear_cart($cart, true); $customer_auth = fn_fill_auth(array(), array(), false, 'C'); fn_form_cart($order_id, $cart, $customer_auth); if ($pp_settings['override_customer_info'] == 'Y') { $cart['user_data'] = fn_paypal_get_customer_info($data); } $cart['order_id'] = $order_id; $cart['payment_info'] = $order_info['payment_info']; $cart['payment_info']['protection_eligibility'] = !empty($data['protection_eligibility']) ? $data['protection_eligibility'] : ''; $cart['payment_id'] = $order_info['payment_id']; if (!empty($data['memo'])) { //Save customer notes $cart['notes'] = $data['memo']; } if ($data['payment_status'] == 'Completed') { //save uniq ipn id to avoid double ipn processing $cart['payment_info']['txn_id'] = $data['txn_id']; } fn_calculate_cart_content($cart, $customer_auth); list($order_id, ) = fn_update_order($cart, $order_id); if ($order_id) { $send_notification = $order_info['status'] == $pp_settings['pp_statuses'][$data['payment_status']] ? false : array(); $short_order_data = fn_get_order_short_info($order_id); fn_change_order_status($order_id, $pp_settings['pp_statuses'][$data['payment_status']], $short_order_data['status'], $send_notification); } return true; } }