} $ppe_payerid = $response_array['PAYERID']; tep_redirect(tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL')); } } else { tep_redirect(tep_href_link(FILENAME_SHOPPING_CART, 'error_message=' . stripslashes($response_array['L_LONGMESSAGE0']), 'SSL')); } break; default: include DIR_WS_CLASSES . 'order.php'; $order = new order(); $params['METHOD'] = 'SetExpressCheckout'; $params['PAYMENTACTION'] = MODULE_PAYMENT_PAYPAL_EXPRESS_TRANSACTION_METHOD == 'Sale' ? 'Sale' : 'Authorization'; $params['RETURNURL'] = tep_href_link('ext/modules/payment/paypal/express.php', 'osC_Action=retrieve', 'SSL', true, false); $params['CANCELURL'] = tep_href_link(FILENAME_SHOPPING_CART, '', 'SSL', true, false); $params['AMT'] = $paypal_express->format_raw($order->info['total']); $params['CURRENCYCODE'] = $order->info['currency']; if ($order->content_type == 'virtual') { $params['NOSHIPPING'] = '1'; } $post_string = ''; foreach ($params as $key => $value) { $post_string .= $key . '=' . urlencode(trim($value)) . '&'; } $post_string = substr($post_string, 0, -1); $response = $paypal_express->sendTransactionToGateway($api_url, $post_string); $response_array = array(); parse_str($response, $response_array); if ($response_array['ACK'] == 'Success' || $response_array['ACK'] == 'SuccessWithWarning') { tep_redirect($paypal_url . '&token=' . $response_array['TOKEN']); } else {
} } else { $quotes_array[] = array('id' => 'null', 'name' => 'No Shipping', 'label' => '', 'cost' => '0', 'tax' => '0'); } include DIR_WS_CLASSES . 'order_total.php'; $order_total_modules = new order_total(); $order_totals = $order_total_modules->process(); $params = array('METHOD' => 'CallbackResponse', 'CALLBACKVERSION' => $paypal_express->api_version); if (!empty($quotes_array)) { $params['CURRENCYCODE'] = $currency; $params['OFFERINSURANCEOPTION'] = 'false'; $counter = 0; $cheapest_rate = null; $cheapest_counter = $counter; foreach ($quotes_array as $quote) { $shipping_rate = $paypal_express->format_raw($quote['cost'] + tep_calculate_tax($quote['cost'], $quote['tax'])); $params['L_SHIPPINGOPTIONNAME' . $counter] = $quote['name']; $params['L_SHIPPINGOPTIONLABEL' . $counter] = $quote['label']; $params['L_SHIPPINGOPTIONAMOUNT' . $counter] = $shipping_rate; $params['L_SHIPPINGOPTIONISDEFAULT' . $counter] = 'false'; if (DISPLAY_PRICE_WITH_TAX == 'false') { $params['L_TAXAMT' . $counter] = $paypal_express->format_raw($order->info['tax']); } if (is_null($cheapest_rate) || $shipping_rate < $cheapest_rate) { $cheapest_rate = $shipping_rate; $cheapest_counter = $counter; } $counter++; } $params['L_SHIPPINGOPTIONISDEFAULT' . $cheapest_counter] = 'true'; } else {
foreach ($quote['methods'] as $rate) { $quotes_array[] = array('id' => $quote['id'] . '_' . $rate['id'], 'name' => $quote['module'], 'label' => $rate['title'], 'cost' => $rate['cost'], 'tax' => isset($quote['tax']) ? $quote['tax'] : '0'); } } } } } } else { $quotes_array[] = array('id' => 'null', 'name' => 'No Shipping', 'label' => 'No Shipping', 'cost' => '0', 'tax' => '0'); } $params = array('METHOD' => 'CallbackResponse', 'OFFERINSURANCEOPTION' => 'false'); $counter = 0; $cheapest_rate = null; $cheapest_counter = $counter; foreach ($quotes_array as $quote) { $shipping_rate = $paypal_express->format_raw($quote['cost'] + tep_calculate_tax($quote['cost'], $quote['tax'])); $params['L_SHIPPINGOPTIONNAME' . $counter] = $quote['name'] . ' (' . $quote['label'] . ')'; $params['L_SHIPINGPOPTIONLABEL' . $counter] = $quote['name'] . ' (' . $quote['label'] . ')'; $params['L_SHIPPINGOPTIONAMOUNT' . $counter] = $paypal_express->format_raw($quote['cost']); $params['L_SHIPPINGOPTIONISDEFAULT' . $counter] = 'false'; $params['L_TAXAMT' . $counter] = $paypal_express->format_raw($order->info['tax'] + tep_calculate_tax($quote['cost'], $quote['tax'])); if (is_null($cheapest_rate) || $shipping_rate < $cheapest_rate) { $cheapest_rate = $shipping_rate; $cheapest_counter = $counter; } $counter++; } $params['L_SHIPPINGOPTIONISDEFAULT' . $cheapest_counter] = 'true'; $post_string = ''; foreach ($params as $key => $value) { $post_string .= $key . '=' . urlencode(utf8_encode(trim($value))) . '&';
tep_session_register('ppe_payerid'); } $ppe_payerid = $response_array['PAYERID']; tep_redirect(tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL')); } } else { tep_redirect(tep_href_link(FILENAME_SHOPPING_CART, 'error_message=' . stripslashes($response_array['L_LONGMESSAGE0']), 'SSL')); } break; default: if (MODULE_PAYMENT_PAYPAL_EXPRESS_TRANSACTION_SERVER == 'Live') { $paypal_url = 'https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout'; } else { $paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout'; } include DIR_WS_CLASSES . 'order.php'; $order = new order(); $params = array('AMT' => $paypal_express->format_raw($order->info['total']), 'CURRENCYCODE' => $order->info['currency']); if ($order->content_type == 'virtual') { $params['NOSHIPPING'] = '1'; } $response_array = $paypal_express->setExpressCheckout($params); if ($response_array['ACK'] == 'Success' || $response_array['ACK'] == 'SuccessWithWarning') { tep_redirect($paypal_url . '&token=' . $response_array['TOKEN']); } else { tep_redirect(tep_href_link(FILENAME_SHOPPING_CART, 'error_message=' . stripslashes($response_array['L_LONGMESSAGE0']), 'SSL')); } break; } tep_redirect(tep_href_link(FILENAME_SHOPPING_CART, '', 'SSL')); require DIR_WS_INCLUDES . 'application_bottom.php';