Ejemplo n.º 1
0
 function template_vars()
 {
     $order = get_order();
     if (!$order->get_gateway()) {
         return;
     }
     $gateway = APP_Gateway_Registry::get_gateway($order->get_gateway());
     $template_vars = array('gateway' => $gateway->display_name('dropdown'));
     return $template_vars;
 }
Ejemplo n.º 2
0
 /**
  * Displays notices if a gateway is disabled.
  */
 function disabled_gateway_warning()
 {
     if (isset($_GET['tab'])) {
         $gateway_id = $_GET['tab'];
         $gateway = APP_Gateway_Registry::get_gateway($gateway_id);
         if (APP_Gateway_Registry::is_gateway_registered($gateway_id) && $gateway->supports('escrow') && !APP_Gateway_Registry::is_gateway_enabled($gateway_id, 'escrow')) {
             $this->admin_msg(__('This gateway is currently <strong>disabled</strong>. It cannot be used on escrow transactions. Go to the <a href="?page=app-payments-settings&tab=escrow">Escrow</a> tab to enable it.', APP_TD));
         }
     }
 }
Ejemplo n.º 3
0
 public function test_gateway_creation()
 {
     appthemes_register_gateway('APP_Mock_Gateway');
     $gateway = APP_Gateway_Registry::get_gateway('mock-gateway');
     $this->assertNotEmpty($gateway);
     // New gateways should not be enabled
     $this->assertFalse(APP_Gateway_Registry::is_gateway_enabled('mock-gateway'));
     $this->assertTrue($this->_test_gateway_creation_internal($gateway));
     return $gateway;
 }
 /**
  * See APP_Order::set_gateway() for more information
  * @param string $gateway_id The Gateway Identifier. See APP_gateway
  */
 public function set_gateway($gateway_id)
 {
     if (!is_string($gateway_id)) {
         trigger_error('Gateway ID must be a string', E_USER_WARNING);
     }
     if ($gateway = APP_Gateway_Registry::get_gateway($gateway_id)) {
         $this->payment['gateway'] = $gateway->identifier();
         $this->modified = true;
         return true;
     }
     return false;
 }
Ejemplo n.º 5
0
function appthemes_recurring_available($gateway_id = '')
{
    if (!empty($gateway_id) && APP_Gateway_Registry::is_gateway_enabled($gateway_id)) {
        $gateways = array(APP_Gateway_Registry::get_gateway($gateway_id));
    } else {
        $gateways = APP_Gateway_Registry::get_active_gateways();
    }
    foreach ($gateways as $gateway) {
        if ($gateway->is_recurring()) {
            return true;
        }
    }
    return false;
}
 public function process_item($item)
 {
     $order = appthemes_get_order($item->ID, true);
     if (!$order) {
         return;
     }
     if ($order->get_status() == APPTHEMES_ORDER_PENDING) {
         $gateway = $order->get_gateway();
         if (empty($gateway)) {
             return;
         }
         $gateway_object = APP_Gateway_Registry::get_gateway($gateway);
         if (!$gateway_object || !$gateway_object->is_recurring()) {
             return;
         }
         appthemes_process_recurring_gateway($gateway, $order);
     }
     $order = appthemes_get_order($item->ID, true);
     if ($order->get_status() == APPTHEMES_ORDER_COMPLETED) {
         $order->log('Processing Queue: Order is completed. Activating');
         $order->activate();
     }
 }
Ejemplo n.º 7
0
/**
 * Outputs column data for orders
 * @param  string $column_index Name of the column being processed
 * @param  int $post_id         ID of order being dispalyed
 * @return void
 */
function appthemes_order_add_column_data($column_index, $post_id)
{
    $order = appthemes_get_order($post_id);
    switch ($column_index) {
        case 'order':
            echo '<a href="' . get_edit_post_link($post_id) . '">' . $order->get_ID() . '</a>';
            break;
        case 'order_author':
            $user = get_userdata($order->get_author());
            echo $user->display_name;
            echo '<br>';
            echo $order->get_ip_address();
            break;
        case 'item':
            $count = count($order->get_items());
            $string = _n('Purchased %s item', 'Purchased %s items', $count, APP_TD);
            printf($string, $count);
            break;
        case 'price':
            $currency = $order->get_currency();
            if (!empty($currency)) {
                echo appthemes_get_price($order->get_total(), $order->get_currency());
            } else {
                echo appthemes_get_price($order->get_total());
            }
            break;
        case 'payment':
            $gateway_id = $order->get_gateway();
            if (!empty($gateway_id)) {
                $gateway = APP_Gateway_Registry::get_gateway($gateway_id);
                if ($gateway) {
                    echo $gateway->display_name('admin');
                } else {
                    _e('Unknown', APP_TD);
                }
            } else {
                _e('Undecided', APP_TD);
            }
            echo '</br>';
            $status = $order->get_display_status();
            if ($order->get_status() == APPTHEMES_ORDER_PENDING) {
                echo '<strong>' . ucfirst($status) . '</strong>';
            } else {
                echo ucfirst($status);
            }
            break;
        case 'status':
            echo ucfirst($order->get_status());
            break;
        case 'order_date':
            $order_post = get_post($order->get_ID());
            if ('0000-00-00 00:00:00' == $order_post->post_date) {
                $t_time = $h_time = __('Unpublished', APP_TD);
                $time_diff = 0;
            } else {
                $t_time = get_the_time(_x('Y/m/d g:i:s A', 'Order Date Format', APP_TD));
                $m_time = $order_post->post_date;
                $time = get_post_time('G', true, $order_post);
                $time_diff = time() - $time;
                if ($time_diff > 0 && $time_diff < 24 * 60 * 60) {
                    $h_time = sprintf(__('%s ago', APP_TD), human_time_diff($time));
                } else {
                    $h_time = mysql2date(_x('Y/m/d', 'Order Date Format', APP_TD), $m_time);
                }
            }
            echo '<abbr title="' . $t_time . '">' . $h_time . '</abbr>';
            break;
    }
}
Ejemplo n.º 8
0
    /**
     * Displays the order status summary
     * @param  object $post Wordpress Post object
     * @return void
     */
    function display($post)
    {
        $order = appthemes_get_order($post->ID);
        ?>
		<style type="text/css">
			#admin-order-status th{
				padding-right: 10px;
				text-align: right;
				width: 40%;
			}
		</style>
		<table id="admin-order-status">
			<tbody>
				<tr>
					<th><?php 
        _e('ID', APP_TD);
        ?>
