Welcome Guest, Not a member yet? Register   Sign In
How to make payment gate way?
#13

[eluser]barryskidmore[/eluser]
Code:
function build_transaction($cart_id,$recurring_billing,$last_4) {
        $this->x_cart = $this->chalkboard->Cart_model->display_cart($cart_id);
        $this->x_subtotal = 0;
        $this->x_taxes = 0;
        $this->x_amount = 0;
        $this->x_line_item = '';
        $this->x_invoice_num = $cart_id;
        $this->x_cust_id = $this->chalkboard->session->userdata['user_id'];
        $this->x_customer_ip = $_SERVER["REMOTE_ADDR"];
        $this->x_recurring_billing = $recurring_billing;
        $this->item_counter = 0;
        if ($this->x_cart != 0) {
            foreach ($this->x_cart as $this->x_item) {
                $this->item_price_subtotal = $this->x_item->qty * $this->x_item->price;
                $this->item_tax = $this->x_item->tax_rate / 100;
                $this->item_tax = $this->item_price_subtotal * $this->item_tax;
                $this->item_price_total = $this->item_price_subtotal + $this->item_tax;
                if ($this->item_counter > 0) {
                    $this->x_line_item .= '&x_line_item='.urlencode($this->x_item->invoice_id).'<|>'.urlencode($this->x_item->name).'<|><|>'.urlencode($this->x_item->qty).'<|>'.urlencode($this->x_item->price).'<|>Y';
                } else {
                    $this->x_line_item .= 'x_line_item='.urlencode($this->x_item->invoice_id).'<|>'.urlencode($this->x_item->name).'<|><|>'.urlencode($this->x_item->qty).'<|>'.urlencode($this->x_item->price).'<|>Y';
                }
                $this->x_first_name = $this->x_item->fname;
                $this->x_last_name = $this->x_item->lname;
                $this->x_company = '';
                $this->x_address = $this->x_item->addr1.' '.$this->x_item->addr2;
                $this->x_city = $this->x_item->city;
                $this->x_state = $this->x_item->province;
                $this->x_zip = $this->x_item->postal;
                $this->x_country = $this->x_item->country;
                if ($last_4 == 1) {
                    $this->x_card_num = $this->x_item->last_4;
                    $this->x_trans_id = $this->x_item->transaction_id;
                }
                $this->item_counter++;
            }
            $this->x_subtotal = $this->x_subtotal + $this->item_price_subtotal;
            $this->x_taxes = $this->x_taxes + $this->item_tax;
            $this->x_amount = $this->x_amount + $this->item_price_total;
        }
    }
    
    # Authorizes payment based on current cart information.
    function authorize($cart_id = 0, $recurring_billing = 0) {
        if ($cart_id != 0) {
            $this->x_type = 'AUTH_CAPTURE';
            $this->x_description = 'Humanicity Website Transaction';
            $this->build_transaction($cart_id,0,0);
            return $this->parse_response($this->transact());
        } else {
            return 0;
        }
    }
    
    # Issues a percentage based credit (default 100%) to a transaction
    function credit($cart_id = 0) {
        if ($cart_id != 0) {
            $this->x_type = 'CREDIT';
            $this->x_description = 'Humanicity Website Credit';
            $this->build_transaction($cart_id,0,1);
            return $this->parse_response($this->transact());
        } else {
            return 0;
        }
    }
    
    # Voids a transaction from the system
    function void($cart_id = 0) {
        if ($cart_id != 0) {
            $this->x_type = 'VOID';
            $this->x_description = 'Humanicity Website VOID';
            return $this->parse_response($this->transact());
        } else {
            return 0;
        }
    }
    
}


Messages In This Thread
How to make payment gate way? - by El Forum - 09-19-2008, 10:00 AM
How to make payment gate way? - by El Forum - 09-19-2008, 10:11 AM
How to make payment gate way? - by El Forum - 09-19-2008, 10:12 AM
How to make payment gate way? - by El Forum - 09-19-2008, 10:13 AM
How to make payment gate way? - by El Forum - 09-19-2008, 10:16 AM
How to make payment gate way? - by El Forum - 09-19-2008, 10:20 AM
How to make payment gate way? - by El Forum - 09-19-2008, 10:22 AM
How to make payment gate way? - by El Forum - 09-19-2008, 10:42 AM
How to make payment gate way? - by El Forum - 09-22-2008, 12:40 PM
How to make payment gate way? - by El Forum - 09-22-2008, 12:41 PM
How to make payment gate way? - by El Forum - 09-22-2008, 12:43 PM
How to make payment gate way? - by El Forum - 09-22-2008, 12:43 PM
How to make payment gate way? - by El Forum - 09-22-2008, 12:43 PM
How to make payment gate way? - by El Forum - 09-22-2008, 01:18 PM
How to make payment gate way? - by El Forum - 09-23-2008, 06:41 AM
How to make payment gate way? - by El Forum - 09-23-2008, 01:25 PM
How to make payment gate way? - by El Forum - 11-19-2008, 10:55 AM



Theme © iAndrew 2016 - Forum software by © MyBB