Forums / Addon Payment Modules / custom payment

custom payment

Locked

Started by redtoad on 18 Dec 2006, 8:05 PM · Views: 1,864

Results 1 to 10 of 10
This thread is locked. New replies are disabled.
18 Dec 2006, 8:05 PM
#1
redtoad avatar

redtoad

New Zenner

Join Date:
Nov 2006
Posts:
8
Plugin Contributions:
0

custom payment

Hi,

first post, intermediate asp programmer, learning php (not awful at it). However I'm REALLY struggling with modifying the Zen code because everything is a special zen function instead of straightforward code, everything is an include wrapping a class or a function or a template and I do not have time to learn to speak Zen right now. I'm sorry, I don't. I'm trying, but I am getting panicked. I have to finish this NOW.

I've made a custom payment module ...but I need a few more parameters passed to it and have no idea how to get them from the cart to the form handler (which passes the data to my payments processor ) I don't even know where to look. I can't even figure out where it's best to run a query but am about to just write some queries in my form handler to get the data rather than have it passed to the cart. argh. maybe I should just do that. I don't know. (?????) I was trying to find the appropriate places in the process and have it written to session data or a hidden field that would post to my handler.

I need:
the name of what was ordered
the description of what was ordered
the model number and the quantity
what category this product is in (not required but it'd be nice)
the tax SEPARATE from the total
the total SEPARATE from the tax but with shipping
the handling fee (which I have to program in based on which zip code they're in, there may or may not be one... working on this...setting a flag Y/N)

any ideas?

test site is here:

http://www.kyflorists.com/zen/

right now i'm just having the screen print the output so I can see what I'm getting.

all help gratefully appreciated with much love and kudos and bowing and scraping.

edited: typos

18 Dec 2006, 8:11 PM
#2
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,746
Plugin Contributions:
0

Re: custom payment

What payment gateway is the client using?

Please do not PM for support issues: a private solution doesn't benefit the community.

Be careful with unsolicited advice via email or PM - Make sure the person you are talking to is a reliable source.

18 Dec 2006, 8:41 PM
#3
redtoad avatar

redtoad

New Zenner

Join Date:
Nov 2006
Posts:
8
Plugin Contributions:
0

Re: custom payment

one that I am building.

the payment has to post to a green screen application. it isn't a traditional processor. I'm building a form handler to work with it. But basically, the idea is normal, build a string, send it. I'm busy building my queries to get the fields now ...quick and dirty ...but if anyone can help me with
WHERE to get this stuff and just have it passed as hidden form data I'll go back and do it that way. I'd rather have it that way.

I understand dimly the entire idea of how the cart is built with the notifiers and stuff, have even sorted out how things fit together sort of but when it comes to understanding the best way to implement my changes ... sorta stymied. I'm basically hacking up templates for now and trying to avoid touching all other pages.

18 Dec 2006, 9:30 PM
#4
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,746
Plugin Contributions:
0

Re: custom payment

Have you looked at the way other payment module gather and pass the information?

Please do not PM for support issues: a private solution doesn't benefit the community.

Be careful with unsolicited advice via email or PM - Make sure the person you are talking to is a reliable source.

18 Dec 2006, 9:34 PM
#5
redtoad avatar

redtoad

New Zenner

Join Date:
Nov 2006
Posts:
8
Plugin Contributions:
0

Re: custom payment

yes, that is how i figured out how to get the parameters that i have.

the ones i still need are not in them.

even names where to look or a run down of

"this is the overview file"

"this file connects to the overview file like this"

would help point me in the right direction. I'm trying to figure it out on my own now reading through order.php

18 Dec 2006, 10:12 PM
#6
redtoad avatar

redtoad

New Zenner

Join Date:
Nov 2006
Posts:
8
Plugin Contributions:
0

Re: custom payment

okay, here is what I have so far...

<< function process_button() {

global $_SERVER, $order;



$sequence = rand(1, 1000);

$process_button_string = zen_draw_hidden_field('x_Login', MODULE_PAYMENT_WTF_LOGIN) .

    zen_draw_hidden_field('x_Card_Num', $this->cc_card_number) .

    zen_draw_hidden_field('x_Exp_Date', $this->cc_expiry_month . substr($this->cc_expiry_year, -2)) .

    zen_draw_hidden_field('x_Amount', number_format($order->info['total'], 2)) .

// zen_draw_hidden_field('x_currency_code', $_SESSION['currency']) .

zen_draw_hidden_field('x_Cust_ID', $_SESSION['customer_id']) .

zen_draw_hidden_field('x_first_name', $order->billing['firstname']) .

    zen_draw_hidden_field('x_last_name', $order->billing['lastname']) .>>

and so on. then we have:

<< return $process_button_string;>>

okay, so I should be able to write in something like....

	zen_draw_hidden_field('x_name', $order->products['name']) .
     zen_draw_hidden_field('x_model', $order->products['model']) .

to get all of my happy product names/model numbers.

except that I need a loop to get all of the products and this product array in order.php has an index number and i'm now trying to figure out the syntax I need to pull that data.

beautiful. lovely. gorgeous.

(sotto voce muttering)

<officeSpaceBoss> um... yeah </officeSpaceBoss>

19 Dec 2006, 1:43 AM
#7
redtoad avatar

redtoad

New Zenner

Join Date:
Nov 2006
Posts:
8
Plugin Contributions:
0

Re: custom payment

if anyone could help me with the syntax i would greatly appreciate it. If I've been unclear, let me know.

19 Dec 2006, 1:54 AM
#8
redtoad avatar

redtoad

New Zenner

Join Date:
Nov 2006
Posts:
8
Plugin Contributions:
0

Re: custom payment

never mind, I figured it out, was flipping back and forth between pages and got confused, this is just a loop. I get it.

sorry, my head is gonna explode.

19 Dec 2006, 6:28 PM
#9
redtoad avatar

redtoad

New Zenner

Join Date:
Nov 2006
Posts:
8
Plugin Contributions:
0

Re: custom payment

okay, here is my issue.

apparently the cart writes this prod info to the db after I run my form handler. but it clears the session before I run my form handler.

so I have to write this prod info to the process button string. okay. fine.

so the product info is in an array and has a loop.

this is where my novice php is killing me.

how the heck to I make a loop that pulls the data from the cart session and writes it to a hidden form field?

I've got:

$counter=0;
$products = $_SESSION['cart']->get_products();

for ($i=0, $n=sizeof($products); $i<$n; $i++){

  $this->products[$counter] = array('qty' => $products[$i]['quantity'],
                         

                                  'name' => $products[$i]['name'],

                                  'model' => $products[$i]['model'],

                                  'tax' => zen_get_tax_rate($products[$i]['tax_class_id'], $tax_address->fields['entry_country_id'], $tax_address->fields['entry_zone_id']));


   $prodname = $this->products[$i]['name'];
      $prodqty = $this->products[$i]['qty'];
	        $prodmodel = $this->products[$i]['model'];
 //this is where the $prodname, $prodqty, and $prodmodels should be    assigned to go into the process button string ?????? HELP???????
                                  
  $counter++;

}

$process_button_string = zen_draw_hidden_field('x_Login', MODULE_PAYMENT_WTF_LOGIN) .

    zen_draw_hidden_field('x_Card_Num', $this->cc_card_number) .

    zen_draw_hidden_field('x_Exp_Date', $this->cc_expiry_month . substr($this->cc_expiry_year, -2)) .

    zen_draw_hidden_field('x_Amount', number_format($order->info['total'], 2)) .

// zen_draw_hidden_field('x_currency_code', $_SESSION['currency']) .

zen_draw_hidden_field('x_Cust_ID', $_SESSION['customer_id']) .

zen_draw_hidden_field('x_first_name', $order->billing['firstname']) .

    zen_draw_hidden_field('x_last_name', $order->billing['lastname']) .

    zen_draw_hidden_field('x_address', $order->billing['street_address']) .

    zen_draw_hidden_field('x_city', $order->billing['city']) .

    zen_draw_hidden_field('x_state', $order->billing['state']) .

    zen_draw_hidden_field('x_zip', $order->billing['postcode']) .

    zen_draw_hidden_field('x_country', $order->billing['country']['title']) .

    zen_draw_hidden_field('x_phone', $order->customer['telephone']) .

    zen_draw_hidden_field('x_email', $order->customer['email_address']) .
  zen_draw_hidden_field('x_ship_to_first_name', $order->delivery['firstname']) .

    zen_draw_hidden_field('x_ship_to_last_name', $order->delivery['lastname']) .

    zen_draw_hidden_field('x_ship_to_address', $order->delivery['street_address']) .

    zen_draw_hidden_field('x_ship_to_city', $order->delivery['city']) .

    zen_draw_hidden_field('x_ship_to_state', $order->delivery['state']) .

    zen_draw_hidden_field('x_ship_to_zip', $order->delivery['postcode']) .

    zen_draw_hidden_field('x_ship_to_country', $order->delivery['country']['title']) .

    zen_draw_hidden_field('x_Customer_IP', $_SERVER['REMOTE_ADDR']) .

$process_button_string .= zen_draw_hidden_field(zen_session_name(), zen_session_id());

return $process_button_string;

}

20 Dec 2006, 5:30 AM
#10
redtoad avatar

redtoad

New Zenner

Join Date:
Nov 2006
Posts:
8
Plugin Contributions:
0

Re: custom payment

I'm posting my solution as a courtesy for anyone who struggles with similar issues ever.

what I ended up doing (and I know there is probably a better way to do it but hey... I've fought this long enough and arrays make me seasick) ...what I ended up doing was making a couple of loops to loop through the product array and then form one long string with the qty, model number and description that I loaded into ONE variable and then appended to my process button string. it works as I can tear the product string itself apart on the other end myself because I'm making a form handler. whee.

eta: oh and if you ever need the extra data, you can grab it by studying order.php in the classes folder. It has it ALL there.

cheers.