$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('CURRENCY' => $order->info['currency'], 'EMAIL' => $order->customer['email_address'], 'ALLOWNOTE' => '0'); // A billing address is required for digital orders so we use the shipping address PayPal provides // if ($order->content_type == 'virtual') { // $params['NOSHIPPING'] = '1'; // } $item_params = array(); $line_item_no = 0; foreach ($order->products as $product) { if (DISPLAY_PRICE_WITH_TAX == 'true') { $product_price = $paypal_pro_payflow_ec->format_raw($product['final_price'] + tep_calculate_tax($product['final_price'], $product['tax'])); } else { $product_price = $paypal_pro_payflow_ec->format_raw($product['final_price']); } $item_params['L_NAME' . $line_item_no] = $product['name']; $item_params['L_COST' . $line_item_no] = $product_price; $item_params['L_QTY' . $line_item_no] = $product['qty']; $line_item_no++; } $params['BILLTOFIRSTNAME'] = $order->billing['firstname']; $params['BILLTOLASTNAME'] = $order->billing['lastname']; $params['BILLTOSTREET'] = $order->billing['street_address']; $params['BILLTOCITY'] = $order->billing['city']; $params['BILLTOSTATE'] = tep_get_zone_code($order->billing['country']['id'], $order->billing['zone_id'], $order->billing['state']); $params['BILLTOCOUNTRY'] = $order->billing['country']['iso_code_2']; $params['BILLTOZIP'] = $order->billing['postcode'];
$error_message = MODULE_PAYMENT_PAYPAL_PRO_PAYFLOW_EC_ERROR_EXPRESS_DISABLED; break; default: $error_message = MODULE_PAYMENT_PAYPAL_PRO_PAYFLOW_EC_ERROR_GENERAL; break; } tep_redirect(tep_href_link(FILENAME_SHOPPING_CART, 'error_message=' . urlencode($error_message), 'SSL')); } break; default: include DIR_WS_CLASSES . 'order.php'; $order = new order(); $params['ACTION'] = 'S'; $params['CURRENCY'] = $order->info['currency']; $params['EMAIL'] = $order->customer['email_address']; $params['AMT'] = $paypal_pro_payflow_ec->format_raw($order->info['total']); $params['RETURNURL'] = tep_href_link('ext/modules/payment/paypal/express_payflow.php', 'osC_Action=retrieve', 'SSL', true, false); $params['CANCELURL'] = tep_href_link(FILENAME_SHOPPING_CART, '', 'SSL', true, false); if ($order->content_type == 'virtual') { $params['NOSHIPPING'] = '1'; } $post_string = ''; foreach ($params as $key => $value) { $post_string .= $key . '[' . strlen(urlencode(utf8_encode(trim($value)))) . ']=' . urlencode(utf8_encode(trim($value))) . '&'; } $post_string = substr($post_string, 0, -1); $response = $paypal_pro_payflow_ec->sendTransactionToGateway($api_url, $post_string, array('X-VPS-REQUEST-ID: ' . md5($cartID . tep_session_id() . rand()))); $response_array = array(); parse_str($response, $response_array); if ($response_array['RESULT'] == '0') { tep_redirect($paypal_url . '&token=' . $response_array['TOKEN']);