示例#1
0
 public function set_gateway($gateway_id)
 {
     if (!is_string($gateway_id)) {
         trigger_error('Gateway ID must be a string', E_USER_WARNING);
     }
     if ($gateway_object = Colabs_Gateway_Registry::get_gateway($gateway_id)) {
         $this->payment['gateway'] = $gateway_object->identifier();
         $this->update_meta('gateway', $this->payment['gateway']);
         return true;
     }
     return false;
 }
示例#2
0
function colabs_bank_transfer_pending_email($post)
{
    $content = '';
    $content .= html('p', __('A new order is waiting to be processed. Once you recieve payment, you should mark the order as completed.', 'colabsthemes'));
    $content .= html('h3', __('Order Summary', 'colabsthemes'));
    $gateway = Colabs_Gateway_Registry::get_gateway($post['colabs_payment_method']);
    $content .= '<ul>';
    $content .= '<li><strong>' . __('Order:', 'colabsthemes') . '</strong> ' . $post['order_id'] . '</li>';
    $content .= '<li><strong>' . __('Property Name:', 'colabsthemes') . '</strong> ' . get_the_title($post['post_id']) . '</li>';
    $content .= '<li><strong>' . __('Amount:', 'colabsthemes') . '</strong> ' . colabs_get_price($post['item_amount']) . '</li>';
    $content .= '<li><strong>' . __('Payment:', 'colabsthemes') . '</strong> ' . $gateway->display_name('dropdown') . '</li>';
    $content .= '</ul>';
    $order_link = html('a', array('href' => get_edit_post_link($post['order_id'])), __('Review this order', 'colabsthemes'));
    $all_orders = html('a', array('href' => admin_url('edit.php?post_status=transaction_pending&post_type=transaction')), __('review all pending orders', 'colabsthemes'));
    // translators: <Single Order Link> or <Link to All Orders>
    $content .= html('p', sprintf(__('%1$s or %2$s', 'colabsthemes'), $order_link, $all_orders));
    $subject = sprintf(__('[%1$s] Pending Order #%2$d', 'colabsthemes'), get_bloginfo('name'), $post['order_id']);
    if (!function_exists('colabs_send_email')) {
        return false;
    }
    $email = array('to' => get_option('admin_email'), 'subject' => $subject, 'message' => $content);
    colabs_send_email($email['to'], $email['subject'], $email['message']);
}
示例#3
0
function the_orders_history_payment($order)
{
    $gateway_id = $order->get_gateway();
    if (!empty($gateway_id)) {
        $gateway = Colabs_Gateway_Registry::get_gateway($gateway_id);
        if ($gateway) {
            $gateway = $gateway->display_name('admin');
        } else {
            $gateway = __('Unknown', 'colabsthemes');
        }
    } else {
        $gateway = __('Undecided', 'colabsthemes');
    }
    $gateway = html('div', array('class' => 'order-history-gateway'), $gateway);
    $status = html('div', array('class' => 'order-history-status'), $order->get_display_status());
    echo $gateway . $status;
}
if (isset($_POST['action']) && 'payment-process' == $_POST['action']) {
    if (!empty($_POST['order_id'])) {
        $order_id = intval($_POST['order_id']);
        $order = colabs_get_order($order_id);
    }
    if (isset($_GET['cancel'])) {
        $order->clear_gateway();
    }
    $get_gateway = $order->get_gateway();
    if (!empty($_POST['colabs_payment_method']) && empty($get_gateway)) {
        $order->set_gateway($_POST['colabs_payment_method']);
    }
    $gateway_id = $_POST['colabs_payment_method'];
    $gateway = Colabs_Gateway_Registry::get_gateway($gateway_id);
    if (Colabs_Gateway_Registry::is_gateway_enabled($gateway_id)) {
        $receipt_order['order_id'] = $order->get_id();
        $receipt_order['post_id'] = $order->get_post_type_id();
        $receipt_order['item_name'] = get_the_title($order->get_post_type_id());
        $receipt_order['item_amount'] = $order->get_total();
        $receipt_order['colabs_payment_method'] = $gateway_id;
        $gateway->process($receipt_order);
    }
} else {
    the_order_summary();
    $orders = colabs_get_order($order_id);
    if ($orders->get_total() > 0) {
        ?>
    <form action="" method="POST" class="payment-form">
      <p><?php 
        _e('Please select a method for processing your payment:', 'colabsthemes');
 function save_options()
 {
     if (isset($_POST['submitted']) && $_POST['submitted'] == 'true') {
         $options_gateways = $this->default_options_gateways;
         $gateways = Colabs_Gateway_Registry::get_gateways();
         foreach ($gateways as $gateway) {
             $options_gateways = array_merge($options_gateways, $gateway->form());
         }
         foreach ($options_gateways as $value) {
             if (isset($_POST[$value['id']])) {
                 update_option($value['id'], $_POST[$value['id']]);
             } else {
                 @delete_option($value['id']);
             }
         }
     }
 }
示例#6
0
 function colabs_ajax_validate_payment()
 {
     $return = array(success => false, errors => array());
     if (isset($_REQUEST['colabs_payment_method'])) {
         $gateway = Colabs_Gateway_Registry::get_gateway($_REQUEST['colabs_payment_method']);
         if ($gateway->validate_fields() === true) {
             $return['success'] = true;
         } else {
             if (sizeof($gateway->validate_fields()) > 0) {
                 $return['errors'] = $gateway->validate_fields();
             } else {
                 $return['success'] = true;
             }
         }
     } else {
         $return['errors'][] = __('Please select payment method', 'colabsthemes');
     }
     header('Content-Type: application/json');
     echo json_encode($return);
     exit;
 }
示例#7
0
 function is_recurring()
 {
     $options = Colabs_Gateway_Registry::get_gateway_options('paypal');
     return !empty($options['business_account']);
 }