cancel
Showing results for 
Search instead for 
Did you mean: 

Gift Certificate Form?

Greetings,

I'm trying to implement a simple gift certificate system for a restaurant.

 

I have a form that gathers buyer information, a gift message (if any), and of course the payment information.

 

I've searched and read the documentation, but I cannot find examples or tutorials showing how to hook form submissions into the Authorize.net system.

 

Currently, I'm testing out a PHP script from CodeCanyon http://codecanyon.net/item/gift-certificates/1203487).  But I'm wondering whether it might be simpler to just build the form myself?

 

Can someone point me to a complete example of hooking form submissions to the Authorize.net system?

 

Thank you very much!

8 REPLIES 8
RaynorC1emen7
Expert

RaynorC1emen7,

Thanks for the tip.

 

I've built forms and e-ecommerce systems quickly and intuitively using Stripe and payPal.  But wow -- Authorize.net's system is really overly complicated and convoluted!

Did you look at the sample code?

RaynorC1emen7,

I have a PHP script that is mostly working.  It posts transactions successfully to Authorize.net.  The script sends out an e-mail to the restaurant owner with all the transaction details, including the MDFs.

 

The problem is, the MDFs are not showing up in the e-mail that comes from Authorize.net.  How is this done?

 

Can I share my code here and ask people to look at it and tell me what lines I need to include so the MDFs are included in the e-mail receipt from Authorize.net?

 

Thank you for your help!

 

Matthew

Go ahead and post your code here. Some of the php developer here can probably help you. Just make sure to remove any confidential info/data.

Greetings RaynorC1emen7,

Thanks for the offer to help!

 

Below is the complete code for the checkout.php file, which has the main references to the fields that get sent to Authorize.net.  I may have to send another file, but let's start with this one!

 

The Merchant-Defined Fields are established in another file that is filled in during the process.  They are working, since data from those fields is making it into the confirmation e-mail sent to the merchant from the script.

 

So my question is, where in this code would I need to place the references to the merchant-defined fields in order for it to show up in the Authorize.net e-mail receipt?

 

I have tried including them with the following formats:

$a->add_field('MDF_field_name', $loader->address['billing']['MDF_field_name']);

 

And...

 