: </th>
					<td><?php 
        echo $order->get_ID();
        ?>
</td>
				</tr>
				<tr>
					<th><?php 
        _e('Status', APP_TD);
        ?>
: </th>
					<td><?php 
        echo $order->get_display_status();
        ?>
</td>
				</tr>
				<tr>
					<th><?php 
        _e('Gateway', APP_TD);
        ?>
: </th>
					<td>
					<?php 
        $gateway_id = $order->get_gateway();
        if (!empty($gateway_id)) {
            $gateway = APP_Gateway_Registry::get_gateway($gateway_id);
            if ($gateway) {
                echo $gateway->display_name('admin');
            } else {
                _e('Unknown', APP_TD);
            }
        } else {
            _e('Undecided', APP_TD);
        }
        ?>
					</td>
				</tr>
				<tr>
					<th><?php 
        _e('Currency', APP_TD);
        ?>
: </th>
					<td><?php 
        echo APP_Currencies::get_currency_string($order->get_currency());
        ?>
</td>
				</tr>
				<?php 
        if ($order->is_recurring()) {
            $period = $order->get_recurring_period();
            ?>
				<tr>
					<th><?php 
            _e('Recurs:', APP_TD);
            ?>
</th>
					<td><?php 
            printf(_n('Every day', 'Every %d days', $period, APP_TD), $period);
            ?>
</td>
				</tr>
				<tr>
					<th><?php 
            _e('Payment Date:', APP_TD);
            ?>
</th>
					<td><?php 
            echo appthemes_display_date(get_post($order->get_id())->post_date, 'date');
            ?>
</td>
				</tr>
				<?php 
        }
        ?>
				<?php 
        if ($order->get_parent() != 0) {
            ?>
				<tr>
					<th><?php 
            _e('Previously', APP_TD);
            ?>
</th>
					<td><a href="<?php 
            echo get_edit_post_link($order->get_parent());
            ?>
">#<?php 
            echo $order->get_parent();
            ?>
</a></td>
				</tr>
				<?php 
        }
        ?>
			</tbody>
		</table>
		<?php 
    }
 public function test_get_gateway_bad_value()
 {
     $this->setExpectedException('PHPUnit_Framework_Error_Warning');
     APP_Gateway_Registry::get_gateway(array('not-a-string'));
 }
Ejemplo n.º 10
0
/**
 * Retrieves the payment information for a given order.
 *
 * @since 3.5
 *
 * @param  $object $order The Order object.
 *
 * @return string The Order information.
 */
function the_orders_history_payment($order)
{
    $gateway_id = $order->get_gateway();
    if (!empty($gateway_id)) {
        $gateway = APP_Gateway_Registry::get_gateway($gateway_id);
        if ($gateway) {
            $gateway = $gateway->display_name('admin');
        } else {
            $gateway = __('Unknown', APP_TD);
        }
    } else {
        $gateway = __('Undecided', APP_TD);
    }
    $gateway = html('div', array('class' => 'order-history-gateway'), $gateway);
    $status = html('div', array('class' => 'order-history-status'), $order->get_display_status());
    echo $gateway . $status;
}
Ejemplo n.º 11
0
/**
 * Retrieves details for an escrow order.
 *
 * @param APP_Escrow_Order $order The order object
 *
 * @return bool|mixed The details for the order or False if no details found
 */
function appthemes_get_escrow_details(APP_Escrow_Order $order)
{
    $gateway_id = $order->get_gateway();
    $gateway = APP_Gateway_Registry::get_gateway($gateway_id);
    if ($gateway && (APP_Gateway_Registry::is_gateway_enabled($gateway_id) || current_user_can('manage_options'))) {
        if (!$gateway instanceof APP_Escrow_Payment_Processor) {
            return false;
        }
        $options = APP_Gateway_Registry::get_gateway_options($gateway_id);
        return $gateway->get_details($order, $options);
    } else {
        return false;
    }
}
Ejemplo n.º 12
0
function appthemes_process_gateway($gateway_id, $order)
{
    $options = APP_Gateway_Registry::get_gateway_options($gateway_id);
    $gateway = APP_Gateway_Registry::get_gateway($gateway_id);
    $gateway->process($order, $options);
}