create invoice number for authorize.net

leeburstroghm 15 Sep, 2009
Chrono Froms is awesome. Good WORK!

I have purchased the A.Net plugin. I have purchased chronoforms.

I have authorize.net plugin working, everything is great, What I need to do is create an order/invoice # to send to a.net and to store in the database. I have the a.net plugin turned on for the form, I have checks for success in the on submit before email, so that an email will not be sent unless authorize.net is success. I thought that a custom form element was the best. is this correct? I need to create a unique odred# to keep track of everything. probably a YYYYMMDD-{first 4 characters of last name} something like that. Field values are not available in the custom element code. but I need authorize.net to have access to the value. I figure I create the hidden input element, before authorize.net request, create the number populate the field value, and then move on.

so how do I populate the invoice_number field in the onsubmit area??! HELP please
GreyHead 15 Sep, 2009
HI leeburstroghm,

On an ordinary form I'd do this in the OnSubmitBefore box (I don't use the authorise.net plugin but I think the flow should be the same).

I don't know what a Custom Form Element is in this context? Can you explain some more.

Bob
leeburstroghm 15 Sep, 2009
I am trying to create a value for a from element. Invoice_number for isntance.
Invoice_number is a custom form element that I created as a place holder for this value.

I need to populate this form value, before the authorize.net information is sent, with some info.

I presume that I should do all this from the on submit, where the authorize.net code is located. so here is the code in form code, before email!!:

<?php

$form{"invoce_number"] = "MY_UNIQUE_INVOCE_ID";

$MyPlugins =& CFPlugins::getInstance($MyForm->formrow->id);
$MyPlugins->runPlugin('after_email', array('ONSUBMIT', 'ONLOADONSUBMIT'), 'cf_Authorize_dotnet');
if($MyPlugins->cf_Authorize_dotnet['response_code'] == 'Approved'){
    echo  "Thank you for your purchase. You will be receiving a confirmation email shortly";
    $MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
    $MyFormEmails->setEmailData(1, 'enabled', '1');
    $MyFormEmails->sendEmails($MyForm, $MyFormEmails->emails);
  }else{
    $MyForm->addErrorMsg( 'An error occured with the Credit Card Processing:<br />'.$MyPlugins->cf_Authorize_dotnet['response_code'].': '.$MyPlugins->cf_Authorize_dotnet['response_reason_text'] );
    $MyForm->haltFunction["autogenerated_after_email"] = true;
  }
?>


So how do I get the existing form data. Like LAST NAME. or saomething and how do I set an existing form elements value! !
leeburstroghm 15 Sep, 2009
I see another post to use javascript, but If I change my form html code, it gets re-written when someone uses the wizard to make modifications. I suppose javascript would work, if I put a data field in the form. and other information I should use.
GreyHead 15 Sep, 2009
Hi leeburstroghm,

Why would you want the invoice number in the Form HTML?

PHP is fine. If you search here on JRequest you'll find several hundred examples of setting form values from the OnSubmit Before box.

Bob

PS There'ss something badly wrong with this line $form{"invoce_number"] = "MY_UNIQUE_INVOCE_ID";
leeburstroghm 15 Sep, 2009
badly wrong.. lol I know, it is just a concept thing.. lol
The invoice number needs to get emailed, and written to the database..

Is there a better way to create a number and have it emailed, on the redirect page, and written to the database?!

I also see a before and after on submit in the authorize.net plugin.

I am trying to get my head wrapped around how everything works together. Like the run order, wether to have authorize.net plugin turned on in the form plugins. or to use the form code, on submit, before emails.. ect..

I need authorize to success before emails are sent. I thought that the authorize.net plugin would already halt if there was an error. do I need to do this in the form code or the authorize.net before or after submit code?? wish there was better documentation of the flow and functionalit of chronoforms!!
GreyHead 15 Sep, 2009
Hi leeburstroghm,

Create your invoice number in OnSubmit before box and save it in the $_POST array (using JRequest::setVar()), then it's available for email, database and the plugin.

The Plugin is fairly old (I think the first Max wrote) and I'm not certain that the Before and After code boxes actually do anything (test before you use) - I just looked at the code and it does seem to be set up.

You should certainly use the Plugin rather than write your own code.

Use the Run Oder tab to make sure that the plugin runs first, then the onsubmit after, then the Autogenerated code.

Add conditional code in the OnSubmit After box to stop any further processing and issue a failure notice.

I would disable the emails in the Email set up, then re-enable and send them from the OnSubmitAfter box if needed.

Bob
leeburstroghm 15 Sep, 2009
Ok, well I did get something to work, with the custom form element, very nice.

In the form code on submit, how do I get form values??
leeburstroghm 15 Sep, 2009
I see
$Myform->formrow

I have also tried to use the authoriz.ent values, and they are not available, not invoice_num.

So how do I obtain and use the form information. in the form code, onsubmit before email. ??
leeburstroghm 15 Sep, 2009
well, this worked

JRequest::getVar('invoice_number', '', 'post')

so I am able to move on now.
This topic is locked and no more replies can be posted.