$a->add_field('MDF_field_name';

 

But neither seems to work.

 

OK, thank you ahead of time for helping.  Here's the complete checkout.php file I'm using...

 

<?php
    require 'config.php';
    session_start();
    error_reporting(E_ALL);
    ini_set('display_errors','On');
    
    include('elements/loader.php');
    
    $loader=new GiftCardLoader(true,true,true);
    if($loader->checkStep(true)){ echo '<meta http-equiv="refresh" content="0;url=cart.php"> '; }

    $amount=0;
    foreach($loader->cart as $item){
        $amount+=($item['quantity']*$item['amount']);
    }
    $method=$loader->getShippingMethod();
    $amount+=$method['price'];
    
    $a = new PDAuthorizeNet;
    
    /* Set all of the authnet info */
    $a->add_field('x_login', $x_login);
    $a->add_field('x_tran_key', $x_transkey);
    $a->add_field('x_version', '3.1');
    $a->add_field('x_type', 'AUTH_CAPTURE');
    $a->add_field('x_test_request', 'FALSE');
    $a->add_field('x_relay_response', 'FALSE');

    $a->add_field('x_delim_data', 'TRUE');
    $a->add_field('x_delim_char', '|');     
    $a->add_field('x_encap_char', '');

    /* Billing Information */
    $a->add_field('x_first_name', $loader->address['billing']['x_first_name']);
    $a->add_field('x_last_name', $loader->address['billing']['x_last_name']);
    $a->add_field('x_address', $loader->address['billing']['x_address']);
    $a->add_field('x_city', $loader->address['billing']['x_city']);
    $a->add_field('x_state', $loader->address['billing']['x_state']);
    $a->add_field('x_zip', $loader->address['billing']['x_zip']);
    $a->add_field('x_country', $loader->address['billing']['x_country']);
    $a->add_field('x_email', $loader->address['billing']['x_email']);
    
    /* Shipping Information */
    $a->add_field('x_ship_to_first_name', $loader->address['shipping']['x_first_name']);
    $a->add_field('x_ship_to_last_name', $loader->address['shipping']['x_last_name']);
    $a->add_field('x_ship_to_address', $loader->address['shipping']['x_address']);
    $a->add_field('x_ship_to_city', $loader->address['shipping']['x_city']);
    $a->add_field('x_ship_to_state', $loader->address['shipping']['x_state']);
    $a->add_field('x_ship_to_zip', $loader->address['shipping']['x_zip']);
    $a->add_field('x_ship_to_country', $loader->address['shipping']['x_country']);
    $a->add_field('x_ship_to_email', $loader->address['shipping']['x_email']);
    
    /* Credit Card Information */
    $a->add_field('x_method', 'CC');
    $a->add_field('x_card_num', $loader->sale['x_card_num']);
    $a->add_field('x_amount', $amount);
    $a->add_field('x_exp_date', $loader->sale['x_exp_date']);
    $a->add_field('x_card_code', $loader->sale['x_card_code']);
    
    $billing=$loader->address['billing'];
    $shipping=$loader->address['shipping'];
    $body ="<h3>Order Details</h3>";
    $body.="<table width='100%' cellpadding='5' border='1'>";
    $body.="<tr>";
    $body.="<td width='50%'>";
        $body.="<h3>Billing</h3>";
        $body.=$billing['x_first_name']." ".$billing['x_last_name']."<br />";
        $body.=$billing['x_email']."<br />";
        $body.=$billing['x_address']."<br />";
        if($billing['x_address2']!==""){
            $body.=$billing['x_address2']."<br />";
        }
        $body.=$billing['x_city'].", ".$billing['x_state']." ".$billing['x_zip']." ".$billing['x_country'];
    $body.="</td>";
    $body.="<td width='50%'>";
        $body.="<h3>Shipping</h3>";
        $body.=$shipping['x_first_name']." ".$shipping['x_last_name']."<br />";
        $body.=$shipping['x_email']."<br />";
        $body.=$shipping['x_address']."<br />";
        if($shipping['x_address2']!==""){
            $body.=$shipping['x_address2']."<br />";
        }
        $body.=$shipping['x_city'].", ".$shipping['x_state']." ".$shipping['x_zip']." ".$shipping['x_country'];
    $body.="</td>";
    $body.="</tr>";
    $body.="</table>";
    $body.="<p></p>";
    $body.='<table width="100%" cellpadding="5" border="1">';
        $body.='<thead>';
            $body.='<th>Product</th>';
            $body.='<th>Quantity</th>';
            $body.='<th>Price</th>';
            $body.='<th>Subtotal</th>';
        $body.='</thead>';
    foreach($loader->cart as $id=>$item){
        $body.='<tr>';
            $body.='<td>';
                $body.='Gift Card<br />';
                $body.='Amount: <strong>$'.$item['amount'].'</strong><br />';
                $body.='Is this a gift?: <strong>'.($item['gift']?"Yes":"No").'</strong>';
                if($item['gift']){
                        $body.='<br />To: <strong>'.$item['gift-options']['to'].'</strong><br />';
                        $body.='From: <strong>'.$item['gift-options']['from'].'</strong><br />';
                        $body.='Ship to address: <strong>'.$item['gift-options']['address'].'</strong><br />';
                        $body.='Personal Message: <strong>'.$item['gift-options']['message'].'</strong>';
                }
            $body.='</td>';
            $body.='<td>'.$item['quantity'].'</td>';
            $body.='<td>$'.number_format($item['amount'],2).'</td>';
            $body.='<td>$'.number_format($item['amount']*$item['quantity'],2).'</td>';
        $body.='</tr>';
    }
    $body.='<tr><td></td><td></td><td>'.$method['name'].'</td><td>$'.number_format($method['price'],2).'</td></tr>';
    $body.='<tr><td></td><td></td><td>Grand Total</td><td>$'.number_format($amount,2).'</td></tr>';
    $body.='</table>';
    
    /* Respond and stuff */
    switch ($a->process()) {
       case 1:  // Successs
            header('Location: return.php?success');
            mail($store_owner,"Gift Card Purchase",$body,"Content-Type: text/html; charset=ISO-8859-1\r\n");
            break;
       case 2:  // Declined
          header('Location: return.php?decline');
          break;
       case 3:  // Error
          header('Location: return.php?error');
          break;
    }

?>

I am having the exact same problem!

 

Why won't anyone respond to the code that Matthew posted?

It's been my experience with Authorize.net that they let any post begging for help like this one - just die.

There are lots of us out there that would LOVE to get a reply to this posted code, so we can all fix our similar problems!

 

Come on! No one? Really? Not one PHP Developer in this entire forum?

Matthew gave you all the info you could need to help him - and me - and others.

Please someone help!!!

This answer the merchant defined in email question.

http://community.developer.authorize.net/t5/Integration-and-Testing/Merchant-Defined-Fields-in-Email...

 

Option are either put it in the x_header_email_receipt or x_footer_email_receipt or send the email yourselves.