cancel
Showing results for 
Search instead for 
Did you mean: 

Fields in the Payment Gateway Response form validations

Hi everyone. I am newbie to authorize.net and using SIM for payment gateway integration using php all works fine. i am using SIM API given in developer section in testing its work fine but i have an issue related to payment form their is no validation present in the form except for the field credit card number and expiry date. and my problem is that i want to validate all other fields in the form.The form is eaisly submited with empty fields and a receipt is generate.So please help me to solve this problem that how can i validate payment gateway form..thanks

mc
Member
7 REPLIES 7

Hi,

It would be helpful to know what language you are building on. I'm going to assume PHP.

 

If I udnerstand your question correctly, you have fields such as "First Name", "Last Name", "Birth Day", etc that you want to make sure that they are filling out?

butsags
Member

ya i have these fields and i want to validate it on gateway form. and i am using PHP yes...so how can i validate the form. its urgent so please help me

butsags can you please help about this issue.

Well,

You can verify the name of your user and see if it matches the name on the credit card but i think your asking more of a fundamental question than that.

 

In your HTML, you should have a <form> tag that posts to your PHP. Inside the form tag, you should have all your inputs including your credit card number input, etc.

 

For each input, assign a name to the input. For example, if i wanted the users phone number, I would make an input such as:

<input type="text" name="phone_number" value=""  />

 

Then to get this value in the PHP, you would use $_POST["phone_number"] (Notice how phone_number is the NAME of the input. You can make the name of the input ANYTHING you want.)

 

So to use this value, you can assign it to a PHP variable:

$phone_number = $_POST["phone_number"];

 

finally, you can run some checks on the data:

 

if( trim($phone_number) == "" )

{

  echo "I'm sorry, but you forgot to fill out your phone number. Please go back and try again.";

}

else

{

  //Continue checking other fields or even charge the credit card now!

}

 

I hope this helps!

thanks for your suggestion. i want to show my code to you that as follows

 

<?php
require_once 'anet_php_sdk/AuthorizeNet.php'; // Include the SDK you downloaded in Step 2
$api_login_id = 'my id';
$transaction_key = 'my key';
$amount = $_REQUEST['amount'];
$product_name = $_REQUEST['pro_name'];
$quantity = $_REQUEST['quan'];
$email = $_REQUEST['email'];
$fp_timestamp = time();
$fp_sequence = "123" . time(); // Enter an invoice or other unique number.
$fingerprint = AuthorizeNetSIM_Form::getFingerprint($api_login_id,
$transaction_key, $amount, $fp_sequence, $fp_timestamp)
?>

<h1>Review your order</h1>
<label>Email : </label><label><?php echo $email ?></label><br />
<label>Name of the Product : </label><label><?php echo $product_name ?></label><br />
<label>Product Quantity : </label><label><?php echo $quantity ?></label><br />
<label>Product Price : </label><label><?php echo $amount ?></label><br /><br />

 

<form method='post' action="https://test.authorize.net/gateway/transact.dll">

<input type='hidden' name="x_login" value="<?php echo $api_login_id?>" />
<input type='hidden' name="x_fp_hash" value="<?php echo $fingerprint?>" />
<input type='hidden' name="x_amount" value="<?php echo $amount?>" />
<input type='hidden' name="x_fp_timestamp" value="<?php echo $fp_timestamp?>" />
<input type='hidden' name="x_fp_sequence" value="<?php echo $fp_sequence?>" />
<input type='hidden' name="x_version" value="3.1" />
<input type='hidden' name="x_show_form" value="payment_form" />
<input type='hidden' name="x_test_request" value="false" />
<input type='hidden' name="x_method" value="cc" />
<input type='hidden' name="x_receipt_link_method" value="LINK" />
<input type="hidden" name="x_receipt_link_text" value="Back to Merchant Page" />
<input type="hidden" name="x_receipt_link_url" value="http://localhost/pay/cart.php" />
<input type="hidden" name="x_color_background" value="#EBE2DA" />
<input type="hidden" name="x_email" value="<?php echo $email ?>" />
<input type="hidden" name="x_email_customer" value="TRUE" />
<input type="hidden" name="x_header_email_receipt" value="Thanks for using our services, your purchase receipt as follows :" />
<input type="hidden" name="x_footer_email_receipt" value="Regards, Team Apollo" />
<input type="hidden" name="x_description" value="Payment for the purchase of <?php echo $quantity ?> <?php echo $product_name ?>." />
<input type="hidden" name="x_relay_response" value="true" />
<input type="hidden" name="x_invoice_num" value="200012354215" />

<input type='submit' value="Pay Now!" />

</form>

 

after submit the form the page is redirect to "https://test.authorize.net/gateway/transact.dll" .....and a payment form display i want to validate that form because i have not design any extra form for payment.Is it possible to get those text box value. for validation.and i also want to save those vale in my data base except the card details is it possible..

I would suggest validating your inputs BEFORE you post your information to https://test.authorize.net/gateway/transact.dll

 

Then, if there is an error, you just give the user the error and have them resolve the problem before you continue.

 

so maybe, have a conditional branch that checks for errors and at the end of the branch, you can put the "pay now" button.

 

if( first name is not ok)

{

  echo out an error to user. Have them go back and fix it.

}

else if (last name is not ok)

{

  echo out an error to user. Have them go back and fix it.

}

else

{

  pay now button!

}

 

If you have a database, you can look inot how to talk to your database via PHP. It is absolutely possible but will take some researching.