Reply
Highlighted
Member
Posts: 4
Registered: ‎12-07-2011

help with Merchant Defined Fields and DPM (PHP)

I'm a new developer, and new to PHP. Especially OO PHP. I've spend a while trying to figure this out on my own, but I'm totally stuck. I hope somebody can help. 

 

I'm using DPM, and it works without a merchant defined field.  My problem is I need a field related to subscription frequency. I have this in my checkout_form.php: 

 

$authorize = new AuthorizeNetAIM();
$x_freq = $authorize->setCustomField('x_freq', 'monthly');


echo AuthorizeNetDPM::getCreditCardForm($amount, $fp_sequence, $relay_response_url, $api_login_id, $transaction_key,);

 

'monthly' will be replaced with a value taken from the POST, but I have it static for now. I found that if I did not instantiate the AuthorizeNetAIM class, the code would break at the setCustomField line.

 

I have the following in relay_response.php:

 

$freq = $response->x_freq;

 

by using print_r($response) I see that my custom field is not getting passed through. I tried adding $x_freq to the getCreditCardForm call, but that didn't work. 

 

 

Highlighted
Posts: 1,609
Topics: 15
Kudos: 201
Solutions: 121
Registered: ‎06-23-2011

Re: help with Merchant Defined Fields and DPM (PHP)

You do realize you're instantiating a class of type AIM and then expecting it to work with DPM? DPM is layered on top of SIM, not AIM, and you probably need to declare as DPM anyway. Try using $authorize = new AuthorizeNetDPM() and see if it makes a difference. View source on your form and see if it adds a hidden field for x_freq.

Highlighted
Member
Posts: 4
Registered: ‎12-07-2011

Re: help with Merchant Defined Fields and DPM (PHP)

Hi, thanks for the reply. I used the AIM class because when I grep'ed the SDK files, the only place the setCustomField method was defined was in the AIM class. I tried changing the class to DPM, but the code broke: Call to undefined method AuthorizeNetDPM::setCustomField()

 

The documentation on this is kind of confusing. To set a merchant defined field in SIM, it seems you create a hidden input. I can't do that in DPM without modifying the SDK itself. All the other references I've found to creating custom fields seem to assuming AIM, becuase they involved the setCustomField method. In the SDK I only see methods relating to custom fields in the AIM part. 

 

 

Highlighted
Member
Posts: 4
Registered: ‎12-07-2011

Re: help with Merchant Defined Fields and DPM (PHP)

I also tried using the SIM class as well. Same error. 

Highlighted
Posts: 1,609
Topics: 15
Kudos: 201
Solutions: 121
Registered: ‎06-23-2011

Re: help with Merchant Defined Fields and DPM (PHP)

Well, all the getHiddenFieldString() function does is add a bunch of hidden fields:

 

$hidden_fields = $sim->getHiddenFieldString();

 

public function getHiddenFieldString()
    {
        $array = (array)$this;
        $string = "";
        foreach ($array as $key => $value) {
            if ($value) {
                $string .= '<input type="hidden" name="'.$key.'" value="'.$value.'">';
            }
        }
        return $string;
    }

 You could just modify the getCreditCardForm() function to have an additional argument for custom fields and then generate those and put them in below $hidden_fields. I can't seem to figure out a prettier way to do it.

Highlighted
Member
Posts: 4
Registered: ‎12-07-2011

Re: help with Merchant Defined Fields and DPM (PHP)

Thanks very much. It seems there's nothing simple I'm missing. I'm going to look into AIM. I think modifying the SDK will lead to future problems. 

Highlighted
Posts: 1,609
Topics: 15
Kudos: 201
Solutions: 121
Registered: ‎06-23-2011

Re: help with Merchant Defined Fields and DPM (PHP)

Just keep in mind that with AIM, the credit card data is passed through your server, unlike with DPM, so there are some additional PCI requirements. Doesn't bother me any, personally, but I thought I'd mention it. It's fairly easy to design your own form and integrate it with DPM entirely outside of the getCreditCardForm() function (basically, copy the code and then modify it for your page).