Пример #1
0
 /**
  * Show my invoices.
  *
  * @return tempcode	The interface.
  */
 function my()
 {
     $title = get_page_title('MY_INVOICES');
     $member_id = get_member();
     if (has_specific_permission(get_member(), 'assume_any_member')) {
         $member_id = get_param_integer('id', $member_id);
     }
     $invoices = array();
     $rows = $GLOBALS['SITE_DB']->query_select('invoices', array('*'), array('i_member_id' => $member_id));
     foreach ($rows as $row) {
         $product = $row['i_type_code'];
         $object = find_product($product);
         if (is_null($object)) {
             continue;
         }
         $products = $object->get_products(false, $product);
         $invoice_title = $products[$product][4];
         $time = get_timezoned_date($row['i_time'], true, false, false, true);
         $payable = $row['i_state'] == 'new';
         $deliverable = $row['i_state'] == 'paid';
         $state = do_lang('PAYMENT_STATE_' . $row['i_state']);
         if (perform_local_payment()) {
             $transaction_button = hyperlink(build_url(array('page' => '_SELF', 'type' => 'pay', 'id' => $row['id']), '_SELF'), do_lang_tempcode('MAKE_PAYMENT'));
         } else {
             $transaction_button = make_transaction_button(substr(get_class($object), 5), $invoice_title, strval($row['id']), floatval($row['i_amount']), get_option('currency'));
         }
         $invoices[] = array('TRANSACTION_BUTTON' => $transaction_button, 'INVOICE_TITLE' => $invoice_title, 'ID' => strval($row['id']), 'AMOUNT' => $row['i_amount'], 'TIME' => $time, 'STATE' => $state, 'DELIVERABLE' => $deliverable, 'PAYABLE' => $payable, 'NOTE' => $row['i_note'], 'TYPE_CODE' => $row['i_type_code']);
     }
     if (count($invoices) == 0) {
         inform_exit(do_lang_tempcode('NO_ENTRIES'));
     }
     return do_template('ECOM_INVOICES_SCREEN', array('_GUID' => '144a893d93090c105eecc48fa58921a7', 'TITLE' => $title, 'CURRENCY' => get_option('currency'), 'INVOICES' => $invoices));
 }
Пример #2
0
 /**
  * Payment step.
  *
  * @param  tempcode	The page title.
  * @return tempcode	The result of execution.
  */
 function pay($title)
 {
     $product = get_param('product');
     $object = find_product($product);
     if (method_exists($object, 'is_available') && !$object->is_available($product, get_member())) {
         warn_exit(do_lang_tempcode('PRODUCT_UNAVAILABLE'));
     }
     $temp = $object->get_products(true, $product);
     $price = $temp[$product][1];
     $item_name = $temp[$product][4];
     if (method_exists($object, 'set_needed_fields')) {
         $purchase_id = $object->set_needed_fields($product);
     } else {
         $purchase_id = strval(get_member());
     }
     if ($temp[$product][0] == PRODUCT_SUBSCRIPTION) {
         $_purchase_id = $GLOBALS['SITE_DB']->query_value_null_ok('subscriptions', 'id', array('s_type_code' => $product, 's_member_id' => get_member(), 's_state' => 'new'));
         if (is_null($_purchase_id)) {
             $purchase_id = strval($GLOBALS['SITE_DB']->query_insert('subscriptions', array('s_type_code' => $product, 's_member_id' => get_member(), 's_state' => 'new', 's_amount' => $temp[$product][1], 's_special' => $purchase_id, 's_time' => time(), 's_auto_fund_source' => '', 's_auto_fund_key' => '', 's_via' => get_option('payment_gateway')), true));
         } else {
             $purchase_id = strval($_purchase_id);
         }
         $length = array_key_exists('length', $temp[$product][3]) ? $temp[$product][3]['length'] : 1;
         $length_units = array_key_exists('length_units', $temp[$product][3]) ? $temp[$product][3]['length_units'] : 'm';
     } else {
         $length = NULL;
         $length_units = '';
         //Add cataloue item order to shopping_orders
         if (method_exists($object, 'add_purchase_order')) {
             $purchase_id = strval($object->add_purchase_order($product, $temp[$product]));
         }
     }
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('PURCHASING'))));
     if ($price == '0') {
         $payment_status = 'Completed';
         $reason_code = '';
         $pending_reason = '';
         $mc_currency = get_option('currency');
         $txn_id = 'manual-' . substr(uniqid('', true), 0, 10);
         $parent_txn_id = '';
         $memo = 'Free';
         $mc_gross = '';
         handle_confirmed_transaction($purchase_id, $item_name, $payment_status, $reason_code, $pending_reason, $memo, $mc_gross, $mc_currency, $txn_id, $parent_txn_id);
         return inform_screen($title, do_lang_tempcode('FREE_PURCHASE'));
     }
     if (!array_key_exists(4, $temp[$product])) {
         $item_name = do_lang('CUSTOM_PRODUCT_' . $product, NULL, NULL, NULL, get_site_default_lang());
     }
     if (!perform_local_payment()) {
         if ($temp[$product][0] == PRODUCT_SUBSCRIPTION) {
             $transaction_button = make_subscription_button($product, $item_name, $purchase_id, floatval($price), $length, $length_units, get_option('currency'));
         } else {
             $transaction_button = make_transaction_button($product, $item_name, $purchase_id, floatval($price), get_option('currency'));
         }
         $tpl = $temp[$product][0] == PRODUCT_SUBSCRIPTION ? 'PURCHASE_WIZARD_STAGE_SUBSCRIBE' : 'PURCHASE_WIZARD_STAGE_PAY';
         $logos = method_exists($object, 'get_logos') ? $object->get_logos() : new ocp_tempcode();
         $result = do_template($tpl, array('LOGOS' => $logos, 'TRANSACTION_BUTTON' => $transaction_button, 'CURRENCY' => get_option('currency'), 'ITEM_NAME' => $item_name, 'TITLE' => $title, 'LENGTH' => is_null($length) ? '' : strval($length), 'LENGTH_UNITS' => $length_units, 'PURCHASE_ID' => $purchase_id, 'PRICE' => float_to_raw_string(floatval($price))));
     } else {
         if (!tacit_https() && !ecommerce_test_mode()) {
             warn_exit(do_lang_tempcode('NO_SSL_SETUP'));
         }
         $fields = get_transaction_form_fields(NULL, $purchase_id, $item_name, float_to_raw_string($price), $temp[$product][0] == PRODUCT_SUBSCRIPTION ? intval($length) : NULL, $temp[$product][0] == PRODUCT_SUBSCRIPTION ? $length_units : '');
         /*$via		=	get_option('payment_gateway');
         		require_code('hooks/systems/ecommerce_via/'.filter_naughty_harsh($via));
         		$object	=	object_factory('Hook_'.$via);
         		$ipn_url	=	$object->get_ipn_url();*/
         $finish_url = build_url(array('page' => '_SELF', 'type' => 'finish'), '_SELF');
         $result = do_template('PURCHASE_WIZARD_STAGE_TRANSACT', array('_GUID' => '15cbba9733f6ff8610968418d8ab527e', 'FIELDS' => $fields));
         return $this->wrap($result, $title, $finish_url);
     }
     return $this->wrap($result, $title, NULL);
 }