0

我正在为餐厅使用礼券脚本,以便人们可以购买礼券。该脚本捕获所有需要的信息并通过 AIM 方法将其发送到 Authorize.net。餐厅经理收到来自 Authorize.net 的电子邮件传输,其中包含交易信息。

所有主要字段都被传递到 Authorize.net。但是,我们称之为“商家定义的字段”的字段并没有出现在 Authorize.net 电子邮件传输中。我知道有一种方法可以将这些字段引用为 MDF 字段,但我无法弄清楚语法。

有人可以帮我弄清楚我遗漏了哪些行吗?

这是捕获相关字段的表单:

<form method="POST" action="cart.php">
    <fieldset>
        <div class="form-divider">
            <label>Amount</label>
            <select name="amount">
                <?php for($i=5;$i<101;$i=$i+5){ ?>
                    <option value="<?php echo $i; ?>">$<?php echo $i; ?></option>
                <?php } ?>
            </select>
        </div>
        <div class="form-divider">
            <label>Will gift certificate be mailed directly to the recipient?</label>
            <input name="gift" type="radio" value="1" onclick="$('#gift-options').show();" />
            <label>Yes</label>
            <input name="gift" type="radio" value="0" checked="checked" onclick="$('#gift-options').hide();" />
            <label>No</label>
        </div>
        <div id="gift-options">
            <div class="col1">
                <div class="form-divider">
                    <label>To</label>
                    <input name="gift-to" type="text" size="20" />
                </div>
                <div class="form-divider">
                    <label>From</label>
                    <input name="gift-from" type="text" size="20" />
                </div>
            </div>
            <div class="col2">
                <div class="form-divider">
                    <label>Ship To Address</label>
                    <textarea name="gift-address" style="width: 200px; height: 50px;"></textarea>
                </div>
                <div class="form-divider">
                    <label>Gift Message</label>
                    <textarea name="gift-message" style="width: 200px; height: 50px;"></textarea>
                </div>
            </div>
        </div>
        <div class="form-divider">
            <label>Quantity</label>
            <input name="quantity" type="text" value="1" />
        </div>
        <input type="hidden" name="action" value="add" />
    </fieldset>
    <input type="submit" value="Next Step" class="button" />
</form>

这是“结帐”代码,它收集实际发送到 Authorize.net 的数据:

<?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;
}

?>

谢谢您的帮助!!

4

1 回答 1

1

根据我看到的代码,我看不到如何添加商家定义的字段,因为它按名称添加字段并且这些字段没有名称。基本上,字段 38 之后的任何内容都是商家定义的字段,因此看起来您需要返回并破解该脚本以允许以某种方式添加商家定义的字段。可能通过添加具有 , 等的能力merchant_field_1merchant_field_2满足您的需求。

于 2012-07-23T15:52:07.680 回答