function setup_checkout(ET_Order $order) { $_2co_payment = new ET_2CO(); $order_pay = clone $order; $order = $order_pay->generate_data_to_pay(); extract($order); $pro_str = ""; if (!empty($products)) { foreach ($products as $key => $value) { $k = $key; $pro_str .= "&c_prod_{$k}=" . urlencode($value['ID']); $pro_str .= "&c_name_{$k}=" . urldecode($value['NAME']); $pro_str .= "&c_description_{$k}=" . urldecode($value['L_DESC']); //$pro_str .= "&c_price_$k=".urlencode($value['AMT']); } $pro_str .= "&cart_order_id=" . $order_name; } $payer = new WP_User($order['payer']); $first_name = get_user_meta($payer->ID, 'first_name', true); $last_name = get_user_meta($payer->ID, 'last_name', true); $buyer = array('name' => $payer->display_name, 'street_address' => '', 'city' => '', 'state' => '', 'country' => '', 'email' => $payer->user_email, 'phone' => ''); extract($buyer); /* * generate buyer info to send to 2checkout */ $buyer_str = ''; $buyer_str .= '&card_holder_name=' . urlencode($name); $buyer_str .= '&street_address=' . urlencode($street_address); $buyer_str .= '&city=' . urlencode($city); $buyer_str .= '&country=' . urlencode($country); $buyer_str .= '&email=' . urlencode($email); $buyer_str .= '&phone=' . urlencode($phone); /* * ship detail */ $shipping = array('ship_name' => 'Dakachi orime', 'ship_street_address' => '52 Hoa Hong', 'ship_city' => 'Ho Chi Minh', 'ship_state' => '', 'ship_zip' => '', 'ship_country' => 'VNM'); $shipping = array(); $ship_str = ''; extract($shipping); if (!empty($shipping)) { $ship_str .= '&ship_name=' . urlencode($ship_name); $ship_str .= '&ship_street_address=' . urlencode($ship_street_address); $ship_str .= '&ship_city=' . urlencode($ship_city); $ship_str .= '&ship_state=' . urlencode($ship_state); $ship_str .= '&ship_zip=' . urlencode($ship_zip); $ship_str .= '&ship_country=' . urlencode($ship_country); } if ($total == '' || $ID == '') { return array('ACK' => false, 'error_msg' => 'Invalid argument cart order id'); } $return = "&x_receipt_link_url=" . $this->_settings['return']; $nvpstr = "&total=" . urlencode($total) . "&cart_order_id=" . urlencode($ID) . "&id_type=1" . $buyer_str . $ship_str . $pro_str . $return; $location = $_2co_payment->set_checkout($nvpstr, 'SetExpressCheckout'); return array('ACK' => true, 'url' => $location['url'], 'extend' => false); }